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
package/lib/migration/index.js
CHANGED
|
@@ -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
|
};
|
package/lib/option-filter.js
CHANGED
|
@@ -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
|
};
|
|
@@ -41,12 +41,26 @@ function enrichOptsData(opt, optValue, validTargets, multiTargetSupport = true)
|
|
|
41
41
|
.split(',')
|
|
42
42
|
.reduce((accumulator, entry, entryIndex, optArr) => {
|
|
43
43
|
if (optArr.indexOf(entry) !== entryIndex) {
|
|
44
|
-
|
|
44
|
+
optArr[entryIndex] = ansi_colors_1.red(optArr[entryIndex]);
|
|
45
|
+
throw new error_1.default(`Duplicate target found for ${ansi_colors_1.bold(entry)}.`, {
|
|
46
|
+
exit: 1,
|
|
47
|
+
errorId: 'OPT-FILTER-1',
|
|
48
|
+
arg: [
|
|
49
|
+
ansi_colors_1.bold('--' + opt),
|
|
50
|
+
ansi_colors_1.bold('Option input: ') + ansi_colors_1.italic('--' + opt + ' ' + optArr.join(','))
|
|
51
|
+
]
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
const entrySet = entry.split(':');
|
|
47
55
|
if (!validTargets.includes(entrySet[0])) {
|
|
48
|
-
throw new error_1.default(`Invalid target "${entrySet[0]}" specified for option "${opt}"
|
|
49
|
-
exit: 1
|
|
56
|
+
throw new error_1.default(`Invalid target "${entrySet[0]}" specified for option "${opt}".`, {
|
|
57
|
+
exit: 1,
|
|
58
|
+
errorId: 'OPT-FILTER-2',
|
|
59
|
+
arg: [
|
|
60
|
+
ansi_colors_1.bold.red(entrySet[0]),
|
|
61
|
+
ansi_colors_1.bold('--' + opt),
|
|
62
|
+
ansi_colors_1.bold(validTargets.map((target) => '* ' + target).join('\n'))
|
|
63
|
+
]
|
|
50
64
|
});
|
|
51
65
|
}
|
|
52
66
|
if (!multiTargetSupport && accumulator.some((res) => res.target === entrySet[0])) {
|
|
@@ -58,11 +72,24 @@ function enrichOptsData(opt, optValue, validTargets, multiTargetSupport = true)
|
|
|
58
72
|
hasFilter: false,
|
|
59
73
|
target: entrySet[0]
|
|
60
74
|
};
|
|
61
|
-
if (accumulator.some((res) =>
|
|
62
|
-
|
|
63
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
if (accumulator.some((res, idx) => {
|
|
76
|
+
const truthy = res.target === entrySet[0] &&
|
|
77
|
+
((res.hasFilter && entrySet.length === 1) ||
|
|
78
|
+
(!res.hasFilter && entrySet.length === 2));
|
|
79
|
+
if (truthy) {
|
|
80
|
+
optArr[idx] = ansi_colors_1.red(optArr[idx]);
|
|
81
|
+
optArr[entryIndex] = ansi_colors_1.red(optArr[entryIndex]);
|
|
82
|
+
}
|
|
83
|
+
return truthy;
|
|
84
|
+
})) {
|
|
85
|
+
throw new error_1.default(`Target "${entrySet[0]}" is specified with and without a filter for option "${opt}".`, {
|
|
86
|
+
exit: 1,
|
|
87
|
+
errorId: 'OPT-FILTER-3',
|
|
88
|
+
arg: [
|
|
89
|
+
ansi_colors_1.bold.red(entrySet[0]),
|
|
90
|
+
ansi_colors_1.bold('--' + opt),
|
|
91
|
+
ansi_colors_1.bold('Option input: ') + ansi_colors_1.italic(`--${opt} ${optArr.join(',')}`)
|
|
92
|
+
]
|
|
66
93
|
});
|
|
67
94
|
}
|
|
68
95
|
if (entrySet.length > 1) {
|
|
@@ -79,7 +106,9 @@ function enrichOptsData(opt, optValue, validTargets, multiTargetSupport = true)
|
|
|
79
106
|
function validateTargets() {
|
|
80
107
|
if (option_1.getOptionValue('except', false) && option_1.getOptionValue('only', false)) {
|
|
81
108
|
throw new error_1.default('Cannot specify both --only and --except', {
|
|
82
|
-
exit: 1
|
|
109
|
+
exit: 1,
|
|
110
|
+
errorId: 'OPT-FILTER-4',
|
|
111
|
+
arg: [ansi_colors_1.bold('--only'), ansi_colors_1.bold('--except')]
|
|
83
112
|
});
|
|
84
113
|
}
|
|
85
114
|
const enrichedOnlyOpts = enrichOptsData('only', option_1.getOptionValue('only'), validGlobalTargets);
|
|
@@ -95,10 +124,26 @@ function validateTargets() {
|
|
|
95
124
|
function validatePorts() {
|
|
96
125
|
const customHttpPort = option_1.getOptionValue('http', false);
|
|
97
126
|
const enrichedDebugOpts = enrichOptsData('debug', option_1.getOptionValue('debug'), Object.keys(constants_1.DEFAULT.serve_port.debug));
|
|
98
|
-
if (enrichedDebugOpts.some((opt) =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
'
|
|
127
|
+
if (enrichedDebugOpts.some((opt) => {
|
|
128
|
+
const noFilter = !opt.hasFilter;
|
|
129
|
+
if (opt.target === 'client') {
|
|
130
|
+
throw new error_1.default('Client cannot be debugged', {
|
|
131
|
+
exit: 1,
|
|
132
|
+
errorId: 'OPT-FILTER-5'
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return noFilter;
|
|
136
|
+
})) {
|
|
137
|
+
throw new error_1.default('Cannot specify "--debug <target>" alone.', {
|
|
138
|
+
exit: 1,
|
|
139
|
+
errorId: 'OPT-FILTER-6',
|
|
140
|
+
arg: [
|
|
141
|
+
ansi_colors_1.bold('--debug'),
|
|
142
|
+
ansi_colors_1.italic.red('--debug <target>'),
|
|
143
|
+
ansi_colors_1.bold('* basicio: ') + ansi_colors_1.italic.green('--debug basicio:<port>'),
|
|
144
|
+
ansi_colors_1.bold('* advancedio: ') + ansi_colors_1.italic.green('--debug advancedio:<name>:<port>')
|
|
145
|
+
]
|
|
146
|
+
});
|
|
102
147
|
}
|
|
103
148
|
return {
|
|
104
149
|
port: customHttpPort,
|
|
@@ -110,7 +155,16 @@ function filterPorts() {
|
|
|
110
155
|
runtime_store_1.default.set(`context.port.http.master`, validOptResultants.port);
|
|
111
156
|
validOptResultants.debug.forEach((res) => {
|
|
112
157
|
if (res.target === constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.advanced] && !res.specific) {
|
|
113
|
-
throw new error_1.default('
|
|
158
|
+
throw new error_1.default('Invalid input format for advancedio target', {
|
|
159
|
+
exit: 1,
|
|
160
|
+
errorId: 'OPT-FILTER-7',
|
|
161
|
+
arg: [
|
|
162
|
+
ansi_colors_1.bold('--debug'),
|
|
163
|
+
ansi_colors_1.bold('advancedio'),
|
|
164
|
+
ansi_colors_1.italic.red('--debug advancedio:<name|port>'),
|
|
165
|
+
ansi_colors_1.italic.green('--debug advancedio:<name>:<port>')
|
|
166
|
+
]
|
|
167
|
+
});
|
|
114
168
|
}
|
|
115
169
|
else if (res.target === constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic]) {
|
|
116
170
|
runtime_store_1.default.set(`context.port.debug.${res.target}`, res.filter);
|
|
@@ -155,16 +209,19 @@ function filterTargets() {
|
|
|
155
209
|
}
|
|
156
210
|
targets = js_1.JS.uniq(targets);
|
|
157
211
|
if (targets.length === 0) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
constants_1.FILENAME.config
|
|
161
|
-
|
|
162
|
-
exit: 1
|
|
212
|
+
const aid = option_1.getOptionValue('except', false)
|
|
213
|
+
? `the ${ansi_colors_1.bold('--except')} option does not rule out all the valid targets.`
|
|
214
|
+
: `the desired features are initialised in the ${ansi_colors_1.bold(constants_1.FILENAME.config)} file.`;
|
|
215
|
+
throw new error_1.default('Cannot understand what targets.', {
|
|
216
|
+
exit: 1,
|
|
217
|
+
errorId: 'OPT-FILTER-8',
|
|
218
|
+
arg: [aid]
|
|
163
219
|
});
|
|
164
220
|
}
|
|
165
221
|
if (targets.length === 1 && targets.includes('apig') && option_1.getCurrentCommand() === 'serve') {
|
|
166
|
-
throw new error_1.default('API Gateway cannot be served separately
|
|
167
|
-
exit: 1
|
|
222
|
+
throw new error_1.default('API Gateway cannot be served separately', {
|
|
223
|
+
exit: 1,
|
|
224
|
+
errorId: 'OPT-FILTER-9'
|
|
168
225
|
});
|
|
169
226
|
}
|
|
170
227
|
runtime_store_1.default.set('context.targets', targets);
|
package/lib/optional-import.js
CHANGED
|
@@ -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
|
};
|
package/lib/plugin-loader.js
CHANGED
|
@@ -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
|
};
|
package/lib/port-resolver.js
CHANGED
|
@@ -12,6 +12,7 @@ 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 portfinder_1 = require("portfinder");
|
|
16
17
|
const error_1 = __importDefault(require("./error"));
|
|
17
18
|
const runtime_store_1 = __importDefault(require("./runtime-store"));
|
|
@@ -26,7 +27,10 @@ class PortResolver {
|
|
|
26
27
|
if (searchSpan < 0) {
|
|
27
28
|
throw new Error('unable find port. searchSpan has reached the bottom line');
|
|
28
29
|
}
|
|
29
|
-
const port = yield portfinder_1.getPortPromise({
|
|
30
|
+
const port = yield portfinder_1.getPortPromise({
|
|
31
|
+
port: startPort,
|
|
32
|
+
stopPort: startPort + searchSpan
|
|
33
|
+
});
|
|
30
34
|
if (PortResolver.isPortTaken(port)) {
|
|
31
35
|
if (dupCheck) {
|
|
32
36
|
return PortResolver.getFreePort(port + 1, searchSpan - (port - startPort), dupCheck);
|
|
@@ -64,9 +68,25 @@ class PortResolver {
|
|
|
64
68
|
}
|
|
65
69
|
catch (e) {
|
|
66
70
|
if (searchSpan === 0) {
|
|
67
|
-
throw new error_1.default(`Provided port '${port}' is not available
|
|
71
|
+
throw new error_1.default(`Provided port '${port}' is not available`, {
|
|
72
|
+
exit: 1,
|
|
73
|
+
original: e,
|
|
74
|
+
errorId: 'PORT-RESOLVER-1',
|
|
75
|
+
arg: [
|
|
76
|
+
ansi_colors_1.bold.red(port + ''),
|
|
77
|
+
type === 'debug' ? 'debugging' : 'serving',
|
|
78
|
+
ansi_colors_1.bold(feature),
|
|
79
|
+
name,
|
|
80
|
+
type
|
|
81
|
+
]
|
|
82
|
+
});
|
|
68
83
|
}
|
|
69
|
-
throw new error_1.default(`No ports from '${port}' to ${port + searchSpan} is free to use as a ${type} port.`, {
|
|
84
|
+
throw new error_1.default(`No ports from '${port}' to ${port + searchSpan} is free to use as a ${type} port.`, {
|
|
85
|
+
exit: 1,
|
|
86
|
+
original: e,
|
|
87
|
+
errorId: 'PORT-RESOLVER-2',
|
|
88
|
+
arg: [ansi_colors_1.bold(port + ''), ansi_colors_1.bold(port + searchSpan + ''), ansi_colors_1.bold('--' + type)]
|
|
89
|
+
});
|
|
70
90
|
}
|
|
71
91
|
if (finalPort !== port) {
|
|
72
92
|
logger_1.debug(`${type} port : '${port}' is not available. Hence port '${finalPort}' will be used instead.`);
|
package/lib/prompt.js
CHANGED
|
@@ -20,7 +20,7 @@ exports.default = {
|
|
|
20
20
|
return new inquirer_1.default.Separator(line);
|
|
21
21
|
},
|
|
22
22
|
choice: (name, _a = {}) => {
|
|
23
|
-
var { value = name, short =
|
|
23
|
+
var { value = name, short = name, disabled = false, checked = false } = _a, otherOpts = __rest(_a, ["value", "short", "disabled", "checked"]);
|
|
24
24
|
return Object.assign({ name,
|
|
25
25
|
value,
|
|
26
26
|
short,
|
|
@@ -25,6 +25,7 @@ const fs_1 = require("../../../util_modules/fs");
|
|
|
25
25
|
const js_1 = require("../../../util_modules/js");
|
|
26
26
|
const logger_1 = require("../../../util_modules/logger");
|
|
27
27
|
const project_1 = require("../../../util_modules/project");
|
|
28
|
+
const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/runtime"));
|
|
28
29
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
30
|
const fnAPI = yield endpoints_1.functionsAPI();
|
|
30
31
|
const fnDirName = config_1.functionsConfig.source();
|
|
@@ -104,19 +105,18 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
104
105
|
}));
|
|
105
106
|
runtime_store_1.default.set('context.functions.targets', targets);
|
|
106
107
|
targets = yield Promise.all(targets.map((fn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
var _a, _b;
|
|
107
109
|
yield fs_1.ASYNC.ensureDir(fn.source);
|
|
108
110
|
const buffer = (yield fnAPI.download(fn.id));
|
|
109
111
|
yield new archiver_1.default()
|
|
110
112
|
.load(buffer)
|
|
111
113
|
.extract('/', path_1.join(fnDirPath, fn.name), { isFolder: true })
|
|
112
114
|
.finalize();
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
yield languages_1.java(fn);
|
|
119
|
-
break;
|
|
115
|
+
if ((_a = fn.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.nodejs)) {
|
|
116
|
+
yield languages_1.node(fn);
|
|
117
|
+
}
|
|
118
|
+
else if ((_b = fn.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java)) {
|
|
119
|
+
yield languages_1.java(fn);
|
|
120
120
|
}
|
|
121
121
|
return fn;
|
|
122
122
|
})));
|
|
@@ -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
|
};
|
package/lib/pull/index.js
CHANGED
|
@@ -26,9 +26,16 @@ function pull() {
|
|
|
26
26
|
}
|
|
27
27
|
const feature = featureList.shift();
|
|
28
28
|
if (!Object.keys(features_1.default).includes(feature)) {
|
|
29
|
-
throw new error_1.default(
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
throw new error_1.default('invalid feature for pull', {
|
|
30
|
+
exit: 1,
|
|
31
|
+
errorId: 'PULL-1',
|
|
32
|
+
arg: [
|
|
33
|
+
ansi_colors_1.bold.red(feature),
|
|
34
|
+
ansi_colors_1.bold(Object.keys(features_1.default)
|
|
35
|
+
.map((feat) => '* ' + feat)
|
|
36
|
+
.join('\n'))
|
|
37
|
+
]
|
|
38
|
+
});
|
|
32
39
|
}
|
|
33
40
|
const MODULE = features_1.default[feature];
|
|
34
41
|
logger_1.info(ansi_colors_1.bold('\n' + ansi_colors_1.white('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
|
package/lib/repl-server.js
CHANGED
|
@@ -39,13 +39,15 @@ class Repl {
|
|
|
39
39
|
}
|
|
40
40
|
emit(eventName, ...inputs) {
|
|
41
41
|
if (this.server === null) {
|
|
42
|
-
throw new error_1.default('emit cannot be called before server is started');
|
|
42
|
+
throw new error_1.default('emit cannot be called before server is started', { exit: 2 });
|
|
43
43
|
}
|
|
44
44
|
return this.server.emit(eventName, inputs);
|
|
45
45
|
}
|
|
46
46
|
showPrompt() {
|
|
47
47
|
if (this.server === null) {
|
|
48
|
-
throw new error_1.default('showPrompt cannot be called before server is started'
|
|
48
|
+
throw new error_1.default('showPrompt cannot be called before server is started', {
|
|
49
|
+
exit: 2
|
|
50
|
+
});
|
|
49
51
|
}
|
|
50
52
|
if (!this.closed) {
|
|
51
53
|
this.server.displayPrompt();
|
|
@@ -53,7 +55,7 @@ class Repl {
|
|
|
53
55
|
}
|
|
54
56
|
setContext(command, exe) {
|
|
55
57
|
if (this.server === null) {
|
|
56
|
-
throw new error_1.default('context cannot be set before server is started');
|
|
58
|
+
throw new error_1.default('context cannot be set before server is started', { exit: 2 });
|
|
57
59
|
}
|
|
58
60
|
const context = this.server.context;
|
|
59
61
|
this.context.push({ command, exe });
|
|
@@ -65,7 +67,7 @@ class Repl {
|
|
|
65
67
|
}
|
|
66
68
|
close() {
|
|
67
69
|
if (this.server === null) {
|
|
68
|
-
throw new error_1.default('close cannot be called before server is started');
|
|
70
|
+
throw new error_1.default('close cannot be called before server is started', { exit: 2 });
|
|
69
71
|
}
|
|
70
72
|
this.server.close();
|
|
71
73
|
}
|
|
@@ -95,7 +97,9 @@ class Repl {
|
|
|
95
97
|
wait() {
|
|
96
98
|
return new Promise((res) => {
|
|
97
99
|
if (this.server === null) {
|
|
98
|
-
throw new error_1.default('wait cannot be called before server is started'
|
|
100
|
+
throw new error_1.default('wait cannot be called before server is started', {
|
|
101
|
+
exit: 2
|
|
102
|
+
});
|
|
99
103
|
}
|
|
100
104
|
this.server.on('close', () => {
|
|
101
105
|
this.resume();
|
|
@@ -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
|
};
|
|
@@ -35,10 +35,19 @@ exports.apig = exports.functions = exports.client = void 0;
|
|
|
35
35
|
const port_resolver_1 = __importDefault(require("../../port-resolver"));
|
|
36
36
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
37
37
|
const constants_1 = require("../../util_modules/constants");
|
|
38
|
+
const logger_1 = require("../../util_modules/logger");
|
|
38
39
|
function client() {
|
|
39
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
41
|
const clientModule = yield Promise.resolve().then(() => __importStar(require('./client')));
|
|
41
|
-
|
|
42
|
+
try {
|
|
43
|
+
yield clientModule.default();
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
logger_1.info();
|
|
47
|
+
logger_1.warning('Skipping the serve of Client because of the error: ' + err.message);
|
|
48
|
+
logger_1.info();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
42
51
|
const clientName = runtime_store_1.default.get('context.client.name');
|
|
43
52
|
const finalPort = yield port_resolver_1.default.getPort('client', 'http', clientName);
|
|
44
53
|
runtime_store_1.default.set('context.port.http.client.' + clientName, finalPort);
|
package/lib/serve/index.js
CHANGED
|
@@ -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
|
};
|
|
@@ -35,25 +35,29 @@ const path_1 = require("path");
|
|
|
35
35
|
const client_utils_1 = require("../client-utils");
|
|
36
36
|
const error_1 = __importDefault(require("../error"));
|
|
37
37
|
const fn_utils_1 = require("../fn-utils");
|
|
38
|
+
const fn_watcher_1 = __importDefault(require("../fn-watcher"));
|
|
38
39
|
const port_resolver_1 = __importDefault(require("../port-resolver"));
|
|
39
40
|
const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
40
41
|
const http_functions_1 = __importDefault(require("../shell/dependencies/http-functions"));
|
|
41
42
|
const constants_1 = require("../util_modules/constants");
|
|
42
43
|
const fs_1 = require("../util_modules/fs");
|
|
43
44
|
const logger_1 = require("../util_modules/logger");
|
|
45
|
+
const option_1 = require("../util_modules/option");
|
|
44
46
|
const features = __importStar(require("./features"));
|
|
45
47
|
const server_1 = __importDefault(require("./server"));
|
|
46
48
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
|
|
49
|
+
const serveTargets = runtime_store_1.default.get('context.targets', []);
|
|
48
50
|
const advancedServer = new server_1.default();
|
|
49
51
|
const basicFnServer = new http_functions_1.default();
|
|
50
52
|
try {
|
|
51
53
|
const masterPort = yield port_resolver_1.default.getPort('master', 'http', 'master', false);
|
|
52
54
|
runtime_store_1.default.set('context.port.http.master', masterPort);
|
|
53
55
|
yield Promise.all(serveTargets.map((target) => features[target]()));
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
.
|
|
56
|
+
const rawTargets = runtime_store_1.default.get('context.functions.targets', []);
|
|
57
|
+
if (option_1.getOptionValue('watch', false)) {
|
|
58
|
+
yield Promise.all(rawTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () { return (target.valid ? fn_watcher_1.default(target) : undefined); })));
|
|
59
|
+
}
|
|
60
|
+
const funtionTargets = rawTargets.filter((target) => {
|
|
57
61
|
if (!target.valid) {
|
|
58
62
|
logger_1.warning('skipping serve of function [' +
|
|
59
63
|
target.name +
|
|
@@ -67,11 +71,17 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
67
71
|
return target.valid;
|
|
68
72
|
});
|
|
69
73
|
if (serveTargets.includes('client')) {
|
|
70
|
-
|
|
74
|
+
const client = runtime_store_1.default.get('context.client', false);
|
|
75
|
+
if (client && client.valid) {
|
|
76
|
+
advancedServer.add('client', client);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
serveTargets.splice(serveTargets.indexOf('client'), 1);
|
|
80
|
+
}
|
|
71
81
|
}
|
|
72
82
|
if (serveTargets.includes('functions') && funtionTargets.length === 0) {
|
|
73
83
|
logger_1.labeled('functions', 'No targets are ready to be served in local').WARN();
|
|
74
|
-
serveTargets
|
|
84
|
+
serveTargets.splice(serveTargets.indexOf('functions'), 1);
|
|
75
85
|
runtime_store_1.default.set('context.targets', serveTargets);
|
|
76
86
|
}
|
|
77
87
|
if (serveTargets.includes('functions')) {
|
|
@@ -79,15 +89,15 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
79
89
|
}
|
|
80
90
|
if (serveTargets.length === 0 ||
|
|
81
91
|
(serveTargets.length === 1 && serveTargets[0] === 'apig')) {
|
|
82
|
-
throw new error_1.default('No components to serve
|
|
92
|
+
throw new error_1.default('No components to serve', { exit: 0, errorId: 'SERVE-1' });
|
|
83
93
|
}
|
|
84
|
-
yield advancedServer.start();
|
|
85
94
|
const basicFn = runtime_store_1.default
|
|
86
95
|
.get('context.functions.targets', [])
|
|
87
96
|
.find((target) => target.type === constants_1.FN_TYPE.basic && target.valid);
|
|
88
97
|
if (basicFn) {
|
|
89
98
|
yield basicFnServer.start();
|
|
90
99
|
}
|
|
100
|
+
yield advancedServer.start();
|
|
91
101
|
yield advancedServer.wait();
|
|
92
102
|
yield Promise.all([
|
|
93
103
|
fs_1.ASYNC.deleteDir(path_1.join(runtime_store_1.default.get('cwd'), '.build')).catch(),
|