zcatalyst-cli 1.18.0-beta.0 → 1.18.0-beta.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 (115) hide show
  1. package/docs/commands/event/generate/job.toml +7 -0
  2. package/docs/endpoints/lib/job-scheduling.toml +3 -0
  3. package/docs/internal/command.toml +5 -0
  4. package/lib/appsail-utils.js +4 -10
  5. package/lib/authentication/index.js +1 -0
  6. package/lib/bin/catalyst.js +1 -1
  7. package/lib/command_needs/rc.js +1 -1
  8. package/lib/commands/appsail/add.js +1 -0
  9. package/lib/commands/client/setup.js +1 -0
  10. package/lib/commands/event/generate/index.js +2 -1
  11. package/lib/commands/event/generate/integ.js +2 -1
  12. package/lib/commands/event/generate/job.js +82 -0
  13. package/lib/commands/functions/add.js +1 -0
  14. package/lib/commands/functions/delete.js +2 -4
  15. package/lib/commands/functions/setup.js +1 -0
  16. package/lib/commands/functions/shell.js +1 -0
  17. package/lib/commands/index.js +3 -1
  18. package/lib/commands/init.js +2 -6
  19. package/lib/commands/login.js +1 -0
  20. package/lib/commands/logout.js +1 -0
  21. package/lib/commands/pull.js +1 -0
  22. package/lib/commands/serve.js +1 -1
  23. package/lib/commands/whoami.js +1 -0
  24. package/lib/deploy/features/appsail/index.js +19 -17
  25. package/lib/deploy/features/appsail/utils.js +4 -5
  26. package/lib/endpoints/index.js +8 -1
  27. package/lib/endpoints/lib/appsail.js +7 -1
  28. package/lib/endpoints/lib/job-scheduling.js +61 -0
  29. package/lib/express_middlewares/logger.js +2 -4
  30. package/lib/fn-utils/lib/common.js +2 -3
  31. package/lib/fn-utils/lib/java.js +1 -1
  32. package/lib/fn-utils/lib/python.js +2 -2
  33. package/lib/fn-watcher.js +1 -1
  34. package/lib/init/dependencies/python/ensure-python.js +6 -8
  35. package/lib/init/features/appsail/index.js +14 -10
  36. package/lib/init/features/client/index.js +2 -1
  37. package/lib/init/features/functions/index.js +4 -0
  38. package/lib/init/features/functions/languages/python.js +21 -5
  39. package/lib/internal/api.js +12 -1
  40. package/lib/internal/command.js +30 -6
  41. package/lib/migration/index.js +4 -2
  42. package/lib/optional-import.js +3 -2
  43. package/lib/prompt/types/tree.js +3 -3
  44. package/lib/serve/features/appsail.js +2 -3
  45. package/lib/serve/index.js +1 -2
  46. package/lib/serve/server/index.js +8 -9
  47. package/lib/serve/server/lib/appsail/index.js +24 -34
  48. package/lib/serve/server/lib/java/aio_server/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  49. package/lib/serve/server/lib/java/aio_server/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  50. package/lib/serve/server/lib/java/aio_server/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  51. package/lib/serve/server/lib/java/index.js +2 -2
  52. package/lib/serve/server/lib/master/appsail.js +53 -0
  53. package/lib/serve/server/lib/master/functions.js +34 -0
  54. package/lib/serve/server/lib/master/index.js +155 -0
  55. package/lib/{express_middlewares/unknownReqProxy.js → serve/server/lib/master/unknown-req-proxy.js} +4 -7
  56. package/lib/serve/server/lib/master/utils.js +130 -0
  57. package/lib/serve/server/lib/master/web-client.js +39 -0
  58. package/lib/serve/server/lib/node/index.js +3 -3
  59. package/lib/serve/server/lib/python/index.js +3 -3
  60. package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  61. package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  62. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +2 -1
  63. package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  64. package/lib/shell/dependencies/invoker/event/node.mjs +1 -0
  65. package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  66. package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +254 -0
  67. package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  68. package/lib/shell/dependencies/invoker/job/java/lib/org.json.jar +0 -0
  69. package/lib/shell/dependencies/invoker/job/node.mjs +93 -0
  70. package/lib/shell/dependencies/local-function.js +121 -13
  71. package/lib/shell/index.js +7 -1
  72. package/lib/shell/prepare/languages/index.js +4 -4
  73. package/lib/shell/prepare/languages/java.js +1 -2
  74. package/lib/shell/prepare/languages/python.js +10 -16
  75. package/lib/throbber/index.js +6 -1
  76. package/lib/userConfig.js +7 -1
  77. package/lib/util_modules/config/index.js +1 -1
  78. package/lib/util_modules/config/lib/{appSail.js → appsail.js} +61 -9
  79. package/lib/util_modules/config/lib/client.js +6 -8
  80. package/lib/util_modules/config/lib/functions.js +6 -8
  81. package/lib/util_modules/constants/lib/default.js +9 -9
  82. package/lib/util_modules/constants/lib/fn-type.js +2 -1
  83. package/lib/util_modules/constants/lib/needed-scopes.js +53 -44
  84. package/lib/util_modules/constants/lib/placeholders.js +6 -0
  85. package/lib/util_modules/constants/lib/ref-mapping.js +2 -1
  86. package/lib/util_modules/constants/lib/remote-mapping.js +2 -1
  87. package/lib/util_modules/constants/lib/scopes.js +5 -1
  88. package/lib/util_modules/constants/lib/template.js +9 -4
  89. package/lib/util_modules/constants/lib/urls.js +8 -0
  90. package/lib/util_modules/fs/lib/async.js +7 -2
  91. package/lib/util_modules/fs/lib/sync.js +12 -1
  92. package/lib/util_modules/server.js +2 -4
  93. package/lib/winston.js +17 -11
  94. package/package.json +1 -1
  95. package/templates/event/job.json +30 -0
  96. package/templates/init/functions/java/job/.classpath +6 -0
  97. package/templates/init/functions/java/job/.project +17 -0
  98. package/templates/init/functions/java/job/catalyst-config.json +11 -0
  99. package/templates/init/functions/java/job/sample.java +34 -0
  100. package/templates/init/functions/node/aio/package.json +1 -1
  101. package/templates/init/functions/node/bio/package.json +1 -1
  102. package/templates/init/functions/node/cron/package.json +1 -1
  103. package/templates/init/functions/node/event/package.json +1 -1
  104. package/templates/init/functions/node/integ/cliq/package.json +1 -1
  105. package/templates/init/functions/node/integ/convokraft/package.json +1 -1
  106. package/templates/init/functions/node/{stream → job}/catalyst-config.json +3 -2
  107. package/templates/init/functions/node/{stream → job}/package.json +1 -1
  108. package/templates/init/functions/node/job/sample.js +28 -0
  109. package/templates/init/functions/node/job/types/job.d.ts +66 -0
  110. package/templates/init/functions/python/job/catalyst-config.json +11 -0
  111. package/templates/init/functions/python/job/requirements.txt +1 -0
  112. package/templates/init/functions/python/job/sample.py +23 -0
  113. package/templates/init.txt +13 -0
  114. package/lib/serve/server/lib/master.js +0 -326
  115. package/templates/init/functions/node/stream/sample.js +0 -15
@@ -32,7 +32,6 @@ const js_1 = require("../../util_modules/js");
32
32
  const logger_1 = require("../../util_modules/logger");
33
33
  const option_1 = require("../../util_modules/option");
34
34
  const project_1 = require("../../util_modules/project");
35
- const fs_2 = require("fs");
36
35
  const os_1 = require("os");
37
36
  const pip_install_1 = require("../../init/dependencies/python/pip-install");
38
37
  function validate() {
@@ -318,7 +317,7 @@ function pack(target) {
318
317
  const tmpDir = (0, path_1.join)((0, os_1.tmpdir)(), '.catalyst', 'python', target.name + Date.now().toString());
319
318
  yield fs_1.ASYNC.ensureDir(tmpDir);
320
319
  yield fs_1.ASYNC.emptyDir(tmpDir);
321
- yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, target.stack.replace('python_', ''), true);
320
+ yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, target.stack.replace('python_', ''), (0, os_1.platform)() === 'linux');
322
321
  const files = yield fs_1.ASYNC.walk(tmpDir);
323
322
  files.forEach((file) => {
324
323
  zip.add(file.path.replace(tmpDir + path_1.sep, ''), file.stats.isSymbolicLink()
@@ -578,7 +577,7 @@ function copyModDirPerm(src, dest, perm, { replace = true } = {}) {
578
577
  return res();
579
578
  }
580
579
  const destFile = (0, path_1.join)(dest, (0, path_1.basename)(content.path));
581
- yield fs_1.ASYNC.copyFile(content.path, destFile, replace ? fs_2.constants.COPYFILE_FICLONE : fs_2.constants.COPYFILE_EXCL).catch((err) => {
580
+ yield fs_1.ASYNC.copyFile(content.path, destFile, replace).catch((err) => {
582
581
  if (!replace && err.code === 'EEXIST') {
583
582
  return;
584
583
  }
@@ -287,7 +287,7 @@ function compileJavaFiles(file, spawnCommand, targetVersion, targetSource, outpu
287
287
  '*' + module.exports.classPathSep + '.',
288
288
  '-g',
289
289
  '-Xprefer:source',
290
- '-Xlint',
290
+ userConfig_1.default.get('javac.disable_warnings') === 'true' ? '-Xlint:none' : '-Xlint',
291
291
  file.replace(targetSource, outputFolder)
292
292
  ], {
293
293
  cwd: outputFolder,
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.removeRequirements = exports.validate = void 0;
39
39
  const ansi_colors_1 = require("ansi-colors");
40
- const os_1 = require("os");
40
+ const os_1 = __importStar(require("os"));
41
41
  const path_1 = __importStar(require("path"));
42
42
  const error_1 = __importDefault(require("../../error"));
43
43
  const ensure_python_1 = require("../../init/dependencies/python/ensure-python");
@@ -111,7 +111,7 @@ function removeRequirements(reqFile, target) {
111
111
  const tmpDir = (0, path_1.join)((0, os_1.tmpdir)(), '.catalyst', 'python', Date.now().toString());
112
112
  yield fs_1.ASYNC.ensureDir(tmpDir);
113
113
  yield fs_1.ASYNC.emptyDir(tmpDir);
114
- yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''), true);
114
+ yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''), os_1.default.platform() === 'linux');
115
115
  const files = yield fs_1.ASYNC.walk(tmpDir, { depth: 1, includeDirPaths: true });
116
116
  yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
117
117
  yield fs_1.ASYNC.deleteFile((0, path_1.join)(target.source, path_1.default.basename(file.path)));
package/lib/fn-watcher.js CHANGED
@@ -35,7 +35,7 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
35
35
  target.valid = true;
36
36
  target.compilationError = undefined;
37
37
  target.compilationWarning = undefined;
38
- yield (0, languages_1.prepareFunctions)([target], latestEvent);
38
+ yield (0, languages_1.prepareFunctions)([target]);
39
39
  if (currentLatestEvent.at === latestEvent.at) {
40
40
  latestEvent = undefined;
41
41
  }
@@ -99,14 +99,12 @@ function validateCommand(version, spawnCommand, skipHelp) {
99
99
  const data = Buffer.concat(dataBuf).toString();
100
100
  return resolve(data);
101
101
  }
102
- else {
103
- reject(new error_1.default(`unable to locate python${version} with the given binary path`, {
104
- exit: 1,
105
- errorId: 'PY-1',
106
- arg: [version, (0, ansi_colors_1.bold)(spawnCommand)],
107
- skipHelp
108
- }));
109
- }
102
+ reject(new error_1.default(`unable to locate python${version} with the given binary path`, {
103
+ exit: 1,
104
+ errorId: 'PY-1',
105
+ arg: [version, (0, ansi_colors_1.bold)(spawnCommand)],
106
+ skipHelp
107
+ }));
110
108
  });
111
109
  child.on('error', (err) => {
112
110
  reject(new error_1.default(`unable to locate python${version} with the given binary path`, {
@@ -36,7 +36,7 @@ function getAppSailZip() {
36
36
  api: _gitHubAPI.appsailNodejs.bind(_gitHubAPI),
37
37
  command: 'node index.js',
38
38
  source: (0, project_1.resolveProjectPath)('appsail-nodejs'),
39
- build: (0, project_1.resolveProjectPath)('appsail-nodejs'),
39
+ build: './',
40
40
  stack: {
41
41
  runtime: 'node16',
42
42
  lang: 'node'
@@ -54,7 +54,7 @@ function getAppSailZip() {
54
54
  api: _gitHubAPI.appsailJava.bind(_gitHubAPI),
55
55
  command: 'java -jar demo-0.0.1-SNAPSHOT.jar',
56
56
  source: (0, project_1.resolveProjectPath)('appsail-java'),
57
- build: (0, project_1.resolveProjectPath)('appsail-java', 'target', 'demo-0.0.1-SNAPSHOT.jar'),
57
+ build: (0, path_1.join)('target', 'demo-0.0.1-SNAPSHOT.jar'),
58
58
  stack: {
59
59
  runtime: 'java8',
60
60
  lang: 'java'
@@ -73,7 +73,7 @@ function getAppSailZip() {
73
73
  api: _gitHubAPI.appsailPython.bind(_gitHubAPI),
74
74
  command: 'python3 app.py',
75
75
  source: (0, project_1.resolveProjectPath)('appsail-python'),
76
- build: (0, project_1.resolveProjectPath)('appsail-python'),
76
+ build: './',
77
77
  stack: {
78
78
  runtime: 'python_3_9',
79
79
  lang: 'python'
@@ -148,15 +148,14 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
148
148
  const appSail = yield prompt_1.default.ask(prompt_1.default.question('buildPath', 'Please provide the build path of your AppSail service: ', {
149
149
  type: 'file-path',
150
150
  validate: (pth) => __awaiter(void 0, void 0, void 0, function* () {
151
- const buildPath = (0, path_1.resolve)(process.cwd(), pth.value);
151
+ const buildPath = (0, path_1.resolve)(runtime_store_1.default.get('cwd'), pth.value);
152
152
  if ((yield fs_1.ASYNC.dirExists(buildPath)) || (yield fs_1.ASYNC.fileExists(buildPath))) {
153
153
  return true;
154
154
  }
155
155
  return 'Path does not exists';
156
156
  }),
157
- when: !_appSailConfig.build,
158
- rootPath: _appSailConfig.source
159
- }), prompt_1.default.question('name', 'Please provide the name for your AppSail service: ', {
157
+ when: !_appSailConfig.build
158
+ }), prompt_1.default.question('name', 'Please provide the name for your AppSail: ', {
160
159
  type: 'input',
161
160
  default: 'AppSail',
162
161
  validate: (name) => {
@@ -165,7 +164,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
165
164
  : true;
166
165
  const match = name.match(constants_1.REGEX.functions.package.name)
167
166
  ? true
168
- : `Invalid function name. It should be in the following format: ${constants_1.REGEX.functions.package.name}`;
167
+ : `Invalid AppSail name. It should be in the following format: ${constants_1.REGEX.functions.package.name}`;
169
168
  return typeof exists === 'string'
170
169
  ? exists
171
170
  : typeof match === 'string'
@@ -182,7 +181,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
182
181
  const appConfig = {
183
182
  command: _appSailConfig.command ||
184
183
  'echo Please specify the start-up command in the app-config.json file under the key command',
185
- build_path: _appSailConfig.build || appSail.buildPath,
184
+ build_path: _appSailConfig.build || './' + (0, path_1.relative)(_appSailConfig.source, appSail.buildPath),
186
185
  stack: appSailStack.runtime,
187
186
  env_variables: {},
188
187
  memory: _appSailConfig.memory || 256,
@@ -209,5 +208,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
209
208
  }
210
209
  }
211
210
  runtime_store_1.default.set('payload.appsail.targets', [payload]);
212
- !isAppConfig && (yield fs_1.ASYNC.writeJSONFile(appConfigPth, appConfig));
211
+ if (isAppConfig) {
212
+ (0, logger_1.message)((0, ansi_colors_1.bold)(`app-config.json`) + ` file already exist in ${(0, ansi_colors_1.underline)(_appSailConfig.source)}`);
213
+ }
214
+ else {
215
+ yield fs_1.ASYNC.writeJSONFile(appConfigPth, appConfig);
216
+ }
213
217
  });
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  const index_js_1 = __importDefault(require("../../../prompt/index.js"));
39
39
  const index_js_2 = require("../../../util_modules/constants/index.js");
40
40
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
41
+ var _a;
41
42
  const clientInitAnswer = yield index_js_1.default.ask(index_js_1.default.question('clientFlavour', 'Choose the type of client to initialise: ', {
42
43
  type: 'list',
43
44
  choices: index_js_2.PLUGIN.client.map((plugin) => {
@@ -47,5 +48,5 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
47
48
  });
48
49
  })
49
50
  }));
50
- return (yield Promise.resolve().then(() => __importStar(require('./initializers/' + clientInitAnswer.clientFlavour)))).default();
51
+ return (yield (_a = './initializers/' + clientInitAnswer.clientFlavour, Promise.resolve().then(() => __importStar(require(_a))))).default();
51
52
  });
@@ -72,6 +72,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
72
72
  prompt_1.default.choice('Browser Logic', {
73
73
  value: constants_1.FN_TYPE.browserLogic,
74
74
  short: 'browser logic'
75
+ }),
76
+ prompt_1.default.choice('Job', {
77
+ value: constants_1.FN_TYPE.job,
78
+ short: 'job'
75
79
  })
76
80
  ];
77
81
  const integServicesRes = yield integServicesPromise;
@@ -79,15 +79,31 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
79
79
  const pyRespJson = fnType === constants_1.FN_TYPE.integration
80
80
  ? yield (0, pip_install_1.pypiRes)('zcatalyst-cliq')
81
81
  : yield (0, pip_install_1.pypiRes)('zcatalyst-sdk');
82
+ const latestVersion = (() => {
83
+ const releases = pyRespJson.releases;
84
+ const latest = Object.entries(releases).reduce((latest, [version, details]) => {
85
+ var _a;
86
+ const whlDetails = details.at(0);
87
+ if (!(whlDetails === null || whlDetails === void 0 ? void 0 : whlDetails.upload_time)) {
88
+ return latest;
89
+ }
90
+ const uploadTime = new Date(whlDetails.upload_time).getTime();
91
+ if (!((_a = latest.details) === null || _a === void 0 ? void 0 : _a.upload_time) ||
92
+ uploadTime > new Date(latest.details.upload_time).getTime()) {
93
+ latest = {
94
+ version,
95
+ details: whlDetails
96
+ };
97
+ }
98
+ return latest;
99
+ }, {});
100
+ return latest.version;
101
+ })();
82
102
  yield fs_1.ASYNC.findAndReplace(targetPath)([
83
103
  constants_1.PLACEHOLDER.functions.python_package.name,
84
104
  constants_1.PLACEHOLDER.functions.python_package.main,
85
105
  constants_1.PLACEHOLDER.functions.python_package.sdkVersion
86
- ], [
87
- functionAns.name,
88
- functionAns.main,
89
- pyRespJson.info.version
90
- ]);
106
+ ], [functionAns.name, functionAns.main, latestVersion]);
91
107
  yield fs_1.ASYNC.rename((0, path_1.join)(targetPath, constants_1.FILENAME.functions.python_main), () => functionAns.main);
92
108
  const integ_config = runtime_store_1.default.get('context.functions.integration.config', '');
93
109
  yield fn_utils_1.fnUtils.common.findAndReplaceConfigProps(targetPath, {
@@ -54,8 +54,12 @@ class API {
54
54
  json: true,
55
55
  headers
56
56
  };
57
+ const projectSecretKey = process.env.CATALYST_PROJECT_SECRET_KEY;
57
58
  if (!isExternal) {
58
59
  this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { Accept: 'application/vnd.catalyst.v2+json', 'X-CATALYST-Environment': env });
60
+ if (projectSecretKey) {
61
+ this.requestOpts.headers['X-ZC-PROJECT-SECRET-KEY'] = projectSecretKey;
62
+ }
59
63
  if (envId) {
60
64
  this.requestOpts.headers['CATALYST-ORG'] = envId;
61
65
  }
@@ -92,11 +96,18 @@ class API {
92
96
  '\n');
93
97
  }
94
98
  _logResp(resp) {
99
+ const ignoreHeaders = [
100
+ 'content-security-policy-report-only',
101
+ 'set-cookie',
102
+ 'content-security-policy'
103
+ ];
104
+ const logHeaders = Object.assign({}, resp.headers);
105
+ ignoreHeaders.forEach((header) => delete logHeaders[header]);
95
106
  (0, logger_1.debug)('<<<< HTTP RESPONSE : ' +
96
107
  resp.statusCode +
97
108
  '\n' +
98
109
  'Response Headers: ' +
99
- JSON.stringify(resp.headers) +
110
+ JSON.stringify(logHeaders) +
100
111
  '\n');
101
112
  if (!js_1.JS.isUndefined(resp.timings)) {
102
113
  (0, logger_1.debug)('TOTAL TIME TAKEN : ' + Number(resp.timings.end.toFixed(3)) + ' ms\n');
@@ -46,9 +46,12 @@ const js_1 = require("../util_modules/js");
46
46
  const logger_1 = require("../util_modules/logger");
47
47
  const option_1 = require("../util_modules/option");
48
48
  const project_1 = require("../util_modules/project");
49
+ const env_1 = require("../util_modules/env");
49
50
  class Command {
50
51
  constructor(cmd) {
52
+ this.subCommand = [];
51
53
  this.isSubCommand = false;
54
+ this.isCICommand = true;
52
55
  this.command = cmd;
53
56
  this.cmdName = cmd.split(' ')[0];
54
57
  this.aliasName = null;
@@ -88,9 +91,15 @@ class Command {
88
91
  this.helpText = text;
89
92
  return this;
90
93
  }
91
- addSubCommand(command) {
92
- this.subCommand = command;
93
- command.isSubCommand = true;
94
+ addSubCommand(...commands) {
95
+ commands.forEach((command) => {
96
+ this.subCommand.push(command);
97
+ command.isSubCommand = true;
98
+ });
99
+ return this;
100
+ }
101
+ ci(value) {
102
+ this.isCICommand = value;
94
103
  return this;
95
104
  }
96
105
  helpConfig(config) {
@@ -110,9 +119,14 @@ class Command {
110
119
  return this;
111
120
  }
112
121
  register(client, cli) {
122
+ var _a;
113
123
  this.client = client;
114
124
  const program = cli || client.cli;
115
- const cmd = program.command(this.command);
125
+ let opts = {};
126
+ if (env_1.isCI && !this.isCICommand) {
127
+ opts = { hidden: true };
128
+ }
129
+ const cmd = program.command(this.command, opts);
116
130
  if (this.aliasName !== null) {
117
131
  cmd.alias(this.aliasName);
118
132
  }
@@ -140,6 +154,13 @@ class Command {
140
154
  const runner = this.runner();
141
155
  const start = Date.now();
142
156
  const argCount = cmd._args.length;
157
+ if (!this.isCICommand && env_1.isCI) {
158
+ return (0, errorOut_1.default)(new error_1.default('Environment not supported', {
159
+ exit: 1,
160
+ errorId: 'CMD-2',
161
+ arg: [(0, ansi_colors_1.bold)(cmd.name()), (0, ansi_colors_1.bold)('CI=true catalyst help')]
162
+ }));
163
+ }
143
164
  if (programArgs.slice(-1)[0].args.length > argCount &&
144
165
  !this.allowUnknownOptions) {
145
166
  return (0, errorOut_1.default)(new error_1.default('Too many arguments', {
@@ -163,7 +184,9 @@ class Command {
163
184
  }
164
185
  }));
165
186
  if (this.subCommand) {
166
- this.subCommand.register(client, cmd);
187
+ (_a = this.subCommand) === null || _a === void 0 ? void 0 : _a.forEach((subCmd) => {
188
+ subCmd.register(client, cmd);
189
+ });
167
190
  }
168
191
  return cmd;
169
192
  }
@@ -206,7 +229,8 @@ class Command {
206
229
  (0, logger_1.debug)(e);
207
230
  }
208
231
  yield Promise.all(js_1.JS.map(this.beforeRunners, (before) => __awaiter(this, void 0, void 0, function* () {
209
- const beforeModule = (yield Promise.resolve().then(() => __importStar(require('../command_needs/' + before.fn)))).default;
232
+ var _a;
233
+ const beforeModule = (yield (_a = '../command_needs/' + before.fn, Promise.resolve().then(() => __importStar(require(_a))))).default;
210
234
  return beforeModule.call(this, before.args);
211
235
  })));
212
236
  return this.cmdAction.call(this, ...args);
@@ -44,6 +44,7 @@ const rc_1 = __importDefault(require("../internal/rc"));
44
44
  const fs_1 = require("../util_modules/fs");
45
45
  const logger_1 = require("../util_modules/logger");
46
46
  const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0, function* () {
47
+ var _a;
47
48
  if (migFiles.length <= idx) {
48
49
  return Promise.resolve();
49
50
  }
@@ -54,7 +55,7 @@ const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0
54
55
  return runMigration(rc, migFiles, ++idx);
55
56
  }
56
57
  try {
57
- const migModule = yield Promise.resolve().then(() => __importStar(require(migFile)));
58
+ const migModule = yield (_a = migFile, Promise.resolve().then(() => __importStar(require(_a))));
58
59
  if (migModule.isRequire()) {
59
60
  (0, logger_1.debug)('migration started for v' + currentMigFileVersion);
60
61
  migModule.migrate();
@@ -83,6 +84,7 @@ const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0
83
84
  return runMigration(rc, migFiles, ++idx);
84
85
  });
85
86
  const runGlobalMigration = (migFiles) => __awaiter(void 0, void 0, void 0, function* () {
87
+ var _b;
86
88
  if (migFiles.length === 0) {
87
89
  return;
88
90
  }
@@ -96,7 +98,7 @@ const runGlobalMigration = (migFiles) => __awaiter(void 0, void 0, void 0, funct
96
98
  return runGlobalMigration(migFiles);
97
99
  }
98
100
  try {
99
- const migModule = yield Promise.resolve().then(() => __importStar(require(migFile)));
101
+ const migModule = yield (_b = migFile, Promise.resolve().then(() => __importStar(require(_b))));
100
102
  if (migModule.isRequire()) {
101
103
  (0, logger_1.debug)('migration started for v' + currentMigFileVersion);
102
104
  migModule.migrate();
@@ -42,6 +42,7 @@ const async_js_1 = require("./util_modules/fs/lib/async.js");
42
42
  const error_js_1 = __importDefault(require("./error.js"));
43
43
  const ansi_colors_1 = require("ansi-colors");
44
44
  exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function* () {
45
+ var _a, _b;
45
46
  if (name === (0, path_1.basename)(name)) {
46
47
  const projectModulePath = (0, project_js_1.resolveProjectPath)((0, path_1.join)(source, 'node_modules', name));
47
48
  const projectModulePathExists = yield (0, async_js_1.dirExists)(projectModulePath);
@@ -53,7 +54,7 @@ exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function*
53
54
  });
54
55
  }
55
56
  app_module_path_1.default.addPath(projectModulePath);
56
- return Promise.resolve().then(() => __importStar(require(projectModulePath)));
57
+ return _a = projectModulePath, Promise.resolve().then(() => __importStar(require(_a)));
57
58
  }
58
59
  const projectModulePath = (0, project_js_1.resolveProjectPath)(name);
59
60
  const projectModulePathExists = yield (0, async_js_1.dirExists)(projectModulePath);
@@ -65,5 +66,5 @@ exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function*
65
66
  });
66
67
  }
67
68
  app_module_path_1.default.addPath(projectModulePath);
68
- return Promise.resolve().then(() => __importStar(require(projectModulePath)));
69
+ return _b = projectModulePath, Promise.resolve().then(() => __importStar(require(_b)));
69
70
  });
@@ -26,6 +26,9 @@ var ETreeState;
26
26
  ETreeState[ETreeState["EXPANDED"] = 3] = "EXPANDED";
27
27
  })(ETreeState || (ETreeState = {}));
28
28
  class TreeNode {
29
+ get indent() {
30
+ return this.level * 2;
31
+ }
29
32
  constructor(root) {
30
33
  _TreeNode_instances.add(this);
31
34
  this.open = false;
@@ -36,9 +39,6 @@ class TreeNode {
36
39
  this.level = 1;
37
40
  this.root = root;
38
41
  }
39
- get indent() {
40
- return this.level * 2;
41
- }
42
42
  addNode(node) {
43
43
  if (node instanceof TreeNode) {
44
44
  this.leaves.push(node);
@@ -27,19 +27,18 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
27
27
  }
28
28
  const validated = (0, appsail_utils_1.validateAppSail)(optionTargets);
29
29
  const filledTargets = yield Promise.all(validated.map((targ) => __awaiter(void 0, void 0, void 0, function* () {
30
- var _a, _b;
31
30
  if (!targ.validity.valid) {
32
31
  return targ;
33
32
  }
34
33
  const proxyPort = yield port_resolver_1.default.getPort('appsail', 'http', {
35
- name: ((_a = targ.appSail) === null || _a === void 0 ? void 0 : _a.name) + '_proxy',
34
+ name: targ.name + '_proxy',
36
35
  searchSpan: 10,
37
36
  server: 'master'
38
37
  }).catch((err) => {
39
38
  throw new error_1.default('No free ports between 3000 and 3010. AppSail needs the ports within this range to function properly', { original: err });
40
39
  });
41
40
  const appsailPort = yield port_resolver_1.default.getPort('appsail', 'http', {
42
- name: ((_b = targ.appSail) === null || _b === void 0 ? void 0 : _b.name) + '_proxy',
41
+ name: targ.name + '_proxy',
43
42
  server: 'service'
44
43
  });
45
44
  return Object.assign(Object.assign({}, targ), { port: { appsail: appsailPort, proxy: proxyPort } });
@@ -108,10 +108,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
108
108
  if (serveTargets.includes('appsail')) {
109
109
  const appSail = runtime_store_1.default.get('context.appsail.targets', []);
110
110
  const validAppSail = appSail.filter((sail) => {
111
- var _a;
112
111
  if (!sail.validity.valid) {
113
112
  (0, logger_1.warning)('skipping serve of AppSail service [' +
114
- ((_a = sail.appSail) === null || _a === void 0 ? void 0 : _a.name) +
113
+ sail.name +
115
114
  '] since ' +
116
115
  sail.validity.reason);
117
116
  return false;
@@ -117,7 +117,7 @@ class Server {
117
117
  });
118
118
  }
119
119
  startServer(details, masterPort) {
120
- var _a, _b, _c;
120
+ var _a, _b;
121
121
  return __awaiter(this, void 0, void 0, function* () {
122
122
  if (details.target === undefined) {
123
123
  return details;
@@ -170,7 +170,7 @@ class Server {
170
170
  if (details.type === 'appsail') {
171
171
  const target = details.target;
172
172
  target.validity.valid = false;
173
- (0, logger_1.labeled)(`AppSail[${(_c = target.appSail) === null || _c === void 0 ? void 0 : _c.name}]`, error).ERROR();
173
+ (0, logger_1.labeled)(`AppSail[${target.name}]`, error).ERROR();
174
174
  }
175
175
  else if (details.type === 'client') {
176
176
  const target = details.target;
@@ -252,7 +252,7 @@ class Server {
252
252
  }
253
253
  this.masterServer =
254
254
  masterTargets.length > 0
255
- ? yield (0, master_1.default)(masterPort, masterTargets.targets)
255
+ ? yield (0, master_1.default)(masterPort, { otherServerDetails: masterTargets.targets })
256
256
  : undefined;
257
257
  startPromise = new Promise((res) => {
258
258
  this.masterServer
@@ -284,16 +284,16 @@ class Server {
284
284
  }
285
285
  if (this.targetsMap.appSail.length > 0) {
286
286
  yield Promise.all(this.targetsMap.appSail.map((targSail) => this.startServer(targSail, -1).then((details) => {
287
- var _a, _b, _c, _d, _e, _f;
287
+ var _a, _b, _c, _d;
288
288
  const serverDetails = details;
289
289
  if (!((_a = serverDetails.target) === null || _a === void 0 ? void 0 : _a.validity.valid)) {
290
290
  return;
291
291
  }
292
292
  logUrls.appsail.targs.push(targSail);
293
293
  logUrls.appsail.nameMaxLength =
294
- ((_c = (_b = targSail.target) === null || _b === void 0 ? void 0 : _b.appSail) === null || _c === void 0 ? void 0 : _c.name) &&
295
- ((_e = (_d = targSail.target) === null || _d === void 0 ? void 0 : _d.appSail) === null || _e === void 0 ? void 0 : _e.name.length) > logUrls.appsail.nameMaxLength
296
- ? (_f = targSail.target) === null || _f === void 0 ? void 0 : _f.appSail.name.length
294
+ ((_b = targSail.target) === null || _b === void 0 ? void 0 : _b.name) &&
295
+ ((_c = targSail.target) === null || _c === void 0 ? void 0 : _c.name.length) > logUrls.appsail.nameMaxLength
296
+ ? (_d = targSail.target) === null || _d === void 0 ? void 0 : _d.name.length
297
297
  : logUrls.appsail.nameMaxLength;
298
298
  })));
299
299
  }
@@ -370,9 +370,8 @@ class Server {
370
370
  (0, logger_1.info)();
371
371
  (0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>>> AppSail <<<<<<<<<<<<<< '));
372
372
  _logTarg.targs.forEach((t) => {
373
- var _a;
374
373
  const targetSail = t.target;
375
- const targName = ((_a = targetSail.appSail) === null || _a === void 0 ? void 0 : _a.name) + '';
374
+ const targName = targetSail.name + '';
376
375
  (0, logger_1.labeled)(targName +
377
376
  ' '.repeat((_logTarg.nameMaxLength || targName.length) - targName.length), `http://localhost:${targetSail.port.proxy}`).MESSAGE();
378
377
  });
@@ -24,7 +24,6 @@ const archiver_1 = __importDefault(require("../../../../archiver"));
24
24
  const option_1 = require("../../../../util_modules/option");
25
25
  const execute_script_1 = require("../../../../execute-script");
26
26
  const master_1 = __importDefault(require("../master"));
27
- const ansi_colors_1 = require("ansi-colors");
28
27
  function executeHook(script, name, moduleSource) {
29
28
  if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
30
29
  (0, logger_1.debug)(`skipping ${name} hook`);
@@ -48,46 +47,37 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
48
47
  var _a, _b, _c, _d;
49
48
  let child;
50
49
  const targetSail = serverDetails.target;
51
- if (!targetSail || !targetSail.appSail) {
50
+ if (!targetSail || !targetSail.config) {
52
51
  throw new error_1.default('AppSail details not found');
53
52
  }
54
- if ((_a = targetSail.appSail.scripts) === null || _a === void 0 ? void 0 : _a.preserve) {
55
- executeHook(targetSail.appSail.scripts.preserve, `AppSail [PRESERVE] [${(_b = targetSail.appSail) === null || _b === void 0 ? void 0 : _b.name}]`, targetSail.appSail.source);
56
- }
57
- const buildPath = targetSail.appSail.buildPath
58
- ? targetSail.appSail.buildPath
59
- : (_c = targetSail.appSail) === null || _c === void 0 ? void 0 : _c.build_path;
60
- if (!(yield fs_1.ASYNC.isPathExists(buildPath))) {
61
- throw new error_1.default(`Build path does not exists [${buildPath}]`, {
62
- exit: 1,
63
- errorId: 'SERVE-APPSAIL-1',
64
- arg: [ansi_colors_1.italic.red(buildPath), (0, ansi_colors_1.bold)(targetSail.appSail.name)]
65
- });
53
+ if ((_a = targetSail.config.scripts) === null || _a === void 0 ? void 0 : _a.preserve) {
54
+ executeHook(targetSail.config.scripts.preserve, `AppSail [PRESERVE] [${targetSail.name}]`, targetSail.source);
66
55
  }
56
+ const buildPath = (_b = targetSail.config) === null || _b === void 0 ? void 0 : _b.build_path;
67
57
  const target = (yield fs_1.ASYNC.fileExists(buildPath)) ? (0, path_1.dirname)(buildPath) : buildPath;
68
58
  switch (true) {
69
- case targetSail.appSail.stack.startsWith('node'): {
59
+ case targetSail.config.stack.startsWith('node'): {
70
60
  child = startAppSail(targetSail.port.appsail, {
71
61
  type: 'nodejs',
72
62
  target,
73
- command: targetSail.appSail.command,
74
- memory: targetSail.appSail.memory || 256,
75
- env: targetSail.appSail.env_variables
63
+ command: targetSail.config.command,
64
+ memory: targetSail.config.memory || 256,
65
+ env: targetSail.config.env_variables
76
66
  });
77
67
  break;
78
68
  }
79
- case targetSail.appSail.stack.startsWith('python'): {
69
+ case targetSail.config.stack.startsWith('python'): {
80
70
  child = startAppSail(targetSail.port.appsail, {
81
71
  type: 'python',
82
72
  target,
83
- command: targetSail.appSail.command,
84
- memory: targetSail.appSail.memory || 256,
85
- env: targetSail.appSail.env_variables
73
+ command: targetSail.config.command,
74
+ memory: targetSail.config.memory || 256,
75
+ env: targetSail.config.env_variables
86
76
  });
87
77
  break;
88
78
  }
89
- case targetSail.appSail.stack.startsWith('java'): {
90
- if (targetSail.appSail.platform === 'war') {
79
+ case targetSail.config.stack.startsWith('java'): {
80
+ if (targetSail.config.platform === 'war') {
91
81
  const jettyPath = (0, path_1.join)(constants_1.ENVPATH.runtimes.data, 'jetty');
92
82
  if (!(yield fs_1.ASYNC.fileExists((0, path_1.join)(jettyPath, 'start.jar')).catch((err) => (0, logger_1.debug)(err)))) {
93
83
  try {
@@ -112,17 +102,17 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
112
102
  target,
113
103
  type: 'war',
114
104
  command: jettyCommand,
115
- memory: targetSail.appSail.memory || 256,
116
- env: Object.assign({ JETTY_BASE: (0, path_1.join)(jettyPath, 'JETTY_BASE') }, targetSail.appSail.env_variables)
105
+ memory: targetSail.config.memory || 256,
106
+ env: Object.assign({ JETTY_BASE: (0, path_1.join)(jettyPath, 'JETTY_BASE') }, targetSail.config.env_variables)
117
107
  });
118
108
  break;
119
109
  }
120
110
  child = startAppSail(targetSail.port.appsail, {
121
111
  target,
122
- command: targetSail.appSail.command,
112
+ command: targetSail.config.command,
123
113
  type: 'javase',
124
- memory: targetSail.appSail.memory || 256,
125
- env: targetSail.appSail.env_variables
114
+ memory: targetSail.config.memory || 256,
115
+ env: targetSail.config.env_variables
126
116
  });
127
117
  break;
128
118
  }
@@ -131,7 +121,7 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
131
121
  }
132
122
  }
133
123
  const masterServe = yield (0, master_1.default)(targetSail.port.proxy, {
134
- appSail: [serverDetails]
124
+ appSailDetails: serverDetails
135
125
  });
136
126
  child.once('exit', () => {
137
127
  masterServe.close((err) => {
@@ -140,13 +130,13 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
140
130
  }
141
131
  });
142
132
  });
143
- if ((_d = targetSail.appSail.scripts) === null || _d === void 0 ? void 0 : _d.postserve) {
133
+ if ((_d = (_c = targetSail.config) === null || _c === void 0 ? void 0 : _c.scripts) === null || _d === void 0 ? void 0 : _d.postserve) {
144
134
  child.once('exit', () => {
145
- var _a, _b, _c, _d;
146
- if (!((_a = targetSail.appSail) === null || _a === void 0 ? void 0 : _a.scripts)) {
135
+ var _a, _b, _c;
136
+ if (!((_a = targetSail.config) === null || _a === void 0 ? void 0 : _a.scripts)) {
147
137
  return;
148
138
  }
149
- executeHook((_b = targetSail.appSail.scripts) === null || _b === void 0 ? void 0 : _b.postserve, `AppSail [POSTSERVE] [${(_c = targetSail.appSail) === null || _c === void 0 ? void 0 : _c.name}]`, (_d = targetSail.appSail) === null || _d === void 0 ? void 0 : _d.source);
139
+ executeHook((_c = (_b = targetSail.config) === null || _b === void 0 ? void 0 : _b.scripts) === null || _c === void 0 ? void 0 : _c.postserve, `AppSail [POSTSERVE] [${targetSail.name}]`, targetSail.source);
150
140
  });
151
141
  }
152
142
  return child;