zcatalyst-cli 1.15.0-beta.2 → 1.15.0-beta.4

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 (122) hide show
  1. package/lib/appsail-utils.js +84 -0
  2. package/lib/archiver.js +18 -1
  3. package/lib/code-deck.js +114 -0
  4. package/lib/command_needs/rc.js +7 -6
  5. package/lib/commands/appsail/add.js +55 -0
  6. package/lib/commands/codelib/install.js +143 -0
  7. package/lib/commands/config/set.js +1 -1
  8. package/lib/commands/deploy/appsail.js +62 -0
  9. package/lib/commands/{deploy.js → deploy/index.js} +20 -14
  10. package/lib/commands/iac/pack.js +3 -3
  11. package/lib/commands/index.js +2 -0
  12. package/lib/commands/init.js +5 -1
  13. package/lib/commands/pull.js +1 -1
  14. package/lib/commands/serve.js +1 -1
  15. package/lib/commands/whoami.js +2 -1
  16. package/lib/deploy/features/appsail/index.js +246 -0
  17. package/lib/deploy/features/appsail/utils.js +91 -0
  18. package/lib/deploy/features/functions/index.js +12 -10
  19. package/lib/deploy/features/index.js +3 -0
  20. package/lib/deploy/index.js +3 -3
  21. package/lib/endpoints/index.js +22 -1
  22. package/lib/endpoints/lib/appsail.js +98 -0
  23. package/lib/endpoints/lib/code-deck.js +71 -0
  24. package/lib/endpoints/lib/common.js +8 -5
  25. package/lib/endpoints/lib/git-hub.js +148 -0
  26. package/lib/endpoints/lib/iac.js +15 -0
  27. package/lib/endpoints/lib/sdk.js +4 -1
  28. package/lib/execute-script.js +35 -27
  29. package/lib/fn-utils/lib/browserLogic.js +17 -20
  30. package/lib/fn-utils/lib/common.js +3 -4
  31. package/lib/fn-utils/lib/integ.js +6 -4
  32. package/lib/fn-utils/lib/java.js +7 -1
  33. package/lib/fn-watcher.js +3 -0
  34. package/lib/iac/status/deploy.js +26 -4
  35. package/lib/iac/status/util/index.js +3 -0
  36. package/lib/init/dependencies/python/ensure-python.js +2 -2
  37. package/lib/init/dependencies/python/pip-install.js +4 -4
  38. package/lib/init/features/appsail/index.js +213 -0
  39. package/lib/init/features/functions/index.js +5 -72
  40. package/lib/init/features/functions/languages/java.js +7 -3
  41. package/lib/init/features/functions/languages/node.js +9 -7
  42. package/lib/init/features/functions/languages/python.js +1 -1
  43. package/lib/init/features/index.js +28 -12
  44. package/lib/init/features/project.js +3 -3
  45. package/lib/init/index.js +1 -1
  46. package/lib/init/util/common.js +103 -0
  47. package/lib/internal/api.js +5 -5
  48. package/lib/internal/command.js +26 -3
  49. package/lib/option-filter.js +40 -21
  50. package/lib/prompt/index.js +5 -0
  51. package/lib/prompt/types/file-path.js +4 -1
  52. package/lib/prompt/types/tree.js +297 -0
  53. package/lib/pull/features/functions/index.js +70 -47
  54. package/lib/serve/features/appsail.js +37 -0
  55. package/lib/serve/features/index.js +8 -1
  56. package/lib/serve/index.js +23 -6
  57. package/lib/serve/server/index.js +111 -233
  58. package/lib/serve/server/lib/appsail/index.js +134 -0
  59. package/lib/serve/server/lib/appsail/start.js +75 -0
  60. package/lib/serve/server/lib/java/index.js +54 -0
  61. package/lib/serve/server/lib/master.js +84 -60
  62. package/lib/serve/server/lib/node/index.js +85 -74
  63. package/lib/serve/server/lib/node/server/index.js +77 -0
  64. package/lib/serve/server/lib/python/index.js +46 -0
  65. package/lib/serve/server/lib/web_client/index.js +33 -0
  66. package/lib/serve/server/lib/web_client/server.js +3 -0
  67. package/lib/shell/dependencies/http-functions.js +7 -7
  68. package/lib/shell/dependencies/local-function.js +6 -6
  69. package/lib/shell/prepare/index.js +1 -1
  70. package/lib/shell/prepare/languages/index.js +3 -3
  71. package/lib/shell/prepare/languages/java.js +2 -2
  72. package/lib/util_modules/config/index.js +3 -1
  73. package/lib/util_modules/config/lib/appSail.js +89 -0
  74. package/lib/util_modules/constants/index.js +3 -1
  75. package/lib/util_modules/constants/lib/default.js +4 -2
  76. package/lib/util_modules/constants/lib/file-names.js +4 -1
  77. package/lib/util_modules/constants/lib/runtime.js +12 -3
  78. package/lib/util_modules/constants/lib/scopes.js +4 -0
  79. package/lib/util_modules/constants/lib/template.js +23 -20
  80. package/lib/util_modules/constants/lib/urls.js +5 -0
  81. package/lib/util_modules/context-help.js +3 -0
  82. package/lib/util_modules/fs/lib/async.js +10 -3
  83. package/lib/util_modules/fs/lib/sync.js +2 -2
  84. package/lib/util_modules/js.js +4 -0
  85. package/lib/util_modules/project.js +2 -2
  86. package/lib/util_modules/server.js +2 -1
  87. package/package.json +1 -1
  88. package/scripts/postInstall.js +27 -18
  89. package/templates/init/functions/java/browserLogic/playwright/sample.java +1 -1
  90. package/templates/init/functions/java/browserLogic/selenium/sample.java +1 -1
  91. package/templates/init/functions/node/browserlogic/playwright/sample.js +1 -1
  92. package/templates/init/functions/node/browserlogic/puppeteer/sample.js +1 -1
  93. package/templates/init/functions/node/browserlogic/selenium/sample.js +1 -1
  94. package/templates/init/functions/node/integ/cliq/package.json +1 -0
  95. package/templates/init/functions/python/aio/requirements.txt +1 -1
  96. package/templates/init/functions/python/bio/requirements.txt +1 -1
  97. package/templates/init/functions/python/cron/requirements.txt +1 -1
  98. package/templates/init/functions/python/event/requirements.txt +1 -1
  99. package/templates/init/functions/python/integ/cliq/requirements.txt +1 -1
  100. /package/lib/serve/server/lib/java/{JavaaioServer.java → aio_server/JavaaioServer.java} +0 -0
  101. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  102. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-function-sdk-1.0.0.jar +0 -0
  103. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-java-runtime-1.0.0.jar +0 -0
  104. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/gradle-wrapper.jar +0 -0
  105. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-http-9.3.24.v20180605.jar +0 -0
  106. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-io-9.3.24.v20180605.jar +0 -0
  107. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-security-9.3.24.v20180605.jar +0 -0
  108. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-server-9.3.24.v20180605.jar +0 -0
  109. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-servlet-9.3.24.v20180605.jar +0 -0
  110. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-util-9.3.24.v20180605.jar +0 -0
  111. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/org.json.jar +0 -0
  112. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/servlet-api-3.1.jar +0 -0
  113. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/zip4j-2.5.0.jar +0 -0
  114. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-playwright.js +0 -0
  115. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-puppeteer.js +0 -0
  116. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-selenium.js +0 -0
  117. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/index.js +0 -0
  118. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/deferred_promise.js +0 -0
  119. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/playwright-handler.js +0 -0
  120. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/puppeteer-handler.js +0 -0
  121. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/selenium-handler.js +0 -0
  122. /package/lib/serve/server/lib/node/{package.json → server/package.json} +0 -0
@@ -29,7 +29,54 @@ const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/r
29
29
  const error_1 = __importDefault(require("../../../error"));
30
30
  const python_1 = require("../../../fn-utils/lib/python");
31
31
  const throbber_1 = __importDefault(require("../../../throbber"));
32
- exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
32
+ function selFnsPrompt(targs, fnDirPath) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const choicesObj = targs.reduce((accumulator, fn) => {
35
+ const name = fn.name;
36
+ const type = fn.type === constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.applogic]
37
+ ? constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.advanced]
38
+ : fn.type;
39
+ const choice = prompt_1.default.choice(name + ' (' + fn.stack + ')', {
40
+ value: {
41
+ id: fn.id + '',
42
+ stack: fn.stack,
43
+ name,
44
+ type: type,
45
+ source: (0, path_1.join)(fnDirPath, name)
46
+ },
47
+ short: name
48
+ });
49
+ accumulator[type] = js_1.JS.isArray(accumulator[type])
50
+ ? accumulator[type].concat([choice])
51
+ : [choice];
52
+ return accumulator;
53
+ }, {});
54
+ const choicesArr = js_1.JS.transform(choicesObj, (result, value, key) => {
55
+ result.push(prompt_1.default.separator('----' + key + '----'));
56
+ result.push(...value);
57
+ return result;
58
+ }, []);
59
+ const functionsAns = yield prompt_1.default.ask(prompt_1.default.question('functions', 'Select all the functions that you want to pull from remote console : ', {
60
+ type: 'checkbox',
61
+ choices: choicesArr,
62
+ validate: (ansArr) => {
63
+ if (js_1.JS.isEmpty(ansArr)) {
64
+ return ('Must select at least one feature.\n' +
65
+ '(Press ' +
66
+ (0, ansi_colors_1.cyan)('<space>') +
67
+ ' to select, ' +
68
+ (0, ansi_colors_1.cyan)('<a>') +
69
+ ' to toggle all, ' +
70
+ (0, ansi_colors_1.cyan)('<i>') +
71
+ ' to invert selection)');
72
+ }
73
+ return true;
74
+ }
75
+ }));
76
+ return functionsAns.functions;
77
+ });
78
+ }
79
+ exports.default = (_fns) => __awaiter(void 0, void 0, void 0, function* () {
33
80
  const fnAPI = yield (0, endpoints_1.functionsAPI)();
34
81
  const fnDirName = config_1.functionsConfig.source();
35
82
  const fnDirPath = (0, project_1.resolveProjectPath)(fnDirName);
@@ -38,50 +85,26 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
38
85
  (0, logger_1.info)('No function found in remote console.');
39
86
  return;
40
87
  }
41
- const choicesObj = fnArr.reduce((accumulator, fn) => {
42
- const name = fn.name;
43
- const type = fn.type === constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.applogic]
44
- ? constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.advanced]
45
- : fn.type;
46
- const choice = prompt_1.default.choice(name + ' (' + fn.stack + ')', {
47
- value: {
48
- id: fn.id + '',
49
- stack: fn.stack,
50
- name,
51
- type: type,
52
- source: (0, path_1.join)(fnDirPath, name)
53
- },
54
- short: name
55
- });
56
- accumulator[type] = js_1.JS.isArray(accumulator[type])
57
- ? accumulator[type].concat([choice])
58
- : [choice];
59
- return accumulator;
60
- }, {});
61
- const choicesArr = js_1.JS.transform(choicesObj, (result, value, key) => {
62
- result.push(prompt_1.default.separator('----' + key + '----'));
63
- result.push(...value);
64
- return result;
65
- }, []);
66
- const functionsAns = yield prompt_1.default.ask(prompt_1.default.question('functions', 'Select all the functions that you want to pull from remote console : ', {
67
- type: 'checkbox',
68
- choices: choicesArr,
69
- validate: (ansArr) => {
70
- if (js_1.JS.isEmpty(ansArr)) {
71
- return ('Must select at least one feature.\n' +
72
- '(Press ' +
73
- (0, ansi_colors_1.cyan)('<space>') +
74
- ' to select, ' +
75
- (0, ansi_colors_1.cyan)('<a>') +
76
- ' to toggle all, ' +
77
- (0, ansi_colors_1.cyan)('<i>') +
78
- ' to invert selection)');
88
+ const fns = Array.isArray(_fns) && _fns.length > 0
89
+ ? _fns.map((fn) => {
90
+ const idx = fnArr.findIndex((_fn) => _fn.name === fn);
91
+ if (idx === -1) {
92
+ throw new error_1.default('Cannot find the function in remote: ' + fn, {
93
+ exit: 2
94
+ });
79
95
  }
80
- return true;
81
- }
82
- }));
96
+ const fnTarg = fnArr.splice(idx, 1)[0];
97
+ return {
98
+ id: fnTarg.id + '',
99
+ stack: fnTarg.stack,
100
+ name: fnTarg.name,
101
+ type: fnTarg.type,
102
+ source: (0, path_1.join)(fnDirPath, fnTarg.name)
103
+ };
104
+ })
105
+ : yield selFnsPrompt(fnArr, fnDirPath);
83
106
  const dirOverwriteQns = [];
84
- yield Promise.all(functionsAns.functions.map((fn) => __awaiter(void 0, void 0, void 0, function* () {
107
+ yield Promise.all(fns.map((fn) => __awaiter(void 0, void 0, void 0, function* () {
85
108
  const folderExists = yield fs_1.ASYNC.dirExists(fn.source);
86
109
  if (folderExists) {
87
110
  dirOverwriteQns.push(prompt_1.default.question(fn.name, 'Directory ' + (0, ansi_colors_1.underline)(fn.source) + ' already exists. Overwrite ?', {
@@ -91,7 +114,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
91
114
  }
92
115
  })));
93
116
  const dirOverwriteAns = yield prompt_1.default.ask(...dirOverwriteQns);
94
- let targets = functionsAns.functions.filter((fn) => {
117
+ let targets = fns.filter((fn) => {
95
118
  if (dirOverwriteAns[fn.name] === undefined || dirOverwriteAns[fn.name]) {
96
119
  return true;
97
120
  }
@@ -116,13 +139,13 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
116
139
  yield fs_1.ASYNC.ensureDir(fn.source);
117
140
  const buffer = (yield fnAPI.download(fn.id));
118
141
  yield new archiver_1.default().load(buffer).extract((0, path_1.join)(fnDirPath, fn.name)).finalize();
119
- if ((_a = fn.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.nodejs)) {
142
+ if ((_a = fn.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) {
120
143
  yield (0, languages_1.node)(fn);
121
144
  }
122
- else if ((_b = fn.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java)) {
145
+ else if ((_b = fn.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java.value)) {
123
146
  yield (0, languages_1.java)(fn);
124
147
  }
125
- else if ((_c = fn.stack) === null || _c === void 0 ? void 0 : _c.startsWith(runtime_1.default.language.python)) {
148
+ else if ((_c = fn.stack) === null || _c === void 0 ? void 0 : _c.startsWith(runtime_1.default.language.python.value)) {
126
149
  yield (0, languages_1.python)(fn);
127
150
  const reqFile = (0, path_1.join)(fn.source, constants_1.FILENAME.functions.python_requirements);
128
151
  const requirementsExists = yield fs_1.ASYNC.readFile(reqFile);
@@ -0,0 +1,37 @@
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 appsail_utils_1 = require("../../appsail-utils");
16
+ const port_resolver_1 = __importDefault(require("../../port-resolver"));
17
+ const runtime_store_1 = __importDefault(require("../../runtime-store"));
18
+ const config_1 = require("../../util_modules/config");
19
+ const logger_1 = require("../../util_modules/logger");
20
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
21
+ const allTargets = yield config_1.appSailConfig.getAllTargetDetails();
22
+ const optionTargets = (0, appsail_utils_1.filterTargets)(allTargets || []);
23
+ if (optionTargets.length === 0) {
24
+ (0, logger_1.debug)('AppSail targets are empty');
25
+ return;
26
+ }
27
+ const validated = (0, appsail_utils_1.validateAppSail)(optionTargets);
28
+ const filledTargets = yield Promise.all(validated.map((targ) => __awaiter(void 0, void 0, void 0, function* () {
29
+ var _a;
30
+ if (!targ.validity.valid) {
31
+ return targ;
32
+ }
33
+ const port = yield port_resolver_1.default.getPort('appsail', 'http', (_a = targ.appSail) === null || _a === void 0 ? void 0 : _a.name);
34
+ return Object.assign(Object.assign({}, targ), { port });
35
+ })));
36
+ runtime_store_1.default.set('context.appsail.targets', filledTargets);
37
+ });
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.apig = exports.functions = exports.client = void 0;
38
+ exports.appsail = exports.apig = exports.functions = exports.client = void 0;
39
39
  const error_1 = __importDefault(require("../../error"));
40
40
  const port_resolver_1 = __importDefault(require("../../port-resolver"));
41
41
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
@@ -74,3 +74,10 @@ function apig() {
74
74
  });
75
75
  }
76
76
  exports.apig = apig;
77
+ function appsail() {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const appSailModule = yield Promise.resolve().then(() => __importStar(require('./appsail.js')));
80
+ yield appSailModule.default();
81
+ });
82
+ }
83
+ exports.appsail = appsail;
@@ -99,11 +99,31 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
99
99
  advancedServer.add('functions', target);
100
100
  }
101
101
  else if (target.type === constants_1.FN_TYPE.basic &&
102
- ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python))) {
102
+ ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value))) {
103
103
  advancedServer.add('functions', target);
104
104
  }
105
105
  return target.valid;
106
106
  });
107
+ if (serveTargets.includes('appsail')) {
108
+ const appSail = runtime_store_1.default.get('context.appsail.targets', []);
109
+ const validAppSail = appSail.filter((sail) => {
110
+ var _a;
111
+ if (!sail.validity.valid) {
112
+ (0, logger_1.warning)('skipping serve of AppSail service [' +
113
+ ((_a = sail.appSail) === null || _a === void 0 ? void 0 : _a.name) +
114
+ '] since ' +
115
+ sail.validity.reason);
116
+ return false;
117
+ }
118
+ advancedServer.add('appsail', sail);
119
+ return true;
120
+ });
121
+ if (validAppSail.length === 0) {
122
+ (0, logger_1.labeled)('AppSail', 'No targets are ready to be served in local').WARN();
123
+ serveTargets.splice(serveTargets.indexOf('appsail'), 1);
124
+ runtime_store_1.default.set('context.targets', serveTargets);
125
+ }
126
+ }
107
127
  if (serveTargets.includes('client')) {
108
128
  const client = runtime_store_1.default.get('context.client', false);
109
129
  if (client && client.valid) {
@@ -130,13 +150,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
130
150
  (serveTargets.length === 1 && serveTargets[0] === 'apig')) {
131
151
  throw new error_1.default('No components to serve', { exit: 0, errorId: 'SERVE-1' });
132
152
  }
133
- const basicFn = runtime_store_1.default
134
- .get('context.functions.targets', [])
135
- .find((target) => {
153
+ const basicFn = functionTargets.find((target) => {
136
154
  var _a;
137
155
  return target.type === constants_1.FN_TYPE.basic &&
138
- !((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python)) &&
139
- target.valid;
156
+ !((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value));
140
157
  });
141
158
  if (basicFn) {
142
159
  yield basicFnServer.start();