zcatalyst-cli 1.26.2 → 1.27.0

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 (151) hide show
  1. package/README.md +1 -0
  2. package/lib/authentication/credential.d.ts +2 -1
  3. package/lib/authentication/credential.js +20 -3
  4. package/lib/authentication/crypt.d.ts +7 -3
  5. package/lib/authentication/crypt.js +87 -16
  6. package/lib/authentication/index.js +1 -0
  7. package/lib/authentication/key-manager.d.ts +7 -0
  8. package/lib/authentication/key-manager.js +62 -0
  9. package/lib/authentication/login.js +20 -20
  10. package/lib/bin/catalyst.js +1 -15
  11. package/lib/client.d.ts +3 -1
  12. package/lib/client.js +16 -5
  13. package/lib/command_needs/rc.js +13 -3
  14. package/lib/commands/appsail/add.js +10 -0
  15. package/lib/commands/client/delete.js +18 -6
  16. package/lib/commands/client/setup.js +7 -0
  17. package/lib/commands/deploy/index.js +3 -3
  18. package/lib/commands/deploy/slate.js +65 -4
  19. package/lib/commands/functions/add.js +7 -0
  20. package/lib/commands/functions/delete.js +22 -4
  21. package/lib/commands/functions/execute.js +39 -71
  22. package/lib/commands/functions/setup.js +13 -0
  23. package/lib/commands/functions/shell.js +15 -1
  24. package/lib/commands/iac/import.js +2 -2
  25. package/lib/commands/init.js +34 -20
  26. package/lib/commands/login.js +1 -0
  27. package/lib/commands/pull.js +22 -1
  28. package/lib/commands/serve.js +2 -1
  29. package/lib/commands/slate/create.js +7 -4
  30. package/lib/commands/slate/link.js +11 -5
  31. package/lib/commands/slate/unlink.js +7 -0
  32. package/lib/commands/zest/generate/index.js +28 -35
  33. package/lib/deploy/features/slate.d.ts +3 -1
  34. package/lib/deploy/features/slate.js +204 -5
  35. package/lib/docs/client-utils.toml +0 -5
  36. package/lib/docs/command_needs/rc.toml +9 -1
  37. package/lib/docs/commands/client/delete.toml +4 -0
  38. package/lib/docs/commands/deploy/slate.toml +3 -0
  39. package/lib/docs/commands/functions/delete.toml +10 -0
  40. package/lib/docs/commands/functions/execute.toml +1 -16
  41. package/lib/docs/commands/functions/setup.toml +3 -0
  42. package/lib/docs/commands/functions/shell.toml +8 -0
  43. package/lib/docs/commands/init.toml +3 -0
  44. package/lib/docs/commands/pull.toml +6 -0
  45. package/lib/docs/commands/slate/unlink.toml +6 -0
  46. package/lib/docs/execute/command-utils.toml +14 -0
  47. package/lib/docs/execute/execute-input-resolver.toml +37 -0
  48. package/lib/docs/init/features/project.toml +20 -0
  49. package/lib/docs/init/util/client.toml +4 -0
  50. package/lib/docs/prompt/index.toml +15 -0
  51. package/lib/docs/pull/features/apig.toml +6 -0
  52. package/lib/docs/pull/features/client.toml +20 -0
  53. package/lib/docs/pull/features/functions/index.toml +24 -0
  54. package/lib/endpoints/lib/slate.d.ts +14 -1
  55. package/lib/endpoints/lib/slate.js +35 -0
  56. package/lib/error/context-help.js +1 -1
  57. package/lib/error/index.js +9 -13
  58. package/lib/execute/command-utils.d.ts +5 -0
  59. package/lib/execute/command-utils.js +86 -0
  60. package/lib/execute/execute-input-resolver.d.ts +29 -0
  61. package/lib/execute/execute-input-resolver.js +207 -0
  62. package/lib/execute/index.d.ts +4 -1
  63. package/lib/execute/index.js +3 -2
  64. package/lib/fn-utils/lib/integ.js +22 -17
  65. package/lib/index.js +1 -0
  66. package/lib/init/dependencies/package-json.js +11 -7
  67. package/lib/init/features/appsail/index.js +75 -26
  68. package/lib/init/features/appsail/prompt-fields.d.ts +43 -0
  69. package/lib/init/features/appsail/prompt-fields.js +55 -0
  70. package/lib/init/features/appsail/utils/custom-runtime.d.ts +3 -0
  71. package/lib/init/features/appsail/utils/custom-runtime.js +161 -0
  72. package/lib/init/features/appsail/{utils.d.ts → utils/index.d.ts} +2 -2
  73. package/lib/init/features/appsail/utils/index.js +170 -0
  74. package/lib/init/features/client/index.js +4 -3
  75. package/lib/init/features/client/initializers/angular.js +3 -2
  76. package/lib/init/features/client/initializers/react.js +4 -3
  77. package/lib/init/features/client/prompt-fields.d.ts +37 -0
  78. package/lib/init/features/client/prompt-fields.js +48 -0
  79. package/lib/init/features/functions/index.js +37 -8
  80. package/lib/init/features/functions/languages/java.js +42 -7
  81. package/lib/init/features/functions/languages/node.js +42 -10
  82. package/lib/init/features/functions/languages/python.js +42 -7
  83. package/lib/init/features/functions/prompt-fields.d.ts +25 -0
  84. package/lib/init/features/functions/prompt-fields.js +34 -0
  85. package/lib/init/features/project.js +41 -6
  86. package/lib/init/features/slate/index.js +2 -0
  87. package/lib/init/features/slate/prompt-fields.d.ts +31 -0
  88. package/lib/init/features/slate/prompt-fields.js +41 -0
  89. package/lib/init/index.js +2 -1
  90. package/lib/init/util/client.js +11 -8
  91. package/lib/init/util/common.d.ts +2 -0
  92. package/lib/init/util/common.js +33 -3
  93. package/lib/init/util/prompt-fields.d.ts +7 -0
  94. package/lib/init/util/prompt-fields.js +13 -0
  95. package/lib/internal/command.d.ts +3 -0
  96. package/lib/internal/command.js +26 -3
  97. package/lib/migration/global/1.27.0.d.ts +2 -0
  98. package/lib/migration/global/1.27.0.js +39 -0
  99. package/lib/prompt/choice.d.ts +2 -0
  100. package/lib/prompt/choice.js +24 -0
  101. package/lib/prompt/cli-option-key.d.ts +1 -0
  102. package/lib/prompt/cli-option-key.js +10 -0
  103. package/lib/prompt/index.d.ts +6 -22
  104. package/lib/prompt/index.js +264 -67
  105. package/lib/prompt/overwrite-prompt.d.ts +11 -0
  106. package/lib/prompt/overwrite-prompt.js +16 -0
  107. package/lib/prompt/question-factory.d.ts +34 -0
  108. package/lib/prompt/question-factory.js +41 -0
  109. package/lib/prompt/register-fields.d.ts +24 -0
  110. package/lib/prompt/register-fields.js +37 -0
  111. package/lib/pull/features/apig.js +57 -6
  112. package/lib/pull/features/client.js +107 -24
  113. package/lib/pull/features/functions/index.js +100 -4
  114. package/lib/pull/index.js +1 -1
  115. package/lib/pull/utils.d.ts +13 -0
  116. package/lib/pull/utils.js +20 -0
  117. package/lib/repl-server.d.ts +4 -0
  118. package/lib/repl-server.js +9 -0
  119. package/lib/serve/server/lib/master/index.js +3 -3
  120. package/lib/serve/server/lib/slate/static-server.js +2 -2
  121. package/lib/serve/server/lib/web_client/server.js +2 -2
  122. package/lib/shell/format-functions.d.ts +4 -0
  123. package/lib/shell/format-functions.js +59 -0
  124. package/lib/shell/index.js +18 -0
  125. package/lib/util_modules/config/lib/appsail.d.ts +3 -2
  126. package/lib/util_modules/config/lib/appsail.js +6 -3
  127. package/lib/util_modules/config/lib/slate.d.ts +19 -0
  128. package/lib/util_modules/config-store.d.ts +1 -0
  129. package/lib/util_modules/config-store.js +29 -10
  130. package/lib/util_modules/constants/index.d.ts +0 -1
  131. package/lib/util_modules/constants/index.js +1 -3
  132. package/lib/util_modules/constants/lib/urls.d.ts +2 -0
  133. package/lib/util_modules/constants/lib/urls.js +4 -0
  134. package/lib/util_modules/dc.d.ts +6 -1
  135. package/lib/util_modules/dc.js +21 -8
  136. package/lib/util_modules/env.d.ts +3 -0
  137. package/lib/util_modules/env.js +41 -0
  138. package/lib/util_modules/fs/lib/sync.d.ts +1 -0
  139. package/lib/util_modules/fs/lib/sync.js +19 -0
  140. package/lib/util_modules/logger/utils.d.ts +1 -0
  141. package/lib/util_modules/logger/utils.js +5 -1
  142. package/lib/util_modules/option.d.ts +1 -0
  143. package/lib/util_modules/option.js +8 -0
  144. package/lib/util_modules/{server.js → server/index.js} +3 -3
  145. package/lib/util_modules/server/needed-scopes.d.ts +1 -0
  146. package/lib/util_modules/{constants/lib → server}/needed-scopes.js +7 -7
  147. package/package.json +3 -2
  148. package/lib/init/features/appsail/utils.js +0 -273
  149. package/lib/util_modules/constants/lib/needed-scopes.d.ts +0 -4
  150. /package/lib/docs/{dc.toml → util_modules/dc.toml} +0 -0
  151. /package/lib/util_modules/{server.d.ts → server/index.d.ts} +0 -0
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.slateAddPromptFields = void 0;
4
+ const register_fields_1 = require("../../../prompt/register-fields");
5
+ exports.slateAddPromptFields = (0, register_fields_1.definePromptFields)([
6
+ {
7
+ name: 'name',
8
+ cliOption: {
9
+ option: '--name <name>',
10
+ description: 'Specify the name of the Slate application'
11
+ }
12
+ },
13
+ {
14
+ name: 'framework',
15
+ cliOption: {
16
+ option: '--framework <framework_name>',
17
+ description: 'Specify the frontend framework (e.g., React, Angular, Vue)'
18
+ }
19
+ },
20
+ {
21
+ name: 'source',
22
+ cliOption: {
23
+ option: '--source <path>',
24
+ description: 'Specify the source directory of the Slate application'
25
+ }
26
+ },
27
+ {
28
+ name: 'template',
29
+ cliOption: {
30
+ option: '--template <template_url>',
31
+ description: 'Provide a template URL to initialize your Slate application'
32
+ }
33
+ },
34
+ {
35
+ name: 'default',
36
+ cliOption: {
37
+ option: '--default',
38
+ description: 'Use default application configurations without prompting'
39
+ }
40
+ }
41
+ ]);
package/lib/init/index.js CHANGED
@@ -38,7 +38,8 @@ function init() {
38
38
  });
39
39
  }
40
40
  const MODULE = features_1.default[feature];
41
- (0, index_1.info)((0, ansi_colors_1.bold)('\n' + (0, ansi_colors_1.white)('===> ') + js_1.JS.camelToTitleCase(feature) + ' Setup'));
41
+ (0, index_1.info)();
42
+ (0, index_1.info)((0, ansi_colors_1.bold)((0, ansi_colors_1.white)('===> ') + js_1.JS.camelToTitleCase(feature) + ' Setup'));
42
43
  yield MODULE();
43
44
  runtime_store_1.default.set('context.payload.features', runtime_store_1.default.get('context.payload.features', []).concat(feature));
44
45
  return init();
@@ -52,11 +52,13 @@ exports.addDependency = addDependency;
52
52
  const ansi_colors_1 = require("ansi-colors");
53
53
  const runtime_store_js_1 = __importDefault(require("../../runtime-store.js"));
54
54
  const index_js_1 = __importDefault(require("../../error/index.js"));
55
- const index_js_2 = __importDefault(require("../../prompt/index.js"));
55
+ const index_js_2 = __importStar(require("../../prompt/index.js"));
56
+ const prompt_fields_1 = require("../features/client/prompt-fields");
56
57
  const regex_js_1 = __importDefault(require("../../util_modules/constants/lib/regex.js"));
57
58
  const ASYNC = __importStar(require("../../util_modules/fs/lib/async.js"));
58
59
  const index_1 = require("../../util_modules/logger/index");
59
60
  const js_js_1 = require("../../util_modules/js.js");
61
+ const env_js_1 = require("../../util_modules/env.js");
60
62
  const fillClientInitPayload = (source, name) => {
61
63
  runtime_store_js_1.default.set('context.payload.client.source', source);
62
64
  runtime_store_js_1.default.set('context.payload.client.name', name);
@@ -64,14 +66,15 @@ const fillClientInitPayload = (source, name) => {
64
66
  exports.fillClientInitPayload = fillClientInitPayload;
65
67
  function directoryOverridePrompt(dir) {
66
68
  return __awaiter(this, void 0, void 0, function* () {
67
- const foldeExists = yield ASYNC.dirExists(dir);
68
- if (foldeExists) {
69
- const overwriteAns = yield index_js_2.default.ask(index_js_2.default.question('overwrite', 'Directory ' + (0, ansi_colors_1.underline)(dir) + ' already exists. Overwrite ?', {
70
- type: 'confirm',
71
- defaultAns: false
69
+ const folderExists = yield ASYNC.dirExists(dir);
70
+ if (folderExists) {
71
+ const overwriteAns = yield index_js_2.default.ask((0, index_js_2.overwritePromptQuestion)({
72
+ fieldOrName: prompt_fields_1.clientPromptFields.get('overwrite'),
73
+ resourceName: dir,
74
+ defaultAns: (0, env_js_1.isNonInteractiveMode)() ? null : false
72
75
  }));
73
76
  if (!overwriteAns.overwrite) {
74
- throw new index_js_1.default('Skipping client setup since unable to override the already existing client', { exit: 0, errorId: 'CLIENT-UTILS-6', arg: [ansi_colors_1.italic.red(dir)] });
77
+ throw new index_js_1.default('Skipping client setup since the client source directory already exists and not overwritten.', { exit: 0, errorId: 'CLIENT-UTILS-6', arg: [ansi_colors_1.italic.red(dir)] });
75
78
  }
76
79
  yield ASYNC.deleteDir(dir);
77
80
  }
@@ -79,7 +82,7 @@ function directoryOverridePrompt(dir) {
79
82
  }
80
83
  function clientNamePrompt(question, defaultAns) {
81
84
  return __awaiter(this, void 0, void 0, function* () {
82
- const namePrompt = yield index_js_2.default.ask(index_js_2.default.question('name', question, {
85
+ const namePrompt = yield index_js_2.default.ask(index_js_2.default.question(prompt_fields_1.clientPromptFields.get('name'), question, {
83
86
  type: 'input',
84
87
  defaultAns,
85
88
  validate: (ans) => {
@@ -10,3 +10,5 @@ export declare function getRuntimePromptAnswer(question: string, fnType?: keyof
10
10
  runtime: string;
11
11
  lang: 'node' | 'java';
12
12
  }>;
13
+ export declare function ignorableOptsTest(optNames: Array<string> | string, warnMsg: string, removeFromOpts?: boolean): void;
14
+ export declare function niIgnorableOptsTest(optNames: Array<string> | string, warnMsg: string, removeFromOpts?: boolean): void;
@@ -15,12 +15,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getRuntimeDetails = getRuntimeDetails;
16
16
  exports.getRuntimeChoices = getRuntimeChoices;
17
17
  exports.getRuntimePromptAnswer = getRuntimePromptAnswer;
18
+ exports.ignorableOptsTest = ignorableOptsTest;
19
+ exports.niIgnorableOptsTest = niIgnorableOptsTest;
20
+ const ansi_colors_1 = require("ansi-colors");
18
21
  const catalyst_details_js_1 = __importDefault(require("../../endpoints/lib/catalyst-details.js"));
19
22
  const index_js_1 = __importDefault(require("../../error/index.js"));
20
23
  const index_js_2 = __importDefault(require("../../prompt/index.js"));
21
24
  const index_js_3 = require("../../util_modules/constants/index.js");
22
25
  const logger_1 = require("../../util_modules/logger");
23
26
  const index_1 = require("../../util_modules/logger/index");
27
+ const option_js_1 = require("../../util_modules/option.js");
28
+ const prompt_fields_js_1 = require("./prompt-fields.js");
29
+ const env_js_1 = require("../../util_modules/env.js");
24
30
  function getRuntimeDetails(fnType) {
25
31
  const catalystDetailsAPI = new catalyst_details_js_1.default();
26
32
  return catalystDetailsAPI.getDetails('runtime', fnType ? index_js_3.REMOTE_REF.functions.type[fnType] : undefined);
@@ -88,16 +94,40 @@ function getRuntimeChoices(_a) {
88
94
  function getRuntimePromptAnswer(question, fnType) {
89
95
  return __awaiter(this, void 0, void 0, function* () {
90
96
  const runtimeChoices = yield getRuntimeChoices({ fnType });
91
- const runtimeAns = yield index_js_2.default.ask(index_js_2.default.question('runtime', question, {
97
+ const runtimeAns = yield index_js_2.default.ask(index_js_2.default.question(prompt_fields_js_1.initCommonPromptFields.get('stack'), question, {
92
98
  type: 'list',
93
99
  choices: runtimeChoices,
94
100
  when: () => {
95
101
  return runtimeChoices.length > 1;
96
102
  }
97
103
  }));
98
- if (runtimeAns === undefined || runtimeAns.runtime === undefined) {
104
+ if (runtimeAns === undefined || runtimeAns.stack === undefined) {
99
105
  throw new index_js_1.default('Selected runtime is invalid.', { exit: 2 });
100
106
  }
101
- return runtimeAns.runtime;
107
+ return runtimeAns.stack;
102
108
  });
103
109
  }
110
+ function ignorableOptsTest(optNames, warnMsg, removeFromOpts = true) {
111
+ if (typeof optNames === 'string')
112
+ optNames = [optNames];
113
+ const ignorableOpts = optNames.filter((optName) => {
114
+ const optValue = (0, option_js_1.getOptionValue)(optName, undefined);
115
+ return optValue !== undefined;
116
+ });
117
+ if (ignorableOpts.length > 0) {
118
+ (0, logger_1.warning)(`${warnMsg}\nIgnored options: ${ignorableOpts
119
+ .map((_opt) => (0, ansi_colors_1.italic)(`--${_opt}`))
120
+ .join(', ')}.`);
121
+ if (removeFromOpts) {
122
+ ignorableOpts.forEach((optName) => {
123
+ (0, option_js_1.unsetOption)(optName);
124
+ });
125
+ }
126
+ }
127
+ }
128
+ function niIgnorableOptsTest(optNames, warnMsg, removeFromOpts = true) {
129
+ if (!(0, env_js_1.isNonInteractiveMode)()) {
130
+ return;
131
+ }
132
+ return ignorableOptsTest(optNames, warnMsg, removeFromOpts);
133
+ }
@@ -0,0 +1,7 @@
1
+ export declare const initCommonPromptFields: import("../../prompt/register-fields").PromptFieldsRegistry<readonly [{
2
+ readonly name: "stack";
3
+ readonly cliOption: {
4
+ readonly option: "--stack <stack>";
5
+ readonly description: "catalyst runtime stack to scaffold (for example node18, java17, python_3_9)";
6
+ };
7
+ }]>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initCommonPromptFields = void 0;
4
+ const register_fields_1 = require("../../prompt/register-fields");
5
+ exports.initCommonPromptFields = (0, register_fields_1.definePromptFields)([
6
+ {
7
+ name: 'stack',
8
+ cliOption: {
9
+ option: '--stack <stack>',
10
+ description: 'catalyst runtime stack to scaffold (for example node18, java17, python_3_9)'
11
+ }
12
+ }
13
+ ]);
@@ -11,6 +11,7 @@ declare class Command {
11
11
  private beforeRunners;
12
12
  private optIgnores;
13
13
  private helpText;
14
+ private niHelpText;
14
15
  private allowUnknownOptions;
15
16
  client: Client | null;
16
17
  private subCommand;
@@ -25,8 +26,10 @@ declare class Command {
25
26
  argument(name: string, description: string, defaultValue?: string): Command;
26
27
  allowUnknownOpts(): Command;
27
28
  option(...args: Array<string>): Command;
29
+ option(optionTuple: ReadonlyArray<string>): Command;
28
30
  needs(fn: 'auth' | 'config' | 'rc', args?: unknown): Command;
29
31
  help(text: string): Command;
32
+ niHelp(text: string): Command;
30
33
  addSubCommand(...commands: Array<Command>): Command;
31
34
  ci(value: boolean): Command;
32
35
  helpConfig(config: HelpConfiguration): Command;
@@ -72,6 +72,7 @@ class Command {
72
72
  this.beforeRunners = [];
73
73
  this.optIgnores = [];
74
74
  this.helpText = null;
75
+ this.niHelpText = null;
75
76
  this.client = null;
76
77
  this.allowUnknownOptions = false;
77
78
  }
@@ -91,8 +92,16 @@ class Command {
91
92
  this.allowUnknownOptions = true;
92
93
  return this;
93
94
  }
94
- option(...args) {
95
- this.cmdOptions.push(args);
95
+ option(firstOrTuple, ...rest) {
96
+ if (firstOrTuple === undefined) {
97
+ this.cmdOptions.push(rest.length > 0 ? rest : []);
98
+ return this;
99
+ }
100
+ if (typeof firstOrTuple === 'string') {
101
+ this.cmdOptions.push([firstOrTuple, ...rest]);
102
+ return this;
103
+ }
104
+ this.cmdOptions.push([...firstOrTuple, ...rest]);
96
105
  return this;
97
106
  }
98
107
  needs(fn, args) {
@@ -106,6 +115,13 @@ class Command {
106
115
  this.helpText = text;
107
116
  return this;
108
117
  }
118
+ niHelp(text) {
119
+ this.niHelpText = `\nNon-Interactive Mode help: \n${text
120
+ .split('\n')
121
+ .map((line) => ' ' + line)
122
+ .join('\n')}`;
123
+ return this;
124
+ }
109
125
  addSubCommand(...commands) {
110
126
  commands.forEach((command) => {
111
127
  this.subCommand.push(command);
@@ -159,6 +175,13 @@ class Command {
159
175
  (0, index_1.info)(this.helpText);
160
176
  });
161
177
  }
178
+ if (this.niHelpText !== null) {
179
+ cmd.on('--help', () => {
180
+ if (!(0, env_1.isNonInteractiveMode)())
181
+ return;
182
+ (0, index_1.info)(this.niHelpText);
183
+ });
184
+ }
162
185
  if (this._helpConfig) {
163
186
  cmd.configureHelp(this._helpConfig);
164
187
  }
@@ -266,5 +289,5 @@ class Command {
266
289
  });
267
290
  }
268
291
  }
269
- Command.globalOpts = ['project', 'token', 'dc', 'org', 'verbose'];
292
+ Command.globalOpts = ['project', 'token', 'dc', 'org', 'verbose', 'nonInteractive'];
270
293
  exports.default = Command;
@@ -0,0 +1,2 @@
1
+ export declare const isRequire: () => boolean;
2
+ export declare const migrate: () => void;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.migrate = exports.isRequire = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = require("path");
9
+ const config_store_js_1 = __importDefault(require("../../util_modules/config-store.js"));
10
+ const index_1 = require("../../util_modules/logger/index");
11
+ const LEGACY_CLI_CONFIG_NAME = 'zcatalyst-cli';
12
+ const getLegacyConfigPath = () => {
13
+ const configDir = config_store_js_1.default.path;
14
+ return configDir ? (0, path_1.join)(configDir, `${LEGACY_CLI_CONFIG_NAME}.json`) : undefined;
15
+ };
16
+ const isRequire = () => {
17
+ const legacyPath = getLegacyConfigPath();
18
+ if (!legacyPath || !(0, fs_1.existsSync)(legacyPath)) {
19
+ return false;
20
+ }
21
+ return Object.keys(config_store_js_1.default.store).every((key) => key === 'migration');
22
+ };
23
+ exports.isRequire = isRequire;
24
+ const migrate = () => {
25
+ const legacyPath = getLegacyConfigPath();
26
+ if (!legacyPath) {
27
+ return;
28
+ }
29
+ try {
30
+ const legacyContent = JSON.parse((0, fs_1.readFileSync)(legacyPath, 'utf8'));
31
+ config_store_js_1.default.store = Object.assign(Object.assign({}, legacyContent), { migration: config_store_js_1.default.store.migration });
32
+ (0, index_1.debug)('legacy config migrated to zcatalyst-cli-v1.json');
33
+ }
34
+ catch (e) {
35
+ (0, index_1.debug)('legacy config migration failed');
36
+ throw e;
37
+ }
38
+ };
39
+ exports.migrate = migrate;
@@ -0,0 +1,2 @@
1
+ import type { IChoice } from './index';
2
+ export declare const choice: (name: string, { id, value, short, disabled, checked, ...otherOpts }?: IChoice) => IChoice;
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.choice = void 0;
15
+ const choice = (name, _a = {}) => {
16
+ var { id = name, value = name, short = name, disabled = false, checked = false } = _a, otherOpts = __rest(_a, ["id", "value", "short", "disabled", "checked"]);
17
+ return Object.assign({ id,
18
+ name,
19
+ value,
20
+ short,
21
+ disabled,
22
+ checked }, otherOpts);
23
+ };
24
+ exports.choice = choice;
@@ -0,0 +1 @@
1
+ export declare function commanderOptionKey(option: string): string;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commanderOptionKey = commanderOptionKey;
4
+ function commanderOptionKey(option) {
5
+ const parts = option.split(',');
6
+ const tail = parts[parts.length - 1].trim();
7
+ const long = tail.match(/^--([\w-]+)/);
8
+ const kebab = long ? long[1] : tail.replace(/^-+/, '');
9
+ return kebab.replace(/-([a-z])/gi, (_, c) => c.toUpperCase());
10
+ }
@@ -1,26 +1,6 @@
1
1
  import inquirer from 'inquirer';
2
- import Separator from 'inquirer/lib/objects/separator';
3
2
  import PromptUI from 'inquirer/lib/ui/prompt';
4
- import { TreeData, TreeNode } from './types/tree';
5
- export interface IChoice extends inquirer.ChoiceOptions, inquirer.ListChoiceOptions, inquirer.CheckboxChoiceOptions {
6
- id?: string;
7
- }
8
- export interface IQuestion extends inquirer.Question, inquirer.ListQuestionOptions {
9
- name: string;
10
- type?: inquirer.QuestionTypeName | 'file-path' | 'tree' | 'search-box' | 'with-desc';
11
- defaultAns?: unknown;
12
- choices?: Array<IChoice | TSeparator> | Array<string | TSeparator>;
13
- treeChoices?: Array<TreeNode | TreeData>;
14
- rootPath?: string;
15
- exclude?: Array<string>;
16
- excludeDir?: boolean;
17
- ignoreFiles?: boolean;
18
- depth?: number;
19
- empTxt?: string;
20
- validatingText?: string;
21
- description?: string;
22
- }
23
- export type TSeparator = Separator;
3
+ import { buildQuestion, IChoice, IQuestion, TSeparator } from './question-factory';
24
4
  declare const _default: {
25
5
  register: (type: "file-path" | "tree" | "search-box" | "with-desc") => Promise<void>;
26
6
  deregister: (type: "file-path" | "tree" | "search-box") => void;
@@ -29,6 +9,10 @@ declare const _default: {
29
9
  ask: (...questions: Array<IQuestion>) => (Promise<inquirer.Answers> & {
30
10
  ui: PromptUI;
31
11
  }) | Promise<inquirer.Answers>;
32
- question: (name: string, question: string, { type, defaultAns, choices, validate, filter, when, prefix, suffix, ...otheropts }?: Omit<IQuestion, "name">) => IQuestion;
12
+ question: typeof buildQuestion;
33
13
  };
34
14
  export default _default;
15
+ export { overwritePromptQuestion } from './overwrite-prompt';
16
+ export { definePromptFields, PromptFieldHandle, PromptFieldsRegistry } from './register-fields';
17
+ export type { DefinedPromptFields, PromptFieldDef, PromptFieldNames } from './register-fields';
18
+ export type { IQuestion, IChoice, TSeparator } from './question-factory';