zcatalyst-cli 1.15.0-beta.4 → 1.15.0-beta.6
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/lib/archiver.js +8 -3
- package/lib/client-utils.js +5 -1
- package/lib/commands/iac/pack.js +9 -8
- package/lib/deploy/features/appsail/index.js +15 -5
- package/lib/deploy/features/client.js +1 -1
- package/lib/deploy/features/functions/index.js +7 -4
- package/lib/endpoints/lib/applogic.js +14 -2
- package/lib/endpoints/lib/appsail.js +11 -2
- package/lib/endpoints/lib/client.js +11 -2
- package/lib/endpoints/lib/functions.js +14 -2
- package/lib/endpoints/lib/sdk.js +8 -5
- package/lib/express_middlewares/logger.js +6 -2
- package/lib/fn-utils/lib/common.js +78 -48
- package/lib/fn-utils/lib/integ.js +23 -13
- package/lib/fn-utils/lib/java.js +28 -29
- package/lib/fn-utils/lib/node.js +17 -1
- package/lib/fn-utils/lib/python.js +1 -1
- package/lib/init/features/appsail/index.js +2 -2
- package/lib/init/features/functions/index.js +10 -4
- package/lib/init/features/functions/languages/java.js +2 -17
- package/lib/init/features/functions/languages/node.js +2 -17
- package/lib/init/features/project.js +1 -1
- package/lib/internal/api.js +33 -8
- package/lib/option-filter.js +4 -4
- package/lib/port-resolver.js +24 -11
- package/lib/progress.js +3 -2
- package/lib/prompt/types/file-path.js +3 -1
- package/lib/serve/features/appsail.js +14 -3
- package/lib/serve/features/index.js +1 -1
- package/lib/serve/index.js +7 -2
- package/lib/serve/server/index.js +252 -92
- package/lib/serve/server/lib/appsail/index.js +19 -9
- package/lib/serve/server/lib/appsail/start.js +4 -15
- package/lib/serve/server/lib/master.js +10 -10
- package/lib/serve/server/lib/web_client/index.js +5 -5
- package/lib/shell/dependencies/http-functions.js +11 -15
- package/lib/shell/prepare/languages/java.js +9 -4
- package/lib/util_modules/constants/lib/default.js +4 -1
- package/lib/util_modules/constants/lib/integ.js +4 -2
- package/lib/util_modules/constants/lib/scopes.js +1 -0
- package/lib/util_modules/constants/lib/template.js +23 -20
- package/lib/util_modules/fs/lib/async.js +10 -9
- package/lib/util_modules/fs/lib/sync.js +5 -1
- package/package.json +1 -1
- package/templates/init/functions/java/aio/sample.java +14 -4
- package/templates/init/functions/java/integ/convokraft/.classpath +6 -0
- package/templates/init/functions/java/integ/convokraft/.project +17 -0
- package/templates/init/functions/java/integ/convokraft/ExecuteHandler.java +20 -0
- package/templates/init/functions/java/integ/convokraft/FailureHandler.java +20 -0
- package/templates/init/functions/java/integ/convokraft/FallbackHandler.java +13 -0
- package/templates/init/functions/java/integ/convokraft/PromptHandler.java +17 -0
- package/templates/init/functions/java/integ/convokraft/Sample.java +62 -0
- package/templates/init/functions/java/integ/convokraft/WelcomeHandler.java +22 -0
- package/templates/init/functions/java/integ/convokraft/catalyst-config.json +12 -0
- package/templates/init/functions/node/integ/convokraft/catalyst-config.json +12 -0
- package/templates/init/functions/node/integ/convokraft/execute.js +16 -0
- package/templates/init/functions/node/integ/convokraft/failure.js +10 -0
- package/templates/init/functions/node/integ/convokraft/fallback.js +11 -0
- package/templates/init/functions/node/integ/convokraft/integ-response.js +13 -0
- package/templates/init/functions/node/integ/convokraft/logger.js +9 -0
- package/templates/init/functions/node/integ/convokraft/package.json +10 -0
- package/templates/init/functions/node/integ/convokraft/prompt.js +19 -0
- package/templates/init/functions/node/integ/convokraft/sample.js +46 -0
- package/templates/init/functions/node/integ/convokraft/welcome.js +12 -0
- package/templates/init/functions/python/integ/cliq/catalyst-config.json +2 -1
- package/templates/init/functions/python/integ/convokraft/catalyst-config.json +12 -0
- package/templates/init/functions/python/integ/convokraft/execute_handler.py +17 -0
- package/templates/init/functions/python/integ/convokraft/failure_handler.py +15 -0
- package/templates/init/functions/python/integ/convokraft/fallback_handler.py +16 -0
- package/templates/init/functions/python/integ/convokraft/prompt_handler.py +18 -0
- package/templates/init/functions/python/integ/convokraft/requirements.txt +1 -0
- package/templates/init/functions/python/integ/convokraft/sample.py +36 -0
- package/templates/init/functions/python/integ/convokraft/welcome_handler.py +19 -0
package/lib/archiver.js
CHANGED
|
@@ -179,9 +179,12 @@ class Archiver {
|
|
|
179
179
|
getUnixPath(pth) {
|
|
180
180
|
return pth.split(path_1.sep).join('/');
|
|
181
181
|
}
|
|
182
|
-
add(pth, content, { createFolders = true } = {}) {
|
|
182
|
+
add(pth, content, { createFolders = true, mode } = {}) {
|
|
183
183
|
this.promiseArr.push(this.jszip.then((zip) => {
|
|
184
|
-
return zip.file(this.getUnixPath(pth), content, {
|
|
184
|
+
return zip.file(this.getUnixPath(pth), content, {
|
|
185
|
+
createFolders,
|
|
186
|
+
unixPermissions: mode
|
|
187
|
+
});
|
|
185
188
|
}));
|
|
186
189
|
return this;
|
|
187
190
|
}
|
|
@@ -223,18 +226,20 @@ class Archiver {
|
|
|
223
226
|
const zip = yield this.jszip;
|
|
224
227
|
const content = yield zip.generateAsync({
|
|
225
228
|
type: 'nodebuffer',
|
|
229
|
+
platform: 'UNIX',
|
|
226
230
|
compression: 'DEFLATE',
|
|
227
231
|
compressionOptions: {
|
|
228
232
|
level: 9
|
|
229
233
|
}
|
|
230
234
|
});
|
|
231
235
|
yield fs_1.ASYNC.writeFile(tempFilePath, content);
|
|
232
|
-
return fs_1.SYNC.getReadStream(tempFilePath);
|
|
236
|
+
return { stream: fs_1.SYNC.getReadStream(tempFilePath), length: content.length };
|
|
233
237
|
}),
|
|
234
238
|
writeZip: (pth) => __awaiter(this, void 0, void 0, function* () {
|
|
235
239
|
const zip = yield this.jszip;
|
|
236
240
|
const content = yield zip.generateAsync({
|
|
237
241
|
type: 'nodebuffer',
|
|
242
|
+
platform: 'UNIX',
|
|
238
243
|
compression: 'DEFLATE',
|
|
239
244
|
compressionOptions: {
|
|
240
245
|
level: 9
|
package/lib/client-utils.js
CHANGED
|
@@ -171,7 +171,11 @@ exports.clientUtils = {
|
|
|
171
171
|
const files = yield fs_1.ASYNC.walk(source, { filter: { exclude, excludeDir: true } });
|
|
172
172
|
const zip = new archiver_1.default();
|
|
173
173
|
files.forEach((file) => {
|
|
174
|
-
zip.add(file.replace(source + path_1.sep, ''),
|
|
174
|
+
zip.add(file.path.replace(source + path_1.sep, ''), file.stats.isSymbolicLink()
|
|
175
|
+
? fs_1.SYNC.readSymLink(file.path)
|
|
176
|
+
: fs_1.SYNC.getReadStream(file.path), {
|
|
177
|
+
mode: file.stats.mode
|
|
178
|
+
});
|
|
175
179
|
});
|
|
176
180
|
const zipFinalizer = yield zip.finalize();
|
|
177
181
|
return zipFinalizer.fsStream();
|
package/lib/commands/iac/pack.js
CHANGED
|
@@ -55,14 +55,14 @@ exports.default = new command_1.default('iac:pack [zip_name]')
|
|
|
55
55
|
.needs('auth')
|
|
56
56
|
.needs('config')
|
|
57
57
|
.action((userZipName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
-
var _a, _b;
|
|
58
|
+
var _a, _b, _c;
|
|
59
59
|
const config = runtime_store_1.default.get('config');
|
|
60
60
|
const rootDir = (0, path_1.dirname)(config.configPath);
|
|
61
61
|
const filesAtRoot = yield fs_1.ASYNC.walk(rootDir, {
|
|
62
62
|
filter: { excludeDir: true, exclude: [] },
|
|
63
63
|
depth: 1
|
|
64
64
|
});
|
|
65
|
-
const templateFilePth = filesAtRoot.find((
|
|
65
|
+
const templateFilePth = (_a = filesAtRoot.find((file) => file.path.match(constants_1.REGEX.project.template))) === null || _a === void 0 ? void 0 : _a.path;
|
|
66
66
|
if (templateFilePth === undefined) {
|
|
67
67
|
throw new error_1.default('No template file found', { exit: 1 });
|
|
68
68
|
}
|
|
@@ -71,8 +71,8 @@ exports.default = new command_1.default('iac:pack [zip_name]')
|
|
|
71
71
|
throw new error_1.default('Unable to read template file', { exit: 1 });
|
|
72
72
|
}
|
|
73
73
|
const templateJson = js_1.JS.parseJSON(templateFile) || (0, yaml_1.parse)(templateFile);
|
|
74
|
-
const templateFns = ((
|
|
75
|
-
const templateClient = ((
|
|
74
|
+
const templateFns = ((_b = templateJson.components) === null || _b === void 0 ? void 0 : _b.Functions) || [];
|
|
75
|
+
const templateClient = ((_c = templateJson.components) === null || _c === void 0 ? void 0 : _c.WebClient) || [];
|
|
76
76
|
const hrTime = process.hrtime();
|
|
77
77
|
const archiveName = (userZipName === null || userZipName === void 0 ? void 0 : userZipName.replace('.zip', '')) || `iac_${hrTime[0] * 1000000000 + hrTime[1]}`;
|
|
78
78
|
const finalZip = new archiver_1.default(archiveName);
|
|
@@ -114,21 +114,22 @@ exports.default = new command_1.default('iac:pack [zip_name]')
|
|
|
114
114
|
...(packedPythonFns || [])
|
|
115
115
|
];
|
|
116
116
|
packedFns.forEach((fn) => {
|
|
117
|
+
var _a;
|
|
117
118
|
if (!fn.valid) {
|
|
118
119
|
throw new error_1.default(`Unable to pack since "${fn.name}" is not valid. Reason: ${fn.failure_reason}`);
|
|
119
120
|
}
|
|
120
|
-
finalZip.add(fnNameByCodePath[fn.name], fn.zip_stream);
|
|
121
|
+
finalZip.add(fnNameByCodePath[fn.name], (_a = fn.zip_stream) === null || _a === void 0 ? void 0 : _a.stream);
|
|
121
122
|
});
|
|
122
123
|
break;
|
|
123
124
|
case 'client':
|
|
124
125
|
yield client_utils_1.clientUtils.validate();
|
|
125
126
|
const clientName = runtime_store_1.default.get('context.client.name');
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
127
|
+
const clientTemplateConfig = templateClient.find((tClient) => clientName === tClient.properties.app_name);
|
|
128
|
+
if (!clientTemplateConfig) {
|
|
128
129
|
throw new error_1.default(`No property found for client ${clientName} in project template`, { exit: 1 });
|
|
129
130
|
}
|
|
130
131
|
const clientZipStream = yield client_utils_1.clientUtils.pack();
|
|
131
|
-
finalZip.add(
|
|
132
|
+
finalZip.add(clientTemplateConfig.properties.code.path, clientZipStream.stream);
|
|
132
133
|
break;
|
|
133
134
|
default:
|
|
134
135
|
(0, logger_1.debug)(`skipping ${component} since there is no processing needed`);
|
|
@@ -30,6 +30,7 @@ const logger_1 = require("../../../util_modules/logger");
|
|
|
30
30
|
const option_1 = require("../../../util_modules/option");
|
|
31
31
|
const project_1 = require("../../../util_modules/project");
|
|
32
32
|
const utils_1 = require("./utils");
|
|
33
|
+
const throbber_1 = __importDefault(require("../../../throbber"));
|
|
33
34
|
function executeHook(script, name, moduleSource) {
|
|
34
35
|
if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
|
|
35
36
|
(0, logger_1.debug)(`skipping ${name} hook`);
|
|
@@ -175,6 +176,7 @@ exports.default = (standAlone = false) => __awaiter(void 0, void 0, void 0, func
|
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
const sailAPI = yield (0, endpoints_1.appSailAPI)();
|
|
179
|
+
const throbber = throbber_1.default.getInstance();
|
|
178
180
|
const deployRes = yield validTargets.reduce((result, _targ) => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
181
|
var _a, _b;
|
|
180
182
|
const targ = _targ.appSail;
|
|
@@ -183,6 +185,10 @@ exports.default = (standAlone = false) => __awaiter(void 0, void 0, void 0, func
|
|
|
183
185
|
if ((_a = targ.scripts) === null || _a === void 0 ? void 0 : _a.predeploy) {
|
|
184
186
|
executeHook(targ.scripts.predeploy, 'predeploy', targ.source);
|
|
185
187
|
}
|
|
188
|
+
const throbberName = `prepare_appsail_${targ.name}`;
|
|
189
|
+
throbber.add(throbberName, {
|
|
190
|
+
text: `Preparing AppSail[${targ.name}]`
|
|
191
|
+
});
|
|
186
192
|
const zip = new archiver_1.default();
|
|
187
193
|
const folderPath = (0, project_1.resolveProjectPath)(targ.buildPath);
|
|
188
194
|
const ignoreFile = yield fs_1.ASYNC.readFile((0, path_1.join)(folderPath, constants_1.FILENAME.catalyst_ignore));
|
|
@@ -199,20 +205,24 @@ exports.default = (standAlone = false) => __awaiter(void 0, void 0, void 0, func
|
|
|
199
205
|
}
|
|
200
206
|
});
|
|
201
207
|
folderContents.forEach((content) => {
|
|
202
|
-
zip.add(content === folderPath
|
|
203
|
-
? (0, path_1.basename)(content)
|
|
204
|
-
: content.replace(folderPath + path_1.sep, ''),
|
|
208
|
+
zip.add(content.path === folderPath
|
|
209
|
+
? (0, path_1.basename)(content.path)
|
|
210
|
+
: content.path.replace(folderPath + path_1.sep, ''), content.stats.isSymbolicLink()
|
|
211
|
+
? fs_1.SYNC.readSymLink(content.path)
|
|
212
|
+
: fs_1.SYNC.getReadStream(content.path), { mode: content.stats.mode });
|
|
205
213
|
});
|
|
206
214
|
const finalized = yield zip.finalize();
|
|
207
215
|
const zipStream = yield finalized.fsStream();
|
|
216
|
+
throbber.remove(throbberName);
|
|
208
217
|
const { stack, name, command, memory, platform, env_variables } = targ;
|
|
209
|
-
const apiRes = yield sailAPI.deploy(zipStream, {
|
|
218
|
+
const apiRes = yield sailAPI.deploy(zipStream.stream, {
|
|
210
219
|
stack,
|
|
211
220
|
name,
|
|
212
221
|
memory,
|
|
213
222
|
platform,
|
|
214
223
|
command,
|
|
215
|
-
envVariables: env_variables
|
|
224
|
+
envVariables: env_variables,
|
|
225
|
+
contentLength: zipStream.length
|
|
216
226
|
});
|
|
217
227
|
_targ.url = apiRes.url;
|
|
218
228
|
if ((_b = targ.scripts) === null || _b === void 0 ? void 0 : _b.postdeploy) {
|
|
@@ -20,7 +20,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
20
20
|
client_utils_1.clientUtils.executeHook({ prefix: 'pre', command: 'deploy' });
|
|
21
21
|
yield client_utils_1.clientUtils.validate();
|
|
22
22
|
const readStream = yield client_utils_1.clientUtils.pack();
|
|
23
|
-
const resp = (yield (yield (0, endpoints_1.clientAPI)()).deploy(readStream));
|
|
23
|
+
const resp = (yield (yield (0, endpoints_1.clientAPI)()).deploy(readStream.stream, readStream.length));
|
|
24
24
|
const homepage = runtime_store_1.default.get('context.client.homepage', '');
|
|
25
25
|
runtime_store_1.default.set('payload.client.url', 'https://' +
|
|
26
26
|
resp.url_prefix +
|
|
@@ -56,17 +56,19 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
56
56
|
const limit = combinedTarget.length > batchSize ? batchSize : combinedTarget.length;
|
|
57
57
|
const targetBatch = combinedTarget.splice(0, limit);
|
|
58
58
|
yield Promise.all(targetBatch.map((target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
59
60
|
if (!target) {
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
try {
|
|
63
64
|
let resp;
|
|
64
65
|
if (target.type !== undefined && target.type === constants_1.FN_TYPE.advanced) {
|
|
65
|
-
resp = (yield appAPI.deploy(target.zip_stream, {
|
|
66
|
+
resp = (yield appAPI.deploy((_a = target.zip_stream) === null || _a === void 0 ? void 0 : _a.stream, {
|
|
66
67
|
stack: target.stack,
|
|
67
68
|
name: target.name,
|
|
68
69
|
memory: target.memory,
|
|
69
|
-
envVariables: target.env_var
|
|
70
|
+
envVariables: target.env_var,
|
|
71
|
+
contentLength: (_b = target.zip_stream) === null || _b === void 0 ? void 0 : _b.length
|
|
70
72
|
}));
|
|
71
73
|
}
|
|
72
74
|
else {
|
|
@@ -74,7 +76,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
74
76
|
stack: target.stack,
|
|
75
77
|
name: target.name,
|
|
76
78
|
type: constants_1.REMOTE_REF.functions.type[target.type],
|
|
77
|
-
envVariables: target.env_var
|
|
79
|
+
envVariables: target.env_var,
|
|
80
|
+
contentLength: (_c = target.zip_stream) === null || _c === void 0 ? void 0 : _c.length
|
|
78
81
|
};
|
|
79
82
|
if (target.type === constants_1.FN_TYPE.browserLogic && !target.memory && !target.id) {
|
|
80
83
|
deployOptions.memory = 512;
|
|
@@ -82,7 +85,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
82
85
|
else {
|
|
83
86
|
deployOptions.memory = target.memory;
|
|
84
87
|
}
|
|
85
|
-
resp = (yield fnAPI.deploy(target.zip_stream, deployOptions));
|
|
88
|
+
resp = (yield fnAPI.deploy((_d = target.zip_stream) === null || _d === void 0 ? void 0 : _d.stream, deployOptions));
|
|
86
89
|
}
|
|
87
90
|
target.id = resp.id + '';
|
|
88
91
|
fn_utils_1.fnUtils.common.generateUrlForTarget(target);
|
|
@@ -20,7 +20,7 @@ class Applogic {
|
|
|
20
20
|
this.opts = opts;
|
|
21
21
|
this.projectId = projectId;
|
|
22
22
|
}
|
|
23
|
-
deploy(sourceFsStream, { stack, name, memory, envVariables }) {
|
|
23
|
+
deploy(sourceFsStream, { stack, name, memory, envVariables, contentLength }) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
const formData = {
|
|
26
26
|
stack,
|
|
@@ -41,12 +41,24 @@ class Applogic {
|
|
|
41
41
|
if (Object.keys(configuration).length > 0) {
|
|
42
42
|
formData.configuration = JSON.stringify(configuration);
|
|
43
43
|
}
|
|
44
|
+
const log = contentLength
|
|
45
|
+
? {
|
|
46
|
+
uploadProgress: {
|
|
47
|
+
title: `[${name}]`,
|
|
48
|
+
total: contentLength,
|
|
49
|
+
progressType: 'upload'
|
|
50
|
+
},
|
|
51
|
+
stream: sourceFsStream,
|
|
52
|
+
awaitingSpinner: `deploying function [${name}]`
|
|
53
|
+
}
|
|
54
|
+
: undefined;
|
|
44
55
|
const res = yield new api_1.default(this.opts).put(`/baas/v1/project/${this.projectId}/server/upsert`, {
|
|
45
56
|
formData,
|
|
46
57
|
headers: {
|
|
47
58
|
'Content-Type': 'application/zip'
|
|
48
59
|
},
|
|
49
|
-
json: false
|
|
60
|
+
json: false,
|
|
61
|
+
log
|
|
50
62
|
});
|
|
51
63
|
if (res.body && res.body.data) {
|
|
52
64
|
return res.body.data;
|
|
@@ -21,7 +21,7 @@ class AppSail {
|
|
|
21
21
|
this.opts = opts;
|
|
22
22
|
this.projectId = projectId;
|
|
23
23
|
}
|
|
24
|
-
deploy(sourceFsStream, { stack, name, command, memory, platform, envVariables = {} }) {
|
|
24
|
+
deploy(sourceFsStream, { stack, name, contentLength, command, memory, platform, envVariables = {} }) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
const formData = {
|
|
27
27
|
stack,
|
|
@@ -48,7 +48,16 @@ class AppSail {
|
|
|
48
48
|
}
|
|
49
49
|
const res = yield new api_1.default(this.opts).put(`/baas/v1/project/${this.projectId}/appsail/upsert`, {
|
|
50
50
|
formData,
|
|
51
|
-
json: false
|
|
51
|
+
json: false,
|
|
52
|
+
log: {
|
|
53
|
+
uploadProgress: {
|
|
54
|
+
title: `AppSail[${name}]`,
|
|
55
|
+
total: contentLength,
|
|
56
|
+
progressType: 'upload'
|
|
57
|
+
},
|
|
58
|
+
stream: sourceFsStream,
|
|
59
|
+
awaitingSpinner: `deploying Appsail[${name}]`
|
|
60
|
+
}
|
|
52
61
|
});
|
|
53
62
|
if (res.body && res.body.data) {
|
|
54
63
|
return res.body.data;
|
|
@@ -20,13 +20,22 @@ class Client {
|
|
|
20
20
|
this.opts = opts;
|
|
21
21
|
this.projectId = projectId;
|
|
22
22
|
}
|
|
23
|
-
deploy(sourceStream) {
|
|
23
|
+
deploy(sourceStream, contentLength) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
const res = yield new api_1.default(this.opts).post(`/baas/v1/project/${this.projectId}/webapp`, {
|
|
26
26
|
formData: {
|
|
27
27
|
app_zip: sourceStream
|
|
28
28
|
},
|
|
29
|
-
json: false
|
|
29
|
+
json: false,
|
|
30
|
+
log: {
|
|
31
|
+
uploadProgress: {
|
|
32
|
+
title: 'Web_Client',
|
|
33
|
+
total: contentLength,
|
|
34
|
+
progressType: 'upload'
|
|
35
|
+
},
|
|
36
|
+
stream: sourceStream,
|
|
37
|
+
awaitingSpinner: 'deploying Web Client'
|
|
38
|
+
}
|
|
30
39
|
});
|
|
31
40
|
if (res.body && res.body.data) {
|
|
32
41
|
return res.body.data;
|
|
@@ -73,7 +73,7 @@ class Functions {
|
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
deploy(sourceFsStream, { stack, name, type, memory, envVariables }) {
|
|
76
|
+
deploy(sourceFsStream, { stack, name, type, memory, envVariables, contentLength }) {
|
|
77
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
78
|
const formData = {
|
|
79
79
|
stack,
|
|
@@ -95,9 +95,21 @@ class Functions {
|
|
|
95
95
|
if (Object.keys(configuration).length > 0) {
|
|
96
96
|
formData.configuration = JSON.stringify(configuration);
|
|
97
97
|
}
|
|
98
|
+
const log = contentLength
|
|
99
|
+
? {
|
|
100
|
+
uploadProgress: {
|
|
101
|
+
title: `[${name}]`,
|
|
102
|
+
total: contentLength,
|
|
103
|
+
progressType: 'upload'
|
|
104
|
+
},
|
|
105
|
+
stream: sourceFsStream,
|
|
106
|
+
awaitingSpinner: `deploying function [${name}]`
|
|
107
|
+
}
|
|
108
|
+
: undefined;
|
|
98
109
|
const res = yield new api_1.default(this.opts).put(`/baas/v1/project/${this.projectId}/function/upsert`, {
|
|
99
110
|
formData,
|
|
100
|
-
json: false
|
|
111
|
+
json: false,
|
|
112
|
+
log
|
|
101
113
|
});
|
|
102
114
|
if (res.body && res.body.data) {
|
|
103
115
|
return res.body.data;
|
package/lib/endpoints/lib/sdk.js
CHANGED
|
@@ -22,17 +22,20 @@ class SDK {
|
|
|
22
22
|
}
|
|
23
23
|
getSdkUrl(fnType, service) {
|
|
24
24
|
switch (fnType) {
|
|
25
|
+
case constants_1.FN_TYPE.browserLogic: {
|
|
26
|
+
return `/downloads/sdk/java/catalyst_java_sdk_beta.zip`;
|
|
27
|
+
}
|
|
25
28
|
case constants_1.FN_TYPE.integration: {
|
|
26
29
|
if (!service) {
|
|
27
30
|
throw new error_1.default('Invalid integration service');
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
32
|
+
if (service === constants_1.INTEG.services.cliq) {
|
|
33
|
+
return `/downloads/sdk/java/${constants_1.INTEG.service_map[service]}/${constants_1.INTEG.java_dependencies[service]}_latest.zip`;
|
|
34
|
+
}
|
|
35
|
+
return '/downloads/sdk/java/catalyst_java_sdk_beta.zip';
|
|
33
36
|
}
|
|
34
37
|
default: {
|
|
35
|
-
return
|
|
38
|
+
return '/downloads/sdk/java/catalyst_java_sdk_latest.zip';
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ansi_colors_1 = require("ansi-colors");
|
|
4
|
-
exports.default = (req, _RES, next) => {
|
|
4
|
+
exports.default = (appSailDetails) => (req, _RES, next) => {
|
|
5
|
+
var _a, _b;
|
|
5
6
|
console.log('[' +
|
|
6
7
|
new Date().getTime() +
|
|
7
|
-
']' +
|
|
8
|
+
'] ' +
|
|
9
|
+
(appSailDetails
|
|
10
|
+
? (0, ansi_colors_1.cyan)(` Appsail[${(_b = (_a = appSailDetails === null || appSailDetails === void 0 ? void 0 : appSailDetails.target) === null || _a === void 0 ? void 0 : _a.appSail) === null || _b === void 0 ? void 0 : _b.name}] `)
|
|
11
|
+
: '') +
|
|
8
12
|
' "' +
|
|
9
13
|
(0, ansi_colors_1.cyan)(req.method) +
|
|
10
14
|
'" ' +
|
|
@@ -300,14 +300,22 @@ function pack(target) {
|
|
|
300
300
|
const outputFolder = (0, path_1.join)(source, constants_1.FOLDERNAME.output);
|
|
301
301
|
const outputFiles = yield fs_1.ASYNC.walk(outputFolder);
|
|
302
302
|
outputFiles.forEach((file) => {
|
|
303
|
-
zip.add(file.replace(outputFolder + path_1.sep, ''),
|
|
303
|
+
zip.add(file.path.replace(outputFolder + path_1.sep, ''), file.stats.isSymbolicLink()
|
|
304
|
+
? fs_1.SYNC.readSymLink(file.path)
|
|
305
|
+
: fs_1.SYNC.getReadStream(file.path), {
|
|
306
|
+
mode: file.stats.mode
|
|
307
|
+
});
|
|
304
308
|
});
|
|
305
309
|
}
|
|
306
310
|
else {
|
|
307
311
|
const exclude = config_1.functionsConfig.ignore(source);
|
|
308
312
|
const files = yield fs_1.ASYNC.walk(source, { filter: { exclude, excludeDir: true } });
|
|
309
313
|
files.forEach((file) => {
|
|
310
|
-
zip.add(file.replace(source + path_1.sep, ''),
|
|
314
|
+
zip.add(file.path.replace(source + path_1.sep, ''), file.stats.isSymbolicLink()
|
|
315
|
+
? fs_1.SYNC.readSymLink(file.path)
|
|
316
|
+
: fs_1.SYNC.getReadStream(file.path), {
|
|
317
|
+
mode: file.stats.mode
|
|
318
|
+
});
|
|
311
319
|
});
|
|
312
320
|
}
|
|
313
321
|
if ((_b = target.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.python.value)) {
|
|
@@ -320,7 +328,11 @@ function pack(target) {
|
|
|
320
328
|
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, target.stack.replace('python_', ''), true);
|
|
321
329
|
const files = yield fs_1.ASYNC.walk(tmpDir);
|
|
322
330
|
files.forEach((file) => {
|
|
323
|
-
zip.add(file.replace(tmpDir + path_1.sep, ''),
|
|
331
|
+
zip.add(file.path.replace(tmpDir + path_1.sep, ''), file.stats.isSymbolicLink()
|
|
332
|
+
? fs_1.SYNC.readSymLink(file.path)
|
|
333
|
+
: fs_1.SYNC.getReadStream(file.path), {
|
|
334
|
+
mode: file.stats.mode
|
|
335
|
+
});
|
|
324
336
|
});
|
|
325
337
|
}
|
|
326
338
|
}
|
|
@@ -365,53 +377,71 @@ function findAndReplaceConfigProps(dir, { stack, type, integ_config }) {
|
|
|
365
377
|
});
|
|
366
378
|
}
|
|
367
379
|
exports.findAndReplaceConfigProps = findAndReplaceConfigProps;
|
|
368
|
-
function
|
|
369
|
-
var _a;
|
|
380
|
+
function resolveAllFnServePort(targets) {
|
|
370
381
|
return __awaiter(this, void 0, void 0, function* () {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
382
|
+
let isBioHttp = false;
|
|
383
|
+
const debugOpts = runtime_store_1.default.get('context.port.debug', false);
|
|
384
|
+
yield Promise.all(targets.map((target) => __awaiter(this, void 0, void 0, function* () {
|
|
385
|
+
var _a;
|
|
386
|
+
if (!target.valid) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
let curTargetType = target.type;
|
|
390
|
+
if (curTargetType === constants_1.FN_TYPE.basic &&
|
|
391
|
+
((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value))) {
|
|
392
|
+
curTargetType = constants_1.FN_TYPE.advanced;
|
|
393
|
+
}
|
|
394
|
+
if (debugOpts && target.name in (debugOpts[curTargetType] || {})) {
|
|
395
|
+
const debugPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type[curTargetType], 'debug', {
|
|
396
|
+
name: target.name,
|
|
397
|
+
duplicateCheck: false,
|
|
398
|
+
searchSpan: 0
|
|
399
|
+
});
|
|
400
|
+
runtime_store_1.default.set('context.port.debug.functions.' + target.name, debugPort);
|
|
401
|
+
}
|
|
402
|
+
if (curTargetType === constants_1.FN_TYPE.basic && isBioHttp) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const httpPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type[curTargetType], 'http', {
|
|
406
|
+
name: target.name,
|
|
407
|
+
duplicateCheck: curTargetType === constants_1.FN_TYPE.advanced || curTargetType === constants_1.FN_TYPE.browserLogic
|
|
408
|
+
});
|
|
409
|
+
if (curTargetType === constants_1.FN_TYPE.basic) {
|
|
410
|
+
runtime_store_1.default.set('context.port.http.' + constants_1.REMOTE_REF.functions.type.bio, httpPort);
|
|
411
|
+
isBioHttp = true;
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
runtime_store_1.default.set('context.port.http.functions.' + target.name, httpPort);
|
|
415
|
+
}
|
|
416
|
+
})));
|
|
417
|
+
if (debugOpts && 'basicio' in debugOpts) {
|
|
418
|
+
const bioDebugPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type.bio, 'debug', { duplicateCheck: false, searchSpan: 0 });
|
|
419
|
+
runtime_store_1.default.set('context.port.debug.basicio', bioDebugPort);
|
|
378
420
|
}
|
|
379
|
-
|
|
380
|
-
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function resolveAllFnPorts(targets) {
|
|
424
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
381
425
|
switch ((0, option_1.getCurrentCommand)()) {
|
|
382
|
-
case 'serve':
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
httpPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type[currentTargetType], 'http', currentTarget.name, currentTargetType === constants_1.FN_TYPE.advanced ||
|
|
386
|
-
currentTargetType === constants_1.FN_TYPE.browserLogic, isPyBio);
|
|
387
|
-
runtime_store_1.default.set('context.port.http.functions.' + currentTarget.name, httpPort);
|
|
388
|
-
const debugOptValue = (0, option_1.getOptionValue)('debug', false);
|
|
389
|
-
if (debugOptValue &&
|
|
390
|
-
(debugOptValue + '').includes(constants_1.REMOTE_REF.functions.type[currentTargetType]) &&
|
|
391
|
-
((debugOptValue + '').includes(currentTarget.name) ||
|
|
392
|
-
currentTargetType === constants_1.FN_TYPE.basic)) {
|
|
393
|
-
debugPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type[currentTargetType], 'debug', currentTarget.name, currentTargetType === constants_1.FN_TYPE.advanced);
|
|
394
|
-
runtime_store_1.default.set('context.port.debug.functions.' + currentTarget.name, debugPort);
|
|
395
|
-
}
|
|
396
|
-
if (currentTargetType === constants_1.FN_TYPE.basic && !isPyBio) {
|
|
397
|
-
runtime_store_1.default.set('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], httpPort);
|
|
398
|
-
runtime_store_1.default.set('context.port.debug.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], debugPort);
|
|
426
|
+
case 'serve': {
|
|
427
|
+
if (!targets) {
|
|
428
|
+
throw new error_1.default('Invalid targets', { exit: 2 });
|
|
399
429
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
runtime_store_1.default.set('context.port.debug.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], debugPort);
|
|
430
|
+
return resolveAllFnServePort(targets);
|
|
431
|
+
}
|
|
432
|
+
case 'functions:shell': {
|
|
433
|
+
if (runtime_store_1.default.get('context.port.http.basicio', false)) {
|
|
434
|
+
const bioHttpPort = yield port_resolver_1.default.getPort('basicio', 'http', {
|
|
435
|
+
duplicateCheck: false
|
|
436
|
+
});
|
|
437
|
+
runtime_store_1.default.set('context.port.http.' + constants_1.REMOTE_REF.functions.type.bio, bioHttpPort);
|
|
409
438
|
}
|
|
410
439
|
break;
|
|
411
|
-
|
|
412
|
-
|
|
440
|
+
}
|
|
441
|
+
default: {
|
|
442
|
+
throw new error_1.default('Invalid catalyst command', { exit: 2 });
|
|
443
|
+
}
|
|
413
444
|
}
|
|
414
|
-
return resolveAllFnPorts(targets, idx + 1);
|
|
415
445
|
});
|
|
416
446
|
}
|
|
417
447
|
exports.resolveAllFnPorts = resolveAllFnPorts;
|
|
@@ -531,15 +561,15 @@ function copyModDirPerm(src, dest, perm, { replace = true } = {}) {
|
|
|
531
561
|
yield Promise.all(srcContents.map((content) => {
|
|
532
562
|
return new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
533
563
|
try {
|
|
534
|
-
const isDir =
|
|
564
|
+
const isDir = content.stats.isDirectory();
|
|
535
565
|
if (isDir) {
|
|
536
|
-
const destFolder = (0, path_1.join)(dest, (0, path_1.basename)(content));
|
|
566
|
+
const destFolder = (0, path_1.join)(dest, (0, path_1.basename)(content.path));
|
|
537
567
|
yield fs_1.ASYNC.ensureDir(destFolder);
|
|
538
|
-
yield copyModDirPerm(content, destFolder, perm);
|
|
568
|
+
yield copyModDirPerm(content.path, destFolder, perm);
|
|
539
569
|
return res();
|
|
540
570
|
}
|
|
541
|
-
const destFile = (0, path_1.join)(dest, (0, path_1.basename)(content));
|
|
542
|
-
yield fs_1.ASYNC.copyFile(content, destFile, replace ? fs_2.constants.COPYFILE_FICLONE : fs_2.constants.COPYFILE_EXCL).catch((err) => {
|
|
571
|
+
const destFile = (0, path_1.join)(dest, (0, path_1.basename)(content.path));
|
|
572
|
+
yield fs_1.ASYNC.copyFile(content.path, destFile, replace ? fs_2.constants.COPYFILE_FICLONE : fs_2.constants.COPYFILE_EXCL).catch((err) => {
|
|
543
573
|
if (!replace && err.code === 'EEXIST') {
|
|
544
574
|
return;
|
|
545
575
|
}
|
|
@@ -22,16 +22,27 @@ const constants_1 = require("../../util_modules/constants");
|
|
|
22
22
|
const runtime_1 = __importDefault(require("../../util_modules/constants/lib/runtime"));
|
|
23
23
|
const fs_1 = require("../../util_modules/fs");
|
|
24
24
|
const js_1 = require("../../util_modules/js");
|
|
25
|
-
|
|
25
|
+
const serviceChoiceMap = {
|
|
26
|
+
[constants_1.INTEG.services.cliq]: prompt_1.default.choice('Cliq', {
|
|
27
|
+
value: constants_1.INTEG.services.cliq,
|
|
28
|
+
short: 'Cliq'
|
|
29
|
+
}),
|
|
30
|
+
[constants_1.INTEG.services.convokraft]: prompt_1.default.choice(constants_1.INTEG.services.convokraft, {
|
|
31
|
+
value: constants_1.INTEG.services.convokraft,
|
|
32
|
+
short: constants_1.INTEG.services.convokraft
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
function integHelper(services) {
|
|
26
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const serviceChoices = services.map((service) => serviceChoiceMap[service]);
|
|
38
|
+
if (serviceChoices.length === 0) {
|
|
39
|
+
throw new error_1.default(`Invalid integration services: [${services.join(',')}]`, {
|
|
40
|
+
exit: 2
|
|
41
|
+
});
|
|
42
|
+
}
|
|
27
43
|
const serviceAns = yield prompt_1.default.ask(prompt_1.default.question('service', 'Select one of the services to continue:', {
|
|
28
44
|
type: 'list',
|
|
29
|
-
choices:
|
|
30
|
-
prompt_1.default.choice('Cliq', {
|
|
31
|
-
value: constants_1.INTEG.services.cliq,
|
|
32
|
-
short: 'Cliq'
|
|
33
|
-
})
|
|
34
|
-
]
|
|
45
|
+
choices: serviceChoices
|
|
35
46
|
}));
|
|
36
47
|
runtime_store_1.default.set('context.functions.integration.service', serviceAns.service);
|
|
37
48
|
switch (serviceAns.service) {
|
|
@@ -105,15 +116,14 @@ function copyIntegHandlers(templatePath, targetPath, lang) {
|
|
|
105
116
|
else if (lang === runtime_1.default.language.python.value) {
|
|
106
117
|
const filePaths = constants_1.CLIQ.python_template_contents_initial_copy.map((path) => (0, path_1.join)(templatePath, path));
|
|
107
118
|
yield fs_1.ASYNC.copyFiles(filePaths, targetPath);
|
|
108
|
-
const
|
|
109
|
-
const handlerPaths = handlers.map((handler) => {
|
|
110
|
-
integHandlerConfig[handler] = (0, path_1.join)(constants_1.CLIQ.python_handlers_path, constants_1.CLIQ.python_handler_file_mapping[handler]);
|
|
111
|
-
return (0, path_1.join)(templatePath, constants_1.CLIQ.python_handlers_template_dir, constants_1.CLIQ.python_handler_file_mapping[handler]);
|
|
112
|
-
});
|
|
119
|
+
const handlerPaths = handlers.map((handler) => (0, path_1.join)(templatePath, constants_1.CLIQ.python_handlers_template_dir, constants_1.CLIQ.python_handler_file_mapping[handler]));
|
|
113
120
|
yield fs_1.ASYNC.copyFiles(handlerPaths, (0, path_1.join)(targetPath, constants_1.CLIQ.python_handlers_template_dir));
|
|
114
|
-
integ_config.handlers = integHandlerConfig;
|
|
115
121
|
}
|
|
116
122
|
break;
|
|
123
|
+
case constants_1.INTEG.services.convokraft: {
|
|
124
|
+
yield fs_1.ASYNC.copyDir(templatePath, targetPath);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
117
127
|
default:
|
|
118
128
|
break;
|
|
119
129
|
}
|