zcatalyst-cli 1.15.0-beta.3 → 1.15.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/appsail-utils.js +84 -0
- package/lib/archiver.js +18 -1
- package/lib/code-deck.js +114 -0
- package/lib/command_needs/rc.js +7 -6
- package/lib/commands/appsail/add.js +55 -0
- package/lib/commands/codelib/install.js +143 -0
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/deploy/appsail.js +62 -0
- package/lib/commands/{deploy.js → deploy/index.js} +20 -14
- package/lib/commands/iac/pack.js +3 -3
- package/lib/commands/index.js +2 -0
- package/lib/commands/init.js +5 -1
- package/lib/commands/pull.js +1 -1
- package/lib/commands/serve.js +1 -1
- package/lib/commands/whoami.js +2 -1
- package/lib/deploy/features/appsail/index.js +246 -0
- package/lib/deploy/features/appsail/utils.js +91 -0
- package/lib/deploy/features/functions/index.js +12 -10
- package/lib/deploy/features/index.js +3 -0
- package/lib/deploy/index.js +3 -3
- package/lib/endpoints/index.js +22 -1
- package/lib/endpoints/lib/appsail.js +98 -0
- package/lib/endpoints/lib/code-deck.js +71 -0
- package/lib/endpoints/lib/common.js +8 -5
- package/lib/endpoints/lib/git-hub.js +148 -0
- package/lib/endpoints/lib/iac.js +15 -0
- package/lib/endpoints/lib/sdk.js +4 -1
- package/lib/execute-script.js +35 -27
- package/lib/fn-utils/lib/browserLogic.js +17 -20
- package/lib/fn-utils/lib/common.js +3 -4
- package/lib/fn-utils/lib/integ.js +3 -3
- package/lib/fn-utils/lib/java.js +7 -1
- package/lib/fn-watcher.js +3 -0
- package/lib/iac/status/deploy.js +26 -4
- package/lib/iac/status/util/index.js +3 -0
- package/lib/init/dependencies/python/ensure-python.js +2 -2
- package/lib/init/dependencies/python/pip-install.js +4 -4
- package/lib/init/features/appsail/index.js +213 -0
- package/lib/init/features/functions/index.js +5 -72
- package/lib/init/features/functions/languages/java.js +7 -3
- package/lib/init/features/functions/languages/node.js +9 -7
- package/lib/init/features/functions/languages/python.js +1 -1
- package/lib/init/features/index.js +28 -12
- package/lib/init/features/project.js +3 -3
- package/lib/init/index.js +1 -1
- package/lib/init/util/common.js +103 -0
- package/lib/internal/api.js +5 -5
- package/lib/internal/command.js +26 -3
- package/lib/option-filter.js +40 -21
- package/lib/prompt/index.js +5 -0
- package/lib/prompt/types/file-path.js +4 -1
- package/lib/prompt/types/tree.js +297 -0
- package/lib/pull/features/functions/index.js +70 -47
- package/lib/serve/features/appsail.js +37 -0
- package/lib/serve/features/index.js +8 -1
- package/lib/serve/index.js +23 -6
- package/lib/serve/server/index.js +111 -233
- package/lib/serve/server/lib/appsail/index.js +134 -0
- package/lib/serve/server/lib/appsail/start.js +75 -0
- package/lib/serve/server/lib/java/index.js +54 -0
- package/lib/serve/server/lib/master.js +84 -60
- package/lib/serve/server/lib/node/index.js +85 -74
- package/lib/serve/server/lib/node/server/index.js +77 -0
- package/lib/serve/server/lib/python/index.js +46 -0
- package/lib/serve/server/lib/web_client/index.js +33 -0
- package/lib/serve/server/lib/web_client/server.js +3 -0
- package/lib/shell/dependencies/http-functions.js +7 -7
- package/lib/shell/dependencies/local-function.js +6 -6
- package/lib/shell/prepare/index.js +1 -1
- package/lib/shell/prepare/languages/index.js +3 -3
- package/lib/shell/prepare/languages/java.js +2 -2
- package/lib/util_modules/config/index.js +3 -1
- package/lib/util_modules/config/lib/appSail.js +89 -0
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/default.js +4 -2
- package/lib/util_modules/constants/lib/file-names.js +4 -1
- package/lib/util_modules/constants/lib/runtime.js +12 -3
- package/lib/util_modules/constants/lib/scopes.js +4 -0
- package/lib/util_modules/constants/lib/template.js +23 -20
- package/lib/util_modules/constants/lib/urls.js +5 -0
- package/lib/util_modules/context-help.js +3 -0
- package/lib/util_modules/fs/lib/async.js +10 -3
- package/lib/util_modules/fs/lib/sync.js +2 -2
- package/lib/util_modules/js.js +4 -0
- package/lib/util_modules/project.js +2 -2
- package/lib/util_modules/server.js +2 -1
- package/package.json +1 -1
- package/scripts/postInstall.js +27 -18
- package/templates/init/functions/java/browserLogic/playwright/sample.java +1 -1
- package/templates/init/functions/java/browserLogic/selenium/sample.java +1 -1
- package/templates/init/functions/node/browserlogic/playwright/sample.js +1 -1
- package/templates/init/functions/node/browserlogic/puppeteer/sample.js +1 -1
- package/templates/init/functions/node/browserlogic/selenium/sample.js +1 -1
- package/templates/init/functions/python/aio/requirements.txt +1 -1
- package/templates/init/functions/python/bio/requirements.txt +1 -1
- package/templates/init/functions/python/cron/requirements.txt +1 -1
- package/templates/init/functions/python/event/requirements.txt +1 -1
- package/templates/init/functions/python/integ/cliq/requirements.txt +1 -1
- /package/lib/serve/server/lib/java/{JavaaioServer.java → aio_server/JavaaioServer.java} +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-function-sdk-1.0.0.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-java-runtime-1.0.0.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/gradle-wrapper.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-http-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-io-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-security-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-server-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-servlet-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-util-9.3.24.v20180605.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/org.json.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/servlet-api-3.1.jar +0 -0
- /package/lib/serve/server/lib/java/{lib → aio_server/lib}/zip4j-2.5.0.jar +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-playwright.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-puppeteer.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-selenium.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/index.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/deferred_promise.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/playwright-handler.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/puppeteer-handler.js +0 -0
- /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/selenium-handler.js +0 -0
- /package/lib/serve/server/lib/node/{package.json → server/package.json} +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const archiver_1 = __importDefault(require("../../../archiver"));
|
|
18
|
+
const endpoints_1 = require("../../../endpoints");
|
|
19
|
+
const prompt_1 = __importDefault(require("../../../prompt"));
|
|
20
|
+
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
21
|
+
const config_1 = require("../../../util_modules/config");
|
|
22
|
+
const constants_1 = require("../../../util_modules/constants");
|
|
23
|
+
const fs_1 = require("../../../util_modules/fs");
|
|
24
|
+
const logger_1 = require("../../../util_modules/logger");
|
|
25
|
+
const option_1 = require("../../../util_modules/option");
|
|
26
|
+
const common_1 = require("../../util/common");
|
|
27
|
+
const project_1 = require("../../../util_modules/project");
|
|
28
|
+
function getAppSailZip() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const _gitHubAPI = yield (0, endpoints_1.gitHubAPI)();
|
|
31
|
+
const gitRepo = yield prompt_1.default.ask(prompt_1.default.question('repo', 'Please choose from the list of recommended projects to get started', {
|
|
32
|
+
type: 'list',
|
|
33
|
+
choices: [
|
|
34
|
+
prompt_1.default.choice(`appsail-nodejs - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-nodejs')}`, {
|
|
35
|
+
value: {
|
|
36
|
+
api: _gitHubAPI.appsailNodejs.bind(_gitHubAPI),
|
|
37
|
+
command: 'node index.js',
|
|
38
|
+
source: (0, project_1.resolveProjectPath)('appsail-nodejs'),
|
|
39
|
+
build: (0, project_1.resolveProjectPath)('appsail-nodejs'),
|
|
40
|
+
stack: {
|
|
41
|
+
runtime: 'node16',
|
|
42
|
+
lang: 'node'
|
|
43
|
+
},
|
|
44
|
+
scripts: {
|
|
45
|
+
preserve: 'npm install',
|
|
46
|
+
predeploy: 'npm install'
|
|
47
|
+
},
|
|
48
|
+
memory: 256
|
|
49
|
+
},
|
|
50
|
+
short: 'appsail-nodejs'
|
|
51
|
+
}),
|
|
52
|
+
prompt_1.default.choice(`appsail-java - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-java')}`, {
|
|
53
|
+
value: {
|
|
54
|
+
api: _gitHubAPI.appsailJava.bind(_gitHubAPI),
|
|
55
|
+
command: 'java -jar demo-0.0.1-SNAPSHOT.jar',
|
|
56
|
+
source: (0, project_1.resolveProjectPath)('appsail-java'),
|
|
57
|
+
build: (0, project_1.resolveProjectPath)('appsail-java', 'target', 'demo-0.0.1-SNAPSHOT.jar'),
|
|
58
|
+
stack: {
|
|
59
|
+
runtime: 'java8',
|
|
60
|
+
lang: 'java'
|
|
61
|
+
},
|
|
62
|
+
scripts: {
|
|
63
|
+
preserve: './mvnw clean install',
|
|
64
|
+
predeploy: './mvnw clean install'
|
|
65
|
+
},
|
|
66
|
+
memory: 512,
|
|
67
|
+
platform: 'javase'
|
|
68
|
+
},
|
|
69
|
+
short: 'appsail-java'
|
|
70
|
+
}),
|
|
71
|
+
prompt_1.default.choice(`appsail-python - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-python')}`, {
|
|
72
|
+
value: {
|
|
73
|
+
api: _gitHubAPI.appsailPython.bind(_gitHubAPI),
|
|
74
|
+
command: 'python3 app.py',
|
|
75
|
+
source: (0, project_1.resolveProjectPath)('appsail-python'),
|
|
76
|
+
build: (0, project_1.resolveProjectPath)('appsail-python'),
|
|
77
|
+
stack: {
|
|
78
|
+
runtime: 'python_3_9',
|
|
79
|
+
lang: 'python'
|
|
80
|
+
},
|
|
81
|
+
scripts: {
|
|
82
|
+
preserve: 'python3 -m pip install -r ./requirements.txt -t ./',
|
|
83
|
+
predeploy: 'python3 -m pip install -r ./requirements.txt -t ./'
|
|
84
|
+
},
|
|
85
|
+
memory: 256
|
|
86
|
+
},
|
|
87
|
+
short: 'appsail-python'
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}));
|
|
91
|
+
(0, logger_1.info)();
|
|
92
|
+
(0, logger_1.info)((0, ansi_colors_1.white)('=>') + ' Downloading code');
|
|
93
|
+
const code = (yield gitRepo.repo.api());
|
|
94
|
+
const repoDir = gitRepo.repo.source;
|
|
95
|
+
yield fs_1.ASYNC.ensureDir(repoDir);
|
|
96
|
+
const zip = new archiver_1.default();
|
|
97
|
+
zip.load(code);
|
|
98
|
+
zip.extract(repoDir, '/', {
|
|
99
|
+
isFolder: true,
|
|
100
|
+
ignoreInitial: true
|
|
101
|
+
});
|
|
102
|
+
yield zip.finalize();
|
|
103
|
+
(0, logger_1.success)(`Successfully downloaded the code to ${ansi_colors_1.bold.green(gitRepo.repo.source)}`);
|
|
104
|
+
return {
|
|
105
|
+
source: gitRepo.repo.source,
|
|
106
|
+
build: gitRepo.repo.build,
|
|
107
|
+
stack: gitRepo.repo.stack,
|
|
108
|
+
command: gitRepo.repo.command,
|
|
109
|
+
scripts: gitRepo.repo.scripts,
|
|
110
|
+
memory: gitRepo.repo.memory,
|
|
111
|
+
platform: gitRepo.repo.platform
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
+
const curCommand = (0, option_1.getCurrentCommand)();
|
|
117
|
+
const gitPrompt = yield prompt_1.default.ask(prompt_1.default.question('gitClone', 'Do you want to get-started with a list of recommended projects?', {
|
|
118
|
+
type: 'confirm',
|
|
119
|
+
default: true,
|
|
120
|
+
when: curCommand === 'init'
|
|
121
|
+
}));
|
|
122
|
+
const pulledSource = gitPrompt.gitClone && (yield getAppSailZip());
|
|
123
|
+
const sourcePath = yield prompt_1.default.ask(prompt_1.default.question('currentDir', 'Do you want to initialize an AppSail service in this directory?', {
|
|
124
|
+
type: 'confirm',
|
|
125
|
+
default: true,
|
|
126
|
+
when: !pulledSource
|
|
127
|
+
}));
|
|
128
|
+
(0, logger_1.info)();
|
|
129
|
+
(0, logger_1.info)((0, ansi_colors_1.white)('=> ') + 'Configure AppSail service');
|
|
130
|
+
const _appSailConfig = sourcePath.currentDir
|
|
131
|
+
? { source: runtime_store_1.default.get('cwd') }
|
|
132
|
+
: pulledSource || {
|
|
133
|
+
source: (yield prompt_1.default.ask(prompt_1.default.question('source', "Please provide the exact path to your AppSail service's source directory: ", {
|
|
134
|
+
type: 'input',
|
|
135
|
+
validate: (pth) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
+
return (0, path_1.isAbsolute)(pth)
|
|
137
|
+
? (yield fs_1.ASYNC.dirExists(pth))
|
|
138
|
+
? true
|
|
139
|
+
: 'Provided path does not exists'
|
|
140
|
+
: 'Please provide provide an absolute path';
|
|
141
|
+
})
|
|
142
|
+
}))).source
|
|
143
|
+
};
|
|
144
|
+
const appConfigPth = (0, path_1.join)(_appSailConfig.source, constants_1.FILENAME.app_config);
|
|
145
|
+
const isAppConfig = yield fs_1.ASYNC.fileExists(appConfigPth);
|
|
146
|
+
const existingSails = config_1.appSailConfig.raw() || [];
|
|
147
|
+
yield prompt_1.default.register('file-path');
|
|
148
|
+
const appSail = yield prompt_1.default.ask(prompt_1.default.question('buildPath', 'Please provide the build path of your AppSail service: ', {
|
|
149
|
+
type: 'file-path',
|
|
150
|
+
validate: (pth) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
+
const buildPath = (0, path_1.resolve)(runtime_store_1.default.get('cwd'), pth.value);
|
|
152
|
+
if ((yield fs_1.ASYNC.dirExists(buildPath)) || (yield fs_1.ASYNC.fileExists(buildPath))) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
return 'Path does not exists';
|
|
156
|
+
}),
|
|
157
|
+
when: !_appSailConfig.build,
|
|
158
|
+
rootPath: _appSailConfig.source
|
|
159
|
+
}), prompt_1.default.question('name', 'Please provide the name for your AppSail service: ', {
|
|
160
|
+
type: 'input',
|
|
161
|
+
default: 'AppSail',
|
|
162
|
+
validate: (name) => {
|
|
163
|
+
const exists = existingSails.findIndex((appSail) => appSail.name === name) !== -1
|
|
164
|
+
? 'AppSail already exists'
|
|
165
|
+
: true;
|
|
166
|
+
const match = name.match(constants_1.REGEX.functions.package.name)
|
|
167
|
+
? true
|
|
168
|
+
: `Invalid function name. It should be in the following format: ${constants_1.REGEX.functions.package.name}`;
|
|
169
|
+
return typeof exists === 'string'
|
|
170
|
+
? exists
|
|
171
|
+
: typeof match === 'string'
|
|
172
|
+
? match
|
|
173
|
+
: true;
|
|
174
|
+
}
|
|
175
|
+
}));
|
|
176
|
+
const appSailStack = _appSailConfig.stack ||
|
|
177
|
+
(yield (0, common_1.getRuntimePromptAnswer)('Please choose a stack for your AppSail: '));
|
|
178
|
+
const payload = {
|
|
179
|
+
source: _appSailConfig.source,
|
|
180
|
+
name: appSail.name
|
|
181
|
+
};
|
|
182
|
+
const appConfig = {
|
|
183
|
+
command: _appSailConfig.command ||
|
|
184
|
+
'echo Please specify the start-up command in the app-config.json file under the key command',
|
|
185
|
+
buildPath: _appSailConfig.build || appSail.buildPath,
|
|
186
|
+
stack: appSailStack.runtime,
|
|
187
|
+
env_variables: {},
|
|
188
|
+
memory: _appSailConfig.memory || 256,
|
|
189
|
+
scripts: _appSailConfig.scripts || {}
|
|
190
|
+
};
|
|
191
|
+
if (appSailStack.lang === 'java') {
|
|
192
|
+
const platform = yield prompt_1.default.ask(prompt_1.default.question('value', 'Please choose a platform for your AppSail: ', {
|
|
193
|
+
type: 'list',
|
|
194
|
+
choices: [
|
|
195
|
+
prompt_1.default.choice('JavaSE', {
|
|
196
|
+
value: 'javase',
|
|
197
|
+
short: 'JavaSE'
|
|
198
|
+
}),
|
|
199
|
+
prompt_1.default.choice('JavaWAR', {
|
|
200
|
+
value: 'war',
|
|
201
|
+
short: 'JavaWAR'
|
|
202
|
+
})
|
|
203
|
+
],
|
|
204
|
+
when: !_appSailConfig.platform
|
|
205
|
+
}));
|
|
206
|
+
appConfig.platform = _appSailConfig.platform || platform.value;
|
|
207
|
+
if (appConfig.platform === 'war') {
|
|
208
|
+
delete appConfig.command;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
runtime_store_1.default.set('payload.appsail.targets', [payload]);
|
|
212
|
+
!isAppConfig && (yield fs_1.ASYNC.writeJSONFile(appConfigPth, appConfig));
|
|
213
|
+
});
|
|
@@ -14,21 +14,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const ansi_colors_1 = require("ansi-colors");
|
|
16
16
|
const dc_1 = require("../../../dc");
|
|
17
|
-
const catalyst_details_1 = __importDefault(require("../../../endpoints/lib/catalyst-details"));
|
|
18
17
|
const integ_1 = require("../../../fn-utils/lib/integ");
|
|
19
18
|
const prompt_1 = __importDefault(require("../../../prompt"));
|
|
20
19
|
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
21
|
-
const char_1 = require("../../../util_modules/char");
|
|
22
20
|
const constants_1 = require("../../../util_modules/constants");
|
|
23
21
|
const fs_1 = require("../../../util_modules/fs");
|
|
24
|
-
const js_1 = require("../../../util_modules/js");
|
|
25
22
|
const logger_1 = require("../../../util_modules/logger");
|
|
26
23
|
const option_1 = require("../../../util_modules/option");
|
|
27
24
|
const project_1 = require("../../../util_modules/project");
|
|
25
|
+
const common_1 = require("../../util/common");
|
|
28
26
|
const languages_1 = __importDefault(require("./languages"));
|
|
29
27
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
28
|
const currentCmd = (0, option_1.getCurrentCommand)();
|
|
31
|
-
const
|
|
29
|
+
const config = runtime_store_1.default.get('config');
|
|
30
|
+
const functionsDirPath = (0, project_1.resolveProjectPath)(config.get('functions.source') || constants_1.FOLDERNAME.functions);
|
|
32
31
|
runtime_store_1.default.set('context.functions.dir_path', functionsDirPath);
|
|
33
32
|
if (currentCmd === 'init' || currentCmd === 'functions:setup') {
|
|
34
33
|
(0, logger_1.message)('A directory ' +
|
|
@@ -85,72 +84,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
85
84
|
if (fnTypeAns.type === constants_1.FN_TYPE.integration) {
|
|
86
85
|
yield (0, integ_1.integHelper)();
|
|
87
86
|
}
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
const runtimeChoices = runtimeDetails.runtimes.reduce((acc, value) => {
|
|
91
|
-
const langArr = value.match(/^([a-zA-Z]+)([0-9_]+)$/);
|
|
92
|
-
if (langArr === null ||
|
|
93
|
-
languages_1.default[langArr[1]] === undefined) {
|
|
94
|
-
(0, logger_1.debug)('Language cannot be identified hence skipping');
|
|
95
|
-
return acc;
|
|
96
|
-
}
|
|
97
|
-
const runtimeLang = langArr[1];
|
|
98
|
-
const langFn = languages_1.default[runtimeLang];
|
|
99
|
-
let displayValue = value;
|
|
100
|
-
if (displayValue.startsWith('python')) {
|
|
101
|
-
displayValue = 'Python ' + displayValue.replace('python_', '').replace('_', '.');
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
displayValue = js_1.JS.startCase(langArr[1]) + ' ' + langArr[2];
|
|
105
|
-
}
|
|
106
|
-
let disabled = false;
|
|
107
|
-
if (runtimeDetails.eol_runtimes && runtimeDetails.eol_runtimes[value]) {
|
|
108
|
-
switch (runtimeDetails.eol_runtimes[value]) {
|
|
109
|
-
case 1:
|
|
110
|
-
displayValue += ` (${char_1.CHAR.info} This runtime has reached its EOL)`;
|
|
111
|
-
break;
|
|
112
|
-
case 2:
|
|
113
|
-
displayValue += ` (${char_1.CHAR.warning} Only updates are allowed in this runtime)`;
|
|
114
|
-
disabled = true;
|
|
115
|
-
break;
|
|
116
|
-
case 3:
|
|
117
|
-
displayValue += ` (${char_1.CHAR.error} This runtime is no longer supported)`;
|
|
118
|
-
disabled = true;
|
|
119
|
-
break;
|
|
120
|
-
default:
|
|
121
|
-
(0, logger_1.debug)('unknown eol_runtime value ' + runtimeDetails.eol_runtimes[value]);
|
|
122
|
-
return acc;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (acc[runtimeLang].length === 0) {
|
|
126
|
-
const sep = {
|
|
127
|
-
node: '---NodeJS---',
|
|
128
|
-
java: '----Java----',
|
|
129
|
-
python: '----Python----'
|
|
130
|
-
};
|
|
131
|
-
acc[runtimeLang].push(prompt_1.default.separator(sep[runtimeLang]));
|
|
132
|
-
}
|
|
133
|
-
acc[runtimeLang].push(prompt_1.default.choice(displayValue, { value: langFn(value), short: displayValue, disabled }));
|
|
134
|
-
return acc;
|
|
135
|
-
}, {
|
|
136
|
-
node: [],
|
|
137
|
-
java: [],
|
|
138
|
-
python: []
|
|
139
|
-
});
|
|
140
|
-
const runtimeChoicesArr = [
|
|
141
|
-
...runtimeChoices.python,
|
|
142
|
-
...runtimeChoices.java,
|
|
143
|
-
...runtimeChoices.node
|
|
144
|
-
];
|
|
145
|
-
const runtimeAns = yield prompt_1.default.ask(prompt_1.default.question('runtime', 'Which runtime do you prefer to write your function?', {
|
|
146
|
-
type: 'list',
|
|
147
|
-
choices: runtimeChoicesArr,
|
|
148
|
-
when: () => {
|
|
149
|
-
return runtimeChoicesArr.length > 1;
|
|
150
|
-
}
|
|
151
|
-
}));
|
|
152
|
-
if (runtimeAns === undefined || runtimeAns.runtime === undefined) {
|
|
153
|
-
return runtimeChoices.node[1].value();
|
|
154
|
-
}
|
|
155
|
-
return runtimeAns.runtime();
|
|
87
|
+
const runtimeAns = yield (0, common_1.getRuntimePromptAnswer)('Which runtime do you prefer to write your function?', fnTypeAns.type);
|
|
88
|
+
return languages_1.default[runtimeAns.lang](runtimeAns.runtime)();
|
|
156
89
|
});
|
|
@@ -20,18 +20,22 @@ const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
|
|
|
20
20
|
const constants_1 = require("../../../../util_modules/constants");
|
|
21
21
|
const fs_1 = require("../../../../util_modules/fs");
|
|
22
22
|
const logger_1 = require("../../../../util_modules/logger");
|
|
23
|
-
const js_1 = require("../../../../util_modules/js");
|
|
24
23
|
const integ_1 = require("../../../../fn-utils/lib/integ");
|
|
25
24
|
const common_1 = require("../../../../fn-utils/lib/common");
|
|
26
25
|
const runtime_1 = __importDefault(require("../../../../util_modules/constants/lib/runtime"));
|
|
27
26
|
const functions_1 = require("../../../util/functions");
|
|
28
27
|
const browserLogic_1 = require("../../../../fn-utils/lib/browserLogic");
|
|
29
28
|
const browserLogic_2 = __importDefault(require("../../../../util_modules/constants/lib/browserLogic"));
|
|
29
|
+
const error_1 = __importDefault(require("../../../../error"));
|
|
30
30
|
function getTemplatePath(fnType, add) {
|
|
31
31
|
switch (fnType) {
|
|
32
32
|
case constants_1.FN_TYPE.browserLogic:
|
|
33
33
|
case constants_1.FN_TYPE.integration: {
|
|
34
|
-
|
|
34
|
+
if (!add) {
|
|
35
|
+
throw new error_1.default('Invalid additional parameter', { exit: 2 });
|
|
36
|
+
}
|
|
37
|
+
const temp = constants_1.TEMPLATE.functions.java[fnType];
|
|
38
|
+
return temp[add.toLowerCase()];
|
|
35
39
|
}
|
|
36
40
|
default: {
|
|
37
41
|
return constants_1.TEMPLATE.functions.java[fnType];
|
|
@@ -79,7 +83,7 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
79
83
|
const service = runtime_store_1.default.get('context.functions.integration.service', '');
|
|
80
84
|
const templatePath = getTemplatePath(fnType, service || framework || '');
|
|
81
85
|
if (fnType === constants_1.FN_TYPE.integration) {
|
|
82
|
-
yield (0, integ_1.copyIntegHandlers)(templatePath, targetPath, runtime_1.default.language.java);
|
|
86
|
+
yield (0, integ_1.copyIntegHandlers)(templatePath, targetPath, runtime_1.default.language.java.value);
|
|
83
87
|
}
|
|
84
88
|
else {
|
|
85
89
|
yield fs_1.ASYNC.copyDir(templatePath, targetPath);
|
|
@@ -22,17 +22,21 @@ const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
|
|
|
22
22
|
const constants_1 = require("../../../../util_modules/constants");
|
|
23
23
|
const fs_1 = require("../../../../util_modules/fs");
|
|
24
24
|
const logger_1 = require("../../../../util_modules/logger");
|
|
25
|
-
const js_1 = require("../../../../util_modules/js");
|
|
26
25
|
const integ_1 = require("../../../../fn-utils/lib/integ");
|
|
27
26
|
const runtime_1 = __importDefault(require("../../../../util_modules/constants/lib/runtime"));
|
|
28
27
|
const functions_1 = require("../../../util/functions");
|
|
29
28
|
const browserLogic_1 = require("../../../../fn-utils/lib/browserLogic");
|
|
30
29
|
const browserLogic_2 = __importDefault(require("../../../../util_modules/constants/lib/browserLogic"));
|
|
30
|
+
const error_1 = __importDefault(require("../../../../error"));
|
|
31
31
|
function getTemplatePath(fnType, add) {
|
|
32
32
|
switch (fnType) {
|
|
33
33
|
case constants_1.FN_TYPE.browserLogic:
|
|
34
34
|
case constants_1.FN_TYPE.integration: {
|
|
35
|
-
|
|
35
|
+
if (!add) {
|
|
36
|
+
throw new error_1.default('Invalid additional parameter', { exit: 2 });
|
|
37
|
+
}
|
|
38
|
+
const fnTemplate = constants_1.TEMPLATE.functions.node[fnType];
|
|
39
|
+
return fnTemplate[add.toLowerCase()];
|
|
36
40
|
}
|
|
37
41
|
default: {
|
|
38
42
|
return constants_1.TEMPLATE.functions.node[fnType];
|
|
@@ -61,9 +65,9 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
61
65
|
(0, logger_1.warning)('Skipping functions node setup...');
|
|
62
66
|
return;
|
|
63
67
|
}
|
|
64
|
-
yield fs_1.ASYNC.deleteDir(targetPath).catch();
|
|
68
|
+
dirExists && (yield fs_1.ASYNC.deleteDir(targetPath).catch());
|
|
65
69
|
if (fnType === constants_1.FN_TYPE.integration) {
|
|
66
|
-
yield (0, integ_1.copyIntegHandlers)(templatePath, targetPath, runtime_1.default.language.
|
|
70
|
+
yield (0, integ_1.copyIntegHandlers)(templatePath, targetPath, runtime_1.default.language.node.value);
|
|
67
71
|
}
|
|
68
72
|
else {
|
|
69
73
|
yield fs_1.ASYNC.copyDir(templatePath, targetPath);
|
|
@@ -77,9 +81,7 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
77
81
|
if (key === 'name') {
|
|
78
82
|
finalJson[key] = finalJson[key].toLowerCase();
|
|
79
83
|
}
|
|
80
|
-
replaceArr.push(typeof finalJson[key] === 'string'
|
|
81
|
-
? finalJson[key]
|
|
82
|
-
: JSON.stringify(finalJson[key]));
|
|
84
|
+
replaceArr.push(typeof finalJson[key] === 'string' ? finalJson[key] : JSON.stringify(finalJson[key]));
|
|
83
85
|
});
|
|
84
86
|
yield fs_1.ASYNC.findAndReplace(targetPath)(placeholderArr, replaceArr);
|
|
85
87
|
const integ_config = runtime_store_1.default.get('context.functions.integration.config', '');
|
|
@@ -71,7 +71,7 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
71
71
|
}
|
|
72
72
|
yield fs_1.ASYNC.deleteDir(targetPath).catch();
|
|
73
73
|
if (fnType === constants_1.FN_TYPE.integration) {
|
|
74
|
-
yield (0, integ_1.copyIntegHandlers)(templatePath, targetPath, runtime_1.default.language.python);
|
|
74
|
+
yield (0, integ_1.copyIntegHandlers)(templatePath, targetPath, runtime_1.default.language.python.value);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
yield fs_1.ASYNC.copyDir(templatePath, targetPath);
|
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.project = exports.client = exports.functions = exports.
|
|
38
|
+
exports.appsail = exports.project = exports.client = exports.functions = exports.setCatalystConfig = void 0;
|
|
39
39
|
const ansi_colors_1 = require("ansi-colors");
|
|
40
40
|
const path_1 = require("path");
|
|
41
41
|
const error_1 = __importDefault(require("../../error"));
|
|
@@ -62,7 +62,7 @@ function upsertEnvArr(envArr, idx = 0) {
|
|
|
62
62
|
return upsertEnvArr(envArr, idx + 1);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function setCatalystConfig(featureName, add) {
|
|
66
66
|
const featureContext = runtime_store_1.default.get('payload.' + featureName, null);
|
|
67
67
|
let featureContextArr = runtime_store_1.default.get('payload.' + featureName + '.targets', null);
|
|
68
68
|
if (featureContext === null && featureContextArr === null) {
|
|
@@ -83,16 +83,19 @@ function setFnConfig(featureName, add) {
|
|
|
83
83
|
const targetSource = (0, path_1.relative)((0, project_1.getProjectRoot)(), targetSourceDir);
|
|
84
84
|
switch (featureName) {
|
|
85
85
|
case 'functions':
|
|
86
|
+
const _context = context;
|
|
86
87
|
if (!add) {
|
|
87
|
-
config.set(featureName + '.targets', [
|
|
88
|
-
config.set(featureName + '.ignore', ((_a =
|
|
88
|
+
config.set(featureName + '.targets', [_context.name]);
|
|
89
|
+
config.set(featureName + '.ignore', ((_a = _context.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value))
|
|
90
|
+
? [constants_1.FOLDERNAME.output]
|
|
91
|
+
: []);
|
|
89
92
|
config.set(featureName + '.source', targetSource);
|
|
90
93
|
return;
|
|
91
94
|
}
|
|
92
95
|
const targetArr = config.get(featureName + '.targets', []);
|
|
93
|
-
config.set(featureName + '.targets', js_1.JS.uniq(targetArr.concat([
|
|
96
|
+
config.set(featureName + '.targets', js_1.JS.uniq(targetArr.concat([_context.name])));
|
|
94
97
|
const ignoreArr = config.get(featureName + '.ignore', []);
|
|
95
|
-
config.set(featureName + '.ignore', ((_b =
|
|
98
|
+
config.set(featureName + '.ignore', ((_b = _context.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.java.value))
|
|
96
99
|
? js_1.JS.uniq(ignoreArr.concat([constants_1.FOLDERNAME.output]))
|
|
97
100
|
: ignoreArr);
|
|
98
101
|
if (config.get(featureName + '.source') !== targetSource) {
|
|
@@ -100,6 +103,11 @@ function setFnConfig(featureName, add) {
|
|
|
100
103
|
config.set(featureName + '.source', targetSource);
|
|
101
104
|
}
|
|
102
105
|
break;
|
|
106
|
+
case 'appsail': {
|
|
107
|
+
const targetArr = config.get('appsail', []);
|
|
108
|
+
config.set('appsail', js_1.JS.uniq(targetArr.concat([context])));
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
103
111
|
case 'client':
|
|
104
112
|
config.set('client.source', targetSource);
|
|
105
113
|
const plugin = runtime_store_1.default.get('payload.client.plugin', false);
|
|
@@ -117,18 +125,18 @@ function setFnConfig(featureName, add) {
|
|
|
117
125
|
}
|
|
118
126
|
});
|
|
119
127
|
}
|
|
120
|
-
exports.
|
|
128
|
+
exports.setCatalystConfig = setCatalystConfig;
|
|
121
129
|
function functions(add = false) {
|
|
122
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
131
|
yield (yield Promise.resolve().then(() => __importStar(require('./functions/index.js')))).default();
|
|
124
|
-
|
|
132
|
+
setCatalystConfig('functions', add);
|
|
125
133
|
});
|
|
126
134
|
}
|
|
127
135
|
exports.functions = functions;
|
|
128
136
|
function client() {
|
|
129
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
138
|
yield (yield Promise.resolve().then(() => __importStar(require('./client/index.js')))).default();
|
|
131
|
-
|
|
139
|
+
setCatalystConfig('client', false);
|
|
132
140
|
});
|
|
133
141
|
}
|
|
134
142
|
exports.client = client;
|
|
@@ -150,14 +158,22 @@ function project() {
|
|
|
150
158
|
(0, logger_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.rc) + ' file has be successfully created with project details.');
|
|
151
159
|
const isImport = runtime_store_1.default.get('payload.project.import', false);
|
|
152
160
|
if (isImport) {
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
setCatalystConfig('functions', true);
|
|
162
|
+
setCatalystConfig('client', false);
|
|
155
163
|
}
|
|
156
164
|
});
|
|
157
165
|
}
|
|
158
166
|
exports.project = project;
|
|
167
|
+
function appsail() {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
yield (yield Promise.resolve().then(() => __importStar(require('./appsail/index.js')))).default();
|
|
170
|
+
setCatalystConfig('appsail');
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
exports.appsail = appsail;
|
|
159
174
|
exports.default = {
|
|
160
175
|
functions,
|
|
161
176
|
client,
|
|
162
|
-
project
|
|
177
|
+
project,
|
|
178
|
+
appsail
|
|
163
179
|
};
|
|
@@ -122,11 +122,11 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
122
122
|
const source = properties.code.path.replace('/', path_1.sep).replace('.zip', '');
|
|
123
123
|
const stack = properties.stack.toLowerCase();
|
|
124
124
|
const refinedTargets = yield fn_utils_1.fnUtils.common.refineTargets([source], false);
|
|
125
|
-
const fnUtil = stack.startsWith(runtime_1.default.language.
|
|
125
|
+
const fnUtil = stack.startsWith(runtime_1.default.language.node.value)
|
|
126
126
|
? fn_utils_1.fnUtils.node
|
|
127
|
-
: stack.startsWith(runtime_1.default.language.java)
|
|
127
|
+
: stack.startsWith(runtime_1.default.language.java.value)
|
|
128
128
|
? fn_utils_1.fnUtils.java
|
|
129
|
-
: stack.startsWith(runtime_1.default.language.python)
|
|
129
|
+
: stack.startsWith(runtime_1.default.language.python.value)
|
|
130
130
|
? fn_utils_1.fnUtils.python
|
|
131
131
|
: null;
|
|
132
132
|
if (fnUtil === null) {
|
package/lib/init/index.js
CHANGED
|
@@ -38,7 +38,7 @@ function init() {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
const MODULE = features_1.default[feature];
|
|
41
|
-
(0, logger_1.info)((0, ansi_colors_1.bold)('\n' + (0, ansi_colors_1.white)('===> ') + js_1.JS.
|
|
41
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)('\n' + (0, ansi_colors_1.white)('===> ') + js_1.JS.camelToTitleCase(feature) + ' Setup'));
|
|
42
42
|
yield MODULE();
|
|
43
43
|
runtime_store_1.default.set('payload.features', runtime_store_1.default.get('payload.features', []).concat(feature));
|
|
44
44
|
return init();
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getRuntimePromptAnswer = exports.getRuntimeChoices = exports.getRuntimeDetails = void 0;
|
|
16
|
+
const catalyst_details_js_1 = __importDefault(require("../../endpoints/lib/catalyst-details.js"));
|
|
17
|
+
const error_js_1 = __importDefault(require("../../error.js"));
|
|
18
|
+
const index_js_1 = __importDefault(require("../../prompt/index.js"));
|
|
19
|
+
const char_1 = require("../../util_modules/char");
|
|
20
|
+
const index_js_2 = require("../../util_modules/constants/index.js");
|
|
21
|
+
const logger_js_1 = require("../../util_modules/logger.js");
|
|
22
|
+
function getRuntimeDetails(fnType) {
|
|
23
|
+
const catalystDetailsAPI = new catalyst_details_js_1.default();
|
|
24
|
+
return catalystDetailsAPI.getDetails('runtime', fnType ? index_js_2.REMOTE_REF.functions.type[fnType] : undefined);
|
|
25
|
+
}
|
|
26
|
+
exports.getRuntimeDetails = getRuntimeDetails;
|
|
27
|
+
function getRuntimeChoices({ fnType, runtimeDetails }) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
if (runtimeDetails === undefined) {
|
|
30
|
+
runtimeDetails = yield getRuntimeDetails(fnType);
|
|
31
|
+
}
|
|
32
|
+
const runtimeChoices = runtimeDetails.runtimes.reduce((acc, value) => {
|
|
33
|
+
const langArr = value.match(/^([a-zA-Z]+)([0-9_]+)$/);
|
|
34
|
+
const runtimeLang = langArr !== null
|
|
35
|
+
? index_js_2.RUNTIME.language[langArr[1]]
|
|
36
|
+
: undefined;
|
|
37
|
+
if (!langArr || !runtimeLang) {
|
|
38
|
+
(0, logger_js_1.debug)('Language cannot be identified hence skipping');
|
|
39
|
+
return acc;
|
|
40
|
+
}
|
|
41
|
+
const langV = langArr[2].split('_');
|
|
42
|
+
let displayValue = runtimeLang.label +
|
|
43
|
+
' ' +
|
|
44
|
+
(langV.length === 1 ? langV[0] : langV.slice(1).join('.'));
|
|
45
|
+
let disabled = false;
|
|
46
|
+
if ((runtimeDetails === null || runtimeDetails === void 0 ? void 0 : runtimeDetails.eol_runtimes) && runtimeDetails.eol_runtimes[value]) {
|
|
47
|
+
switch (runtimeDetails.eol_runtimes[value]) {
|
|
48
|
+
case 1:
|
|
49
|
+
displayValue += ` (${char_1.CHAR.info} This runtime has reached its EOL)`;
|
|
50
|
+
break;
|
|
51
|
+
case 2:
|
|
52
|
+
displayValue += ` (${char_1.CHAR.warning} Only updates are allowed in this runtime)`;
|
|
53
|
+
disabled = true;
|
|
54
|
+
break;
|
|
55
|
+
case 3:
|
|
56
|
+
displayValue += ` (${char_1.CHAR.error} This runtime is no longer supported)`;
|
|
57
|
+
disabled = true;
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
(0, logger_js_1.debug)('unknown eol_runtime value ' + runtimeDetails.eol_runtimes[value]);
|
|
61
|
+
return acc;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (acc[runtimeLang.value].length === 0) {
|
|
65
|
+
const sep = {
|
|
66
|
+
node: '---NodeJS---',
|
|
67
|
+
java: '----Java----',
|
|
68
|
+
python: '---Python---'
|
|
69
|
+
};
|
|
70
|
+
acc[runtimeLang.value].push(index_js_1.default.separator(sep[runtimeLang.value]));
|
|
71
|
+
}
|
|
72
|
+
acc[runtimeLang.value].push(index_js_1.default.choice(displayValue, {
|
|
73
|
+
value: { runtime: value, lang: runtimeLang.value },
|
|
74
|
+
short: displayValue,
|
|
75
|
+
disabled
|
|
76
|
+
}));
|
|
77
|
+
return acc;
|
|
78
|
+
}, {
|
|
79
|
+
node: [],
|
|
80
|
+
java: [],
|
|
81
|
+
python: []
|
|
82
|
+
});
|
|
83
|
+
return [...runtimeChoices.java, ...runtimeChoices.node, ...runtimeChoices.python];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.getRuntimeChoices = getRuntimeChoices;
|
|
87
|
+
function getRuntimePromptAnswer(question, fnType) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const runtimeChoices = yield getRuntimeChoices({ fnType });
|
|
90
|
+
const runtimeAns = yield index_js_1.default.ask(index_js_1.default.question('runtime', question, {
|
|
91
|
+
type: 'list',
|
|
92
|
+
choices: runtimeChoices,
|
|
93
|
+
when: () => {
|
|
94
|
+
return runtimeChoices.length > 1;
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
if (runtimeAns === undefined || runtimeAns.runtime === undefined) {
|
|
98
|
+
throw new error_js_1.default('Selected runtime is invalid.', { exit: 2 });
|
|
99
|
+
}
|
|
100
|
+
return runtimeAns.runtime;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
exports.getRuntimePromptAnswer = getRuntimePromptAnswer;
|