zcatalyst-cli 1.13.2 → 1.14.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/docs/client-utils.toml +6 -1
- package/docs/commands/ds/import.toml +5 -0
- package/docs/fn-utils/lib/python.toml +4 -0
- package/docs/init/dependencies/python/ensure-python.toml +12 -0
- package/docs/init/dependencies/python/pip-install.toml +4 -0
- package/docs/serve/index.toml +5 -0
- package/lib/authentication/login.js +2 -1
- package/lib/cli_table/index.js +26 -2
- package/lib/cli_table/src/cell.js +359 -267
- package/lib/cli_table/src/layout-manager.js +231 -209
- package/lib/cli_table/src/table.js +76 -60
- package/lib/cli_table/src/utils.js +259 -224
- package/lib/client-utils.js +18 -4
- package/lib/command_needs/rc.js +57 -8
- package/lib/commands/config/delete.js +23 -0
- package/lib/commands/config/get.js +23 -0
- package/lib/commands/config/list.js +23 -0
- package/lib/commands/config/set.js +29 -0
- package/lib/commands/console/cache.js +31 -1
- package/lib/commands/console/queue.js +31 -1
- package/lib/commands/console/zcql.js +27 -1
- package/lib/commands/ds/export.js +2 -2
- package/lib/commands/ds/import.js +25 -5
- package/lib/commands/ds/status.js +2 -2
- package/lib/commands/iac/export.js +1 -1
- package/lib/commands/iac/import.js +1 -1
- package/lib/commands/iac/pack.js +16 -5
- package/lib/commands/iac/status.js +1 -1
- package/lib/commands/index.js +4 -0
- package/lib/commands/project/list.js +1 -1
- package/lib/commands/project/use.js +1 -1
- package/lib/deploy/features/client.js +2 -2
- package/lib/deploy/features/functions/index.js +13 -3
- package/lib/deploy/features/functions/languages/index.js +19 -2
- package/lib/endpoints/index.js +12 -5
- package/lib/endpoints/lib/env.js +5 -2
- package/lib/endpoints/lib/functions.js +30 -0
- package/lib/endpoints/lib/org.js +35 -0
- package/lib/endpoints/lib/project.js +7 -3
- package/lib/express_middlewares/unknownReqProxy.js +4 -1
- package/lib/fn-utils/index.js +2 -0
- package/lib/fn-utils/lib/common.js +68 -7
- package/lib/fn-utils/lib/integ.js +15 -11
- package/lib/fn-utils/lib/java.js +7 -3
- package/lib/fn-utils/lib/python.js +121 -0
- package/lib/fn-watcher.js +10 -2
- package/lib/index.js +2 -1
- package/lib/init/dependencies/python/ensure-python.js +151 -0
- package/lib/init/dependencies/python/pip-install.js +175 -0
- package/lib/init/features/functions/index.js +50 -29
- package/lib/init/features/functions/languages/index.js +3 -1
- package/lib/init/features/functions/languages/python.js +115 -0
- package/lib/init/features/index.js +2 -2
- package/lib/init/features/project.js +26 -6
- package/lib/init/util/project.js +2 -2
- package/lib/internal/api.js +2 -0
- package/lib/internal/command.js +1 -1
- package/lib/internal/rc.js +2 -0
- package/lib/port-resolver.js +4 -3
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/pull/features/functions/index.js +35 -2
- package/lib/pull/features/functions/languages.js +8 -1
- package/lib/readLineUtils.js +37 -1
- package/lib/readline/features/cache.js +175 -1
- package/lib/readline/features/index.js +7 -1
- package/lib/readline/features/queue.js +209 -1
- package/lib/readline/features/zcql.js +237 -1
- package/lib/readline/index.js +30 -1
- package/lib/serve/index.js +48 -7
- package/lib/serve/server/index.js +118 -44
- package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/master.js +18 -5
- package/lib/serve/server/lib/node.mjs +41 -0
- package/lib/serve/server/lib/web_client/index.js +7 -3
- package/lib/serve/server/lib/web_client/server.js +31 -15
- package/lib/shell/dependencies/http-functions.js +57 -21
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +1 -2
- package/lib/shell/dependencies/invoker/bio/node.mjs +127 -0
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/cron/node.mjs +87 -0
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +3 -3
- package/lib/shell/dependencies/invoker/event/node.mjs +84 -0
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/integ/node.mjs +88 -0
- package/lib/shell/dependencies/local-function.js +74 -22
- package/lib/shell/index.js +11 -2
- package/lib/shell/prepare/index.js +21 -0
- package/lib/shell/prepare/languages/index.js +8 -2
- package/lib/shell/prepare/languages/java.js +39 -2
- package/lib/shell/prepare/languages/node.js +21 -2
- package/lib/shell/prepare/languages/python.js +65 -0
- package/lib/throbber/index.js +3 -1
- package/lib/userConfig.js +48 -0
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/apig-rules.js +8 -0
- package/lib/util_modules/constants/lib/cliq-handlers.js +17 -1
- package/lib/util_modules/constants/lib/dc-type.js +8 -0
- package/lib/util_modules/constants/lib/default.js +2 -2
- package/lib/util_modules/constants/lib/env-path.js +12 -0
- package/lib/util_modules/constants/lib/file-names.js +4 -1
- package/lib/util_modules/constants/lib/folder-names.js +3 -1
- package/lib/util_modules/constants/lib/placeholders.js +6 -1
- package/lib/util_modules/constants/lib/runtime.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +1 -0
- package/lib/util_modules/constants/lib/template.js +9 -0
- package/lib/util_modules/constants/lib/urls.js +2 -6
- package/lib/util_modules/context-help.js +2 -0
- package/lib/util_modules/fs/lib/async.js +35 -11
- package/lib/util_modules/project.js +20 -1
- package/package.json +2 -1
- package/templates/init/functions/java/aio/catalyst-config.json +3 -2
- package/templates/init/functions/java/bio/catalyst-config.json +3 -2
- package/templates/init/functions/java/cron/catalyst-config.json +3 -2
- package/templates/init/functions/java/event/catalyst-config.json +3 -2
- package/templates/init/functions/java/integ/cliq/catalyst-config.json +1 -0
- package/templates/init/functions/node/aio/catalyst-config.json +3 -2
- package/templates/init/functions/node/bio/catalyst-config.json +3 -2
- package/templates/init/functions/node/cron/catalyst-config.json +3 -2
- package/templates/init/functions/node/event/catalyst-config.json +3 -2
- package/templates/init/functions/node/integ/cliq/catalyst-config.json +1 -0
- package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +2 -2
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +1 -2
- package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/installation-validator.js +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/message-action-handler.js +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +1 -1
- package/templates/init/functions/node/integ/cliq/sample.js +4 -4
- package/templates/init/functions/python/aio/catalyst-config.json +11 -0
- package/templates/init/functions/python/aio/requirements.txt +1 -0
- package/templates/init/functions/python/aio/sample.py +26 -0
- package/templates/init/functions/python/bio/catalyst-config.json +11 -0
- package/templates/init/functions/python/bio/requirements.txt +1 -0
- package/templates/init/functions/python/bio/sample.py +6 -0
- package/templates/init/functions/python/cron/catalyst-config.json +11 -0
- package/templates/init/functions/python/cron/requirements.txt +1 -0
- package/templates/init/functions/python/cron/sample.py +18 -0
- package/templates/init/functions/python/event/catalyst-config.json +11 -0
- package/templates/init/functions/python/event/requirements.txt +1 -0
- package/templates/init/functions/python/event/sample.py +21 -0
- package/templates/init/functions/python/integ/cliq/catalyst-config.json +11 -0
- package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +174 -0
- package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +102 -0
- package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +409 -0
- package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +12 -0
- package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +16 -0
- package/templates/init/functions/python/integ/cliq/handlers/message_action_handler.py +18 -0
- package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +269 -0
- package/templates/init/functions/python/integ/cliq/requirements.txt +1 -0
- package/templates/init/functions/python/integ/cliq/sample.py +21 -0
- package/lib/serve/server/lib/node.js +0 -62
- package/lib/shell/dependencies/invoker/bio/node.js +0 -80
- package/lib/shell/dependencies/invoker/cron/node.js +0 -54
- package/lib/shell/dependencies/invoker/event/node.js +0 -56
- package/lib/shell/dependencies/invoker/integ/node.js +0 -79
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/react/.DS_Store +0 -0
- package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
|
@@ -33,7 +33,8 @@ const fn_utils_1 = require("../../fn-utils");
|
|
|
33
33
|
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
|
-
const
|
|
36
|
+
const orgAPI = yield (0, endpoints_1.orgAPI)();
|
|
37
|
+
const projectAPIWithoutOrg = yield (0, endpoints_1.projectAPI)();
|
|
37
38
|
const defaultRCProjectName = (0, project_1.getDefaultProjectName)(null);
|
|
38
39
|
const defaultRCProjectId = (0, project_1.getDefaultProjectId)(null);
|
|
39
40
|
if (defaultRCProjectName !== null &&
|
|
@@ -41,7 +42,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
41
42
|
!(0, option_1.getOptionValue)('force', false)) {
|
|
42
43
|
(0, logger_1.message)(constants_1.FILENAME.rc + ' already has ' + (0, ansi_colors_1.bold)(defaultRCProjectName) + ' as a default project.');
|
|
43
44
|
try {
|
|
44
|
-
yield
|
|
45
|
+
yield projectAPIWithoutOrg.getProject(defaultRCProjectId);
|
|
45
46
|
throw new error_1.default('Skipping project setup, since project directory contains a default project. To overwrite use --force option');
|
|
46
47
|
}
|
|
47
48
|
catch (err) {
|
|
@@ -54,7 +55,24 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
54
55
|
yield (0, project_1.removeProject)(defaultRCProjectId + '');
|
|
55
56
|
}
|
|
56
57
|
}
|
|
58
|
+
const orgList = yield orgAPI.getAllOrgs();
|
|
59
|
+
if (orgList.length === 0) {
|
|
60
|
+
throw new error_1.default('Visit ' +
|
|
61
|
+
(0, ansi_colors_1.underline)(constants_1.ORIGIN.console) +
|
|
62
|
+
' for creation of your first project before you continue.', { exit: 1 });
|
|
63
|
+
}
|
|
64
|
+
const orgChoice = orgList.map((org) => prompt_1.default.choice(org.name + ' (' + org.id + ')', {
|
|
65
|
+
value: org,
|
|
66
|
+
short: org.name
|
|
67
|
+
}));
|
|
68
|
+
const orgAns = yield prompt_1.default.ask(prompt_1.default.question('org', 'Select a default Catalyst portal for this directory: ', {
|
|
69
|
+
type: 'list',
|
|
70
|
+
choices: js_1.JS.reverse(orgChoice),
|
|
71
|
+
when: orgChoice.length > 0
|
|
72
|
+
}));
|
|
73
|
+
const selectedOrg = orgAns.org || orgList[0];
|
|
57
74
|
(0, logger_1.message)('Setting up a new default project for this folder\n');
|
|
75
|
+
const projectAPI = yield (0, endpoints_1.projectAPI)({ auth: true, org: selectedOrg.id });
|
|
58
76
|
const allProjects = (yield projectAPI.getAllProjects());
|
|
59
77
|
if (allProjects.length === 0) {
|
|
60
78
|
throw new error_1.default('Visit ' +
|
|
@@ -83,14 +101,14 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
83
101
|
}));
|
|
84
102
|
let selectedProject = projectAns.project;
|
|
85
103
|
if (typeof selectedProject !== 'number') {
|
|
86
|
-
return (0, project_2.fillProjectPayload)(selectedProject);
|
|
104
|
+
return (0, project_2.fillProjectPayload)(selectedOrg, selectedProject);
|
|
87
105
|
}
|
|
88
106
|
if (selectedProject === 0) {
|
|
89
107
|
const projectNameAns = yield prompt_1.default.ask(prompt_1.default.question('projectName', 'Provide a name for your new project:', {
|
|
90
108
|
validate: (ans) => (ans.match(constants_1.REGEX.project.name) ? true : 'Invalid project name')
|
|
91
109
|
}));
|
|
92
110
|
selectedProject = yield projectAPI.createProject(projectNameAns.projectName);
|
|
93
|
-
return (0, project_2.fillProjectPayload)(selectedProject, true);
|
|
111
|
+
return (0, project_2.fillProjectPayload)(selectedOrg, selectedProject, true);
|
|
94
112
|
}
|
|
95
113
|
const [zipArchive, template, importRes] = yield (0, import_1.iacImport)();
|
|
96
114
|
yield zipArchive
|
|
@@ -108,7 +126,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
108
126
|
? fn_utils_1.fnUtils.node
|
|
109
127
|
: stack.startsWith(runtime_1.default.language.java)
|
|
110
128
|
? fn_utils_1.fnUtils.java
|
|
111
|
-
:
|
|
129
|
+
: stack.startsWith(runtime_1.default.language.python)
|
|
130
|
+
? fn_utils_1.fnUtils.python
|
|
131
|
+
: null;
|
|
112
132
|
if (fnUtil === null) {
|
|
113
133
|
(0, logger_1.warning)(`skipping setup of function(${refinedTargets[0].name}) since provided stack ${stack} is not supported.`);
|
|
114
134
|
return;
|
|
@@ -131,5 +151,5 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
131
151
|
(0, client_1.fillClientInitPayload)(source, properties.app_name);
|
|
132
152
|
}
|
|
133
153
|
const projectDetails = yield projectAPI.getProject(importRes.project_details.id);
|
|
134
|
-
return (0, project_2.fillProjectPayload)(projectDetails, true, true);
|
|
154
|
+
return (0, project_2.fillProjectPayload)(selectedOrg, projectDetails, true, true);
|
|
135
155
|
});
|
package/lib/init/util/project.js
CHANGED
|
@@ -18,10 +18,10 @@ const error_1 = __importDefault(require("../../error"));
|
|
|
18
18
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
19
19
|
const constants_1 = require("../../util_modules/constants");
|
|
20
20
|
const project_1 = require("../../util_modules/project");
|
|
21
|
-
const fillProjectPayload = (selectedProject, isNew = false, isImport = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const fillProjectPayload = (selectedOrg, selectedProject, isNew = false, isImport = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
22
|
runtime_store_1.default.set('payload.project', selectedProject);
|
|
23
23
|
runtime_store_1.default.set('project', (0, project_1.transformProject)(selectedProject));
|
|
24
|
-
const envAPI = yield (0, endpoints_1.envAPI)();
|
|
24
|
+
const envAPI = yield (0, endpoints_1.envAPI)({ auth: true, org: selectedOrg.id });
|
|
25
25
|
const envArr = (yield envAPI.getEnvs((0, project_1.getProjectId)()));
|
|
26
26
|
const envObj = envArr.find((env) => env.env_name === constants_1.DEFAULT.env_name);
|
|
27
27
|
if (envObj === undefined) {
|
package/lib/internal/api.js
CHANGED
|
@@ -43,6 +43,7 @@ const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
|
43
43
|
const constants_1 = require("../util_modules/constants");
|
|
44
44
|
const js_1 = require("../util_modules/js");
|
|
45
45
|
const logger_1 = require("../util_modules/logger");
|
|
46
|
+
const project_1 = require("../util_modules/project");
|
|
46
47
|
class API {
|
|
47
48
|
constructor({ authNeeded = true, resolveOnError = false, maxRetry = 3, env = constants_1.DEFAULT.env_name, log = {}, headers = {} } = {}) {
|
|
48
49
|
this.requestOpts = {
|
|
@@ -208,6 +209,7 @@ class API {
|
|
|
208
209
|
this.logOpts = js_1.JS.get(options, 'log', this.logOpts);
|
|
209
210
|
this.requestOpts = js_1.JS.defaultsDeep(js_1.JS.omit(options, ['origin', 'auth', 'maxRetry', 'resolveOnError', 'log']), this.requestOpts);
|
|
210
211
|
this.requestOpts.url = js_1.JS.get(options, 'origin', constants_1.ORIGIN.admin) + path;
|
|
212
|
+
js_1.JS.set(this.requestOpts, 'headers.CATALYST-ORG', js_1.JS.get(options, 'envId', (0, project_1.getEnvId)()));
|
|
211
213
|
this.requestOpts.method = method;
|
|
212
214
|
if (this.authNeeded) {
|
|
213
215
|
yield this._addAuthHeader();
|
package/lib/internal/command.js
CHANGED
package/lib/internal/rc.js
CHANGED
|
@@ -122,6 +122,7 @@ class RC {
|
|
|
122
122
|
id: project.id + '',
|
|
123
123
|
name: project.name,
|
|
124
124
|
domain: project.domain,
|
|
125
|
+
timezone: project.timezone,
|
|
125
126
|
env: []
|
|
126
127
|
});
|
|
127
128
|
projIdx = lastIdx;
|
|
@@ -140,6 +141,7 @@ class RC {
|
|
|
140
141
|
id: mergedProject.id + '',
|
|
141
142
|
name: mergedProject.name,
|
|
142
143
|
domain: mergedProject.domain,
|
|
144
|
+
timezone: mergedProject.timezone,
|
|
143
145
|
env: mergedProject.env
|
|
144
146
|
});
|
|
145
147
|
projIdx = mergedProject.idx;
|
package/lib/port-resolver.js
CHANGED
|
@@ -25,7 +25,7 @@ class PortResolver {
|
|
|
25
25
|
static getFreePort(startPort, searchSpan, dupCheck) {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
if (searchSpan < 0) {
|
|
28
|
-
throw new Error('unable find port. searchSpan has reached the bottom line');
|
|
28
|
+
throw new Error('unable to find port. searchSpan has reached the bottom line');
|
|
29
29
|
}
|
|
30
30
|
const port = yield (0, portfinder_1.getPortPromise)({
|
|
31
31
|
port: startPort,
|
|
@@ -41,9 +41,10 @@ class PortResolver {
|
|
|
41
41
|
return port;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
static getPort(feature, type, name = '', duplicateCheck = true, searchSpan = 20, fallbackNeeded = true) {
|
|
44
|
+
static getPort(feature, type, name = '', duplicateCheck = true, pythonBio = false, searchSpan = 20, fallbackNeeded = true) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
let port = parseInt(runtime_store_1.default.get(`context.port.${type}.${feature}.${name}`), 10);
|
|
47
|
+
feature = pythonBio ? 'advancedio' : feature;
|
|
47
48
|
port = isNaN(port) ? parseInt(runtime_store_1.default.get(`context.port.${type}.${feature}`), 10) : port;
|
|
48
49
|
if (isNaN(port)) {
|
|
49
50
|
if (type === 'debug' && feature === 'client') {
|
|
@@ -64,7 +65,7 @@ class PortResolver {
|
|
|
64
65
|
}
|
|
65
66
|
let finalPort = port;
|
|
66
67
|
try {
|
|
67
|
-
finalPort = yield PortResolver.getFreePort(port, searchSpan, duplicateCheck);
|
|
68
|
+
finalPort = yield PortResolver.getFreePort(port, searchSpan, duplicateCheck || pythonBio);
|
|
68
69
|
}
|
|
69
70
|
catch (e) {
|
|
70
71
|
if (searchSpan === 0) {
|
|
@@ -19,7 +19,7 @@ const fs_1 = require("../../util_modules/fs");
|
|
|
19
19
|
const ansi_colors_1 = require("ansi-colors");
|
|
20
20
|
function getPaths(rootPath, pattern, exclude, defaultItem) {
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const nodeList = yield fs_1.ASYNC.walk(rootPath, { exclude, excludeDir: false });
|
|
22
|
+
const nodeList = yield fs_1.ASYNC.walk(rootPath, { filter: { exclude, excludeDir: false } });
|
|
23
23
|
const filteredNodes = fuzzy_1.default.filter(pattern || '', nodeList).map((e) => e.string);
|
|
24
24
|
if (!pattern && defaultItem) {
|
|
25
25
|
filteredNodes.unshift(defaultItem);
|
|
@@ -27,6 +27,8 @@ const logger_1 = require("../../../util_modules/logger");
|
|
|
27
27
|
const project_1 = require("../../../util_modules/project");
|
|
28
28
|
const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/runtime"));
|
|
29
29
|
const error_1 = __importDefault(require("../../../error"));
|
|
30
|
+
const python_1 = require("../../../fn-utils/lib/python");
|
|
31
|
+
const throbber_1 = __importDefault(require("../../../throbber"));
|
|
30
32
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
33
|
const fnAPI = yield (0, endpoints_1.functionsAPI)();
|
|
32
34
|
const fnDirName = config_1.functionsConfig.source();
|
|
@@ -99,14 +101,18 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
99
101
|
if (js_1.JS.isEmpty(targets)) {
|
|
100
102
|
return;
|
|
101
103
|
}
|
|
104
|
+
const throbber = throbber_1.default.getInstance();
|
|
102
105
|
targets.forEach((fn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
106
|
if (dirOverwriteAns[fn.name]) {
|
|
104
107
|
yield fs_1.ASYNC.deleteDir(fn.source);
|
|
105
108
|
}
|
|
109
|
+
throbber.add('function_pull_' + fn.name, {
|
|
110
|
+
text: `extracting function [${fn.name}]`
|
|
111
|
+
});
|
|
106
112
|
}));
|
|
107
113
|
runtime_store_1.default.set('context.functions.targets', targets);
|
|
108
114
|
targets = yield Promise.all(targets.map((fn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
-
var _a, _b;
|
|
115
|
+
var _a, _b, _c;
|
|
110
116
|
yield fs_1.ASYNC.ensureDir(fn.source);
|
|
111
117
|
const buffer = (yield fnAPI.download(fn.id));
|
|
112
118
|
yield new archiver_1.default().load(buffer).extract((0, path_1.join)(fnDirPath, fn.name)).finalize();
|
|
@@ -116,14 +122,41 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
116
122
|
else if ((_b = fn.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java)) {
|
|
117
123
|
yield (0, languages_1.java)(fn);
|
|
118
124
|
}
|
|
125
|
+
else if ((_c = fn.stack) === null || _c === void 0 ? void 0 : _c.startsWith(runtime_1.default.language.python)) {
|
|
126
|
+
yield (0, languages_1.python)(fn);
|
|
127
|
+
const reqFile = (0, path_1.join)(fn.source, constants_1.FILENAME.functions.python_requirements);
|
|
128
|
+
const requirementsExists = yield fs_1.ASYNC.readFile(reqFile);
|
|
129
|
+
if (requirementsExists && fn.valid) {
|
|
130
|
+
try {
|
|
131
|
+
yield (0, python_1.removeRequirements)(reqFile, fn);
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
const err = error_1.default.getErrorInstance(e);
|
|
135
|
+
(fn.valid = false), (fn.failure_reason = err.message);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const catalystJsonPth = (0, path_1.join)(fn.source, constants_1.FILENAME.catalyst_config);
|
|
140
|
+
const catalystJson = yield fs_1.ASYNC.readJSONFile(catalystJsonPth);
|
|
141
|
+
const fnDetails = (yield fnAPI.getFunction(fn.id));
|
|
142
|
+
const envVariables = js_1.JS.get(fnDetails, 'configuration.environment.variables', false);
|
|
143
|
+
if (catalystJson && envVariables) {
|
|
144
|
+
catalystJson.deployment.env_variables = envVariables;
|
|
145
|
+
yield fs_1.ASYNC.writeJSONFile(catalystJsonPth, catalystJson);
|
|
146
|
+
}
|
|
147
|
+
throbber.remove('function_pull_' + fn.name);
|
|
119
148
|
return fn;
|
|
120
149
|
})));
|
|
121
150
|
targets = targets.filter((target) => {
|
|
122
|
-
|
|
151
|
+
var _a, _b;
|
|
152
|
+
if (!target.valid && !((_a = target.failure_reason) === null || _a === void 0 ? void 0 : _a.startsWith('unable to locate python'))) {
|
|
123
153
|
(0, logger_1.debug)('Invalid target : ' + target.name + ' reason : ' + target.failure_reason);
|
|
124
154
|
(0, logger_1.warning)(`skipping pull of function(${target.name}) since the package is invalid. \nContact catalyst support with debug log.`);
|
|
125
155
|
new error_1.default('invalid package: ' + target.name, { exit: 2 });
|
|
126
156
|
}
|
|
157
|
+
else if (!target.valid && ((_b = target.failure_reason) === null || _b === void 0 ? void 0 : _b.startsWith('unable to locate python'))) {
|
|
158
|
+
(0, logger_1.warning)(`skipping pull of function(${target.name}) since ${target.failure_reason}`);
|
|
159
|
+
}
|
|
127
160
|
return target.valid;
|
|
128
161
|
});
|
|
129
162
|
runtime_store_1.default.set('payload.functions.targets', targets);
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.java = exports.node = void 0;
|
|
12
|
+
exports.python = exports.java = exports.node = void 0;
|
|
13
13
|
const fn_utils_1 = require("../../../fn-utils");
|
|
14
14
|
const js_1 = require("../../../util_modules/js");
|
|
15
15
|
function node(target) {
|
|
@@ -26,3 +26,10 @@ function java(target) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
exports.java = java;
|
|
29
|
+
function python(target) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const refinedTargets = yield fn_utils_1.fnUtils.common.refineTargets([target.source]);
|
|
32
|
+
yield fn_utils_1.fnUtils.python.validate([js_1.JS.assignIn(target, refinedTargets[0])], 0);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.python = python;
|
package/lib/readLineUtils.js
CHANGED
|
@@ -1 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
// 'use strict';
|
|
2
|
+
|
|
3
|
+
// var _ = require('lodash');
|
|
4
|
+
// var clc = require('ansi-colors');
|
|
5
|
+
|
|
6
|
+
// var utils = require('./utils');
|
|
7
|
+
|
|
8
|
+
// module.exports = {
|
|
9
|
+
// splitLineIntoArray: function(line) {
|
|
10
|
+
// var lineArr = [];
|
|
11
|
+
// var words = line.split(' ');
|
|
12
|
+
// if (!words.length) {
|
|
13
|
+
// return lineArr;
|
|
14
|
+
// }
|
|
15
|
+
// var fullWord = '';
|
|
16
|
+
// var pushReady = true;
|
|
17
|
+
// _.forEach(words, function(value) {
|
|
18
|
+
// if (value.startsWith('"')) {
|
|
19
|
+
// pushReady = false;
|
|
20
|
+
// }
|
|
21
|
+
// if (value.endsWith('"')) {
|
|
22
|
+
// pushReady = true;
|
|
23
|
+
// }
|
|
24
|
+
// var word = _.replace(value, /"/g, '');
|
|
25
|
+
// fullWord =
|
|
26
|
+
// (word !== ' ' || word !== '') && fullWord === '' ? word : fullWord + ' ' + word;
|
|
27
|
+
// if (pushReady && fullWord) {
|
|
28
|
+
// lineArr.push(fullWord);
|
|
29
|
+
// fullWord = '';
|
|
30
|
+
// }
|
|
31
|
+
// });
|
|
32
|
+
// return lineArr;
|
|
33
|
+
// },
|
|
34
|
+
// displayHelp: function(message) {
|
|
35
|
+
// utils.logWarning('Anomaly Detected. ' + clc.redBright(message));
|
|
36
|
+
// }
|
|
37
|
+
// };
|
|
@@ -1 +1,175 @@
|
|
|
1
|
-
|
|
1
|
+
// 'use strict';
|
|
2
|
+
|
|
3
|
+
// var _ = require('lodash');
|
|
4
|
+
// var clc = require('cli-color');
|
|
5
|
+
// var readline = require('readline');
|
|
6
|
+
|
|
7
|
+
// var endpoints = require('../../endpoints');
|
|
8
|
+
// var logger = require('../../logger');
|
|
9
|
+
// var utils = require('../../utils');
|
|
10
|
+
// var readlineUtil = require('../../readLineUtils');
|
|
11
|
+
|
|
12
|
+
// var outputStream = process.stdout;
|
|
13
|
+
// var inputStream = process.stdin;
|
|
14
|
+
|
|
15
|
+
// module.exports = function(options) {
|
|
16
|
+
// var state = 0;
|
|
17
|
+
// var segment = '';
|
|
18
|
+
// const cacheAPI = endpoints(options).cache();
|
|
19
|
+
// return new Promise(function(resolve) {
|
|
20
|
+
// var prompt = clc.cyanBright('cache > ');
|
|
21
|
+
|
|
22
|
+
// function completer(line) {
|
|
23
|
+
// var completions = 'list use set get'.split(' ');
|
|
24
|
+
// var hits = completions.filter(function(c) {
|
|
25
|
+
// c.startsWith(line);
|
|
26
|
+
// });
|
|
27
|
+
// // show all completions if none found
|
|
28
|
+
// return [hits.length ? hits : completions, line];
|
|
29
|
+
// }
|
|
30
|
+
// // function completer(line) {
|
|
31
|
+
// // var completions = ['use ', 'GET '];
|
|
32
|
+
// // var lineArr = line.trim().split(' ');
|
|
33
|
+
// // if (lineArr[(lineArr.length) - 1] !== '') {
|
|
34
|
+
// // switch (lineArr[(lineArr.length) - 1]) {
|
|
35
|
+
// // case 'use':
|
|
36
|
+
// // // completions[0] = completions[0] + 'segment ';
|
|
37
|
+
// // completions.pop();
|
|
38
|
+
// // completions.push('segment ');
|
|
39
|
+
// // break;
|
|
40
|
+
// // default:
|
|
41
|
+
// // completions = [];
|
|
42
|
+
// // }
|
|
43
|
+
// // var hits = completions.filter((c) => line.startsWith(c) || line.endsWith(c));
|
|
44
|
+
// // return [hits, line];
|
|
45
|
+
// // }
|
|
46
|
+
// // return [completions, line];
|
|
47
|
+
// // }
|
|
48
|
+
// var rl = readline.createInterface({
|
|
49
|
+
// input: inputStream,
|
|
50
|
+
// output: outputStream,
|
|
51
|
+
// prompt: prompt,
|
|
52
|
+
// completer: completer
|
|
53
|
+
// });
|
|
54
|
+
|
|
55
|
+
// rl.prompt();
|
|
56
|
+
|
|
57
|
+
// rl.on('line', function(line) {
|
|
58
|
+
// var originalLine = line.trim();
|
|
59
|
+
// var lineArr = readlineUtil.splitLineIntoArray(originalLine);
|
|
60
|
+
// return new Promise(function(resolve) {
|
|
61
|
+
// switch (true) {
|
|
62
|
+
// case /^exit/i.test(originalLine):
|
|
63
|
+
// case /\\q/i.test(originalLine):
|
|
64
|
+
// rl.close();
|
|
65
|
+
// break;
|
|
66
|
+
// case /^list/i.test(originalLine):
|
|
67
|
+
// return cacheAPI
|
|
68
|
+
// .listSegments(options.project)
|
|
69
|
+
// .then(function(data) {
|
|
70
|
+
// _.forEach(data, function(segment, index) {
|
|
71
|
+
// logger.info(
|
|
72
|
+
// index +
|
|
73
|
+
// 1 +
|
|
74
|
+
// '. ' +
|
|
75
|
+
// clc.bold(segment.segment_name) +
|
|
76
|
+
// ' ( ' +
|
|
77
|
+
// segment.id +
|
|
78
|
+
// ' )'
|
|
79
|
+
// );
|
|
80
|
+
// });
|
|
81
|
+
// return resolve();
|
|
82
|
+
// })
|
|
83
|
+
// .catch(function(err) {
|
|
84
|
+
// logger.debug('There was an error processing the request.' + err);
|
|
85
|
+
// logger.info(clc.redBright("couldn't fetch segment details"));
|
|
86
|
+
// return resolve();
|
|
87
|
+
// });
|
|
88
|
+
// case /^use/i.test(originalLine):
|
|
89
|
+
// var segmentID = lineArr[lineArr.length - 1];
|
|
90
|
+
// if ((lineArr.length = 2 && /^[0-9]*$/gm.test(segmentID))) {
|
|
91
|
+
// segment = segmentID;
|
|
92
|
+
// state = 1;
|
|
93
|
+
// rl.setPrompt(clc.cyanBright('cache:' + segment + ' > '));
|
|
94
|
+
// return resolve();
|
|
95
|
+
// } else {
|
|
96
|
+
// readlineUtil.displayHelp('Segment ID not valid.');
|
|
97
|
+
// return resolve();
|
|
98
|
+
// }
|
|
99
|
+
// case /^get/i.test(line):
|
|
100
|
+
// if (state === 0) {
|
|
101
|
+
// utils.logWarning('Trying to get data from default segment', 'info');
|
|
102
|
+
// }
|
|
103
|
+
// if (lineArr.length === 2) {
|
|
104
|
+
// var cachekey = lineArr[lineArr.length - 1];
|
|
105
|
+
// return cacheAPI
|
|
106
|
+
// .get(options.project, segment, cachekey)
|
|
107
|
+
// .then(function(data) {
|
|
108
|
+
// data.cache_value
|
|
109
|
+
// ? logger.info('"' + clc.greenBright(data.cache_value) + '"')
|
|
110
|
+
// : logger.info('(' + clc.redBright('nil') + ')');
|
|
111
|
+
// return resolve();
|
|
112
|
+
// })
|
|
113
|
+
// .catch(function(err) {
|
|
114
|
+
// logger.error(
|
|
115
|
+
// 'There was an error processing the request.' + err
|
|
116
|
+
// );
|
|
117
|
+
// logger.info('(' + clc.redBright('error') + ')');
|
|
118
|
+
// return resolve();
|
|
119
|
+
// });
|
|
120
|
+
// } else {
|
|
121
|
+
// readlineUtil.displayHelp('Key Name not valid.');
|
|
122
|
+
// return resolve();
|
|
123
|
+
// }
|
|
124
|
+
// case /^set/i.test(line):
|
|
125
|
+
// if (state === 0) {
|
|
126
|
+
// utils.logWarning('Trying to put data to default segment', 'info');
|
|
127
|
+
// }
|
|
128
|
+
// if (lineArr.length === 3) {
|
|
129
|
+
// var data = {};
|
|
130
|
+
// data.key = lineArr[lineArr.length - 2];
|
|
131
|
+
// data.value = lineArr[lineArr.length - 1];
|
|
132
|
+
// return cacheAPI
|
|
133
|
+
// .put(options.project, segment, data)
|
|
134
|
+
// .then(function(data) {
|
|
135
|
+
// if (data) {
|
|
136
|
+
// logger.info(clc.greenBright('OK'));
|
|
137
|
+
// }
|
|
138
|
+
// return resolve();
|
|
139
|
+
// })
|
|
140
|
+
// .catch(function(err) {
|
|
141
|
+
// logger.debug(
|
|
142
|
+
// 'There was an error processing the request.' + err
|
|
143
|
+
// );
|
|
144
|
+
// logger.info('(' + clc.redBright('error') + ')');
|
|
145
|
+
// return resolve();
|
|
146
|
+
// });
|
|
147
|
+
// } else {
|
|
148
|
+
// readlineUtil.displayHelp('Key or Value not valid.');
|
|
149
|
+
// return resolve();
|
|
150
|
+
// }
|
|
151
|
+
// case /^help/i.test(originalLine):
|
|
152
|
+
// case /^\\h/i.test(originalLine):
|
|
153
|
+
// utils.logBullet(
|
|
154
|
+
// 'Available commands :\t ' + clc.bold('list, use, get, set, exit')
|
|
155
|
+
// );
|
|
156
|
+
// return resolve();
|
|
157
|
+
// default:
|
|
158
|
+
// logger.info(
|
|
159
|
+
// `We might have heard '${clc.bold(
|
|
160
|
+
// line.trim()
|
|
161
|
+
// )}'\n which is an unknown command!! Use '${clc.bold(
|
|
162
|
+
// 'help'
|
|
163
|
+
// )}' for the list of commands you can use.`
|
|
164
|
+
// );
|
|
165
|
+
// return resolve();
|
|
166
|
+
// }
|
|
167
|
+
// }).then(function() {
|
|
168
|
+
// rl.prompt();
|
|
169
|
+
// });
|
|
170
|
+
// }).on('close', function() {
|
|
171
|
+
// logger.info('Have a great day!');
|
|
172
|
+
// return resolve();
|
|
173
|
+
// });
|
|
174
|
+
// });
|
|
175
|
+
// };
|