@amplitude/ampli
Version:
Amplitude CLI
97 lines (94 loc) • 6.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = require("chalk");
const lodash_1 = require("lodash");
const string_1 = require("../util/string");
const icons_1 = require("../ui/icons");
const runtime_1 = require("../util/runtime");
const { bold: b, red: r, white: w, yellow: y, } = chalk_1.default;
const by = b.yellow;
function mayBeSpecific(text) {
return (specific) => (specific
? `${text} ${specific}`
: text);
}
const USER_ERROR_MESSAGES = Object.freeze({
folderNotInitialized: `\
Ampli has not been initialized in this folder. To initialize, run ${b('ampli init')} in the project's root folder.`,
pullRequiresSourceOnFirstRun: (sources) => {
const exampleSource = sources && sources.length > 0 ? sources[0] : '<source-name>';
const helpText = !lodash_1.isEmpty(sources)
? `
${icons_1.ICON_RETURN_ARROW} ${b(`ampli pull ${exampleSource}`)} pulls the "${exampleSource}" source.
${icons_1.ICON_RETURN_ARROW} ${b('ampli source')} lists all available sources.`
: `
${icons_1.ICON_RETURN_ARROW} There are no sources in your tracking plan. Add a new source on the website to continue.`;
return `${b('ampli pull')} requires you specify a ${b('source')} on first run.${helpText}`;
},
runPullBefore: (command) => `\
Before running ${b(`ampli ${command}`)}, run ${b('ampli pull')} to pull down your tracking library.`,
branchDoesNotExist: (branchName) => `\
Unable to find branch ${b(branchName)}. Try one of the following commands.
${icons_1.ICON_RETURN_ARROW} ${b('ampli checkout')} to select from active branches.
${icons_1.ICON_RETURN_ARROW} ${b('ampli branch')} lists all active branches and then ${b('ampli pull -b [branch]')}.`,
defaultBranchDoesNotExist: 'Unable to find the default branch.',
branchDoesNotMatchExpected: (expectedBranch, actualBranch) => `\
Expected tracking plan to be on branch ${b(expectedBranch)} but currently on ${b(actualBranch)}.
${icons_1.ICON_RETURN_ARROW} ${b(`ampli pull -b ${expectedBranch}`)} to pull the expected branch.`,
versionDoesNotExist: (versionNumber) => `Version ${b(versionNumber)} does not exist in your account.`,
versionNotFoundOnServer: (versionId) => `Version ${b(versionId)} not found on server.`,
versionDoesNotExistOnBranch: (semver, branchName, latestVersion) => `\
Version ${b(semver)} does not exist on branch ${b(branchName)}.${latestVersion
? `\nLatest version is: ${b(latestVersion)}` : ''}`,
fixAmpliConfigToContinue: (configPath, command) => `\
Error reading ${b(configPath)} file. Resolve using one of the following options.
${icons_1.ICON_RETURN_ARROW} Fix ${b(configPath)} file manually, then re-run the command.
${icons_1.ICON_RETURN_ARROW} Delete ${b(configPath)} file, then re-run ${b(`ampli ${command}`)}`,
settingsFailedToLoad: (configPath, command) => `\
Error reading ${b(configPath)} file. Resolve using one of the following options.
${icons_1.ICON_RETURN_ARROW} Fix ${b(configPath)} file manually, then re-run the command.
${icons_1.ICON_RETURN_ARROW} Run ${b(`ampli ${command}`)} to reinitialize configuration.`,
settingsContainMergeConflict: (configPath) => `\
Merge conflicts found in ${b(configPath)} configuration file.
${icons_1.ICON_RETURN_ARROW} Resolve merge conflicts to continue.`,
sourceDoesNotExist: (sourceName) => `Source ${b(sourceName)} does not exist in your account.`,
sourceHasNoEvents: (sourceName) => `There are no events associated with source ${b(sourceName)}.`,
unsupportedRuntime: (runtimeId) => `\
Unsupported runtime '${runtimeId}'. Try updating to the latest version.
${by(`brew upgrade ampli`) + w(` OR `) + by(`npm install [-g] @amplitude/ampli`)}`,
unauthorized: mayBeSpecific(`Authentication failed. Try running ${b('ampli login')} to login.`),
badRequest: `There was an error processing your request. Please try ${b('ampli login')} to login again.`,
notLoggedInYet: `You are not logged in. Run ${b('ampli login')} to authenticate.`,
expiredAuthentication: `Your authentication has expired or there was a problem authenticating. Please run ${b('ampli login')} to log back in.`,
unexpectedError: mayBeSpecific(`\
An unexpected error occurred. \
Our team has been notified, but you can also reach us anytime at ${b('https://support.amplitude.com')}.`),
updateNode: (requiredVersion = '12.16.3 LTS') => y(`\
WARNING: ampli is built for Node ${requiredVersion} and above. \
Running on older versions may result in errors. \
Please update Node for the best experience.`),
verifyRequiredCommandNotFound: mayBeSpecific(`\
Required dependency not found. Install missing command to continue.`),
verifyResultsContainErrors: (errors) => {
const an = string_1.pluralize(errors, '', 'an ');
const the = string_1.pluralize(errors, 'all', 'the');
const s = string_1.pluralizeS(errors);
return `\
One or more files had ${an}error${s} during verification. Resolve ${the} error${s} and try again.
${errors.map(e => r(b(` › ${e.location}: ${e.message}`))).join(`\n`)}
See something unexpected? Please let us know at ${b(`https://support.amplitude.com`)}.`;
},
userDoesntHaveAccessToWorkspace: `\
Current user doesn't have access to the workspace in ${b('ampli.json')}. \
Run ${b('ampli login')} to login as another user. You may need to ${b('ampli logout')} first.`,
workspaceNoLongerExist: `\
Unable to load workspace, it's possible it no longer exists. \
You can try deleting the ${b('ampli.json')} file, and running ${b(`ampli pull`)} again.`,
runtimeDoesNotMatchExpected: (actualRuntime) => `\
Runtime has been changed to ${b(`${runtime_1.getRuntimeDisplayString({ platformName: actualRuntime.platform.name, languageName: actualRuntime.language.name })}`)}.
Run ${b(`ampli pull`)} to pull down updated tracking library.`,
versionIsNotLatest: (branchName, latestVersion, currentVersion) => `\
Branch ${b(branchName)} latest version is ${b(latestVersion)}. You are on ${b(currentVersion)}. Run ${b('ampli pull')} to update.`,
unknownZone: (zone) => `Unknown zone ${b(zone)}.`,
});
exports.default = USER_ERROR_MESSAGES;