zcatalyst-cli 1.9.0 → 1.11.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.
- package/README.md +29 -29
- package/docs/client-utils.toml +5 -0
- package/docs/command_needs/auth.toml +5 -0
- package/docs/commands/iac/export.toml +4 -0
- package/docs/commands/iac/import.toml +4 -0
- package/docs/commands/iac/status.toml +4 -0
- package/docs/commands/project/use.toml +6 -0
- package/docs/iac/status/bundle.toml +4 -0
- package/docs/plugin-loader.toml +4 -0
- package/docs/serve/server/index.toml +4 -0
- package/docs/serve/server/lib/web_client/server.toml +4 -0
- package/lib/api-timer.js +81 -0
- package/lib/apig-utils.js +17 -14
- package/lib/archiver.js +83 -45
- package/lib/authentication/login.js +4 -2
- package/lib/bin/catalyst.js +0 -1
- package/lib/client-utils.js +55 -26
- package/lib/client.js +0 -3
- package/lib/command_needs/auth.js +12 -3
- package/lib/command_needs/rc.js +12 -7
- package/lib/commands/apig/disable.js +1 -1
- package/lib/commands/apig/enable.js +1 -1
- package/lib/commands/apig/status.js +7 -5
- package/lib/commands/client/delete.js +4 -5
- package/lib/commands/client/setup.js +1 -1
- package/lib/commands/deploy.js +4 -2
- package/lib/commands/ds/export.js +4 -2
- package/lib/commands/ds/import.js +4 -2
- package/lib/commands/ds/status.js +146 -150
- package/lib/commands/event/generate/index.js +5 -14
- package/lib/commands/event/generate/integ.js +1 -1
- package/lib/commands/functions/add.js +1 -1
- package/lib/commands/functions/config.js +1 -1
- package/lib/commands/functions/delete.js +1 -1
- package/lib/commands/functions/setup.js +1 -1
- package/lib/commands/functions/shell.js +1 -1
- package/lib/commands/help.js +0 -22
- package/lib/commands/iac/export.js +85 -0
- package/lib/commands/iac/import.js +189 -0
- package/lib/commands/iac/pack.js +129 -0
- package/lib/commands/iac/status.js +63 -0
- package/lib/commands/index.js +4 -0
- package/lib/commands/init.js +35 -28
- package/lib/commands/login.js +1 -1
- package/lib/commands/logout.js +1 -1
- package/lib/commands/project/list.js +11 -7
- package/lib/commands/project/reset.js +1 -1
- package/lib/commands/project/use.js +42 -25
- package/lib/commands/pull.js +2 -2
- package/lib/commands/run.js +1 -1
- package/lib/commands/serve.js +3 -2
- package/lib/commands/token/generate.js +1 -1
- package/lib/commands/token/list.js +1 -1
- package/lib/commands/token/revoke.js +1 -1
- package/lib/commands/whoami.js +1 -1
- package/lib/deploy/features/functions/index.js +2 -1
- package/lib/deploy/index.js +3 -1
- package/lib/endpoints/lib/iac.js +134 -0
- package/lib/error.js +33 -3
- package/lib/errorOut.js +4 -3
- package/lib/fn-utils/lib/common.js +37 -16
- package/lib/fn-utils/lib/java.js +7 -9
- package/lib/fn-utils/lib/node.js +7 -1
- package/lib/iac/status/bundle.js +82 -0
- package/lib/iac/status/deploy.js +74 -0
- package/lib/iac/status/util/index.js +26 -0
- package/lib/index.js +13 -19
- package/lib/init/dependencies/npm-install.js +2 -9
- package/lib/init/features/client/index.js +47 -0
- package/lib/init/features/client/initializers/angular.js +88 -0
- package/lib/init/features/client/initializers/basic.js +27 -0
- package/lib/init/features/client/initializers/lyte.js +44 -0
- package/lib/init/features/client/initializers/react.js +53 -0
- package/lib/init/features/functions/languages/java.js +2 -5
- package/lib/init/features/functions/languages/node.js +5 -6
- package/lib/init/features/index.js +18 -6
- package/lib/init/features/project.js +72 -34
- package/lib/init/util/client.js +12 -0
- package/lib/init/util/functions.js +20 -0
- package/lib/init/util/project.js +35 -0
- package/lib/internal/api.js +6 -9
- package/lib/internal/command.js +6 -3
- package/lib/internal/config.js +7 -4
- package/lib/migration/index.js +10 -6
- package/lib/option-filter.js +4 -1
- package/lib/optional-import.js +11 -25
- package/lib/plugin-loader.js +8 -2
- package/lib/port-resolver.js +20 -16
- package/lib/prompt/index.js +92 -0
- package/lib/prompt/types/file-path.js +95 -0
- package/lib/pull/features/client.js +1 -1
- package/lib/pull/features/functions/index.js +5 -7
- package/lib/pull/index.js +4 -1
- package/lib/serve/features/index.js +3 -1
- package/lib/serve/index.js +6 -1
- package/lib/serve/server/index.js +74 -29
- package/lib/serve/server/lib/master.js +28 -12
- package/lib/serve/server/lib/web_client/index.js +30 -0
- package/lib/serve/server/lib/web_client/server.js +171 -0
- package/lib/serve/server/lib/web_client/utils.js +10 -0
- package/lib/shell/dependencies/http-functions.js +1 -1
- package/lib/shell/index.js +3 -1
- package/lib/track.js +3 -1
- package/lib/util_modules/char.js +1 -1
- package/lib/util_modules/config/lib/apig.js +2 -1
- package/lib/util_modules/constants/index.js +5 -1
- package/lib/util_modules/constants/lib/file-names.js +2 -1
- package/lib/util_modules/constants/lib/iac.js +8 -0
- package/lib/util_modules/constants/lib/placeholders.js +3 -1
- package/lib/util_modules/constants/lib/plugin.js +28 -0
- package/lib/util_modules/constants/lib/regex.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +5 -0
- package/lib/util_modules/constants/lib/template.js +11 -1
- package/lib/util_modules/constants/lib/urls.js +8 -0
- package/lib/util_modules/constants/project.js +6 -0
- package/lib/util_modules/{contextHelp.js → context-help.js} +5 -1
- package/lib/util_modules/env.js +14 -16
- package/lib/util_modules/fs/index.js +9 -1
- package/lib/util_modules/fs/lib/async.js +29 -22
- package/lib/util_modules/global-space.js +99 -0
- package/lib/util_modules/js.js +6 -0
- package/lib/util_modules/option.js +5 -1
- package/lib/util_modules/parser/toml.js +5 -1
- package/lib/util_modules/project.js +3 -0
- package/lib/util_modules/shell.js +9 -8
- package/lib/winston.js +1 -1
- package/package.json +11 -5
- package/templates/iacSuccess.html +391 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
- package/templates/init/client/{index.html → basic/index.html} +0 -0
- package/templates/init/client/{main.css → basic/main.css} +0 -0
- package/templates/init/client/{main.js → basic/main.js} +0 -0
- package/templates/init/client/lyte/build/build.js +301 -0
- package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
- package/templates/init/client/lyte/client-package.json +5 -0
- package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
- package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
- package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
- package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
- package/templates/init/client/lyte/index.html +17 -0
- package/templates/init/client/lyte/package.json +12 -0
- package/templates/init/client/lyte/router.js +14 -0
- package/templates/init/client/lyte/routes/index.js +54 -0
- package/templates/init/client/react/.DS_Store +0 -0
- package/templates/init/client/react/react_js/package.json +11 -0
- package/templates/init/client/react/react_js/template/README.md +70 -0
- package/templates/init/client/react/react_js/template/client-package.json +5 -0
- package/templates/init/client/react/react_js/template/gitignore +23 -0
- package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_js/template/public/index.html +43 -0
- package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_js/template/src/App.css +38 -0
- package/templates/init/client/react/react_js/template/src/App.js +25 -0
- package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
- package/templates/init/client/react/react_js/template/src/index.css +13 -0
- package/templates/init/client/react/react_js/template/src/index.js +17 -0
- package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
- package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
- package/templates/init/client/react/react_js/template.json +13 -0
- package/templates/init/client/react/react_ts/package.json +11 -0
- package/templates/init/client/react/react_ts/template/README.md +46 -0
- package/templates/init/client/react/react_ts/template/client-package.json +5 -0
- package/templates/init/client/react/react_ts/template/gitignore +23 -0
- package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_ts/template/public/index.html +43 -0
- package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_ts/template/src/App.css +38 -0
- package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
- package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
- package/templates/init/client/react/react_ts/template/src/index.css +13 -0
- package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
- package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
- package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
- package/templates/init/client/react/react_ts/template.json +18 -0
- package/templates/web-socket.txt +21 -0
- package/lib/init/features/client.js +0 -51
- package/lib/prompt.js +0 -49
- package/lib/serve/server/lib/client.js +0 -30
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebClientEvent = void 0;
|
|
7
|
+
const events_1 = __importDefault(require("events"));
|
|
8
|
+
class WebClientEvent extends events_1.default {
|
|
9
|
+
}
|
|
10
|
+
exports.WebClientEvent = WebClientEvent;
|
|
@@ -235,7 +235,7 @@ class HttpFunctions {
|
|
|
235
235
|
};
|
|
236
236
|
shell_1.clearLine(process.stdout);
|
|
237
237
|
const masterPort = runtime_store_1.default.get(`context.port.http.master`, -1);
|
|
238
|
-
const fnTargets = runtime_store_1.default.get('context.functions.targets');
|
|
238
|
+
const fnTargets = runtime_store_1.default.get('context.functions.targets', []);
|
|
239
239
|
fnTargets
|
|
240
240
|
.filter((t) => t.url !== undefined && t.type === constants_1.FN_TYPE.basic)
|
|
241
241
|
.map((t) => {
|
package/lib/shell/index.js
CHANGED
|
@@ -46,7 +46,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
46
46
|
const httpServer = new http_functions_1.default(replServer);
|
|
47
47
|
try {
|
|
48
48
|
yield prepare_1.default([constants_1.FN_TYPE.basic, constants_1.FN_TYPE.cron, constants_1.FN_TYPE.event, constants_1.FN_TYPE.integration]);
|
|
49
|
-
const targets = runtime_store_1.default
|
|
49
|
+
const targets = runtime_store_1.default
|
|
50
|
+
.get('context.functions.targets', [])
|
|
51
|
+
.filter((target) => {
|
|
50
52
|
if (!target.valid) {
|
|
51
53
|
logger_1.warning('target [' +
|
|
52
54
|
target.name +
|
package/lib/track.js
CHANGED
|
@@ -16,6 +16,7 @@ const path_1 = require("path");
|
|
|
16
16
|
const readline_1 = require("readline");
|
|
17
17
|
const config_store_1 = __importDefault(require("./config-store"));
|
|
18
18
|
const endpoints_1 = require("./endpoints");
|
|
19
|
+
const error_1 = __importDefault(require("./error"));
|
|
19
20
|
const runtime_store_1 = __importDefault(require("./runtime-store"));
|
|
20
21
|
const fs_1 = require("./util_modules/fs");
|
|
21
22
|
const logger_1 = require("./util_modules/logger");
|
|
@@ -52,7 +53,8 @@ exports.default = (event, message, duration) => __awaiter(void 0, void 0, void 0
|
|
|
52
53
|
yield httpLogger.log(logInput);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
catch (
|
|
56
|
+
catch (e) {
|
|
57
|
+
const err = error_1.default.getErrorInstance(e);
|
|
56
58
|
logger_1.debug('Unable to send debug log to server: ' + err.message);
|
|
57
59
|
}
|
|
58
60
|
});
|
package/lib/util_modules/char.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CHAR = void 0;
|
|
4
4
|
const ansi_colors_1 = require("ansi-colors");
|
|
5
5
|
const env_1 = require("./env");
|
|
6
|
-
const isSupported = !env_1.isWindows
|
|
6
|
+
const isSupported = !env_1.isWindows || process.env.CI || process.env.TERM === 'xterm-256color';
|
|
7
7
|
exports.CHAR = {
|
|
8
8
|
success: isSupported ? ansi_colors_1.bold.green('✔') : ansi_colors_1.bold.green('√'),
|
|
9
9
|
warning: isSupported ? ansi_colors_1.bold.yellow('⚠') : ansi_colors_1.bold.yellow('‼'),
|
|
@@ -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.script = exports.enabled = exports.rules = exports.raw = void 0;
|
|
6
|
+
exports.source = exports.script = exports.enabled = exports.rules = exports.raw = void 0;
|
|
7
7
|
const error_1 = __importDefault(require("../../../error"));
|
|
8
8
|
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
9
9
|
const constants_1 = require("../../constants");
|
|
@@ -43,3 +43,4 @@ function script(name, fallback) {
|
|
|
43
43
|
return (rawScripts && rawScripts[name]) || fallback;
|
|
44
44
|
}
|
|
45
45
|
exports.script = script;
|
|
46
|
+
exports.source = rules;
|
|
@@ -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.ORIGIN = exports.TEMPLATE = exports.SCOPE = 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.AUTH = exports.APIG_RULES = void 0;
|
|
6
|
+
exports.IAC = exports.PLUGIN = exports.ORIGIN = exports.TEMPLATE = exports.SCOPE = 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.AUTH = 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 auth_1 = require("./lib/auth");
|
|
@@ -40,3 +40,7 @@ var template_1 = require("./lib/template");
|
|
|
40
40
|
Object.defineProperty(exports, "TEMPLATE", { enumerable: true, get: function () { return __importDefault(template_1).default; } });
|
|
41
41
|
var urls_1 = require("./lib/urls");
|
|
42
42
|
Object.defineProperty(exports, "ORIGIN", { enumerable: true, get: function () { return __importDefault(urls_1).default; } });
|
|
43
|
+
var plugin_1 = require("./lib/plugin");
|
|
44
|
+
Object.defineProperty(exports, "PLUGIN", { enumerable: true, get: function () { return __importDefault(plugin_1).default; } });
|
|
45
|
+
var iac_1 = require("./lib/iac");
|
|
46
|
+
Object.defineProperty(exports, "IAC", { enumerable: true, get: function () { return __importDefault(iac_1).default; } });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = Object.freeze({
|
|
4
|
+
mangaer: {
|
|
5
|
+
npm: {
|
|
6
|
+
command: 'npm',
|
|
7
|
+
opts: ['config', 'get', 'prefix', '--json']
|
|
8
|
+
},
|
|
9
|
+
yarn: {
|
|
10
|
+
command: 'yarn',
|
|
11
|
+
opts: ['global', 'dir']
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
client: ['Angular', 'React', 'Basic'],
|
|
15
|
+
react: {
|
|
16
|
+
plugin: 'zcatalyst-cli-plugin-react',
|
|
17
|
+
runner_command: ['create-react-app']
|
|
18
|
+
},
|
|
19
|
+
lyte: {
|
|
20
|
+
plugin: 'zcatalyst-cli-plugin-lyte'
|
|
21
|
+
},
|
|
22
|
+
angular: {
|
|
23
|
+
plugin: 'zcatalyst-cli-plugin-angular',
|
|
24
|
+
runner_command: ['ng', 'new'],
|
|
25
|
+
collection_name: 'zcatalyst-angular-schematics',
|
|
26
|
+
runner_package: '@angular/cli@v12-lts'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const functionName = /(?!^\d+$)^(\w|-)+$/g;
|
|
4
4
|
exports.default = Object.freeze({
|
|
5
5
|
project: {
|
|
6
|
-
name: /^[a-zA-Z0-9][a-zA-Z0-9-]*$/g
|
|
6
|
+
name: /^[a-zA-Z0-9][a-zA-Z0-9-]*$/g,
|
|
7
|
+
template: /project-template-\d{1,2}\.\d{1,2}\.\d{1,2}.(yml|json)/g
|
|
7
8
|
},
|
|
8
9
|
client: {
|
|
9
10
|
package_name: /^[a-zA-Z0-9][a-zA-Z0-9-]*$/g
|
|
@@ -15,6 +15,11 @@ exports.default = Object.freeze({
|
|
|
15
15
|
queue_data_read: 'ZohoCatalyst.queue.data.READ',
|
|
16
16
|
queue_data_create: 'ZohoCatalyst.queue.data.CREATE',
|
|
17
17
|
projects: 'ZohoCatalyst.projects.ALL',
|
|
18
|
+
project_export_read: 'ZohoCatalyst.project.export.READ',
|
|
19
|
+
project_export_create: 'ZohoCatalyst.project.export.CREATE',
|
|
20
|
+
project_import_read: 'ZohoCatalyst.project.import.READ',
|
|
21
|
+
project_import_create: 'ZohoCatalyst.project.import.CREATE',
|
|
22
|
+
project_import_delete: 'ZohoCatalyst.project.import.DELETE',
|
|
18
23
|
cron: 'ZohoCatalyst.cron.ALL',
|
|
19
24
|
zcql: 'ZohoCatalyst.zcql.CREATE',
|
|
20
25
|
webapp: 'ZohoCatalyst.webapp.ALL',
|
|
@@ -7,7 +7,17 @@ exports.default = Object.freeze({
|
|
|
7
7
|
banner: path_1.join(TEMPLATE_ROOT, 'banner.txt'),
|
|
8
8
|
login_success: path_1.join(TEMPLATE_ROOT, 'loginSuccess.html'),
|
|
9
9
|
login_fail: path_1.join(TEMPLATE_ROOT, 'loginFailure.html'),
|
|
10
|
-
client:
|
|
10
|
+
client: {
|
|
11
|
+
basic: {
|
|
12
|
+
new: path_1.join(TEMPLATE_ROOT, 'init', 'client', 'basic'),
|
|
13
|
+
socket: path_1.join(TEMPLATE_ROOT, 'web-socket.txt')
|
|
14
|
+
},
|
|
15
|
+
lyte: path_1.join(TEMPLATE_ROOT, 'init', 'client', 'lyte'),
|
|
16
|
+
react: {
|
|
17
|
+
js: path_1.join(TEMPLATE_ROOT, 'init', 'client', 'react', 'react_js'),
|
|
18
|
+
ts: path_1.join(TEMPLATE_ROOT, 'init', 'client', 'react', 'react_ts')
|
|
19
|
+
}
|
|
20
|
+
},
|
|
11
21
|
applogic: {
|
|
12
22
|
node: path_1.join(TEMPLATE_ROOT, 'init', 'applogic', 'node')
|
|
13
23
|
},
|
|
@@ -31,9 +31,17 @@ class URL {
|
|
|
31
31
|
}
|
|
32
32
|
return URL._zoho.replace('.com', dc.ext);
|
|
33
33
|
}
|
|
34
|
+
static get console() {
|
|
35
|
+
const dc = dc_1.getActiveDCType();
|
|
36
|
+
if (dc === undefined) {
|
|
37
|
+
return URL._console;
|
|
38
|
+
}
|
|
39
|
+
return URL._console.replace('.com', dc.ext);
|
|
40
|
+
}
|
|
34
41
|
}
|
|
35
42
|
exports.default = URL;
|
|
36
43
|
URL._auth = env_1.envOverride('CATALYST_AUTH_URL', 'https://accounts.zoho.com');
|
|
37
44
|
URL._admin = env_1.envOverride('CATALYST_ADMIN_URL', 'https://api.catalyst.zoho.com');
|
|
38
45
|
URL._app = env_1.envOverride('CATALYST_APP_URL', 'https://catalystserverless.com');
|
|
39
46
|
URL._zoho = env_1.envOverride('ZOHO_URL', 'https://www.zoho.com');
|
|
47
|
+
URL._console = env_1.envOverride('CATALYST_CONSOLE_URL', 'https://console.catalyst.zoho.com');
|
|
@@ -10,10 +10,11 @@ const fs_1 = require("./fs");
|
|
|
10
10
|
const logger_1 = require("./logger");
|
|
11
11
|
const toml_1 = __importDefault(require("./parser/toml"));
|
|
12
12
|
function help() {
|
|
13
|
+
let exitCode = 0;
|
|
13
14
|
const logs = runtime_store_1.default.get('log');
|
|
14
15
|
if (logs === undefined) {
|
|
15
16
|
logger_1.debug('NO ERRORS REGISTERED');
|
|
16
|
-
return;
|
|
17
|
+
return exitCode;
|
|
17
18
|
}
|
|
18
19
|
const logKeys = Object.keys(logs);
|
|
19
20
|
const fillTemplate = (...arg) => {
|
|
@@ -28,6 +29,7 @@ function help() {
|
|
|
28
29
|
const errQueue = logs[key];
|
|
29
30
|
if (key === 'faultyError') {
|
|
30
31
|
errQueue.forEach((err) => {
|
|
32
|
+
exitCode = err.exit > exitCode ? err.exit : exitCode;
|
|
31
33
|
outputError(err, errQueue);
|
|
32
34
|
return;
|
|
33
35
|
});
|
|
@@ -36,6 +38,7 @@ function help() {
|
|
|
36
38
|
const doc = fs_1.SYNC.readFile(docPath) || '';
|
|
37
39
|
const catHelp = toml_1.default(doc);
|
|
38
40
|
errQueue.forEach((err) => {
|
|
41
|
+
exitCode = err.exit > exitCode ? err.exit : exitCode;
|
|
39
42
|
if (err.errorId === undefined || catHelp === undefined || catHelp === {}) {
|
|
40
43
|
outputError(err, errQueue);
|
|
41
44
|
return;
|
|
@@ -59,6 +62,7 @@ function help() {
|
|
|
59
62
|
errQueue.shift();
|
|
60
63
|
});
|
|
61
64
|
});
|
|
65
|
+
return exitCode;
|
|
62
66
|
}
|
|
63
67
|
exports.default = help;
|
|
64
68
|
function outputError(err, errQueue) {
|
package/lib/util_modules/env.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEnvVariable = exports.envOverride = exports.isPrimaryShell = exports.isWindows = exports.isMac = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
exports.getEnvVariable = exports.envOverride = exports.isPrimaryShell = exports.isWindows = exports.isMac = exports.isCI = void 0;
|
|
4
|
+
exports.isCI = process &&
|
|
5
|
+
!!(process.env.CI ||
|
|
6
|
+
process.env.CONTINUOUS_INTEGRATION ||
|
|
7
|
+
process.env.BUILD_NUMBER ||
|
|
8
|
+
process.env.RUN_ID ||
|
|
9
|
+
exports.name ||
|
|
10
|
+
false);
|
|
11
|
+
exports.isMac = process && process.platform === 'darwin';
|
|
12
|
+
exports.isWindows = process &&
|
|
13
|
+
(process.platform === 'win32' ||
|
|
14
|
+
(process.env.OSTYPE !== undefined && /^(msys|cygwin)$/.test(process.env.OSTYPE)));
|
|
14
15
|
function isPrimaryShell() {
|
|
15
|
-
if (!process) {
|
|
16
|
+
if (!process || process.env.CATALYST_SUB_PROCESS) {
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
|
-
if (process.env.
|
|
19
|
-
return !process.env.CATALYST_SUB_PROCESS;
|
|
20
|
-
}
|
|
21
|
-
if (process.env.SHLVL) {
|
|
19
|
+
if (!exports.isWindows && process.env.SHLVL) {
|
|
22
20
|
return parseInt(process.env.SHLVL) <= 1;
|
|
23
21
|
}
|
|
24
22
|
return false;
|
|
@@ -18,9 +18,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
21
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.ASYNC = exports.SYNC = void 0;
|
|
25
|
+
exports.ASYNC = exports.SYNC = exports.untildify = void 0;
|
|
26
|
+
const os_1 = __importDefault(require("os"));
|
|
23
27
|
const ASYNC = __importStar(require("./lib/async"));
|
|
24
28
|
exports.ASYNC = ASYNC;
|
|
25
29
|
const SYNC = __importStar(require("./lib/sync"));
|
|
26
30
|
exports.SYNC = SYNC;
|
|
31
|
+
const tildRegex = /^~(?=$|\/|\\)/;
|
|
32
|
+
const homeDirectory = os_1.default.homedir();
|
|
33
|
+
const untildify = (pth) => homeDirectory ? pth.replace(tildRegex, homeDirectory) : pth;
|
|
34
|
+
exports.untildify = untildify;
|
|
@@ -17,26 +17,31 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
17
17
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
18
18
|
const os_1 = __importDefault(require("os"));
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const __1 = require("..");
|
|
20
21
|
function dirExists(pth) {
|
|
21
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const stats = yield fs_extra_1.default.stat(pth).catch(() => false);
|
|
23
|
+
const stats = yield fs_extra_1.default.stat(__1.untildify(pth)).catch(() => false);
|
|
23
24
|
return stats && stats.isDirectory();
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
exports.dirExists = dirExists;
|
|
27
28
|
function fileExists(pth) {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const stats = yield fs_extra_1.default.stat(pth).catch(() => false);
|
|
30
|
+
const stats = yield fs_extra_1.default.stat(__1.untildify(pth)).catch(() => false);
|
|
30
31
|
return stats && stats.isFile();
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
exports.fileExists = fileExists;
|
|
34
|
-
function readFile(pth,
|
|
35
|
+
function readFile(pth, type) {
|
|
35
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
if (yield fileExists(pth)) {
|
|
37
|
-
return
|
|
37
|
+
if (!(yield fileExists(pth))) {
|
|
38
|
+
return undefined;
|
|
38
39
|
}
|
|
39
|
-
return
|
|
40
|
+
return (type === 'buffer'
|
|
41
|
+
? fs_extra_1.default.readFile(pth)
|
|
42
|
+
: type
|
|
43
|
+
? fs_extra_1.default.readFile(pth, type)
|
|
44
|
+
: fs_extra_1.default.readFile(pth, 'utf8'));
|
|
40
45
|
});
|
|
41
46
|
}
|
|
42
47
|
exports.readFile = readFile;
|
|
@@ -70,27 +75,29 @@ function dirList(dir) {
|
|
|
70
75
|
});
|
|
71
76
|
}
|
|
72
77
|
exports.dirList = dirList;
|
|
73
|
-
function walk(dir, exclude = []) {
|
|
78
|
+
function walk(dir, { exclude = [], excludeDir = true, depth = -1 } = {}) {
|
|
74
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
if (depth === 0) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
75
83
|
const isDir = yield fs_extra_1.default.stat(dir).then((stat) => stat.isDirectory());
|
|
76
84
|
const files = isDir ? yield fs_extra_1.default.readdir(dir) : [path_1.default.basename(dir)];
|
|
77
|
-
const folderContentPromise = files
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (match) {
|
|
86
|
-
return false;
|
|
85
|
+
const folderContentPromise = files.map((entry) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const entryPath = isDir ? path_1.default.join(dir, entry) : dir;
|
|
87
|
+
const stats = yield fs_extra_1.default.stat(entryPath);
|
|
88
|
+
const isEntryPthDir = stats.isDirectory();
|
|
89
|
+
let excludeMatch = false;
|
|
90
|
+
if (!(isEntryPthDir && !excludeDir)) {
|
|
91
|
+
for (const glob of exclude) {
|
|
92
|
+
excludeMatch = excludeMatch || minimatch_1.default(entryPath, glob);
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
if (excludeMatch) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
return isEntryPthDir
|
|
99
|
+
? walk(entryPath, { exclude, excludeDir, depth: --depth })
|
|
100
|
+
: [entryPath];
|
|
94
101
|
}));
|
|
95
102
|
const folderContents = yield Promise.all(folderContentPromise);
|
|
96
103
|
return folderContents.reduce((all, folderContent) => all.concat(folderContent), []);
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
exports.getYarnNodePth = exports.getNpmNodePth = void 0;
|
|
16
|
+
const shell_js_1 = require("./shell.js");
|
|
17
|
+
const plugin_js_1 = __importDefault(require("./constants/lib/plugin.js"));
|
|
18
|
+
const env_js_1 = require("./env.js");
|
|
19
|
+
const path_1 = require("path");
|
|
20
|
+
const index_js_1 = require("./fs/index.js");
|
|
21
|
+
const runtime_store_js_1 = __importDefault(require("../runtime-store.js"));
|
|
22
|
+
const logger_js_1 = require("./logger.js");
|
|
23
|
+
function getNpmNodePth() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const cachedPath = runtime_store_js_1.default.get('npm.nodePath', false);
|
|
26
|
+
if (cachedPath) {
|
|
27
|
+
return cachedPath;
|
|
28
|
+
}
|
|
29
|
+
const spawnres = yield shell_js_1.spawn(plugin_js_1.default.mangaer.npm.command, plugin_js_1.default.mangaer.npm.opts, {
|
|
30
|
+
stdio: 'pipe'
|
|
31
|
+
}).ASYNC();
|
|
32
|
+
const nodePath = spawnres.stdout.replace(/\n/g, env_js_1.isWindows ? '\\node_modules' : '/lib/node_modules');
|
|
33
|
+
runtime_store_js_1.default.set('npm.nodePath', nodePath);
|
|
34
|
+
return nodePath;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.getNpmNodePth = getNpmNodePth;
|
|
38
|
+
function getYarnNodePth() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const cachedPath = runtime_store_js_1.default.get('yarn.nodePath', false);
|
|
41
|
+
if (cachedPath) {
|
|
42
|
+
return cachedPath;
|
|
43
|
+
}
|
|
44
|
+
const spawnres = yield shell_js_1.spawn(plugin_js_1.default.mangaer.yarn.command, plugin_js_1.default.mangaer.yarn.opts, {
|
|
45
|
+
stdio: 'pipe'
|
|
46
|
+
}).ASYNC();
|
|
47
|
+
const nodePath = spawnres.stdout.replace(/\n/g, path_1.sep + 'node_modules');
|
|
48
|
+
runtime_store_js_1.default.set('yarn.nodePath', nodePath);
|
|
49
|
+
return nodePath;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.getYarnNodePth = getYarnNodePth;
|
|
53
|
+
function findNpmPkg(pkgName, fallback) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
const nodeModulesPath = yield getNpmNodePth().catch((err) => logger_js_1.debug(err));
|
|
57
|
+
const pkgPath = path_1.join(nodeModulesPath, pkgName);
|
|
58
|
+
return (yield index_js_1.ASYNC.dirExists(pkgPath)) ? pkgPath : fallback;
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
logger_js_1.debug('NPM pkg find error');
|
|
62
|
+
logger_js_1.debug(e);
|
|
63
|
+
}
|
|
64
|
+
return fallback;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function findYarnPkg(pkgName, fallback) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
try {
|
|
70
|
+
const nodeModulesPath = yield getYarnNodePth().catch((err) => logger_js_1.debug(err));
|
|
71
|
+
const pkgPath = path_1.join(nodeModulesPath, pkgName);
|
|
72
|
+
return (yield index_js_1.ASYNC.dirExists(pkgPath)) ? pkgPath : fallback;
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
logger_js_1.debug('YARN pkg find error');
|
|
76
|
+
logger_js_1.debug(e);
|
|
77
|
+
}
|
|
78
|
+
return fallback;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function findPkg(pkgName, fallback = false, pkgManager) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
if (pkgManager) {
|
|
84
|
+
return pkgManager === 'npm'
|
|
85
|
+
? findNpmPkg(pkgName, fallback)
|
|
86
|
+
: findYarnPkg(pkgName, fallback);
|
|
87
|
+
}
|
|
88
|
+
const npmPkg = yield findNpmPkg(pkgName, fallback);
|
|
89
|
+
if (npmPkg !== null) {
|
|
90
|
+
return npmPkg;
|
|
91
|
+
}
|
|
92
|
+
const yarnPkg = yield findYarnPkg(pkgName, fallback);
|
|
93
|
+
if (yarnPkg !== null) {
|
|
94
|
+
return yarnPkg;
|
|
95
|
+
}
|
|
96
|
+
return fallback;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
exports.default = findPkg;
|
package/lib/util_modules/js.js
CHANGED
|
@@ -42,5 +42,11 @@ exports.JS = lodash_1.default.mixin({
|
|
|
42
42
|
exports.JS.removeNullAndUndefined(val)) ||
|
|
43
43
|
((val === null || val === undefined) && delete copy[key]));
|
|
44
44
|
return copy;
|
|
45
|
+
},
|
|
46
|
+
parseJSON: (str) => {
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(str);
|
|
49
|
+
}
|
|
50
|
+
catch (e) { }
|
|
45
51
|
}
|
|
46
52
|
});
|
|
@@ -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.getGlobalOptionValue = exports.setGlobalOption = exports.getOptionValue = exports.getCurrentCommand = void 0;
|
|
6
|
+
exports.getUnknownOpts = exports.getGlobalOptionValue = exports.setGlobalOption = exports.getOptionValue = exports.getCurrentCommand = void 0;
|
|
7
7
|
const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
8
8
|
function getCurrentCommand(fallback) {
|
|
9
9
|
return runtime_store_1.default.get('opts._name', fallback);
|
|
@@ -21,3 +21,7 @@ function getGlobalOptionValue(key, fallback) {
|
|
|
21
21
|
return runtime_store_1.default.get('opts.globalOpts.' + key, fallback);
|
|
22
22
|
}
|
|
23
23
|
exports.getGlobalOptionValue = getGlobalOptionValue;
|
|
24
|
+
function getUnknownOpts(fallback) {
|
|
25
|
+
return runtime_store_1.default.get('opts.unknownOpts', fallback);
|
|
26
|
+
}
|
|
27
|
+
exports.getUnknownOpts = getUnknownOpts;
|
|
@@ -10,6 +10,10 @@ exports.default = (str) => {
|
|
|
10
10
|
return toml_1.parse(str);
|
|
11
11
|
}
|
|
12
12
|
catch (e) {
|
|
13
|
-
|
|
13
|
+
const err = error_1.default.getErrorInstance(e, {
|
|
14
|
+
message: 'TOML Parsing error'
|
|
15
|
+
});
|
|
16
|
+
err.exit = 2;
|
|
17
|
+
throw err;
|
|
14
18
|
}
|
|
15
19
|
};
|
|
@@ -49,25 +49,26 @@ function spawn(command, opts, _a = {}) {
|
|
|
49
49
|
stdio,
|
|
50
50
|
shell }, otherOpts));
|
|
51
51
|
return new Promise((res, rej) => {
|
|
52
|
+
var _a;
|
|
52
53
|
let message = '';
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
let stdout = '';
|
|
55
|
+
(_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (msg) => {
|
|
56
|
+
stdout += msg.toString();
|
|
55
57
|
});
|
|
56
58
|
childProcess.on('message', (msg) => {
|
|
57
59
|
message += msg.toString();
|
|
58
|
-
logger_1.debug(msg.toString());
|
|
59
60
|
});
|
|
61
|
+
childProcess.on('error', (err) => rej(err));
|
|
60
62
|
childProcess.on('exit', (code) => {
|
|
61
63
|
if (code !== 0) {
|
|
62
64
|
rej(code);
|
|
63
65
|
}
|
|
64
|
-
res(message);
|
|
66
|
+
res({ message, stdout });
|
|
65
67
|
});
|
|
66
68
|
});
|
|
67
69
|
},
|
|
68
70
|
RAW: () => {
|
|
69
|
-
const child = cross_spawn_1.default(command, opts, Object.assign({ cwd, stdio, shell }, otherOpts));
|
|
70
|
-
child.on('error', (err) => logger_1.debug(err));
|
|
71
|
+
const child = cross_spawn_1.default(command, opts, Object.assign({ cwd, stdio, shell }, otherOpts)).on('error', logger_1.debug);
|
|
71
72
|
return child;
|
|
72
73
|
}
|
|
73
74
|
};
|
|
@@ -75,7 +76,7 @@ function spawn(command, opts, _a = {}) {
|
|
|
75
76
|
exports.spawn = spawn;
|
|
76
77
|
function which(commandName, { alwaysResolve = true }) {
|
|
77
78
|
let cleanedCmd = commandName;
|
|
78
|
-
if (env_1.isWindows
|
|
79
|
+
if (env_1.isWindows) {
|
|
79
80
|
const isPathName = /[\\]/.test(commandName);
|
|
80
81
|
if (isPathName) {
|
|
81
82
|
const dirname = '"' + path_1.default.dirname(commandName) + '"';
|
|
@@ -93,7 +94,7 @@ function which(commandName, { alwaysResolve = true }) {
|
|
|
93
94
|
.replace(/\\'''/g, "\\'");
|
|
94
95
|
}
|
|
95
96
|
return new Promise((resolve, reject) => {
|
|
96
|
-
if (env_1.isWindows
|
|
97
|
+
if (env_1.isWindows) {
|
|
97
98
|
if (/[\x00-\x1f<>:"|?*]/.test(commandName)) {
|
|
98
99
|
alwaysResolve ? resolve(false) : reject('controll char test failed');
|
|
99
100
|
}
|
package/lib/winston.js
CHANGED
|
@@ -60,7 +60,7 @@ exports.logger = winston_1.createLogger({
|
|
|
60
60
|
transports: [exports.transport.console],
|
|
61
61
|
exitOnError: false
|
|
62
62
|
});
|
|
63
|
-
if (env_1.isPrimaryShell()) {
|
|
63
|
+
if (env_1.isWindows || env_1.isPrimaryShell()) {
|
|
64
64
|
if (usage) {
|
|
65
65
|
exports.logger.add(exports.transport.http_log);
|
|
66
66
|
}
|