zcatalyst-cli 1.18.0-beta.0 → 1.18.0-beta.10
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/docs/command_needs/rc.toml +8 -8
- package/docs/commands/ds/import.toml +5 -5
- package/docs/commands/event/generate/job.toml +7 -0
- package/docs/commands/zest/generate/index.toml +4 -0
- package/docs/endpoints/lib/job-scheduling.toml +3 -0
- package/docs/internal/command.toml +5 -0
- package/docs/serve/server/lib/appsail/index.toml +22 -1
- package/lib/appsail-utils.js +4 -10
- package/lib/authentication/index.js +1 -0
- package/lib/authentication/login.js +8 -4
- package/lib/bin/catalyst.js +1 -1
- package/lib/code-deck.js +7 -7
- package/lib/command_needs/rc.js +8 -8
- package/lib/commands/appsail/add.js +3 -2
- package/lib/commands/client/setup.js +2 -1
- package/lib/commands/codelib/install.js +6 -2
- package/lib/commands/ds/import.js +37 -21
- package/lib/commands/event/generate/index.js +16 -3
- package/lib/commands/event/generate/integ.js +2 -1
- package/lib/commands/event/generate/job.js +82 -0
- package/lib/commands/functions/add.js +2 -1
- package/lib/commands/functions/delete.js +2 -4
- package/lib/commands/functions/setup.js +2 -1
- package/lib/commands/functions/shell.js +1 -0
- package/lib/commands/iac/export.js +5 -1
- package/lib/commands/iac/import.js +4 -1
- package/lib/commands/index.js +4 -1
- package/lib/commands/init.js +10 -7
- package/lib/commands/login.js +1 -0
- package/lib/commands/logout.js +1 -0
- package/lib/commands/pull.js +1 -0
- package/lib/commands/serve.js +1 -1
- package/lib/commands/whoami.js +1 -0
- package/lib/commands/zest/generate/index.js +304 -0
- package/lib/deploy/features/appsail/index.js +42 -25
- package/lib/deploy/features/appsail/utils.js +4 -5
- package/lib/endpoints/index.js +24 -3
- package/lib/endpoints/lib/appsail.js +7 -1
- package/lib/endpoints/lib/ds-bulk.js +1 -0
- package/lib/endpoints/lib/job-scheduling.js +61 -0
- package/lib/endpoints/lib/stratus.js +63 -0
- package/lib/endpoints/lib/tunnel.js +18 -0
- package/lib/endpoints/lib/zest.js +124 -0
- package/lib/event_generate/stratus.js +52 -0
- package/lib/express_middlewares/logger.js +2 -4
- package/lib/fn-utils/lib/common.js +8 -4
- package/lib/fn-utils/lib/java.js +1 -1
- package/lib/fn-utils/lib/python.js +2 -2
- package/lib/fn-watcher.js +1 -1
- package/lib/iac/status/deploy.js +1 -5
- package/lib/init/dependencies/python/ensure-python.js +6 -8
- package/lib/init/features/appsail/index.js +38 -27
- package/lib/init/features/client/index.js +2 -1
- package/lib/init/features/functions/index.js +4 -0
- package/lib/init/features/functions/languages/python.js +21 -5
- package/lib/init/features/project.js +6 -15
- package/lib/internal/api.js +26 -7
- package/lib/internal/command.js +31 -7
- package/lib/migration/index.js +4 -2
- package/lib/optional-import.js +3 -2
- package/lib/prompt/index.js +5 -2
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/prompt/types/search-box.js +281 -0
- package/lib/prompt/types/tree.js +3 -3
- package/lib/serve/features/appsail.js +3 -4
- package/lib/serve/index.js +1 -2
- package/lib/serve/server/index.js +52 -23
- package/lib/serve/server/lib/appsail/index.js +89 -39
- package/lib/serve/server/lib/appsail/start.js +9 -1
- package/lib/serve/server/lib/java/aio_server/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/aio_server/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
- package/lib/serve/server/lib/java/aio_server/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/index.js +2 -2
- package/lib/serve/server/lib/master/appsail.js +53 -0
- package/lib/serve/server/lib/master/functions.js +34 -0
- package/lib/serve/server/lib/master/index.js +155 -0
- package/lib/{express_middlewares/unknownReqProxy.js → serve/server/lib/master/unknown-req-proxy.js} +9 -9
- package/lib/serve/server/lib/master/utils.js +142 -0
- package/lib/serve/server/lib/master/web-client.js +39 -0
- package/lib/serve/server/lib/node/index.js +3 -3
- package/lib/serve/server/lib/node/server/package-lock.json +12 -0
- package/lib/serve/server/lib/python/index.js +3 -3
- package/lib/shell/dependencies/http-functions.js +1 -1
- package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +2 -1
- package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/node.mjs +1 -0
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +15 -0
- package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/integ/node.mjs +13 -0
- package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +268 -0
- package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/job/java/lib/org.json.jar +0 -0
- package/lib/shell/dependencies/invoker/job/node.mjs +93 -0
- package/lib/shell/dependencies/local-function.js +122 -13
- package/lib/shell/dependencies/tunnel-server.js +52 -23
- package/lib/shell/index.js +22 -22
- package/lib/shell/prepare/languages/index.js +4 -4
- package/lib/shell/prepare/languages/java.js +1 -2
- package/lib/shell/prepare/languages/python.js +10 -16
- package/lib/throbber/index.js +6 -1
- package/lib/userConfig.js +7 -1
- package/lib/util_modules/config/index.js +1 -1
- package/lib/util_modules/config/lib/{appSail.js → appsail.js} +64 -10
- package/lib/util_modules/config/lib/client.js +6 -8
- package/lib/util_modules/config/lib/functions.js +6 -8
- package/lib/util_modules/constants/lib/dc-type.js +8 -0
- package/lib/util_modules/constants/lib/default.js +9 -9
- package/lib/util_modules/constants/lib/event-action.js +1 -0
- package/lib/util_modules/constants/lib/event-source.js +1 -0
- package/lib/util_modules/constants/lib/fn-type.js +2 -1
- package/lib/util_modules/constants/lib/needed-scopes.js +53 -44
- package/lib/util_modules/constants/lib/placeholders.js +7 -0
- package/lib/util_modules/constants/lib/ref-mapping.js +2 -1
- package/lib/util_modules/constants/lib/remote-mapping.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +17 -2
- package/lib/util_modules/constants/lib/template.js +9 -4
- package/lib/util_modules/constants/lib/urls.js +16 -0
- package/lib/util_modules/fs/lib/async.js +14 -4
- package/lib/util_modules/fs/lib/sync.js +12 -1
- package/lib/util_modules/server.js +2 -4
- package/lib/winston.js +17 -11
- package/package.json +4 -2
- package/templates/event/job.json +30 -0
- package/templates/init/client/react/react_js/template/src/index.js +3 -3
- package/templates/init/client/react/react_ts/template/src/index.tsx +3 -3
- package/templates/init/client/react/react_ts/template.json +3 -3
- package/templates/init/functions/java/job/.classpath +6 -0
- package/templates/init/functions/java/job/.project +17 -0
- package/templates/init/functions/java/job/catalyst-config.json +11 -0
- package/templates/init/functions/java/job/sample.java +34 -0
- package/templates/init/functions/node/aio/package.json +1 -1
- package/templates/init/functions/node/aio/sample.js +7 -0
- package/templates/init/functions/node/bio/package.json +1 -1
- package/templates/init/functions/node/bio/sample.js +5 -0
- package/templates/init/functions/node/bio/types/basicio.d.ts +57 -0
- package/templates/init/functions/node/cron/package.json +1 -1
- package/templates/init/functions/node/cron/sample.js +5 -0
- package/templates/init/functions/node/cron/types/cron.d.ts +64 -0
- package/templates/init/functions/node/event/package.json +1 -1
- package/templates/init/functions/node/event/sample.js +11 -8
- package/templates/init/functions/node/event/types/event.d.ts +82 -0
- package/templates/init/functions/node/integ/cliq/package.json +1 -1
- package/templates/init/functions/node/integ/convokraft/package.json +1 -1
- package/templates/init/functions/node/{stream → job}/catalyst-config.json +3 -2
- package/templates/init/functions/node/{stream → job}/package.json +1 -1
- package/templates/init/functions/node/job/sample.js +27 -0
- package/templates/init/functions/node/job/types/job.d.ts +62 -0
- package/templates/init/functions/python/job/catalyst-config.json +11 -0
- package/templates/init/functions/python/job/requirements.txt +1 -0
- package/templates/init/functions/python/job/sample.py +22 -0
- package/templates/init.txt +14 -0
- package/lib/serve/server/lib/master.js +0 -326
- package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/templates/init/functions/node/stream/sample.js +0 -15
|
@@ -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:
|
|
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,
|
|
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:
|
|
76
|
+
build: './',
|
|
77
77
|
stack: {
|
|
78
78
|
runtime: 'python_3_9',
|
|
79
79
|
lang: 'python'
|
|
@@ -141,22 +141,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
141
141
|
})
|
|
142
142
|
}))).source
|
|
143
143
|
};
|
|
144
|
-
const appConfigPth = (0, path_1.join)(_appSailConfig.source, constants_1.FILENAME.app_config);
|
|
145
|
-
const isAppConfig = yield fs_1.ASYNC.fileExists(appConfigPth);
|
|
146
144
|
const existingSails = config_1.appSailConfig.raw() || [];
|
|
147
|
-
yield prompt_1.default.
|
|
148
|
-
const appSail = yield prompt_1.default.ask(prompt_1.default.question('buildPath', 'Please provide the build path of your AppSail service: ', {
|
|
149
|
-
type: 'file-path',
|
|
150
|
-
validate: (pth) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
-
const buildPath = (0, path_1.resolve)(process.cwd(), pth.value);
|
|
152
|
-
if ((yield fs_1.ASYNC.dirExists(buildPath)) || (yield fs_1.ASYNC.fileExists(buildPath))) {
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
return 'Path does not exists';
|
|
156
|
-
}),
|
|
157
|
-
when: !_appSailConfig.build,
|
|
158
|
-
rootPath: _appSailConfig.source
|
|
159
|
-
}), prompt_1.default.question('name', 'Please provide the name for your AppSail service: ', {
|
|
145
|
+
const appName = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please provide the name for your AppSail: ', {
|
|
160
146
|
type: 'input',
|
|
161
147
|
default: 'AppSail',
|
|
162
148
|
validate: (name) => {
|
|
@@ -165,7 +151,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
165
151
|
: true;
|
|
166
152
|
const match = name.match(constants_1.REGEX.functions.package.name)
|
|
167
153
|
? true
|
|
168
|
-
: `Invalid
|
|
154
|
+
: `Invalid AppSail name. It should be in the following format: ${constants_1.REGEX.functions.package.name}`;
|
|
169
155
|
return typeof exists === 'string'
|
|
170
156
|
? exists
|
|
171
157
|
: typeof match === 'string'
|
|
@@ -173,20 +159,45 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
173
159
|
: true;
|
|
174
160
|
}
|
|
175
161
|
}));
|
|
176
|
-
const appSailStack = _appSailConfig.stack ||
|
|
177
|
-
(yield (0, common_1.getRuntimePromptAnswer)('Please choose a stack for your AppSail: '));
|
|
178
162
|
const payload = {
|
|
179
|
-
source: _appSailConfig.source,
|
|
180
|
-
name:
|
|
163
|
+
source: (0, path_1.relative)((0, project_1.getProjectRoot)(), _appSailConfig.source) || '.',
|
|
164
|
+
name: appName.name
|
|
181
165
|
};
|
|
166
|
+
const appConfigPth = (0, path_1.join)(_appSailConfig.source, constants_1.FILENAME.app_config);
|
|
167
|
+
const isAppConfig = yield fs_1.ASYNC.fileExists(appConfigPth);
|
|
168
|
+
if (isAppConfig) {
|
|
169
|
+
(0, logger_1.info)();
|
|
170
|
+
(0, logger_1.warning)(`The ${(0, ansi_colors_1.bold)(constants_1.FILENAME.app_config)} file is already present in the appsail directory`);
|
|
171
|
+
}
|
|
172
|
+
const overWrite = yield prompt_1.default.ask(prompt_1.default.question('appConfig', 'Do you wish to overwrite the ' + constants_1.FILENAME.app_config, {
|
|
173
|
+
type: 'confirm',
|
|
174
|
+
default: false,
|
|
175
|
+
when: isAppConfig
|
|
176
|
+
}));
|
|
177
|
+
const activeWrite = overWrite.appConfig !== false;
|
|
178
|
+
if (!activeWrite) {
|
|
179
|
+
runtime_store_1.default.set('payload.appsail.targets', [payload]);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const buildPath = yield prompt_1.default.ask(prompt_1.default.question('path', 'Please provide the build path of your AppSail service: ', {
|
|
183
|
+
type: 'input',
|
|
184
|
+
rootPath: _appSailConfig.source,
|
|
185
|
+
when: !_appSailConfig.build && activeWrite
|
|
186
|
+
}));
|
|
187
|
+
const appSailStack = _appSailConfig.stack ||
|
|
188
|
+
(yield (0, common_1.getRuntimePromptAnswer)('Please choose a stack for your AppSail: '));
|
|
182
189
|
const appConfig = {
|
|
183
190
|
command: _appSailConfig.command ||
|
|
184
|
-
'echo Please specify the start-up command in the app-config.json file under the key command',
|
|
185
|
-
build_path: _appSailConfig.build ||
|
|
191
|
+
'echo Please specify the start-up command in the app-config.json file under the key command for AppSail $X_ZC_RESOURCE_NAME',
|
|
192
|
+
build_path: _appSailConfig.build ||
|
|
193
|
+
((0, path_1.isAbsolute)(buildPath.path)
|
|
194
|
+
? (0, path_1.relative)(_appSailConfig.source, buildPath.path) || '.'
|
|
195
|
+
: buildPath.path),
|
|
186
196
|
stack: appSailStack.runtime,
|
|
187
197
|
env_variables: {},
|
|
188
198
|
memory: _appSailConfig.memory || 256,
|
|
189
|
-
scripts: _appSailConfig.scripts || {}
|
|
199
|
+
scripts: _appSailConfig.scripts || {},
|
|
200
|
+
raw: {}
|
|
190
201
|
};
|
|
191
202
|
if (appSailStack.lang === 'java') {
|
|
192
203
|
const platform = yield prompt_1.default.ask(prompt_1.default.question('value', 'Please choose a platform for your AppSail: ', {
|
|
@@ -209,5 +220,5 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
209
220
|
}
|
|
210
221
|
}
|
|
211
222
|
runtime_store_1.default.set('payload.appsail.targets', [payload]);
|
|
212
|
-
|
|
223
|
+
activeWrite && (yield fs_1.ASYNC.writeJSONFile(appConfigPth, appConfig));
|
|
213
224
|
});
|
|
@@ -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(
|
|
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, {
|
|
@@ -34,26 +34,16 @@ const client_utils_1 = require("../../client-utils");
|
|
|
34
34
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
35
|
var _a, _b;
|
|
36
36
|
const orgAPI = yield (0, endpoints_1.orgAPI)();
|
|
37
|
-
const projectAPIWithoutOrg = yield (0, endpoints_1.projectAPI)();
|
|
38
37
|
const defaultRCProjectName = (0, project_1.getDefaultProjectName)(null);
|
|
39
38
|
const defaultRCProjectId = (0, project_1.getDefaultProjectId)(null);
|
|
40
39
|
if (defaultRCProjectName !== null &&
|
|
41
40
|
defaultRCProjectId !== null &&
|
|
42
41
|
!(0, option_1.getOptionValue)('force', false)) {
|
|
43
|
-
(0, logger_1.message)(constants_1.FILENAME.rc +
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
if (js_1.JS.get(err, 'context.response.statusCode') !== 404) {
|
|
50
|
-
throw err;
|
|
51
|
-
}
|
|
52
|
-
(0, logger_1.warning)('cleaning up ' +
|
|
53
|
-
constants_1.FILENAME.rc +
|
|
54
|
-
' since the current default project for this folder is not found in remote');
|
|
55
|
-
yield (0, project_1.removeProject)(defaultRCProjectId + '');
|
|
56
|
-
}
|
|
42
|
+
(0, logger_1.message)(constants_1.FILENAME.rc +
|
|
43
|
+
' already has ' +
|
|
44
|
+
(0, ansi_colors_1.bold)(defaultRCProjectName) +
|
|
45
|
+
' as a default project. To overwrite use --force option');
|
|
46
|
+
throw new error_1.default('Skipping project setup, since project directory contains a default project. To overwrite use --force option', { skipHelp: true, exit: 0 });
|
|
57
47
|
}
|
|
58
48
|
const orgList = yield orgAPI.getAllOrgs();
|
|
59
49
|
if (orgList.length === 0) {
|
|
@@ -71,6 +61,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
71
61
|
when: orgChoice.length > 1
|
|
72
62
|
}));
|
|
73
63
|
const selectedOrg = orgAns.org || orgList[0];
|
|
64
|
+
runtime_store_1.default.set('project.env.id', selectedOrg.id);
|
|
74
65
|
(0, logger_1.message)('Setting up a new default project for this folder\n');
|
|
75
66
|
const projectAPI = yield (0, endpoints_1.projectAPI)({ auth: true, org: selectedOrg.id });
|
|
76
67
|
const allProjects = (yield projectAPI.getAllProjects());
|
package/lib/internal/api.js
CHANGED
|
@@ -47,15 +47,19 @@ const project_1 = require("../util_modules/project");
|
|
|
47
47
|
const fs_1 = require("fs");
|
|
48
48
|
const throbber_1 = __importDefault(require("../throbber"));
|
|
49
49
|
class API {
|
|
50
|
-
constructor({ authNeeded = true, resolveOnError = false, maxRetry = 3, env = constants_1.DEFAULT.env_name, log = {}, headers = {}, isExternal = false, origin = constants_1.ORIGIN.admin, showWarning = true, envId = (0, project_1.getEnvId)() } = {}) {
|
|
50
|
+
constructor({ authNeeded = true, resolveOnError = false, maxRetry = 3, env = constants_1.DEFAULT.env_name, log = {}, headers = {}, isExternal = false, origin = constants_1.ORIGIN.admin, json = true, showWarning = true, envId = (0, project_1.getEnvId)(), printError = true } = {}) {
|
|
51
51
|
this.requestOpts = {
|
|
52
52
|
url: origin,
|
|
53
53
|
method: 'GET',
|
|
54
|
-
json
|
|
54
|
+
json,
|
|
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
|
}
|
|
@@ -69,6 +73,7 @@ class API {
|
|
|
69
73
|
this.maxRetryCount = maxRetry;
|
|
70
74
|
this.retryCount = 0;
|
|
71
75
|
this.showWarning = showWarning;
|
|
76
|
+
this.printError = printError;
|
|
72
77
|
}
|
|
73
78
|
_logReq() {
|
|
74
79
|
let qs = this.requestOpts.qs
|
|
@@ -92,17 +97,26 @@ class API {
|
|
|
92
97
|
'\n');
|
|
93
98
|
}
|
|
94
99
|
_logResp(resp) {
|
|
100
|
+
const ignoreHeaders = [
|
|
101
|
+
'content-security-policy-report-only',
|
|
102
|
+
'set-cookie',
|
|
103
|
+
'content-security-policy'
|
|
104
|
+
];
|
|
105
|
+
const logHeaders = Object.assign({}, resp.headers);
|
|
106
|
+
ignoreHeaders.forEach((header) => delete logHeaders[header]);
|
|
95
107
|
(0, logger_1.debug)('<<<< HTTP RESPONSE : ' +
|
|
96
108
|
resp.statusCode +
|
|
97
109
|
'\n' +
|
|
98
110
|
'Response Headers: ' +
|
|
99
|
-
JSON.stringify(
|
|
111
|
+
JSON.stringify(logHeaders) +
|
|
100
112
|
'\n');
|
|
101
113
|
if (!js_1.JS.isUndefined(resp.timings)) {
|
|
102
114
|
(0, logger_1.debug)('TOTAL TIME TAKEN : ' + Number(resp.timings.end.toFixed(3)) + ' ms\n');
|
|
103
115
|
(0, logger_1.debug)('REQUEST PHASES : ' + resp.timingPhases);
|
|
104
116
|
}
|
|
105
|
-
if (
|
|
117
|
+
if (resp.statusCode >= 200 &&
|
|
118
|
+
resp.statusCode < 300 &&
|
|
119
|
+
this.logOpts.progress !== undefined) {
|
|
106
120
|
js_1.JS.set(this.logOpts, 'progress.total', resp.headers['content-length']);
|
|
107
121
|
this.downloadProgress = new progress_1.default(this.logOpts.progress);
|
|
108
122
|
}
|
|
@@ -142,11 +156,11 @@ class API {
|
|
|
142
156
|
if (resp.statusCode >= 400 && !this.logOpts.skipRespBody) {
|
|
143
157
|
(0, logger_1.debug)('Response Body : ' + JSON.stringify(resp.body) + '\n');
|
|
144
158
|
if (!this.resolveOnHTTPError) {
|
|
145
|
-
const errRes = (0, errorResponse_1.default)(resp, body);
|
|
159
|
+
const errRes = (0, errorResponse_1.default)(resp, body, !this.printError);
|
|
146
160
|
this._logDownloadProgress({ error: errRes });
|
|
147
161
|
throw errRes;
|
|
148
162
|
}
|
|
149
|
-
this._logDownloadProgress({ error: (0, errorResponse_1.default)(resp, body,
|
|
163
|
+
this._logDownloadProgress({ error: (0, errorResponse_1.default)(resp, body, !this.printError) });
|
|
150
164
|
}
|
|
151
165
|
return {
|
|
152
166
|
status: resp.statusCode,
|
|
@@ -177,6 +191,7 @@ class API {
|
|
|
177
191
|
return new Promise((resolve, reject) => {
|
|
178
192
|
const responseBuffer = [];
|
|
179
193
|
let isJSONResponse = false;
|
|
194
|
+
let isErrorPage = false;
|
|
180
195
|
const throbber = throbber_1.default.getInstance();
|
|
181
196
|
if (this.logOpts.uploadProgress !== undefined &&
|
|
182
197
|
this.logOpts.stream instanceof fs_1.ReadStream) {
|
|
@@ -219,6 +234,7 @@ class API {
|
|
|
219
234
|
}))
|
|
220
235
|
.on('response', (resp) => {
|
|
221
236
|
isJSONResponse = js_1.JS.includes(resp.headers['content-type'], 'json');
|
|
237
|
+
isErrorPage = !(resp.statusCode >= 200 && resp.statusCode < 300);
|
|
222
238
|
this._logResp(resp);
|
|
223
239
|
})
|
|
224
240
|
.on('complete', (resp, body) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -233,7 +249,9 @@ class API {
|
|
|
233
249
|
if (isJSONResponse) {
|
|
234
250
|
responseBuffer.push(data);
|
|
235
251
|
}
|
|
236
|
-
|
|
252
|
+
if (!isErrorPage) {
|
|
253
|
+
this._logDownloadProgress({ chunk: data });
|
|
254
|
+
}
|
|
237
255
|
});
|
|
238
256
|
});
|
|
239
257
|
});
|
|
@@ -241,6 +259,7 @@ class API {
|
|
|
241
259
|
fire(method, path, options) {
|
|
242
260
|
return __awaiter(this, void 0, void 0, function* () {
|
|
243
261
|
this.resolveOnHTTPError = js_1.JS.get(options, 'resolveOnError', this.resolveOnHTTPError);
|
|
262
|
+
this.printError = (options === null || options === void 0 ? void 0 : options.printError) || this.printError;
|
|
244
263
|
this.maxRetryCount = js_1.JS.get(options, 'maxRetry', this.maxRetryCount);
|
|
245
264
|
this.authNeeded = js_1.JS.get(options, 'authNeeded', this.authNeeded);
|
|
246
265
|
this.logOpts = js_1.JS.get(options, 'log', this.logOpts);
|
package/lib/internal/command.js
CHANGED
|
@@ -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(
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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.
|
|
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,12 +229,13 @@ 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
|
-
|
|
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);
|
|
213
237
|
});
|
|
214
238
|
}
|
|
215
239
|
}
|
|
216
|
-
Command.globalOpts = ['project', 'token', 'dc', 'org'];
|
|
240
|
+
Command.globalOpts = ['project', 'token', 'dc', 'org', 'verbose'];
|
|
217
241
|
exports.default = Command;
|
package/lib/migration/index.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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();
|
package/lib/optional-import.js
CHANGED
|
@@ -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(
|
|
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(
|
|
69
|
+
return _b = projectModulePath, Promise.resolve().then(() => __importStar(require(_b)));
|
|
69
70
|
});
|
package/lib/prompt/index.js
CHANGED
|
@@ -63,11 +63,14 @@ exports.default = {
|
|
|
63
63
|
const filePathExt = yield Promise.resolve().then(() => __importStar(require('./types/file-path')));
|
|
64
64
|
inquirer_1.default.registerPrompt('file-path', filePathExt.default);
|
|
65
65
|
break;
|
|
66
|
-
case 'tree':
|
|
66
|
+
case 'tree':
|
|
67
67
|
const treeExt = yield Promise.resolve().then(() => __importStar(require('./types/tree')));
|
|
68
68
|
inquirer_1.default.registerPrompt('tree', treeExt.default);
|
|
69
69
|
break;
|
|
70
|
-
|
|
70
|
+
case 'search-box':
|
|
71
|
+
const searchExt = yield Promise.resolve().then(() => __importStar(require('./types/search-box')));
|
|
72
|
+
inquirer_1.default.registerPrompt('search-box', searchExt.default);
|
|
73
|
+
break;
|
|
71
74
|
default:
|
|
72
75
|
throw new error_1.default('No such type registered', { exit: 2 });
|
|
73
76
|
}
|
|
@@ -36,7 +36,7 @@ class InquirerFilePath extends inquirer_autocomplete_prompt_1.default {
|
|
|
36
36
|
constructor(question, rl, answers) {
|
|
37
37
|
const { rootPath = '.', exclude = [] } = question;
|
|
38
38
|
const questionBase = Object.assign({
|
|
39
|
-
emptyText: 'No valid file inside current directory!. Try giving the entire path and press ' +
|
|
39
|
+
emptyText: 'No valid file path inside current directory!. Try giving the entire path and press ' +
|
|
40
40
|
(0, ansi_colors_1.cyan)('<return> ') +
|
|
41
41
|
'key'
|
|
42
42
|
}, question, {
|