zcatalyst-cli 1.17.3 → 1.17.5

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.
@@ -1,6 +1,6 @@
1
1
  [RC-1]
2
- context = '''The project(${arg[0]}) provided with the ${arg[1]} option is not available in the Catalyst remote console'''
3
- aid = '''Please use one of the available projects with the ${arg[1]} option. \nThe available projects are: \n${arg[2]}'''
2
+ context = '''The project(${arg[0]}) provided with the ${arg[1]} option is not available is not available in the ${arg[3]} org.'''
3
+ aid = '''Please use one of the available projects with the ${arg[1]} option or specify the correct org \nThe available projects in the ${arg[3]} org are: \n${arg[2]}'''
4
4
  link = 'https://www.zoho.com/catalyst/help/cli-options.html#Project'
5
5
 
6
6
  [RC-2]
@@ -34,11 +34,6 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
34
34
  const projectOpt = globProjectOpt
35
35
  ? globProjectOpt
36
36
  : (0, env_1.getEnvVariable)('CATALYST_PROJECT', null);
37
- if (projectOpt !== null && orgOpt === null) {
38
- throw new error_1.default('Org option is needed when project option is supplied', {
39
- exit: 2
40
- });
41
- }
42
37
  const orgApi = yield (0, endpoints_1.orgAPI)();
43
38
  if (orgOpt !== null) {
44
39
  const orgList = yield orgApi.getAllOrgs();
@@ -50,8 +45,8 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
50
45
  }
51
46
  runtime_store_1.default.set('project.env.id', orgOpt + '');
52
47
  }
53
- let projectApi = orgOpt !== null ? yield (0, endpoints_1.projectAPI)({ auth: true, org: orgOpt }) : yield (0, endpoints_1.projectAPI)();
54
- let envApi = orgOpt !== null ? yield (0, endpoints_1.envAPI)({ auth: true, org: orgOpt }) : yield (0, endpoints_1.envAPI)();
48
+ let projectApi = yield (0, endpoints_1.projectAPI)();
49
+ let envApi = yield (0, endpoints_1.envAPI)();
55
50
  const convertProjectToProperties = (project) => {
56
51
  project = (0, project_2.transformProject)(project);
57
52
  runtime_store_1.default.set('project.name', project.name);
@@ -81,6 +76,9 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
81
76
  const projectArr = (yield projectApi.getAllProjects());
82
77
  const project = js_1.JS.find(projectArr, { project_name: projectOpt });
83
78
  if (project === undefined) {
79
+ const allOrgs = yield orgApi.getAllOrgs();
80
+ const orgId = (0, project_2.getEnvId)();
81
+ const orgDetails = allOrgs.find((org) => (!orgId && org.is_default) || org.name === orgId || org.id === orgId);
84
82
  throw new error_1.default('invalid project provided with the --project option', {
85
83
  exit: 1,
86
84
  errorId: 'RC-1',
@@ -91,7 +89,9 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
91
89
  .filter((proj) => proj.project_type &&
92
90
  project_1.default.accepted_types.includes(proj.project_type))
93
91
  .map((project) => '* ' + project.project_name)
94
- .join('\n'))
92
+ .join('\n')),
93
+ `${orgDetails === null || orgDetails === void 0 ? void 0 : orgDetails.name}(${orgDetails === null || orgDetails === void 0 ? void 0 : orgDetails.id})` +
94
+ ((orgDetails === null || orgDetails === void 0 ? void 0 : orgDetails.is_default) ? ' [DEFAULT]' : '')
95
95
  ]
96
96
  });
97
97
  }
@@ -45,7 +45,7 @@ function getConfigJsonInputs() {
45
45
  const stack = yield (0, utils_1.validateOptions)(utils_1.validateStack, 'stack', runtimeDetailsPromise);
46
46
  const platform = yield (0, utils_1.validateOptions)(utils_1.validatePlatform, 'platform', stack);
47
47
  const optValues = {
48
- buildPath: yield (0, utils_1.validateOptions)(utils_1.validateBuildPath, 'buildPath'),
48
+ build_path: yield (0, utils_1.validateOptions)(utils_1.validateBuildPath, 'buildPath'),
49
49
  stack,
50
50
  platform,
51
51
  command: (0, option_1.getOptionValue)('command', false)
@@ -54,7 +54,7 @@ function getConfigJsonInputs() {
54
54
  yield prompt_1.default.register('file-path');
55
55
  const appConfigAns = yield prompt_1.default.ask(prompt_1.default.question('buildPath', 'Please provide the build directory of your AppSail service', {
56
56
  type: 'file-path',
57
- when: () => optValues.buildPath === false,
57
+ when: () => optValues.build_path === false,
58
58
  rootPath: cwd,
59
59
  validate: ({ value }) => __awaiter(this, void 0, void 0, function* () {
60
60
  const pathRes = (0, utils_1.validateBuildPath)(value);
@@ -190,7 +190,8 @@ exports.default = (standAlone = false) => __awaiter(void 0, void 0, void 0, func
190
190
  text: `Preparing AppSail[${targ.name}]`
191
191
  });
192
192
  const zip = new archiver_1.default();
193
- const folderPath = (0, project_1.resolveProjectPath)(targ.buildPath);
193
+ const buildPath = targ.buildPath ? targ.buildPath : targ.build_path;
194
+ const folderPath = (0, project_1.resolveProjectPath)(buildPath);
194
195
  const ignoreFile = yield fs_1.ASYNC.readFile((0, path_1.join)(folderPath, constants_1.FILENAME.catalyst_ignore));
195
196
  const folderContents = yield fs_1.ASYNC.walk(folderPath, {
196
197
  filter: {
@@ -36,7 +36,7 @@ function validateOptions(validationFn, option, ...args) {
36
36
  exports.validateOptions = validateOptions;
37
37
  function validateBuildPath(path) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
- const cwd = runtime_store_1.default.get('cwd');
39
+ const cwd = process.cwd();
40
40
  if (path) {
41
41
  const buildPath = (0, path_1.isAbsolute)(path) ? path : (0, path_1.resolve)(cwd, path);
42
42
  return (yield fs_1.ASYNC.dirExists(buildPath)) ? path : false;
@@ -148,7 +148,7 @@ 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)(runtime_store_1.default.get('cwd'), pth.value);
151
+ const buildPath = (0, path_1.resolve)(process.cwd(), pth.value);
152
152
  if ((yield fs_1.ASYNC.dirExists(buildPath)) || (yield fs_1.ASYNC.fileExists(buildPath))) {
153
153
  return true;
154
154
  }
@@ -182,7 +182,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
182
182
  const appConfig = {
183
183
  command: _appSailConfig.command ||
184
184
  'echo Please specify the start-up command in the app-config.json file under the key command',
185
- buildPath: _appSailConfig.build || appSail.buildPath,
185
+ build_path: _appSailConfig.build || appSail.buildPath,
186
186
  stack: appSailStack.runtime,
187
187
  env_variables: {},
188
188
  memory: _appSailConfig.memory || 256,
@@ -55,7 +55,10 @@ class API {
55
55
  headers
56
56
  };
57
57
  if (!isExternal) {
58
- this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { Accept: 'application/vnd.catalyst.v2+json', 'X-CATALYST-Environment': env, 'CATALYST-ORG': envId });
58
+ this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { Accept: 'application/vnd.catalyst.v2+json', 'X-CATALYST-Environment': env });
59
+ if (envId) {
60
+ this.requestOpts.headers['CATALYST-ORG'] = envId;
61
+ }
59
62
  }
60
63
  this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { 'User-Agent': runtime_store_1.default.get('context.cli.package.name') +
61
64
  '/' +
@@ -45,7 +45,7 @@ const startAppSail = (port, opts) => {
45
45
  }).RAW();
46
46
  };
47
47
  exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function* () {
48
- var _a, _b, _c;
48
+ var _a, _b, _c, _d;
49
49
  let child;
50
50
  const targetSail = serverDetails.target;
51
51
  if (!targetSail || !targetSail.appSail) {
@@ -54,16 +54,17 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
54
54
  if ((_a = targetSail.appSail.scripts) === null || _a === void 0 ? void 0 : _a.preserve) {
55
55
  executeHook(targetSail.appSail.scripts.preserve, `AppSail [PRESERVE] [${(_b = targetSail.appSail) === null || _b === void 0 ? void 0 : _b.name}]`, targetSail.appSail.source);
56
56
  }
57
- if (!(yield fs_1.ASYNC.isPathExists(targetSail.appSail.buildPath))) {
58
- throw new error_1.default(`Build path does not exists [${targetSail.appSail.buildPath}]`, {
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}]`, {
59
62
  exit: 1,
60
63
  errorId: 'SERVE-APPSAIL-1',
61
- arg: [ansi_colors_1.italic.red(targetSail.appSail.buildPath), (0, ansi_colors_1.bold)(targetSail.appSail.name)]
64
+ arg: [ansi_colors_1.italic.red(buildPath), (0, ansi_colors_1.bold)(targetSail.appSail.name)]
62
65
  });
63
66
  }
64
- const target = (yield fs_1.ASYNC.fileExists(targetSail.appSail.buildPath))
65
- ? (0, path_1.dirname)(targetSail.appSail.buildPath)
66
- : targetSail.appSail.buildPath;
67
+ const target = (yield fs_1.ASYNC.fileExists(buildPath)) ? (0, path_1.dirname)(buildPath) : buildPath;
67
68
  switch (true) {
68
69
  case targetSail.appSail.stack.startsWith('node'): {
69
70
  child = startAppSail(targetSail.port.appsail, {
@@ -139,7 +140,7 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
139
140
  }
140
141
  });
141
142
  });
142
- if ((_c = targetSail.appSail.scripts) === null || _c === void 0 ? void 0 : _c.postserve) {
143
+ if ((_d = targetSail.appSail.scripts) === null || _d === void 0 ? void 0 : _d.postserve) {
143
144
  child.once('exit', () => {
144
145
  var _a, _b, _c, _d;
145
146
  if (!((_a = targetSail.appSail) === null || _a === void 0 ? void 0 : _a.scripts)) {
@@ -34,9 +34,9 @@ const logger_1 = require("../../../../util_modules/logger");
34
34
  const project_1 = require("../../../../util_modules/project");
35
35
  const shell_1 = require("../../../../util_modules/shell");
36
36
  exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, function* () {
37
- var _a, _b;
37
+ var _a, _b, _c, _d, _e, _f;
38
38
  const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
39
- const _c = details.target, { ['watcher']: _ } = _c, serialisableTarget = __rest(_c, ['watcher']);
39
+ const _g = details.target, { ['watcher']: _ } = _g, serialisableTarget = __rest(_g, ['watcher']);
40
40
  const projectRoot = runtime_store_1.default.get('project.root');
41
41
  serialisableTarget.index = serialisableTarget.index
42
42
  ? serialisableTarget.index.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build))
@@ -44,13 +44,20 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
44
44
  const opts = [
45
45
  (0, path_1.join)(__dirname, 'server'),
46
46
  details.httpPort + '',
47
- JSON.stringify(serialisableTarget)
47
+ JSON.stringify({
48
+ index: ((_b = details.target) === null || _b === void 0 ? void 0 : _b.index)
49
+ ? details.target.index.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build))
50
+ : undefined,
51
+ name: (_c = details.target) === null || _c === void 0 ? void 0 : _c.name,
52
+ type: (_d = details.target) === null || _d === void 0 ? void 0 : _d.type,
53
+ source: (_e = details.target) === null || _e === void 0 ? void 0 : _e.source
54
+ })
48
55
  ];
49
56
  if (details.debugPort !== -1) {
50
57
  (0, logger_1.labeled)(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
51
58
  opts.unshift('--inspect=' + details.debugPort);
52
59
  }
53
- const targetSource = (_b = details.target) === null || _b === void 0 ? void 0 : _b.source;
60
+ const targetSource = (_f = details.target) === null || _f === void 0 ? void 0 : _f.source;
54
61
  const servePlugin = yield (0, plugin_loader_1.default)('functions', 'start', targetSource).catch((err) => (0, logger_1.debug)(err));
55
62
  if (typeof servePlugin === 'function') {
56
63
  const logStreamPlugin = yield (0, plugin_loader_1.default)('functions', 'logs', targetSource).catch((err) => (0, logger_1.debug)(err));
@@ -184,12 +184,13 @@ class HttpFunctions {
184
184
  exit: 2
185
185
  });
186
186
  }
187
+ const slaveFnTarget = { index: fnTarget.index, name: fnTarget.name };
187
188
  if ((_a = fnTarget.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) {
188
189
  if (debugPort !== -1) {
189
190
  slaveOptions.push('--inspect-brk=' + debugPort);
190
191
  }
191
192
  slaveOptions.push(this.nodeInvoker[fnTarget.type]);
192
- slaveOptions.push(JSON.stringify(fnTarget));
193
+ slaveOptions.push(JSON.stringify(slaveFnTarget));
193
194
  slaveOptions.push(query);
194
195
  slaveOptions.push(JSON.stringify({
195
196
  'x-zc-projectid': request.headers['x-zc-projectid'],
@@ -232,7 +233,7 @@ class HttpFunctions {
232
233
  }
233
234
  slaveOptions.push((0, path_1.basename)(invoker));
234
235
  slaveOptions.push(javaInvokerDir);
235
- slaveOptions.push(JSON.stringify(fnTarget));
236
+ slaveOptions.push(JSON.stringify(slaveFnTarget));
236
237
  slaveOptions.push(query);
237
238
  slaveOptions.push(JSON.stringify({
238
239
  'x-zc-projectid': request.headers['x-zc-projectid'],
@@ -95,12 +95,13 @@ class LocalFunction {
95
95
  const debugPort = runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, null);
96
96
  yield fs_1.ASYNC.ensureFile(this.responseFile, true);
97
97
  yield fs_1.ASYNC.ensureFile(this.metaFile, true);
98
+ const slaveFnTarget = { index: this.target.index, name: this.target.name };
98
99
  if ((_a = this.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) {
99
100
  if (debugPort !== null) {
100
101
  slaveOptions.push('--inspect-brk=' + debugPort);
101
102
  }
102
103
  slaveOptions.push(this.nodeInvoker);
103
- slaveOptions.push(JSON.stringify(this.target));
104
+ slaveOptions.push(JSON.stringify(slaveFnTarget));
104
105
  slaveOptions.push(data);
105
106
  slaveOptions.push(JSON.stringify({
106
107
  'x-zc-projectid': (0, project_1.getProjectId)(),
@@ -132,7 +133,7 @@ class LocalFunction {
132
133
  }
133
134
  slaveOptions.push((0, path_1.basename)(this.javaInvoker));
134
135
  slaveOptions.push(javaInvokerDir);
135
- slaveOptions.push(JSON.stringify(this.target));
136
+ slaveOptions.push(JSON.stringify(slaveFnTarget));
136
137
  slaveOptions.push(data);
137
138
  slaveOptions.push(JSON.stringify({
138
139
  'x-zc-projectid': (0, project_1.getProjectId)(),
@@ -45,7 +45,7 @@ exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
45
45
  }
46
46
  const targetBuildPath = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, target.name);
47
47
  if (yield fs_1.ASYNC.isPathExists(targetBuildPath)) {
48
- yield fs_1.ASYNC.deleteDir(targetBuildPath);
48
+ yield fs_1.ASYNC.emptyDir(targetBuildPath);
49
49
  }
50
50
  if (target.type === constants_1.FN_TYPE.advanced ||
51
51
  target.type === constants_1.FN_TYPE.applogic ||
@@ -36,7 +36,9 @@ exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
36
36
  return target;
37
37
  });
38
38
  return Promise.all(nodeTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () {
39
- yield fs_1.ASYNC.copyDir(target.source, (0, path_1.join)(runtime_store_1.default.get('project.root'), constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, target.name));
39
+ const buildPath = (0, path_1.join)(runtime_store_1.default.get('project.root'), constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, target.name);
40
+ yield fs_1.ASYNC.emptyDir(buildPath);
41
+ yield fs_1.ASYNC.copyDir(target.source, buildPath);
40
42
  throbber.remove('function_serve_' + target.name);
41
43
  return target;
42
44
  })));
@@ -57,6 +57,7 @@ exports.default = (targets, fnWatchEvent) => __awaiter(void 0, void 0, void 0, f
57
57
  target.failure_reason = error.message;
58
58
  }
59
59
  }
60
+ yield fs_1.ASYNC.emptyDir(buildPath);
60
61
  yield fs_1.ASYNC.copyDir(target.source, buildPath);
61
62
  throbber.remove('function_serve_' + target.name);
62
63
  return target;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.17.3",
3
+ "version": "1.17.5",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {