@forge/cli 0.0.0-experimental-c3effe3 → 0.0.0-experimental-820808c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -7
- package/npm-shrinkwrap.json +111 -5108
- package/out/analytics-client/analytics-client.d.ts +0 -24
- package/out/analytics-client/analytics-client.d.ts.map +1 -1
- package/out/analytics-client/analytics-client.js +0 -115
- package/out/analytics-client/analytics-message-handler.d.ts +1 -5
- package/out/analytics-client/analytics-message-handler.d.ts.map +1 -1
- package/out/analytics-client/analytics-message-handler.js +2 -30
- package/out/autocomplete/autocomplete-config.json +2 -242
- package/out/bin/cli.d.ts +0 -1
- package/out/bin/cli.d.ts.map +1 -1
- package/out/bin/cli.js +1 -4
- package/out/bin/postinstall.d.ts +0 -1
- package/out/bin/postinstall.js +1 -22
- package/out/storage/local-file-storage.d.ts +0 -2
- package/out/storage/local-file-storage.d.ts.map +1 -1
- package/out/storage/local-file-storage.js +1 -9
- package/package.json +3 -44
- package/out/autocomplete/index.d.ts +0 -5
- package/out/autocomplete/index.d.ts.map +0 -1
- package/out/autocomplete/index.js +0 -40
- package/out/autocomplete/types.d.ts +0 -14
- package/out/autocomplete/types.d.ts.map +0 -1
- package/out/autocomplete/types.js +0 -2
- package/out/autocomplete/util.d.ts +0 -6
- package/out/autocomplete/util.d.ts.map +0 -1
- package/out/autocomplete/util.js +0 -13
- package/out/command-line/anon-user-id.d.ts +0 -3
- package/out/command-line/anon-user-id.d.ts.map +0 -1
- package/out/command-line/anon-user-id.js +0 -17
- package/out/command-line/command.d.ts +0 -81
- package/out/command-line/command.d.ts.map +0 -1
- package/out/command-line/command.js +0 -382
- package/out/command-line/controller/assertUnreachable.d.ts +0 -2
- package/out/command-line/controller/assertUnreachable.d.ts.map +0 -1
- package/out/command-line/controller/assertUnreachable.js +0 -7
- package/out/command-line/controller/autocomplete-controller.d.ts +0 -12
- package/out/command-line/controller/autocomplete-controller.d.ts.map +0 -1
- package/out/command-line/controller/autocomplete-controller.js +0 -54
- package/out/command-line/controller/deploy-controller.d.ts +0 -43
- package/out/command-line/controller/deploy-controller.d.ts.map +0 -1
- package/out/command-line/controller/deploy-controller.js +0 -139
- package/out/command-line/controller/feedback-controller.d.ts +0 -9
- package/out/command-line/controller/feedback-controller.d.ts.map +0 -1
- package/out/command-line/controller/feedback-controller.js +0 -19
- package/out/command-line/controller/getNodeVersion.d.ts +0 -2
- package/out/command-line/controller/getNodeVersion.d.ts.map +0 -1
- package/out/command-line/controller/getNodeVersion.js +0 -7
- package/out/command-line/controller/install-controller.d.ts +0 -35
- package/out/command-line/controller/install-controller.d.ts.map +0 -1
- package/out/command-line/controller/install-controller.js +0 -154
- package/out/command-line/controller/lint-controller.d.ts +0 -9
- package/out/command-line/controller/lint-controller.d.ts.map +0 -1
- package/out/command-line/controller/lint-controller.js +0 -20
- package/out/command-line/controller/pre-command-controller.d.ts +0 -25
- package/out/command-line/controller/pre-command-controller.d.ts.map +0 -1
- package/out/command-line/controller/pre-command-controller.js +0 -57
- package/out/command-line/controller/prerequisites-controller.d.ts +0 -11
- package/out/command-line/controller/prerequisites-controller.d.ts.map +0 -1
- package/out/command-line/controller/prerequisites-controller.js +0 -34
- package/out/command-line/controller/settings-controller.d.ts +0 -19
- package/out/command-line/controller/settings-controller.d.ts.map +0 -1
- package/out/command-line/controller/settings-controller.js +0 -48
- package/out/command-line/controller/stubController.d.ts +0 -9
- package/out/command-line/controller/stubController.d.ts.map +0 -1
- package/out/command-line/controller/stubController.js +0 -15
- package/out/command-line/controller/tunnel-controller.d.ts +0 -14
- package/out/command-line/controller/tunnel-controller.d.ts.map +0 -1
- package/out/command-line/controller/tunnel-controller.js +0 -43
- package/out/command-line/dependency-injection.d.ts +0 -69
- package/out/command-line/dependency-injection.d.ts.map +0 -1
- package/out/command-line/dependency-injection.js +0 -188
- package/out/command-line/environment.d.ts +0 -2
- package/out/command-line/environment.d.ts.map +0 -1
- package/out/command-line/environment.js +0 -15
- package/out/command-line/errors.d.ts +0 -6
- package/out/command-line/errors.d.ts.map +0 -1
- package/out/command-line/errors.js +0 -12
- package/out/command-line/index.d.ts +0 -5
- package/out/command-line/index.d.ts.map +0 -1
- package/out/command-line/index.js +0 -66
- package/out/command-line/register-app-commands.d.ts +0 -10
- package/out/command-line/register-app-commands.d.ts.map +0 -1
- package/out/command-line/register-app-commands.js +0 -128
- package/out/command-line/register-authentication-command.d.ts +0 -16
- package/out/command-line/register-authentication-command.d.ts.map +0 -1
- package/out/command-line/register-authentication-command.js +0 -92
- package/out/command-line/register-autocomplete-commands.d.ts +0 -3
- package/out/command-line/register-autocomplete-commands.d.ts.map +0 -1
- package/out/command-line/register-autocomplete-commands.js +0 -13
- package/out/command-line/register-deployment-commands.d.ts +0 -22
- package/out/command-line/register-deployment-commands.d.ts.map +0 -1
- package/out/command-line/register-deployment-commands.js +0 -15
- package/out/command-line/register-environment-variables-commands.d.ts +0 -3
- package/out/command-line/register-environment-variables-commands.d.ts.map +0 -1
- package/out/command-line/register-environment-variables-commands.js +0 -99
- package/out/command-line/register-feedback-commands.d.ts +0 -3
- package/out/command-line/register-feedback-commands.d.ts.map +0 -1
- package/out/command-line/register-feedback-commands.js +0 -31
- package/out/command-line/register-installation-commands.d.ts +0 -6
- package/out/command-line/register-installation-commands.d.ts.map +0 -1
- package/out/command-line/register-installation-commands.js +0 -140
- package/out/command-line/register-lint-command.d.ts +0 -8
- package/out/command-line/register-lint-command.d.ts.map +0 -1
- package/out/command-line/register-lint-command.js +0 -15
- package/out/command-line/register-log-commands.d.ts +0 -4
- package/out/command-line/register-log-commands.d.ts.map +0 -1
- package/out/command-line/register-log-commands.js +0 -138
- package/out/command-line/register-providers-commands.d.ts +0 -3
- package/out/command-line/register-providers-commands.d.ts.map +0 -1
- package/out/command-line/register-providers-commands.js +0 -43
- package/out/command-line/register-settings-commands.d.ts +0 -3
- package/out/command-line/register-settings-commands.d.ts.map +0 -1
- package/out/command-line/register-settings-commands.js +0 -37
- package/out/command-line/register-tunnel-commands.d.ts +0 -3
- package/out/command-line/register-tunnel-commands.d.ts.map +0 -1
- package/out/command-line/register-tunnel-commands.js +0 -14
- package/out/command-line/register-webtrigger-commands.d.ts +0 -3
- package/out/command-line/register-webtrigger-commands.d.ts.map +0 -1
- package/out/command-line/register-webtrigger-commands.js +0 -55
- package/out/command-line/unique-machine-id.d.ts +0 -3
- package/out/command-line/unique-machine-id.d.ts.map +0 -1
- package/out/command-line/unique-machine-id.js +0 -18
- package/out/command-line/version-info.d.ts +0 -8
- package/out/command-line/version-info.d.ts.map +0 -1
- package/out/command-line/version-info.js +0 -34
- package/out/command-line/view/analytics-settings-view.d.ts +0 -7
- package/out/command-line/view/analytics-settings-view.d.ts.map +0 -1
- package/out/command-line/view/analytics-settings-view.js +0 -18
- package/out/command-line/view/deploy-view.d.ts +0 -21
- package/out/command-line/view/deploy-view.d.ts.map +0 -1
- package/out/command-line/view/deploy-view.js +0 -58
- package/out/command-line/view/install-view.d.ts +0 -18
- package/out/command-line/view/install-view.d.ts.map +0 -1
- package/out/command-line/view/install-view.js +0 -55
- package/out/command-line/view/lint-view.d.ts +0 -12
- package/out/command-line/view/lint-view.d.ts.map +0 -1
- package/out/command-line/view/lint-view.js +0 -31
- package/out/command-line/view/lite-lint-view.d.ts +0 -10
- package/out/command-line/view/lite-lint-view.d.ts.map +0 -1
- package/out/command-line/view/lite-lint-view.js +0 -18
- package/out/command-line/view/settings-view.d.ts +0 -8
- package/out/command-line/view/settings-view.d.ts.map +0 -1
- package/out/command-line/view/settings-view.js +0 -21
- package/out/command-line/view/tunnel-view.d.ts +0 -18
- package/out/command-line/view/tunnel-view.d.ts.map +0 -1
- package/out/command-line/view/tunnel-view.js +0 -89
- package/out/deploy/deployer/deploy-monitor-graphql-client.d.ts +0 -24
- package/out/deploy/deployer/deploy-monitor-graphql-client.d.ts.map +0 -1
- package/out/deploy/deployer/deploy-monitor-graphql-client.js +0 -57
- package/out/deploy/deployer/deployer.d.ts +0 -31
- package/out/deploy/deployer/deployer.d.ts.map +0 -1
- package/out/deploy/deployer/deployer.js +0 -154
- package/out/deploy/deployer/index.d.ts +0 -4
- package/out/deploy/deployer/index.d.ts.map +0 -1
- package/out/deploy/deployer/index.js +0 -6
- package/out/deploy/deployer/trigger-deploy-graphql-client.d.ts +0 -19
- package/out/deploy/deployer/trigger-deploy-graphql-client.d.ts.map +0 -1
- package/out/deploy/deployer/trigger-deploy-graphql-client.js +0 -45
- package/out/deploy/index.d.ts +0 -5
- package/out/deploy/index.d.ts.map +0 -1
- package/out/deploy/index.js +0 -7
- package/out/deploy/package-upload-deploy.d.ts +0 -18
- package/out/deploy/package-upload-deploy.d.ts.map +0 -1
- package/out/deploy/package-upload-deploy.js +0 -28
- package/out/deploy/packager/archiver.d.ts +0 -24
- package/out/deploy/packager/archiver.d.ts.map +0 -1
- package/out/deploy/packager/archiver.js +0 -62
- package/out/deploy/packager/index.d.ts +0 -3
- package/out/deploy/packager/index.d.ts.map +0 -1
- package/out/deploy/packager/index.js +0 -5
- package/out/deploy/packager/packager.d.ts +0 -35
- package/out/deploy/packager/packager.d.ts.map +0 -1
- package/out/deploy/packager/packager.js +0 -61
- package/out/deploy/uploader/artifact-graphql-client.d.ts +0 -26
- package/out/deploy/uploader/artifact-graphql-client.d.ts.map +0 -1
- package/out/deploy/uploader/artifact-graphql-client.js +0 -92
- package/out/deploy/uploader/index.d.ts +0 -3
- package/out/deploy/uploader/index.d.ts.map +0 -1
- package/out/deploy/uploader/index.js +0 -5
- package/out/deploy/uploader/uploader.d.ts +0 -19
- package/out/deploy/uploader/uploader.d.ts.map +0 -1
- package/out/deploy/uploader/uploader.js +0 -43
- package/out/environment-variables/delete-environment-variable.d.ts +0 -18
- package/out/environment-variables/delete-environment-variable.d.ts.map +0 -1
- package/out/environment-variables/delete-environment-variable.js +0 -14
- package/out/environment-variables/graphql-client.d.ts +0 -16
- package/out/environment-variables/graphql-client.d.ts.map +0 -1
- package/out/environment-variables/graphql-client.js +0 -105
- package/out/environment-variables/list-environment-variables.d.ts +0 -22
- package/out/environment-variables/list-environment-variables.d.ts.map +0 -1
- package/out/environment-variables/list-environment-variables.js +0 -14
- package/out/environment-variables/set-environment-variable.d.ts +0 -20
- package/out/environment-variables/set-environment-variable.d.ts.map +0 -1
- package/out/environment-variables/set-environment-variable.js +0 -14
- package/out/installations/graphql-client.d.ts +0 -60
- package/out/installations/graphql-client.d.ts.map +0 -1
- package/out/installations/graphql-client.js +0 -408
- package/out/installations/install-app-site.d.ts +0 -21
- package/out/installations/install-app-site.d.ts.map +0 -1
- package/out/installations/install-app-site.js +0 -19
- package/out/installations/shared.d.ts +0 -5
- package/out/installations/shared.d.ts.map +0 -1
- package/out/installations/shared.js +0 -19
- package/out/installations/uninstall-app.d.ts +0 -25
- package/out/installations/uninstall-app.d.ts.map +0 -1
- package/out/installations/uninstall-app.js +0 -43
- package/out/migration-keys/graphql-client.d.ts +0 -8
- package/out/migration-keys/graphql-client.d.ts.map +0 -1
- package/out/migration-keys/graphql-client.js +0 -55
- package/out/providers/configure-provider.d.ts +0 -19
- package/out/providers/configure-provider.d.ts.map +0 -1
- package/out/providers/configure-provider.js +0 -14
- package/out/providers/graphql-client.d.ts +0 -12
- package/out/providers/graphql-client.d.ts.map +0 -1
- package/out/providers/graphql-client.js +0 -47
- package/out/service/cached-config-service.d.ts +0 -8
- package/out/service/cached-config-service.d.ts.map +0 -1
- package/out/service/cached-config-service.js +0 -16
- package/out/service/command-suggestion-service.d.ts +0 -4
- package/out/service/command-suggestion-service.d.ts.map +0 -1
- package/out/service/command-suggestion-service.js +0 -17
- package/out/service/docker-service.d.ts +0 -24
- package/out/service/docker-service.d.ts.map +0 -1
- package/out/service/docker-service.js +0 -71
- package/out/service/installation-service.d.ts +0 -51
- package/out/service/installation-service.d.ts.map +0 -1
- package/out/service/installation-service.js +0 -89
- package/out/service/lint-service.d.ts +0 -23
- package/out/service/lint-service.d.ts.map +0 -1
- package/out/service/lint-service.js +0 -39
- package/out/service/lite-lint-service.d.ts +0 -10
- package/out/service/lite-lint-service.d.ts.map +0 -1
- package/out/service/lite-lint-service.js +0 -27
- package/out/service/migration-keys-service.d.ts +0 -19
- package/out/service/migration-keys-service.d.ts.map +0 -1
- package/out/service/migration-keys-service.js +0 -14
- package/out/service/port-finding-service.d.ts +0 -12
- package/out/service/port-finding-service.d.ts.map +0 -1
- package/out/service/port-finding-service.js +0 -34
- package/out/service/resource-packaging-service.d.ts +0 -46
- package/out/service/resource-packaging-service.d.ts.map +0 -1
- package/out/service/resource-packaging-service.js +0 -128
- package/out/service/resources-uploader-service.d.ts +0 -16
- package/out/service/resources-uploader-service.d.ts.map +0 -1
- package/out/service/resources-uploader-service.js +0 -34
- package/out/service/tunnel-analytics-service.d.ts +0 -11
- package/out/service/tunnel-analytics-service.d.ts.map +0 -1
- package/out/service/tunnel-analytics-service.js +0 -24
- package/out/service/tunnel-service.d.ts +0 -49
- package/out/service/tunnel-service.d.ts.map +0 -1
- package/out/service/tunnel-service.js +0 -190
- package/out/webtrigger/get-webtrigger-url.d.ts +0 -27
- package/out/webtrigger/get-webtrigger-url.d.ts.map +0 -1
- package/out/webtrigger/get-webtrigger-url.js +0 -26
- package/out/webtrigger/graphql-client.d.ts +0 -14
- package/out/webtrigger/graphql-client.d.ts.map +0 -1
- package/out/webtrigger/graphql-client.js +0 -52
- package/out/workers/analytics-message-worker.d.ts +0 -12
- package/out/workers/analytics-message-worker.d.ts.map +0 -1
- package/out/workers/analytics-message-worker.js +0 -29
- package/out/workers/forge-cli-workers.d.ts +0 -2
- package/out/workers/forge-cli-workers.d.ts.map +0 -1
- package/out/workers/forge-cli-workers.js +0 -21
- package/out/workers/tunnel-clean-up-worker.d.ts +0 -8
- package/out/workers/tunnel-clean-up-worker.d.ts.map +0 -1
- package/out/workers/tunnel-clean-up-worker.js +0 -31
- package/out/workers/version-check-worker.d.ts +0 -8
- package/out/workers/version-check-worker.d.ts.map +0 -1
- package/out/workers/version-check-worker.js +0 -20
- package/out/workers/worker-info.d.ts +0 -8
- package/out/workers/worker-info.d.ts.map +0 -1
- package/out/workers/worker-info.js +0 -14
- package/out/workers/worker.d.ts +0 -6
- package/out/workers/worker.d.ts.map +0 -1
- package/out/workers/worker.js +0 -7
- package/out/workers/workers-starter.d.ts +0 -5
- package/out/workers/workers-starter.d.ts.map +0 -1
- package/out/workers/workers-starter.js +0 -22
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.autocomplete = exports.processAutocompleteFactory = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const omelette_1 = tslib_1.__importDefault(require("omelette"));
|
|
6
|
-
const autocomplete_config_json_1 = tslib_1.__importDefault(require("./autocomplete-config.json"));
|
|
7
|
-
const util_1 = require("./util");
|
|
8
|
-
const autocompleteConfig = autocomplete_config_json_1.default;
|
|
9
|
-
exports.processAutocompleteFactory = (autocompleteConfig) => {
|
|
10
|
-
const processAutocomplete = (_, { line, reply }) => {
|
|
11
|
-
var _a;
|
|
12
|
-
const splitLine = line.split(' ');
|
|
13
|
-
const numArgs = splitLine.length;
|
|
14
|
-
if (numArgs === 2) {
|
|
15
|
-
if (splitLine.slice(-1)[0].startsWith('-')) {
|
|
16
|
-
reply(Object.keys(autocompleteConfig.options));
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
reply(Object.keys(autocompleteConfig.commands));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
const command = splitLine[1];
|
|
23
|
-
if (!autocompleteConfig.commands.hasOwnProperty(command)) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const commandOptions = autocompleteConfig.commands[command];
|
|
27
|
-
const lastArg = splitLine.slice(-2, -1)[0];
|
|
28
|
-
if ((_a = commandOptions[lastArg]) === null || _a === void 0 ? void 0 : _a.requireUserArg) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const userOptionsSelected = util_1.getUserOptionsSelectedFromSplitLine(splitLine);
|
|
32
|
-
const remainingOptions = util_1.getRemainingOptions(commandOptions, userOptionsSelected);
|
|
33
|
-
reply(Object.keys(remainingOptions));
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
return processAutocomplete;
|
|
37
|
-
};
|
|
38
|
-
exports.autocomplete = omelette_1.default(process.env.AUTOCOMPLETE_ALIAS || 'forge');
|
|
39
|
-
exports.autocomplete.on('complete', exports.processAutocompleteFactory(autocompleteConfig));
|
|
40
|
-
exports.autocomplete.init();
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface Option {
|
|
2
|
-
requireUserArg: boolean;
|
|
3
|
-
}
|
|
4
|
-
export interface CommandOptions {
|
|
5
|
-
[key: string]: Option;
|
|
6
|
-
}
|
|
7
|
-
export interface CommandConfig {
|
|
8
|
-
[key: string]: CommandOptions;
|
|
9
|
-
}
|
|
10
|
-
export interface AutocompleteConfig {
|
|
11
|
-
commands: CommandConfig;
|
|
12
|
-
options: CommandOptions;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/autocomplete/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;CACzB"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CommandOptions } from './types';
|
|
2
|
-
export declare const getUserOptionsSelectedFromSplitLine: (splitLine: string[]) => string[];
|
|
3
|
-
export declare const getRemainingOptions: (commandOptions: CommandOptions, userSelectedOptions: string[]) => {
|
|
4
|
-
[x: string]: import("./types").Option;
|
|
5
|
-
};
|
|
6
|
-
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/autocomplete/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,mCAAmC,cAAe,MAAM,EAAE,aAEtE,CAAC;AAEF,eAAO,MAAM,mBAAmB,mBAAoB,cAAc,uBAAuB,MAAM,EAAE;;CAQhG,CAAC"}
|
package/out/autocomplete/util.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRemainingOptions = exports.getUserOptionsSelectedFromSplitLine = void 0;
|
|
4
|
-
exports.getUserOptionsSelectedFromSplitLine = (splitLine) => {
|
|
5
|
-
return splitLine.slice(2).filter((o) => o.startsWith('--'));
|
|
6
|
-
};
|
|
7
|
-
exports.getRemainingOptions = (commandOptions, userSelectedOptions) => {
|
|
8
|
-
const commandOptionsClone = Object.assign({}, commandOptions);
|
|
9
|
-
for (const option of userSelectedOptions) {
|
|
10
|
-
delete commandOptionsClone[option];
|
|
11
|
-
}
|
|
12
|
-
return commandOptionsClone;
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anon-user-id.d.ts","sourceRoot":"","sources":["../../src/command-line/anon-user-id.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;AACnD,wBAAgB,SAAS,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAnonId = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const uuid_1 = tslib_1.__importDefault(require("uuid"));
|
|
6
|
-
const cli_shared_1 = require("@forge/cli-shared");
|
|
7
|
-
const ANON_ID_CACHE_KEY = 'anonId';
|
|
8
|
-
function getAnonId(createNew = false) {
|
|
9
|
-
const cachedConf = cli_shared_1.CachedConf.getCache('@forge/cli');
|
|
10
|
-
return cachedConf.cached(ANON_ID_CACHE_KEY, () => {
|
|
11
|
-
if (!createNew) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
return uuid_1.default();
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
exports.getAnonId = getAnonId;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import commander, { CommanderError, OutputConfiguration } from 'commander';
|
|
2
|
-
import { AnalyticsClientReporter } from '../analytics-client/analytics-client';
|
|
3
|
-
import { PersonalApiCredentialsValidated } from '@forge/cli-shared';
|
|
4
|
-
import { UI } from '@forge/cli-shared';
|
|
5
|
-
import { CLIDetails } from '@forge/cli-shared';
|
|
6
|
-
import { PreCommandController } from './controller/pre-command-controller';
|
|
7
|
-
import { StubController } from './controller/stubController';
|
|
8
|
-
declare type PreconditionCallback = (...args: any[]) => any;
|
|
9
|
-
declare type ActionResult = Promise<{
|
|
10
|
-
creds?: PersonalApiCredentialsValidated;
|
|
11
|
-
analytics: any;
|
|
12
|
-
} | void>;
|
|
13
|
-
export declare class WrapperError extends CommanderError {
|
|
14
|
-
private readonly commandName;
|
|
15
|
-
constructor(error: CommanderError, commandName: string);
|
|
16
|
-
getCommandName: () => string;
|
|
17
|
-
}
|
|
18
|
-
export interface ErrorWithAnalytics {
|
|
19
|
-
getAttributes: () => Record<string, string | string[]>;
|
|
20
|
-
}
|
|
21
|
-
export declare class Command {
|
|
22
|
-
private readonly ui;
|
|
23
|
-
private readonly analyticsClient;
|
|
24
|
-
private readonly preCommandController;
|
|
25
|
-
private readonly cliDetails;
|
|
26
|
-
private readonly expectsArguments;
|
|
27
|
-
private readonly analyticsName?;
|
|
28
|
-
get verbose(): boolean;
|
|
29
|
-
static reportHelp: (cmd: Command, cmdError: WrapperError) => Promise<undefined>;
|
|
30
|
-
private static isError;
|
|
31
|
-
private static isHelpTriggered;
|
|
32
|
-
private static isVersionTriggered;
|
|
33
|
-
private static isUnknownCommand;
|
|
34
|
-
private static isExcessCommands;
|
|
35
|
-
private static concatenateNames;
|
|
36
|
-
private readonly cmd;
|
|
37
|
-
private newCommand;
|
|
38
|
-
private requiresAuthentication;
|
|
39
|
-
private requiresAnalyticsConsent;
|
|
40
|
-
private requiredOptionFlags;
|
|
41
|
-
private preconditionFn;
|
|
42
|
-
private options;
|
|
43
|
-
private commands;
|
|
44
|
-
constructor(ui: UI, analyticsClient: AnalyticsClientReporter, preCommandController: PreCommandController, cliDetails: CLIDetails | undefined, cmd?: commander.Command, expectsArguments?: boolean, analyticsName?: string | undefined);
|
|
45
|
-
version(str: string, flags?: string): this;
|
|
46
|
-
command(name: string, opts?: commander.CommandOptions): Command;
|
|
47
|
-
deprecatedCommand(oldName: string, newName: string, stubController: StubController): void;
|
|
48
|
-
getAnalyticsName(): string | undefined;
|
|
49
|
-
deprecate(newCommand: string): this;
|
|
50
|
-
description(desc: string): this;
|
|
51
|
-
option(flags: string, description: string, defaultValue?: any): this;
|
|
52
|
-
option(flags: string, description: string, fn: (userValue: any, defaultValue?: any) => any, defaultValue?: any): this;
|
|
53
|
-
precondition(fn: PreconditionCallback): this;
|
|
54
|
-
requireManifestFile(): this;
|
|
55
|
-
requireAppId(): this;
|
|
56
|
-
nonInteractiveOption(...args: string[]): this;
|
|
57
|
-
action(fn: (...args: any[]) => ActionResult): this;
|
|
58
|
-
parse(argv: string[]): Promise<undefined>;
|
|
59
|
-
exitOverride: (listener: (err: any) => void) => this;
|
|
60
|
-
getDefinedCommands(): commander.Command[];
|
|
61
|
-
getDefinedOptions(): commander.Option[];
|
|
62
|
-
getCmdName(): string;
|
|
63
|
-
getCommands(): Command[];
|
|
64
|
-
environmentOption(): this;
|
|
65
|
-
siteAndProductOption(): this;
|
|
66
|
-
requireNoAuthentication(): this;
|
|
67
|
-
requireNoAnalyticsConsent(): this;
|
|
68
|
-
private satisfiesNonInteractiveOptions;
|
|
69
|
-
actionProcessor: (cb: (...cbArgs: any[]) => ActionResult, ...args: any[]) => Promise<void>;
|
|
70
|
-
configureOutput(obj: OutputConfiguration): this;
|
|
71
|
-
private checkPreconditions;
|
|
72
|
-
private checkAuthentication;
|
|
73
|
-
private checkVersion;
|
|
74
|
-
private validateContext;
|
|
75
|
-
private findLastValidCommand;
|
|
76
|
-
private outputRelevantHelp;
|
|
77
|
-
private unknownCommand;
|
|
78
|
-
private assertValidArgs;
|
|
79
|
-
}
|
|
80
|
-
export {};
|
|
81
|
-
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/command-line/command.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Command = exports.WrapperError = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const commander_1 = tslib_1.__importStar(require("commander"));
|
|
6
|
-
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
7
|
-
const cli_shared_1 = require("@forge/cli-shared");
|
|
8
|
-
const cli_shared_2 = require("@forge/cli-shared");
|
|
9
|
-
const cli_shared_3 = require("@forge/cli-shared");
|
|
10
|
-
const environment_1 = require("./environment");
|
|
11
|
-
const cli_shared_4 = require("@forge/cli-shared");
|
|
12
|
-
const version_info_1 = require("./version-info");
|
|
13
|
-
const anon_user_id_1 = require("./anon-user-id");
|
|
14
|
-
const errors_1 = require("./errors");
|
|
15
|
-
const command_suggestion_service_1 = tslib_1.__importDefault(require("../service/command-suggestion-service"));
|
|
16
|
-
class WrapperError extends commander_1.CommanderError {
|
|
17
|
-
constructor(error, commandName) {
|
|
18
|
-
super(error.exitCode, error.code, error.message);
|
|
19
|
-
this.getCommandName = () => this.commandName;
|
|
20
|
-
this.commandName = commandName;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.WrapperError = WrapperError;
|
|
24
|
-
const isErrorWithAnalytics = (e) => {
|
|
25
|
-
return e.getAttributes !== undefined;
|
|
26
|
-
};
|
|
27
|
-
class Command {
|
|
28
|
-
constructor(ui, analyticsClient, preCommandController, cliDetails, cmd, expectsArguments = false, analyticsName) {
|
|
29
|
-
this.ui = ui;
|
|
30
|
-
this.analyticsClient = analyticsClient;
|
|
31
|
-
this.preCommandController = preCommandController;
|
|
32
|
-
this.cliDetails = cliDetails;
|
|
33
|
-
this.expectsArguments = expectsArguments;
|
|
34
|
-
this.analyticsName = analyticsName;
|
|
35
|
-
this.requiresAuthentication = true;
|
|
36
|
-
this.requiresAnalyticsConsent = true;
|
|
37
|
-
this.requiredOptionFlags = [];
|
|
38
|
-
this.preconditionFn = [];
|
|
39
|
-
this.options = [];
|
|
40
|
-
this.commands = [];
|
|
41
|
-
this.exitOverride = (listener) => {
|
|
42
|
-
this.cmd.exitOverride((err) => listener(err));
|
|
43
|
-
return this;
|
|
44
|
-
};
|
|
45
|
-
this.actionProcessor = async (cb, ...args) => {
|
|
46
|
-
var _a, _b, _c;
|
|
47
|
-
if (this.newCommand) {
|
|
48
|
-
this.ui.error(new Error(cli_shared_3.Text.deprecate(this.newCommand)));
|
|
49
|
-
}
|
|
50
|
-
const cmdName = this.cmd.name();
|
|
51
|
-
let cred = anon_user_id_1.getAnonId(true);
|
|
52
|
-
let attributes = {};
|
|
53
|
-
try {
|
|
54
|
-
if (!this.expectsArguments && args.length > 2) {
|
|
55
|
-
throw new cli_shared_3.ValidationError(cli_shared_3.Text.extraArguments(cmdName));
|
|
56
|
-
}
|
|
57
|
-
const [options] = args;
|
|
58
|
-
if (options === null || options === void 0 ? void 0 : options.nonInteractive) {
|
|
59
|
-
if (!this.satisfiesNonInteractiveOptions(options)) {
|
|
60
|
-
throw new cli_shared_3.ValidationError(cli_shared_3.Text.nonInteractive.error.missingRequiredOption(cmdName, this.requiredOptionFlags));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (this.requiresAnalyticsConsent) {
|
|
64
|
-
await this.preCommandController.verifyAnalyticsPreferences((_a = options === null || options === void 0 ? void 0 : options.nonInteractive) !== null && _a !== void 0 ? _a : false)();
|
|
65
|
-
}
|
|
66
|
-
this.checkVersion();
|
|
67
|
-
if (this.cliDetails) {
|
|
68
|
-
attributes = { version: this.cliDetails.version, latest: this.cliDetails.latest };
|
|
69
|
-
}
|
|
70
|
-
const preconditionCheckAttributes = await this.checkPreconditions(...args);
|
|
71
|
-
attributes = Object.assign(Object.assign({}, attributes), preconditionCheckAttributes);
|
|
72
|
-
const actualCred = await this.checkAuthentication();
|
|
73
|
-
if (actualCred) {
|
|
74
|
-
cred = actualCred;
|
|
75
|
-
}
|
|
76
|
-
const result = await cb(...args);
|
|
77
|
-
if (result) {
|
|
78
|
-
attributes = Object.assign(Object.assign({}, attributes), result.analytics);
|
|
79
|
-
if (result.creds) {
|
|
80
|
-
cred = result.creds;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
this.analyticsClient.reportSuccess((_b = this.analyticsName) !== null && _b !== void 0 ? _b : cmdName, cred, attributes);
|
|
84
|
-
}
|
|
85
|
-
catch (e) {
|
|
86
|
-
if (isErrorWithAnalytics(e)) {
|
|
87
|
-
attributes = Object.assign(Object.assign({}, e.getAttributes()), attributes);
|
|
88
|
-
}
|
|
89
|
-
if (e instanceof errors_1.DeferredErrors) {
|
|
90
|
-
e.getErrors().forEach((error) => { var _a; return this.analyticsClient.reportFailure((_a = this.analyticsName) !== null && _a !== void 0 ? _a : cmdName, cred, attributes, error); });
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this.analyticsClient.reportFailure((_c = this.analyticsName) !== null && _c !== void 0 ? _c : cmdName, cred, attributes, e);
|
|
95
|
-
cli_shared_4.exitOnError(this.ui)(e);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
this.outputRelevantHelp = (argv) => {
|
|
100
|
-
this.findLastValidCommand(argv).command.outputHelp();
|
|
101
|
-
};
|
|
102
|
-
this.cmd = cmd || new commander_1.default.Command();
|
|
103
|
-
}
|
|
104
|
-
get verbose() {
|
|
105
|
-
return this.cmd.opts().verbose;
|
|
106
|
-
}
|
|
107
|
-
version(str, flags) {
|
|
108
|
-
this.cmd.version(str, flags);
|
|
109
|
-
flags = flags || '-V, --version';
|
|
110
|
-
const versionOption = new commander_1.Option(flags, 'output the version number');
|
|
111
|
-
this.options.push(versionOption);
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
command(name, opts) {
|
|
115
|
-
const cmd = this.cmd
|
|
116
|
-
.command(name, opts)
|
|
117
|
-
.allowUnknownOption(false)
|
|
118
|
-
.allowExcessArguments(false);
|
|
119
|
-
const trimmedName = name.trim();
|
|
120
|
-
const expectsArguments = trimmedName.endsWith(']') || trimmedName.endsWith('>');
|
|
121
|
-
const subCommand = new Command(this.ui, this.analyticsClient, this.preCommandController, this.cliDetails, cmd, expectsArguments, Command.concatenateNames(this.analyticsName, cmd.name()));
|
|
122
|
-
subCommand.option('--verbose', cli_shared_3.Text.optionVerbose);
|
|
123
|
-
subCommand.exitOverride((err) => {
|
|
124
|
-
throw new WrapperError(err, subCommand.cmd.name());
|
|
125
|
-
});
|
|
126
|
-
this.commands.push(subCommand);
|
|
127
|
-
return subCommand;
|
|
128
|
-
}
|
|
129
|
-
deprecatedCommand(oldName, newName, stubController) {
|
|
130
|
-
this.command(oldName, { hidden: true })
|
|
131
|
-
.requireNoAuthentication()
|
|
132
|
-
.requireNoAnalyticsConsent()
|
|
133
|
-
.action(() => stubController.run({ oldName, newName }));
|
|
134
|
-
}
|
|
135
|
-
getAnalyticsName() {
|
|
136
|
-
return this.analyticsName;
|
|
137
|
-
}
|
|
138
|
-
deprecate(newCommand) {
|
|
139
|
-
this.newCommand = newCommand;
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
description(desc) {
|
|
143
|
-
this.cmd.description(desc);
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
option(flags, description, fn, defaultValue) {
|
|
147
|
-
this.cmd.option(flags, description, fn, defaultValue);
|
|
148
|
-
const option = new commander_1.Option(flags, description);
|
|
149
|
-
if (typeof fn === 'function') {
|
|
150
|
-
option.default(defaultValue).argParser(fn);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
option.default(fn);
|
|
154
|
-
}
|
|
155
|
-
this.options.push(option);
|
|
156
|
-
return this;
|
|
157
|
-
}
|
|
158
|
-
precondition(fn) {
|
|
159
|
-
this.preconditionFn.push(fn);
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
requireManifestFile() {
|
|
163
|
-
this.precondition(this.preCommandController.verifyManifestExists());
|
|
164
|
-
return this;
|
|
165
|
-
}
|
|
166
|
-
requireAppId() {
|
|
167
|
-
this.precondition(this.preCommandController.verifyManifestExistsWithAppConfig());
|
|
168
|
-
return this;
|
|
169
|
-
}
|
|
170
|
-
nonInteractiveOption(...args) {
|
|
171
|
-
this.requiredOptionFlags = args;
|
|
172
|
-
this.cmd.option('--non-interactive', cli_shared_3.Text.nonInteractive.description);
|
|
173
|
-
return this;
|
|
174
|
-
}
|
|
175
|
-
action(fn) {
|
|
176
|
-
this.cmd.action((...args) => this.actionProcessor(fn, ...args));
|
|
177
|
-
return this;
|
|
178
|
-
}
|
|
179
|
-
async parse(argv) {
|
|
180
|
-
try {
|
|
181
|
-
this.assertValidArgs(argv);
|
|
182
|
-
this.cmd.parse(argv);
|
|
183
|
-
}
|
|
184
|
-
catch (err) {
|
|
185
|
-
if (Command.isHelpTriggered(err)) {
|
|
186
|
-
if (Command.isError(err)) {
|
|
187
|
-
this.outputRelevantHelp(argv);
|
|
188
|
-
}
|
|
189
|
-
return Command.reportHelp(this, err);
|
|
190
|
-
}
|
|
191
|
-
if (Command.isVersionTriggered(err)) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (Command.isUnknownCommand(err) || Command.isExcessCommands(err)) {
|
|
195
|
-
this.unknownCommand(argv);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
return cli_shared_4.exitOnError(this.ui)(err);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
getDefinedCommands() {
|
|
202
|
-
return this.cmd.commands;
|
|
203
|
-
}
|
|
204
|
-
getDefinedOptions() {
|
|
205
|
-
return this.options;
|
|
206
|
-
}
|
|
207
|
-
getCmdName() {
|
|
208
|
-
return this.cmd.name();
|
|
209
|
-
}
|
|
210
|
-
getCommands() {
|
|
211
|
-
return this.commands;
|
|
212
|
-
}
|
|
213
|
-
environmentOption() {
|
|
214
|
-
this.option('-e, --environment [environment]', cli_shared_3.Text.env.option(cli_shared_2.DEFAULT_ENVIRONMENT_OPTION, cli_shared_2.VALID_ENVIRONMENT_OPTIONS));
|
|
215
|
-
this.precondition(() => {
|
|
216
|
-
this.cmd.opts().environment = environment_1.checkEnvironmentOption(this.cmd.opts().environment || cli_shared_2.DEFAULT_ENVIRONMENT_OPTION);
|
|
217
|
-
return { appEnv: this.cmd.opts().environment };
|
|
218
|
-
});
|
|
219
|
-
return this;
|
|
220
|
-
}
|
|
221
|
-
siteAndProductOption() {
|
|
222
|
-
this.option('-s, --site [site]', cli_shared_3.Text.optionSite);
|
|
223
|
-
this.option('-p, --product [product]', cli_shared_3.Text.optionProduct(cli_shared_2.SUPPORTED_PRODUCTS));
|
|
224
|
-
this.precondition(() => {
|
|
225
|
-
return this.validateContext();
|
|
226
|
-
});
|
|
227
|
-
return this;
|
|
228
|
-
}
|
|
229
|
-
requireNoAuthentication() {
|
|
230
|
-
this.requiresAuthentication = false;
|
|
231
|
-
return this;
|
|
232
|
-
}
|
|
233
|
-
requireNoAnalyticsConsent() {
|
|
234
|
-
this.requiresAnalyticsConsent = false;
|
|
235
|
-
return this;
|
|
236
|
-
}
|
|
237
|
-
satisfiesNonInteractiveOptions(options) {
|
|
238
|
-
const optionKeys = Object.keys(options);
|
|
239
|
-
const requiredOptionKeys = [...this.requiredOptionFlags.map((arg) => new commander_1.Option(arg).attributeName())];
|
|
240
|
-
return requiredOptionKeys.every((requiredOption) => optionKeys.includes(requiredOption));
|
|
241
|
-
}
|
|
242
|
-
configureOutput(obj) {
|
|
243
|
-
this.cmd.configureOutput(obj);
|
|
244
|
-
return this;
|
|
245
|
-
}
|
|
246
|
-
async checkPreconditions(...args) {
|
|
247
|
-
let attributes = {};
|
|
248
|
-
for (const precondition of this.preconditionFn) {
|
|
249
|
-
const extra = await precondition(...args);
|
|
250
|
-
attributes = Object.assign(Object.assign({}, attributes), extra);
|
|
251
|
-
}
|
|
252
|
-
return attributes;
|
|
253
|
-
}
|
|
254
|
-
async checkAuthentication() {
|
|
255
|
-
if (this.requiresAuthentication) {
|
|
256
|
-
const credentialsGetter = cli_shared_1.getCredentialsStoreProvider(this.ui);
|
|
257
|
-
return credentialsGetter.getCredentials();
|
|
258
|
-
}
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
checkVersion() {
|
|
262
|
-
if (!this.cliDetails ||
|
|
263
|
-
!this.cliDetails.latest ||
|
|
264
|
-
!semver_1.default.valid(this.cliDetails.version) ||
|
|
265
|
-
!semver_1.default.valid(this.cliDetails.latest)) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
if (semver_1.default.gt(this.cliDetails.latest, this.cliDetails.version)) {
|
|
269
|
-
this.ui.warn(cli_shared_3.Text.error.outdatedCLIVersion(this.cliDetails.version, this.cliDetails.latest));
|
|
270
|
-
}
|
|
271
|
-
else if (semver_1.default.gt(this.cliDetails.version, this.cliDetails.latest)) {
|
|
272
|
-
version_info_1.clearVersionCache(this.cliDetails.name);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
async validateContext() {
|
|
276
|
-
if (this.cmd.opts().product) {
|
|
277
|
-
const capitalizedProduct = cli_shared_2.capitalizeProduct(this.cmd.opts().product);
|
|
278
|
-
if (!cli_shared_2.isSuppportedProduct(capitalizedProduct)) {
|
|
279
|
-
throw new cli_shared_3.ValidationError(cli_shared_3.Text.error.invalidProduct);
|
|
280
|
-
}
|
|
281
|
-
this.cmd.opts().product = capitalizedProduct;
|
|
282
|
-
}
|
|
283
|
-
let trySite;
|
|
284
|
-
if (this.cmd.opts().site) {
|
|
285
|
-
trySite = this.cmd.opts().site;
|
|
286
|
-
}
|
|
287
|
-
this.cmd.opts().site = trySite ? cli_shared_2.validateSite(trySite) : undefined;
|
|
288
|
-
return { product: this.cmd.opts().product };
|
|
289
|
-
}
|
|
290
|
-
findLastValidCommand(argv) {
|
|
291
|
-
let command = this.cmd;
|
|
292
|
-
for (const [index, arg] of argv.slice(2).entries()) {
|
|
293
|
-
const commandMatch = command.commands.find((cmd) => cmd.name() === arg);
|
|
294
|
-
if (!commandMatch) {
|
|
295
|
-
return {
|
|
296
|
-
command,
|
|
297
|
-
index: index + 1
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
command = commandMatch;
|
|
301
|
-
}
|
|
302
|
-
return {
|
|
303
|
-
command,
|
|
304
|
-
index: 1
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
unknownCommand(argv) {
|
|
308
|
-
const errorMessage = [];
|
|
309
|
-
const { command: lastCommand, index: lastCommandIndex } = this.findLastValidCommand(argv);
|
|
310
|
-
const badLastArg = argv[lastCommandIndex + 1];
|
|
311
|
-
const suggestionService = new command_suggestion_service_1.default();
|
|
312
|
-
const suggestions = suggestionService.getSuggestions(badLastArg, lastCommand.commands
|
|
313
|
-
.filter((cmd) => {
|
|
314
|
-
return cmd._hidden !== true;
|
|
315
|
-
})
|
|
316
|
-
.map((cmd) => cmd.name()));
|
|
317
|
-
errorMessage.push(cli_shared_3.Text.invalidCmd(argv.slice(2, lastCommandIndex + 2).join(' ')));
|
|
318
|
-
if (suggestions.length) {
|
|
319
|
-
errorMessage.push(`Did you mean:`);
|
|
320
|
-
const suggestionsPrefixed = suggestions.map((suggestion) => [...argv.slice(2, lastCommandIndex + 1), suggestion].join(' '));
|
|
321
|
-
errorMessage.push(suggestionsPrefixed.join('\n'));
|
|
322
|
-
errorMessage.push(cli_shared_3.Text.invalidCmdHelp);
|
|
323
|
-
this.ui.info(errorMessage.join('\n\n'));
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
errorMessage.push(cli_shared_3.Text.invalidCmdHelp);
|
|
327
|
-
this.ui.error(new Error(errorMessage.join(' ')));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
assertValidArgs(argv) {
|
|
331
|
-
const args = argv.slice(2);
|
|
332
|
-
let commands = this.cmd.commands;
|
|
333
|
-
while (args[0] && !args[0].startsWith('-')) {
|
|
334
|
-
if (args[0] === 'help') {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
const commandMatch = commands.find((cmd) => cmd.name() === args[0]);
|
|
338
|
-
if (!commandMatch) {
|
|
339
|
-
throw new commander_1.default.CommanderError(1, 'commander.unknownCommand', `error: unknown command '${args[0]}'.`);
|
|
340
|
-
}
|
|
341
|
-
commands = commandMatch.commands;
|
|
342
|
-
args.shift();
|
|
343
|
-
if (commands.length === 0) {
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
exports.Command = Command;
|
|
350
|
-
Command.reportHelp = async (cmd, cmdError) => {
|
|
351
|
-
try {
|
|
352
|
-
let cred = anon_user_id_1.getAnonId(true);
|
|
353
|
-
try {
|
|
354
|
-
const credentialsGetter = cli_shared_1.getCredentialsStoreProvider(cmd.ui);
|
|
355
|
-
cred = await credentialsGetter.getCredentials();
|
|
356
|
-
}
|
|
357
|
-
catch (noTokenError) {
|
|
358
|
-
}
|
|
359
|
-
cmd.analyticsClient.reportSuccess('help', cred, { command: cmdError.getCommandName() });
|
|
360
|
-
}
|
|
361
|
-
catch (err) {
|
|
362
|
-
}
|
|
363
|
-
return;
|
|
364
|
-
};
|
|
365
|
-
Command.isError = (cmdError) => {
|
|
366
|
-
return cmdError.exitCode === 1;
|
|
367
|
-
};
|
|
368
|
-
Command.isHelpTriggered = (cmdError) => {
|
|
369
|
-
return ['commander.helpDisplayed', 'commander.help'].includes(cmdError.code);
|
|
370
|
-
};
|
|
371
|
-
Command.isVersionTriggered = (cmdError) => {
|
|
372
|
-
return 'commander.version' === cmdError.code;
|
|
373
|
-
};
|
|
374
|
-
Command.isUnknownCommand = (cmdError) => {
|
|
375
|
-
return cmdError.code === 'commander.unknownCommand';
|
|
376
|
-
};
|
|
377
|
-
Command.isExcessCommands = (cmdError) => {
|
|
378
|
-
return cmdError.code === 'commander.excessArguments';
|
|
379
|
-
};
|
|
380
|
-
Command.concatenateNames = (parent, subcommand) => {
|
|
381
|
-
return parent ? `${parent}:${subcommand}` : subcommand;
|
|
382
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertUnreachable.d.ts","sourceRoot":"","sources":["../../../src/command-line/controller/assertUnreachable.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAEjD"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { UI } from '@forge/cli-shared';
|
|
2
|
-
export declare enum Argument {
|
|
3
|
-
install = "install",
|
|
4
|
-
uninstall = "uninstall"
|
|
5
|
-
}
|
|
6
|
-
export declare function assertNodeVersionSupported(version?: string): void;
|
|
7
|
-
export declare class AutocompleteController {
|
|
8
|
-
private readonly ui;
|
|
9
|
-
constructor(ui: UI);
|
|
10
|
-
run(arg: string): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=autocomplete-controller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-controller.d.ts","sourceRoot":"","sources":["../../../src/command-line/controller/autocomplete-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,EAAE,EAAmB,MAAM,mBAAmB,CAAC;AAK9D,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,SAAS,cAAc;CACxB;AAQD,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,MAAyB,GAAG,IAAI,CAInF;AAED,qBAAa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,EAAE;IAEtB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAwB7C"}
|