zcatalyst-cli 1.25.3 → 1.26.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 (263) hide show
  1. package/lib/api-timer.d.ts +0 -1
  2. package/lib/apig-utils.d.ts +1 -1
  3. package/lib/apig-utils.js +1 -1
  4. package/lib/appsail-utils.js +6 -7
  5. package/lib/archiver.d.ts +0 -4
  6. package/lib/archiver.js +21 -11
  7. package/lib/authentication/constants/auth.js +1 -1
  8. package/lib/authentication/credential.js +3 -3
  9. package/lib/authentication/index.js +25 -14
  10. package/lib/authentication/login.d.ts +0 -2
  11. package/lib/authentication/login.js +23 -10
  12. package/lib/bin/catalyst.js +17 -7
  13. package/lib/client-utils.d.ts +3 -3
  14. package/lib/client-utils.js +2 -2
  15. package/lib/client.js +19 -9
  16. package/lib/code-deck.d.ts +0 -2
  17. package/lib/code-deck.js +4 -4
  18. package/lib/command_needs/config.js +1 -1
  19. package/lib/command_needs/rc.js +5 -2
  20. package/lib/commands/appsail/add.js +17 -7
  21. package/lib/commands/client/setup.js +17 -7
  22. package/lib/commands/config/set.js +5 -3
  23. package/lib/commands/deploy/appsail.js +37 -14
  24. package/lib/commands/deploy/index.js +88 -66
  25. package/lib/commands/deploy/slate.js +37 -14
  26. package/lib/commands/event/generate/integ.js +18 -9
  27. package/lib/commands/functions/add.js +17 -7
  28. package/lib/commands/functions/execute.js +17 -7
  29. package/lib/commands/functions/setup.js +17 -7
  30. package/lib/commands/functions/shell.js +17 -7
  31. package/lib/commands/iac/import.js +18 -8
  32. package/lib/commands/iac/pack.js +17 -7
  33. package/lib/commands/iac/status.js +17 -7
  34. package/lib/commands/index.js +20 -12
  35. package/lib/commands/init.js +17 -7
  36. package/lib/commands/login.js +17 -7
  37. package/lib/commands/logout.js +17 -7
  38. package/lib/commands/project/list.js +17 -7
  39. package/lib/commands/project/use.js +1 -0
  40. package/lib/commands/pull.js +17 -7
  41. package/lib/commands/run.js +17 -7
  42. package/lib/commands/serve.js +17 -7
  43. package/lib/commands/signals/generate/index.js +1 -1
  44. package/lib/commands/slate/create.js +17 -7
  45. package/lib/commands/slate/link.js +17 -7
  46. package/lib/commands/token/generate.js +17 -7
  47. package/lib/commands/token/list.js +17 -7
  48. package/lib/commands/token/revoke.js +17 -7
  49. package/lib/commands/zest/generate/index.js +21 -11
  50. package/lib/deploy/features/appsail/index.js +2 -3
  51. package/lib/deploy/features/appsail/pack.d.ts +0 -1
  52. package/lib/deploy/features/appsail/pack.js +2 -3
  53. package/lib/deploy/features/appsail/utils.js +7 -8
  54. package/lib/deploy/features/functions/languages/index.js +3 -4
  55. package/lib/deploy/features/index.js +17 -7
  56. package/lib/deploy/features/slate.js +11 -8
  57. package/lib/deploy/index.js +2 -2
  58. package/lib/deploy/util.d.ts +2 -0
  59. package/lib/deploy/util.js +3 -1
  60. package/lib/docs/commands/signals/generate/generate.toml +19 -0
  61. package/lib/docs/commands/slate/unlink.toml +9 -0
  62. package/lib/docs/fn-utils/lib/node.toml +4 -0
  63. package/lib/docs/init/dependencies/python/ensure-python.toml +4 -0
  64. package/lib/docs/serve/server/lib/slate/index.toml +20 -0
  65. package/lib/docs/slate-utils.toml +9 -0
  66. package/lib/endpoints/index.d.ts +2 -1
  67. package/lib/endpoints/index.js +88 -79
  68. package/lib/endpoints/lib/apig.d.ts +0 -1
  69. package/lib/endpoints/lib/apig.js +2 -2
  70. package/lib/endpoints/lib/applogic.d.ts +0 -1
  71. package/lib/endpoints/lib/applogic.js +2 -2
  72. package/lib/endpoints/lib/appsail.d.ts +1 -4
  73. package/lib/endpoints/lib/appsail.js +7 -7
  74. package/lib/endpoints/lib/client.d.ts +0 -1
  75. package/lib/endpoints/lib/code-deck.js +1 -1
  76. package/lib/endpoints/lib/common.d.ts +0 -2
  77. package/lib/endpoints/lib/ds-bulk.js +2 -2
  78. package/lib/endpoints/lib/env.js +2 -2
  79. package/lib/endpoints/lib/filestore.d.ts +0 -1
  80. package/lib/endpoints/lib/functions.d.ts +0 -1
  81. package/lib/endpoints/lib/functions.js +2 -2
  82. package/lib/endpoints/lib/git-hub.d.ts +0 -2
  83. package/lib/endpoints/lib/iac.d.ts +0 -3
  84. package/lib/endpoints/lib/iac.js +2 -2
  85. package/lib/endpoints/lib/project.d.ts +0 -1
  86. package/lib/endpoints/lib/project.js +2 -2
  87. package/lib/endpoints/lib/sdk.d.ts +0 -2
  88. package/lib/endpoints/lib/sdk.js +1 -1
  89. package/lib/endpoints/lib/slate.d.ts +0 -1
  90. package/lib/endpoints/lib/stratus.d.ts +0 -1
  91. package/lib/endpoints/lib/user.d.ts +0 -2
  92. package/lib/endpoints/lib/user.js +2 -1
  93. package/lib/error/context-help.js +1 -1
  94. package/lib/error/index.js +2 -2
  95. package/lib/event_generate/cache.js +4 -4
  96. package/lib/event_generate/custom.js +1 -2
  97. package/lib/event_generate/datastore.js +4 -4
  98. package/lib/event_generate/filestore.js +4 -4
  99. package/lib/event_generate/github.js +2 -2
  100. package/lib/event_generate/index.js +19 -11
  101. package/lib/event_generate/stratus.js +2 -2
  102. package/lib/event_generate/user.js +2 -2
  103. package/lib/event_generate/webapp.js +2 -2
  104. package/lib/execute/caller.d.ts +0 -1
  105. package/lib/execute/caller.js +20 -7
  106. package/lib/execute/index.js +27 -4
  107. package/lib/execute-script.js +22 -13
  108. package/lib/express_middlewares/auth-checker.js +2 -3
  109. package/lib/express_middlewares/project.d.ts +1 -1
  110. package/lib/fn-utils/index.js +17 -7
  111. package/lib/fn-utils/lib/browserLogic.js +4 -5
  112. package/lib/fn-utils/lib/common.d.ts +0 -1
  113. package/lib/fn-utils/lib/common.js +25 -26
  114. package/lib/fn-utils/lib/integ.js +2 -3
  115. package/lib/fn-utils/lib/java/classpath.js +2 -3
  116. package/lib/fn-utils/lib/java/compile.js +4 -4
  117. package/lib/fn-utils/lib/java/ensure-java-userconfig.d.ts +10 -0
  118. package/lib/fn-utils/lib/java/ensure-java-userconfig.js +45 -23
  119. package/lib/fn-utils/lib/java/index.d.ts +0 -1
  120. package/lib/fn-utils/lib/java/index.js +11 -11
  121. package/lib/fn-utils/lib/java/keywords.js +2 -2
  122. package/lib/fn-utils/lib/node.d.ts +1 -1
  123. package/lib/fn-utils/lib/node.js +67 -15
  124. package/lib/fn-utils/lib/python.js +29 -19
  125. package/lib/iac/status/util/index.d.ts +1 -1
  126. package/lib/init/dependencies/npm-install.js +2 -2
  127. package/lib/init/dependencies/python/ensure-python.d.ts +2 -2
  128. package/lib/init/dependencies/python/ensure-python.js +65 -58
  129. package/lib/init/dependencies/python/pip-install.d.ts +3 -5
  130. package/lib/init/dependencies/python/pip-install.js +14 -53
  131. package/lib/init/features/appsail/utils.js +21 -12
  132. package/lib/init/features/client/index.js +18 -9
  133. package/lib/init/features/client/initializers/angular.js +17 -7
  134. package/lib/init/features/client/initializers/basic.js +17 -7
  135. package/lib/init/features/client/initializers/lyte.js +17 -7
  136. package/lib/init/features/client/initializers/react.js +17 -7
  137. package/lib/init/features/index.js +29 -20
  138. package/lib/init/features/project.js +5 -5
  139. package/lib/init/features/slate/index.js +23 -11
  140. package/lib/init/util/client.js +23 -13
  141. package/lib/init/util/common.js +5 -6
  142. package/lib/init/util/project.js +1 -1
  143. package/lib/internal/api.d.ts +0 -3
  144. package/lib/internal/api.js +19 -9
  145. package/lib/internal/command.js +18 -9
  146. package/lib/migration/global/1.25.0.d.ts +2 -0
  147. package/lib/migration/global/1.25.0.js +28 -0
  148. package/lib/migration/index.js +20 -12
  149. package/lib/option-filter.js +19 -10
  150. package/lib/optional-import.js +19 -10
  151. package/lib/plugin-loader.d.ts +0 -2
  152. package/lib/plugin-loader.js +18 -8
  153. package/lib/port-resolver.js +10 -10
  154. package/lib/prompt/index.d.ts +3 -3
  155. package/lib/prompt/index.js +17 -7
  156. package/lib/prompt/types/file-path.d.ts +0 -1
  157. package/lib/prompt/types/search-box.d.ts +0 -1
  158. package/lib/prompt/types/tree.d.ts +1 -2
  159. package/lib/prompt/types/tree.js +10 -10
  160. package/lib/prompt/types/with-description.d.ts +0 -1
  161. package/lib/pull/features/functions/index.js +71 -52
  162. package/lib/pull/features/functions/languages.js +3 -4
  163. package/lib/pull/features/index.js +17 -7
  164. package/lib/repl-server.d.ts +0 -1
  165. package/lib/repl-server.js +9 -1
  166. package/lib/serve/features/apig.js +7 -1
  167. package/lib/serve/features/appsail.d.ts +1 -0
  168. package/lib/serve/features/appsail.js +51 -7
  169. package/lib/serve/features/index.js +22 -13
  170. package/lib/serve/index.js +17 -7
  171. package/lib/serve/server/index.d.ts +0 -2
  172. package/lib/serve/server/index.js +26 -12
  173. package/lib/serve/server/lib/appsail/index.js +27 -34
  174. package/lib/serve/server/lib/appsail/util.d.ts +11 -0
  175. package/lib/serve/server/lib/appsail/util.js +69 -0
  176. package/lib/serve/server/lib/java/index.js +18 -7
  177. package/lib/serve/server/lib/master/appsail.js +3 -4
  178. package/lib/serve/server/lib/master/functions.js +1 -2
  179. package/lib/serve/server/lib/master/index.d.ts +0 -1
  180. package/lib/serve/server/lib/master/index.js +5 -5
  181. package/lib/serve/server/lib/master/slate.js +1 -2
  182. package/lib/serve/server/lib/master/unknown-req-proxy.js +5 -2
  183. package/lib/serve/server/lib/master/utils.d.ts +4 -8
  184. package/lib/serve/server/lib/master/utils.js +4 -6
  185. package/lib/serve/server/lib/master/web-client.js +1 -2
  186. package/lib/serve/server/lib/node/index.js +22 -11
  187. package/lib/serve/server/lib/node/server/browserlogic/utils/playwright-handler.js +1 -1
  188. package/lib/serve/server/lib/node/server/browserlogic/utils/puppeteer-handler.js +1 -1
  189. package/lib/serve/server/lib/node/server/browserlogic/utils/selenium-handler.js +2 -0
  190. package/lib/serve/server/lib/python/index.js +23 -14
  191. package/lib/serve/server/lib/slate/index.js +7 -0
  192. package/lib/serve/server/lib/slate/static-server.d.ts +0 -1
  193. package/lib/serve/server/lib/slate/static-server.js +5 -4
  194. package/lib/serve/server/lib/web_client/server.d.ts +0 -1
  195. package/lib/serve/server/lib/web_client/server.js +5 -4
  196. package/lib/shell/dependencies/http-functions.d.ts +0 -2
  197. package/lib/shell/dependencies/http-functions.js +7 -7
  198. package/lib/shell/dependencies/non-http-function/fn-execution-handler.d.ts +0 -2
  199. package/lib/shell/dependencies/non-http-function/fn-execution-handler.js +55 -24
  200. package/lib/shell/dependencies/non-http-function/fn-handler.d.ts +3 -3
  201. package/lib/shell/dependencies/non-http-function/fn-handler.js +54 -20
  202. package/lib/shell/dependencies/non-http-function/node.js +4 -4
  203. package/lib/shell/dependencies/non-http-function/python.d.ts +1 -1
  204. package/lib/shell/dependencies/non-http-function/python.js +11 -13
  205. package/lib/shell/dependencies/non-http-function/slave-manager.d.ts +0 -2
  206. package/lib/shell/dependencies/non-http-function/slave-manager.js +11 -7
  207. package/lib/shell/dependencies/tunnel-server.js +4 -4
  208. package/lib/shell/index.js +50 -3
  209. package/lib/shell/prepare/index.js +4 -3
  210. package/lib/shell/prepare/languages/index.js +18 -9
  211. package/lib/shell/prepare/languages/node.js +29 -19
  212. package/lib/shell/prepare/languages/python.js +6 -12
  213. package/lib/signals/index.js +19 -11
  214. package/lib/slate-utils.js +25 -16
  215. package/lib/throbber/index.d.ts +1 -2
  216. package/lib/throbber/index.js +5 -2
  217. package/lib/throbber/utils.d.ts +0 -1
  218. package/lib/throbber/utils.js +4 -5
  219. package/lib/userConfig.d.ts +14 -0
  220. package/lib/userConfig.js +15 -1
  221. package/lib/util_modules/config/index.js +17 -7
  222. package/lib/util_modules/config/lib/apig.d.ts +1 -0
  223. package/lib/util_modules/config/lib/apig.js +10 -5
  224. package/lib/util_modules/config/lib/appsail.js +7 -7
  225. package/lib/util_modules/config/lib/client.js +5 -6
  226. package/lib/util_modules/config/lib/functions.js +5 -6
  227. package/lib/util_modules/config/lib/slate.d.ts +2 -1
  228. package/lib/util_modules/config/lib/slate.js +27 -13
  229. package/lib/util_modules/config-store.d.ts +1 -1
  230. package/lib/util_modules/config-store.js +30 -13
  231. package/lib/util_modules/constants/lib/apig-rules.d.ts +1 -1
  232. package/lib/util_modules/constants/lib/dc-type.js +3 -3
  233. package/lib/util_modules/constants/lib/placeholders.d.ts +1 -1
  234. package/lib/util_modules/constants/lib/placeholders.js +1 -1
  235. package/lib/util_modules/constants/lib/urls.js +2 -9
  236. package/lib/util_modules/container.js +23 -14
  237. package/lib/util_modules/dc.js +3 -4
  238. package/lib/util_modules/env.d.ts +3 -0
  239. package/lib/util_modules/env.js +64 -4
  240. package/lib/util_modules/event-emitter.d.ts +9 -0
  241. package/lib/util_modules/event-emitter.js +68 -0
  242. package/lib/util_modules/fs/index.js +17 -7
  243. package/lib/util_modules/fs/lib/async.d.ts +0 -4
  244. package/lib/util_modules/fs/lib/async.js +46 -46
  245. package/lib/util_modules/fs/lib/sync.d.ts +1 -3
  246. package/lib/util_modules/fs/lib/sync.js +40 -30
  247. package/lib/util_modules/logger/index.js +12 -12
  248. package/lib/util_modules/logger/utils.d.ts +0 -4
  249. package/lib/util_modules/logger/utils.js +1 -1
  250. package/lib/util_modules/logger/winston.js +2 -2
  251. package/lib/util_modules/option.js +5 -6
  252. package/lib/util_modules/project.js +22 -23
  253. package/lib/util_modules/runtime-store.d.ts +2 -2
  254. package/lib/util_modules/server.d.ts +1 -2
  255. package/lib/util_modules/server.js +54 -15
  256. package/lib/util_modules/shell.d.ts +0 -3
  257. package/lib/util_modules/shell.js +5 -6
  258. package/lib/util_modules/toml.js +2 -3
  259. package/package.json +13 -13
  260. package/templates/init/functions/java/event/sample.java +5 -2
  261. package/templates/web-socket.txt +1 -1
  262. /package/lib/docs/{commands/event/generate → event_generate}/index.toml +0 -0
  263. /package/templates/init/functions/java/integ/convokraft/{Sample.java → sample.java} +0 -0
@@ -26,7 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getTemplatePath = exports.validate = exports.extractAllData = exports.projectFileValidation = exports.ensureJavaInvoker = exports.isValidClassName = exports.classPathSep = exports.FN_TYPE = void 0;
29
+ exports.classPathSep = exports.FN_TYPE = void 0;
30
+ exports.isValidClassName = isValidClassName;
31
+ exports.ensureJavaInvoker = ensureJavaInvoker;
32
+ exports.projectFileValidation = projectFileValidation;
33
+ exports.extractAllData = extractAllData;
34
+ exports.validate = validate;
35
+ exports.getTemplatePath = getTemplatePath;
30
36
  const ansi_colors_1 = require("ansi-colors");
31
37
  const path_1 = require("path");
32
38
  const xml2js_1 = __importDefault(require("xml2js"));
@@ -57,7 +63,6 @@ function isValidClassName(name) {
57
63
  }
58
64
  return true;
59
65
  }
60
- exports.isValidClassName = isValidClassName;
61
66
  function ensureJavaInvoker(pth, invoker, target) {
62
67
  var _a, _b, _c;
63
68
  const spawnCommand = (0, ensure_java_userconfig_js_1.getJavaSpawnCommand)('javac', (_a = target.additionalInfo) === null || _a === void 0 ? void 0 : _a.binPath);
@@ -94,10 +99,9 @@ function ensureJavaInvoker(pth, invoker, target) {
94
99
  index_js_3.SYNC.copyDir((0, path_1.join)((0, path_1.dirname)(invoker), 'lib'), (0, path_1.join)((0, path_1.dirname)(classPth), 'lib'));
95
100
  return true;
96
101
  }
97
- exports.ensureJavaInvoker = ensureJavaInvoker;
98
102
  function projectFileValidation(pth, target) {
99
- var _a, _b;
100
103
  return __awaiter(this, void 0, void 0, function* () {
104
+ var _a, _b;
101
105
  const fileExists = yield index_js_3.ASYNC.fileExists(pth);
102
106
  if (!fileExists) {
103
107
  const templatePath = getTemplatePath(target.type, (_b = (_a = target.integ_config) === null || _a === void 0 ? void 0 : _a.at(0)) === null || _b === void 0 ? void 0 : _b.service);
@@ -119,7 +123,6 @@ function projectFileValidation(pth, target) {
119
123
  }
120
124
  });
121
125
  }
122
- exports.projectFileValidation = projectFileValidation;
123
126
  function extractAllData(child, name) {
124
127
  return __awaiter(this, void 0, void 0, function* () {
125
128
  return new Promise((res, rej) => {
@@ -137,16 +140,14 @@ function extractAllData(child, name) {
137
140
  });
138
141
  });
139
142
  }
140
- exports.extractAllData = extractAllData;
141
143
  function validate(targets) {
142
144
  return __awaiter(this, void 0, void 0, function* () {
143
145
  return _validate(targets);
144
146
  });
145
147
  }
146
- exports.validate = validate;
147
- function _validate(targets, ensured = {}, idx = 0) {
148
- var _a;
149
- return __awaiter(this, void 0, void 0, function* () {
148
+ function _validate(targets_1) {
149
+ return __awaiter(this, arguments, void 0, function* (targets, ensured = {}, idx = 0) {
150
+ var _a;
150
151
  if (targets.length < idx + 1) {
151
152
  return;
152
153
  }
@@ -247,7 +248,6 @@ function getTemplatePath(fnType, add) {
247
248
  }
248
249
  }
249
250
  }
250
- exports.getTemplatePath = getTemplatePath;
251
251
  __exportStar(require("./classpath"), exports);
252
252
  __exportStar(require("./compile"), exports);
253
253
  __exportStar(require("./ensure-java-userconfig.js"), exports);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.containsKeyWord = exports.keywords = void 0;
3
+ exports.keywords = void 0;
4
+ exports.containsKeyWord = containsKeyWord;
4
5
  const js_1 = require("../../../util_modules/js");
5
6
  exports.keywords = Object.freeze([
6
7
  'abstract',
@@ -68,4 +69,3 @@ function containsKeyWord(name) {
68
69
  return false;
69
70
  });
70
71
  }
71
- exports.containsKeyWord = containsKeyWord;
@@ -1,5 +1,5 @@
1
1
  import { TEMPLATE } from '../../util_modules/constants';
2
2
  import { IFnTarget, NodeFn } from './common';
3
3
  export declare function validate(targets: Array<IFnTarget<NodeFn>>): Promise<void>;
4
- export declare function checkNodePresence(): Promise<void>;
4
+ export declare function ensureNodeVersion(stack: string, onlyDirPath?: boolean): Promise<string>;
5
5
  export declare function getTemplatePath(fnType: keyof typeof TEMPLATE.functions.node, add?: string): string;
@@ -12,29 +12,35 @@ 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
- exports.getTemplatePath = exports.checkNodePresence = exports.validate = void 0;
15
+ exports.validate = validate;
16
+ exports.ensureNodeVersion = ensureNodeVersion;
17
+ exports.getTemplatePath = getTemplatePath;
16
18
  const ansi_colors_1 = require("ansi-colors");
17
19
  const path_1 = require("path");
18
20
  const index_js_1 = __importDefault(require("../../error/index.js"));
19
21
  const npm_install_1 = __importDefault(require("../../init/dependencies/npm-install"));
20
- const runtime_store_js_1 = __importDefault(require("../../runtime-store.js"));
21
22
  const env_js_1 = require("../../util_modules/env.js");
22
23
  const constants_1 = require("../../util_modules/constants");
23
24
  const fs_1 = require("../../util_modules/fs");
24
25
  const js_1 = require("../../util_modules/js");
25
26
  const shell_js_1 = require("../../util_modules/shell.js");
27
+ const userConfig_js_1 = __importDefault(require("../../userConfig.js"));
28
+ const utils_js_1 = require("../../util_modules/fs/utils.js");
29
+ const runtime_store_js_1 = __importDefault(require("../../runtime-store.js"));
26
30
  function validate(targets) {
27
31
  return __awaiter(this, void 0, void 0, function* () {
28
32
  return _validate(targets);
29
33
  });
30
34
  }
31
- exports.validate = validate;
32
- function _validate(targets, idx = 0) {
33
- return __awaiter(this, void 0, void 0, function* () {
35
+ function _validate(targets_1) {
36
+ return __awaiter(this, arguments, void 0, function* (targets, idx = 0) {
34
37
  if (targets.length < idx + 1) {
35
38
  return;
36
39
  }
37
40
  const currentTarget = targets[idx];
41
+ if (currentTarget.valid === false) {
42
+ return _validate(targets, ++idx);
43
+ }
38
44
  try {
39
45
  const catalystFile = (0, path_1.join)(currentTarget.source, constants_1.FILENAME.catalyst_config);
40
46
  const data = yield fs_1.ASYNC.readJSONFile(catalystFile, { checkpath: true });
@@ -72,18 +78,65 @@ function _validate(targets, idx = 0) {
72
78
  }
73
79
  });
74
80
  }
75
- function checkNodePresence() {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const nodeChild = yield (0, shell_js_1.spawn)(env_js_1.isWindows ? 'where' : 'which', ['node'], {
78
- cwd: runtime_store_js_1.default.get('cwd'),
79
- stdio: 'pipe'
80
- }).ASYNC();
81
- if (nodeChild.status !== 0) {
82
- throw new index_js_1.default('NodeJS not installed. Please install NodeJS to continue');
81
+ function ensureNodeVersion(stack_1) {
82
+ return __awaiter(this, arguments, void 0, function* (stack, onlyDirPath = false) {
83
+ if (!stack.startsWith('node')) {
84
+ throw new index_js_1.default('Invalid stack passed for node: ' + stack, { exit: 2 });
85
+ }
86
+ const configKey = `${stack}.bin`;
87
+ let binPath = env_js_1.isExtension
88
+ ? runtime_store_js_1.default.get(`executables.${configKey}`)
89
+ : userConfig_js_1.default.get(configKey);
90
+ const bin = env_js_1.isWindows ? 'node.exe' : 'node';
91
+ if (binPath) {
92
+ binPath = (0, utils_js_1.untildify)(binPath);
93
+ if (!binPath.endsWith(bin))
94
+ binPath = (0, path_1.join)(binPath, bin);
95
+ const fileExists = yield fs_1.ASYNC.fileExists(binPath);
96
+ if (!fileExists) {
97
+ throw new index_js_1.default(`Invalid NodeJS binary path set for stack ${stack}`, {
98
+ exit: 1,
99
+ errorId: '',
100
+ arg: [stack.replace('node', ''), (0, ansi_colors_1.bold)(binPath), (0, ansi_colors_1.bold)(configKey)]
101
+ });
102
+ }
103
+ }
104
+ else {
105
+ binPath = checkNodePresence(stack);
106
+ }
107
+ if (onlyDirPath) {
108
+ return (0, path_1.dirname)(binPath);
83
109
  }
110
+ return binPath;
84
111
  });
85
112
  }
86
- exports.checkNodePresence = checkNodePresence;
113
+ function checkNodePresence(stack) {
114
+ const nodeVersion = `v${stack.replace('node', '')}`;
115
+ if (process.version.includes(nodeVersion)) {
116
+ return process.execPath;
117
+ }
118
+ const nodeVChild = (0, shell_js_1.spawn)('node', ['-v'], { stdio: 'pipe' }).SYNC();
119
+ if (!nodeVChild.stdout.toString().includes(nodeVersion)) {
120
+ throw new index_js_1.default(`Required NodeJS version ${nodeVersion} is not present in the system path`, {
121
+ exit: 1,
122
+ errorId: 'NODE-2',
123
+ arg: [
124
+ (0, ansi_colors_1.bold)(nodeVersion),
125
+ env_js_1.isExtension
126
+ ? `settings ${(0, ansi_colors_1.italic)(`zcatalyst.${stack}`)}`
127
+ : `${(0, ansi_colors_1.italic)('`catalyst config`')} command.\n\n${(0, ansi_colors_1.bold)('Example:')} ${(0, ansi_colors_1.italic)(`catalyst config:set ${stack}.bin=<path-to-node-${nodeVersion}-binary>`)}`
128
+ ]
129
+ });
130
+ }
131
+ const whichChild = (0, shell_js_1.spawn)('node', ['-p', 'process.execPath'], {
132
+ stdio: 'pipe'
133
+ }).SYNC();
134
+ const nodePath = whichChild.stdout.toString().trim();
135
+ if (!nodePath) {
136
+ throw new index_js_1.default(`Unable to find the file path for node ${nodeVersion} binary in system path`, { exit: 1 });
137
+ }
138
+ return nodePath;
139
+ }
87
140
  function getTemplatePath(fnType, add) {
88
141
  switch (fnType) {
89
142
  case constants_1.FN_TYPE.browserLogic:
@@ -99,4 +152,3 @@ function getTemplatePath(fnType, add) {
99
152
  }
100
153
  }
101
154
  }
102
- exports.getTemplatePath = getTemplatePath;
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,7 +45,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
46
  };
37
47
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.removeRequirements = exports.validate = void 0;
48
+ exports.validate = validate;
49
+ exports.removeRequirements = removeRequirements;
39
50
  const ansi_colors_1 = require("ansi-colors");
40
51
  const os_1 = require("os");
41
52
  const path_1 = __importStar(require("path"));
@@ -45,15 +56,13 @@ const pip_install_1 = require("../../init/dependencies/python/pip-install");
45
56
  const constants_1 = require("../../util_modules/constants");
46
57
  const fs_1 = require("../../util_modules/fs");
47
58
  const js_1 = require("../../util_modules/js");
48
- const validationResults = {};
49
59
  function validate(targets) {
50
60
  return __awaiter(this, void 0, void 0, function* () {
51
61
  return _validate(targets);
52
62
  });
53
63
  }
54
- exports.validate = validate;
55
- function _validate(targets, idx = 0) {
56
- return __awaiter(this, void 0, void 0, function* () {
64
+ function _validate(targets_1) {
65
+ return __awaiter(this, arguments, void 0, function* (targets, idx = 0, validationResults = {}) {
57
66
  if (targets.length < idx + 1) {
58
67
  return;
59
68
  }
@@ -87,8 +96,9 @@ function _validate(targets, idx = 0) {
87
96
  });
88
97
  }
89
98
  if (!(stack in validationResults)) {
90
- yield (0, ensure_python_1.ensurePythonWithPip)(stack.replace('python_', '').replace('_', '.'));
91
- validationResults[stack] = { valid: true };
99
+ const _bin = yield (0, ensure_python_1.ensurePythonWithPip)(stack.replace('python_', '').replace('_', '.'));
100
+ validationResults[stack] = { valid: true, bin: _bin };
101
+ currentTarget.additionalInfo = { binPath: _bin };
92
102
  }
93
103
  if (!validationResults[stack]['valid']) {
94
104
  currentTarget.valid = validationResults[stack]['valid'];
@@ -96,8 +106,9 @@ function _validate(targets, idx = 0) {
96
106
  }
97
107
  else {
98
108
  currentTarget.valid = true;
109
+ currentTarget.additionalInfo = { binPath: validationResults[stack]['bin'] };
99
110
  }
100
- return _validate(targets, ++idx);
111
+ return _validate(targets, ++idx, validationResults);
101
112
  }
102
113
  catch (e) {
103
114
  const err = error_1.default.getErrorInstance(e);
@@ -106,21 +117,20 @@ function _validate(targets, idx = 0) {
106
117
  if (stack) {
107
118
  validationResults[stack] = { valid: false, message: err.message };
108
119
  }
109
- return _validate(targets, ++idx);
120
+ return _validate(targets, ++idx, validationResults);
110
121
  }
111
122
  });
112
123
  }
113
124
  function removeRequirements(reqFile, target) {
114
- var _a;
115
125
  return __awaiter(this, void 0, void 0, function* () {
126
+ var _a;
116
127
  const tmpDir = (0, path_1.join)((0, os_1.tmpdir)(), '.catalyst', 'python', Date.now().toString());
117
128
  yield fs_1.ASYNC.ensureDir(tmpDir);
118
129
  yield fs_1.ASYNC.emptyDir(tmpDir);
119
- yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''), true);
130
+ yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, (_a = target.additionalInfo) === null || _a === void 0 ? void 0 : _a.binPath, true);
120
131
  const files = yield fs_1.ASYNC.walk(tmpDir, { depth: 1, includeDirPaths: true });
121
132
  yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
122
133
  yield fs_1.ASYNC.deleteFile((0, path_1.join)(target.source, path_1.default.basename(file.path)));
123
134
  })));
124
135
  });
125
136
  }
126
- exports.removeRequirements = removeRequirements;
@@ -1,2 +1,2 @@
1
1
  import { IIacResponse } from '../../../endpoints/lib/iac';
2
- export declare const getSpinnerTxt: (type: 'bundle' | 'deploy' | 'codedeck') => (deployDetails: IIacResponse, status?: string) => string;
2
+ export declare const getSpinnerTxt: (type: "bundle" | "deploy" | "codedeck") => (deployDetails: IIacResponse, status?: string) => string;
@@ -16,14 +16,14 @@ const index_js_1 = __importDefault(require("../../error/index.js"));
16
16
  const prompt_1 = __importDefault(require("../../prompt"));
17
17
  const env_js_1 = require("../../util_modules/env.js");
18
18
  const shell_1 = require("../../util_modules/shell");
19
- exports.default = (pth, skipPrompt = false) => __awaiter(void 0, void 0, void 0, function* () {
19
+ exports.default = (pth_1, ...args_1) => __awaiter(void 0, [pth_1, ...args_1], void 0, function* (pth, skipPrompt = false) {
20
20
  const ans = yield prompt_1.default.ask(prompt_1.default.question('NPMinstall', 'Do you wish to install all dependencies now ? ', {
21
21
  type: 'confirm',
22
22
  defaultAns: true,
23
23
  when: () => !skipPrompt
24
24
  }));
25
25
  if (ans.NPMinstall === undefined || ans.NPMinstall) {
26
- return (0, shell_1.spawn)('npm', ['install'], { cwd: pth, detached: env_js_1.isVsCode })
26
+ return (0, shell_1.spawn)('npm', ['install'], { cwd: pth, detached: env_js_1.isExtension })
27
27
  .ASYNC()
28
28
  .catch((err) => {
29
29
  throw index_js_1.default.getErrorInstance(err, {
@@ -1,2 +1,2 @@
1
- export declare function ensurePython(version: string, fallBackNeeded: boolean, skipHelp: boolean): Promise<void>;
2
- export declare function ensurePythonWithPip(version: string, fallBackNeeded?: boolean, skipHelp?: boolean): Promise<void>;
1
+ export declare function ensurePython(version: string, fallBackNeeded: boolean, skipHelp: boolean): Promise<string>;
2
+ export declare function ensurePythonWithPip(version: string, fallBackNeeded?: boolean, skipHelp?: boolean): Promise<string>;
@@ -12,7 +12,8 @@ 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
- exports.ensurePythonWithPip = exports.ensurePython = void 0;
15
+ exports.ensurePython = ensurePython;
16
+ exports.ensurePythonWithPip = ensurePythonWithPip;
16
17
  const error_1 = __importDefault(require("../../../error"));
17
18
  const prompt_1 = __importDefault(require("../../../prompt"));
18
19
  const env_1 = require("../../../util_modules/env");
@@ -20,71 +21,68 @@ const shell_1 = require("../../../util_modules/shell");
20
21
  const userConfig_1 = __importDefault(require("../../../userConfig"));
21
22
  const ansi_colors_1 = require("ansi-colors");
22
23
  const console_1 = require("console");
24
+ const utils_1 = require("../../../util_modules/fs/utils");
25
+ const runtime_store_1 = __importDefault(require("../../../runtime-store"));
26
+ const logger_1 = require("../../../util_modules/logger");
23
27
  function ensurePython(version, fallBackNeeded, skipHelp) {
24
28
  return __awaiter(this, void 0, void 0, function* () {
25
29
  const configKey = `python${version.replace('.', '_')}.bin`;
26
- const spawnCommand = userConfig_1.default.get(configKey);
27
- try {
28
- if (spawnCommand) {
30
+ const spawnCommand = env_1.isExtension
31
+ ? runtime_store_1.default.get(`executables.${configKey}`)
32
+ : userConfig_1.default.get(configKey);
33
+ if (spawnCommand) {
34
+ try {
29
35
  yield validateCommand(version, spawnCommand, true);
30
- return;
36
+ return getPythonExecPath(spawnCommand);
37
+ }
38
+ catch (er) {
39
+ throw er;
31
40
  }
32
41
  }
33
- catch (_a) { }
34
- return new Promise((resolve, reject) => {
35
- const child = (0, shell_1.spawn)('python' + version, ['--version'], {
36
- stdio: 'ignore'
37
- }).RAW();
38
- child.on('error', (error) => __awaiter(this, void 0, void 0, function* () {
39
- if (env_1.isWindows) {
40
- try {
41
- yield (0, shell_1.spawn)('py -' + version, ['--version'], {
42
- stdio: 'ignore'
43
- }).ASYNC();
44
- userConfig_1.default.set(configKey, 'py -' + version);
45
- return resolve();
46
- }
47
- catch (_a) { }
48
- }
49
- if (fallBackNeeded) {
50
- (0, console_1.info)(`unable to locate python${version} in your system`);
51
- const ans = yield prompt_1.default.ask(prompt_1.default.question('binPath', `Please provide the binary path for python${version}:`, {
52
- type: 'input'
53
- }));
54
- yield validateCommand(version, ans.binPath, skipHelp)
55
- .then(() => {
56
- userConfig_1.default.set(`python${version.replace('.', '_')}.bin`, ans.binPath);
57
- resolve();
58
- })
59
- .catch((err) => {
60
- reject(err);
61
- });
62
- }
63
- else {
64
- reject(new error_1.default(`unable to locate python${version} in your system`, {
65
- original: error,
66
- exit: 1,
67
- errorId: 'PY-2',
68
- arg: [
69
- version,
70
- (0, ansi_colors_1.italic)((0, ansi_colors_1.bold)(`catalyst config:set ${configKey}=<binary_path>`))
71
- ],
72
- skipHelp
73
- }));
42
+ try {
43
+ const fallBackSpawnCommand = 'python' + version;
44
+ yield validateCommand(version, fallBackSpawnCommand, true);
45
+ return getPythonExecPath(fallBackSpawnCommand);
46
+ }
47
+ catch (err) {
48
+ if (env_1.isWindows) {
49
+ try {
50
+ const winPyLauncher = 'py -' + version;
51
+ yield (0, shell_1.spawn)(winPyLauncher, ['--version'], {
52
+ stdio: 'ignore'
53
+ }).ASYNC();
54
+ userConfig_1.default.set(configKey, winPyLauncher);
55
+ yield validateCommand(version, winPyLauncher, true);
56
+ return getPythonExecPath(winPyLauncher);
74
57
  }
75
- }));
76
- child.on('exit', (code) => {
77
- if (code === 0) {
78
- userConfig_1.default.set(configKey, 'python' + version);
58
+ catch (er) {
59
+ (0, logger_1.debug)('Unable to locate PyLauncher in win: ' + er);
79
60
  }
80
- resolve();
61
+ }
62
+ if (fallBackNeeded) {
63
+ (0, console_1.info)(`unable to locate python${version} in your system`);
64
+ const ans = yield prompt_1.default.ask(prompt_1.default.question('binPath', `Please provide the binary path for python${version}:`, {
65
+ type: 'input'
66
+ }));
67
+ yield validateCommand(version, ans.binPath, skipHelp);
68
+ userConfig_1.default.set(`python${version.replace('.', '_')}.bin`, ans.binPath);
69
+ return getPythonExecPath(ans.binPath);
70
+ }
71
+ const { errorId, config } = env_1.isExtension
72
+ ? { errorId: 'PY-2-EXT', config: 'zcatalyst.python_3_9' }
73
+ : { errorId: 'PY-2', config: `catalyst config:set ${configKey}=<binary_path>` };
74
+ throw new error_1.default(`unable to locate python${version} in your system`, {
75
+ exit: 1,
76
+ errorId: errorId,
77
+ arg: [version, (0, ansi_colors_1.italic)((0, ansi_colors_1.bold)(config))],
78
+ skipHelp
81
79
  });
82
- });
80
+ }
83
81
  });
84
82
  }
85
- exports.ensurePython = ensurePython;
86
83
  function validateCommand(version, spawnCommand, skipHelp) {
87
84
  return __awaiter(this, void 0, void 0, function* () {
85
+ spawnCommand = (0, utils_1.untildify)(spawnCommand);
88
86
  const versionResponse = yield new Promise((resolve, reject) => {
89
87
  var _a;
90
88
  const child = (0, shell_1.spawn)(spawnCommand, ['--version'], {
@@ -126,11 +124,20 @@ function validateCommand(version, spawnCommand, skipHelp) {
126
124
  }
127
125
  });
128
126
  }
129
- function ensurePythonWithPip(version, fallBackNeeded = false, skipHelp = false) {
127
+ function getPythonExecPath(spawnCommand) {
130
128
  return __awaiter(this, void 0, void 0, function* () {
131
- yield ensurePython(version, fallBackNeeded, skipHelp);
132
- return new Promise((resolve, reject) => {
133
- const child = (0, shell_1.spawn)(userConfig_1.default.get(`python${version.replace('.', '_')}.bin`), ['-m', 'pip', '--version'], {
129
+ spawnCommand = (0, utils_1.untildify)(spawnCommand);
130
+ const pyVChild = (0, shell_1.spawn)(spawnCommand, ['-c', 'import sys;print(sys.executable)'], {
131
+ stdio: 'pipe'
132
+ }).SYNC();
133
+ return pyVChild.stdout.toString().trim();
134
+ });
135
+ }
136
+ function ensurePythonWithPip(version_1) {
137
+ return __awaiter(this, arguments, void 0, function* (version, fallBackNeeded = false, skipHelp = false) {
138
+ const pyBin = yield ensurePython(version, fallBackNeeded, skipHelp);
139
+ yield new Promise((resolve, reject) => {
140
+ const child = (0, shell_1.spawn)(pyBin, ['-m', 'pip', '--version'], {
134
141
  stdio: 'ignore'
135
142
  }).RAW();
136
143
  child.on('error', (err) => {
@@ -144,6 +151,6 @@ function ensurePythonWithPip(version, fallBackNeeded = false, skipHelp = false)
144
151
  });
145
152
  child.on('exit', resolve);
146
153
  });
154
+ return pyBin;
147
155
  });
148
156
  }
149
- exports.ensurePythonWithPip = ensurePythonWithPip;
@@ -1,7 +1,5 @@
1
1
  import { asyncSpawnResposne } from '../../../util_modules/shell';
2
- declare const _default: (pth: string, stack: string, isIntegFn?: boolean, integService?: string | boolean) => Promise<asyncSpawnResposne | Array<asyncSpawnResposne> | void>;
3
- export default _default;
4
- export declare function ensurePyRuntime(pth: string, stack: string): Promise<void>;
2
+ export declare function ensurePyRuntime(pth: string, stack: string, spawnCommand?: string): Promise<void>;
5
3
  export declare const pypiRes: (pkg: string) => Promise<Record<string, unknown>>;
6
- export declare function installRequirements(reqFile: string, pth: string, stackVersion: string, linuxMode?: boolean): Promise<void>;
7
- export declare function installPkgs(pkgs: Array<string>, stackVersion: string, pth?: string | undefined): Promise<asyncSpawnResposne>;
4
+ export declare function installRequirements(reqFile: string, pth: string, spawnCommand?: string, linuxMode?: boolean): Promise<void>;
5
+ export declare function installPkgs(pkgs: Array<string>, spawnCommand?: string, pth?: string | undefined): Promise<asyncSpawnResposne>;