zcatalyst-cli 1.11.1 → 1.13.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/optional-import.toml +10 -0
- package/lib/apig-utils.js +39 -39
- package/lib/archiver.js +13 -9
- package/lib/authentication/index.js +22 -18
- package/lib/authentication/login.js +37 -39
- package/lib/bin/catalyst.js +15 -15
- package/lib/cli_table/src/cell.js +26 -26
- package/lib/cli_table/src/layout-manager.js +44 -45
- package/lib/cli_table/src/table.js +9 -9
- package/lib/cli_table/src/utils.js +35 -36
- package/lib/client-utils.js +18 -18
- package/lib/client.js +1 -1
- package/lib/command_needs/auth.js +7 -7
- package/lib/command_needs/rc.js +24 -24
- package/lib/commands/apig/disable.js +5 -5
- package/lib/commands/apig/enable.js +5 -5
- package/lib/commands/apig/status.js +9 -9
- package/lib/commands/client/delete.js +19 -19
- package/lib/commands/client/setup.js +8 -4
- package/lib/commands/deploy.js +18 -14
- package/lib/commands/ds/export.js +11 -11
- package/lib/commands/ds/import.js +12 -12
- package/lib/commands/ds/status.js +15 -15
- package/lib/commands/event/generate/index.js +21 -17
- package/lib/commands/event/generate/integ.js +7 -3
- package/lib/commands/functions/add.js +8 -4
- package/lib/commands/functions/config.js +5 -5
- package/lib/commands/functions/delete.js +22 -22
- package/lib/commands/functions/setup.js +8 -4
- package/lib/commands/functions/shell.js +12 -5
- package/lib/commands/help.js +4 -4
- package/lib/commands/iac/export.js +8 -8
- package/lib/commands/iac/import.js +29 -21
- package/lib/commands/iac/pack.js +15 -11
- package/lib/commands/iac/status.js +6 -2
- package/lib/commands/index.js +5 -1
- package/lib/commands/init.js +14 -10
- package/lib/commands/login.js +5 -1
- package/lib/commands/logout.js +5 -1
- package/lib/commands/project/list.js +14 -10
- package/lib/commands/project/reset.js +5 -5
- package/lib/commands/project/use.js +9 -9
- package/lib/commands/pull.js +18 -14
- package/lib/commands/run.js +13 -9
- package/lib/commands/serve.js +5 -1
- package/lib/commands/token/generate.js +6 -2
- package/lib/commands/token/list.js +7 -3
- package/lib/commands/token/revoke.js +6 -2
- package/lib/commands/whoami.js +3 -3
- package/lib/dc.js +2 -2
- package/lib/deploy/features/apig.js +6 -6
- package/lib/deploy/features/client.js +1 -1
- package/lib/deploy/features/functions/index.js +9 -9
- package/lib/deploy/features/index.js +5 -1
- package/lib/deploy/index.js +2 -2
- package/lib/endpoints/index.js +17 -13
- package/lib/endpoints/lib/apig.js +5 -5
- package/lib/endpoints/lib/applogic.js +4 -4
- package/lib/endpoints/lib/cache.js +3 -3
- package/lib/endpoints/lib/catalyst-details.js +1 -1
- package/lib/endpoints/lib/client.js +5 -5
- package/lib/endpoints/lib/datastore.js +2 -2
- package/lib/endpoints/lib/ds-bulk.js +5 -5
- package/lib/endpoints/lib/env.js +1 -1
- package/lib/endpoints/lib/event-bus.js +1 -1
- package/lib/endpoints/lib/filestore.js +2 -2
- package/lib/endpoints/lib/functions.js +4 -4
- package/lib/endpoints/lib/iac.js +10 -10
- package/lib/endpoints/lib/project.js +20 -5
- package/lib/endpoints/lib/queue.js +3 -3
- package/lib/endpoints/lib/sdk.js +1 -1
- package/lib/endpoints/lib/zcql.js +1 -1
- package/lib/error.js +11 -9
- package/lib/errorOut.js +2 -2
- package/lib/event_generate/cache.js +5 -5
- package/lib/event_generate/custom.js +2 -2
- package/lib/event_generate/datastore.js +5 -5
- package/lib/event_generate/filestore.js +5 -5
- package/lib/event_generate/integration/cliq.js +3 -3
- package/lib/event_generate/user.js +1 -1
- package/lib/event_generate/webapp.js +5 -5
- package/lib/execute-script.js +19 -15
- package/lib/express_middlewares/authenticator.js +32 -5
- package/lib/express_middlewares/logger.js +2 -2
- package/lib/express_middlewares/unknownReqProxy.js +1 -1
- package/lib/fn-utils/index.js +5 -1
- package/lib/fn-utils/lib/common.js +44 -44
- package/lib/fn-utils/lib/integ.js +9 -9
- package/lib/fn-utils/lib/java.js +48 -46
- package/lib/fn-utils/lib/node.js +8 -8
- package/lib/fn-watcher.js +9 -11
- package/lib/iac/status/bundle.js +5 -5
- package/lib/iac/status/deploy.js +4 -4
- package/lib/index.js +2 -2
- package/lib/init/dependencies/npm-install.js +8 -1
- package/lib/init/dependencies/package-json.js +6 -6
- package/lib/init/features/client/index.js +5 -1
- package/lib/init/features/client/initializers/angular.js +29 -27
- package/lib/init/features/client/initializers/basic.js +10 -6
- package/lib/init/features/client/initializers/lyte.js +12 -13
- package/lib/init/features/client/initializers/react.js +23 -18
- package/lib/init/features/functions/index.js +23 -14
- package/lib/init/features/functions/languages/java.js +10 -10
- package/lib/init/features/functions/languages/node.js +9 -9
- package/lib/init/features/index.js +12 -8
- package/lib/init/features/project.js +20 -20
- package/lib/init/index.js +2 -2
- package/lib/init/util/client.js +12 -7
- package/lib/init/util/functions.js +1 -1
- package/lib/init/util/project.js +4 -4
- package/lib/internal/api.js +19 -19
- package/lib/internal/command.js +20 -16
- package/lib/internal/config.js +5 -5
- package/lib/internal/credential.js +10 -10
- package/lib/internal/crypt.js +5 -5
- package/lib/internal/rc.js +5 -5
- package/lib/migration/global/1.6.2.js +3 -3
- package/lib/migration/index.js +22 -18
- package/lib/option-filter.js +34 -30
- package/lib/optional-import.js +30 -11
- package/lib/plugin-loader.js +28 -13
- package/lib/port-resolver.js +4 -4
- package/lib/progress.js +2 -2
- package/lib/prompt/index.js +6 -2
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/pull/features/apig.js +9 -9
- package/lib/pull/features/client.js +7 -7
- package/lib/pull/features/functions/index.js +15 -15
- package/lib/pull/features/index.js +5 -1
- package/lib/pull/index.js +4 -4
- package/lib/repl-server.js +2 -2
- package/lib/serve/features/apig.js +1 -1
- package/lib/serve/features/index.js +8 -4
- package/lib/serve/index.js +15 -11
- package/lib/serve/server/index.js +34 -27
- package/lib/serve/server/lib/java/JavaaioServer.java +5 -3
- package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/zip4j-2.5.0.jar +0 -0
- package/lib/serve/server/lib/master.js +33 -36
- package/lib/serve/server/lib/node.js +7 -3
- package/lib/serve/server/lib/web_client/index.js +3 -3
- package/lib/serve/server/lib/web_client/server.js +33 -30
- package/lib/shell/dependencies/http-functions.js +38 -33
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +14 -3
- package/lib/shell/dependencies/invoker/bio/node.js +5 -2
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/integ/node.js +8 -4
- package/lib/shell/dependencies/local-function.js +44 -40
- package/lib/shell/index.js +16 -12
- package/lib/shell/prepare/index.js +2 -2
- package/lib/shell/prepare/languages/index.js +5 -1
- package/lib/shell/prepare/languages/java.js +1 -1
- package/lib/throbber/index.js +17 -17
- package/lib/throbber/utils.js +9 -9
- package/lib/track.js +7 -7
- package/lib/util_modules/config/index.js +5 -1
- package/lib/util_modules/config/lib/client.js +18 -21
- package/lib/util_modules/constants/lib/auth.js +6 -6
- package/lib/util_modules/constants/lib/cliq-handlers.js +2 -2
- package/lib/util_modules/constants/lib/template.js +21 -21
- package/lib/util_modules/constants/lib/urls.js +20 -12
- package/lib/util_modules/context-help.js +15 -15
- package/lib/util_modules/fs/index.js +5 -1
- package/lib/util_modules/fs/lib/async.js +4 -4
- package/lib/util_modules/fs/utils.js +1 -1
- package/lib/util_modules/global-space.js +0 -97
- package/lib/util_modules/logger.js +2 -2
- package/lib/util_modules/parser/toml.js +1 -1
- package/lib/util_modules/project.js +6 -6
- package/lib/util_modules/server.js +53 -0
- package/lib/util_modules/shell.js +4 -4
- package/lib/winston.js +5 -5
- package/package.json +40 -40
- package/scripts/postInstall.js +7 -6
- package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +23 -5
- package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +23 -8
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -3
- package/templates/init/functions/node/integ/cliq/package.json +2 -1
- package/templates/init/functions/node/integ/cliq/sample.js +3 -1
- package/docs/.DS_Store +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/react/.DS_Store +0 -0
package/lib/fn-utils/lib/node.js
CHANGED
|
@@ -16,10 +16,10 @@ exports.validate = void 0;
|
|
|
16
16
|
const ansi_colors_1 = require("ansi-colors");
|
|
17
17
|
const path_1 = require("path");
|
|
18
18
|
const error_1 = __importDefault(require("../../error"));
|
|
19
|
+
const npm_install_1 = __importDefault(require("../../init/dependencies/npm-install"));
|
|
19
20
|
const constants_1 = require("../../util_modules/constants");
|
|
20
21
|
const fs_1 = require("../../util_modules/fs");
|
|
21
22
|
const js_1 = require("../../util_modules/js");
|
|
22
|
-
const shell_1 = require("../../util_modules/shell");
|
|
23
23
|
function validate(targets, idx) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
if (targets.length < idx + 1) {
|
|
@@ -27,14 +27,14 @@ function validate(targets, idx) {
|
|
|
27
27
|
}
|
|
28
28
|
const currentTarget = targets[idx];
|
|
29
29
|
try {
|
|
30
|
-
const catalystFile = path_1.join(currentTarget.source, constants_1.FILENAME.catalyst_config);
|
|
30
|
+
const catalystFile = (0, path_1.join)(currentTarget.source, constants_1.FILENAME.catalyst_config);
|
|
31
31
|
const data = yield fs_1.ASYNC.readJSONFile(catalystFile, { checkpath: true });
|
|
32
32
|
if (data === undefined) {
|
|
33
33
|
throw new error_1.default('no ' + constants_1.FILENAME.catalyst_config + ' file found', {
|
|
34
34
|
exit: 1
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
const indexFile = path_1.join(currentTarget.source, js_1.JS.get(data, 'execution.main', 'index.js'));
|
|
37
|
+
const indexFile = (0, path_1.join)(currentTarget.source, js_1.JS.get(data, 'execution.main', 'index.js'));
|
|
38
38
|
currentTarget.index = indexFile;
|
|
39
39
|
const indexFileExists = yield fs_1.ASYNC.fileExists(indexFile);
|
|
40
40
|
if (!indexFileExists) {
|
|
@@ -42,15 +42,15 @@ function validate(targets, idx) {
|
|
|
42
42
|
errorId: 'NODE-1',
|
|
43
43
|
exit: 1,
|
|
44
44
|
arg: [
|
|
45
|
-
ansi_colors_1.bold(currentTarget.index || 'undefined'),
|
|
46
|
-
ansi_colors_1.bold(constants_1.FILENAME.catalyst_config),
|
|
47
|
-
ansi_colors_1.bold(currentTarget.name)
|
|
45
|
+
(0, ansi_colors_1.bold)(currentTarget.index || 'undefined'),
|
|
46
|
+
(0, ansi_colors_1.bold)(constants_1.FILENAME.catalyst_config),
|
|
47
|
+
(0, ansi_colors_1.bold)(currentTarget.name)
|
|
48
48
|
]
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
const nodeModuleExists = yield fs_1.ASYNC.dirExists(path_1.join(currentTarget.source, constants_1.FILENAME.node_modules));
|
|
51
|
+
const nodeModuleExists = yield fs_1.ASYNC.dirExists((0, path_1.join)(currentTarget.source, constants_1.FILENAME.node_modules));
|
|
52
52
|
if (!nodeModuleExists) {
|
|
53
|
-
yield
|
|
53
|
+
yield (0, npm_install_1.default)(currentTarget.source, true);
|
|
54
54
|
}
|
|
55
55
|
currentTarget.valid = true;
|
|
56
56
|
return validate(targets, ++idx);
|
package/lib/fn-watcher.js
CHANGED
|
@@ -12,13 +12,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const chokidar_1 = require("chokidar");
|
|
13
13
|
const languages_1 = require("./shell/prepare/languages");
|
|
14
14
|
const logger_1 = require("./util_modules/logger");
|
|
15
|
-
const shell_1 = require("./util_modules/shell");
|
|
16
15
|
exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
16
|
return new Promise((res) => {
|
|
18
17
|
let paused = false;
|
|
19
18
|
let latestEvent;
|
|
20
|
-
const watcher = chokidar_1.watch(target.source, {
|
|
21
|
-
ignored: /(^|[\/\\])\../,
|
|
19
|
+
const watcher = (0, chokidar_1.watch)(target.source, {
|
|
20
|
+
ignored: [/(^|[\/\\])\../, 'node_modules/**/*', '/**/*.jar'],
|
|
22
21
|
cwd: target.source,
|
|
23
22
|
ignoreInitial: true
|
|
24
23
|
});
|
|
@@ -28,12 +27,11 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
29
|
const currentLatestEvent = latestEvent;
|
|
31
|
-
|
|
32
|
-
logger_1.info(`\n${currentLatestEvent.evnt} of ${currentLatestEvent.pth} in ${target.name} detected. Preparing your function, please wait...`);
|
|
30
|
+
(0, logger_1.info)(`\n${currentLatestEvent.evnt} of ${currentLatestEvent.pth} in ${target.name} detected. Preparing your function, please wait...`);
|
|
33
31
|
watcher.emit('preparing');
|
|
34
32
|
target.failure_reason = undefined;
|
|
35
33
|
target.valid = true;
|
|
36
|
-
yield languages_1.prepareFunctions([target]);
|
|
34
|
+
yield (0, languages_1.prepareFunctions)([target]);
|
|
37
35
|
if (currentLatestEvent.at === latestEvent.at) {
|
|
38
36
|
latestEvent = undefined;
|
|
39
37
|
}
|
|
@@ -41,9 +39,9 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
41
39
|
watcher.emit('compiled');
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
|
-
logger_1.warning('target [' + target.name + '] is not a valid one reason : ' + target.failure_reason);
|
|
45
|
-
logger_1.info('Waiting for correction..');
|
|
46
|
-
logger_1.info('\n(To exit, press ^C)');
|
|
42
|
+
(0, logger_1.warning)('target [' + target.name + '] is not a valid one reason : ' + target.failure_reason);
|
|
43
|
+
(0, logger_1.info)('Waiting for correction..');
|
|
44
|
+
(0, logger_1.info)('\n(To exit, press ^C)');
|
|
47
45
|
watcher.emit('next');
|
|
48
46
|
}));
|
|
49
47
|
watcher.on('all', (evnt, pth) => {
|
|
@@ -59,8 +57,8 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
59
57
|
res();
|
|
60
58
|
});
|
|
61
59
|
watcher.on('error', (err) => {
|
|
62
|
-
logger_1.debug(err);
|
|
63
|
-
logger_1.warning(`Unable to start watcher for target [${target.name}]. Skipping watch mode.`);
|
|
60
|
+
(0, logger_1.debug)(err);
|
|
61
|
+
(0, logger_1.warning)(`Unable to start watcher for target [${target.name}]. Skipping watch mode.`);
|
|
64
62
|
res();
|
|
65
63
|
});
|
|
66
64
|
});
|
package/lib/iac/status/bundle.js
CHANGED
|
@@ -23,8 +23,8 @@ const fs_1 = require("../../util_modules/fs");
|
|
|
23
23
|
const path_1 = require("path");
|
|
24
24
|
const option_1 = require("../../util_modules/option");
|
|
25
25
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
const env = option_1.getOptionValue('production', false) ? 'Production' : 'Development';
|
|
27
|
-
const getSpinnerTxt = util_1.getSpinnerTxt('bundle');
|
|
26
|
+
const env = (0, option_1.getOptionValue)('production', false) ? 'Production' : 'Development';
|
|
27
|
+
const getSpinnerTxt = (0, util_1.getSpinnerTxt)('bundle');
|
|
28
28
|
const iacAPI = new iac_1.default(undefined, { env });
|
|
29
29
|
const bundleStatus = yield iacAPI.bundleStatus();
|
|
30
30
|
if (bundleStatus === undefined) {
|
|
@@ -60,12 +60,12 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
60
60
|
timerAPI.end(undefined, true);
|
|
61
61
|
break;
|
|
62
62
|
default:
|
|
63
|
-
logger_1.debug('Unknown status received : ', data.status);
|
|
63
|
+
(0, logger_1.debug)('Unknown status received : ', data.status);
|
|
64
64
|
timerAPI.end();
|
|
65
65
|
}
|
|
66
66
|
}));
|
|
67
67
|
timerAPI.on('error', (e) => {
|
|
68
|
-
logger_1.debug('Error encounted :', e);
|
|
68
|
+
(0, logger_1.debug)('Error encounted :', e);
|
|
69
69
|
});
|
|
70
70
|
timerAPI.on('end', () => throbber.stopAll());
|
|
71
71
|
timerAPI.start();
|
|
@@ -76,7 +76,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
76
76
|
const hrTime = process.hrtime();
|
|
77
77
|
const fileName = `export_${bundleStatus.id}_${hrTime[0] * 1000000000 + hrTime[1]}.zip`;
|
|
78
78
|
const bundlezip = yield iacAPI.bundleDownload();
|
|
79
|
-
return fs_1.ASYNC.writeFile(path_1.join(process.cwd(), fileName), bundlezip);
|
|
79
|
+
return fs_1.ASYNC.writeFile((0, path_1.join)(process.cwd(), fileName), bundlezip);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
});
|
package/lib/iac/status/deploy.js
CHANGED
|
@@ -20,8 +20,8 @@ const throbber_1 = __importDefault(require("../../throbber"));
|
|
|
20
20
|
const logger_1 = require("../../util_modules/logger");
|
|
21
21
|
const util_1 = require("./util");
|
|
22
22
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const getSpinnerTxt = util_1.getSpinnerTxt('deploy');
|
|
24
|
-
const idOpt = option_1.getOptionValue('id', false);
|
|
23
|
+
const getSpinnerTxt = (0, util_1.getSpinnerTxt)('deploy');
|
|
24
|
+
const idOpt = (0, option_1.getOptionValue)('id', false);
|
|
25
25
|
const iacAPI = new iac_1.default();
|
|
26
26
|
const allDeploys = yield iacAPI.allDeploys();
|
|
27
27
|
if (allDeploys.length <= 0) {
|
|
@@ -61,12 +61,12 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
61
61
|
timerAPI.end(undefined, true);
|
|
62
62
|
break;
|
|
63
63
|
default:
|
|
64
|
-
logger_1.debug('Unknown status received : ', data.status);
|
|
64
|
+
(0, logger_1.debug)('Unknown status received : ', data.status);
|
|
65
65
|
timerAPI.end();
|
|
66
66
|
}
|
|
67
67
|
}));
|
|
68
68
|
timerAPI.on('error', (e) => {
|
|
69
|
-
logger_1.debug('Error encounted : ', e);
|
|
69
|
+
(0, logger_1.debug)('Error encounted : ', e);
|
|
70
70
|
});
|
|
71
71
|
timerAPI.on('end', () => throbber.stopAll());
|
|
72
72
|
timerAPI.start();
|
package/lib/index.js
CHANGED
|
@@ -20,8 +20,8 @@ program.option('--dc <us|eu|in>', 'Supply a data center for a command');
|
|
|
20
20
|
program.option('--verbose', 'Change the log level to verbose for debugging purposes');
|
|
21
21
|
program.helpOption('-h, --help', 'Display help for a Catalyst command');
|
|
22
22
|
program.showSuggestionAfterError();
|
|
23
|
-
program.showHelpAfterError(`For more usage information use the ${ansi_colors_1.bold('catalyst help')} command`);
|
|
23
|
+
program.showHelpAfterError(`For more usage information use the ${(0, ansi_colors_1.bold)('catalyst help')} command`);
|
|
24
24
|
program.addHelpText('before', fs_1.SYNC.readFile(constants_1.TEMPLATE.banner, 'utf-8') || '');
|
|
25
|
-
program.addHelpText('afterAll', `\nFor detailed documentations please visit ${ansi_colors_1.underline('https://www.zoho.com/catalyst/help/cli-command-reference.html')}`);
|
|
25
|
+
program.addHelpText('afterAll', `\nFor detailed documentations please visit ${(0, ansi_colors_1.underline)('https://www.zoho.com/catalyst/help/cli-command-reference.html')}`);
|
|
26
26
|
const cli = new client_1.Client(program);
|
|
27
27
|
exports.default = cli;
|
|
@@ -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 error_1 = __importDefault(require("../../error"));
|
|
15
16
|
const prompt_1 = __importDefault(require("../../prompt"));
|
|
16
17
|
const shell_1 = require("../../util_modules/shell");
|
|
17
18
|
exports.default = (pth, skipPrompt = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -21,7 +22,13 @@ exports.default = (pth, skipPrompt = false) => __awaiter(void 0, void 0, void 0,
|
|
|
21
22
|
when: () => !skipPrompt
|
|
22
23
|
}));
|
|
23
24
|
if (ans.NPMinstall === undefined || ans.NPMinstall) {
|
|
24
|
-
return shell_1.spawn('npm', ['install'], { cwd: pth })
|
|
25
|
+
return (0, shell_1.spawn)('npm', ['install'], { cwd: pth })
|
|
26
|
+
.ASYNC()
|
|
27
|
+
.catch((err) => {
|
|
28
|
+
throw error_1.default.getErrorInstance(err, {
|
|
29
|
+
message: 'Failure when executing npm install.'
|
|
30
|
+
});
|
|
31
|
+
});
|
|
25
32
|
}
|
|
26
33
|
return;
|
|
27
34
|
});
|
|
@@ -23,12 +23,12 @@ const js_1 = require("../../util_modules/js");
|
|
|
23
23
|
const logger_1 = require("../../util_modules/logger");
|
|
24
24
|
const project_1 = require("../../util_modules/project");
|
|
25
25
|
exports.default = (templateJsonDir = 'package.json', keys) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
const templateJsonPath = path_1.join(templateJsonDir, 'package.json');
|
|
26
|
+
const templateJsonPath = (0, path_1.join)(templateJsonDir, 'package.json');
|
|
27
27
|
const qns = keys.map((qn) => {
|
|
28
28
|
switch (qn) {
|
|
29
29
|
case 'name':
|
|
30
30
|
return prompt_1.default.question('name', 'package name: ', {
|
|
31
|
-
defaultAns: js_1.JS.snakeCase(project_1.getProjectName('sample') + '_function'),
|
|
31
|
+
defaultAns: js_1.JS.snakeCase((0, project_1.getProjectName)('sample') + '_function'),
|
|
32
32
|
validate: (ans) => {
|
|
33
33
|
if (ans.match(constants_1.REGEX.functions.package.name)) {
|
|
34
34
|
return true;
|
|
@@ -54,11 +54,11 @@ exports.default = (templateJsonDir = 'package.json', keys) => __awaiter(void 0,
|
|
|
54
54
|
throw new error_1.default('unknown key provided', { exit: 2 });
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
logger_1.info('This utility will ask series of questions with sensible defaults for creating ' +
|
|
58
|
-
ansi_colors_1.cyan('package.json') +
|
|
57
|
+
(0, logger_1.info)('This utility will ask series of questions with sensible defaults for creating ' +
|
|
58
|
+
(0, ansi_colors_1.cyan)('package.json') +
|
|
59
59
|
'\nFeel free to modify them if needed.\n');
|
|
60
|
-
logger_1.info('Use `' +
|
|
61
|
-
ansi_colors_1.bold('npm install <pkg> --save') +
|
|
60
|
+
(0, logger_1.info)('Use `' +
|
|
61
|
+
(0, ansi_colors_1.bold)('npm install <pkg> --save') +
|
|
62
62
|
'` afterwards to install a package and \nsave it as a dependency in the package.json file.\n');
|
|
63
63
|
const answers = yield prompt_1.default.ask(...qns);
|
|
64
64
|
let content = yield fs_1.ASYNC.readFile(templateJsonPath);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -42,15 +46,14 @@ const logger_js_1 = require("../../../../util_modules/logger.js");
|
|
|
42
46
|
const ansi_colors_1 = require("ansi-colors");
|
|
43
47
|
const client_js_1 = require("../../../util/client.js");
|
|
44
48
|
const path_1 = require("path");
|
|
45
|
-
const global_space_js_1 = __importDefault(require("../../../../util_modules/global-space.js"));
|
|
46
49
|
const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
|
|
47
50
|
const error_js_1 = __importDefault(require("../../../../error.js"));
|
|
48
51
|
const { angular } = plugin_js_1.default;
|
|
49
52
|
const { client } = placeholders_js_1.default;
|
|
50
53
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
const clientName = yield client_js_1.clientNamePrompt('Please provide a name for your Angular App:', 'angular-app');
|
|
52
|
-
const clientDirPath = project_js_1.resolveProjectPath(folder_names_js_1.default.client);
|
|
53
|
-
yield client_js_1.directoryOverridePrompt(clientDirPath);
|
|
54
|
+
const clientName = yield (0, client_js_1.clientNamePrompt)('Please provide a name for your Angular App:', 'angular-app');
|
|
55
|
+
const clientDirPath = (0, project_js_1.resolveProjectPath)(folder_names_js_1.default.client);
|
|
56
|
+
yield (0, client_js_1.directoryOverridePrompt)(clientDirPath);
|
|
54
57
|
const opts = [
|
|
55
58
|
angular.runner_command[1],
|
|
56
59
|
clientName,
|
|
@@ -59,29 +62,27 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
59
62
|
'--skip-git',
|
|
60
63
|
'true'
|
|
61
64
|
];
|
|
62
|
-
const isModuleFound = (yield global_space_js_1.default(angular.plugin, false));
|
|
63
65
|
try {
|
|
64
|
-
const collection = require.resolve(path_1.join(angular.collection_name, 'package.json'));
|
|
65
|
-
yield shell_js_1.spawn(angular.runner_command[0], [...opts, '--collection', path_1.dirname(collection)], {
|
|
66
|
+
const collection = require.resolve((0, path_1.join)(angular.collection_name, 'package.json'));
|
|
67
|
+
yield (0, shell_js_1.spawn)(angular.runner_command[0], [...opts, '--collection', (0, path_1.dirname)(collection)], {
|
|
66
68
|
stdio: 'inherit',
|
|
67
|
-
cwd: runtime_store_js_1.default.get('cwd')
|
|
68
|
-
env: {
|
|
69
|
-
CATALYST_ANGULAR_PLUGIN_GLOBAL: isModuleFound ? 'true' : 'false'
|
|
70
|
-
}
|
|
69
|
+
cwd: runtime_store_js_1.default.get('cwd')
|
|
71
70
|
}).ASYNC();
|
|
72
71
|
}
|
|
73
72
|
catch (e) {
|
|
74
73
|
if (e === null) {
|
|
75
74
|
throw new error_js_1.default('Process aborted!', { exit: 0, skipHelp: true });
|
|
76
75
|
}
|
|
77
|
-
const err = error_js_1.default.getErrorInstance(e
|
|
76
|
+
const err = error_js_1.default.getErrorInstance(e, {
|
|
77
|
+
message: 'Failure when creating new Angular App'
|
|
78
|
+
}).original;
|
|
78
79
|
if (!err.code || err.code !== 'ENOENT') {
|
|
79
80
|
throw err;
|
|
80
81
|
}
|
|
81
|
-
logger_js_1.info(`Angular CLI (${ansi_colors_1.red.italic('@angular/cli')}) not found....`);
|
|
82
|
-
logger_js_1.info(`Installing ${ansi_colors_1.bold('@angular/cli')} using ${ansi_colors_1.bold('npx')}`);
|
|
83
|
-
logger_js_1.info('Note: this may take a while...');
|
|
84
|
-
yield shell_js_1.spawn('npx', [
|
|
82
|
+
(0, logger_js_1.info)(`Angular CLI (${ansi_colors_1.red.italic('@angular/cli')}) not found....`);
|
|
83
|
+
(0, logger_js_1.info)(`Installing ${(0, ansi_colors_1.bold)('@angular/cli')} using ${(0, ansi_colors_1.bold)('npx')}`);
|
|
84
|
+
(0, logger_js_1.info)('Note: this may take a while...');
|
|
85
|
+
yield (0, shell_js_1.spawn)('npx', [
|
|
85
86
|
'-p',
|
|
86
87
|
angular.collection_name,
|
|
87
88
|
'-p',
|
|
@@ -92,15 +93,16 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
92
93
|
angular.collection_name
|
|
93
94
|
], {
|
|
94
95
|
stdio: 'inherit',
|
|
95
|
-
cwd: runtime_store_js_1.default.get('cwd')
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
cwd: runtime_store_js_1.default.get('cwd')
|
|
97
|
+
})
|
|
98
|
+
.ASYNC()
|
|
99
|
+
.catch((err) => {
|
|
100
|
+
throw error_js_1.default.getErrorInstance(err, {
|
|
101
|
+
message: 'Failure when creating new Angular App with npx'
|
|
102
|
+
});
|
|
103
|
+
});
|
|
100
104
|
}
|
|
101
|
-
yield ASYNC.findAndReplace(path_1.join(clientDirPath, file_names_js_1.default.client.package_json))(client.package.name, clientName);
|
|
102
|
-
runtime_store_js_1.default.set('payload.client.plugin',
|
|
103
|
-
|
|
104
|
-
: path_1.relative(project_js_1.getProjectRoot(), path_1.join(clientDirPath, 'node_modules', angular.plugin)));
|
|
105
|
-
return client_js_1.fillClientInitPayload(clientDirPath, clientName);
|
|
105
|
+
yield ASYNC.findAndReplace((0, path_1.join)(clientDirPath, file_names_js_1.default.client.package_json))(client.package.name, clientName);
|
|
106
|
+
runtime_store_js_1.default.set('payload.client.plugin', angular.plugin);
|
|
107
|
+
return (0, client_js_1.fillClientInitPayload)(clientDirPath, clientName);
|
|
106
108
|
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -40,11 +44,11 @@ const logger_js_1 = require("../../../../util_modules/logger.js");
|
|
|
40
44
|
const project_js_1 = require("../../../../util_modules/project.js");
|
|
41
45
|
const client_js_1 = require("../../../util/client.js");
|
|
42
46
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
logger_js_1.message('A directory ' + ansi_colors_1.cyan.bold('client') + ' will be created with a webapp pre-configured.');
|
|
44
|
-
const clientDirPath = project_js_1.resolveProjectPath(folder_names_js_1.default.client);
|
|
45
|
-
yield client_js_1.directoryOverridePrompt(clientDirPath);
|
|
47
|
+
(0, logger_js_1.message)('A directory ' + ansi_colors_1.cyan.bold('client') + ' will be created with a webapp pre-configured.');
|
|
48
|
+
const clientDirPath = (0, project_js_1.resolveProjectPath)(folder_names_js_1.default.client);
|
|
49
|
+
yield (0, client_js_1.directoryOverridePrompt)(clientDirPath);
|
|
46
50
|
yield ASYNC.copyDir(template_js_1.default.client.basic.new, clientDirPath);
|
|
47
|
-
const clientName = yield client_js_1.clientNamePrompt('How do you want to address the client ?', 'sampleApp');
|
|
51
|
+
const clientName = yield (0, client_js_1.clientNamePrompt)('How do you want to address the client ?', 'sampleApp');
|
|
48
52
|
yield ASYNC.findAndReplace(clientDirPath)(placeholders_js_1.default.client.package.name, clientName);
|
|
49
|
-
return client_js_1.fillClientInitPayload(clientDirPath, clientName);
|
|
53
|
+
return (0, client_js_1.fillClientInitPayload)(clientDirPath, clientName);
|
|
50
54
|
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -41,21 +45,16 @@ const placeholders_js_1 = __importDefault(require("../../../../util_modules/cons
|
|
|
41
45
|
const folder_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/folder-names.js"));
|
|
42
46
|
const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
|
|
43
47
|
const project_js_1 = require("../../../../util_modules/project.js");
|
|
44
|
-
const global_space_js_1 = __importDefault(require("../../../../util_modules/global-space.js"));
|
|
45
48
|
const { lyte } = plugin_js_1.default;
|
|
46
49
|
const { client } = placeholders_js_1.default;
|
|
47
50
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
const clientName = yield client_js_1.clientNamePrompt('Please provide a name for your Lyte web app: ', 'lyte-app');
|
|
49
|
-
const clientDirPath = project_js_1.resolveProjectPath(folder_names_js_1.default.client);
|
|
50
|
-
yield client_js_1.directoryOverridePrompt(clientDirPath);
|
|
51
|
+
const clientName = yield (0, client_js_1.clientNamePrompt)('Please provide a name for your Lyte web app: ', 'lyte-app');
|
|
52
|
+
const clientDirPath = (0, project_js_1.resolveProjectPath)(folder_names_js_1.default.client);
|
|
53
|
+
yield (0, client_js_1.directoryOverridePrompt)(clientDirPath);
|
|
51
54
|
yield ASYNC.copyDir(template_js_1.default.client.lyte, clientDirPath);
|
|
52
|
-
|
|
53
|
-
!isModuleFound &&
|
|
54
|
-
(yield client_js_1.addDevDep(path_1.join(clientDirPath, 'package.json'), { [lyte.plugin]: 'latest' }));
|
|
55
|
+
yield (0, client_js_1.addDependency)((0, path_1.join)(clientDirPath, 'package.json'), { [lyte.plugin]: 'latest' }, { dev: true });
|
|
55
56
|
yield ASYNC.findAndReplace(clientDirPath)(client.package.name, clientName);
|
|
56
|
-
yield npm_install_js_1.default(clientDirPath, true);
|
|
57
|
-
runtime_store_js_1.default.set('payload.client.plugin',
|
|
58
|
-
|
|
59
|
-
: path_1.relative(project_js_1.getProjectRoot(), path_1.join(clientDirPath, 'node_modules', lyte.plugin)));
|
|
60
|
-
return client_js_1.fillClientInitPayload(clientDirPath, clientName);
|
|
57
|
+
yield (0, npm_install_js_1.default)(clientDirPath, true);
|
|
58
|
+
runtime_store_js_1.default.set('payload.client.plugin', lyte.plugin);
|
|
59
|
+
return (0, client_js_1.fillClientInitPayload)(clientDirPath, clientName);
|
|
61
60
|
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -37,12 +41,12 @@ const runtime_store_js_1 = __importDefault(require("../../../../runtime-store.js
|
|
|
37
41
|
const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
|
|
38
42
|
const path_1 = require("path");
|
|
39
43
|
const os_1 = require("os");
|
|
40
|
-
const global_space_js_1 = __importDefault(require("../../../../util_modules/global-space.js"));
|
|
41
44
|
const index_js_1 = __importDefault(require("../../../../prompt/index.js"));
|
|
42
45
|
const client_js_1 = require("../../../util/client.js");
|
|
43
46
|
const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
|
|
44
47
|
const template_js_1 = __importDefault(require("../../../../util_modules/constants/lib/template.js"));
|
|
45
48
|
const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
|
|
49
|
+
const error_js_1 = __importDefault(require("../../../../error.js"));
|
|
46
50
|
const { react } = plugin_js_1.default;
|
|
47
51
|
const { client } = placeholders_js_1.default;
|
|
48
52
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -53,25 +57,26 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
53
57
|
index_js_1.default.choice('TypeScript', { value: 'ts', short: 'TypeScript' })
|
|
54
58
|
]
|
|
55
59
|
}));
|
|
56
|
-
const clientName = yield client_js_1.clientNamePrompt('Please provide a name for your React App:', 'react-app');
|
|
57
|
-
const clientDirPath = project_js_1.resolveProjectPath(clientName);
|
|
58
|
-
yield client_js_1.directoryOverridePrompt(clientDirPath);
|
|
59
|
-
const catalystTempDir = path_1.join(os_1.tmpdir(), '.catalyst');
|
|
60
|
-
const reactPluginDir = path_1.join(catalystTempDir, 'react');
|
|
60
|
+
const clientName = yield (0, client_js_1.clientNamePrompt)('Please provide a name for your React App:', 'react-app');
|
|
61
|
+
const clientDirPath = (0, project_js_1.resolveProjectPath)(clientName);
|
|
62
|
+
yield (0, client_js_1.directoryOverridePrompt)(clientDirPath);
|
|
63
|
+
const catalystTempDir = (0, path_1.join)((0, os_1.tmpdir)(), '.catalyst');
|
|
64
|
+
const reactPluginDir = (0, path_1.join)(catalystTempDir, 'react');
|
|
61
65
|
yield ASYNC.emptyDir(reactPluginDir);
|
|
62
66
|
yield ASYNC.copyDir(flavourPrompt.flavour === 'ts' ? template_js_1.default.client.react.ts : template_js_1.default.client.react.js, reactPluginDir);
|
|
63
|
-
|
|
64
|
-
!isModuleFound &&
|
|
65
|
-
(yield client_js_1.addDevDep(path_1.join(reactPluginDir, 'template.json'), { [react.plugin]: 'latest' }, [
|
|
66
|
-
'package'
|
|
67
|
-
]));
|
|
67
|
+
yield (0, client_js_1.addDependency)((0, path_1.join)(reactPluginDir, 'template.json'), { [react.plugin]: 'latest' }, { depPath: ['package'] });
|
|
68
68
|
yield ASYNC.findAndReplace(reactPluginDir)(client.package.name, clientName);
|
|
69
|
-
yield shell_js_1.spawn('npx', [react.runner_command[0], clientName, '--template', 'file:' + reactPluginDir], {
|
|
69
|
+
yield (0, shell_js_1.spawn)('npx', [react.runner_command[0], clientName, '--template', 'file:' + reactPluginDir], {
|
|
70
70
|
stdio: 'inherit',
|
|
71
71
|
cwd: runtime_store_js_1.default.get('cwd')
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
})
|
|
73
|
+
.ASYNC()
|
|
74
|
+
.catch((err) => {
|
|
75
|
+
throw error_js_1.default.getErrorInstance(err, {
|
|
76
|
+
message: 'Failure while Creating react app',
|
|
77
|
+
skipHelp: false
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
runtime_store_js_1.default.set('payload.client.plugin', react.plugin);
|
|
81
|
+
return (0, client_js_1.fillClientInitPayload)(clientDirPath, clientName);
|
|
77
82
|
});
|
|
@@ -25,24 +25,24 @@ const option_1 = require("../../../util_modules/option");
|
|
|
25
25
|
const project_1 = require("../../../util_modules/project");
|
|
26
26
|
const languages_1 = __importDefault(require("./languages"));
|
|
27
27
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
const currentCmd = option_1.getCurrentCommand();
|
|
29
|
-
const functionsDirPath = project_1.resolveProjectPath(constants_1.FOLDERNAME.functions);
|
|
28
|
+
const currentCmd = (0, option_1.getCurrentCommand)();
|
|
29
|
+
const functionsDirPath = (0, project_1.resolveProjectPath)(constants_1.FOLDERNAME.functions);
|
|
30
30
|
runtime_store_1.default.set('context.functions.dir_path', functionsDirPath);
|
|
31
31
|
if (currentCmd === 'init' || currentCmd === 'functions:setup') {
|
|
32
|
-
logger_1.message('A directory ' +
|
|
32
|
+
(0, logger_1.message)('A directory ' +
|
|
33
33
|
ansi_colors_1.cyan.bold(constants_1.FOLDERNAME.functions) +
|
|
34
34
|
' will be created with a catalyst function pre-configured.\n');
|
|
35
35
|
const folderExits = yield fs_1.ASYNC.dirExists(functionsDirPath);
|
|
36
36
|
const overwriteAns = folderExits
|
|
37
37
|
? yield prompt_1.default.ask(prompt_1.default.question('overwrite', 'Directory ' +
|
|
38
|
-
ansi_colors_1.underline(constants_1.FOLDERNAME.functions) +
|
|
38
|
+
(0, ansi_colors_1.underline)(constants_1.FOLDERNAME.functions) +
|
|
39
39
|
' already exists. Overwrite ?', {
|
|
40
40
|
type: 'confirm',
|
|
41
41
|
defaultAns: false
|
|
42
42
|
}))
|
|
43
43
|
: { overwrite: true };
|
|
44
44
|
if (!overwriteAns.overwrite) {
|
|
45
|
-
logger_1.warning('skipping function setup');
|
|
45
|
+
(0, logger_1.warning)('skipping function setup');
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
yield fs_1.ASYNC.deleteDir(functionsDirPath).catch();
|
|
@@ -76,16 +76,17 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
76
76
|
}));
|
|
77
77
|
runtime_store_1.default.set('context.functions.type', fnTypeAns.type);
|
|
78
78
|
if (fnTypeAns.type === constants_1.FN_TYPE.integration) {
|
|
79
|
-
yield integ_1.integHelper();
|
|
79
|
+
yield (0, integ_1.integHelper)();
|
|
80
80
|
}
|
|
81
81
|
const runtimeDetails = (yield runtimeDetailsPromise);
|
|
82
82
|
const runtimeChoices = runtimeDetails.runtimes.reduce((acc, value) => {
|
|
83
83
|
const langArr = value.match(/[a-zA-Z]+/g);
|
|
84
84
|
if (langArr === null || languages_1.default[langArr[0]] === undefined) {
|
|
85
|
-
logger_1.debug('Language cannot be identified hence skipping');
|
|
85
|
+
(0, logger_1.debug)('Language cannot be identified hence skipping');
|
|
86
86
|
return acc;
|
|
87
87
|
}
|
|
88
|
-
const
|
|
88
|
+
const runtimeLang = langArr[0];
|
|
89
|
+
const langFn = languages_1.default[runtimeLang];
|
|
89
90
|
let displayValue = value;
|
|
90
91
|
let disabled = false;
|
|
91
92
|
if (runtimeDetails.eol_runtimes && runtimeDetails.eol_runtimes[value]) {
|
|
@@ -102,22 +103,30 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
102
103
|
disabled = true;
|
|
103
104
|
break;
|
|
104
105
|
default:
|
|
105
|
-
logger_1.debug('unknown eol_runtime value ' + runtimeDetails.eol_runtimes[value]);
|
|
106
|
+
(0, logger_1.debug)('unknown eol_runtime value ' + runtimeDetails.eol_runtimes[value]);
|
|
106
107
|
return acc;
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
acc.
|
|
110
|
+
if (acc[runtimeLang].length === 0) {
|
|
111
|
+
const sep = {
|
|
112
|
+
node: '---NodeJS---',
|
|
113
|
+
java: '----Java----'
|
|
114
|
+
};
|
|
115
|
+
acc[runtimeLang].push(prompt_1.default.separator(sep[runtimeLang]));
|
|
116
|
+
}
|
|
117
|
+
acc[runtimeLang].push(prompt_1.default.choice(displayValue, { value: langFn(value), short: value, disabled }));
|
|
110
118
|
return acc;
|
|
111
|
-
}, []);
|
|
119
|
+
}, { node: [], java: [] });
|
|
120
|
+
const runtimeChoicesArr = [...runtimeChoices.java, ...runtimeChoices.node];
|
|
112
121
|
const runtimeAns = yield prompt_1.default.ask(prompt_1.default.question('runtime', 'Which runtime do you prefer to write your function?', {
|
|
113
122
|
type: 'list',
|
|
114
|
-
choices:
|
|
123
|
+
choices: runtimeChoicesArr,
|
|
115
124
|
when: () => {
|
|
116
|
-
return
|
|
125
|
+
return runtimeChoicesArr.length > 1;
|
|
117
126
|
}
|
|
118
127
|
}));
|
|
119
128
|
if (runtimeAns === undefined || runtimeAns.runtime === undefined) {
|
|
120
|
-
return
|
|
129
|
+
return runtimeChoices.node[1].value();
|
|
121
130
|
}
|
|
122
131
|
return runtimeAns.runtime();
|
|
123
132
|
});
|