zcatalyst-cli 1.15.0-beta.2 → 1.15.0-beta.4
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/appsail-utils.js +84 -0
- package/lib/archiver.js +18 -1
- package/lib/code-deck.js +114 -0
- package/lib/command_needs/rc.js +7 -6
- package/lib/commands/appsail/add.js +55 -0
- package/lib/commands/codelib/install.js +143 -0
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/deploy/appsail.js +62 -0
- package/lib/commands/{deploy.js → deploy/index.js} +20 -14
- package/lib/commands/iac/pack.js +3 -3
- package/lib/commands/index.js +2 -0
- package/lib/commands/init.js +5 -1
- package/lib/commands/pull.js +1 -1
- package/lib/commands/serve.js +1 -1
- package/lib/commands/whoami.js +2 -1
- package/lib/deploy/features/appsail/index.js +246 -0
- package/lib/deploy/features/appsail/utils.js +91 -0
- package/lib/deploy/features/functions/index.js +12 -10
- package/lib/deploy/features/index.js +3 -0
- package/lib/deploy/index.js +3 -3
- package/lib/endpoints/index.js +22 -1
- package/lib/endpoints/lib/appsail.js +98 -0
- package/lib/endpoints/lib/code-deck.js +71 -0
- package/lib/endpoints/lib/common.js +8 -5
- package/lib/endpoints/lib/git-hub.js +148 -0
- package/lib/endpoints/lib/iac.js +15 -0
- package/lib/endpoints/lib/sdk.js +4 -1
- package/lib/execute-script.js +35 -27
- package/lib/fn-utils/lib/browserLogic.js +17 -20
- package/lib/fn-utils/lib/common.js +3 -4
- package/lib/fn-utils/lib/integ.js +6 -4
- package/lib/fn-utils/lib/java.js +7 -1
- package/lib/fn-watcher.js +3 -0
- package/lib/iac/status/deploy.js +26 -4
- package/lib/iac/status/util/index.js +3 -0
- package/lib/init/dependencies/python/ensure-python.js +2 -2
- package/lib/init/dependencies/python/pip-install.js +4 -4
- package/lib/init/features/appsail/index.js +213 -0
- package/lib/init/features/functions/index.js +5 -72
- package/lib/init/features/functions/languages/java.js +7 -3
- package/lib/init/features/functions/languages/node.js +9 -7
- package/lib/init/features/functions/languages/python.js +1 -1
- package/lib/init/features/index.js +28 -12
- package/lib/init/features/project.js +3 -3
- package/lib/init/index.js +1 -1
- package/lib/init/util/common.js +103 -0
- package/lib/internal/api.js +5 -5
- package/lib/internal/command.js +26 -3
- package/lib/option-filter.js +40 -21
- package/lib/prompt/index.js +5 -0
- package/lib/prompt/types/file-path.js +4 -1
- package/lib/prompt/types/tree.js +297 -0
- package/lib/pull/features/functions/index.js +70 -47
- package/lib/serve/features/appsail.js +37 -0
- package/lib/serve/features/index.js +8 -1
- package/lib/serve/index.js +23 -6
- package/lib/serve/server/index.js +111 -233
- package/lib/serve/server/lib/appsail/index.js +134 -0
- package/lib/serve/server/lib/appsail/start.js +75 -0
- package/lib/serve/server/lib/java/index.js +54 -0
- package/lib/serve/server/lib/master.js +84 -60
- package/lib/serve/server/lib/node/index.js +85 -74
- package/lib/serve/server/lib/node/server/index.js +77 -0
- package/lib/serve/server/lib/python/index.js +46 -0
- package/lib/serve/server/lib/web_client/index.js +33 -0
- package/lib/serve/server/lib/web_client/server.js +3 -0
- package/lib/shell/dependencies/http-functions.js +7 -7
- package/lib/shell/dependencies/local-function.js +6 -6
- package/lib/shell/prepare/index.js +1 -1
- package/lib/shell/prepare/languages/index.js +3 -3
- package/lib/shell/prepare/languages/java.js +2 -2
- package/lib/util_modules/config/index.js +3 -1
- package/lib/util_modules/config/lib/appSail.js +89 -0
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/default.js +4 -2
- package/lib/util_modules/constants/lib/file-names.js +4 -1
- package/lib/util_modules/constants/lib/runtime.js +12 -3
- package/lib/util_modules/constants/lib/scopes.js +4 -0
- package/lib/util_modules/constants/lib/template.js +23 -20
- package/lib/util_modules/constants/lib/urls.js +5 -0
- package/lib/util_modules/context-help.js +3 -0
- package/lib/util_modules/fs/lib/async.js +10 -3
- package/lib/util_modules/fs/lib/sync.js +2 -2
- package/lib/util_modules/js.js +4 -0
- package/lib/util_modules/project.js +2 -2
- package/lib/util_modules/server.js +2 -1
- package/package.json +1 -1
- package/scripts/postInstall.js +27 -18
- package/templates/init/functions/java/browserLogic/playwright/sample.java +1 -1
- package/templates/init/functions/java/browserLogic/selenium/sample.java +1 -1
- package/templates/init/functions/node/browserlogic/playwright/sample.js +1 -1
- package/templates/init/functions/node/browserlogic/puppeteer/sample.js +1 -1
- package/templates/init/functions/node/browserlogic/selenium/sample.js +1 -1
- package/templates/init/functions/node/integ/cliq/package.json +1 -0
- package/templates/init/functions/python/aio/requirements.txt +1 -1
- package/templates/init/functions/python/bio/requirements.txt +1 -1
- package/templates/init/functions/python/cron/requirements.txt +1 -1
- package/templates/init/functions/python/event/requirements.txt +1 -1
- package/templates/init/functions/python/integ/cliq/requirements.txt +1 -1
- /package/lib/serve/server/lib/java/{JavaaioServer.java → aio_server/JavaaioServer.java} +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-function-sdk-1.0.0.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-java-runtime-1.0.0.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/gradle-wrapper.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-http-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-io-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-security-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-server-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-servlet-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-util-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/org.json.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/servlet-api-3.1.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/zip4j-2.5.0.jar +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-playwright.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-puppeteer.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-selenium.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/index.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/deferred_promise.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/playwright-handler.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/puppeteer-handler.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/selenium-handler.js +0 -0
- /package/lib/serve/server/lib/node/{package.json → server/package.json} +0 -0
package/lib/commands/init.js
CHANGED
|
@@ -116,6 +116,10 @@ exports.default = new command_1.default('init [feature]')
|
|
|
116
116
|
prompt_1.default.choice('Client: Configure and deploy client files', {
|
|
117
117
|
value: 'client',
|
|
118
118
|
short: 'Client'
|
|
119
|
+
}),
|
|
120
|
+
prompt_1.default.choice('AppSail: Configure and deploy AppSail services', {
|
|
121
|
+
value: 'appsail',
|
|
122
|
+
short: 'AppSail'
|
|
119
123
|
})
|
|
120
124
|
],
|
|
121
125
|
when: !runtime_store_1.default.get('payload.project.import', false) &&
|
|
@@ -126,7 +130,7 @@ exports.default = new command_1.default('init [feature]')
|
|
|
126
130
|
return saveAndComplete(config);
|
|
127
131
|
}
|
|
128
132
|
if (typeof feature === 'string') {
|
|
129
|
-
featureAns.features =
|
|
133
|
+
featureAns.features = feature;
|
|
130
134
|
}
|
|
131
135
|
runtime_store_1.default.set('context.features', featureAns.features);
|
|
132
136
|
yield (yield Promise.resolve().then(() => __importStar(require('../init')))).default();
|
package/lib/commands/pull.js
CHANGED
|
@@ -131,7 +131,7 @@ exports.default = new command_1.default('pull [feature]')
|
|
|
131
131
|
}
|
|
132
132
|
payload.forEach((featureName) => {
|
|
133
133
|
(0, logger_1.debug)(`Updating ${featureName} in ${constants_1.FILENAME.config} with respect to the pulled resouce`);
|
|
134
|
-
(0, features_1.
|
|
134
|
+
(0, features_1.setCatalystConfig)(featureName, true);
|
|
135
135
|
});
|
|
136
136
|
yield config.save();
|
|
137
137
|
(0, logger_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.config) + ' file has been successfully updated with feature details.');
|
package/lib/commands/serve.js
CHANGED
|
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
const command_1 = __importDefault(require("../internal/command"));
|
|
39
39
|
const constants_1 = require("../util_modules/constants");
|
|
40
40
|
exports.default = new command_1.default('serve')
|
|
41
|
-
.description('Serve Basic I/O and Advanced I/O functions, and the client, to test them locally')
|
|
41
|
+
.description('Serve Basic I/O and Advanced I/O functions, Appsail and the client, to test them locally')
|
|
42
42
|
.option('--http <port>', 'start the server at specified port ')
|
|
43
43
|
.option('--debug <type:port>', 'the functions are invoked from local environment enabling debugging options on provided ports ' +
|
|
44
44
|
`(example: advancedio:<name>:${constants_1.DEFAULT.serve_port.debug.advancedio},basicio:${constants_1.DEFAULT.serve_port.debug.basicio})`)
|
package/lib/commands/whoami.js
CHANGED
|
@@ -24,7 +24,8 @@ exports.default = new command_1.default('whoami')
|
|
|
24
24
|
const user = config_store_1.default.get(`${activeDC}.user`);
|
|
25
25
|
const token = config_store_1.default.get(`${activeDC}.credential`);
|
|
26
26
|
if (user && token) {
|
|
27
|
-
(0, logger_1.success)('Logged as: ' +
|
|
27
|
+
(0, logger_1.success)('Logged as: ' +
|
|
28
|
+
ansi_colors_1.cyan.bold(user.Email ? user.Email : `${user.First_Name} ${user.Last_Name}`));
|
|
28
29
|
return user;
|
|
29
30
|
}
|
|
30
31
|
(0, logger_1.error)('Not logged in yet. To login use ' + ansi_colors_1.underline.bold('catalyst login'));
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.executeHook = void 0;
|
|
16
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
17
|
+
const path_1 = require("path");
|
|
18
|
+
const appsail_utils_1 = require("../../../appsail-utils");
|
|
19
|
+
const archiver_1 = __importDefault(require("../../../archiver"));
|
|
20
|
+
const endpoints_1 = require("../../../endpoints");
|
|
21
|
+
const error_1 = __importDefault(require("../../../error"));
|
|
22
|
+
const execute_script_1 = require("../../../execute-script");
|
|
23
|
+
const common_1 = require("../../../init/util/common");
|
|
24
|
+
const prompt_1 = __importDefault(require("../../../prompt"));
|
|
25
|
+
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
26
|
+
const config_1 = require("../../../util_modules/config");
|
|
27
|
+
const constants_1 = require("../../../util_modules/constants");
|
|
28
|
+
const fs_1 = require("../../../util_modules/fs");
|
|
29
|
+
const logger_1 = require("../../../util_modules/logger");
|
|
30
|
+
const option_1 = require("../../../util_modules/option");
|
|
31
|
+
const project_1 = require("../../../util_modules/project");
|
|
32
|
+
const utils_1 = require("./utils");
|
|
33
|
+
function executeHook(script, name, moduleSource) {
|
|
34
|
+
if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
|
|
35
|
+
(0, logger_1.debug)(`skipping ${name} hook`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
(0, execute_script_1.executeCommand)(script, { moduleSource, feature: name });
|
|
39
|
+
}
|
|
40
|
+
exports.executeHook = executeHook;
|
|
41
|
+
function getConfigJsonInputs() {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const runtimeDetailsPromise = (0, common_1.getRuntimeDetails)();
|
|
44
|
+
const stack = yield (0, utils_1.validateOptions)(utils_1.validateStack, 'stack', runtimeDetailsPromise);
|
|
45
|
+
const platform = yield (0, utils_1.validateOptions)(utils_1.validatePlatform, 'platform', stack);
|
|
46
|
+
const optValues = {
|
|
47
|
+
buildPath: yield (0, utils_1.validateOptions)(utils_1.validateBuildPath, 'buildPath'),
|
|
48
|
+
stack,
|
|
49
|
+
platform,
|
|
50
|
+
command: (0, option_1.getOptionValue)('command', false)
|
|
51
|
+
};
|
|
52
|
+
const cwd = runtime_store_1.default.get('cwd');
|
|
53
|
+
yield prompt_1.default.register('file-path');
|
|
54
|
+
const appConfigAns = yield prompt_1.default.ask(prompt_1.default.question('buildPath', 'Please provide the build directory of your AppSail service', {
|
|
55
|
+
type: 'file-path',
|
|
56
|
+
when: () => optValues.buildPath === false,
|
|
57
|
+
rootPath: cwd,
|
|
58
|
+
validate: ({ value }) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const pathRes = (0, utils_1.validateBuildPath)(value);
|
|
60
|
+
if (!pathRes) {
|
|
61
|
+
return `Invalid path: ${value}`;
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
})
|
|
65
|
+
}), prompt_1.default.question('stack', 'Please select the stack for your AppSail service', {
|
|
66
|
+
type: 'list',
|
|
67
|
+
choices: yield (0, common_1.getRuntimeChoices)({ runtimeDetails: yield runtimeDetailsPromise }),
|
|
68
|
+
when: () => optValues.stack === false
|
|
69
|
+
}), prompt_1.default.question('platform', 'Please choose a platform for your AppSail: ', {
|
|
70
|
+
type: 'list',
|
|
71
|
+
choices: [
|
|
72
|
+
prompt_1.default.choice('JavaSE', {
|
|
73
|
+
value: 'javase',
|
|
74
|
+
short: 'JavaSE'
|
|
75
|
+
}),
|
|
76
|
+
prompt_1.default.choice('JavaWAR', {
|
|
77
|
+
value: 'war',
|
|
78
|
+
short: 'JavaWAR'
|
|
79
|
+
})
|
|
80
|
+
],
|
|
81
|
+
when: (answers) => {
|
|
82
|
+
var _a;
|
|
83
|
+
const _stack = ((_a = answers.stack) === null || _a === void 0 ? void 0 : _a.lang) ||
|
|
84
|
+
(typeof optValues.stack === 'boolean' ? '' : optValues.stack.lang) ||
|
|
85
|
+
'';
|
|
86
|
+
return (optValues.platform === false &&
|
|
87
|
+
_stack.startsWith(constants_1.RUNTIME.language.java.value));
|
|
88
|
+
}
|
|
89
|
+
}), prompt_1.default.question('command', 'Please specify the command to start the AppSail service', {
|
|
90
|
+
type: 'input',
|
|
91
|
+
when: (answers) => {
|
|
92
|
+
var _a;
|
|
93
|
+
const stack = ((_a = answers.stack) === null || _a === void 0 ? void 0 : _a.lang) ||
|
|
94
|
+
(typeof optValues.stack === 'boolean' ? '' : optValues.stack.lang) ||
|
|
95
|
+
'';
|
|
96
|
+
const _platform = answers.platform || optValues.platform || '';
|
|
97
|
+
return (optValues.command === false &&
|
|
98
|
+
!(stack.startsWith(constants_1.RUNTIME.language.java.value) &&
|
|
99
|
+
_platform === 'war'));
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
const finalConfig = Object.entries(optValues).reduce((config, [key, val]) => {
|
|
103
|
+
config[key] = val === false ? appConfigAns[key] : val;
|
|
104
|
+
return config;
|
|
105
|
+
}, {});
|
|
106
|
+
if (typeof finalConfig.stack !== 'string') {
|
|
107
|
+
finalConfig.stack = finalConfig.stack.runtime;
|
|
108
|
+
}
|
|
109
|
+
if (!finalConfig.stack.startsWith(constants_1.RUNTIME.language.java.value) &&
|
|
110
|
+
finalConfig.platform) {
|
|
111
|
+
(0, logger_1.message)('Platform argument is not supported for stack: ' + finalConfig.stack);
|
|
112
|
+
delete finalConfig.platform;
|
|
113
|
+
}
|
|
114
|
+
if (finalConfig.platform === 'war' && finalConfig.command) {
|
|
115
|
+
(0, logger_1.message)('Command argument not need for platform type war');
|
|
116
|
+
delete finalConfig.command;
|
|
117
|
+
}
|
|
118
|
+
return finalConfig;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function getStandAloneTarget() {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
const isProjectInfo = (0, project_1.getProjectId)(false) || (0, project_1.getProjectName)(false);
|
|
124
|
+
if (!isProjectInfo) {
|
|
125
|
+
throw new error_1.default('Project info is not present');
|
|
126
|
+
}
|
|
127
|
+
const cwd = runtime_store_1.default.get('cwd');
|
|
128
|
+
const catalystConfigPath = (0, path_1.join)(cwd, constants_1.FILENAME.app_config);
|
|
129
|
+
const nameOpt = yield (0, utils_1.validateOptions)(utils_1.validateName, 'name');
|
|
130
|
+
const appSailName = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please provide a name for your AppSail service', {
|
|
131
|
+
type: 'input',
|
|
132
|
+
when: () => nameOpt === false,
|
|
133
|
+
validate: (name) => __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
return (yield (0, utils_1.validateName)(name)) !== false
|
|
135
|
+
? true
|
|
136
|
+
: `AppSail service name is Invalid, it should match ${constants_1.REGEX.functions.package.name}`;
|
|
137
|
+
})
|
|
138
|
+
}));
|
|
139
|
+
const configJson = (yield fs_1.ASYNC.readJSONFile(catalystConfigPath).catch((err) => (0, logger_1.debug)(err))) || (yield getConfigJsonInputs());
|
|
140
|
+
if (typeof configJson.stack === 'object') {
|
|
141
|
+
configJson.stack = configJson.stack.runtime;
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
appSail: Object.assign({ name: nameOpt === false ? appSailName.name : nameOpt, source: cwd }, configJson),
|
|
145
|
+
validity: { valid: true }
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
exports.default = (standAlone = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
+
const targets = standAlone
|
|
151
|
+
? (yield config_1.appSailConfig.getAllTargetDetails(false)) || [yield getStandAloneTarget()]
|
|
152
|
+
: yield config_1.appSailConfig.getAllTargetDetails();
|
|
153
|
+
if (!targets || targets.length === 0) {
|
|
154
|
+
throw new error_1.default('No targets found');
|
|
155
|
+
}
|
|
156
|
+
const filtered = (0, appsail_utils_1.filterTargets)(targets);
|
|
157
|
+
let pythonPrompt = false;
|
|
158
|
+
const validTargets = (0, appsail_utils_1.validateAppSail)(filtered).filter((targ) => {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
if (targ.validity.valid) {
|
|
161
|
+
if (!pythonPrompt &&
|
|
162
|
+
((_a = targ.appSail) === null || _a === void 0 ? void 0 : _a.stack.startsWith(constants_1.RUNTIME.language.python.value))) {
|
|
163
|
+
pythonPrompt = true;
|
|
164
|
+
}
|
|
165
|
+
return targ;
|
|
166
|
+
}
|
|
167
|
+
(0, logger_1.labeled)('AppSail: ', 'Invalid AppSail service ' + (0, ansi_colors_1.bold)(((_b = targ.appSail) === null || _b === void 0 ? void 0 : _b.name) || 'Unknown')).ERROR();
|
|
168
|
+
(0, logger_1.error)('Reason: ' + targ.validity.reason);
|
|
169
|
+
(0, logger_1.info)();
|
|
170
|
+
return false;
|
|
171
|
+
});
|
|
172
|
+
if (validTargets.length === 0) {
|
|
173
|
+
throw new error_1.default('No valid AppSail services found to deploy', {
|
|
174
|
+
skipHelp: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const sailAPI = yield (0, endpoints_1.appSailAPI)();
|
|
178
|
+
const deployRes = yield validTargets.reduce((result, _targ) => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
|
+
var _a, _b;
|
|
180
|
+
const targ = _targ.appSail;
|
|
181
|
+
const prevRes = yield result;
|
|
182
|
+
try {
|
|
183
|
+
if ((_a = targ.scripts) === null || _a === void 0 ? void 0 : _a.predeploy) {
|
|
184
|
+
executeHook(targ.scripts.predeploy, 'predeploy', targ.source);
|
|
185
|
+
}
|
|
186
|
+
const zip = new archiver_1.default();
|
|
187
|
+
const folderPath = (0, project_1.resolveProjectPath)(targ.buildPath);
|
|
188
|
+
const ignoreFile = yield fs_1.ASYNC.readFile((0, path_1.join)(folderPath, constants_1.FILENAME.catalyst_ignore));
|
|
189
|
+
const folderContents = yield fs_1.ASYNC.walk(folderPath, {
|
|
190
|
+
filter: {
|
|
191
|
+
exclude: [
|
|
192
|
+
'**/.DS_Store',
|
|
193
|
+
'**/.vscode/**/*',
|
|
194
|
+
`**/${constants_1.FILENAME.app_config}`,
|
|
195
|
+
`**/${constants_1.FILENAME.catalyst_ignore}`,
|
|
196
|
+
...((ignoreFile === null || ignoreFile === void 0 ? void 0 : ignoreFile.split('\n')) || [])
|
|
197
|
+
],
|
|
198
|
+
excludeDir: true
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
folderContents.forEach((content) => {
|
|
202
|
+
zip.add(content === folderPath
|
|
203
|
+
? (0, path_1.basename)(content)
|
|
204
|
+
: content.replace(folderPath + path_1.sep, ''), fs_1.SYNC.getReadStream(content));
|
|
205
|
+
});
|
|
206
|
+
const finalized = yield zip.finalize();
|
|
207
|
+
const zipStream = yield finalized.fsStream();
|
|
208
|
+
const { stack, name, command, memory, platform, env_variables } = targ;
|
|
209
|
+
const apiRes = yield sailAPI.deploy(zipStream, {
|
|
210
|
+
stack,
|
|
211
|
+
name,
|
|
212
|
+
memory,
|
|
213
|
+
platform,
|
|
214
|
+
command,
|
|
215
|
+
envVariables: env_variables
|
|
216
|
+
});
|
|
217
|
+
_targ.url = apiRes.url;
|
|
218
|
+
if ((_b = targ.scripts) === null || _b === void 0 ? void 0 : _b.postdeploy) {
|
|
219
|
+
executeHook(targ.scripts.postdeploy, 'postdeploy', targ.source);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
(0, logger_1.debug)(err);
|
|
224
|
+
_targ.validity = {
|
|
225
|
+
valid: false,
|
|
226
|
+
reason: error_1.default.getErrorInstance(err).message
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
prevRes.push(_targ);
|
|
230
|
+
return Promise.resolve(prevRes);
|
|
231
|
+
}), Promise.resolve([]));
|
|
232
|
+
const deployedValidTargets = deployRes.filter((targ) => {
|
|
233
|
+
var _a;
|
|
234
|
+
if (!targ.validity.valid) {
|
|
235
|
+
(0, logger_1.warning)('Deploy of AppSail [' +
|
|
236
|
+
((_a = targ.appSail) === null || _a === void 0 ? void 0 : _a.name) +
|
|
237
|
+
'] was unsuccessful since ' +
|
|
238
|
+
targ.validity.reason);
|
|
239
|
+
}
|
|
240
|
+
return targ.validity.valid;
|
|
241
|
+
});
|
|
242
|
+
runtime_store_1.default.set('payload.appsail.targets', deployedValidTargets);
|
|
243
|
+
if (deployedValidTargets.length > 0) {
|
|
244
|
+
runtime_store_1.default.set('payload.appsail.deploy', true);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.urlLogger = exports.validateName = exports.validatePlatform = exports.validateStack = exports.validateBuildPath = exports.validateOptions = void 0;
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
18
|
+
const constants_1 = require("../../../util_modules/constants");
|
|
19
|
+
const fs_1 = require("../../../util_modules/fs");
|
|
20
|
+
const logger_1 = require("../../../util_modules/logger");
|
|
21
|
+
const option_1 = require("../../../util_modules/option");
|
|
22
|
+
function validateOptions(validationFn, option, ...args) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const value = (0, option_1.getOptionValue)(option, false);
|
|
25
|
+
if (value === false) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const validationRes = yield validationFn(value, ...args);
|
|
29
|
+
if (validationRes === false) {
|
|
30
|
+
(0, logger_1.debug)(`Invalid value for option: ${option}`);
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return validationRes;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.validateOptions = validateOptions;
|
|
37
|
+
function validateBuildPath(path) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const cwd = runtime_store_1.default.get('cwd');
|
|
40
|
+
if (path) {
|
|
41
|
+
const buildPath = (0, path_1.isAbsolute)(path) ? path : (0, path_1.resolve)(cwd, path);
|
|
42
|
+
return (yield fs_1.ASYNC.dirExists(buildPath)) ? path : false;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.validateBuildPath = validateBuildPath;
|
|
48
|
+
function validateStack(stack, stackPromise) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const runtimeStacks = yield stackPromise;
|
|
51
|
+
if (runtimeStacks.runtimes.includes(stack)) {
|
|
52
|
+
return {
|
|
53
|
+
runtime: stack,
|
|
54
|
+
lang: Object.keys(constants_1.RUNTIME.language).find((lang) => stack.startsWith(lang))
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.validateStack = validateStack;
|
|
61
|
+
function validatePlatform(platform, stack) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
if (!stack || stack.lang === constants_1.RUNTIME.language.java.value) {
|
|
64
|
+
return ['javase', 'war'].includes(platform) ? platform : false;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
exports.validatePlatform = validatePlatform;
|
|
70
|
+
function validateName(name) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
if (name.match(constants_1.REGEX.functions.package.name)) {
|
|
73
|
+
return name;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.validateName = validateName;
|
|
79
|
+
function urlLogger() {
|
|
80
|
+
const deployTargets = runtime_store_1.default.get('payload.appsail.targets', []);
|
|
81
|
+
deployTargets.forEach((sail) => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
if (sail.url !== undefined) {
|
|
84
|
+
(0, logger_1.labeled)(`AppSail(${(_a = sail.appSail) === null || _a === void 0 ? void 0 : _a.name})`, 'URL => ' + sail.url).MESSAGE();
|
|
85
|
+
}
|
|
86
|
+
(0, logger_1.labeled)(`AppSail(${(_b = sail.appSail) === null || _b === void 0 ? void 0 : _b.name})`, 'deploy successful').SUCCESS();
|
|
87
|
+
(0, logger_1.info)();
|
|
88
|
+
});
|
|
89
|
+
return deployTargets;
|
|
90
|
+
}
|
|
91
|
+
exports.urlLogger = urlLogger;
|
|
@@ -44,9 +44,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
44
44
|
text: `packaging function [${target.name}]`
|
|
45
45
|
}));
|
|
46
46
|
const [nodeTarget, javaTarget, pythonTarget] = yield Promise.all([
|
|
47
|
-
(0, languages_1.node)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.
|
|
48
|
-
(0, languages_1.java)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java)) && target.valid; })),
|
|
49
|
-
(0, languages_1.python)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python)) && target.valid; }))
|
|
47
|
+
(0, languages_1.node)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) && target.valid; })),
|
|
48
|
+
(0, languages_1.java)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) && target.valid; })),
|
|
49
|
+
(0, languages_1.python)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value)) && target.valid; }))
|
|
50
50
|
]);
|
|
51
51
|
const combinedTarget = [...(nodeTarget || []), ...(javaTarget || []), ...(pythonTarget || [])];
|
|
52
52
|
const batchSize = 1;
|
|
@@ -70,17 +70,19 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
70
70
|
}));
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
|
-
|
|
73
|
+
const deployOptions = {
|
|
74
74
|
stack: target.stack,
|
|
75
75
|
name: target.name,
|
|
76
76
|
type: constants_1.REMOTE_REF.functions.type[target.type],
|
|
77
|
-
memory: target.type === constants_1.FN_TYPE.browserLogic
|
|
78
|
-
? !target.memory && !target.id
|
|
79
|
-
? 512
|
|
80
|
-
: target.memory
|
|
81
|
-
: target.memory,
|
|
82
77
|
envVariables: target.env_var
|
|
83
|
-
}
|
|
78
|
+
};
|
|
79
|
+
if (target.type === constants_1.FN_TYPE.browserLogic && !target.memory && !target.id) {
|
|
80
|
+
deployOptions.memory = 512;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
deployOptions.memory = target.memory;
|
|
84
|
+
}
|
|
85
|
+
resp = (yield fnAPI.deploy(target.zip_stream, deployOptions));
|
|
84
86
|
}
|
|
85
87
|
target.id = resp.id + '';
|
|
86
88
|
fn_utils_1.fnUtils.common.generateUrlForTarget(target);
|
|
@@ -41,5 +41,8 @@ exports.default = {
|
|
|
41
41
|
}),
|
|
42
42
|
apig: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
43
|
return (yield Promise.resolve().then(() => __importStar(require('./apig')))).default();
|
|
44
|
+
}),
|
|
45
|
+
appsail: (standAlone) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
return (yield Promise.resolve().then(() => __importStar(require('./appsail/index.js')))).default(standAlone);
|
|
44
47
|
})
|
|
45
48
|
};
|
package/lib/deploy/index.js
CHANGED
|
@@ -16,9 +16,9 @@ const error_1 = __importDefault(require("../error"));
|
|
|
16
16
|
const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
17
17
|
const logger_1 = require("../util_modules/logger");
|
|
18
18
|
const features_1 = __importDefault(require("./features"));
|
|
19
|
-
function deploy() {
|
|
19
|
+
function deploy(feature) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const deployTargets = runtime_store_1.default.get('context.targets', []);
|
|
21
|
+
const deployTargets = runtime_store_1.default.get('context.targets', feature ? [feature] : []);
|
|
22
22
|
if (deployTargets.length === 0) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -30,7 +30,7 @@ function deploy() {
|
|
|
30
30
|
runtime_store_1.default.set('context.current.target', currentTarget);
|
|
31
31
|
try {
|
|
32
32
|
runtime_store_1.default.set('payload.targets', runtime_store_1.default.get('payload.targets', []).concat(currentTarget));
|
|
33
|
-
yield featureModule();
|
|
33
|
+
yield featureModule(feature ? true : false);
|
|
34
34
|
}
|
|
35
35
|
catch (e) {
|
|
36
36
|
const error = error_1.default.getErrorInstance(e);
|
package/lib/endpoints/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.commonAPI = exports.logAPI = exports.eventBusAPI = exports.functionsAPI = exports.applogicAPI = exports.bulkDSAPI = exports.apigAPI = exports.clientAPI = exports.datastoreAPI = exports.zcqlAPI = exports.queueAPI = exports.filestoreAPI = exports.cacheAPI = exports.sdkAPI = exports.envAPI = exports.projectAPI = exports.orgAPI = void 0;
|
|
35
|
+
exports.commonAPI = exports.codeDeck = exports.gitHubAPI = exports.appSailAPI = exports.logAPI = exports.eventBusAPI = exports.functionsAPI = exports.applogicAPI = exports.bulkDSAPI = exports.apigAPI = exports.clientAPI = exports.datastoreAPI = exports.zcqlAPI = exports.queueAPI = exports.filestoreAPI = exports.cacheAPI = exports.sdkAPI = exports.envAPI = exports.projectAPI = exports.orgAPI = void 0;
|
|
36
36
|
const project_1 = require("../util_modules/project");
|
|
37
37
|
function orgAPI({ auth = true } = {}) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -149,6 +149,27 @@ function logAPI({ auth = true, projectId = (0, project_1.getProjectId)(-1), env
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
exports.logAPI = logAPI;
|
|
152
|
+
function appSailAPI({ auth = true, projectId = (0, project_1.getProjectId)(), env = (0, project_1.getEnvName)() } = {}) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const appSail = (yield Promise.resolve().then(() => __importStar(require('./lib/appsail.js')))).default;
|
|
155
|
+
return new appSail(projectId, { authNeeded: auth, env });
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
exports.appSailAPI = appSailAPI;
|
|
159
|
+
function gitHubAPI() {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const gitHub = (yield Promise.resolve().then(() => __importStar(require('./lib/git-hub')))).default;
|
|
162
|
+
return new gitHub();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
exports.gitHubAPI = gitHubAPI;
|
|
166
|
+
function codeDeck() {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const codeDeck = (yield Promise.resolve().then(() => __importStar(require('./lib/code-deck')))).default;
|
|
169
|
+
return new codeDeck({ authNeeded: false });
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
exports.codeDeck = codeDeck;
|
|
152
173
|
function commonAPI() {
|
|
153
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
175
|
const common = (yield Promise.resolve().then(() => __importStar(require('./lib/common')))).default;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const error_1 = __importDefault(require("../../error"));
|
|
16
|
+
const api_1 = __importDefault(require("../../internal/api"));
|
|
17
|
+
const constants_1 = require("../../util_modules/constants");
|
|
18
|
+
const logger_1 = require("../../util_modules/logger");
|
|
19
|
+
class AppSail {
|
|
20
|
+
constructor(projectId, opts) {
|
|
21
|
+
this.opts = opts;
|
|
22
|
+
this.projectId = projectId;
|
|
23
|
+
}
|
|
24
|
+
deploy(sourceFsStream, { stack, name, command, memory, platform, envVariables = {} }) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const formData = {
|
|
27
|
+
stack,
|
|
28
|
+
name,
|
|
29
|
+
code: sourceFsStream
|
|
30
|
+
};
|
|
31
|
+
if (typeof memory === 'number') {
|
|
32
|
+
formData.memory = memory;
|
|
33
|
+
}
|
|
34
|
+
if (typeof platform === 'string') {
|
|
35
|
+
formData.platform = platform;
|
|
36
|
+
}
|
|
37
|
+
const configuration = {};
|
|
38
|
+
if (typeof command === 'string') {
|
|
39
|
+
configuration.startup_command = command;
|
|
40
|
+
}
|
|
41
|
+
if (typeof envVariables === 'object' && Object.keys(envVariables).length > 0) {
|
|
42
|
+
configuration.environment = {
|
|
43
|
+
variables: envVariables
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (Object.keys(configuration).length > 0) {
|
|
47
|
+
formData.configuration = JSON.stringify(configuration);
|
|
48
|
+
}
|
|
49
|
+
const res = yield new api_1.default(this.opts).put(`/baas/v1/project/${this.projectId}/appsail/upsert`, {
|
|
50
|
+
formData,
|
|
51
|
+
json: false
|
|
52
|
+
});
|
|
53
|
+
if (res.body && res.body.data) {
|
|
54
|
+
return res.body.data;
|
|
55
|
+
}
|
|
56
|
+
(0, logger_1.debug)('save AppSail response from server : ' + res.body);
|
|
57
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
58
|
+
exit: 2
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
updateConfig(appSailId, env) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const res = yield new api_1.default(this.opts).post(`/baas/v1/project/${this.projectId}/appsail/${appSailId}/configuration`, {
|
|
65
|
+
body: {
|
|
66
|
+
environment: {
|
|
67
|
+
variables: env
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (res.body && res.body.data) {
|
|
72
|
+
return res.body.data;
|
|
73
|
+
}
|
|
74
|
+
(0, logger_1.debug)('Update configuration response from server : ' + res.body);
|
|
75
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
76
|
+
exit: 2
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
downloadJetty() {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const res = yield new api_1.default({
|
|
83
|
+
origin: constants_1.ORIGIN.zohoCDN,
|
|
84
|
+
authNeeded: false,
|
|
85
|
+
json: false,
|
|
86
|
+
isExternal: true
|
|
87
|
+
}).get('/catalyst/appsail/1.0.0/jetty_runtime_dependency.zip', { encoding: null });
|
|
88
|
+
if (res.body) {
|
|
89
|
+
return res.body;
|
|
90
|
+
}
|
|
91
|
+
(0, logger_1.debug)('Download JETTY server response from server : ' + res.body);
|
|
92
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
93
|
+
exit: 2
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.default = AppSail;
|