zcatalyst-cli 1.17.4 → 1.18.0-beta.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/command_needs/rc.toml +2 -2
- package/docs/commands/functions/shell.toml +4 -0
- package/docs/endpoints/lib/env.toml +3 -0
- package/docs/shell/dependencies/tunnel-server.toml +4 -0
- package/docs/shell/index.toml +7 -0
- package/lib/appsail-utils.js +7 -1
- package/lib/command_needs/rc.js +8 -8
- package/lib/commands/functions/shell.js +97 -1
- package/lib/commands/serve.js +1 -1
- package/lib/deploy/features/appsail/index.js +4 -3
- package/lib/deploy/features/appsail/utils.js +1 -1
- package/lib/endpoints/index.js +8 -1
- package/lib/endpoints/lib/env.js +20 -2
- package/lib/endpoints/lib/sdk.js +2 -2
- package/lib/endpoints/lib/tunnel.js +66 -0
- package/lib/init/features/appsail/index.js +2 -2
- package/lib/internal/api.js +9 -1
- package/lib/port-resolver.js +1 -1
- package/lib/repl-server.js +9 -0
- package/lib/serve/server/lib/appsail/index.js +9 -8
- package/lib/serve/server/lib/master.js +18 -9
- package/lib/serve/server/lib/python/index.js +3 -0
- package/lib/shell/dependencies/http-functions.js +21 -8
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +28 -32
- package/lib/shell/dependencies/invoker/bio/node.mjs +2 -2
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +62 -13
- package/lib/shell/dependencies/invoker/cron/node.mjs +28 -24
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +40 -6
- package/lib/shell/dependencies/invoker/event/node.mjs +22 -9
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +3 -3
- package/lib/shell/dependencies/invoker/integ/node.mjs +6 -6
- package/lib/shell/dependencies/local-function.js +290 -199
- package/lib/shell/dependencies/tunnel-server.js +173 -0
- package/lib/shell/index.js +55 -1
- package/lib/shell/prepare/languages/java.js +1 -1
- package/lib/shell/prepare/languages/node.js +3 -1
- package/lib/shell/prepare/languages/python.js +1 -0
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/needed-scopes.js +52 -0
- package/lib/util_modules/constants/lib/scopes.js +5 -0
- package/lib/util_modules/constants/lib/urls.js +8 -0
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[RC-1]
|
|
2
|
-
context = '''The project(${arg[0]}) provided with the ${arg[1]} option is not available in the
|
|
3
|
-
aid = '''Please use one of the available projects with the ${arg[1]} option
|
|
2
|
+
context = '''The project(${arg[0]}) provided with the ${arg[1]} option is not available is not available in the ${arg[3]} org.'''
|
|
3
|
+
aid = '''Please use one of the available projects with the ${arg[1]} option or specify the correct org \nThe available projects in the ${arg[3]} org are: \n${arg[2]}'''
|
|
4
4
|
link = 'https://www.zoho.com/catalyst/help/cli-options.html#Project'
|
|
5
5
|
|
|
6
6
|
[RC-2]
|
package/docs/shell/index.toml
CHANGED
|
@@ -2,3 +2,10 @@
|
|
|
2
2
|
context = '''No valid functions to Serve!'''
|
|
3
3
|
aid = '''Please rectify the above errors, if any and try once again.'''
|
|
4
4
|
link = 'https://www.zoho.com/catalyst/help/cli-functions.html#Shell'
|
|
5
|
+
|
|
6
|
+
[SHELL-IDX-2]
|
|
7
|
+
context = '''Cannot enable Tunneling from ZCatalyst CLI.
|
|
8
|
+
Reason: ${arg[0]}
|
|
9
|
+
Error Code: ${arg[1]}'''
|
|
10
|
+
aid = '''Please rectify the above errors and try once again.'''
|
|
11
|
+
link = 'https://www.zoho.com/catalyst/help/cli-functions.html#Shell'
|
package/lib/appsail-utils.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateAppSail = exports.filterTargets = void 0;
|
|
6
|
+
exports.getDomainPrefix = exports.validateAppSail = exports.filterTargets = void 0;
|
|
7
7
|
const ansi_colors_1 = require("ansi-colors");
|
|
8
8
|
const error_1 = __importDefault(require("./error"));
|
|
9
9
|
const constants_1 = require("./util_modules/constants");
|
|
10
10
|
const logger_1 = require("./util_modules/logger");
|
|
11
11
|
const option_1 = require("./util_modules/option");
|
|
12
|
+
const project_1 = require("./util_modules/project");
|
|
12
13
|
function getAppSailFilters(targetStr) {
|
|
13
14
|
return targetStr.split(',').reduce((filterArr, target) => {
|
|
14
15
|
const opts = target.split(':');
|
|
@@ -82,3 +83,8 @@ function validateAppSail(targDetails) {
|
|
|
82
83
|
return targDetails;
|
|
83
84
|
}
|
|
84
85
|
exports.validateAppSail = validateAppSail;
|
|
86
|
+
function getDomainPrefix(targetDetail) {
|
|
87
|
+
var _a;
|
|
88
|
+
return `${(_a = targetDetail.appSail) === null || _a === void 0 ? void 0 : _a.name}-${(0, project_1.getDomainKey)()}.development`;
|
|
89
|
+
}
|
|
90
|
+
exports.getDomainPrefix = getDomainPrefix;
|
package/lib/command_needs/rc.js
CHANGED
|
@@ -34,11 +34,6 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
|
|
|
34
34
|
const projectOpt = globProjectOpt
|
|
35
35
|
? globProjectOpt
|
|
36
36
|
: (0, env_1.getEnvVariable)('CATALYST_PROJECT', null);
|
|
37
|
-
if (projectOpt !== null && orgOpt === null) {
|
|
38
|
-
throw new error_1.default('Org option is needed when project option is supplied', {
|
|
39
|
-
exit: 2
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
37
|
const orgApi = yield (0, endpoints_1.orgAPI)();
|
|
43
38
|
if (orgOpt !== null) {
|
|
44
39
|
const orgList = yield orgApi.getAllOrgs();
|
|
@@ -50,8 +45,8 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
|
|
|
50
45
|
}
|
|
51
46
|
runtime_store_1.default.set('project.env.id', orgOpt + '');
|
|
52
47
|
}
|
|
53
|
-
let projectApi =
|
|
54
|
-
let envApi =
|
|
48
|
+
let projectApi = yield (0, endpoints_1.projectAPI)();
|
|
49
|
+
let envApi = yield (0, endpoints_1.envAPI)();
|
|
55
50
|
const convertProjectToProperties = (project) => {
|
|
56
51
|
project = (0, project_2.transformProject)(project);
|
|
57
52
|
runtime_store_1.default.set('project.name', project.name);
|
|
@@ -81,6 +76,9 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
|
|
|
81
76
|
const projectArr = (yield projectApi.getAllProjects());
|
|
82
77
|
const project = js_1.JS.find(projectArr, { project_name: projectOpt });
|
|
83
78
|
if (project === undefined) {
|
|
79
|
+
const allOrgs = yield orgApi.getAllOrgs();
|
|
80
|
+
const orgId = (0, project_2.getEnvId)();
|
|
81
|
+
const orgDetails = allOrgs.find((org) => (!orgId && org.is_default) || org.name === orgId || org.id === orgId);
|
|
84
82
|
throw new error_1.default('invalid project provided with the --project option', {
|
|
85
83
|
exit: 1,
|
|
86
84
|
errorId: 'RC-1',
|
|
@@ -91,7 +89,9 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
|
|
|
91
89
|
.filter((proj) => proj.project_type &&
|
|
92
90
|
project_1.default.accepted_types.includes(proj.project_type))
|
|
93
91
|
.map((project) => '* ' + project.project_name)
|
|
94
|
-
.join('\n'))
|
|
92
|
+
.join('\n')),
|
|
93
|
+
`${orgDetails === null || orgDetails === void 0 ? void 0 : orgDetails.name}(${orgDetails === null || orgDetails === void 0 ? void 0 : orgDetails.id})` +
|
|
94
|
+
((orgDetails === null || orgDetails === void 0 ? void 0 : orgDetails.is_default) ? ' [DEFAULT]' : '')
|
|
95
95
|
]
|
|
96
96
|
});
|
|
97
97
|
}
|
|
@@ -35,22 +35,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
39
|
+
const endpoints_1 = require("../../endpoints");
|
|
40
|
+
const error_1 = __importDefault(require("../../error"));
|
|
38
41
|
const command_1 = __importDefault(require("../../internal/command"));
|
|
42
|
+
const prompt_1 = __importDefault(require("../../prompt"));
|
|
39
43
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
40
44
|
const constants_1 = require("../../util_modules/constants");
|
|
45
|
+
const logger_1 = require("../../util_modules/logger");
|
|
41
46
|
const option_1 = require("../../util_modules/option");
|
|
47
|
+
const project_1 = require("../../util_modules/project");
|
|
42
48
|
exports.default = new command_1.default('functions:shell')
|
|
43
49
|
.description('Launch a node shell to test emulated functions of any stack or type, other than Advanced I/O functions')
|
|
44
50
|
.option('--http [port]', 'enables http mode for the basicIO functions and start server at specified port' +
|
|
45
51
|
`(default: ${constants_1.DEFAULT.serve_port.http.basicio})`)
|
|
46
52
|
.option('--debug [port]', 'the functions are invoked from local environment enabling debugging options on provided port.' +
|
|
47
53
|
`(default: ${constants_1.DEFAULT.serve_port.debug.basicio})`)
|
|
54
|
+
.option('--tunnel <port>', 'start tunneling functions at the specified port')
|
|
55
|
+
.option('--enable-tunnel [tunnel-url]', 'enable tunneling for this particular command execution')
|
|
48
56
|
.option('--ignore-scripts', 'ignore the pre and post lifecycle scripts')
|
|
49
57
|
.option('--watch', 'watch for file and directory changes and enable hot reload' +
|
|
50
58
|
'\n' +
|
|
51
59
|
'(deprecated: The watch mode will be enabled by default. To disable watch mode use the --no-watch option)')
|
|
52
60
|
.option('--no-watch', 'disable watching the files for changes')
|
|
53
|
-
.needs('auth',
|
|
61
|
+
.needs('auth', constants_1.NEEDED_SCOPES.SERVE)
|
|
54
62
|
.needs('config')
|
|
55
63
|
.needs('rc')
|
|
56
64
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -62,5 +70,93 @@ exports.default = new command_1.default('functions:shell')
|
|
|
62
70
|
if (debugOpt && typeof debugOpt !== 'boolean') {
|
|
63
71
|
runtime_store_1.default.set('context.port.debug.bio', debugOpt);
|
|
64
72
|
}
|
|
73
|
+
const tunnelOpt = (0, option_1.getOptionValue)('tunnel', false);
|
|
74
|
+
if (tunnelOpt && typeof tunnelOpt !== 'boolean') {
|
|
75
|
+
runtime_store_1.default.set('context.port.tunnel', tunnelOpt);
|
|
76
|
+
}
|
|
77
|
+
const enableTunnelOpt = (0, option_1.getOptionValue)('enableTunnel', false);
|
|
78
|
+
if (!tunnelOpt && enableTunnelOpt) {
|
|
79
|
+
throw new error_1.default('Invalid Command. Use --enable-tunnel option with the -—tunnel option.', { exit: 1 });
|
|
80
|
+
}
|
|
81
|
+
if (enableTunnelOpt) {
|
|
82
|
+
const _tunnelAPI = yield (0, endpoints_1.tunnelAPI)();
|
|
83
|
+
const tunnelDetails = yield _tunnelAPI.getTunnel().catch((er) => {
|
|
84
|
+
const _er = error_1.default.getErrorInstance(er);
|
|
85
|
+
if (_er.status === 404) {
|
|
86
|
+
throw new error_1.default('Tunneling not configured', {
|
|
87
|
+
exit: 1,
|
|
88
|
+
errorId: 'FSHELL-1',
|
|
89
|
+
arg: [
|
|
90
|
+
(0, ansi_colors_1.bold)(`${(0, project_1.getProjectName)()}(${(0, project_1.getProjectId)()})`),
|
|
91
|
+
ansi_colors_1.italic.underline(`${constants_1.ORIGIN.console}/baas/${(0, project_1.getEnvId)()}/project/${(0, project_1.getProjectId)()}/Development#/settings/project/tunneling`)
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
throw _er;
|
|
96
|
+
});
|
|
97
|
+
if (tunnelDetails.tunnel_status === 'Disabled') {
|
|
98
|
+
runtime_store_1.default.set('context.fn_shell.enable_tunnel', enableTunnelOpt);
|
|
99
|
+
(0, logger_1.info)();
|
|
100
|
+
(0, logger_1.info)((0, ansi_colors_1.yellow)('Tunneling will be disabled at the end of this command execution'));
|
|
101
|
+
(0, logger_1.info)();
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
(0, logger_1.info)();
|
|
105
|
+
(0, logger_1.info)(`Tunneling is already enabled for the project ${(0, ansi_colors_1.bold)((0, project_1.getProjectName)())}(${(0, project_1.getProjectId)()}) with the configurations below:`);
|
|
106
|
+
(0, logger_1.info)();
|
|
107
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)('Tunneling URL: ') + ansi_colors_1.italic.underline(tunnelDetails.tunnel_url));
|
|
108
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)('Tunneled functions: '));
|
|
109
|
+
tunnelDetails.function_details.forEach((fn) => {
|
|
110
|
+
(0, logger_1.info)('* ' + fn.name);
|
|
111
|
+
});
|
|
112
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)('Enabled by: ') + (0, ansi_colors_1.italic)(tunnelDetails.created_by.email_id));
|
|
113
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)('Enabled on: ') + tunnelDetails.enabled_time);
|
|
114
|
+
(0, logger_1.info)();
|
|
115
|
+
if (typeof enableTunnelOpt === 'boolean') {
|
|
116
|
+
const continueAsIs = yield prompt_1.default.ask(prompt_1.default.question('consent', 'Do you wish to continue ?', {
|
|
117
|
+
type: 'list',
|
|
118
|
+
choices: [
|
|
119
|
+
prompt_1.default.choice('continue', { value: true, short: 'continue' }),
|
|
120
|
+
prompt_1.default.choice('abort', { value: false, short: 'aborted' })
|
|
121
|
+
]
|
|
122
|
+
}));
|
|
123
|
+
if (continueAsIs.consent === false) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
(0, logger_1.info)();
|
|
127
|
+
(0, logger_1.info)('Ignoring `--enable-tunnel` option since tunneling is already enabled');
|
|
128
|
+
(0, logger_1.info)();
|
|
129
|
+
}
|
|
130
|
+
else if (enableTunnelOpt !== tunnelDetails.tunnel_url) {
|
|
131
|
+
(0, logger_1.info)('Tunneling has already been enabled with a different tunneling URL.');
|
|
132
|
+
(0, logger_1.info)('Do you wish to update the tunnel request with the tunneling URL entered in the --enable-tunnel option?');
|
|
133
|
+
(0, logger_1.info)();
|
|
134
|
+
(0, logger_1.info)((0, ansi_colors_1.red)('- ' + tunnelDetails.tunnel_url));
|
|
135
|
+
(0, logger_1.info)((0, ansi_colors_1.green)('+ ' + enableTunnelOpt));
|
|
136
|
+
(0, logger_1.info)();
|
|
137
|
+
const updateCont = yield prompt_1.default.ask(prompt_1.default.question('consent', 'Do you wish to update and continue', {
|
|
138
|
+
type: 'list',
|
|
139
|
+
choices: [
|
|
140
|
+
prompt_1.default.choice('continue', { value: true, short: 'continue' }),
|
|
141
|
+
prompt_1.default.choice('abort', { value: false, short: 'aborted' })
|
|
142
|
+
]
|
|
143
|
+
}));
|
|
144
|
+
if (updateCont.consent === false) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
yield (yield (0, endpoints_1.tunnelAPI)()).disableTunnel();
|
|
148
|
+
runtime_store_1.default.set('context.fn_shell.enable_tunnel', enableTunnelOpt);
|
|
149
|
+
(0, logger_1.info)();
|
|
150
|
+
(0, logger_1.info)((0, ansi_colors_1.yellow)('Tunneling will be disabled at the end of this command execution'));
|
|
151
|
+
(0, logger_1.info)();
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
(0, logger_1.info)();
|
|
155
|
+
(0, logger_1.info)('Ignoring `--enable-tunnel` option since a tunnel already exists with the same tunnel url provided: ' +
|
|
156
|
+
ansi_colors_1.italic.underline(enableTunnelOpt));
|
|
157
|
+
(0, logger_1.info)();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
65
161
|
return (yield Promise.resolve().then(() => __importStar(require('../../shell')))).default();
|
|
66
162
|
}));
|
package/lib/commands/serve.js
CHANGED
|
@@ -49,7 +49,7 @@ exports.default = new command_1.default('serve')
|
|
|
49
49
|
.option('--except <targets>', 'serve all targets except specified (e.g. "client")')
|
|
50
50
|
.option('--ignore-scripts', 'ignore the pre and post lifescycle scripts')
|
|
51
51
|
.option('--no-open', 'disable opening the client automatically when served')
|
|
52
|
-
.needs('auth',
|
|
52
|
+
.needs('auth', constants_1.NEEDED_SCOPES.SERVE)
|
|
53
53
|
.needs('config')
|
|
54
54
|
.needs('rc')
|
|
55
55
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -45,7 +45,7 @@ function getConfigJsonInputs() {
|
|
|
45
45
|
const stack = yield (0, utils_1.validateOptions)(utils_1.validateStack, 'stack', runtimeDetailsPromise);
|
|
46
46
|
const platform = yield (0, utils_1.validateOptions)(utils_1.validatePlatform, 'platform', stack);
|
|
47
47
|
const optValues = {
|
|
48
|
-
|
|
48
|
+
build_path: yield (0, utils_1.validateOptions)(utils_1.validateBuildPath, 'buildPath'),
|
|
49
49
|
stack,
|
|
50
50
|
platform,
|
|
51
51
|
command: (0, option_1.getOptionValue)('command', false)
|
|
@@ -54,7 +54,7 @@ function getConfigJsonInputs() {
|
|
|
54
54
|
yield prompt_1.default.register('file-path');
|
|
55
55
|
const appConfigAns = yield prompt_1.default.ask(prompt_1.default.question('buildPath', 'Please provide the build directory of your AppSail service', {
|
|
56
56
|
type: 'file-path',
|
|
57
|
-
when: () => optValues.
|
|
57
|
+
when: () => optValues.build_path === false,
|
|
58
58
|
rootPath: cwd,
|
|
59
59
|
validate: ({ value }) => __awaiter(this, void 0, void 0, function* () {
|
|
60
60
|
const pathRes = (0, utils_1.validateBuildPath)(value);
|
|
@@ -190,7 +190,8 @@ exports.default = (standAlone = false) => __awaiter(void 0, void 0, void 0, func
|
|
|
190
190
|
text: `Preparing AppSail[${targ.name}]`
|
|
191
191
|
});
|
|
192
192
|
const zip = new archiver_1.default();
|
|
193
|
-
const
|
|
193
|
+
const buildPath = targ.buildPath ? targ.buildPath : targ.build_path;
|
|
194
|
+
const folderPath = (0, project_1.resolveProjectPath)(buildPath);
|
|
194
195
|
const ignoreFile = yield fs_1.ASYNC.readFile((0, path_1.join)(folderPath, constants_1.FILENAME.catalyst_ignore));
|
|
195
196
|
const folderContents = yield fs_1.ASYNC.walk(folderPath, {
|
|
196
197
|
filter: {
|
|
@@ -36,7 +36,7 @@ function validateOptions(validationFn, option, ...args) {
|
|
|
36
36
|
exports.validateOptions = validateOptions;
|
|
37
37
|
function validateBuildPath(path) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const cwd =
|
|
39
|
+
const cwd = process.cwd();
|
|
40
40
|
if (path) {
|
|
41
41
|
const buildPath = (0, path_1.isAbsolute)(path) ? path : (0, path_1.resolve)(cwd, path);
|
|
42
42
|
return (yield fs_1.ASYNC.dirExists(buildPath)) ? path : false;
|
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.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;
|
|
35
|
+
exports.tunnelAPI = 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* () {
|
|
@@ -177,3 +177,10 @@ function commonAPI() {
|
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
exports.commonAPI = commonAPI;
|
|
180
|
+
function tunnelAPI({ auth = true, projectId = (0, project_1.getProjectId)() } = {}) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const tunnel = (yield Promise.resolve().then(() => __importStar(require('./lib/tunnel')))).default;
|
|
183
|
+
return new tunnel(projectId, { authNeeded: auth });
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
exports.tunnelAPI = tunnelAPI;
|
package/lib/endpoints/lib/env.js
CHANGED
|
@@ -12,19 +12,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
15
16
|
const error_1 = __importDefault(require("../../error"));
|
|
16
17
|
const api_1 = __importDefault(require("../../internal/api"));
|
|
18
|
+
const constants_1 = require("../../util_modules/constants");
|
|
17
19
|
const logger_1 = require("../../util_modules/logger");
|
|
18
20
|
class Env {
|
|
19
21
|
constructor(opts, org) {
|
|
20
22
|
this.opts = opts;
|
|
21
23
|
this.opts.envId = org;
|
|
22
24
|
}
|
|
23
|
-
getEnvs(projectId) {
|
|
25
|
+
getEnvs(projectId, throwErr = true) {
|
|
24
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
27
|
const res = yield new api_1.default(this.opts).get('/baas/v1/project/' + projectId + '/environment');
|
|
26
28
|
if (res.body && res.body.data) {
|
|
27
|
-
|
|
29
|
+
const data = res.body.data;
|
|
30
|
+
if (throwErr) {
|
|
31
|
+
const devEnv = data.find((env) => env.env_name === constants_1.DEFAULT.env_name);
|
|
32
|
+
if ((devEnv === null || devEnv === void 0 ? void 0 : devEnv.env_status) === 'Blocked') {
|
|
33
|
+
throw new error_1.default('Environment blocked', {
|
|
34
|
+
exit: 1,
|
|
35
|
+
errorId: 'ENV-1',
|
|
36
|
+
arg: [
|
|
37
|
+
(0, ansi_colors_1.bold)(constants_1.DEFAULT.env_name),
|
|
38
|
+
(0, ansi_colors_1.bold)(projectId),
|
|
39
|
+
ansi_colors_1.bold.red('blocked'),
|
|
40
|
+
ansi_colors_1.italic.underline('support@zohocatalyst.com')
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return data;
|
|
28
46
|
}
|
|
29
47
|
(0, logger_1.debug)('get environment response from server : ' + JSON.stringify(res.body));
|
|
30
48
|
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
package/lib/endpoints/lib/sdk.js
CHANGED
|
@@ -29,10 +29,10 @@ class SDK {
|
|
|
29
29
|
if (service === constants_1.INTEG.services.cliq) {
|
|
30
30
|
return `/downloads/sdk/java/${constants_1.INTEG.service_map[service]}/${constants_1.INTEG.java_dependencies[service]}_latest.zip`;
|
|
31
31
|
}
|
|
32
|
-
return '/downloads/sdk/java/
|
|
32
|
+
return '/downloads/sdk/java/catalyst_java_sdk_beta.zip';
|
|
33
33
|
}
|
|
34
34
|
default: {
|
|
35
|
-
return '/downloads/sdk/java/
|
|
35
|
+
return '/downloads/sdk/java/catalyst_java_sdk_beta.zip';
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 logger_1 = require("../../util_modules/logger");
|
|
18
|
+
class TunnelAPI {
|
|
19
|
+
constructor(projectId, opts) {
|
|
20
|
+
this.projectId = projectId;
|
|
21
|
+
this.opts = opts;
|
|
22
|
+
}
|
|
23
|
+
getTunnel() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const res = yield new api_1.default(this.opts).get(`/baas/v1/project/${this.projectId}/tunneling`);
|
|
26
|
+
if (res.body && res.body.data) {
|
|
27
|
+
return res.body.data;
|
|
28
|
+
}
|
|
29
|
+
(0, logger_1.debug)('get tunnel response from server : ' + res.body);
|
|
30
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
31
|
+
exit: 2
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
enableTunnel(tunnelUrl) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const qs = {};
|
|
38
|
+
if (tunnelUrl) {
|
|
39
|
+
qs.tunnel_url = tunnelUrl;
|
|
40
|
+
}
|
|
41
|
+
const res = yield new api_1.default(this.opts).patch(`/baas/v1/project/${this.projectId}/tunneling`, {
|
|
42
|
+
qs
|
|
43
|
+
});
|
|
44
|
+
if (res.body && res.body.data) {
|
|
45
|
+
return res.body.data;
|
|
46
|
+
}
|
|
47
|
+
(0, logger_1.debug)('enable tunnel response from server : ' + res.body);
|
|
48
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
49
|
+
exit: 2
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
disableTunnel() {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const res = yield new api_1.default(this.opts).patch(`/baas/v1/project/${this.projectId}/tunneling`);
|
|
56
|
+
if (res.body && res.body.data) {
|
|
57
|
+
return res.body.data;
|
|
58
|
+
}
|
|
59
|
+
(0, logger_1.debug)('disable tunnel response from server : ' + res.body);
|
|
60
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
61
|
+
exit: 2
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = TunnelAPI;
|
|
@@ -148,7 +148,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
148
148
|
const appSail = yield prompt_1.default.ask(prompt_1.default.question('buildPath', 'Please provide the build path of your AppSail service: ', {
|
|
149
149
|
type: 'file-path',
|
|
150
150
|
validate: (pth) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
-
const buildPath = (0, path_1.resolve)(
|
|
151
|
+
const buildPath = (0, path_1.resolve)(process.cwd(), pth.value);
|
|
152
152
|
if ((yield fs_1.ASYNC.dirExists(buildPath)) || (yield fs_1.ASYNC.fileExists(buildPath))) {
|
|
153
153
|
return true;
|
|
154
154
|
}
|
|
@@ -182,7 +182,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
182
182
|
const appConfig = {
|
|
183
183
|
command: _appSailConfig.command ||
|
|
184
184
|
'echo Please specify the start-up command in the app-config.json file under the key command',
|
|
185
|
-
|
|
185
|
+
build_path: _appSailConfig.build || appSail.buildPath,
|
|
186
186
|
stack: appSailStack.runtime,
|
|
187
187
|
env_variables: {},
|
|
188
188
|
memory: _appSailConfig.memory || 256,
|
package/lib/internal/api.js
CHANGED
|
@@ -55,7 +55,10 @@ class API {
|
|
|
55
55
|
headers
|
|
56
56
|
};
|
|
57
57
|
if (!isExternal) {
|
|
58
|
-
this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { Accept: 'application/vnd.catalyst.v2+json', 'X-CATALYST-Environment': env
|
|
58
|
+
this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { Accept: 'application/vnd.catalyst.v2+json', 'X-CATALYST-Environment': env });
|
|
59
|
+
if (envId) {
|
|
60
|
+
this.requestOpts.headers['CATALYST-ORG'] = envId;
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { 'User-Agent': runtime_store_1.default.get('context.cli.package.name') +
|
|
61
64
|
'/' +
|
|
@@ -276,5 +279,10 @@ class API {
|
|
|
276
279
|
return this.fire('HEAD', path);
|
|
277
280
|
});
|
|
278
281
|
}
|
|
282
|
+
patch(path, options) {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
return this.fire('PATCH', path, options);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
279
287
|
}
|
|
280
288
|
exports.default = API;
|
package/lib/port-resolver.js
CHANGED
|
@@ -33,7 +33,7 @@ const featureRef = {
|
|
|
33
33
|
browserlogic: 'browser_logic'
|
|
34
34
|
};
|
|
35
35
|
class PortResolver {
|
|
36
|
-
static getFreePort(startPort, searchSpan, dupCheck) {
|
|
36
|
+
static getFreePort(startPort, searchSpan = 0, dupCheck = false) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
if (searchSpan < 0) {
|
|
39
39
|
throw new Error('unable to find port. searchSpan has reached the bottom line');
|
package/lib/repl-server.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const repl_1 = require("repl");
|
|
7
7
|
const util_1 = require("util");
|
|
8
8
|
const error_1 = __importDefault(require("./error"));
|
|
9
|
+
const logger_1 = require("./util_modules/logger");
|
|
9
10
|
const stdin = process.stdin;
|
|
10
11
|
const ASCII_ETX_CODE = 0x03;
|
|
11
12
|
class Repl {
|
|
@@ -108,5 +109,13 @@ class Repl {
|
|
|
108
109
|
});
|
|
109
110
|
});
|
|
110
111
|
}
|
|
112
|
+
write(str = '') {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
if (((_a = this.server) === null || _a === void 0 ? void 0 : _a.getCursorPos().cols) !== this.prompt.length) {
|
|
115
|
+
(_b = this.server) === null || _b === void 0 ? void 0 : _b.prompt();
|
|
116
|
+
}
|
|
117
|
+
(0, logger_1.info)(str);
|
|
118
|
+
(_c = this.server) === null || _c === void 0 ? void 0 : _c.prompt();
|
|
119
|
+
}
|
|
111
120
|
}
|
|
112
121
|
exports.default = Repl;
|
|
@@ -45,7 +45,7 @@ const startAppSail = (port, opts) => {
|
|
|
45
45
|
}).RAW();
|
|
46
46
|
};
|
|
47
47
|
exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
var _a, _b, _c;
|
|
48
|
+
var _a, _b, _c, _d;
|
|
49
49
|
let child;
|
|
50
50
|
const targetSail = serverDetails.target;
|
|
51
51
|
if (!targetSail || !targetSail.appSail) {
|
|
@@ -54,16 +54,17 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
|
|
|
54
54
|
if ((_a = targetSail.appSail.scripts) === null || _a === void 0 ? void 0 : _a.preserve) {
|
|
55
55
|
executeHook(targetSail.appSail.scripts.preserve, `AppSail [PRESERVE] [${(_b = targetSail.appSail) === null || _b === void 0 ? void 0 : _b.name}]`, targetSail.appSail.source);
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const buildPath = targetSail.appSail.buildPath
|
|
58
|
+
? targetSail.appSail.buildPath
|
|
59
|
+
: (_c = targetSail.appSail) === null || _c === void 0 ? void 0 : _c.build_path;
|
|
60
|
+
if (!(yield fs_1.ASYNC.isPathExists(buildPath))) {
|
|
61
|
+
throw new error_1.default(`Build path does not exists [${buildPath}]`, {
|
|
59
62
|
exit: 1,
|
|
60
63
|
errorId: 'SERVE-APPSAIL-1',
|
|
61
|
-
arg: [ansi_colors_1.italic.red(
|
|
64
|
+
arg: [ansi_colors_1.italic.red(buildPath), (0, ansi_colors_1.bold)(targetSail.appSail.name)]
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
|
-
const target = (yield fs_1.ASYNC.fileExists(
|
|
65
|
-
? (0, path_1.dirname)(targetSail.appSail.buildPath)
|
|
66
|
-
: targetSail.appSail.buildPath;
|
|
67
|
+
const target = (yield fs_1.ASYNC.fileExists(buildPath)) ? (0, path_1.dirname)(buildPath) : buildPath;
|
|
67
68
|
switch (true) {
|
|
68
69
|
case targetSail.appSail.stack.startsWith('node'): {
|
|
69
70
|
child = startAppSail(targetSail.port.appsail, {
|
|
@@ -139,7 +140,7 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
|
|
|
139
140
|
}
|
|
140
141
|
});
|
|
141
142
|
});
|
|
142
|
-
if ((
|
|
143
|
+
if ((_d = targetSail.appSail.scripts) === null || _d === void 0 ? void 0 : _d.postserve) {
|
|
143
144
|
child.once('exit', () => {
|
|
144
145
|
var _a, _b, _c, _d;
|
|
145
146
|
if (!((_a = targetSail.appSail) === null || _a === void 0 ? void 0 : _a.scripts)) {
|
|
@@ -32,6 +32,7 @@ const project_2 = require("../../../util_modules/project");
|
|
|
32
32
|
const option_1 = require("../../../util_modules/option");
|
|
33
33
|
const server_js_1 = require("../../../util_modules/server.js");
|
|
34
34
|
const http_proxy_1 = require("http-proxy");
|
|
35
|
+
const appsail_utils_1 = require("../../../appsail-utils");
|
|
35
36
|
const removeSecure = (str) => str.replace(/;\s?Secure/i, '').replace(/;\s?SameSite=None/i, '');
|
|
36
37
|
const redirectByAuth = (req, res, redirectUrl) => {
|
|
37
38
|
if (req.headers['x-zc-user-cred-token'] === undefined) {
|
|
@@ -92,21 +93,29 @@ const proxyResponseHandler = (systemRoutes) => (proxyRes, req, res) => {
|
|
|
92
93
|
}
|
|
93
94
|
};
|
|
94
95
|
function spinUpMaster(listenPort, otherServerDetails) {
|
|
95
|
-
var _a;
|
|
96
|
+
var _a, _b, _c, _d;
|
|
96
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
const projectDetails =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
const projectDetails = ((_b = (_a = otherServerDetails.appSail) === null || _a === void 0 ? void 0 : _a.at(0)) === null || _b === void 0 ? void 0 : _b.target) !== undefined
|
|
99
|
+
? {
|
|
100
|
+
id: (0, project_2.getProjectId)(),
|
|
101
|
+
domain_prefix: (0, appsail_utils_1.getDomainPrefix)((_c = otherServerDetails.appSail.at(0)) === null || _c === void 0 ? void 0 : _c.target),
|
|
102
|
+
domain: constants_1.ORIGIN.appSailDomain.replace('https://', ''),
|
|
103
|
+
key: (0, project_2.getDomainKey)(),
|
|
104
|
+
env_name: (0, project_2.getEnvName)()
|
|
105
|
+
}
|
|
106
|
+
: {
|
|
107
|
+
id: (0, project_2.getProjectId)(),
|
|
108
|
+
domain_prefix: (0, project_2.getDomainPrefix)(),
|
|
109
|
+
domain: constants_1.ORIGIN.app.replace('https://', ''),
|
|
110
|
+
key: (0, project_2.getDomainKey)(),
|
|
111
|
+
env_name: (0, project_2.getEnvName)()
|
|
112
|
+
};
|
|
104
113
|
const rules = runtime_store_1.default.get('context.apig.local.config', -1);
|
|
105
114
|
const customProxyUrl = (0, option_1.getOptionValue)('proxy');
|
|
106
115
|
const app = (0, express_1.default)();
|
|
107
116
|
let systemRoutes;
|
|
108
117
|
const nonApigURL = ['/accounts', '/clientoauth', '/_wms', '/wmssrv'];
|
|
109
|
-
app.use((0, logger_1.default)((
|
|
118
|
+
app.use((0, logger_1.default)((_d = otherServerDetails.appSail) === null || _d === void 0 ? void 0 : _d.at(0)));
|
|
110
119
|
app.use(cookie_parser_1.default);
|
|
111
120
|
app.use((0, project_1.default)(projectDetails));
|
|
112
121
|
app.use(authenticator_1.default);
|