zcatalyst-cli 1.26.2 → 1.27.0

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 (151) hide show
  1. package/README.md +1 -0
  2. package/lib/authentication/credential.d.ts +2 -1
  3. package/lib/authentication/credential.js +20 -3
  4. package/lib/authentication/crypt.d.ts +7 -3
  5. package/lib/authentication/crypt.js +87 -16
  6. package/lib/authentication/index.js +1 -0
  7. package/lib/authentication/key-manager.d.ts +7 -0
  8. package/lib/authentication/key-manager.js +62 -0
  9. package/lib/authentication/login.js +20 -20
  10. package/lib/bin/catalyst.js +1 -15
  11. package/lib/client.d.ts +3 -1
  12. package/lib/client.js +16 -5
  13. package/lib/command_needs/rc.js +13 -3
  14. package/lib/commands/appsail/add.js +10 -0
  15. package/lib/commands/client/delete.js +18 -6
  16. package/lib/commands/client/setup.js +7 -0
  17. package/lib/commands/deploy/index.js +3 -3
  18. package/lib/commands/deploy/slate.js +65 -4
  19. package/lib/commands/functions/add.js +7 -0
  20. package/lib/commands/functions/delete.js +22 -4
  21. package/lib/commands/functions/execute.js +39 -71
  22. package/lib/commands/functions/setup.js +13 -0
  23. package/lib/commands/functions/shell.js +15 -1
  24. package/lib/commands/iac/import.js +2 -2
  25. package/lib/commands/init.js +34 -20
  26. package/lib/commands/login.js +1 -0
  27. package/lib/commands/pull.js +22 -1
  28. package/lib/commands/serve.js +2 -1
  29. package/lib/commands/slate/create.js +7 -4
  30. package/lib/commands/slate/link.js +11 -5
  31. package/lib/commands/slate/unlink.js +7 -0
  32. package/lib/commands/zest/generate/index.js +28 -35
  33. package/lib/deploy/features/slate.d.ts +3 -1
  34. package/lib/deploy/features/slate.js +204 -5
  35. package/lib/docs/client-utils.toml +0 -5
  36. package/lib/docs/command_needs/rc.toml +9 -1
  37. package/lib/docs/commands/client/delete.toml +4 -0
  38. package/lib/docs/commands/deploy/slate.toml +3 -0
  39. package/lib/docs/commands/functions/delete.toml +10 -0
  40. package/lib/docs/commands/functions/execute.toml +1 -16
  41. package/lib/docs/commands/functions/setup.toml +3 -0
  42. package/lib/docs/commands/functions/shell.toml +8 -0
  43. package/lib/docs/commands/init.toml +3 -0
  44. package/lib/docs/commands/pull.toml +6 -0
  45. package/lib/docs/commands/slate/unlink.toml +6 -0
  46. package/lib/docs/execute/command-utils.toml +14 -0
  47. package/lib/docs/execute/execute-input-resolver.toml +37 -0
  48. package/lib/docs/init/features/project.toml +20 -0
  49. package/lib/docs/init/util/client.toml +4 -0
  50. package/lib/docs/prompt/index.toml +15 -0
  51. package/lib/docs/pull/features/apig.toml +6 -0
  52. package/lib/docs/pull/features/client.toml +20 -0
  53. package/lib/docs/pull/features/functions/index.toml +24 -0
  54. package/lib/endpoints/lib/slate.d.ts +14 -1
  55. package/lib/endpoints/lib/slate.js +35 -0
  56. package/lib/error/context-help.js +1 -1
  57. package/lib/error/index.js +9 -13
  58. package/lib/execute/command-utils.d.ts +5 -0
  59. package/lib/execute/command-utils.js +86 -0
  60. package/lib/execute/execute-input-resolver.d.ts +29 -0
  61. package/lib/execute/execute-input-resolver.js +207 -0
  62. package/lib/execute/index.d.ts +4 -1
  63. package/lib/execute/index.js +3 -2
  64. package/lib/fn-utils/lib/integ.js +22 -17
  65. package/lib/index.js +1 -0
  66. package/lib/init/dependencies/package-json.js +11 -7
  67. package/lib/init/features/appsail/index.js +75 -26
  68. package/lib/init/features/appsail/prompt-fields.d.ts +43 -0
  69. package/lib/init/features/appsail/prompt-fields.js +55 -0
  70. package/lib/init/features/appsail/utils/custom-runtime.d.ts +3 -0
  71. package/lib/init/features/appsail/utils/custom-runtime.js +161 -0
  72. package/lib/init/features/appsail/{utils.d.ts → utils/index.d.ts} +2 -2
  73. package/lib/init/features/appsail/utils/index.js +170 -0
  74. package/lib/init/features/client/index.js +4 -3
  75. package/lib/init/features/client/initializers/angular.js +3 -2
  76. package/lib/init/features/client/initializers/react.js +4 -3
  77. package/lib/init/features/client/prompt-fields.d.ts +37 -0
  78. package/lib/init/features/client/prompt-fields.js +48 -0
  79. package/lib/init/features/functions/index.js +37 -8
  80. package/lib/init/features/functions/languages/java.js +42 -7
  81. package/lib/init/features/functions/languages/node.js +42 -10
  82. package/lib/init/features/functions/languages/python.js +42 -7
  83. package/lib/init/features/functions/prompt-fields.d.ts +25 -0
  84. package/lib/init/features/functions/prompt-fields.js +34 -0
  85. package/lib/init/features/project.js +41 -6
  86. package/lib/init/features/slate/index.js +2 -0
  87. package/lib/init/features/slate/prompt-fields.d.ts +31 -0
  88. package/lib/init/features/slate/prompt-fields.js +41 -0
  89. package/lib/init/index.js +2 -1
  90. package/lib/init/util/client.js +11 -8
  91. package/lib/init/util/common.d.ts +2 -0
  92. package/lib/init/util/common.js +33 -3
  93. package/lib/init/util/prompt-fields.d.ts +7 -0
  94. package/lib/init/util/prompt-fields.js +13 -0
  95. package/lib/internal/command.d.ts +3 -0
  96. package/lib/internal/command.js +26 -3
  97. package/lib/migration/global/1.27.0.d.ts +2 -0
  98. package/lib/migration/global/1.27.0.js +39 -0
  99. package/lib/prompt/choice.d.ts +2 -0
  100. package/lib/prompt/choice.js +24 -0
  101. package/lib/prompt/cli-option-key.d.ts +1 -0
  102. package/lib/prompt/cli-option-key.js +10 -0
  103. package/lib/prompt/index.d.ts +6 -22
  104. package/lib/prompt/index.js +264 -67
  105. package/lib/prompt/overwrite-prompt.d.ts +11 -0
  106. package/lib/prompt/overwrite-prompt.js +16 -0
  107. package/lib/prompt/question-factory.d.ts +34 -0
  108. package/lib/prompt/question-factory.js +41 -0
  109. package/lib/prompt/register-fields.d.ts +24 -0
  110. package/lib/prompt/register-fields.js +37 -0
  111. package/lib/pull/features/apig.js +57 -6
  112. package/lib/pull/features/client.js +107 -24
  113. package/lib/pull/features/functions/index.js +100 -4
  114. package/lib/pull/index.js +1 -1
  115. package/lib/pull/utils.d.ts +13 -0
  116. package/lib/pull/utils.js +20 -0
  117. package/lib/repl-server.d.ts +4 -0
  118. package/lib/repl-server.js +9 -0
  119. package/lib/serve/server/lib/master/index.js +3 -3
  120. package/lib/serve/server/lib/slate/static-server.js +2 -2
  121. package/lib/serve/server/lib/web_client/server.js +2 -2
  122. package/lib/shell/format-functions.d.ts +4 -0
  123. package/lib/shell/format-functions.js +59 -0
  124. package/lib/shell/index.js +18 -0
  125. package/lib/util_modules/config/lib/appsail.d.ts +3 -2
  126. package/lib/util_modules/config/lib/appsail.js +6 -3
  127. package/lib/util_modules/config/lib/slate.d.ts +19 -0
  128. package/lib/util_modules/config-store.d.ts +1 -0
  129. package/lib/util_modules/config-store.js +29 -10
  130. package/lib/util_modules/constants/index.d.ts +0 -1
  131. package/lib/util_modules/constants/index.js +1 -3
  132. package/lib/util_modules/constants/lib/urls.d.ts +2 -0
  133. package/lib/util_modules/constants/lib/urls.js +4 -0
  134. package/lib/util_modules/dc.d.ts +6 -1
  135. package/lib/util_modules/dc.js +21 -8
  136. package/lib/util_modules/env.d.ts +3 -0
  137. package/lib/util_modules/env.js +41 -0
  138. package/lib/util_modules/fs/lib/sync.d.ts +1 -0
  139. package/lib/util_modules/fs/lib/sync.js +19 -0
  140. package/lib/util_modules/logger/utils.d.ts +1 -0
  141. package/lib/util_modules/logger/utils.js +5 -1
  142. package/lib/util_modules/option.d.ts +1 -0
  143. package/lib/util_modules/option.js +8 -0
  144. package/lib/util_modules/{server.js → server/index.js} +3 -3
  145. package/lib/util_modules/server/needed-scopes.d.ts +1 -0
  146. package/lib/util_modules/{constants/lib → server}/needed-scopes.js +7 -7
  147. package/package.json +3 -2
  148. package/lib/init/features/appsail/utils.js +0 -273
  149. package/lib/util_modules/constants/lib/needed-scopes.d.ts +0 -4
  150. /package/lib/docs/{dc.toml → util_modules/dc.toml} +0 -0
  151. /package/lib/util_modules/{server.d.ts → server/index.d.ts} +0 -0
@@ -4,46 +4,63 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const conf_1 = __importDefault(require("conf"));
7
+ const fs_1 = require("fs");
7
8
  const path_1 = require("path");
8
9
  const error_1 = __importDefault(require("../error"));
9
10
  const path = process.env['X_ZC_CREDENTIAL_PATH'];
11
+ const CONFIG_FILE_MODE = 0o600;
12
+ const CLI_CONFIG_NAME = 'zcatalyst-cli-v1';
10
13
  class Store {
11
14
  static changeStore(store, path) {
12
15
  switch (store) {
13
16
  case 'cli': {
14
17
  Store._store = new conf_1.default({
15
- configName: 'zcatalyst-cli',
18
+ configName: CLI_CONFIG_NAME,
16
19
  projectName: 'zcatalyst-cli',
17
- cwd: path
20
+ cwd: path,
21
+ configFileMode: CONFIG_FILE_MODE
18
22
  });
19
- return;
23
+ break;
20
24
  }
21
25
  case 'vscode': {
22
26
  Store._store = new conf_1.default({
23
27
  configName: 'auth',
24
28
  projectName: 'zcatalyst-vscode',
25
- cwd: path ? (0, path_1.join)(path, 'zcatalyst-vscode') : undefined
29
+ cwd: path ? (0, path_1.join)(path, 'zcatalyst-vscode') : undefined,
30
+ configFileMode: CONFIG_FILE_MODE
26
31
  });
27
- return;
32
+ break;
28
33
  }
29
34
  case 'zcode': {
30
35
  Store._store = new conf_1.default({
31
36
  configName: 'auth',
32
37
  projectName: 'zcatalyst-zcode',
33
- cwd: path ? (0, path_1.join)(path, 'zcatalyst-code') : undefined
38
+ cwd: path ? (0, path_1.join)(path, 'zcatalyst-code') : undefined,
39
+ configFileMode: CONFIG_FILE_MODE
34
40
  });
35
- return;
41
+ break;
36
42
  }
37
43
  default: {
38
44
  throw new error_1.default('Invalid Store type: ' + store, { exit: 2 });
39
45
  }
40
46
  }
47
+ Store._lockDownPermissions();
48
+ }
49
+ static _lockDownPermissions() {
50
+ try {
51
+ const filePath = Store._store.path;
52
+ if ((0, fs_1.existsSync)(filePath)) {
53
+ (0, fs_1.chmodSync)(filePath, CONFIG_FILE_MODE);
54
+ }
55
+ }
56
+ catch (err) {
57
+ }
41
58
  }
42
59
  static get istore() {
43
60
  return Store._store;
44
61
  }
45
62
  static get path() {
46
- return (0, path_1.join)(this._store.path, '../../');
63
+ return (0, path_1.dirname)(this._store.path);
47
64
  }
48
65
  static get store() {
49
66
  return Store.istore.store;
@@ -65,8 +82,10 @@ class Store {
65
82
  }
66
83
  }
67
84
  Store._store = new conf_1.default({
68
- configName: 'zcatalyst-cli',
85
+ configName: CLI_CONFIG_NAME,
69
86
  projectName: 'zcatalyst-cli',
70
- cwd: path
87
+ cwd: path,
88
+ configFileMode: CONFIG_FILE_MODE
71
89
  });
72
90
  exports.default = Store;
91
+ Store._lockDownPermissions();
@@ -18,7 +18,6 @@ export { default as PLUGIN } from './lib/plugin';
18
18
  export { default as IAC } from './lib/iac';
19
19
  export { default as RUNTIME } from './lib/runtime';
20
20
  export { default as ENVPATH } from './lib/env-path';
21
- export { default as NEEDED_SCOPES } from './lib/needed-scopes';
22
21
  export { default as SIGNALS_PUBLISHERS_TYPE } from './lib/signals-publishers-type';
23
22
  export { default as SIGNALS_PUBLISHERS } from './lib/signals-publishers';
24
23
  export { default as SIGNALS_API_NAMES } from './lib/signals-api-names';
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SIGNALS_API_NAMES = exports.SIGNALS_PUBLISHERS = exports.SIGNALS_PUBLISHERS_TYPE = exports.NEEDED_SCOPES = exports.ENVPATH = exports.RUNTIME = exports.IAC = exports.PLUGIN = exports.ORIGIN = exports.TEMPLATE = exports.REMOTE_REF = exports.REGEX = exports.REFERENCE = exports.PLACEHOLDER = exports.INTEG = exports.FOLDERNAME = exports.FN_TYPE = exports.DC_TYPE = exports.FILENAME = exports.EVENT_SOURCE = exports.EVENT_REF = exports.DEFAULT = exports.CLIQ = exports.APIG_RULES = void 0;
6
+ exports.SIGNALS_API_NAMES = exports.SIGNALS_PUBLISHERS = exports.SIGNALS_PUBLISHERS_TYPE = exports.ENVPATH = exports.RUNTIME = exports.IAC = exports.PLUGIN = exports.ORIGIN = exports.TEMPLATE = exports.REMOTE_REF = exports.REGEX = exports.REFERENCE = exports.PLACEHOLDER = exports.INTEG = exports.FOLDERNAME = exports.FN_TYPE = exports.DC_TYPE = exports.FILENAME = exports.EVENT_SOURCE = exports.EVENT_REF = exports.DEFAULT = exports.CLIQ = exports.APIG_RULES = void 0;
7
7
  var apig_rules_1 = require("./lib/apig-rules");
8
8
  Object.defineProperty(exports, "APIG_RULES", { enumerable: true, get: function () { return __importDefault(apig_rules_1).default; } });
9
9
  var cliq_handlers_1 = require("./lib/cliq-handlers");
@@ -44,8 +44,6 @@ var runtime_1 = require("./lib/runtime");
44
44
  Object.defineProperty(exports, "RUNTIME", { enumerable: true, get: function () { return __importDefault(runtime_1).default; } });
45
45
  var env_path_1 = require("./lib/env-path");
46
46
  Object.defineProperty(exports, "ENVPATH", { enumerable: true, get: function () { return __importDefault(env_path_1).default; } });
47
- var needed_scopes_1 = require("./lib/needed-scopes");
48
- Object.defineProperty(exports, "NEEDED_SCOPES", { enumerable: true, get: function () { return __importDefault(needed_scopes_1).default; } });
49
47
  var signals_publishers_type_1 = require("./lib/signals-publishers-type");
50
48
  Object.defineProperty(exports, "SIGNALS_PUBLISHERS_TYPE", { enumerable: true, get: function () { return __importDefault(signals_publishers_type_1).default; } });
51
49
  var signals_publishers_1 = require("./lib/signals-publishers");
@@ -9,6 +9,7 @@ export default class URL {
9
9
  private static readonly _stratusSuffixBase;
10
10
  private static readonly _zohoCDNBase;
11
11
  private static readonly _contacts;
12
+ private static readonly _zgraphql;
12
13
  static get zohoCDNUS(): string;
13
14
  static get zohoCDN(): string;
14
15
  static get auth(): string;
@@ -18,6 +19,7 @@ export default class URL {
18
19
  static get appSailDomain(): string;
19
20
  static get catalystStatic(): string;
20
21
  static get console(): string;
22
+ static get zgraphql(): string;
21
23
  static get contacts(): string;
22
24
  static get stratusSuffix(): string;
23
25
  static external: Readonly<{
@@ -34,6 +34,9 @@ class URL {
34
34
  static get console() {
35
35
  return (0, env_js_1.envOverride)('CATALYST_CONSOLE_URL', mapDataCenterUrl(URL._consoleBase));
36
36
  }
37
+ static get zgraphql() {
38
+ return (0, env_js_1.envOverride)('CATALYST_ZGRAPHQL_URL', mapDataCenterUrl(URL._zgraphql));
39
+ }
37
40
  static get contacts() {
38
41
  return (0, env_js_1.envOverride)('ZOHO_CONTACTS', mapDataCenterUrl(URL._contacts));
39
42
  }
@@ -51,6 +54,7 @@ URL._consoleBase = 'https://console.catalyst.zoho.com';
51
54
  URL._stratusSuffixBase = '.zohostratus.com';
52
55
  URL._zohoCDNBase = 'https://static.zohocdn.com';
53
56
  URL._contacts = 'https://profile.zoho.com';
57
+ URL._zgraphql = 'https://zgraphql.zoho.com';
54
58
  URL.external = Object.freeze({
55
59
  gitHubAPI: 'https://api.github.com',
56
60
  gitHubWeb: 'https://github.com'
@@ -1,4 +1,9 @@
1
- export declare function getActiveDC(dcOption?: string): string;
1
+ export declare function getActiveDC(): string;
2
+ export declare function getActiveDC(dcOption: string): string;
3
+ export declare function getActiveDC(opts?: {
4
+ dcOption?: string;
5
+ throwError?: boolean;
6
+ }): string | undefined;
2
7
  export declare function getActiveDCType(): {
3
8
  loc: string;
4
9
  value: string;
@@ -7,11 +7,20 @@ exports.getActiveDC = getActiveDC;
7
7
  exports.getActiveDCType = getActiveDCType;
8
8
  exports.updateActiveDC = updateActiveDC;
9
9
  const ansi_colors_1 = require("ansi-colors");
10
- const path_1 = require("path");
11
10
  const config_store_js_1 = __importDefault(require("./config-store.js"));
12
11
  const index_js_1 = __importDefault(require("../error/index.js"));
13
12
  const dc_type_js_1 = __importDefault(require("./constants/lib/dc-type.js"));
14
- function getActiveDC(dcOption) {
13
+ function getActiveDC(opts) {
14
+ switch (typeof opts) {
15
+ case 'string':
16
+ return _getActiveDC({ dcOption: opts, throwError: true });
17
+ case 'object':
18
+ return _getActiveDC(opts);
19
+ default:
20
+ return _getActiveDC();
21
+ }
22
+ }
23
+ function _getActiveDC({ dcOption, throwError = true } = {}) {
15
24
  const envname = 'CATALYST_ACTIVE_DC';
16
25
  if (process.env[envname] !== undefined) {
17
26
  return process.env[envname];
@@ -26,12 +35,16 @@ function getActiveDC(dcOption) {
26
35
  if (typeof dcOption === 'string') {
27
36
  const availableDcs = Object.keys(dc_type_js_1.default);
28
37
  if (!availableDcs.includes(dcOption)) {
29
- throw new index_js_1.default('Provide DC in global option is not valid: ' + dcOption, {
30
- exit: 1,
31
- errorId: 'DC-1',
32
- arg: [ansi_colors_1.bold.red(dcOption), (0, ansi_colors_1.bold)(availableDcs.map((dc) => '* ' + dc).join('\n'))],
33
- docPath: (0, path_1.join)(__dirname, './docs/dc.toml')
34
- });
38
+ if (throwError) {
39
+ throw new index_js_1.default('Provide DC in global option is not valid: ' + dcOption, {
40
+ exit: 1,
41
+ errorId: 'DC-1',
42
+ arg: [ansi_colors_1.bold.red(dcOption), (0, ansi_colors_1.bold)(availableDcs.map((dc) => '* ' + dc).join('\n'))]
43
+ });
44
+ }
45
+ else {
46
+ return;
47
+ }
35
48
  }
36
49
  return dc_type_js_1.default[dcOption].value;
37
50
  }
@@ -4,7 +4,10 @@ export declare const isWindows: boolean;
4
4
  export declare const isVsCode: boolean;
5
5
  export declare const isZCode: boolean;
6
6
  export declare const isExtension: boolean;
7
+ export declare function isCLIBin(): boolean;
7
8
  export declare function isPrimaryShell(): boolean;
8
9
  export declare function envOverride(envname: string, value: string): string;
9
10
  export declare function getEnvVariable(variable: string, fallback?: unknown): unknown;
10
11
  export declare const getLocalAccessDomain: (port: number, protocol?: "http" | "ws") => string;
12
+ export declare function isNonInteractiveMode(): boolean;
13
+ export declare function getNonInteractiveModeSource(): 'env' | 'option' | undefined;
@@ -34,9 +34,15 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.getLocalAccessDomain = exports.isExtension = exports.isZCode = exports.isVsCode = exports.isWindows = exports.isMac = exports.isCI = void 0;
37
+ exports.isCLIBin = isCLIBin;
37
38
  exports.isPrimaryShell = isPrimaryShell;
38
39
  exports.envOverride = envOverride;
39
40
  exports.getEnvVariable = getEnvVariable;
41
+ exports.isNonInteractiveMode = isNonInteractiveMode;
42
+ exports.getNonInteractiveModeSource = getNonInteractiveModeSource;
43
+ const fs_1 = require("fs");
44
+ const path_1 = require("path");
45
+ const option_1 = require("./option");
40
46
  exports.isCI = process &&
41
47
  !!(process.env.CI ||
42
48
  process.env.CONTINUOUS_INTEGRATION ||
@@ -51,6 +57,23 @@ exports.isWindows = process &&
51
57
  exports.isVsCode = process.env.ZCATALYST_VSCODE === 'true';
52
58
  exports.isZCode = process.env.ZCODE === 'true';
53
59
  exports.isExtension = exports.isVsCode || exports.isZCode;
60
+ function isCLIBin() {
61
+ var _a;
62
+ if (!((_a = require.main) === null || _a === void 0 ? void 0 : _a.filename)) {
63
+ return false;
64
+ }
65
+ const resolveComparablePath = (filePath) => {
66
+ try {
67
+ return (0, fs_1.realpathSync)(filePath);
68
+ }
69
+ catch (_a) {
70
+ return (0, path_1.resolve)(filePath);
71
+ }
72
+ };
73
+ const mainPath = resolveComparablePath(require.main.filename);
74
+ const cliBinPath = resolveComparablePath((0, path_1.resolve)(__dirname, '../bin/catalyst.js'));
75
+ return mainPath === cliBinPath;
76
+ }
54
77
  function isPrimaryShell() {
55
78
  if (!process || process.env.CATALYST_SUB_PROCESS) {
56
79
  return false;
@@ -95,3 +118,21 @@ const getLocalAccessDomain = (port, protocol = 'http') => {
95
118
  return protocol === 'http' ? `http://localhost:${port}` : `ws://localhost:${port}`;
96
119
  };
97
120
  exports.getLocalAccessDomain = getLocalAccessDomain;
121
+ function isNonInteractiveMode() {
122
+ return getNonInteractiveModeSource() !== undefined;
123
+ }
124
+ function getNonInteractiveModeSource() {
125
+ const env = process.env.ZCATALYST_NON_INTERACTIVE;
126
+ if (env === '1' || env === 'true' || env === 'yes') {
127
+ return 'env';
128
+ }
129
+ const flag = (0, option_1.getGlobalOptionValue)('nonInteractive', false);
130
+ if (flag === true || flag === 'true') {
131
+ return 'option';
132
+ }
133
+ const _globalFlag = process.argv.includes('--non-interactive') || process.argv.includes('-ni');
134
+ if (_globalFlag) {
135
+ return 'option';
136
+ }
137
+ return undefined;
138
+ }
@@ -34,4 +34,5 @@ export declare function readJSONFile(pth: string, opts?: fs.ReadOptions & {
34
34
  }): Record<string, any> | undefined;
35
35
  export declare function writeJSONFile(pth: string, object: Record<string, unknown>, opts?: fs.WriteOptions): void;
36
36
  export declare function readPackageJson(): Record<string, unknown> | undefined;
37
+ export declare function getStdinType(): 'tty' | 'pipe' | 'file' | 'other';
37
38
  export declare function isDirEmpty(pth: string): boolean;
@@ -32,6 +32,7 @@ exports.emptyDir = emptyDir;
32
32
  exports.readJSONFile = readJSONFile;
33
33
  exports.writeJSONFile = writeJSONFile;
34
34
  exports.readPackageJson = readPackageJson;
35
+ exports.getStdinType = getStdinType;
35
36
  exports.isDirEmpty = isDirEmpty;
36
37
  const fs_extra_1 = __importDefault(require("fs-extra"));
37
38
  const os_1 = __importDefault(require("os"));
@@ -199,6 +200,24 @@ function readPackageJson() {
199
200
  });
200
201
  return pkg;
201
202
  }
203
+ function getStdinType() {
204
+ if (process.stdin.isTTY) {
205
+ return 'tty';
206
+ }
207
+ try {
208
+ const stdinStat = fs_extra_1.default.fstatSync(process.stdin.fd);
209
+ if (stdinStat.isFIFO()) {
210
+ return 'pipe';
211
+ }
212
+ if (stdinStat.isFile()) {
213
+ return 'file';
214
+ }
215
+ return 'other';
216
+ }
217
+ catch (error) {
218
+ return 'other';
219
+ }
220
+ }
202
221
  function isDirEmpty(pth) {
203
222
  const files = fs_extra_1.default.readdirSync(pth);
204
223
  return files.length === 0;
@@ -6,6 +6,7 @@ export declare const CHAR: {
6
6
  info: string;
7
7
  error: string;
8
8
  };
9
+ export declare function shellCommand(cmd: string): string;
9
10
  export declare class TTYPassThrough extends PassThrough {
10
11
  columns: number;
11
12
  rows: number;
@@ -7,10 +7,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
7
7
  var _a, _LogStreamFactory_logStream;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.LogStreamFactory = exports.TTYPassThrough = exports.CHAR = void 0;
10
+ exports.shellCommand = shellCommand;
10
11
  const ansi_colors_1 = require("ansi-colors");
11
- const env_js_1 = require("../env.js");
12
12
  const readline_1 = require("readline");
13
13
  const stream_1 = require("stream");
14
+ const env_js_1 = require("../env.js");
14
15
  const option_1 = require("../option");
15
16
  const isSupported = !env_js_1.isWindows || process.env.CI || process.env.TERM === 'xterm-256color';
16
17
  exports.CHAR = {
@@ -19,6 +20,9 @@ exports.CHAR = {
19
20
  info: isSupported ? ansi_colors_1.bold.cyan('ℹ') : ansi_colors_1.bold.cyan('i'),
20
21
  error: isSupported ? ansi_colors_1.bold.red('✖') : ansi_colors_1.bold.red('×')
21
22
  };
23
+ function shellCommand(cmd) {
24
+ return `${(0, ansi_colors_1.dim)('>')} ${(0, ansi_colors_1.italic)(cmd)} `;
25
+ }
22
26
  class TTYPassThrough extends stream_1.PassThrough {
23
27
  constructor() {
24
28
  super(...arguments);
@@ -3,3 +3,4 @@ export declare function getOptionValue<T = string | boolean>(key: string, fallba
3
3
  export declare function setGlobalOption(key: string, value: unknown): void;
4
4
  export declare function getGlobalOptionValue<T>(key: string, fallback?: T): T | string;
5
5
  export declare function getUnknownOpts<T>(fallback?: T): T | Array<string>;
6
+ export declare function unsetOption(optKey: string): void;
@@ -8,6 +8,7 @@ exports.getOptionValue = getOptionValue;
8
8
  exports.setGlobalOption = setGlobalOption;
9
9
  exports.getGlobalOptionValue = getGlobalOptionValue;
10
10
  exports.getUnknownOpts = getUnknownOpts;
11
+ exports.unsetOption = unsetOption;
11
12
  const runtime_store_1 = __importDefault(require("../runtime-store"));
12
13
  function getCurrentCommand(fallback) {
13
14
  return runtime_store_1.default.get('context.opts._name', fallback);
@@ -24,3 +25,10 @@ function getGlobalOptionValue(key, fallback) {
24
25
  function getUnknownOpts(fallback) {
25
26
  return runtime_store_1.default.get('context.opts.unknownOpts', fallback);
26
27
  }
28
+ function unsetOption(optKey) {
29
+ const opts = runtime_store_1.default.get('context.opts', {});
30
+ if (opts[optKey] !== undefined) {
31
+ delete opts[optKey];
32
+ runtime_store_1.default.set('context.opts', opts);
33
+ }
34
+ }
@@ -51,10 +51,10 @@ exports.getHostIP = getHostIP;
51
51
  exports.isPortListening = isPortListening;
52
52
  const http_proxy_1 = __importDefault(require("http-proxy"));
53
53
  const net_1 = require("net");
54
- const env_1 = require("./env");
55
54
  const child_process_1 = require("child_process");
56
- const logger_1 = require("./logger");
57
- const error_1 = __importDefault(require("../error"));
55
+ const env_1 = require("../env");
56
+ const logger_1 = require("../logger");
57
+ const error_1 = __importDefault(require("../../error"));
58
58
  class ConnectionDestroyer {
59
59
  constructor(server) {
60
60
  this.server = server;
@@ -0,0 +1 @@
1
+ export declare const SERVE_SCOPES: ("ZohoCatalyst.apigateway.apis.READ" | "ZohoCatalyst.apigateway.READ" | "ZohoCatalyst.segments.ALL" | "ZohoCatalyst.cache.READ" | "ZohoCatalyst.cache.CREATE" | "ZohoCatalyst.cache.DELETE" | "ZohoCatalyst.projects.ALL" | "ZohoCatalyst.cron.ALL" | "ZohoCatalyst.zcql.CREATE" | "ZohoCatalyst.projects.users.READ" | "ZohoCatalyst.projects.users.CREATE" | "ZohoCatalyst.projects.users.DELETE" | "ZohoCatalyst.projects.users.UPDATE" | "ZohoCatalyst.authentication.CREATE" | "ZohoCatalyst.email.CREATE" | "ZohoCatalyst.tables.ALL" | "ZohoCatalyst.tables.rows.ALL" | "ZohoCatalyst.tables.columns.ALL" | "ZohoCatalyst.tables.bulk.READ" | "ZohoCatalyst.tables.bulk.CREATE" | "ZohoCatalyst.nosql.READ" | "ZohoCatalyst.nosql.rows.ALL" | "ZohoCatalyst.folders.ALL" | "ZohoCatalyst.files.CREATE" | "ZohoCatalyst.files.READ" | "ZohoCatalyst.files.DELETE" | "ZohoCatalyst.functions.ALL" | "ZohoCatalyst.functions.EXECUTE" | "ZohoCatalyst.eventlistners.ALL" | "ZohoCatalyst.eventlisteners.produce" | "ZohoCatalyst.security.rules.Read" | "ZohoCatalyst.security.rules.Update" | "ZohoCatalyst.notifications.mobile" | "ZohoCatalyst.notifications.web" | "ZohoCatalyst.search.READ" | "ZohoCatalyst.mlkit.READ" | "QuickML.deployment.READ" | "ZohoCatalyst.pdfshot.execute" | "ZohoCatalyst.dataverse.execute" | "ZohoCatalyst.grid.READ" | "ZohoCatalyst.grid.terminate" | "ZohoCatalyst.circuits.execute" | "ZohoCatalyst.circuits.execution.READ" | "ZohoCatalyst.circuits.execution.DELETE" | "ZohoCatalyst.appsail.Read" | "ZohoCatalyst.jobpool.READ" | "ZohoCatalyst.job.ALL")[];
@@ -4,9 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const scopes_1 = __importDefault(require("../../../authentication/constants/scopes"));
8
- const login_1 = require("../../../authentication/login");
9
- const dc_1 = require("../../dc");
7
+ exports.SERVE_SCOPES = void 0;
8
+ const scopes_1 = __importDefault(require("../../authentication/constants/scopes"));
9
+ const login_1 = require("../../authentication/login");
10
+ const dc_1 = require("../dc");
10
11
  const serveScopes = [
11
12
  scopes_1.default.api_read,
12
13
  scopes_1.default.apig_read,
@@ -56,7 +57,6 @@ const serveScopes = [
56
57
  scopes_1.default.nosql_table,
57
58
  scopes_1.default.nosql_rows
58
59
  ];
59
- const _missingScope = ((_a = login_1.missingScopes[(0, dc_1.getActiveDC)()]) === null || _a === void 0 ? void 0 : _a.map((dvScope) => scopes_1.default[dvScope])) || [];
60
- exports.default = Object.freeze({
61
- SERVE: serveScopes.filter((scope) => !_missingScope.includes(scope))
62
- });
60
+ const dc = (0, dc_1.getActiveDC)({ throwError: false });
61
+ const _missingScope = (dc && ((_a = login_1.missingScopes[dc]) === null || _a === void 0 ? void 0 : _a.map((dvScope) => scopes_1.default[dvScope]))) || [];
62
+ exports.SERVE_SCOPES = serveScopes.filter((scope) => !_missingScope.includes(scope));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.26.2",
3
+ "version": "1.27.0",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -97,11 +97,12 @@
97
97
  "build:watch": "gulp watch",
98
98
  "clean": "gulp cleanup",
99
99
  "test:unit": "jest --config jest.config.js",
100
+ "test:integration": "npm run build && jest --config jest.config.js --testPathPattern=test/integration --no-coverage",
100
101
  "lint:nofix": "eslint --ext .ts src/ --color",
101
102
  "lint:src": "eslint --ext .ts src/ --fix --color",
102
103
  "lint:unit": "eslint --ext .js,.ts test/ --fix --color",
103
104
  "lint": "run-p lint:src lint:unit",
104
- "test": "run-s lint:unit test:unit",
105
+ "test": "run-s lint:unit test:unit test:integration",
105
106
  "prepare": "npm run build",
106
107
  "prepublishOnly": "npm test && npm run lint",
107
108
  "preversion": "npm run lint",