zcatalyst-cli 1.26.1 → 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 (155) hide show
  1. package/README.md +1 -0
  2. package/lib/appsail-utils.d.ts +1 -1
  3. package/lib/appsail-utils.js +170 -129
  4. package/lib/authentication/credential.d.ts +2 -1
  5. package/lib/authentication/credential.js +20 -3
  6. package/lib/authentication/crypt.d.ts +7 -3
  7. package/lib/authentication/crypt.js +87 -16
  8. package/lib/authentication/index.js +1 -0
  9. package/lib/authentication/key-manager.d.ts +7 -0
  10. package/lib/authentication/key-manager.js +62 -0
  11. package/lib/authentication/login.js +20 -20
  12. package/lib/bin/catalyst.js +1 -15
  13. package/lib/client.d.ts +3 -1
  14. package/lib/client.js +16 -5
  15. package/lib/command_needs/rc.js +13 -3
  16. package/lib/commands/appsail/add.js +10 -0
  17. package/lib/commands/client/delete.js +18 -6
  18. package/lib/commands/client/setup.js +7 -0
  19. package/lib/commands/deploy/index.js +3 -3
  20. package/lib/commands/deploy/slate.js +65 -4
  21. package/lib/commands/functions/add.js +7 -0
  22. package/lib/commands/functions/delete.js +22 -4
  23. package/lib/commands/functions/execute.js +39 -71
  24. package/lib/commands/functions/setup.js +13 -0
  25. package/lib/commands/functions/shell.js +15 -1
  26. package/lib/commands/iac/import.js +2 -2
  27. package/lib/commands/init.js +34 -20
  28. package/lib/commands/login.js +1 -0
  29. package/lib/commands/pull.js +22 -1
  30. package/lib/commands/serve.js +2 -1
  31. package/lib/commands/slate/create.js +7 -4
  32. package/lib/commands/slate/link.js +11 -5
  33. package/lib/commands/slate/unlink.js +7 -0
  34. package/lib/commands/zest/generate/index.js +28 -35
  35. package/lib/deploy/features/appsail/index.js +2 -1
  36. package/lib/deploy/features/slate.d.ts +3 -1
  37. package/lib/deploy/features/slate.js +204 -5
  38. package/lib/docs/client-utils.toml +0 -5
  39. package/lib/docs/command_needs/rc.toml +9 -1
  40. package/lib/docs/commands/client/delete.toml +4 -0
  41. package/lib/docs/commands/deploy/slate.toml +3 -0
  42. package/lib/docs/commands/functions/delete.toml +10 -0
  43. package/lib/docs/commands/functions/execute.toml +1 -16
  44. package/lib/docs/commands/functions/setup.toml +3 -0
  45. package/lib/docs/commands/functions/shell.toml +8 -0
  46. package/lib/docs/commands/init.toml +3 -0
  47. package/lib/docs/commands/pull.toml +6 -0
  48. package/lib/docs/commands/slate/unlink.toml +6 -0
  49. package/lib/docs/execute/command-utils.toml +14 -0
  50. package/lib/docs/execute/execute-input-resolver.toml +37 -0
  51. package/lib/docs/init/features/project.toml +20 -0
  52. package/lib/docs/init/util/client.toml +4 -0
  53. package/lib/docs/prompt/index.toml +15 -0
  54. package/lib/docs/pull/features/apig.toml +6 -0
  55. package/lib/docs/pull/features/client.toml +20 -0
  56. package/lib/docs/pull/features/functions/index.toml +24 -0
  57. package/lib/endpoints/lib/slate.d.ts +14 -1
  58. package/lib/endpoints/lib/slate.js +35 -0
  59. package/lib/error/context-help.js +1 -1
  60. package/lib/error/index.js +9 -13
  61. package/lib/execute/command-utils.d.ts +5 -0
  62. package/lib/execute/command-utils.js +86 -0
  63. package/lib/execute/execute-input-resolver.d.ts +29 -0
  64. package/lib/execute/execute-input-resolver.js +207 -0
  65. package/lib/execute/index.d.ts +4 -1
  66. package/lib/execute/index.js +3 -2
  67. package/lib/fn-utils/lib/integ.js +22 -17
  68. package/lib/index.js +1 -0
  69. package/lib/init/dependencies/package-json.js +11 -7
  70. package/lib/init/features/appsail/index.js +75 -26
  71. package/lib/init/features/appsail/prompt-fields.d.ts +43 -0
  72. package/lib/init/features/appsail/prompt-fields.js +55 -0
  73. package/lib/init/features/appsail/utils/custom-runtime.d.ts +3 -0
  74. package/lib/init/features/appsail/utils/custom-runtime.js +161 -0
  75. package/lib/init/features/appsail/{utils.d.ts → utils/index.d.ts} +2 -2
  76. package/lib/init/features/appsail/utils/index.js +170 -0
  77. package/lib/init/features/client/index.js +4 -3
  78. package/lib/init/features/client/initializers/angular.js +3 -2
  79. package/lib/init/features/client/initializers/react.js +4 -3
  80. package/lib/init/features/client/prompt-fields.d.ts +37 -0
  81. package/lib/init/features/client/prompt-fields.js +48 -0
  82. package/lib/init/features/functions/index.js +37 -8
  83. package/lib/init/features/functions/languages/java.js +42 -7
  84. package/lib/init/features/functions/languages/node.js +42 -10
  85. package/lib/init/features/functions/languages/python.js +42 -7
  86. package/lib/init/features/functions/prompt-fields.d.ts +25 -0
  87. package/lib/init/features/functions/prompt-fields.js +34 -0
  88. package/lib/init/features/project.js +41 -6
  89. package/lib/init/features/slate/index.js +2 -0
  90. package/lib/init/features/slate/prompt-fields.d.ts +31 -0
  91. package/lib/init/features/slate/prompt-fields.js +41 -0
  92. package/lib/init/index.js +2 -1
  93. package/lib/init/util/client.js +11 -8
  94. package/lib/init/util/common.d.ts +2 -0
  95. package/lib/init/util/common.js +33 -3
  96. package/lib/init/util/prompt-fields.d.ts +7 -0
  97. package/lib/init/util/prompt-fields.js +13 -0
  98. package/lib/internal/command.d.ts +3 -0
  99. package/lib/internal/command.js +26 -3
  100. package/lib/migration/global/1.27.0.d.ts +2 -0
  101. package/lib/migration/global/1.27.0.js +39 -0
  102. package/lib/prompt/choice.d.ts +2 -0
  103. package/lib/prompt/choice.js +24 -0
  104. package/lib/prompt/cli-option-key.d.ts +1 -0
  105. package/lib/prompt/cli-option-key.js +10 -0
  106. package/lib/prompt/index.d.ts +6 -22
  107. package/lib/prompt/index.js +264 -67
  108. package/lib/prompt/overwrite-prompt.d.ts +11 -0
  109. package/lib/prompt/overwrite-prompt.js +16 -0
  110. package/lib/prompt/question-factory.d.ts +34 -0
  111. package/lib/prompt/question-factory.js +41 -0
  112. package/lib/prompt/register-fields.d.ts +24 -0
  113. package/lib/prompt/register-fields.js +37 -0
  114. package/lib/pull/features/apig.js +57 -6
  115. package/lib/pull/features/client.js +107 -24
  116. package/lib/pull/features/functions/index.js +100 -4
  117. package/lib/pull/index.js +1 -1
  118. package/lib/pull/utils.d.ts +13 -0
  119. package/lib/pull/utils.js +20 -0
  120. package/lib/repl-server.d.ts +4 -0
  121. package/lib/repl-server.js +9 -0
  122. package/lib/serve/features/appsail.js +2 -45
  123. package/lib/serve/server/lib/master/index.js +3 -3
  124. package/lib/serve/server/lib/slate/static-server.js +2 -2
  125. package/lib/serve/server/lib/web_client/server.js +2 -2
  126. package/lib/shell/format-functions.d.ts +4 -0
  127. package/lib/shell/format-functions.js +59 -0
  128. package/lib/shell/index.js +18 -0
  129. package/lib/util_modules/config/lib/appsail.d.ts +3 -2
  130. package/lib/util_modules/config/lib/appsail.js +21 -5
  131. package/lib/util_modules/config/lib/slate.d.ts +19 -0
  132. package/lib/util_modules/config-store.d.ts +1 -0
  133. package/lib/util_modules/config-store.js +29 -10
  134. package/lib/util_modules/constants/index.d.ts +0 -1
  135. package/lib/util_modules/constants/index.js +1 -3
  136. package/lib/util_modules/constants/lib/urls.d.ts +2 -0
  137. package/lib/util_modules/constants/lib/urls.js +4 -0
  138. package/lib/util_modules/dc.d.ts +6 -1
  139. package/lib/util_modules/dc.js +21 -8
  140. package/lib/util_modules/env.d.ts +3 -0
  141. package/lib/util_modules/env.js +41 -0
  142. package/lib/util_modules/fs/lib/sync.d.ts +1 -0
  143. package/lib/util_modules/fs/lib/sync.js +19 -0
  144. package/lib/util_modules/logger/utils.d.ts +1 -0
  145. package/lib/util_modules/logger/utils.js +5 -1
  146. package/lib/util_modules/option.d.ts +1 -0
  147. package/lib/util_modules/option.js +8 -0
  148. package/lib/util_modules/{server.js → server/index.js} +3 -3
  149. package/lib/util_modules/server/needed-scopes.d.ts +1 -0
  150. package/lib/util_modules/{constants/lib → server}/needed-scopes.js +7 -7
  151. package/package.json +3 -2
  152. package/lib/init/features/appsail/utils.js +0 -273
  153. package/lib/util_modules/constants/lib/needed-scopes.d.ts +0 -4
  154. /package/lib/docs/{dc.toml → util_modules/dc.toml} +0 -0
  155. /package/lib/util_modules/{server.d.ts → server/index.d.ts} +0 -0
@@ -57,69 +57,18 @@ const common_js_1 = require("../../fn-utils/lib/common.js");
57
57
  const index_js_3 = require("../../util_modules/constants/index.js");
58
58
  const path_1 = require("path");
59
59
  const ansi_colors_1 = require("ansi-colors");
60
- const async_js_1 = require("../../util_modules/fs/lib/async.js");
60
+ const sync_js_1 = require("../../util_modules/fs/lib/sync.js");
61
61
  const index_js_4 = __importDefault(require("../../execute/index.js"));
62
- const project_js_1 = require("../../util_modules/project.js");
63
- function getInputs(exeTarget) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- const inputsFile = (0, path_1.resolve)(exeTarget.source, typeof exeTarget.inputs === 'string' ? exeTarget.inputs : index_js_3.FILENAME.catalyst_inputs);
66
- const projectRoot = (0, project_js_1.getProjectRoot)();
67
- if (!inputsFile.startsWith(projectRoot)) {
68
- throw new index_js_2.default(`Input file path ${exeTarget.inputs} is outside the project directory.`, {
69
- exit: 1,
70
- context: {
71
- resolvePath: inputsFile,
72
- targetSource: projectRoot,
73
- inputs: exeTarget.inputs
74
- }
75
- });
76
- }
77
- const targetInputs = yield (0, async_js_1.readJSONFile)(inputsFile).catch((err) => {
78
- throw new index_js_2.default('Unable to read the inputs file', {
79
- original: err,
80
- exit: 1,
81
- errorId: 'FEXE-2',
82
- arg: [(0, ansi_colors_1.italic)(inputsFile), ansi_colors_1.italic.red(err || '')]
83
- });
84
- });
85
- if (!targetInputs || Object.keys(targetInputs).length === 0) {
86
- throw new index_js_2.default('Empty inputs', {
87
- exit: 0,
88
- errorId: 'FEXE-3',
89
- arg: [
90
- (0, ansi_colors_1.bold)(index_js_3.FILENAME.catalyst_inputs),
91
- (0, ansi_colors_1.bold)(index_js_3.FILENAME.catalyst_config),
92
- (0, ansi_colors_1.bold)('execution.test_inputs')
93
- ]
94
- });
95
- }
96
- const inputKeys = Object.keys(targetInputs);
97
- const keyOpt = (0, option_js_1.getOptionValue)('key', undefined);
98
- if (keyOpt && !(keyOpt in targetInputs)) {
99
- throw new index_js_2.default('Key not present in inputs', {
100
- exit: 0,
101
- errorId: 'FEXE-4',
102
- arg: [
103
- ansi_colors_1.bold.italic('--key ' + (0, ansi_colors_1.red)(keyOpt)),
104
- (0, ansi_colors_1.bold)(inputKeys.map((key) => '* ' + key).join('\n'))
105
- ]
106
- });
107
- }
108
- const selectedKey = yield index_js_1.default.ask(index_js_1.default.question('key', 'Please select the input', {
109
- type: 'list',
110
- choices: inputKeys.map((key) => index_js_1.default.choice(key, { value: key, short: key })),
111
- when: !keyOpt && inputKeys.length > 1
112
- }));
113
- return inputKeys.length === 1
114
- ? targetInputs[inputKeys[0]]
115
- : targetInputs[selectedKey.key] || targetInputs[keyOpt];
116
- });
117
- }
62
+ const index_1 = require("../../util_modules/logger/index");
63
+ const execute_input_resolver_js_1 = require("../../execute/execute-input-resolver.js");
64
+ const command_utils_js_1 = require("../../execute/command-utils.js");
65
+ const util_1 = require("util");
118
66
  exports.default = new command_js_1.default('functions:execute')
119
67
  .argument('[function_name]', 'Name of the function to execute')
120
- .argument('[data]', 'Input data for the function', '')
68
+ .argument('[data]', 'Input data for the function (deprecated)', '')
121
69
  .description('Execute the Non-Http functions')
122
- .option('--key <input_key>', 'Specify the input to be provided incase of multiple inputs present')
70
+ .option('--input <value>', 'Function input: inline JSON, a JSON file path, or "-" for stdin')
71
+ .option('--key <input_key>', 'Specify the input to be provided in-case of multiple inputs present')
123
72
  .option('--debug [port]', 'the functions are invoked from local environment enabling debugging options on provided port.' +
124
73
  `(default: ${default_js_1.default.serve_port.debug.basicio})`)
125
74
  .option('--ignore-scripts', 'ignore teh pre and post lifecycle scripts')
@@ -127,6 +76,16 @@ exports.default = new command_js_1.default('functions:execute')
127
76
  .needs('config')
128
77
  .needs('rc')
129
78
  .action((functionName, data) => __awaiter(void 0, void 0, void 0, function* () {
79
+ const inputOption = (0, option_js_1.getOptionValue)('input', undefined);
80
+ if (!inputOption && data) {
81
+ (0, index_1.warning)('The positional [data] argument is deprecated and will be removed in a future release. Use --input <value> instead.');
82
+ }
83
+ if (!inputOption && !data) {
84
+ const stdinType = (0, sync_js_1.getStdinType)();
85
+ if (stdinType === 'pipe' || stdinType === 'file') {
86
+ (0, index_1.warning)('Piped stdin is ignored unless you pass --input -. Use --input - to consume piped JSON input.');
87
+ }
88
+ }
130
89
  const fnSource = FUNCTIONS_CONFIG.source();
131
90
  const rawFnTargets = FUNCTIONS_CONFIG.targets();
132
91
  if (!rawFnTargets || rawFnTargets.length === 0) {
@@ -185,23 +144,32 @@ exports.default = new command_js_1.default('functions:execute')
185
144
  ]
186
145
  });
187
146
  }
188
- let jsonData;
189
- try {
190
- jsonData = data ? JSON.parse(data) : undefined;
147
+ let fnInput;
148
+ if (typeof inputOption === 'string') {
149
+ const resolvedInput = yield (0, execute_input_resolver_js_1.resolveExecuteInputOption)(inputOption);
150
+ if (!resolvedInput.ok) {
151
+ throw (0, execute_input_resolver_js_1.resolveInputError)(resolvedInput, inputOption);
152
+ }
153
+ fnInput = resolvedInput.value;
191
154
  }
192
- catch (er) {
193
- throw new index_js_2.default('Error parsing the JSON input', {
194
- exit: 1,
195
- errorId: 'FEXE-6',
196
- arg: [ansi_colors_1.italic.red(data || '<empty-string>')]
197
- });
155
+ else if (data) {
156
+ try {
157
+ fnInput = JSON.parse(data);
158
+ }
159
+ catch (er) {
160
+ throw new index_js_2.default('Error parsing the JSON input', {
161
+ exit: 1,
162
+ errorId: 'FEXE-6',
163
+ arg: [ansi_colors_1.italic.red(data || '<empty-string>')]
164
+ });
165
+ }
198
166
  }
199
- const fnInput = jsonData || (yield getInputs(exeTarget));
200
- if (!fnInput || typeof fnInput !== 'object') {
167
+ fnInput = yield (0, command_utils_js_1.getInputs)(exeTarget, fnInput);
168
+ if (!fnInput || typeof fnInput !== 'object' || Array.isArray(fnInput.ip)) {
201
169
  throw new index_js_2.default('Invalid input', {
202
170
  exit: 1,
203
171
  errorId: 'FEXE-5',
204
- arg: [ansi_colors_1.bold.red(fnInput || '')]
172
+ arg: [ansi_colors_1.bold.red((0, util_1.inspect)(fnInput) || '')]
205
173
  });
206
174
  }
207
175
  const debugPort = (0, option_js_1.getOptionValue)('debug', false);
@@ -51,6 +51,8 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
51
51
  const constants_1 = require("../../util_modules/constants");
52
52
  const scopes_js_1 = __importDefault(require("../../authentication/constants/scopes.js"));
53
53
  const index_1 = require("../../util_modules/logger/index");
54
+ const env_1 = require("../../util_modules/env");
55
+ const error_1 = __importDefault(require("../../error"));
54
56
  exports.default = new command_1.default('functions:setup')
55
57
  .description('Set up and configure the function directory in your project directory')
56
58
  .needs('auth', [scopes_js_1.default.functions])
@@ -58,6 +60,17 @@ exports.default = new command_1.default('functions:setup')
58
60
  .needs('rc')
59
61
  .ci(false)
60
62
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
63
+ if ((0, env_1.isNonInteractiveMode)()) {
64
+ throw new error_1.default('The functions:setup command is disabled in non-interactive mode. Please use the functions:add command to add functions in non-interactive mode.', {
65
+ exit: 1,
66
+ errorId: 'E_NON_INTERACTIVE_MODE_FUNCTIONS_SETUP',
67
+ arg: [
68
+ ansi_colors_1.italic.yellow('catalyst functions:setup'),
69
+ (0, ansi_colors_1.bold)('non-interactive'),
70
+ ansi_colors_1.italic.green('catalyst functions:add')
71
+ ]
72
+ });
73
+ }
61
74
  const config = runtime_store_1.default.get('config');
62
75
  yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).functions();
63
76
  yield config.save();
@@ -55,6 +55,8 @@ const constants_1 = require("../../util_modules/constants");
55
55
  const index_1 = require("../../util_modules/logger/index");
56
56
  const option_1 = require("../../util_modules/option");
57
57
  const project_1 = require("../../util_modules/project");
58
+ const needed_scopes_1 = require("../../util_modules/server/needed-scopes");
59
+ const env_1 = require("../../util_modules/env");
58
60
  exports.default = new command_1.default('functions:shell')
59
61
  .description('Launch a node shell to test emulated functions of any stack or type, other than Advanced I/O functions')
60
62
  .option('--only <targets>', 'only serve specified, comma-separated targets (e.g. "f1,f2")')
@@ -70,11 +72,23 @@ exports.default = new command_1.default('functions:shell')
70
72
  '\n' +
71
73
  '(deprecated: The watch mode will be enabled by default. To disable watch mode use the --no-watch option)')
72
74
  .option('--no-watch', 'disable watching the files for changes')
73
- .needs('auth', constants_1.NEEDED_SCOPES.SERVE)
75
+ .needs('auth', needed_scopes_1.SERVE_SCOPES)
74
76
  .needs('config')
75
77
  .needs('rc')
76
78
  .ci(false)
77
79
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
80
+ if ((0, env_1.isNonInteractiveMode)()) {
81
+ throw new error_1.default('The functions:shell command cannot be run in non-interactive mode. Please run the command in an interactive shell.', {
82
+ exit: 1,
83
+ errorId: 'FSHELL-2',
84
+ arg: [
85
+ (0, ansi_colors_1.bold)('functions:shell'),
86
+ (0, ansi_colors_1.bold)('non-interactive'),
87
+ (0, ansi_colors_1.bold)('functions:execute'),
88
+ (0, ansi_colors_1.italic)(`${(0, ansi_colors_1.dim)('>')} catalyst functions:execute -h`)
89
+ ]
90
+ });
91
+ }
78
92
  const httpOpt = (0, option_1.getOptionValue)('http', false);
79
93
  if (httpOpt && typeof httpOpt !== 'boolean') {
80
94
  runtime_store_1.default.set('context.port.http.bio', httpOpt);
@@ -68,7 +68,7 @@ const js_1 = require("../../util_modules/js");
68
68
  const index_1 = require("../../util_modules/logger/index");
69
69
  const option_1 = require("../../util_modules/option");
70
70
  const shell_1 = require("../../util_modules/shell");
71
- const server_js_1 = require("../../util_modules/server.js");
71
+ const index_js_2 = require("../../util_modules/server/index.js");
72
72
  const project_1 = require("../../util_modules/project");
73
73
  const getZipAndTemplate = (filePath, stagedDeploy) => __awaiter(void 0, void 0, void 0, function* () {
74
74
  const zipFile = filePath
@@ -119,7 +119,7 @@ const ensureUserAction = (deployRes) => __awaiter(void 0, void 0, void 0, functi
119
119
  res(e);
120
120
  }
121
121
  }));
122
- const destroyer = new server_js_1.ConnectionDestroyer(server);
122
+ const destroyer = new index_js_2.ConnectionDestroyer(server);
123
123
  server.listen(callbackPort, '127.0.0.1', () => {
124
124
  const urlString = accessUrl.toString();
125
125
  (0, index_1.info)();
@@ -56,16 +56,23 @@ const fs_1 = require("../util_modules/fs");
56
56
  const js_1 = require("../util_modules/js");
57
57
  const index_1 = require("../util_modules/logger/index");
58
58
  const shell_1 = require("../util_modules/shell");
59
+ const project_1 = require("../util_modules/project");
60
+ const error_1 = __importDefault(require("../error"));
61
+ const env_1 = require("../util_modules/env");
59
62
  const saveAndComplete = (config) => __awaiter(void 0, void 0, void 0, function* () {
60
- yield config.save();
61
- (0, index_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.config) + ' file has been successfully created with feature details.');
63
+ if (Object.keys(config.data).length > 0) {
64
+ yield config.save();
65
+ (0, index_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.config) + ' file has been successfully created with feature details.');
66
+ }
62
67
  (0, index_1.info)();
63
68
  (0, index_1.success)('Catalyst initialization complete!');
64
69
  });
65
- exports.default = new command_1.default('init [feature]')
70
+ exports.default = new command_1.default('init')
66
71
  .description('Initialize a Catalyst project, function, and client resources in the local directory')
72
+ .argument('[feature]', 'feature to initialize')
67
73
  .option('--force', 'force initialise a project for this directory')
68
- .ignore(['project'])
74
+ .option('--project <project_id>', 'project id to initialize the project for')
75
+ .option('--org <org_id>', 'organization id to initialize the project for')
69
76
  .needs('auth', [scopes_js_1.default.projects, scopes_js_1.default.project_import_create])
70
77
  .needs('config', { optional: true })
71
78
  .needs('rc', { optional: true, resolveOnNotFound: true })
@@ -74,6 +81,7 @@ exports.default = new command_1.default('init [feature]')
74
81
  var _a;
75
82
  const config = runtime_store_1.default.get('config');
76
83
  const homeDir = (yield Promise.resolve().then(() => __importStar(require('os')))).homedir();
84
+ const projectId = (0, project_1.getDefaultProjectId)(false);
77
85
  const warnings = [];
78
86
  if (fs_1.SYNC.isPathOutside(homeDir, runtime_store_1.default.get('cwd'))) {
79
87
  warnings.push('You are currently outside your home directory');
@@ -81,7 +89,7 @@ exports.default = new command_1.default('init [feature]')
81
89
  if (runtime_store_1.default.get('cwd') === homeDir) {
82
90
  warnings.push('You are initializing your home directory as a Catalyst project');
83
91
  }
84
- if (config.loaded) {
92
+ if (projectId) {
85
93
  warnings.push('You are initializing in an existing Catalyst project directory');
86
94
  }
87
95
  let warningText = '';
@@ -89,8 +97,7 @@ exports.default = new command_1.default('init [feature]')
89
97
  warningText =
90
98
  '\nBefore we get started, keep in mind:\n\n ' +
91
99
  ansi_colors_1.yellow.bold('* ') +
92
- warnings.join('\n ' + ansi_colors_1.yellow.bold('* ')) +
93
- '\n';
100
+ warnings.join('\n ' + ansi_colors_1.yellow.bold('* '));
94
101
  }
95
102
  (0, shell_1.clearStdout)(true);
96
103
  const bannerString = yield fs_1.ASYNC.readFile(constants_1.TEMPLATE.banner);
@@ -100,16 +107,22 @@ exports.default = new command_1.default('init [feature]')
100
107
  (0, ansi_colors_1.bold)(runtime_store_1.default.get('project.root')) +
101
108
  '\n' +
102
109
  warningText);
103
- if (feature !== 'project') {
104
- try {
105
- yield (0, features_1.project)();
106
- }
107
- catch (er) {
108
- (0, index_1.debug)(er);
109
- return;
110
+ if ((0, env_1.isNonInteractiveMode)()) {
111
+ if (feature && feature !== 'project') {
112
+ throw new error_1.default('ni mode is only supported for project initialization.', {
113
+ exit: 1,
114
+ errorId: 'E_NON_INTERACTIVE_FEATURE_INIT'
115
+ });
110
116
  }
117
+ feature = 'project';
111
118
  }
112
- (0, index_1.info)();
119
+ yield (0, features_1.project)();
120
+ if (feature === 'project') {
121
+ return saveAndComplete(config);
122
+ }
123
+ const askFeatIp = !runtime_store_1.default.get('context.payload.project.import', false) &&
124
+ typeof feature !== 'string';
125
+ askFeatIp && (0, index_1.info)();
113
126
  const featureAns = yield prompt_1.default.ask(prompt_1.default.question('features', 'Which are the features you want to setup for this folder?\n This step is optional! Press ' +
114
127
  (0, ansi_colors_1.cyan)('<return> ') +
115
128
  'to proceed.\n', {
@@ -132,12 +145,13 @@ exports.default = new command_1.default('init [feature]')
132
145
  short: 'Slate'
133
146
  })
134
147
  ],
135
- when: !runtime_store_1.default.get('context.payload.project.import', false) &&
136
- typeof feature !== 'string'
148
+ when: askFeatIp
137
149
  }));
138
- if (!((_a = featureAns.features) === null || _a === void 0 ? void 0 : _a.length) &&
139
- (runtime_store_1.default.get('context.payload.project.import', false) ||
140
- typeof feature !== 'string')) {
150
+ if (!((_a = featureAns.features) === null || _a === void 0 ? void 0 : _a.length) && !feature) {
151
+ (0, index_1.message)('No features selected for setup. Exiting...');
152
+ return saveAndComplete(config);
153
+ }
154
+ if (runtime_store_1.default.get('context.payload.project.import', false)) {
141
155
  return saveAndComplete(config);
142
156
  }
143
157
  if (typeof feature === 'string') {
@@ -50,6 +50,7 @@ exports.default = new command_1.default('login')
50
50
  .description('Log the CLI in to your Catalyst account')
51
51
  .option('--no-localhost', 'login without browser')
52
52
  .option('--force', 'force re-authentication')
53
+ .option('--dc <us|eu|in|au|ca|sa|jp|uae>', 'data center to login to')
53
54
  .ci(false)
54
55
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
55
56
  const auth = yield Promise.resolve().then(() => __importStar(require('../authentication/index.js')));
@@ -56,13 +56,32 @@ const env_1 = require("../util_modules/env");
56
56
  const fs_1 = require("../util_modules/fs");
57
57
  const js_1 = require("../util_modules/js");
58
58
  const index_1 = require("../util_modules/logger/index");
59
- exports.default = new command_1.default('pull [feature]')
59
+ const utils_1 = require("../pull/utils");
60
+ const common_1 = require("../init/util/common");
61
+ const error_1 = __importDefault(require("../error"));
62
+ exports.default = new command_1.default('pull')
60
63
  .description('Pull resources of your project from the remote console to the local directory')
64
+ .argument('[feature]', 'The feature to pull from the remote console. Valid values are: functions, client, apig')
65
+ .option(utils_1.promptPullFields.get('overwrite'))
66
+ .option(utils_1.promptPullFields.get('resource'))
61
67
  .needs('auth', [scopes_js_1.default.functions, scopes_js_1.default.webapp])
62
68
  .needs('config', { optional: true })
63
69
  .needs('rc')
70
+ .niHelp([
71
+ 'In Non-Interactive mode at a time only one feature can be pulled.',
72
+ 'In case of pulling multiple features, run the command multiple times.'
73
+ ]
74
+ .map((_txt) => '* ' + _txt)
75
+ .join('\n'))
64
76
  .ci(false)
65
77
  .action((feature) => __awaiter(void 0, void 0, void 0, function* () {
78
+ if ((0, env_1.isNonInteractiveMode)() && !feature) {
79
+ throw new error_1.default('In Non-Interactive mode the feature to pull must be specified as an argument. For example: catalyst pull functions', {
80
+ exit: 1,
81
+ errorId: 'E_NON_INTERACTIVE_PULL_NO_FEATURE',
82
+ arg: [(0, ansi_colors_1.italic)('<feature>'), (0, ansi_colors_1.italic)(`catalyst pull ${(0, ansi_colors_1.green)('functions')}`)]
83
+ });
84
+ }
66
85
  const config = runtime_store_1.default.get('config');
67
86
  const homeDir = (yield Promise.resolve().then(() => __importStar(require('os')))).homedir();
68
87
  const warnings = [];
@@ -97,6 +116,8 @@ exports.default = new command_1.default('pull [feature]')
97
116
  (0, index_1.message)('Aborted by user.');
98
117
  return;
99
118
  }
119
+ !(0, env_1.isNonInteractiveMode)() &&
120
+ (0, common_1.ignorableOptsTest)(utils_1.promptPullFields.get('resource').optKey, 'The overwrite option is not applicable for this command in interactive mode.');
100
121
  let featureAns = { features: [feature] };
101
122
  if (feature === undefined) {
102
123
  const featureChoices = [
@@ -47,6 +47,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  const command_1 = __importDefault(require("../internal/command"));
49
49
  const constants_1 = require("../util_modules/constants");
50
+ const needed_scopes_1 = require("../util_modules/server/needed-scopes");
50
51
  exports.default = new command_1.default('serve')
51
52
  .description('Serve Basic I/O and Advanced I/O functions, Appsail and the client, to test them locally')
52
53
  .option('--http <port>', 'start the server at specified port ')
@@ -59,7 +60,7 @@ exports.default = new command_1.default('serve')
59
60
  .option('--except <targets>', 'serve all targets except specified (e.g. "client")')
60
61
  .option('--ignore-scripts', 'ignore the pre and post lifecycle scripts')
61
62
  .option('--no-open', 'disable opening the client automatically when served')
62
- .needs('auth', constants_1.NEEDED_SCOPES.SERVE)
63
+ .needs('auth', needed_scopes_1.SERVE_SCOPES)
63
64
  .needs('config')
64
65
  .needs('rc')
65
66
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
@@ -50,16 +50,19 @@ const command_1 = __importDefault(require("../../internal/command"));
50
50
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
51
51
  const constants_1 = require("../../util_modules/constants");
52
52
  const logger_1 = require("../../util_modules/logger");
53
+ const common_1 = require("../../init/util/common");
54
+ const prompt_fields_1 = require("../../init/features/slate/prompt-fields");
53
55
  exports.default = new command_1.default('slate:create')
54
56
  .description('Generates a new Slate app with starter examples')
55
- .option('--name <app_name>', 'Please provide name for your slate app')
56
- .option('--framework <framework_name>', 'Specify framework name for your slate')
57
- .option('--template <template_url>', 'Provide template url for your slate')
58
- .option('--default', 'Set default app configurations')
57
+ .option(prompt_fields_1.slateAddPromptFields.get('name'))
58
+ .option(prompt_fields_1.slateAddPromptFields.get('framework'))
59
+ .option(prompt_fields_1.slateAddPromptFields.get('template'))
60
+ .option(prompt_fields_1.slateAddPromptFields.get('default'))
59
61
  .needs('auth')
60
62
  .needs('config', { optional: true })
61
63
  .needs('rc', { optional: true, generateRc: true })
62
64
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
65
+ (0, common_1.niIgnorableOptsTest)([prompt_fields_1.slateAddPromptFields.get('default').optKey], 'Ignoring the following options in non-interactive mode:');
63
66
  const config = runtime_store_1.default.get('config');
64
67
  yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).slate();
65
68
  yield config.save();
@@ -50,17 +50,23 @@ const command_1 = __importDefault(require("../../internal/command"));
50
50
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
51
51
  const constants_1 = require("../../util_modules/constants");
52
52
  const logger_1 = require("../../util_modules/logger");
53
+ const prompt_fields_1 = require("../../init/features/slate/prompt-fields");
54
+ const common_1 = require("../../init/util/common");
53
55
  exports.default = new command_1.default('slate:link')
54
56
  .description('Links an existing local application to the Catalyst Slate service for web hosting')
55
- .option('--name <app_name>', 'Specify the name for your Slate application')
56
- .option('--framework <framework_name>', 'Specify the frontend framework used (e.g., React, Angular, Vue)')
57
- .option('--source <path>', 'Path to the existing slate app directory')
58
- .option('--template <template_url>', 'Provide a template URL to initialize your Slate application')
59
- .option('--default', 'Use default application configurations without prompting')
57
+ .option(prompt_fields_1.slateAddPromptFields.get('name'))
58
+ .option(prompt_fields_1.slateAddPromptFields.get('framework'))
59
+ .option(prompt_fields_1.slateAddPromptFields.get('source'))
60
+ .option(prompt_fields_1.slateAddPromptFields.get('template'))
61
+ .option(prompt_fields_1.slateAddPromptFields.get('default'))
60
62
  .needs('auth')
61
63
  .needs('config', { optional: true })
62
64
  .needs('rc', { optional: true, generateRc: true })
63
65
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
66
+ (0, common_1.niIgnorableOptsTest)([
67
+ prompt_fields_1.slateAddPromptFields.get('template').optKey,
68
+ prompt_fields_1.slateAddPromptFields.get('default').optKey
69
+ ], 'Ignoring the following options in non-interactive mode:');
64
70
  const config = runtime_store_1.default.get('config');
65
71
  yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).slate(true);
66
72
  yield config.save();
@@ -52,6 +52,13 @@ exports.default = new command_1.default('slate:unlink')
52
52
  }
53
53
  const slateDetails = slateServices.find((slate) => slate.name === appName);
54
54
  if (!slateDetails) {
55
+ if ((0, env_1.isNonInteractiveMode)()) {
56
+ throw new error_1.default(`No slates match the given name ${appName}.`, {
57
+ exit: 1,
58
+ errorId: 'SLULK-3',
59
+ arg: [(0, ansi_colors_1.bold)(slateServices.map((slate) => `* ${slate.name}`).join('\n'))]
60
+ });
61
+ }
55
62
  throw new error_1.default(`No slates match the given name ${appName}.`, {
56
63
  exit: 1,
57
64
  errorId: 'SLULK-2',
@@ -47,13 +47,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  const command_1 = __importDefault(require("../../../internal/command"));
49
49
  const constants_1 = require("../../../util_modules/constants");
50
- const prompt_1 = __importDefault(require("../../../prompt"));
50
+ const prompt_1 = __importStar(require("../../../prompt"));
51
51
  const js_1 = require("../../../util_modules/js");
52
52
  const endpoints_1 = require("../../../endpoints");
53
53
  const runtime_store_1 = __importDefault(require("../../../runtime-store"));
54
54
  const archiver_1 = __importDefault(require("../../../archiver"));
55
55
  const logger_1 = require("../../../util_modules/logger");
56
- const inquirer_1 = __importStar(require("inquirer"));
56
+ const inquirer_1 = require("inquirer");
57
57
  const error_1 = __importDefault(require("../../../error"));
58
58
  const project_1 = require("../../../util_modules/project");
59
59
  const features_1 = require("../../../init/features");
@@ -140,37 +140,33 @@ exports.default = new command_1.default('zest:generate')
140
140
  });
141
141
  }
142
142
  yield prompt_1.default.register('search-box');
143
- const specName = yield inquirer_1.default.prompt([
144
- {
145
- type: 'search-box',
146
- name: 'specs',
147
- searchable: true,
148
- pageSize: 10,
149
- highlight: true,
150
- notFoundMsg: 'No specifications found!',
151
- searchMsg: 'Search specifications...',
152
- message: 'Please search and select the specifications(Use space key to select)',
153
- source(_answersSoFar, input) {
154
- input || (input = '');
155
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
156
- const fuzzyResult = yield searchSpecification(input, specArray);
157
- const data = fuzzyResult.map((element) => {
158
- return {
159
- name: `${element.name}(${element.version})`,
160
- value: element.id
161
- };
162
- });
163
- resolve(data);
164
- }));
165
- },
166
- validate: (ansArr) => {
167
- if (js_1.JS.isEmpty(ansArr)) {
168
- return 'Must select one specification.';
169
- }
170
- return true;
143
+ const specName = yield prompt_1.default.ask(prompt_1.default.question('specs', 'Please search and select the specifications(Use space key to select)', {
144
+ type: 'search-box',
145
+ searchable: true,
146
+ pageSize: 10,
147
+ highlight: true,
148
+ notFoundMsg: 'No specifications found!',
149
+ searchMsg: 'Search specifications...',
150
+ source(_answersSoFar, input) {
151
+ input || (input = '');
152
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
153
+ const fuzzyResult = yield searchSpecification(input, specArray);
154
+ const data = fuzzyResult.map((element) => {
155
+ return {
156
+ name: `${element.name}(${element.version})`,
157
+ value: element.id
158
+ };
159
+ });
160
+ resolve(data);
161
+ }));
162
+ },
163
+ validate: (ansArr) => {
164
+ if (js_1.JS.isEmpty(ansArr)) {
165
+ return 'Must select one specification.';
171
166
  }
167
+ return true;
172
168
  }
173
- ]);
169
+ }));
174
170
  const srcTypeAns = yield prompt_1.default.ask(prompt_1.default.question('source', 'Please specify which source type you want to download', {
175
171
  type: 'list',
176
172
  choices: [
@@ -278,10 +274,7 @@ exports.default = new command_1.default('zest:generate')
278
274
  }
279
275
  const folderExists = yield fs_1.ASYNC.dirExists(outputDir);
280
276
  const overwriteAns = folderExists
281
- ? yield prompt_1.default.ask(prompt_1.default.question('overwrite', 'Directory ' + (0, ansi_colors_1.underline)(outputDir) + ' already exists. Overwrite ?', {
282
- type: 'confirm',
283
- defaultAns: false
284
- }))
277
+ ? yield prompt_1.default.ask((0, prompt_1.overwritePromptQuestion)({ resourceName: outputDir }))
285
278
  : { overwrite: true };
286
279
  if (!overwriteAns.overwrite) {
287
280
  (0, logger_1.labeled)('zest', `${sourceLabel} generation skipped.`).WARN();
@@ -43,7 +43,8 @@ exports.default = (...args_1) => __awaiter(void 0, [...args_1], void 0, function
43
43
  throw new error_1.default('No targets found');
44
44
  }
45
45
  const filtered = (0, appsail_utils_1.filterTargets)(targets);
46
- const validTargets = (yield (0, appsail_utils_1.validateAppSail)(filtered)).filter((targ) => {
46
+ const [_validatePromise] = (0, appsail_utils_1.validateAppSail)(filtered, false);
47
+ const validTargets = (yield _validatePromise).filter((targ) => {
47
48
  if (targ.validity.valid) {
48
49
  return targ;
49
50
  }
@@ -2,4 +2,6 @@ import { ISlateConfig } from '../../util_modules/config/lib/slate';
2
2
  declare const _default: () => Promise<void>;
3
3
  export default _default;
4
4
  export declare function getEnvironmentType(): string;
5
- export declare function slateLogger(): Array<ISlateConfig>;
5
+ export declare function slateLogger(opts?: {
6
+ wait?: boolean;
7
+ }): Promise<Array<ISlateConfig>>;