zcatalyst-cli 1.10.1 → 1.12.1

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 (149) hide show
  1. package/docs/.DS_Store +0 -0
  2. package/docs/client-utils.toml +5 -0
  3. package/docs/command_needs/auth.toml +1 -1
  4. package/docs/optional-import.toml +10 -0
  5. package/docs/plugin-loader.toml +4 -0
  6. package/docs/serve/server/index.toml +4 -0
  7. package/docs/serve/server/lib/web_client/server.toml +4 -0
  8. package/lib/apig-utils.js +2 -1
  9. package/lib/authentication/login.js +10 -12
  10. package/lib/client-utils.js +8 -6
  11. package/lib/command_needs/auth.js +2 -2
  12. package/lib/commands/client/delete.js +2 -1
  13. package/lib/commands/ds/status.js +5 -5
  14. package/lib/commands/event/generate/index.js +4 -13
  15. package/lib/commands/functions/delete.js +2 -2
  16. package/lib/commands/functions/shell.js +5 -2
  17. package/lib/commands/iac/import.js +37 -10
  18. package/lib/commands/init.js +1 -1
  19. package/lib/commands/pull.js +1 -1
  20. package/lib/commands/serve.js +2 -1
  21. package/lib/endpoints/lib/sdk.js +2 -2
  22. package/lib/error.js +16 -13
  23. package/lib/errorOut.js +2 -2
  24. package/lib/fn-utils/lib/common.js +4 -4
  25. package/lib/fn-utils/lib/java.js +6 -4
  26. package/lib/fn-utils/lib/node.js +2 -2
  27. package/lib/init/dependencies/npm-install.js +10 -10
  28. package/lib/init/features/client/index.js +47 -0
  29. package/lib/init/features/client/initializers/angular.js +104 -0
  30. package/lib/init/features/client/initializers/basic.js +50 -0
  31. package/lib/init/features/client/initializers/lyte.js +56 -0
  32. package/lib/init/features/client/initializers/react.js +78 -0
  33. package/lib/init/features/functions/index.js +14 -5
  34. package/lib/init/features/functions/languages/node.js +3 -1
  35. package/lib/init/features/index.js +10 -3
  36. package/lib/init/features/project.js +1 -1
  37. package/lib/init/util/client.js +89 -4
  38. package/lib/internal/command.js +4 -1
  39. package/lib/internal/config.js +2 -1
  40. package/lib/optional-import.js +27 -26
  41. package/lib/plugin-loader.js +27 -10
  42. package/lib/port-resolver.js +4 -2
  43. package/lib/prompt/index.js +1 -1
  44. package/lib/pull/features/functions/index.js +1 -1
  45. package/lib/serve/index.js +6 -1
  46. package/lib/serve/server/index.js +52 -8
  47. package/lib/serve/server/lib/java/JavaaioServer.java +3 -2
  48. package/lib/serve/server/lib/master.js +22 -24
  49. package/lib/serve/server/lib/web_client/index.js +30 -0
  50. package/lib/serve/server/lib/web_client/server.js +174 -0
  51. package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +7 -1
  52. package/lib/shell/dependencies/invoker/bio/node.js +5 -2
  53. package/lib/shell/index.js +10 -6
  54. package/lib/util_modules/char.js +1 -1
  55. package/lib/util_modules/config/lib/apig.js +2 -1
  56. package/lib/util_modules/config/lib/client.js +18 -21
  57. package/lib/util_modules/constants/index.js +3 -1
  58. package/lib/util_modules/constants/lib/placeholders.js +1 -0
  59. package/lib/util_modules/constants/lib/plugin.js +28 -0
  60. package/lib/util_modules/constants/lib/template.js +11 -1
  61. package/lib/util_modules/constants/lib/urls.js +29 -13
  62. package/lib/util_modules/{contextHelp.js → context-help.js} +0 -0
  63. package/lib/util_modules/env.js +13 -12
  64. package/lib/util_modules/fs/index.js +1 -9
  65. package/lib/util_modules/fs/lib/async.js +3 -3
  66. package/lib/util_modules/fs/utils.js +8 -0
  67. package/lib/util_modules/global-space.js +2 -0
  68. package/lib/util_modules/option.js +5 -1
  69. package/lib/util_modules/server.js +53 -0
  70. package/lib/util_modules/shell.js +10 -6
  71. package/lib/winston.js +1 -1
  72. package/package.json +8 -5
  73. package/templates/.DS_Store +0 -0
  74. package/templates/init/.DS_Store +0 -0
  75. package/templates/init/client/.DS_Store +0 -0
  76. package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
  77. package/templates/init/client/{index.html → basic/index.html} +0 -0
  78. package/templates/init/client/{main.css → basic/main.css} +0 -0
  79. package/templates/init/client/{main.js → basic/main.js} +0 -0
  80. package/templates/init/client/lyte/build/build.js +301 -0
  81. package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
  82. package/templates/init/client/lyte/client-package.json +5 -0
  83. package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
  84. package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
  85. package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
  86. package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
  87. package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
  88. package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
  89. package/templates/init/client/lyte/index.html +17 -0
  90. package/templates/init/client/lyte/package.json +12 -0
  91. package/templates/init/client/lyte/router.js +14 -0
  92. package/templates/init/client/lyte/routes/index.js +54 -0
  93. package/templates/init/client/react/.DS_Store +0 -0
  94. package/templates/init/client/react/react_js/package.json +11 -0
  95. package/templates/init/client/react/react_js/template/README.md +70 -0
  96. package/templates/init/client/react/react_js/template/client-package.json +5 -0
  97. package/templates/init/client/react/react_js/template/gitignore +23 -0
  98. package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
  99. package/templates/init/client/react/react_js/template/public/index.html +43 -0
  100. package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
  101. package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
  102. package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
  103. package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
  104. package/templates/init/client/react/react_js/template/src/App.css +38 -0
  105. package/templates/init/client/react/react_js/template/src/App.js +25 -0
  106. package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
  107. package/templates/init/client/react/react_js/template/src/index.css +13 -0
  108. package/templates/init/client/react/react_js/template/src/index.js +17 -0
  109. package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
  110. package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
  111. package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
  112. package/templates/init/client/react/react_js/template.json +13 -0
  113. package/templates/init/client/react/react_ts/package.json +11 -0
  114. package/templates/init/client/react/react_ts/template/README.md +46 -0
  115. package/templates/init/client/react/react_ts/template/client-package.json +5 -0
  116. package/templates/init/client/react/react_ts/template/gitignore +23 -0
  117. package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
  118. package/templates/init/client/react/react_ts/template/public/index.html +43 -0
  119. package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
  120. package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
  121. package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
  122. package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
  123. package/templates/init/client/react/react_ts/template/src/App.css +38 -0
  124. package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
  125. package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
  126. package/templates/init/client/react/react_ts/template/src/index.css +13 -0
  127. package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
  128. package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
  129. package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
  130. package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
  131. package/templates/init/client/react/react_ts/template.json +18 -0
  132. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +116 -113
  133. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
  134. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
  135. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
  136. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
  137. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
  138. package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
  139. package/templates/init/functions/java/integ/cliq/sample.java +5 -7
  140. package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
  141. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +23 -8
  142. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -4
  143. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
  144. package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
  145. package/templates/init/functions/node/integ/cliq/package.json +2 -1
  146. package/templates/init/functions/node/integ/cliq/sample.js +3 -1
  147. package/templates/web-socket.txt +21 -0
  148. package/lib/init/features/client.js +0 -50
  149. package/lib/serve/server/lib/client.js +0 -30
@@ -16,10 +16,10 @@ exports.validate = void 0;
16
16
  const ansi_colors_1 = require("ansi-colors");
17
17
  const path_1 = require("path");
18
18
  const error_1 = __importDefault(require("../../error"));
19
+ const npm_install_1 = __importDefault(require("../../init/dependencies/npm-install"));
19
20
  const constants_1 = require("../../util_modules/constants");
20
21
  const fs_1 = require("../../util_modules/fs");
21
22
  const js_1 = require("../../util_modules/js");
22
- const shell_1 = require("../../util_modules/shell");
23
23
  function validate(targets, idx) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  if (targets.length < idx + 1) {
@@ -50,7 +50,7 @@ function validate(targets, idx) {
50
50
  }
51
51
  const nodeModuleExists = yield fs_1.ASYNC.dirExists(path_1.join(currentTarget.source, constants_1.FILENAME.node_modules));
52
52
  if (!nodeModuleExists) {
53
- yield shell_1.spawn('npm', ['install'], { cwd: currentTarget.source }).ASYNC();
53
+ yield npm_install_1.default(currentTarget.source, true);
54
54
  }
55
55
  currentTarget.valid = true;
56
56
  return validate(targets, ++idx);
@@ -12,23 +12,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const error_1 = __importDefault(require("../../error"));
15
16
  const prompt_1 = __importDefault(require("../../prompt"));
16
- const runtime_store_1 = __importDefault(require("../../runtime-store"));
17
- const constants_1 = require("../../util_modules/constants");
18
17
  const shell_1 = require("../../util_modules/shell");
19
- exports.default = (pth) => __awaiter(void 0, void 0, void 0, function* () {
18
+ exports.default = (pth, skipPrompt = false) => __awaiter(void 0, void 0, void 0, function* () {
20
19
  const ans = yield prompt_1.default.ask(prompt_1.default.question('NPMinstall', 'Do you wish to install all dependencies now ? ', {
21
20
  type: 'confirm',
22
21
  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
- }
22
+ when: () => !skipPrompt
29
23
  }));
30
24
  if (ans.NPMinstall === undefined || ans.NPMinstall) {
31
- return shell_1.spawn('npm', ['install'], { cwd: pth }).ASYNC();
25
+ return shell_1.spawn('npm', ['install'], { cwd: pth })
26
+ .ASYNC()
27
+ .catch((err) => {
28
+ throw error_1.default.getErrorInstance(err, {
29
+ message: 'Failure when executing npm install.'
30
+ });
31
+ });
32
32
  }
33
33
  return;
34
34
  });
@@ -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,104 @@
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 file_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/file-names.js"));
35
+ const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
36
+ const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
37
+ const folder_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/folder-names.js"));
38
+ const project_js_1 = require("../../../../util_modules/project.js");
39
+ const shell_js_1 = require("../../../../util_modules/shell.js");
40
+ const runtime_store_js_1 = __importDefault(require("../../../../runtime-store.js"));
41
+ const logger_js_1 = require("../../../../util_modules/logger.js");
42
+ const ansi_colors_1 = require("ansi-colors");
43
+ const client_js_1 = require("../../../util/client.js");
44
+ const path_1 = require("path");
45
+ const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
46
+ const error_js_1 = __importDefault(require("../../../../error.js"));
47
+ const { angular } = plugin_js_1.default;
48
+ const { client } = placeholders_js_1.default;
49
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
50
+ const clientName = yield client_js_1.clientNamePrompt('Please provide a name for your Angular App:', 'angular-app');
51
+ const clientDirPath = project_js_1.resolveProjectPath(folder_names_js_1.default.client);
52
+ yield client_js_1.directoryOverridePrompt(clientDirPath);
53
+ const opts = [
54
+ angular.runner_command[1],
55
+ clientName,
56
+ '--directory',
57
+ folder_names_js_1.default.client,
58
+ '--skip-git',
59
+ 'true'
60
+ ];
61
+ try {
62
+ const collection = require.resolve(path_1.join(angular.collection_name, 'package.json'));
63
+ yield shell_js_1.spawn(angular.runner_command[0], [...opts, '--collection', path_1.dirname(collection)], {
64
+ stdio: 'inherit',
65
+ cwd: runtime_store_js_1.default.get('cwd')
66
+ }).ASYNC();
67
+ }
68
+ catch (e) {
69
+ if (e === null) {
70
+ throw new error_js_1.default('Process aborted!', { exit: 0, skipHelp: true });
71
+ }
72
+ const err = error_js_1.default.getErrorInstance(e, {
73
+ message: 'Failure when creating new Angular App'
74
+ }).original;
75
+ if (!err.code || err.code !== 'ENOENT') {
76
+ throw err;
77
+ }
78
+ logger_js_1.info(`Angular CLI (${ansi_colors_1.red.italic('@angular/cli')}) not found....`);
79
+ logger_js_1.info(`Installing ${ansi_colors_1.bold('@angular/cli')} using ${ansi_colors_1.bold('npx')}`);
80
+ logger_js_1.info('Note: this may take a while...');
81
+ yield shell_js_1.spawn('npx', [
82
+ '-p',
83
+ angular.collection_name,
84
+ '-p',
85
+ angular.runner_package,
86
+ angular.runner_command[0],
87
+ ...opts,
88
+ '--collection',
89
+ angular.collection_name
90
+ ], {
91
+ stdio: 'inherit',
92
+ cwd: runtime_store_js_1.default.get('cwd')
93
+ })
94
+ .ASYNC()
95
+ .catch((err) => {
96
+ throw error_js_1.default.getErrorInstance(err, {
97
+ message: 'Failure when creating new Angular App with npx'
98
+ });
99
+ });
100
+ }
101
+ yield ASYNC.findAndReplace(path_1.join(clientDirPath, file_names_js_1.default.client.package_json))(client.package.name, clientName);
102
+ runtime_store_js_1.default.set('payload.client.plugin', angular.plugin);
103
+ return client_js_1.fillClientInitPayload(clientDirPath, clientName);
104
+ });
@@ -0,0 +1,50 @@
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 ansi_colors_1 = require("ansi-colors");
35
+ const folder_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/folder-names.js"));
36
+ const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
37
+ const template_js_1 = __importDefault(require("../../../../util_modules/constants/lib/template.js"));
38
+ const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
39
+ const logger_js_1 = require("../../../../util_modules/logger.js");
40
+ const project_js_1 = require("../../../../util_modules/project.js");
41
+ const client_js_1 = require("../../../util/client.js");
42
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
43
+ logger_js_1.message('A directory ' + ansi_colors_1.cyan.bold('client') + ' will be created with a webapp pre-configured.');
44
+ const clientDirPath = project_js_1.resolveProjectPath(folder_names_js_1.default.client);
45
+ yield client_js_1.directoryOverridePrompt(clientDirPath);
46
+ yield ASYNC.copyDir(template_js_1.default.client.basic.new, clientDirPath);
47
+ const clientName = yield client_js_1.clientNamePrompt('How do you want to address the client ?', 'sampleApp');
48
+ yield ASYNC.findAndReplace(clientDirPath)(placeholders_js_1.default.client.package.name, clientName);
49
+ return client_js_1.fillClientInitPayload(clientDirPath, clientName);
50
+ });
@@ -0,0 +1,56 @@
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 path_1 = require("path");
35
+ const client_js_1 = require("../../../util/client.js");
36
+ const runtime_store_js_1 = __importDefault(require("../../../../runtime-store.js"));
37
+ const npm_install_js_1 = __importDefault(require("../../../dependencies/npm-install.js"));
38
+ const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
39
+ const template_js_1 = __importDefault(require("../../../../util_modules/constants/lib/template.js"));
40
+ const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
41
+ const folder_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/folder-names.js"));
42
+ const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
43
+ const project_js_1 = require("../../../../util_modules/project.js");
44
+ const { lyte } = plugin_js_1.default;
45
+ const { client } = placeholders_js_1.default;
46
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
47
+ const clientName = yield client_js_1.clientNamePrompt('Please provide a name for your Lyte web app: ', 'lyte-app');
48
+ const clientDirPath = project_js_1.resolveProjectPath(folder_names_js_1.default.client);
49
+ yield client_js_1.directoryOverridePrompt(clientDirPath);
50
+ yield ASYNC.copyDir(template_js_1.default.client.lyte, clientDirPath);
51
+ yield client_js_1.addDependency(path_1.join(clientDirPath, 'package.json'), { [lyte.plugin]: 'latest' }, { dev: true });
52
+ yield ASYNC.findAndReplace(clientDirPath)(client.package.name, clientName);
53
+ yield npm_install_js_1.default(clientDirPath, true);
54
+ runtime_store_js_1.default.set('payload.client.plugin', lyte.plugin);
55
+ return client_js_1.fillClientInitPayload(clientDirPath, clientName);
56
+ });
@@ -0,0 +1,78 @@
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 project_js_1 = require("../../../../util_modules/project.js");
35
+ const shell_js_1 = require("../../../../util_modules/shell.js");
36
+ const runtime_store_js_1 = __importDefault(require("../../../../runtime-store.js"));
37
+ const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
38
+ const path_1 = require("path");
39
+ const os_1 = require("os");
40
+ const index_js_1 = __importDefault(require("../../../../prompt/index.js"));
41
+ const client_js_1 = require("../../../util/client.js");
42
+ const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
43
+ const template_js_1 = __importDefault(require("../../../../util_modules/constants/lib/template.js"));
44
+ const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
45
+ const error_js_1 = __importDefault(require("../../../../error.js"));
46
+ const { react } = plugin_js_1.default;
47
+ const { client } = placeholders_js_1.default;
48
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
49
+ const flavourPrompt = yield index_js_1.default.ask(index_js_1.default.question('flavour', `Choose an option to create the React App:`, {
50
+ type: 'list',
51
+ choices: [
52
+ index_js_1.default.choice('JavaScript', { value: 'js', short: 'JavaScript' }),
53
+ index_js_1.default.choice('TypeScript', { value: 'ts', short: 'TypeScript' })
54
+ ]
55
+ }));
56
+ const clientName = yield client_js_1.clientNamePrompt('Please provide a name for your React App:', 'react-app');
57
+ const clientDirPath = project_js_1.resolveProjectPath(clientName);
58
+ yield client_js_1.directoryOverridePrompt(clientDirPath);
59
+ const catalystTempDir = path_1.join(os_1.tmpdir(), '.catalyst');
60
+ const reactPluginDir = path_1.join(catalystTempDir, 'react');
61
+ yield ASYNC.emptyDir(reactPluginDir);
62
+ yield ASYNC.copyDir(flavourPrompt.flavour === 'ts' ? template_js_1.default.client.react.ts : template_js_1.default.client.react.js, reactPluginDir);
63
+ yield client_js_1.addDependency(path_1.join(reactPluginDir, 'template.json'), { [react.plugin]: 'latest' }, { depPath: ['package'] });
64
+ yield ASYNC.findAndReplace(reactPluginDir)(client.package.name, clientName);
65
+ yield shell_js_1.spawn('npx', [react.runner_command[0], clientName, '--template', 'file:' + reactPluginDir], {
66
+ stdio: 'inherit',
67
+ cwd: runtime_store_js_1.default.get('cwd')
68
+ })
69
+ .ASYNC()
70
+ .catch((err) => {
71
+ throw error_js_1.default.getErrorInstance(err, {
72
+ message: 'Failure while Creating react app',
73
+ skipHelp: false
74
+ });
75
+ });
76
+ runtime_store_js_1.default.set('payload.client.plugin', react.plugin);
77
+ return client_js_1.fillClientInitPayload(clientDirPath, clientName);
78
+ });
@@ -85,7 +85,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
85
85
  logger_1.debug('Language cannot be identified hence skipping');
86
86
  return acc;
87
87
  }
88
- const lang = languages_1.default[langArr[0]];
88
+ const runtimeLang = langArr[0];
89
+ const langFn = languages_1.default[runtimeLang];
89
90
  let displayValue = value;
90
91
  let disabled = false;
91
92
  if (runtimeDetails.eol_runtimes && runtimeDetails.eol_runtimes[value]) {
@@ -106,14 +107,22 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
106
107
  return acc;
107
108
  }
108
109
  }
109
- acc.push(prompt_1.default.choice(displayValue, { value: lang(value), short: value, disabled }));
110
+ if (acc[runtimeLang].length === 0) {
111
+ const sep = {
112
+ node: '---NodeJS---',
113
+ java: '----Java----'
114
+ };
115
+ acc[runtimeLang].push(prompt_1.default.separator(sep[runtimeLang]));
116
+ }
117
+ acc[runtimeLang].push(prompt_1.default.choice(displayValue, { value: langFn(value), short: value, disabled }));
110
118
  return acc;
111
- }, []);
119
+ }, { node: [], java: [] });
120
+ const runtimeChoicesArr = [...runtimeChoices.java, ...runtimeChoices.node];
112
121
  const runtimeAns = yield prompt_1.default.ask(prompt_1.default.question('runtime', 'Which runtime do you prefer to write your function?', {
113
122
  type: 'list',
114
- choices: runtimeChoices,
123
+ choices: runtimeChoicesArr,
115
124
  when: () => {
116
- return runtimeChoices.length > 1;
125
+ return runtimeChoicesArr.length > 1;
117
126
  }
118
127
  }));
119
128
  if (runtimeAns === undefined || runtimeAns.runtime === undefined) {
@@ -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
  });
@@ -98,6 +98,13 @@ function setFnConfig(featureName, add) {
98
98
  break;
99
99
  case 'client':
100
100
  config.set('client.source', targetSource);
101
+ const plugin = runtime_store_1.default.get('payload.client.plugin', false);
102
+ if (plugin) {
103
+ config.set('client.plugin', plugin);
104
+ }
105
+ else {
106
+ config.unset('client.plugin');
107
+ }
101
108
  break;
102
109
  case 'apig':
103
110
  config.set('apig.rules', targetSource);
@@ -109,21 +116,21 @@ function setFnConfig(featureName, add) {
109
116
  exports.setFnConfig = setFnConfig;
110
117
  function functions(add = false) {
111
118
  return __awaiter(this, void 0, void 0, function* () {
112
- yield (yield Promise.resolve().then(() => __importStar(require('./functions')))).default();
119
+ yield (yield Promise.resolve().then(() => __importStar(require('./functions/index.js')))).default();
113
120
  setFnConfig('functions', add);
114
121
  });
115
122
  }
116
123
  exports.functions = functions;
117
124
  function client() {
118
125
  return __awaiter(this, void 0, void 0, function* () {
119
- yield (yield Promise.resolve().then(() => __importStar(require('./client')))).default();
126
+ yield (yield Promise.resolve().then(() => __importStar(require('./client/index.js')))).default();
120
127
  setFnConfig('client', false);
121
128
  });
122
129
  }
123
130
  exports.client = client;
124
131
  function project() {
125
132
  return __awaiter(this, void 0, void 0, function* () {
126
- yield (yield Promise.resolve().then(() => __importStar(require('./project')))).default();
133
+ yield (yield Promise.resolve().then(() => __importStar(require('./project.js')))).default();
127
134
  const projectPayload = runtime_store_1.default.get('payload.project', null);
128
135
  if (!projectPayload) {
129
136
  return;
@@ -58,7 +58,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
58
58
  const allProjects = (yield projectAPI.getAllProjects());
59
59
  if (allProjects.length === 0) {
60
60
  throw new error_1.default('Visit ' +
61
- ansi_colors_1.underline(constants_1.ORIGIN.admin) +
61
+ ansi_colors_1.underline(constants_1.ORIGIN.console) +
62
62
  ' for creation of your first project before you continue.', { exit: 1 });
63
63
  }
64
64
  const projectChoices = [
@@ -1,12 +1,97 @@
1
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
+ };
2
30
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
32
  };
5
33
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fillClientInitPayload = void 0;
7
- const runtime_store_1 = __importDefault(require("../../runtime-store"));
34
+ exports.addDependency = exports.clientNamePrompt = exports.directoryOverridePrompt = exports.fillClientInitPayload = void 0;
35
+ const ansi_colors_1 = require("ansi-colors");
36
+ const runtime_store_js_1 = __importDefault(require("../../runtime-store.js"));
37
+ const error_js_1 = __importDefault(require("../../error.js"));
38
+ const index_js_1 = __importDefault(require("../../prompt/index.js"));
39
+ const regex_js_1 = __importDefault(require("../../util_modules/constants/lib/regex.js"));
40
+ const ASYNC = __importStar(require("../../util_modules/fs/lib/async.js"));
41
+ const logger_js_1 = require("../../util_modules/logger.js");
42
+ const js_js_1 = require("../../util_modules/js.js");
8
43
  const fillClientInitPayload = (source, name) => {
9
- runtime_store_1.default.set('payload.client.source', source);
10
- runtime_store_1.default.set('payload.client.name', name);
44
+ runtime_store_js_1.default.set('payload.client.source', source);
45
+ runtime_store_js_1.default.set('payload.client.name', name);
11
46
  };
12
47
  exports.fillClientInitPayload = fillClientInitPayload;
48
+ function directoryOverridePrompt(dir) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const foldeExists = yield ASYNC.dirExists(dir);
51
+ if (foldeExists) {
52
+ const overwriteAns = yield index_js_1.default.ask(index_js_1.default.question('overwrite', 'Directory ' + ansi_colors_1.underline(dir) + ' already exists. Overwrite ?', {
53
+ type: 'confirm',
54
+ defaultAns: false
55
+ }));
56
+ if (!overwriteAns.overwrite) {
57
+ throw new error_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)] });
58
+ }
59
+ yield ASYNC.deleteDir(dir);
60
+ }
61
+ });
62
+ }
63
+ exports.directoryOverridePrompt = directoryOverridePrompt;
64
+ function clientNamePrompt(question, defaultAns) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ const namePrompt = yield index_js_1.default.ask(index_js_1.default.question('name', question, {
67
+ type: 'input',
68
+ defaultAns,
69
+ validate: (ans) => {
70
+ if (ans.match(regex_js_1.default.client.package_name)) {
71
+ return true;
72
+ }
73
+ return 'Invalid client name';
74
+ }
75
+ }));
76
+ return namePrompt.name;
77
+ });
78
+ }
79
+ exports.clientNamePrompt = clientNamePrompt;
80
+ function addDependency(filePath, dep, { dev = false, depPath = [] } = {}) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ try {
83
+ const packageJson = yield ASYNC.readJSONFile(filePath);
84
+ if (packageJson) {
85
+ depPath.push(dev ? 'devDependencies' : 'dependencies');
86
+ js_js_1.JS.assign(dep, js_js_1.JS.get(packageJson, depPath));
87
+ js_js_1.JS.set(packageJson, depPath, dep);
88
+ yield ASYNC.writeJSONFile(filePath, packageJson);
89
+ }
90
+ }
91
+ catch (e) {
92
+ const err = error_js_1.default.getErrorInstance(e, { skipHelp: true });
93
+ logger_js_1.debug(`unable to write to ${filePath}: ${err.message}`);
94
+ }
95
+ });
96
+ }
97
+ exports.addDependency = addDependency;
@@ -167,7 +167,10 @@ class Command {
167
167
  args.push({});
168
168
  }
169
169
  const [opts, command] = args.slice(-2);
170
- runtime_store_1.default.set('opts', Object.assign({ _name: command.name() }, opts));
170
+ const unknownOpts = this.allowUnknownOptions
171
+ ? command.parseOptions(process.argv).unknown
172
+ : undefined;
173
+ runtime_store_1.default.set('opts', Object.assign({ _name: command.name(), unknownOpts }, opts));
171
174
  this._prepare(command);
172
175
  try {
173
176
  yield migration_1.default(runtime_store_1.default.get('context.cli.package.version'));
@@ -70,7 +70,8 @@ class Config {
70
70
  catch (e) {
71
71
  const err = error_1.default.getErrorInstance(e, {
72
72
  message: 'There was an error loading a file',
73
- skipHelp: false
73
+ skipHelp: false,
74
+ fileName: __filename
74
75
  });
75
76
  err.errorId = 'CONFIG-1';
76
77
  err.arg = [ansi_colors_1.bold(constants_1.FILENAME.config), err.message];