@forge/cli 6.4.3 → 6.5.0-next.9

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/npm-shrinkwrap.json +104 -101
  3. package/out/autocomplete/autocomplete-config.json +7 -30
  4. package/out/command-line/command.d.ts +63 -40
  5. package/out/command-line/command.d.ts.map +1 -1
  6. package/out/command-line/command.js +133 -128
  7. package/out/command-line/controller/feedback-controller.d.ts +3 -3
  8. package/out/command-line/controller/feedback-controller.d.ts.map +1 -1
  9. package/out/command-line/controller/feedback-controller.js +3 -4
  10. package/out/command-line/controller/prerequisites-controller.d.ts +6 -1
  11. package/out/command-line/controller/prerequisites-controller.d.ts.map +1 -1
  12. package/out/command-line/controller/prerequisites-controller.js +9 -1
  13. package/out/command-line/dependency-injection.d.ts +3 -1
  14. package/out/command-line/dependency-injection.d.ts.map +1 -1
  15. package/out/command-line/dependency-injection.js +11 -6
  16. package/out/command-line/index.d.ts +1 -2
  17. package/out/command-line/index.d.ts.map +1 -1
  18. package/out/command-line/index.js +10 -26
  19. package/out/command-line/register-app-commands.d.ts +2 -2
  20. package/out/command-line/register-app-commands.d.ts.map +1 -1
  21. package/out/command-line/register-app-commands.js +3 -1
  22. package/out/command-line/register-authentication-command.d.ts +2 -2
  23. package/out/command-line/register-authentication-command.d.ts.map +1 -1
  24. package/out/command-line/register-authentication-command.js +2 -1
  25. package/out/command-line/register-contributors-commands.d.ts.map +1 -1
  26. package/out/command-line/register-contributors-commands.js +2 -1
  27. package/out/command-line/register-environment-commands.d.ts +6 -0
  28. package/out/command-line/register-environment-commands.d.ts.map +1 -0
  29. package/out/command-line/register-environment-commands.js +35 -0
  30. package/out/command-line/register-installation-commands.d.ts +4 -2
  31. package/out/command-line/register-installation-commands.d.ts.map +1 -1
  32. package/out/command-line/register-installation-commands.js +6 -8
  33. package/out/command-line/register-lint-command.js +1 -1
  34. package/out/command-line/register-log-commands.d.ts +1 -1
  35. package/out/command-line/register-log-commands.d.ts.map +1 -1
  36. package/out/command-line/register-log-commands.js +4 -3
  37. package/out/command-line/register-providers-commands.d.ts.map +1 -1
  38. package/out/command-line/register-providers-commands.js +2 -1
  39. package/out/command-line/sentry.js +1 -1
  40. package/out/environment/create-environment.d.ts +17 -0
  41. package/out/environment/create-environment.d.ts.map +1 -0
  42. package/out/environment/create-environment.js +14 -0
  43. package/out/environment/graphql-client.d.ts +8 -0
  44. package/out/environment/graphql-client.d.ts.map +1 -0
  45. package/out/environment/graphql-client.js +47 -0
  46. package/out/service/tunnel-service.d.ts.map +1 -1
  47. package/out/service/tunnel-service.js +2 -0
  48. package/package.json +11 -10
@@ -1,9 +1,10 @@
1
- import commander, { CommanderError, OutputConfiguration } from 'commander';
1
+ import commander, { CommanderError } from 'commander';
2
+ import { CamelCase } from 'type-fest';
2
3
  import { AnalyticsClientReporter } from '../analytics-client/analytics-client';
3
- import { UI, CLIDetails, PersonalApiCredentialsValidated } from '@forge/cli-shared';
4
+ import { Logger, CLIDetails, CredentialGetter, PersonalApiCredentialsValidated } from '@forge/cli-shared';
4
5
  import { PreCommandController } from './controller/pre-command-controller';
6
+ import * as autocomplete from '../autocomplete/types';
5
7
  import { StubController } from './controller/stubController';
6
- declare type PreconditionCallback = (...args: any[]) => any;
7
8
  declare type ActionResult = Promise<{
8
9
  creds?: PersonalApiCredentialsValidated;
9
10
  analytics: any;
@@ -13,15 +14,36 @@ export declare class WrapperError extends CommanderError {
13
14
  constructor(error: CommanderError, commandName: string);
14
15
  getCommandName: () => string;
15
16
  }
16
- export declare class Command {
17
+ declare type AnyOpts = {};
18
+ declare type ParseOpts<OptsStr extends string, Default extends string | boolean | undefined = undefined> = OptsStr extends `-${infer _}, --${infer Rest}` ? ParseOpts<`--${Rest}`, Default> : OptsStr extends `--${infer Flag} [${infer _}...]` ? {
19
+ [k in CamelCase<Flag>]: [string] | Default;
20
+ } : OptsStr extends `--${infer Flag} <${infer _}...>` ? {
21
+ [k in CamelCase<Flag>]: [string] | Default;
22
+ } : OptsStr extends `--${infer Flag} [${infer _}]` ? {
23
+ [k in CamelCase<Flag>]: string | Default;
24
+ } : OptsStr extends `--${infer Flag} <${infer _}>` ? {
25
+ [k in CamelCase<Flag>]: string | Default;
26
+ } : OptsStr extends `--no-${infer Flag}` ? Default extends undefined ? {
27
+ [k in CamelCase<Flag>]: boolean;
28
+ } : never : OptsStr extends `--${infer Flag}` ? Default extends boolean ? {
29
+ [k in CamelCase<Flag>]: boolean;
30
+ } : Default extends undefined ? {
31
+ [k in CamelCase<Flag>]?: boolean;
32
+ } : never : never;
33
+ export declare type DefaultOpts = {
34
+ verbose?: boolean;
35
+ };
36
+ declare type AnyArgs = string[];
37
+ declare type ParseArgs<ArgsStr extends string> = ArgsStr extends `${infer _} ${infer Rest}` ? [string, ...ParseArgs<Rest>] : [];
38
+ declare type ActionArgs<Args extends AnyArgs, Opts extends AnyOpts> = [...Args, Opts];
39
+ declare type PreconditionCallback<Args extends AnyArgs, Opts extends AnyOpts, MoreOpts> = (...args: ActionArgs<Args, Opts>) => Promise<MoreOpts>;
40
+ export declare class Command<Args extends AnyArgs = [], Opts extends AnyOpts = DefaultOpts> {
17
41
  private readonly ui;
18
42
  private readonly analyticsClient;
19
43
  private readonly preCommandController;
20
44
  private readonly cliDetails;
21
- private readonly expectsArguments;
22
- private readonly analyticsName?;
45
+ private readonly credentialStore;
23
46
  get verbose(): boolean;
24
- static reportHelp: (cmd: Command, cmdError: WrapperError) => Promise<undefined>;
25
47
  private static isError;
26
48
  private static isHelpTriggered;
27
49
  private static isVersionTriggered;
@@ -29,48 +51,49 @@ export declare class Command {
29
51
  private static isExcessCommands;
30
52
  private static concatenateNames;
31
53
  private readonly cmd;
32
- private newCommand;
33
- private requiresAuthentication;
34
- private requiresAnalyticsConsent;
35
- private requiredOptionFlags;
36
- private preconditionFn;
37
- private options;
38
- private commands;
39
- constructor(ui: UI, analyticsClient: AnalyticsClientReporter, preCommandController: PreCommandController, cliDetails: CLIDetails | undefined, cmd?: commander.Command, expectsArguments?: boolean, analyticsName?: string | undefined);
40
- version(str: string, flags?: string): this;
41
- command(name: string, opts?: commander.CommandOptions): Command;
54
+ private readonly analyticsName;
55
+ private readonly requiresAuthentication;
56
+ private readonly requiresAnalyticsConsent;
57
+ private readonly requiredOptionFlags;
58
+ private readonly preconditionFn;
59
+ static program(ui: Logger, analyticsClient: AnalyticsClientReporter, preCommandController: PreCommandController, cliDetails: CLIDetails | undefined, credentialStore: CredentialGetter): Command<[], DefaultOpts>;
60
+ private constructor();
61
+ private clone;
62
+ version(str: string, flags?: string): Command<Args, Opts>;
63
+ command<ArgsStr extends string>(name: ArgsStr, opts?: commander.CommandOptions): Command<ParseArgs<ArgsStr>, DefaultOpts>;
42
64
  deprecatedCommand(oldName: string, newName: string, stubController: StubController): void;
43
- getAnalyticsName(): string | undefined;
44
- deprecate(newCommand: string): this;
45
- description(desc: string): this;
46
- option(flags: string, description: string, defaultValue?: any): this;
47
- option(flags: string, description: string, fn: (userValue: any, defaultValue?: any) => any, defaultValue?: any): this;
48
- precondition(fn: PreconditionCallback): this;
49
- requireManifestFile(): this;
50
- requireAppId(): this;
51
- nonInteractiveOption(...args: string[]): this;
52
- action(fn: (...args: any[]) => ActionResult): this;
53
- parse(argv: string[]): Promise<undefined>;
54
- exitOverride: (listener: (err: any) => void) => this;
55
- getDefinedCommands(): commander.Command[];
56
- getDefinedOptions(): commander.Option[];
57
- getCmdName(): string;
58
- getCommands(): Command[];
59
- environmentOption(): this;
60
- jsonOption(): this;
61
- requireNoAuthentication(): this;
62
- requireNoAnalyticsConsent(): this;
65
+ description(desc: string): Command<Args, Opts>;
66
+ option<OptsStr extends string, Default extends string | boolean | undefined = undefined>(flags: OptsStr, description: string, defaultValue?: Default): Command<Args, Opts & ParseOpts<OptsStr, Default>>;
67
+ precondition(fn: PreconditionCallback<Args, Opts, void>): Command<Args, Opts>;
68
+ precondition<More extends AnyOpts>(fn: PreconditionCallback<Args, Opts, More>): Command<Args, Opts & More>;
69
+ requireManifestFile(): Command<Args, Opts>;
70
+ requireAppId(): Command<Args, Opts>;
71
+ nonInteractiveOption(...args: string[]): Command<Args, Opts & {
72
+ nonInteractive?: boolean;
73
+ }>;
74
+ action(fn: (...args: ActionArgs<Args, Opts>) => ActionResult): Command<Args, Opts>;
75
+ parse(argv: string[]): Promise<void>;
76
+ environmentOption(): Command<Args, Opts & {
77
+ environment: string;
78
+ }>;
79
+ jsonOption(): Command<Args, Opts & {
80
+ json: boolean;
81
+ }>;
82
+ requireNoAuthentication(): Command<Args, Opts>;
83
+ requireNoAnalyticsConsent(): Command<Args, Opts>;
63
84
  private satisfiesNonInteractiveOptions;
64
- actionProcessor: (cb: (...cbArgs: any[]) => ActionResult, ...args: any[]) => Promise<void>;
65
- configureOutput(obj: OutputConfiguration): this;
85
+ actionProcessor: (cb: (...cbArgs: ActionArgs<Args, Opts>) => ActionResult, ...args: ActionArgs<Args, Opts>) => Promise<void>;
66
86
  private checkPreconditions;
67
87
  private checkAuthentication;
68
88
  private checkVersion;
69
89
  private isLatestVersion;
70
90
  private findLastValidCommand;
71
- private outputRelevantHelp;
91
+ outputRelevantHelp(argv: string[]): void;
92
+ reportHelp(cmdError: WrapperError): Promise<void>;
72
93
  private unknownCommand;
73
94
  private assertValidArgs;
95
+ getAutocompleteConfig(): autocomplete.AutocompleteConfig;
74
96
  }
97
+ export declare function getAutocompleteConfig(cmd: commander.Command): autocomplete.AutocompleteConfig;
75
98
  export {};
76
99
  //# sourceMappingURL=command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/command-line/command.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,cAAc,EAAU,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAEL,EAAE,EAGF,UAAU,EAGV,+BAA+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A;KAAE,CAAC;IAUlE,UAAU,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAIrD,uBAAuB,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC;IAI9C,yBAAyB,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC;IAIvD,OAAO,CAAC,8BAA8B;IAW/B,eAAe,mBACJ,WAAW,IAAI,EAAE,IAAI,CAAC,4BAC7B,WAAW,IAAI,EAAE,IAAI,CAAC,mBA0F/B;YAGY,kBAAkB;YAUlB,mBAAmB;IAQjC,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,oBAAoB;IAyBrB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;IAIlC,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;YAehD,cAAc;IAqC5B,OAAO,CAAC,eAAe;IA0BvB,qBAAqB,IAAI,YAAY,CAAC,kBAAkB;CAGzD;AAiCD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,SAAS,CAAC,OAAO,GAAG,YAAY,CAAC,kBAAkB,CAY7F"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Command = exports.WrapperError = void 0;
3
+ exports.getAutocompleteConfig = exports.Command = exports.WrapperError = void 0;
5
4
  const tslib_1 = require("tslib");
6
5
  const commander_1 = tslib_1.__importStar(require("commander"));
7
6
  const semver_1 = tslib_1.__importDefault(require("semver"));
@@ -22,30 +21,22 @@ exports.WrapperError = WrapperError;
22
21
  const isErrorWithAnalytics = (e) => {
23
22
  return e.getAttributes !== undefined;
24
23
  };
24
+ function last(arg) {
25
+ return arg[arg.length - 1];
26
+ }
25
27
  class Command {
26
- constructor(ui, analyticsClient, preCommandController, cliDetails, cmd, expectsArguments = false, analyticsName) {
28
+ constructor(ui, analyticsClient, preCommandController, cliDetails, credentialStore, { cmd, analyticsName, requiresAuthentication, requiresAnalyticsConsent, requiredOptionFlags, preconditionFn }) {
27
29
  this.ui = ui;
28
30
  this.analyticsClient = analyticsClient;
29
31
  this.preCommandController = preCommandController;
30
32
  this.cliDetails = cliDetails;
31
- this.expectsArguments = expectsArguments;
32
- this.analyticsName = analyticsName;
33
- this.requiresAuthentication = true;
34
- this.requiresAnalyticsConsent = true;
33
+ this.credentialStore = credentialStore;
35
34
  this.requiredOptionFlags = [];
36
35
  this.preconditionFn = [];
37
- this.options = [];
38
- this.commands = [];
39
- this.exitOverride = (listener) => {
40
- this.cmd.exitOverride((err) => listener(err));
41
- return this;
42
- };
43
36
  this.actionProcessor = async (cb, ...args) => {
44
- var _b, _c, _d, _e, _f;
45
- if (this.newCommand) {
46
- this.ui.error(new Error(cli_shared_1.Text.deprecate(this.newCommand)));
47
- }
37
+ var _a, _b, _c;
48
38
  const cmdName = this.cmd.name();
39
+ const analyticsName = (_a = this.analyticsName) !== null && _a !== void 0 ? _a : cmdName;
49
40
  let cred = (0, anon_user_id_1.getAnonId)(true);
50
41
  let attributes = {};
51
42
  try {
@@ -56,24 +47,35 @@ class Command {
56
47
  isLatest: this.isLatestVersion()
57
48
  };
58
49
  }
59
- this.analyticsClient.reportCommandInvoke((_b = this.analyticsName) !== null && _b !== void 0 ? _b : cmdName, cred, attributes);
60
- if (!this.expectsArguments && args.length > 2) {
61
- throw new cli_shared_1.ValidationError(cli_shared_1.Text.extraArguments(cmdName));
62
- }
63
- const [options] = args;
64
- if (options === null || options === void 0 ? void 0 : options.nonInteractive) {
50
+ this.analyticsClient.reportCommandInvoke(analyticsName, cred, attributes);
51
+ const options = last(args);
52
+ const nonInteractive = (_b = options.nonInteractive) !== null && _b !== void 0 ? _b : false;
53
+ const json = (_c = options.json) !== null && _c !== void 0 ? _c : false;
54
+ if (nonInteractive) {
65
55
  if (!this.satisfiesNonInteractiveOptions(options)) {
66
56
  throw new cli_shared_1.ValidationError(cli_shared_1.Text.nonInteractive.error.missingRequiredOption(cmdName, this.requiredOptionFlags));
67
57
  }
68
58
  }
69
59
  if (this.requiresAnalyticsConsent) {
70
- await this.preCommandController.verifyAnalyticsPreferences((_c = options === null || options === void 0 ? void 0 : options.nonInteractive) !== null && _c !== void 0 ? _c : false)();
60
+ await this.preCommandController.verifyAnalyticsPreferences(nonInteractive)();
71
61
  }
72
- if (!(options === null || options === void 0 ? void 0 : options.json)) {
62
+ if (!json) {
73
63
  this.checkVersion();
74
64
  }
75
65
  const preconditionCheckAttributes = await this.checkPreconditions(...args);
76
- attributes = Object.assign(Object.assign({}, attributes), preconditionCheckAttributes);
66
+ Object.assign(options, preconditionCheckAttributes);
67
+ const preconditionAnalyticsAttributes = [
68
+ ['appId'],
69
+ ['environment', 'appEnv'],
70
+ ['siteURL', 'site'],
71
+ ['product']
72
+ ];
73
+ for (const [preconditionAttribute, analyticsAttribute] of preconditionAnalyticsAttributes) {
74
+ const value = preconditionCheckAttributes[preconditionAttribute];
75
+ if (value) {
76
+ attributes[analyticsAttribute !== null && analyticsAttribute !== void 0 ? analyticsAttribute : preconditionAttribute] = value;
77
+ }
78
+ }
77
79
  const actualCred = await this.checkAuthentication();
78
80
  if (actualCred) {
79
81
  cred = actualCred;
@@ -85,7 +87,7 @@ class Command {
85
87
  cred = result.creds;
86
88
  }
87
89
  }
88
- this.analyticsClient.reportSuccess((_d = this.analyticsName) !== null && _d !== void 0 ? _d : cmdName, cred, attributes);
90
+ this.analyticsClient.reportSuccess(analyticsName, cred, attributes);
89
91
  }
90
92
  catch (e) {
91
93
  if (isErrorWithAnalytics(e)) {
@@ -94,30 +96,43 @@ class Command {
94
96
  if (attributes.isUserError === undefined) {
95
97
  attributes = Object.assign(Object.assign({}, attributes), { isUserError: false });
96
98
  }
97
- this.analyticsClient.reportInvokeFailure((_e = this.analyticsName) !== null && _e !== void 0 ? _e : cmdName, cred, attributes, e);
99
+ this.analyticsClient.reportInvokeFailure(analyticsName, cred, attributes, e);
98
100
  if (e instanceof errors_1.DeferredErrors) {
99
- e.getErrors().forEach((error) => { var _b; return this.analyticsClient.reportFailure((_b = this.analyticsName) !== null && _b !== void 0 ? _b : cmdName, cred, attributes, error); });
101
+ e.getErrors().forEach((error) => this.analyticsClient.reportFailure(analyticsName, cred, attributes, error));
100
102
  process.exit(1);
101
103
  }
102
104
  else {
103
- this.analyticsClient.reportFailure((_f = this.analyticsName) !== null && _f !== void 0 ? _f : cmdName, cred, attributes, e);
105
+ this.analyticsClient.reportFailure(analyticsName, cred, attributes, e);
104
106
  await (0, cli_shared_1.exitOnError)(this.ui, e);
105
107
  }
106
108
  }
107
109
  };
108
- this.outputRelevantHelp = (argv) => {
109
- this.findLastValidCommand(argv).command.outputHelp();
110
- };
111
110
  this.cmd = cmd || new commander_1.default.Command();
111
+ this.analyticsName = analyticsName;
112
+ this.requiresAuthentication = requiresAuthentication !== null && requiresAuthentication !== void 0 ? requiresAuthentication : true;
113
+ this.requiresAnalyticsConsent = requiresAnalyticsConsent !== null && requiresAnalyticsConsent !== void 0 ? requiresAnalyticsConsent : true;
114
+ this.requiredOptionFlags = requiredOptionFlags !== null && requiredOptionFlags !== void 0 ? requiredOptionFlags : [];
115
+ this.preconditionFn = preconditionFn !== null && preconditionFn !== void 0 ? preconditionFn : [];
116
+ this.cmd.exitOverride((err) => {
117
+ throw new WrapperError(err, this.cmd.name());
118
+ });
119
+ this.cmd.configureOutput({
120
+ writeErr: () => { }
121
+ });
112
122
  }
113
123
  get verbose() {
114
124
  return this.cmd.opts().verbose;
115
125
  }
126
+ static program(ui, analyticsClient, preCommandController, cliDetails, credentialStore) {
127
+ var _a;
128
+ const cmd = new Command(ui, analyticsClient, preCommandController, cliDetails, credentialStore, {});
129
+ return cmd.version((_a = cliDetails === null || cliDetails === void 0 ? void 0 : cliDetails.version) !== null && _a !== void 0 ? _a : 'unknown', '--version').option('--verbose', cli_shared_1.Text.optionVerbose);
130
+ }
131
+ clone(overrides) {
132
+ return new Command(this.ui, this.analyticsClient, this.preCommandController, this.cliDetails, this.credentialStore, Object.assign({ cmd: this.cmd, analyticsName: this.analyticsName, requiresAuthentication: this.requiresAuthentication, requiresAnalyticsConsent: this.requiresAnalyticsConsent, requiredOptionFlags: this.requiredOptionFlags, preconditionFn: this.preconditionFn }, overrides));
133
+ }
116
134
  version(str, flags) {
117
135
  this.cmd.version(str, flags);
118
- flags = flags || '-V, --version';
119
- const versionOption = new commander_1.Option(flags, 'output the version number');
120
- this.options.push(versionOption);
121
136
  return this;
122
137
  }
123
138
  command(name, opts) {
@@ -125,14 +140,11 @@ class Command {
125
140
  .command(name, opts)
126
141
  .allowUnknownOption(false)
127
142
  .allowExcessArguments(false);
128
- const trimmedName = name.trim();
129
- const expectsArguments = trimmedName.endsWith(']') || trimmedName.endsWith('>');
130
- const subCommand = new Command(this.ui, this.analyticsClient, this.preCommandController, this.cliDetails, cmd, expectsArguments, Command.concatenateNames(this.analyticsName, cmd.name()));
131
- subCommand.option('--verbose', cli_shared_1.Text.optionVerbose);
132
- subCommand.exitOverride((err) => {
133
- throw new WrapperError(err, subCommand.cmd.name());
134
- });
135
- this.commands.push(subCommand);
143
+ const subCommand = new Command(this.ui, this.analyticsClient, this.preCommandController, this.cliDetails, this.credentialStore, {
144
+ cmd,
145
+ analyticsName: Command.concatenateNames(this.analyticsName, cmd.name())
146
+ }).option('--verbose', cli_shared_1.Text.optionVerbose);
147
+ this.cmd.commands.sort((a, b) => a.name().localeCompare(b.name()));
136
148
  return subCommand;
137
149
  }
138
150
  deprecatedCommand(oldName, newName, stubController) {
@@ -141,61 +153,44 @@ class Command {
141
153
  .requireNoAnalyticsConsent()
142
154
  .action(() => stubController.run({ oldName, newName }));
143
155
  }
144
- getAnalyticsName() {
145
- return this.analyticsName;
146
- }
147
- deprecate(newCommand) {
148
- this.newCommand = newCommand;
149
- return this;
150
- }
151
156
  description(desc) {
152
157
  this.cmd.description(desc);
153
158
  return this;
154
159
  }
155
- option(flags, description, fn, defaultValue) {
156
- this.cmd.option(flags, description, fn, defaultValue);
157
- const option = new commander_1.Option(flags, description);
158
- if (typeof fn === 'function') {
159
- option.default(defaultValue).argParser(fn);
160
- }
161
- else {
162
- option.default(fn);
163
- }
164
- this.options.push(option);
160
+ option(flags, description, defaultValue) {
161
+ this.cmd.option(flags, description, defaultValue);
165
162
  return this;
166
163
  }
167
164
  precondition(fn) {
168
- this.preconditionFn.push(fn);
169
- return this;
165
+ return this.clone({ preconditionFn: [...this.preconditionFn, fn] });
170
166
  }
171
167
  requireManifestFile() {
172
- this.precondition(this.preCommandController.verifyManifestExists());
173
- return this;
168
+ return this.precondition(this.preCommandController.verifyManifestExists());
174
169
  }
175
170
  requireAppId() {
176
- this.precondition(this.preCommandController.verifyManifestExistsWithAppConfig());
177
- return this;
171
+ return this.precondition(this.preCommandController.verifyManifestExistsWithAppConfig());
178
172
  }
179
173
  nonInteractiveOption(...args) {
180
- this.requiredOptionFlags = args;
181
- this.cmd.option('--non-interactive', cli_shared_1.Text.nonInteractive.description);
182
- return this;
174
+ return this.clone({ requiredOptionFlags: args }).option('--non-interactive', cli_shared_1.Text.nonInteractive.description);
183
175
  }
184
176
  action(fn) {
185
- this.cmd.action((...args) => this.actionProcessor(fn, ...args));
177
+ this.cmd.action((...args) => {
178
+ args.pop();
179
+ return this.actionProcessor(fn, ...args);
180
+ });
186
181
  return this;
187
182
  }
188
183
  async parse(argv) {
189
184
  try {
190
185
  this.assertValidArgs(argv);
191
- this.cmd.parse(argv);
186
+ await this.cmd.parseAsync(argv);
192
187
  }
193
188
  catch (err) {
194
189
  if (Command.isHelpTriggered(err)) {
195
190
  if (Command.isError(err)) {
196
191
  this.outputRelevantHelp(argv);
197
192
  }
198
- return Command.reportHelp(this, err);
193
+ return this.reportHelp(err);
199
194
  }
200
195
  if (Command.isVersionTriggered(err)) {
201
196
  return;
@@ -206,47 +201,26 @@ class Command {
206
201
  return await (0, cli_shared_1.exitOnError)(this.ui, err);
207
202
  }
208
203
  }
209
- getDefinedCommands() {
210
- return this.cmd.commands;
211
- }
212
- getDefinedOptions() {
213
- return this.options;
214
- }
215
- getCmdName() {
216
- return this.cmd.name();
217
- }
218
- getCommands() {
219
- return this.commands;
220
- }
221
204
  environmentOption() {
222
- this.option('-e, --environment [environment]', cli_shared_1.Text.env.option(cli_shared_1.DEFAULT_ENVIRONMENT_OPTION, cli_shared_1.VALID_ENVIRONMENT_OPTIONS));
223
- this.precondition(() => {
224
- this.cmd.opts().environment = (0, environment_1.checkEnvironmentOption)(this.cmd.opts().environment || cli_shared_1.DEFAULT_ENVIRONMENT_OPTION);
225
- return { appEnv: this.cmd.opts().environment };
205
+ return this.option('-e, --environment [environment]', cli_shared_1.Text.env.option(cli_shared_1.DEFAULT_ENVIRONMENT_OPTION, cli_shared_1.VALID_ENVIRONMENT_OPTIONS)).precondition(async (...args) => {
206
+ const environment = (0, environment_1.checkEnvironmentOption)(last(args).environment || cli_shared_1.DEFAULT_ENVIRONMENT_OPTION);
207
+ return { environment };
226
208
  });
227
- return this;
228
209
  }
229
210
  jsonOption() {
230
- this.option('--json', cli_shared_1.Text.optionJson);
231
- return this;
211
+ return this.option('--json', cli_shared_1.Text.optionJson, false);
232
212
  }
233
213
  requireNoAuthentication() {
234
- this.requiresAuthentication = false;
235
- return this;
214
+ return this.clone({ requiresAuthentication: false });
236
215
  }
237
216
  requireNoAnalyticsConsent() {
238
- this.requiresAnalyticsConsent = false;
239
- return this;
217
+ return this.clone({ requiresAnalyticsConsent: false });
240
218
  }
241
219
  satisfiesNonInteractiveOptions(options) {
242
220
  const optionKeys = Object.keys(options);
243
221
  const requiredOptionKeys = [...this.requiredOptionFlags.map((arg) => new commander_1.Option(arg).attributeName())];
244
222
  return requiredOptionKeys.every((requiredOption) => optionKeys.includes(requiredOption));
245
223
  }
246
- configureOutput(obj) {
247
- this.cmd.configureOutput(obj);
248
- return this;
249
- }
250
224
  async checkPreconditions(...args) {
251
225
  let attributes = {};
252
226
  for (const precondition of this.preconditionFn) {
@@ -257,8 +231,7 @@ class Command {
257
231
  }
258
232
  async checkAuthentication() {
259
233
  if (this.requiresAuthentication) {
260
- const credentialsGetter = (0, cli_shared_1.getCredentialStore)(this.ui);
261
- return credentialsGetter.getCredentials();
234
+ return this.credentialStore.getCredentials();
262
235
  }
263
236
  return undefined;
264
237
  }
@@ -277,18 +250,13 @@ class Command {
277
250
  }
278
251
  }
279
252
  isLatestVersion() {
280
- if (!this.cliDetails ||
281
- !this.cliDetails.latest ||
282
- !semver_1.default.valid(this.cliDetails.version) ||
283
- !semver_1.default.valid(this.cliDetails.latest)) {
284
- return false;
285
- }
286
- if (semver_1.default.eq(this.cliDetails.version, this.cliDetails.latest)) {
287
- return true;
288
- }
289
- else {
253
+ var _a, _b;
254
+ const version = semver_1.default.valid((_a = this.cliDetails) === null || _a === void 0 ? void 0 : _a.version);
255
+ const latest = semver_1.default.valid((_b = this.cliDetails) === null || _b === void 0 ? void 0 : _b.latest);
256
+ if (!version || !latest) {
290
257
  return false;
291
258
  }
259
+ return semver_1.default.eq(version, latest);
292
260
  }
293
261
  findLastValidCommand(argv) {
294
262
  let command = this.cmd;
@@ -307,6 +275,22 @@ class Command {
307
275
  index: 1
308
276
  };
309
277
  }
278
+ outputRelevantHelp(argv) {
279
+ this.findLastValidCommand(argv).command.outputHelp();
280
+ }
281
+ async reportHelp(cmdError) {
282
+ try {
283
+ let cred = (0, anon_user_id_1.getAnonId)(true);
284
+ try {
285
+ cred = await this.credentialStore.getCredentials();
286
+ }
287
+ catch (noTokenError) {
288
+ }
289
+ this.analyticsClient.reportSuccess('help', cred, { command: cmdError.getCommandName() });
290
+ }
291
+ catch (err) {
292
+ }
293
+ }
310
294
  async unknownCommand(argv) {
311
295
  const errorMessage = [];
312
296
  const { command: lastCommand, index: lastCommandIndex } = this.findLastValidCommand(argv);
@@ -344,24 +328,11 @@ class Command {
344
328
  }
345
329
  }
346
330
  }
331
+ getAutocompleteConfig() {
332
+ return getAutocompleteConfig(this.cmd);
333
+ }
347
334
  }
348
335
  exports.Command = Command;
349
- _a = Command;
350
- Command.reportHelp = async (cmd, cmdError) => {
351
- try {
352
- let cred = (0, anon_user_id_1.getAnonId)(true);
353
- try {
354
- const credentialsGetter = (0, cli_shared_1.getCredentialStore)(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
336
  Command.isError = (cmdError) => {
366
337
  return cmdError.exitCode === 1;
367
338
  };
@@ -380,3 +351,37 @@ Command.isExcessCommands = (cmdError) => {
380
351
  Command.concatenateNames = (parent, subcommand) => {
381
352
  return parent ? `${parent}:${subcommand}` : subcommand;
382
353
  };
354
+ const help = new commander_1.default.Help();
355
+ function getOptionData(option) {
356
+ let requireUserArg = false;
357
+ if (/<*>/.test(option.flags) || /\[*\]/.test(option.flags)) {
358
+ requireUserArg = true;
359
+ }
360
+ return {
361
+ requireUserArg
362
+ };
363
+ }
364
+ function getOptionsData(command) {
365
+ const commandOptions = {};
366
+ for (const opt of help.visibleOptions(command)) {
367
+ if (opt.long !== undefined) {
368
+ commandOptions[opt.long] = getOptionData(opt);
369
+ }
370
+ }
371
+ commandOptions['--help'] = {
372
+ requireUserArg: false
373
+ };
374
+ return commandOptions;
375
+ }
376
+ function getAutocompleteConfig(cmd) {
377
+ const commands = {};
378
+ for (const command of help.visibleCommands(cmd)) {
379
+ if (command.name() === 'help') {
380
+ continue;
381
+ }
382
+ commands[command.name()] = getOptionsData(command);
383
+ }
384
+ const options = getOptionsData(cmd);
385
+ return { commands, options };
386
+ }
387
+ exports.getAutocompleteConfig = getAutocompleteConfig;
@@ -1,9 +1,9 @@
1
- import { UI, FeedbackPostClient } from '@forge/cli-shared';
1
+ import { FeedbackPostClient, CredentialGetter } from '@forge/cli-shared';
2
2
  import { Response } from 'node-fetch';
3
3
  export declare class FeedbackController {
4
- private readonly ui;
4
+ private readonly credentialStore;
5
5
  private readonly feedbackPostClient;
6
- constructor(ui: UI, feedbackPostClient: FeedbackPostClient);
6
+ constructor(credentialStore: CredentialGetter, feedbackPostClient: FeedbackPostClient);
7
7
  sendFeedback(feedback: string): Promise<Response>;
8
8
  }
9
9
  //# sourceMappingURL=feedback-controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feedback-controller.d.ts","sourceRoot":"","sources":["../../../src/command-line/controller/feedback-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,kBAAkB,EAAsB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,EAAE;IAAM,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAA3C,EAAE,EAAE,EAAE,EAAmB,kBAAkB,EAAE,kBAAkB;IAE/E,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAQ/D"}
1
+ {"version":3,"file":"feedback-controller.d.ts","sourceRoot":"","sources":["../../../src/command-line/controller/feedback-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBADlB,eAAe,EAAE,gBAAgB,EACjC,kBAAkB,EAAE,kBAAkB;IAG5C,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAQ/D"}
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FeedbackController = void 0;
4
- const cli_shared_1 = require("@forge/cli-shared");
5
4
  class FeedbackController {
6
- constructor(ui, feedbackPostClient) {
7
- this.ui = ui;
5
+ constructor(credentialStore, feedbackPostClient) {
6
+ this.credentialStore = credentialStore;
8
7
  this.feedbackPostClient = feedbackPostClient;
9
8
  }
10
9
  async sendFeedback(feedback) {
11
- const { email } = await (0, cli_shared_1.getCredentialStore)(this.ui).getCredentials();
10
+ const { email } = await this.credentialStore.getCredentials();
12
11
  return this.feedbackPostClient.sendFeedback({
13
12
  summary: feedback.length <= 50 ? feedback : feedback.slice(0, 50) + '...',
14
13
  description: feedback,
@@ -1,15 +1,20 @@
1
1
  import { CLIDetails, FeatureFlagReader, Logger } from '@forge/cli-shared';
2
- export interface PrerequisitesCheckResult {
2
+ interface FeatureFlagValues {
3
3
  muaoEnabled: boolean | null;
4
+ concurrentDevEnabled: boolean | null;
4
5
  }
6
+ export declare type PrerequisitesCheckResult = FeatureFlagValues;
5
7
  export declare class PrerequisitesController {
6
8
  private readonly logger;
7
9
  private readonly featureFlags;
8
10
  private readonly cliDetails;
9
11
  constructor(logger: Logger, featureFlags: FeatureFlagReader, cliDetails: CLIDetails | undefined);
10
12
  check(): Promise<PrerequisitesCheckResult>;
13
+ private evaluateFeatureFlags;
11
14
  private checkNodeVersion;
12
15
  private checkCustomWarning;
13
16
  private checkMUAOEnabled;
17
+ private checkConcurrentDevelopmentEnabled;
14
18
  }
19
+ export {};
15
20
  //# sourceMappingURL=prerequisites-controller.d.ts.map