zcatalyst-cli 1.10.1 → 1.11.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 (113) hide show
  1. package/docs/client-utils.toml +5 -0
  2. package/docs/command_needs/auth.toml +1 -1
  3. package/docs/plugin-loader.toml +4 -0
  4. package/docs/serve/server/index.toml +4 -0
  5. package/docs/serve/server/lib/web_client/server.toml +4 -0
  6. package/lib/apig-utils.js +2 -1
  7. package/lib/client-utils.js +35 -6
  8. package/lib/command_needs/auth.js +2 -2
  9. package/lib/commands/client/delete.js +1 -0
  10. package/lib/commands/event/generate/index.js +4 -13
  11. package/lib/commands/iac/import.js +3 -1
  12. package/lib/commands/init.js +1 -1
  13. package/lib/commands/pull.js +1 -1
  14. package/lib/commands/serve.js +2 -1
  15. package/lib/error.js +6 -5
  16. package/lib/errorOut.js +2 -2
  17. package/lib/fn-utils/lib/common.js +4 -4
  18. package/lib/fn-utils/lib/java.js +1 -1
  19. package/lib/init/dependencies/npm-install.js +2 -9
  20. package/lib/init/features/client/index.js +47 -0
  21. package/lib/init/features/client/initializers/angular.js +88 -0
  22. package/lib/init/features/client/initializers/basic.js +27 -0
  23. package/lib/init/features/client/initializers/lyte.js +44 -0
  24. package/lib/init/features/client/initializers/react.js +53 -0
  25. package/lib/init/features/functions/languages/node.js +3 -1
  26. package/lib/init/features/index.js +10 -3
  27. package/lib/init/features/project.js +1 -1
  28. package/lib/internal/command.js +4 -1
  29. package/lib/internal/config.js +2 -1
  30. package/lib/optional-import.js +11 -25
  31. package/lib/plugin-loader.js +8 -2
  32. package/lib/port-resolver.js +4 -2
  33. package/lib/serve/index.js +6 -1
  34. package/lib/serve/server/index.js +52 -8
  35. package/lib/serve/server/lib/master.js +28 -12
  36. package/lib/serve/server/lib/web_client/index.js +30 -0
  37. package/lib/serve/server/lib/web_client/server.js +171 -0
  38. package/lib/serve/server/lib/web_client/utils.js +10 -0
  39. package/lib/util_modules/char.js +1 -1
  40. package/lib/util_modules/config/lib/apig.js +2 -1
  41. package/lib/util_modules/constants/index.js +3 -1
  42. package/lib/util_modules/constants/lib/placeholders.js +3 -1
  43. package/lib/util_modules/constants/lib/plugin.js +28 -0
  44. package/lib/util_modules/constants/lib/template.js +11 -1
  45. package/lib/util_modules/constants/lib/urls.js +8 -0
  46. package/lib/util_modules/{contextHelp.js → context-help.js} +0 -0
  47. package/lib/util_modules/env.js +13 -12
  48. package/lib/util_modules/global-space.js +99 -0
  49. package/lib/util_modules/option.js +5 -1
  50. package/lib/util_modules/shell.js +10 -6
  51. package/lib/winston.js +1 -1
  52. package/package.json +6 -3
  53. package/templates/init/.DS_Store +0 -0
  54. package/templates/init/client/.DS_Store +0 -0
  55. package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
  56. package/templates/init/client/{index.html → basic/index.html} +0 -0
  57. package/templates/init/client/{main.css → basic/main.css} +0 -0
  58. package/templates/init/client/{main.js → basic/main.js} +0 -0
  59. package/templates/init/client/lyte/build/build.js +301 -0
  60. package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
  61. package/templates/init/client/lyte/client-package.json +5 -0
  62. package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
  63. package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
  64. package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
  65. package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
  66. package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
  67. package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
  68. package/templates/init/client/lyte/index.html +17 -0
  69. package/templates/init/client/lyte/package.json +12 -0
  70. package/templates/init/client/lyte/router.js +14 -0
  71. package/templates/init/client/lyte/routes/index.js +54 -0
  72. package/templates/init/client/react/.DS_Store +0 -0
  73. package/templates/init/client/react/react_js/package.json +11 -0
  74. package/templates/init/client/react/react_js/template/README.md +70 -0
  75. package/templates/init/client/react/react_js/template/client-package.json +5 -0
  76. package/templates/init/client/react/react_js/template/gitignore +23 -0
  77. package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
  78. package/templates/init/client/react/react_js/template/public/index.html +43 -0
  79. package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
  80. package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
  81. package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
  82. package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
  83. package/templates/init/client/react/react_js/template/src/App.css +38 -0
  84. package/templates/init/client/react/react_js/template/src/App.js +25 -0
  85. package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
  86. package/templates/init/client/react/react_js/template/src/index.css +13 -0
  87. package/templates/init/client/react/react_js/template/src/index.js +17 -0
  88. package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
  89. package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
  90. package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
  91. package/templates/init/client/react/react_js/template.json +13 -0
  92. package/templates/init/client/react/react_ts/package.json +11 -0
  93. package/templates/init/client/react/react_ts/template/README.md +46 -0
  94. package/templates/init/client/react/react_ts/template/client-package.json +5 -0
  95. package/templates/init/client/react/react_ts/template/gitignore +23 -0
  96. package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
  97. package/templates/init/client/react/react_ts/template/public/index.html +43 -0
  98. package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
  99. package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
  100. package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
  101. package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
  102. package/templates/init/client/react/react_ts/template/src/App.css +38 -0
  103. package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
  104. package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
  105. package/templates/init/client/react/react_ts/template/src/index.css +13 -0
  106. package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
  107. package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
  108. package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
  109. package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
  110. package/templates/init/client/react/react_ts/template.json +18 -0
  111. package/templates/web-socket.txt +21 -0
  112. package/lib/init/features/client.js +0 -50
  113. package/lib/serve/server/lib/client.js +0 -30
@@ -22,3 +22,8 @@ link = 'https://www.zoho.com/catalyst/help/project-directory-structure.html#Clie
22
22
  context = '''Error when ${arg[0]} the Client with the ${arg[1]} plugin.'''
23
23
  aid = '''Please rectify the below error to continue. \n${arg[2]}'''
24
24
  link = ''
25
+
26
+ [CLIENT-UTILS-6]
27
+ context = '''Client Setup Skipped: Since the consent to overwrite the existing directory was not given.'''
28
+ aid = '''Existing directory: ${arg[0]}'''
29
+ link = ''
@@ -5,5 +5,5 @@ link = 'https://www.zoho.com/catalyst/help/cli-login.html'
5
5
 
6
6
  [AUTH-2]
7
7
  context = '''Oops! It looks like there is a scope missing for running this command'''
8
- aid = '''Please use the ${arg[0]} command to re-login, or provide different auth token via ${arg[1]} param'''
8
+ aid = '''Please use the ${arg[0]} command to re-login'''
9
9
  link = 'https://www.zoho.com/catalyst/help/cli-login.html'
@@ -0,0 +1,4 @@
1
+ [PLG-LDR-1]
2
+ context = '''The ${arg[0]} plugin configured to ${arg[1]} the ${arg[2]} is not found.'''
3
+ aid = '''Please install the ${arg[0]} plugin either locally or globally to ${arg[1]} the ${arg[2]}.'''
4
+ link = ''
@@ -0,0 +1,4 @@
1
+ [SERVE-IDX-1]
2
+ context = '''Error when serving the ${arg[0]} with the ${arg[1]} plugin.'''
3
+ aid = '''Please rectify the below error to serve the ${arg[0]}: \n${arg[2]}'''
4
+ link = ''
@@ -0,0 +1,4 @@
1
+ [WEB-CLIENT-SERVER-1]
2
+ context = '''The file provided as homepage(${arg[0]}) for the web-client is not found inside the client source directory.'''
3
+ aid = '''Please provide a valid file as the web-client homepage'''
4
+ link = ''
package/lib/apig-utils.js CHANGED
@@ -202,7 +202,8 @@ exports.apigUtils = {
202
202
  message: 'source_endpoint provided for apig rule "' +
203
203
  rule.name +
204
204
  '" is not valid',
205
- skipHelp: false
205
+ skipHelp: false,
206
+ fileName: __filename
206
207
  });
207
208
  err.errorId = 'APIG-UTILS-9';
208
209
  err.arg = [
@@ -27,6 +27,7 @@ const js_1 = require("./util_modules/js");
27
27
  const logger_1 = require("./util_modules/logger");
28
28
  const option_1 = require("./util_modules/option");
29
29
  const project_1 = require("./util_modules/project");
30
+ const prompt_1 = __importDefault(require("./prompt"));
30
31
  exports.clientUtils = {
31
32
  validate: (source) => __awaiter(void 0, void 0, void 0, function* () {
32
33
  const sourceDir = source || project_1.resolveProjectPath(config_1.clientConfig.source());
@@ -71,8 +72,8 @@ exports.clientUtils = {
71
72
  runtime_store_1.default.set('context.client.source', sourceDir);
72
73
  runtime_store_1.default.set('context.client.login_redirect', loginRedirect || homepage);
73
74
  runtime_store_1.default.set('context.client.package_json', packageJsonFile);
74
- const validatePlugin = yield plugin_loader_1.default('client', 'validate');
75
- if (validatePlugin === undefined) {
75
+ const validatePlugin = yield plugin_loader_1.default('client', 'validate').catch((err) => logger_1.debug(err));
76
+ if (typeof validatePlugin !== 'function') {
76
77
  runtime_store_1.default.set('context.client.valid', true);
77
78
  return packageJson;
78
79
  }
@@ -81,7 +82,8 @@ exports.clientUtils = {
81
82
  }
82
83
  catch (e) {
83
84
  const err = error_1.default.getErrorInstance(e, {
84
- skipHelp: false
85
+ skipHelp: false,
86
+ fileName: __filename
85
87
  });
86
88
  err.errorId = 'CLIENT-UTILS-5';
87
89
  err.arg = [
@@ -107,8 +109,8 @@ exports.clientUtils = {
107
109
  },
108
110
  pack: () => __awaiter(void 0, void 0, void 0, function* () {
109
111
  let source = project_1.resolveProjectPath(config_1.clientConfig.source());
110
- const buildPlugin = yield plugin_loader_1.default('client', 'build');
111
- if (buildPlugin !== undefined) {
112
+ const buildPlugin = yield plugin_loader_1.default('client', 'build').catch((err) => logger_1.debug(err));
113
+ if (typeof buildPlugin === 'function') {
112
114
  try {
113
115
  logger_1.message(`Plugin : "${runtime_store_1.default.get(`context.client.plugins.build`)}" is used for client deploy`);
114
116
  const outputDir = yield buildPlugin(source, runtime_store_1.default);
@@ -119,7 +121,8 @@ exports.clientUtils = {
119
121
  }
120
122
  catch (e) {
121
123
  const err = error_1.default.getErrorInstance(e, {
122
- skipHelp: false
124
+ skipHelp: false,
125
+ fileName: __filename
123
126
  });
124
127
  err.errorId = 'CLIENT-UTILS-5';
125
128
  err.arg = [
@@ -147,5 +150,31 @@ exports.clientUtils = {
147
150
  }
148
151
  conf.unset('client');
149
152
  yield conf.save();
153
+ }),
154
+ directoryOverridePrompt: (dir) => __awaiter(void 0, void 0, void 0, function* () {
155
+ const foldeExists = yield fs_1.ASYNC.dirExists(dir);
156
+ if (foldeExists) {
157
+ const overwriteAns = yield prompt_1.default.ask(prompt_1.default.question('overwrite', 'Directory ' + ansi_colors_1.underline(dir) + ' already exists. Overwrite ?', {
158
+ type: 'confirm',
159
+ defaultAns: false
160
+ }));
161
+ if (!overwriteAns.overwrite) {
162
+ throw new error_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)] });
163
+ }
164
+ yield fs_1.ASYNC.deleteDir(dir);
165
+ }
166
+ }),
167
+ clientNamePrompt: (question, defaultAns) => __awaiter(void 0, void 0, void 0, function* () {
168
+ const namePrompt = yield prompt_1.default.ask(prompt_1.default.question('name', question, {
169
+ type: 'input',
170
+ defaultAns,
171
+ validate: (ans) => {
172
+ if (ans.match(constants_1.REGEX.client.package_name)) {
173
+ return true;
174
+ }
175
+ return 'Invalid client name';
176
+ }
177
+ }));
178
+ return namePrompt.name;
150
179
  })
151
180
  };
@@ -45,11 +45,11 @@ exports.default = (inScopes = []) => {
45
45
  const requiredScopes = [constants_1.SCOPE.projects, ...inScopes];
46
46
  logger_1.debug('> command requires scopes: ' + JSON.stringify(requiredScopes));
47
47
  const hasAllScope = requiredScopes.every((scope) => existingScopes.includes(scope));
48
- if (!hasAllScope) {
48
+ if (!tokenObj.temp && !env_1.isCI && !hasAllScope) {
49
49
  throw new error_1.default('Re-login required due to missing scopes!!', {
50
50
  exit: 0,
51
51
  errorId: 'AUTH-2',
52
- arg: [ansi_colors_1.bold('catalyst login --force'), ansi_colors_1.bold('--token')]
52
+ arg: [ansi_colors_1.bold('catalyst login --force')]
53
53
  });
54
54
  }
55
55
  runtime_store_1.default.set('auth_scopes', requiredScopes);
@@ -88,6 +88,7 @@ exports.default = new command_1.default('client:delete [client_version]')
88
88
  }
89
89
  catch (error) {
90
90
  const err = error_1.default.getErrorInstance(error);
91
+ err.exit = 2;
91
92
  logger_1.debug('Failed to read ' + constants_1.FILENAME.client.package_json + ' Reason: ' + err.message);
92
93
  }
93
94
  if (clientVersion !== undefined && clientVersion !== localDel.version) {
@@ -49,14 +49,8 @@ exports.default = new command_1.default('event:generate <source> <action>')
49
49
  .needs('rc')
50
50
  .needs('auth')
51
51
  .action(function generate(source, action) {
52
- var _a;
53
52
  return __awaiter(this, void 0, void 0, function* () {
54
- const args = (_a = this.client) === null || _a === void 0 ? void 0 : _a.cli.parseOptions(process.argv);
55
- let unknownArgs = args.unknown;
56
- if (unknownArgs === undefined) {
57
- logger_1.debug('No unknownArgs supplied');
58
- unknownArgs = [];
59
- }
53
+ const unknownArgs = option_1.getUnknownOpts([]);
60
54
  if (unknownArgs.length % 2 !== 0) {
61
55
  throw new error_1.default('Unknown options are not provided as key value pairs', {
62
56
  exit: 1,
@@ -89,8 +83,8 @@ exports.default = new command_1.default('event:generate <source> <action>')
89
83
  if (currentIndex % 2 === 0) {
90
84
  if (!currentValue.startsWith('--') &&
91
85
  currentValue !== '-e' &&
92
- currentValue !== '-rid') {
93
- const knownArgs = args.operands.slice(2).join(' ');
86
+ currentValue !== '-rid' &&
87
+ currentValue !== '--verbose') {
94
88
  const fault = unknownArgs === null || unknownArgs === void 0 ? void 0 : unknownArgs.map((arg) => {
95
89
  if (arg === currentValue) {
96
90
  return ansi_colors_1.red(arg);
@@ -100,10 +94,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
100
94
  throw new error_1.default('Invalid option format detected', {
101
95
  exit: 1,
102
96
  errorId: 'IDX-3',
103
- arg: [
104
- ansi_colors_1.bold('[catalyst ' + knownArgs + ' ' + fault + ']'),
105
- ansi_colors_1.bold('--<option> <value>')
106
- ]
97
+ arg: [ansi_colors_1.italic(fault), ansi_colors_1.bold('--<option> <value>')]
107
98
  });
108
99
  }
109
100
  previousValue[currentValue.slice(2)] = optionArr[currentIndex + 1];
@@ -111,7 +111,9 @@ const ensureUserAction = (deployRes) => __awaiter(void 0, void 0, void 0, functi
111
111
  yield shell_1.spawn('catalyst', ['iac:status', 'import', ...optsArr], {
112
112
  shell: true,
113
113
  stdio: 'inherit'
114
- }).ASYNC();
114
+ })
115
+ .ASYNC()
116
+ .catch((err) => logger_1.debug(err));
115
117
  (exitListeners || []).forEach((listner) => {
116
118
  process.addListener('exit', listner);
117
119
  });
@@ -90,7 +90,7 @@ exports.default = new command_1.default('init [feature]')
90
90
  ansi_colors_1.bold(runtime_store_1.default.get('project.root')) +
91
91
  '\n' +
92
92
  warningText);
93
- const windownConfirmation = env_1.isWindows()
93
+ const windownConfirmation = env_1.isWindows
94
94
  ? yield prompt_1.default.ask(prompt_1.default.question('confirmation', 'Are you ready to proceed?', {
95
95
  type: 'confirm'
96
96
  }))
@@ -72,7 +72,7 @@ exports.default = new command_1.default('pull [feature]')
72
72
  ansi_colors_1.bold(runtime_store_1.default.get('project.root')) +
73
73
  '\n' +
74
74
  warningText);
75
- const ans = env_1.isWindows()
75
+ const ans = env_1.isWindows
76
76
  ? yield prompt_1.default.ask(prompt_1.default.question('confirmation', 'Are you ready to proceed?', {
77
77
  type: 'confirm'
78
78
  }))
@@ -41,9 +41,10 @@ exports.default = new command_1.default('serve')
41
41
  .option('--proxy <url>', 'proxy url to proxy any unknown request to the given url ' +
42
42
  '(e.g. "http://localhost:8080")')
43
43
  .option('--only <targets>', 'only serve specified, comma-separated targets (e.g. "client,functions:f1")')
44
- .option('--watch', 'watch for file and directory changes and enable hot reload')
44
+ .option('--no-watch', 'disable watching the files for changes')
45
45
  .option('--except <targets>', 'serve all targets except specified (e.g. "client")')
46
46
  .option('--ignore-scripts', 'ignore the pre and post lifescycle scripts')
47
+ .option('--no-open', 'disable opening the client automatically when served')
47
48
  .needs('auth', [constants_1.SCOPE.functions, constants_1.SCOPE.functions_execution, constants_1.SCOPE.webapp])
48
49
  .needs('config')
49
50
  .needs('rc')
package/lib/error.js CHANGED
@@ -8,7 +8,7 @@ const runtime_store_1 = __importDefault(require("./runtime-store"));
8
8
  const default_1 = __importDefault(require("./util_modules/constants/lib/default"));
9
9
  class CatalystError extends Error {
10
10
  constructor(message, options = {}) {
11
- var _a;
11
+ var _a, _b;
12
12
  super(message);
13
13
  this.name = default_1.default.catalystError;
14
14
  this.status = options.status || 500;
@@ -24,15 +24,15 @@ class CatalystError extends Error {
24
24
  this.fileName =
25
25
  options.fileName === undefined && stackArr[1] !== undefined
26
26
  ? stackArr[1].replace(/\.[^.]+$/, '').replace(/^[^(]+\(/, '')
27
- : options.fileName;
28
- runtime_store_1.default.set('log.' + this.fileName, runtime_store_1.default.get('log.' + this.fileName, []).concat(this));
27
+ : (_b = options.fileName) === null || _b === void 0 ? void 0 : _b.replace(/\.[^.]+$/, '');
28
+ runtime_store_1.default.set(`[log]["${this.fileName}"]`, runtime_store_1.default.get(`[log]["${this.fileName}"]`, []).concat(this));
29
29
  }
30
30
  }
31
31
  catch (e) {
32
32
  runtime_store_1.default.set('log.faultyError', runtime_store_1.default.get('log.faultyError', []).concat(this));
33
33
  }
34
34
  }
35
- static getErrorInstance(unknownError, { message, skipHelp } = {}) {
35
+ static getErrorInstance(unknownError, { message, skipHelp, fileName } = {}) {
36
36
  if (unknownError instanceof CatalystError) {
37
37
  if (message) {
38
38
  unknownError.message = message;
@@ -42,7 +42,8 @@ class CatalystError extends Error {
42
42
  if (unknownError instanceof Error) {
43
43
  return new CatalystError(message || unknownError.message, {
44
44
  original: unknownError,
45
- skipHelp: skipHelp === undefined ? true : skipHelp
45
+ skipHelp: skipHelp === undefined ? true : skipHelp,
46
+ fileName
46
47
  });
47
48
  }
48
49
  const newError = new CatalystError(message || 'Malformed error', {
package/lib/errorOut.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const logger_1 = require("./util_modules/logger");
7
7
  const error_1 = __importDefault(require("./error"));
8
8
  const constants_1 = require("./util_modules/constants");
9
- const contextHelp_1 = __importDefault(require("./util_modules/contextHelp"));
9
+ const context_help_1 = __importDefault(require("./util_modules/context-help"));
10
10
  exports.default = (error, status) => {
11
11
  if (typeof error === 'string') {
12
12
  error = new error_1.default('An unexpected error has occurred.', {
@@ -23,7 +23,7 @@ exports.default = (error, status) => {
23
23
  });
24
24
  }
25
25
  try {
26
- const exitCode = contextHelp_1.default();
26
+ const exitCode = context_help_1.default();
27
27
  process.exitCode = typeof exitCode === 'number' ? exitCode : 2;
28
28
  }
29
29
  catch (err) {
@@ -158,8 +158,8 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
158
158
  failure_reason: 'there is no valid ' + constants_1.FILENAME.catalyst_config + ' file present'
159
159
  };
160
160
  }
161
- const validatePlugin = yield plugin_loader_1.default('functions', 'validate', fnPath);
162
- if (validatePlugin !== undefined) {
161
+ const validatePlugin = yield plugin_loader_1.default('functions', 'validate', fnPath).catch((err) => logger_1.debug(err));
162
+ if (typeof validatePlugin === 'function') {
163
163
  try {
164
164
  yield validatePlugin(option_1.getCurrentCommand(), fnPath, runtime_store_1.default, catalystJson);
165
165
  }
@@ -249,8 +249,8 @@ function pack(target) {
249
249
  return __awaiter(this, void 0, void 0, function* () {
250
250
  try {
251
251
  let source = target.source;
252
- const buildPlugin = yield plugin_loader_1.default('functions', 'build', source);
253
- if (buildPlugin !== undefined) {
252
+ const buildPlugin = yield plugin_loader_1.default('functions', 'build', source).catch((err) => logger_1.debug(err));
253
+ if (typeof buildPlugin === 'function') {
254
254
  try {
255
255
  logger_1.message(`Plugin : "${runtime_store_1.default.get(`context.functions.plugins.build.${source}`)}" is used for functions deploy`);
256
256
  const outputDir = yield buildPlugin(source, runtime_store_1.default);
@@ -82,7 +82,7 @@ const keyWords = [
82
82
  'volatile',
83
83
  'while'
84
84
  ];
85
- exports.classPathSep = env_1.isWindows() ? ';' : ':';
85
+ exports.classPathSep = env_1.isWindows ? ';' : ':';
86
86
  function containsKeyWord(name) {
87
87
  return keyWords.some((keyWord) => {
88
88
  if (name === keyWord ||
@@ -13,19 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const prompt_1 = __importDefault(require("../../prompt"));
16
- const runtime_store_1 = __importDefault(require("../../runtime-store"));
17
- const constants_1 = require("../../util_modules/constants");
18
16
  const shell_1 = require("../../util_modules/shell");
19
- exports.default = (pth) => __awaiter(void 0, void 0, void 0, function* () {
17
+ exports.default = (pth, skipPrompt = false) => __awaiter(void 0, void 0, void 0, function* () {
20
18
  const ans = yield prompt_1.default.ask(prompt_1.default.question('NPMinstall', 'Do you wish to install all dependencies now ? ', {
21
19
  type: 'confirm',
22
20
  defaultAns: true,
23
- when: () => {
24
- if (runtime_store_1.default.get('context.functions.type') === constants_1.FN_TYPE.integration) {
25
- return false;
26
- }
27
- return true;
28
- }
21
+ when: () => !skipPrompt
29
22
  }));
30
23
  if (ans.NPMinstall === undefined || ans.NPMinstall) {
31
24
  return shell_1.spawn('npm', ['install'], { cwd: pth }).ASYNC();
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ const index_js_1 = __importDefault(require("../../../prompt/index.js"));
35
+ const index_js_2 = require("../../../util_modules/constants/index.js");
36
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
37
+ const clientInitAnswer = yield index_js_1.default.ask(index_js_1.default.question('clientFlavour', 'Choose the type of client to initialise: ', {
38
+ type: 'list',
39
+ choices: index_js_2.PLUGIN.client.map((plugin) => {
40
+ return index_js_1.default.choice(plugin + ' web app', {
41
+ value: plugin.toLowerCase(),
42
+ short: plugin.toUpperCase()
43
+ });
44
+ })
45
+ }));
46
+ return (yield Promise.resolve().then(() => __importStar(require('./initializers/' + clientInitAnswer.clientFlavour)))).default();
47
+ });
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const file_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/file-names.js"));
16
+ const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
17
+ const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
18
+ const folder_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/folder-names.js"));
19
+ const client_utils_js_1 = require("../../../../client-utils.js");
20
+ const project_js_1 = require("../../../../util_modules/project.js");
21
+ const shell_js_1 = require("../../../../util_modules/shell.js");
22
+ const runtime_store_js_1 = __importDefault(require("../../../../runtime-store.js"));
23
+ const logger_js_1 = require("../../../../util_modules/logger.js");
24
+ const ansi_colors_1 = require("ansi-colors");
25
+ const client_js_1 = require("../../../util/client.js");
26
+ const path_1 = require("path");
27
+ const global_space_js_1 = __importDefault(require("../../../../util_modules/global-space.js"));
28
+ const index_js_1 = require("../../../../util_modules/fs/index.js");
29
+ const error_js_1 = __importDefault(require("../../../../error.js"));
30
+ const { angular } = plugin_js_1.default;
31
+ const { client } = placeholders_js_1.default;
32
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
33
+ const clientName = yield client_utils_js_1.clientUtils.clientNamePrompt('Please provide a name for your Angular App:', 'angular-app');
34
+ const clientDirPath = project_js_1.resolveProjectPath(folder_names_js_1.default.client);
35
+ yield client_utils_js_1.clientUtils.directoryOverridePrompt(clientDirPath);
36
+ const opts = [
37
+ angular.runner_command[1],
38
+ clientName,
39
+ '--directory',
40
+ folder_names_js_1.default.client,
41
+ '--skip-git',
42
+ 'true'
43
+ ];
44
+ const isModuleFound = (yield global_space_js_1.default(angular.plugin, false));
45
+ try {
46
+ const collection = require.resolve(path_1.join(angular.collection_name, 'package.json'));
47
+ yield shell_js_1.spawn(angular.runner_command[0], [...opts, '--collection', path_1.dirname(collection)], {
48
+ stdio: 'inherit',
49
+ cwd: runtime_store_js_1.default.get('cwd'),
50
+ env: {
51
+ CATALYST_ANGULAR_PLUGIN_GLOBAL: isModuleFound ? 'true' : 'false'
52
+ }
53
+ }).ASYNC();
54
+ }
55
+ catch (e) {
56
+ if (e === null) {
57
+ throw new error_js_1.default('Process aborted!', { exit: 0, skipHelp: true });
58
+ }
59
+ const err = error_js_1.default.getErrorInstance(e).original;
60
+ if (!err.code || err.code !== 'ENOENT') {
61
+ throw err;
62
+ }
63
+ logger_js_1.info(`Angular CLI (${ansi_colors_1.red.italic('@angular/cli')}) not found....`);
64
+ logger_js_1.info(`Installing ${ansi_colors_1.bold('@angular/cli')} using ${ansi_colors_1.bold('npx')}`);
65
+ logger_js_1.info('Note: this may take a while...');
66
+ yield shell_js_1.spawn('npx', [
67
+ '-p',
68
+ angular.collection_name,
69
+ '-p',
70
+ angular.runner_package,
71
+ angular.runner_command[0],
72
+ ...opts,
73
+ '--collection',
74
+ angular.collection_name
75
+ ], {
76
+ stdio: 'inherit',
77
+ cwd: runtime_store_js_1.default.get('cwd'),
78
+ env: {
79
+ CATALYST_ANGULAR_PLUGIN_GLOBAL: isModuleFound ? 'true' : 'false'
80
+ }
81
+ }).ASYNC();
82
+ }
83
+ yield index_js_1.ASYNC.findAndReplace(path_1.join(clientDirPath, file_names_js_1.default.client.package_json))(client.package.name, clientName);
84
+ runtime_store_js_1.default.set('payload.client.plugin', isModuleFound
85
+ ? angular.plugin
86
+ : path_1.relative(project_js_1.getProjectRoot(), path_1.join(clientDirPath, 'node_modules', angular.plugin)));
87
+ return client_js_1.fillClientInitPayload(clientDirPath, clientName);
88
+ });
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const ansi_colors_1 = require("ansi-colors");
13
+ const constants_1 = require("../../../../util_modules/constants");
14
+ const fs_1 = require("../../../../util_modules/fs");
15
+ const logger_1 = require("../../../../util_modules/logger");
16
+ const project_1 = require("../../../../util_modules/project");
17
+ const client_utils_1 = require("../../../../client-utils");
18
+ const client_1 = require("../../../util/client");
19
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
20
+ logger_1.message('A directory ' + ansi_colors_1.cyan.bold('client') + ' will be created with a webapp pre-configured.');
21
+ const clientDirPath = project_1.resolveProjectPath(constants_1.FOLDERNAME.client);
22
+ yield client_utils_1.clientUtils.directoryOverridePrompt(clientDirPath);
23
+ yield fs_1.ASYNC.copyDir(constants_1.TEMPLATE.client.basic.new, clientDirPath);
24
+ const clientName = yield client_utils_1.clientUtils.clientNamePrompt('How do you want to address the client ?', 'sampleApp');
25
+ yield fs_1.ASYNC.findAndReplace(clientDirPath)(constants_1.PLACEHOLDER.client.package.name, clientName);
26
+ return client_1.fillClientInitPayload(clientDirPath, clientName);
27
+ });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const constants_1 = require("../../../../util_modules/constants");
16
+ const fs_1 = require("../../../../util_modules/fs");
17
+ const project_1 = require("../../../../util_modules/project");
18
+ const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
19
+ const path_1 = require("path");
20
+ const client_utils_1 = require("../../../../client-utils");
21
+ const global_space_1 = __importDefault(require("../../../../util_modules/global-space"));
22
+ const npm_install_1 = __importDefault(require("../../../dependencies/npm-install"));
23
+ const client_1 = require("../../../util/client");
24
+ const { lyte } = constants_1.PLUGIN;
25
+ const { client } = constants_1.PLACEHOLDER;
26
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
27
+ const clientName = yield client_utils_1.clientUtils.clientNamePrompt('Please provide a name for your Lyte web app: ', 'lyte-app');
28
+ const clientDirPath = project_1.resolveProjectPath(constants_1.FOLDERNAME.client);
29
+ yield client_utils_1.clientUtils.directoryOverridePrompt(clientDirPath);
30
+ yield fs_1.ASYNC.copyDir(constants_1.TEMPLATE.client.lyte, clientDirPath);
31
+ const isModuleFound = yield global_space_1.default(lyte.plugin);
32
+ yield fs_1.ASYNC.findAndReplace(clientDirPath)([client.package.name, client.package.devDependencies], [
33
+ clientName,
34
+ isModuleFound
35
+ ? ''
36
+ : ',\n "devDependencies": ' +
37
+ JSON.stringify({ [lyte.plugin]: 'latest' }, null, ' ').replace(/\n}/g, '\n }')
38
+ ]);
39
+ yield npm_install_1.default(clientDirPath, true);
40
+ runtime_store_1.default.set('payload.client.plugin', isModuleFound
41
+ ? lyte.plugin
42
+ : path_1.relative(project_1.getProjectRoot(), path_1.join(clientDirPath, 'node_modules', lyte.plugin)));
43
+ return client_1.fillClientInitPayload(clientDirPath, clientName);
44
+ });
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const constants_1 = require("../../../../util_modules/constants");
16
+ const client_utils_1 = require("../../../../client-utils");
17
+ const project_1 = require("../../../../util_modules/project");
18
+ const shell_1 = require("../../../../util_modules/shell");
19
+ const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
20
+ const fs_1 = require("../../../../util_modules/fs");
21
+ const path_1 = require("path");
22
+ const os_1 = require("os");
23
+ const global_space_1 = __importDefault(require("../../../../util_modules/global-space"));
24
+ const prompt_1 = __importDefault(require("../../../../prompt"));
25
+ const client_1 = require("../../../util/client");
26
+ const { react } = constants_1.PLUGIN;
27
+ const { client } = constants_1.PLACEHOLDER;
28
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
29
+ const flavourPrompt = yield prompt_1.default.ask(prompt_1.default.question('flavour', `Choose an option to create the React App:`, {
30
+ type: 'list',
31
+ choices: [
32
+ prompt_1.default.choice('JavaScript', { value: 'js', short: 'JavaScript' }),
33
+ prompt_1.default.choice('TypeScript', { value: 'ts', short: 'TypeScript' })
34
+ ]
35
+ }));
36
+ const clientName = yield client_utils_1.clientUtils.clientNamePrompt('Please provide a name for your React App:', 'react-app');
37
+ const clientDirPath = project_1.resolveProjectPath(clientName);
38
+ yield client_utils_1.clientUtils.directoryOverridePrompt(clientDirPath);
39
+ const catalystTempDir = path_1.join(os_1.tmpdir(), '.catalyst');
40
+ const reactPluginDir = path_1.join(catalystTempDir, 'react');
41
+ yield fs_1.ASYNC.emptyDir(reactPluginDir);
42
+ yield fs_1.ASYNC.copyDir(flavourPrompt.flavour === 'ts' ? constants_1.TEMPLATE.client.react.ts : constants_1.TEMPLATE.client.react.js, reactPluginDir);
43
+ const isModuleFound = yield global_space_1.default(react.plugin);
44
+ yield fs_1.ASYNC.findAndReplace(path_1.join(reactPluginDir))([client.package.name, client.package.devDependencies], [clientName, isModuleFound ? '' : `, "devDependencies": { "${react.plugin}": "latest" }`]);
45
+ yield shell_1.spawn('npx', [react.runner_command[0], clientName, '--template', 'file:' + reactPluginDir], {
46
+ stdio: 'inherit',
47
+ cwd: runtime_store_1.default.get('cwd')
48
+ }).ASYNC();
49
+ runtime_store_1.default.set('payload.client.plugin', isModuleFound
50
+ ? react.plugin
51
+ : path_1.relative(project_1.getProjectRoot(), path_1.join(clientDirPath, 'node_modules', react.plugin)));
52
+ return client_1.fillClientInitPayload(clientDirPath, clientName);
53
+ });
@@ -70,6 +70,8 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
70
70
  type: fnType,
71
71
  integ_config
72
72
  });
73
- yield npm_install_1.default(targetPath);
73
+ fnType === constants_1.FN_TYPE.integration
74
+ ? yield npm_install_1.default(targetPath, true)
75
+ : yield npm_install_1.default(targetPath);
74
76
  return functions_1.fillFunctionsInitPayload(targetPath, finalJson.name, stack, fnType);
75
77
  });