zcatalyst-cli 1.7.1 → 1.9.1
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/README.md +31 -10
- package/docs/apig-utils.toml +69 -0
- package/docs/authentication/index.toml +15 -0
- package/docs/authentication/login.toml +14 -0
- package/docs/client-utils.toml +24 -0
- package/docs/command_needs/auth.toml +4 -0
- package/docs/command_needs/rc.toml +24 -0
- package/docs/commands/apig/disable.toml +4 -0
- package/docs/commands/apig/enable.toml +4 -0
- package/docs/commands/apig/status.toml +4 -0
- package/docs/commands/client/delete.toml +34 -0
- package/docs/commands/ds/export.toml +4 -0
- package/docs/commands/ds/import.toml +15 -0
- package/docs/commands/ds/status.toml +9 -0
- package/docs/commands/event/generate/index.toml +29 -0
- package/docs/commands/event/generate/integ.toml +4 -0
- package/docs/commands/functions/config.toml +11 -0
- package/docs/commands/functions/delete.toml +29 -0
- package/docs/commands/project/use.toml +9 -0
- package/docs/dc.toml +4 -0
- package/docs/deploy/features/apig.toml +4 -0
- package/docs/deploy/features/functions/index.toml +4 -0
- package/docs/event_generate/cache.toml +4 -0
- package/docs/event_generate/custom.toml +4 -0
- package/docs/event_generate/datastore.toml +4 -0
- package/docs/event_generate/filestore.toml +4 -0
- package/docs/event_generate/integration/cliq.toml +9 -0
- package/docs/execute-script.toml +19 -0
- package/docs/fn-utils/lib/common.toml +25 -0
- package/docs/fn-utils/lib/java.toml +34 -0
- package/docs/fn-utils/lib/node.toml +4 -0
- package/docs/init/index.toml +4 -0
- package/docs/internal/command.toml +4 -0
- package/docs/internal/config.toml +9 -0
- package/docs/internal/credential.toml +14 -0
- package/docs/option-filter.toml +45 -0
- package/docs/port-resolver.toml +9 -0
- package/docs/pull/index.toml +4 -0
- package/docs/serve/index.toml +4 -0
- package/docs/shell/index.toml +4 -0
- package/docs/util_modules/project.toml +9 -0
- package/lib/apig-utils.js +133 -43
- package/lib/archiver.js +4 -2
- package/lib/authentication/index.js +44 -9
- package/lib/authentication/login.js +51 -8
- package/lib/bin/catalyst.js +14 -7
- package/lib/client-utils.js +47 -14
- package/lib/client.js +1 -1
- package/lib/command_needs/auth.js +5 -3
- package/lib/command_needs/rc.js +35 -13
- package/lib/commands/apig/disable.js +8 -3
- package/lib/commands/apig/enable.js +8 -3
- package/lib/commands/apig/status.js +29 -9
- package/lib/commands/client/delete.js +65 -26
- package/lib/commands/client/setup.js +2 -2
- package/lib/commands/deploy.js +2 -2
- package/lib/commands/ds/export.js +16 -8
- package/lib/commands/ds/import.js +20 -14
- package/lib/commands/ds/status.js +22 -11
- package/lib/commands/event/generate/index.js +62 -12
- package/lib/commands/event/generate/integ.js +7 -3
- package/lib/commands/functions/add.js +2 -2
- package/lib/commands/functions/config.js +11 -3
- package/lib/commands/functions/delete.js +36 -13
- package/lib/commands/functions/setup.js +2 -2
- package/lib/commands/functions/shell.js +2 -2
- package/lib/commands/help.js +1 -1
- package/lib/commands/index.js +2 -3
- package/lib/commands/init.js +4 -4
- package/lib/commands/login.js +2 -2
- package/lib/commands/logout.js +2 -2
- package/lib/commands/project/list.js +2 -2
- package/lib/commands/project/reset.js +1 -1
- package/lib/commands/project/use.js +18 -2
- package/lib/commands/pull.js +5 -5
- package/lib/commands/run.js +2 -2
- package/lib/commands/serve.js +7 -6
- package/lib/commands/token/generate.js +2 -2
- package/lib/commands/token/list.js +2 -2
- package/lib/commands/token/revoke.js +2 -2
- package/lib/commands/whoami.js +1 -1
- package/lib/dc.js +11 -1
- package/lib/deploy/features/apig.js +33 -33
- package/lib/deploy/features/client.js +12 -19
- package/lib/deploy/features/functions/index.js +14 -4
- package/lib/deploy/features/index.js +1 -1
- package/lib/deploy/index.js +2 -9
- package/lib/endpoints/index.js +5 -2
- package/lib/endpoints/lib/apig.js +15 -5
- package/lib/endpoints/lib/applogic.js +12 -4
- package/lib/endpoints/lib/cache.js +9 -3
- package/lib/endpoints/lib/catalyst-details.js +37 -0
- package/lib/endpoints/lib/client.js +15 -5
- package/lib/endpoints/lib/datastore.js +6 -2
- package/lib/endpoints/lib/ds-bulk.js +15 -5
- package/lib/endpoints/lib/env.js +3 -1
- package/lib/endpoints/lib/event-bus.js +3 -1
- package/lib/endpoints/lib/filestore.js +6 -2
- package/lib/endpoints/lib/functions.js +12 -4
- package/lib/endpoints/lib/project.js +9 -3
- package/lib/endpoints/lib/queue.js +9 -3
- package/lib/endpoints/lib/sdk.js +3 -1
- package/lib/endpoints/lib/zcql.js +3 -1
- package/lib/error.js +18 -0
- package/lib/errorOut.js +10 -7
- package/lib/event_generate/cache.js +9 -1
- package/lib/event_generate/custom.js +6 -1
- package/lib/event_generate/datastore.js +12 -2
- package/lib/event_generate/filestore.js +9 -1
- package/lib/event_generate/integration/cliq.js +10 -2
- package/lib/execute-script.js +35 -6
- package/lib/express_middlewares/unknownReqProxy.js +18 -7
- package/lib/fn-utils/index.js +1 -1
- package/lib/fn-utils/lib/common.js +95 -17
- package/lib/fn-utils/lib/integ.js +4 -3
- package/lib/fn-utils/lib/java.js +49 -13
- package/lib/fn-utils/lib/node.js +15 -6
- package/lib/fn-watcher.js +67 -0
- package/lib/index.js +13 -12
- package/lib/init/dependencies/package-json.js +3 -1
- package/lib/init/features/functions/index.js +41 -29
- package/lib/init/features/functions/languages/java.js +5 -4
- package/lib/init/features/functions/languages/node.js +6 -5
- package/lib/init/features/index.js +8 -4
- package/lib/init/index.js +10 -3
- package/lib/internal/api.js +9 -9
- package/lib/internal/command.js +19 -14
- package/lib/internal/config.js +15 -15
- package/lib/internal/credential.js +33 -7
- package/lib/internal/rc.js +18 -10
- package/lib/migration/global/1.4.0.js +4 -2
- package/lib/migration/global/1.6.2.js +4 -2
- package/lib/migration/index.js +1 -1
- package/lib/option-filter.js +79 -22
- package/lib/optional-import.js +1 -1
- package/lib/plugin-loader.js +1 -1
- package/lib/port-resolver.js +23 -3
- package/lib/prompt.js +1 -1
- package/lib/pull/features/functions/index.js +7 -7
- package/lib/pull/features/index.js +1 -1
- package/lib/pull/index.js +10 -3
- package/lib/repl-server.js +9 -5
- package/lib/serve/features/index.js +11 -2
- package/lib/serve/index.js +19 -9
- package/lib/serve/server/index.js +137 -60
- package/lib/serve/server/lib/client.js +1 -1
- package/lib/serve/server/lib/master.js +16 -3
- package/lib/serve/server/lib/node.js +1 -1
- package/lib/shell/dependencies/http-functions.js +120 -90
- package/lib/shell/dependencies/invoker/integ/node.js +1 -1
- package/lib/shell/dependencies/local-function.js +86 -119
- package/lib/shell/index.js +10 -10
- package/lib/shell/prepare/index.js +1 -4
- package/lib/shell/prepare/languages/index.js +15 -4
- package/lib/track.js +4 -1
- package/lib/util_modules/config/index.js +1 -1
- package/lib/util_modules/config/lib/apig.js +3 -3
- package/lib/util_modules/config/lib/client.js +3 -3
- package/lib/util_modules/config/lib/functions.js +5 -5
- package/lib/util_modules/constants/index.js +22 -20
- package/lib/util_modules/constants/lib/regex.js +3 -2
- package/lib/util_modules/constants/lib/runtime.js +9 -0
- package/lib/util_modules/contextHelp.js +63 -123
- package/lib/util_modules/fs/index.js +1 -1
- package/lib/util_modules/fs/lib/async.js +19 -2
- package/lib/util_modules/fs/lib/sync.js +13 -1
- package/lib/util_modules/logger.js +12 -20
- package/lib/util_modules/option.js +1 -13
- package/lib/util_modules/project.js +75 -26
- package/lib/util_modules/shell.js +8 -2
- package/package.json +45 -45
- package/scripts/postInstall.js +31 -0
- package/lib/cjson.js +0 -20
- package/lib/log-error.js +0 -18
- package/lib/util_modules/big-json.js +0 -16
- package/lib/util_modules/constants/lib/stack.js +0 -6
- package/templates/init/functions/.DS_Store +0 -0
- package/templates/init/functions/node/.DS_Store +0 -0
- package/templates/init/functions/node/integ/.DS_Store +0 -0
|
@@ -18,72 +18,46 @@ const fn_utils_1 = require("../../fn-utils");
|
|
|
18
18
|
const credential_1 = __importDefault(require("../../internal/credential"));
|
|
19
19
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
20
20
|
const constants_1 = require("../../util_modules/constants");
|
|
21
|
+
const runtime_1 = __importDefault(require("../../util_modules/constants/lib/runtime"));
|
|
21
22
|
const fs_1 = require("../../util_modules/fs");
|
|
22
23
|
const js_1 = require("../../util_modules/js");
|
|
23
24
|
const logger_1 = require("../../util_modules/logger");
|
|
24
25
|
const project_1 = require("../../util_modules/project");
|
|
25
26
|
const shell_1 = require("../../util_modules/shell");
|
|
26
|
-
const languages_1 = require("../prepare/languages");
|
|
27
|
-
function prepareTarget(target) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
switch (target.stack) {
|
|
30
|
-
case constants_1.STACK.java8:
|
|
31
|
-
return languages_1.java([target]);
|
|
32
|
-
case constants_1.STACK.node10:
|
|
33
|
-
return languages_1.node([target]);
|
|
34
|
-
default:
|
|
35
|
-
throw new error_1.default('Unknown stack received', { exit: 2 });
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
27
|
class LocalFunction {
|
|
40
28
|
constructor(repl, target) {
|
|
29
|
+
var _a, _b, _c;
|
|
41
30
|
if (target.type === undefined || !Object.values(constants_1.FN_TYPE).includes(target.type)) {
|
|
42
31
|
throw new error_1.default('target type is not defined', { exit: 2 });
|
|
43
32
|
}
|
|
44
33
|
this.repl = repl;
|
|
34
|
+
this.watcher = target.watcher;
|
|
45
35
|
this.target = js_1.JS.omit(target, ['zip_stream', 'watcher']);
|
|
46
36
|
this.slave = null;
|
|
47
37
|
this.nodeInvoker = path_1.normalize(path_1.join(__dirname, './invoker', target.type, 'node.js'));
|
|
48
38
|
this.javaInvoker = path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'Java' + target.type + 'Invoker');
|
|
49
|
-
if (target.stack ===
|
|
39
|
+
if ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java)) {
|
|
50
40
|
fn_utils_1.fnUtils.java.ensureJavaInvoker(this.javaInvoker, path_1.normalize(path_1.join(__dirname, './invoker', target.type, 'java', 'Java' + target.type + 'Invoker.java')));
|
|
51
41
|
}
|
|
52
42
|
this.responseFile = path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'user_res_body');
|
|
53
43
|
this.metaFile = path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'user_meta.json');
|
|
54
44
|
this.call = this._call.bind(this);
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
target.watcher.on('all', (eventName, pth) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('preparing', () => {
|
|
46
|
+
if (!this.repl.paused) {
|
|
58
47
|
this.repl.pause();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.exitTimer = setTimeout(() => {
|
|
73
|
-
logger_1.info('\n(To exit, press ^C)');
|
|
74
|
-
}, 2000);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
logger_1.labeled(`functions(${target.name})`, 'ready!').MESSAGE();
|
|
79
|
-
if (this.exitTimer) {
|
|
80
|
-
clearTimeout(this.exitTimer);
|
|
81
|
-
}
|
|
82
|
-
this.repl.resume();
|
|
83
|
-
this.repl.showPrompt();
|
|
84
|
-
}
|
|
85
|
-
}));
|
|
86
|
-
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
(_c = this.watcher) === null || _c === void 0 ? void 0 : _c.on('compiled', () => {
|
|
51
|
+
logger_1.labeled(`functions(${target.name})`, 'ready!').MESSAGE();
|
|
52
|
+
if (this.repl.paused) {
|
|
53
|
+
repl.resume();
|
|
54
|
+
repl.showPrompt();
|
|
55
|
+
}
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
var _a;
|
|
58
|
+
(_a = this.watcher) === null || _a === void 0 ? void 0 : _a.emit('next');
|
|
59
|
+
}, 1000);
|
|
60
|
+
});
|
|
87
61
|
}
|
|
88
62
|
_call(rawData = {}) {
|
|
89
63
|
let data;
|
|
@@ -107,90 +81,86 @@ class LocalFunction {
|
|
|
107
81
|
return new error_1.default('Event bus details missing');
|
|
108
82
|
}
|
|
109
83
|
return (() => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
var _a, _b;
|
|
84
|
+
var _a, _b, _c, _d;
|
|
111
85
|
const accessToken = yield credential_1.default.getAccessToken();
|
|
112
86
|
const slaveOptions = [];
|
|
113
87
|
const debugPort = runtime_store_1.default.get('context.port.debug.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], null);
|
|
114
88
|
yield fs_1.ASYNC.ensureFile(this.responseFile, true);
|
|
115
89
|
yield fs_1.ASYNC.ensureFile(this.metaFile, true);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
if ((_a = this.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.nodejs)) {
|
|
91
|
+
if (debugPort !== null) {
|
|
92
|
+
slaveOptions.push('--inspect-brk=' + debugPort);
|
|
93
|
+
}
|
|
94
|
+
slaveOptions.push(this.nodeInvoker);
|
|
95
|
+
slaveOptions.push(JSON.stringify(this.target));
|
|
96
|
+
slaveOptions.push(data);
|
|
97
|
+
slaveOptions.push(JSON.stringify({
|
|
98
|
+
'x-zc-projectid': project_1.getProjectId(),
|
|
99
|
+
'x-zc-project-domain': project_1.getDomainPrefix() + '.' + constants_1.ORIGIN.app.replace('https://', ''),
|
|
100
|
+
'x-zc-project-key': project_1.getDomainKey(),
|
|
101
|
+
'x-zc-environment': project_1.getEnvName()
|
|
102
|
+
}));
|
|
103
|
+
slaveOptions.push(JSON.stringify({
|
|
104
|
+
'x-zc-user-cred-type': 'token',
|
|
105
|
+
'x-zc-user-cred-token': accessToken,
|
|
106
|
+
'x-zc-admin-cred-type': 'token',
|
|
107
|
+
'x-zc-admin-cred-token': accessToken
|
|
108
|
+
}));
|
|
109
|
+
slaveOptions.push(JSON.stringify(path_1.join(runtime_store_1.default.get('cwd'), '.build')));
|
|
110
|
+
this.slave = shell_1.spawn('node', slaveOptions, {
|
|
111
|
+
cwd: this.target.source,
|
|
112
|
+
stdio: 'pipe',
|
|
113
|
+
env: {
|
|
114
|
+
X_ZOHO_CATALYST_IS_LOCAL: 'true',
|
|
115
|
+
X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth,
|
|
116
|
+
X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
|
|
120
117
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
slaveOptions.push('-Xdebug');
|
|
155
|
-
slaveOptions.push('-Xrunjdwp:transport=dt_socket,address=' +
|
|
156
|
-
debugPort +
|
|
157
|
-
',server=y,suspend=y');
|
|
118
|
+
}).RAW();
|
|
119
|
+
}
|
|
120
|
+
else if ((_b = this.target.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java)) {
|
|
121
|
+
const javaInvokerDir = path_1.parse(this.javaInvoker).dir;
|
|
122
|
+
slaveOptions.push('-cp');
|
|
123
|
+
slaveOptions.push(javaInvokerDir + fn_utils_1.fnUtils.java.classPathSep + path_1.join(javaInvokerDir, 'lib', '*'));
|
|
124
|
+
if (debugPort !== null) {
|
|
125
|
+
slaveOptions.push('-Xdebug');
|
|
126
|
+
slaveOptions.push('-Xrunjdwp:transport=dt_socket,address=' + debugPort + ',server=y,suspend=y');
|
|
127
|
+
}
|
|
128
|
+
slaveOptions.push(path_1.basename(this.javaInvoker));
|
|
129
|
+
slaveOptions.push(javaInvokerDir);
|
|
130
|
+
slaveOptions.push(JSON.stringify(this.target));
|
|
131
|
+
slaveOptions.push(data);
|
|
132
|
+
slaveOptions.push(JSON.stringify({
|
|
133
|
+
'x-zc-projectid': project_1.getProjectId(),
|
|
134
|
+
'x-zc-project-domain': project_1.getDomainPrefix() + '.' + constants_1.ORIGIN.app.replace('https://', ''),
|
|
135
|
+
'x-zc-project-key': project_1.getDomainKey(),
|
|
136
|
+
'x-zc-environment': project_1.getEnvName()
|
|
137
|
+
}));
|
|
138
|
+
slaveOptions.push(JSON.stringify({
|
|
139
|
+
'x-zc-user-cred-type': 'token',
|
|
140
|
+
'x-zc-user-cred-token': accessToken,
|
|
141
|
+
'x-zc-admin-cred-type': 'token',
|
|
142
|
+
'x-zc-admin-cred-token': accessToken
|
|
143
|
+
}));
|
|
144
|
+
this.slave = shell_1.spawn('java', slaveOptions, {
|
|
145
|
+
cwd: this.target.source,
|
|
146
|
+
stdio: 'pipe',
|
|
147
|
+
env: {
|
|
148
|
+
X_ZOHO_CATALYST_IS_LOCAL: 'true',
|
|
149
|
+
X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth,
|
|
150
|
+
X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
|
|
158
151
|
}
|
|
159
|
-
|
|
160
|
-
slaveOptions.push(javaInvokerDir);
|
|
161
|
-
slaveOptions.push(JSON.stringify(this.target));
|
|
162
|
-
slaveOptions.push(data);
|
|
163
|
-
slaveOptions.push(JSON.stringify({
|
|
164
|
-
'x-zc-projectid': project_1.getProjectId(),
|
|
165
|
-
'x-zc-project-domain': project_1.getDomainPrefix() + '.' + constants_1.ORIGIN.app.replace('https://', ''),
|
|
166
|
-
'x-zc-project-key': project_1.getDomainKey(),
|
|
167
|
-
'x-zc-environment': project_1.getEnvName()
|
|
168
|
-
}));
|
|
169
|
-
slaveOptions.push(JSON.stringify({
|
|
170
|
-
'x-zc-user-cred-type': 'token',
|
|
171
|
-
'x-zc-user-cred-token': accessToken,
|
|
172
|
-
'x-zc-admin-cred-type': 'token',
|
|
173
|
-
'x-zc-admin-cred-token': accessToken
|
|
174
|
-
}));
|
|
175
|
-
this.slave = shell_1.spawn('java', slaveOptions, {
|
|
176
|
-
cwd: this.target.source,
|
|
177
|
-
stdio: 'pipe',
|
|
178
|
-
env: {
|
|
179
|
-
X_ZOHO_CATALYST_IS_LOCAL: 'true',
|
|
180
|
-
X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth,
|
|
181
|
-
X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
|
|
182
|
-
}
|
|
183
|
-
}).RAW();
|
|
184
|
-
break;
|
|
152
|
+
}).RAW();
|
|
185
153
|
}
|
|
186
154
|
if (this.slave === null) {
|
|
187
|
-
throw new error_1.default('Slave listening started before initialising', {
|
|
155
|
+
throw new error_1.default('Slave listening started before initialising', {
|
|
156
|
+
exit: 2
|
|
157
|
+
});
|
|
188
158
|
}
|
|
189
|
-
(
|
|
159
|
+
(_c = this.slave.stdout) === null || _c === void 0 ? void 0 : _c.on('data', (message) => {
|
|
190
160
|
shell_1.clearLine(process.stdout);
|
|
191
161
|
logger_1.info(message.toString());
|
|
192
162
|
});
|
|
193
|
-
(
|
|
163
|
+
(_d = this.slave.stderr) === null || _d === void 0 ? void 0 : _d.on('data', (message) => {
|
|
194
164
|
const errorStr = js_1.JS.trim(message.toString());
|
|
195
165
|
shell_1.clearLine(process.stdout);
|
|
196
166
|
logger_1.info(errorStr);
|
|
@@ -238,9 +208,6 @@ class LocalFunction {
|
|
|
238
208
|
if (this.slave) {
|
|
239
209
|
this.slave.kill('SIGINT');
|
|
240
210
|
}
|
|
241
|
-
if (this.exitTimer) {
|
|
242
|
-
clearTimeout(this.exitTimer);
|
|
243
|
-
}
|
|
244
211
|
if (this.watcher) {
|
|
245
212
|
this.watcher.close().then(res).catch(res);
|
|
246
213
|
}
|
package/lib/shell/index.js
CHANGED
|
@@ -12,7 +12,6 @@ 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 chokidar_1 = require("chokidar");
|
|
16
15
|
const path_1 = require("path");
|
|
17
16
|
const util_1 = require("util");
|
|
18
17
|
const repl_server_1 = __importDefault(require("../repl-server"));
|
|
@@ -27,6 +26,7 @@ const option_1 = require("../util_modules/option");
|
|
|
27
26
|
const http_functions_1 = __importDefault(require("./dependencies/http-functions"));
|
|
28
27
|
const local_function_1 = __importDefault(require("./dependencies/local-function"));
|
|
29
28
|
const prepare_1 = __importDefault(require("./prepare"));
|
|
29
|
+
const fn_watcher_1 = __importDefault(require("../fn-watcher"));
|
|
30
30
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
31
|
const replServer = new repl_server_1.default({
|
|
32
32
|
prompt: 'functions > ',
|
|
@@ -56,21 +56,21 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
56
56
|
return target.valid;
|
|
57
57
|
});
|
|
58
58
|
if (targets.length === 0) {
|
|
59
|
-
throw new error_1.default('No functions are ready for serving', {
|
|
59
|
+
throw new error_1.default('No functions are ready for serving', {
|
|
60
|
+
exit: 0,
|
|
61
|
+
errorId: 'SHELL-IDX-1'
|
|
62
|
+
});
|
|
60
63
|
}
|
|
61
64
|
replServer.start();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
cwd: target.source,
|
|
67
|
-
ignoreInitial: true
|
|
68
|
-
});
|
|
65
|
+
const watchOpt = option_1.getOptionValue('watch', false);
|
|
66
|
+
yield Promise.all(targets.map((target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
if (watchOpt) {
|
|
68
|
+
yield fn_watcher_1.default(target);
|
|
69
69
|
}
|
|
70
70
|
const localFn = new local_function_1.default(replServer, target);
|
|
71
71
|
replServer.setContext(target.name, localFn.call);
|
|
72
72
|
target.localFn = localFn;
|
|
73
|
-
});
|
|
73
|
+
})));
|
|
74
74
|
if (runtime_store_1.default.get('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], false)) {
|
|
75
75
|
yield httpServer.start();
|
|
76
76
|
}
|
|
@@ -32,10 +32,7 @@ exports.default = (fnTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
32
32
|
return target;
|
|
33
33
|
});
|
|
34
34
|
runtime_store_1.default.set('context.functions.targets', refinedTargets);
|
|
35
|
-
yield
|
|
36
|
-
languages_1.node(refinedTargets.filter((target) => target.stack === constants_1.STACK.node10 && target.valid)),
|
|
37
|
-
languages_1.java(refinedTargets.filter((target) => target.stack === constants_1.STACK.java8 && target.valid))
|
|
38
|
-
]);
|
|
35
|
+
yield languages_1.prepareFunctions(refinedTargets);
|
|
39
36
|
yield common_1.resolveAllFnPorts(refinedTargets);
|
|
40
37
|
return refinedTargets;
|
|
41
38
|
});
|
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
@@ -27,17 +27,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
30
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.
|
|
34
|
+
exports.prepareFunctions = void 0;
|
|
35
|
+
const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/runtime"));
|
|
32
36
|
function node(targets) {
|
|
33
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
38
|
return (yield Promise.resolve().then(() => __importStar(require('./node')))).default(targets);
|
|
35
39
|
});
|
|
36
40
|
}
|
|
37
|
-
exports.node = node;
|
|
38
41
|
function java(targets) {
|
|
39
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
43
|
return (yield Promise.resolve().then(() => __importStar(require('./java')))).default(targets);
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
|
-
|
|
46
|
+
function prepareFunctions(targets) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return Promise.all([
|
|
49
|
+
node(targets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.nodejs)) && target.valid; })),
|
|
50
|
+
java(targets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java)) && target.valid; }))
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.prepareFunctions = prepareFunctions;
|
package/lib/track.js
CHANGED
|
@@ -32,6 +32,10 @@ exports.default = (event, message, duration) => __awaiter(void 0, void 0, void 0
|
|
|
32
32
|
config_store_1.default.get('usage', false) &&
|
|
33
33
|
httpLog !== undefined) {
|
|
34
34
|
const httpLogger = yield endpoints_1.logAPI();
|
|
35
|
+
if (httpLogger === undefined) {
|
|
36
|
+
logger_1.debug('Unable to initialise the log API');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
35
39
|
winston_1.logger.remove(httpLog);
|
|
36
40
|
const rl = readline_1.createInterface({
|
|
37
41
|
input: fs_1.SYNC.getReadStream(path_1.join(httpLog.dirname, httpLog.filename)),
|
|
@@ -51,5 +55,4 @@ exports.default = (event, message, duration) => __awaiter(void 0, void 0, void 0
|
|
|
51
55
|
catch (err) {
|
|
52
56
|
logger_1.debug('Unable to send debug log to server: ' + err.message);
|
|
53
57
|
}
|
|
54
|
-
return Promise.resolve();
|
|
55
58
|
});
|
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
@@ -11,7 +11,7 @@ function raw(throwError = false) {
|
|
|
11
11
|
const config = runtime_store_1.default.get('config', null);
|
|
12
12
|
if (config === null) {
|
|
13
13
|
if (throwError) {
|
|
14
|
-
throw new error_1.default(constants_1.FILENAME.config + ' file is required', { exit:
|
|
14
|
+
throw new error_1.default(constants_1.FILENAME.config + ' file is required', { exit: 2 });
|
|
15
15
|
}
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
@@ -32,13 +32,13 @@ function script(name, fallback) {
|
|
|
32
32
|
const apigConfig = raw();
|
|
33
33
|
const rawScripts = apigConfig && (apigConfig === null || apigConfig === void 0 ? void 0 : apigConfig.scripts);
|
|
34
34
|
if (rawScripts === undefined && fallback === undefined) {
|
|
35
|
-
throw new error_1.default('Scripts not found', { exit:
|
|
35
|
+
throw new error_1.default('Scripts not found', { exit: 2 });
|
|
36
36
|
}
|
|
37
37
|
if (name === undefined) {
|
|
38
38
|
return rawScripts || fallback;
|
|
39
39
|
}
|
|
40
40
|
if (rawScripts && rawScripts[name] === undefined && fallback === undefined) {
|
|
41
|
-
throw new error_1.default('Scripts not found', { exit:
|
|
41
|
+
throw new error_1.default('Scripts not found', { exit: 2 });
|
|
42
42
|
}
|
|
43
43
|
return (rawScripts && rawScripts[name]) || fallback;
|
|
44
44
|
}
|
|
@@ -14,7 +14,7 @@ function raw(throwError = false) {
|
|
|
14
14
|
const config = runtime_store_1.default.get('config', null);
|
|
15
15
|
if (config === null) {
|
|
16
16
|
if (throwError) {
|
|
17
|
-
throw new error_1.default(constants_1.FILENAME.config + ' file is required', { exit:
|
|
17
|
+
throw new error_1.default(constants_1.FILENAME.config + ' file is required', { exit: 2 });
|
|
18
18
|
}
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
@@ -75,13 +75,13 @@ function script(name, fallback) {
|
|
|
75
75
|
const clientConfig = raw();
|
|
76
76
|
const rawScripts = clientConfig && (clientConfig === null || clientConfig === void 0 ? void 0 : clientConfig.scripts);
|
|
77
77
|
if (rawScripts === undefined && fallback === undefined) {
|
|
78
|
-
throw new error_1.default('Scripts not found', { exit:
|
|
78
|
+
throw new error_1.default('Scripts not found', { exit: 2 });
|
|
79
79
|
}
|
|
80
80
|
if (name === undefined) {
|
|
81
81
|
return rawScripts || fallback;
|
|
82
82
|
}
|
|
83
83
|
if (rawScripts && rawScripts[name] === undefined && fallback === undefined) {
|
|
84
|
-
throw new error_1.default('Scripts not found', { exit:
|
|
84
|
+
throw new error_1.default('Scripts not found', { exit: 2 });
|
|
85
85
|
}
|
|
86
86
|
return (rawScripts && rawScripts[name]) || fallback;
|
|
87
87
|
}
|
|
@@ -36,7 +36,7 @@ function raw(throwError = false) {
|
|
|
36
36
|
const config = runtime_store_1.default.get('config', null);
|
|
37
37
|
if (config === null) {
|
|
38
38
|
if (throwError) {
|
|
39
|
-
throw new error_1.default(constants_1.FILENAME.config + ' file is required', { exit:
|
|
39
|
+
throw new error_1.default(constants_1.FILENAME.config + ' file is required', { exit: 2 });
|
|
40
40
|
}
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
@@ -85,7 +85,7 @@ function targets(fallback) {
|
|
|
85
85
|
const rawTargetArr = getRawTargets();
|
|
86
86
|
if (rawTargetArr === null) {
|
|
87
87
|
if (fallback === undefined) {
|
|
88
|
-
throw new error_1.default('Function targets array is empty.', { exit:
|
|
88
|
+
throw new error_1.default('Function targets array is empty.', { exit: 2 });
|
|
89
89
|
}
|
|
90
90
|
return fallback;
|
|
91
91
|
}
|
|
@@ -96,7 +96,7 @@ function targets(fallback) {
|
|
|
96
96
|
if (typeof targetVal.source === 'string') {
|
|
97
97
|
return targetVal.source;
|
|
98
98
|
}
|
|
99
|
-
throw new error_1.default('Function target array is corrupted.', { exit:
|
|
99
|
+
throw new error_1.default('Function target array is corrupted.', { exit: 2 });
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
exports.targets = targets;
|
|
@@ -114,13 +114,13 @@ function script(name, fallback, sourcePath) {
|
|
|
114
114
|
rawScripts = functionConfig && (functionConfig === null || functionConfig === void 0 ? void 0 : functionConfig.scripts);
|
|
115
115
|
}
|
|
116
116
|
if (rawScripts === undefined && fallback === undefined) {
|
|
117
|
-
throw new error_1.default('Scripts not found', { exit:
|
|
117
|
+
throw new error_1.default('Scripts not found', { exit: 2 });
|
|
118
118
|
}
|
|
119
119
|
if (name === undefined) {
|
|
120
120
|
return rawScripts || fallback;
|
|
121
121
|
}
|
|
122
122
|
if (rawScripts && rawScripts[name] === undefined && fallback === undefined) {
|
|
123
|
-
throw new error_1.default('Scripts not found', { exit:
|
|
123
|
+
throw new error_1.default('Scripts not found', { exit: 2 });
|
|
124
124
|
}
|
|
125
125
|
return (rawScripts && rawScripts[name]) || fallback;
|
|
126
126
|
}
|
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ORIGIN = exports.TEMPLATE = exports.SCOPE = exports.REMOTE_REF = exports.REGEX = exports.REFERENCE = exports.PLACEHOLDER = exports.INTEG = exports.FOLDERNAME = exports.FN_TYPE = exports.DC_TYPE = exports.FILENAME = exports.EVENT_SOURCE = exports.EVENT_REF = exports.DEFAULT = exports.CLIQ = exports.AUTH = exports.APIG_RULES = void 0;
|
|
3
7
|
var apig_rules_1 = require("./lib/apig-rules");
|
|
4
|
-
Object.defineProperty(exports, "APIG_RULES", { enumerable: true, get: function () { return apig_rules_1.default; } });
|
|
8
|
+
Object.defineProperty(exports, "APIG_RULES", { enumerable: true, get: function () { return __importDefault(apig_rules_1).default; } });
|
|
5
9
|
var auth_1 = require("./lib/auth");
|
|
6
|
-
Object.defineProperty(exports, "AUTH", { enumerable: true, get: function () { return auth_1.default; } });
|
|
10
|
+
Object.defineProperty(exports, "AUTH", { enumerable: true, get: function () { return __importDefault(auth_1).default; } });
|
|
7
11
|
var cliq_handlers_1 = require("./lib/cliq-handlers");
|
|
8
|
-
Object.defineProperty(exports, "CLIQ", { enumerable: true, get: function () { return cliq_handlers_1.default; } });
|
|
12
|
+
Object.defineProperty(exports, "CLIQ", { enumerable: true, get: function () { return __importDefault(cliq_handlers_1).default; } });
|
|
9
13
|
var default_1 = require("./lib/default");
|
|
10
|
-
Object.defineProperty(exports, "DEFAULT", { enumerable: true, get: function () { return default_1.default; } });
|
|
14
|
+
Object.defineProperty(exports, "DEFAULT", { enumerable: true, get: function () { return __importDefault(default_1).default; } });
|
|
11
15
|
var event_action_1 = require("./lib/event-action");
|
|
12
|
-
Object.defineProperty(exports, "EVENT_REF", { enumerable: true, get: function () { return event_action_1.default; } });
|
|
16
|
+
Object.defineProperty(exports, "EVENT_REF", { enumerable: true, get: function () { return __importDefault(event_action_1).default; } });
|
|
13
17
|
var event_source_1 = require("./lib/event-source");
|
|
14
|
-
Object.defineProperty(exports, "EVENT_SOURCE", { enumerable: true, get: function () { return event_source_1.default; } });
|
|
18
|
+
Object.defineProperty(exports, "EVENT_SOURCE", { enumerable: true, get: function () { return __importDefault(event_source_1).default; } });
|
|
15
19
|
var file_names_1 = require("./lib/file-names");
|
|
16
|
-
Object.defineProperty(exports, "FILENAME", { enumerable: true, get: function () { return file_names_1.default; } });
|
|
20
|
+
Object.defineProperty(exports, "FILENAME", { enumerable: true, get: function () { return __importDefault(file_names_1).default; } });
|
|
17
21
|
var dc_type_1 = require("./lib/dc-type");
|
|
18
|
-
Object.defineProperty(exports, "DC_TYPE", { enumerable: true, get: function () { return dc_type_1.default; } });
|
|
22
|
+
Object.defineProperty(exports, "DC_TYPE", { enumerable: true, get: function () { return __importDefault(dc_type_1).default; } });
|
|
19
23
|
var fn_type_1 = require("./lib/fn-type");
|
|
20
|
-
Object.defineProperty(exports, "FN_TYPE", { enumerable: true, get: function () { return fn_type_1.default; } });
|
|
24
|
+
Object.defineProperty(exports, "FN_TYPE", { enumerable: true, get: function () { return __importDefault(fn_type_1).default; } });
|
|
21
25
|
var folder_names_1 = require("./lib/folder-names");
|
|
22
|
-
Object.defineProperty(exports, "FOLDERNAME", { enumerable: true, get: function () { return folder_names_1.default; } });
|
|
26
|
+
Object.defineProperty(exports, "FOLDERNAME", { enumerable: true, get: function () { return __importDefault(folder_names_1).default; } });
|
|
23
27
|
var integ_1 = require("./lib/integ");
|
|
24
|
-
Object.defineProperty(exports, "INTEG", { enumerable: true, get: function () { return integ_1.default; } });
|
|
28
|
+
Object.defineProperty(exports, "INTEG", { enumerable: true, get: function () { return __importDefault(integ_1).default; } });
|
|
25
29
|
var placeholders_1 = require("./lib/placeholders");
|
|
26
|
-
Object.defineProperty(exports, "PLACEHOLDER", { enumerable: true, get: function () { return placeholders_1.default; } });
|
|
30
|
+
Object.defineProperty(exports, "PLACEHOLDER", { enumerable: true, get: function () { return __importDefault(placeholders_1).default; } });
|
|
27
31
|
var ref_mapping_1 = require("./lib/ref-mapping");
|
|
28
|
-
Object.defineProperty(exports, "REFERENCE", { enumerable: true, get: function () { return ref_mapping_1.default; } });
|
|
32
|
+
Object.defineProperty(exports, "REFERENCE", { enumerable: true, get: function () { return __importDefault(ref_mapping_1).default; } });
|
|
29
33
|
var regex_1 = require("./lib/regex");
|
|
30
|
-
Object.defineProperty(exports, "REGEX", { enumerable: true, get: function () { return regex_1.default; } });
|
|
34
|
+
Object.defineProperty(exports, "REGEX", { enumerable: true, get: function () { return __importDefault(regex_1).default; } });
|
|
31
35
|
var remote_mapping_1 = require("./lib/remote-mapping");
|
|
32
|
-
Object.defineProperty(exports, "REMOTE_REF", { enumerable: true, get: function () { return remote_mapping_1.default; } });
|
|
36
|
+
Object.defineProperty(exports, "REMOTE_REF", { enumerable: true, get: function () { return __importDefault(remote_mapping_1).default; } });
|
|
33
37
|
var scopes_1 = require("./lib/scopes");
|
|
34
|
-
Object.defineProperty(exports, "SCOPE", { enumerable: true, get: function () { return scopes_1.default; } });
|
|
35
|
-
var stack_1 = require("./lib/stack");
|
|
36
|
-
Object.defineProperty(exports, "STACK", { enumerable: true, get: function () { return stack_1.default; } });
|
|
38
|
+
Object.defineProperty(exports, "SCOPE", { enumerable: true, get: function () { return __importDefault(scopes_1).default; } });
|
|
37
39
|
var template_1 = require("./lib/template");
|
|
38
|
-
Object.defineProperty(exports, "TEMPLATE", { enumerable: true, get: function () { return template_1.default; } });
|
|
40
|
+
Object.defineProperty(exports, "TEMPLATE", { enumerable: true, get: function () { return __importDefault(template_1).default; } });
|
|
39
41
|
var urls_1 = require("./lib/urls");
|
|
40
|
-
Object.defineProperty(exports, "ORIGIN", { enumerable: true, get: function () { return urls_1.default; } });
|
|
42
|
+
Object.defineProperty(exports, "ORIGIN", { enumerable: true, get: function () { return __importDefault(urls_1).default; } });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const functionName = /(?!^\d+$)^(\w|-)+$/g;
|
|
3
4
|
exports.default = Object.freeze({
|
|
4
5
|
project: {
|
|
5
6
|
name: /^[a-zA-Z0-9][a-zA-Z0-9-]*$/g
|
|
@@ -9,9 +10,9 @@ exports.default = Object.freeze({
|
|
|
9
10
|
},
|
|
10
11
|
functions: {
|
|
11
12
|
package: {
|
|
12
|
-
name:
|
|
13
|
+
name: functionName,
|
|
13
14
|
version: /(\d+)\.(\d+)\.(\d+)/g
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
|
-
folder_name:
|
|
17
|
+
folder_name: functionName
|
|
17
18
|
});
|