zcatalyst-cli 1.11.0 → 1.11.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/docs/.DS_Store +0 -0
- package/lib/client-utils.js +0 -27
- package/lib/commands/iac/import.js +26 -5
- package/lib/endpoints/lib/sdk.js +2 -2
- package/lib/init/features/client/initializers/angular.js +23 -5
- package/lib/init/features/client/initializers/basic.js +36 -13
- package/lib/init/features/client/initializers/lyte.js +43 -26
- package/lib/init/features/client/initializers/react.js +50 -26
- package/lib/init/util/client.js +88 -4
- package/lib/serve/server/lib/master.js +2 -6
- package/lib/serve/server/lib/web_client/server.js +2 -2
- package/lib/util_modules/constants/lib/placeholders.js +1 -2
- package/lib/util_modules/constants/lib/urls.js +4 -4
- package/lib/util_modules/fs/index.js +1 -9
- package/lib/util_modules/fs/lib/async.js +3 -3
- package/lib/util_modules/fs/utils.js +8 -0
- package/package.json +2 -2
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/lyte/package.json +1 -1
- package/templates/init/client/react/react_js/template.json +1 -1
- package/templates/init/client/react/react_ts/template.json +1 -1
- package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +94 -109
- package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
- package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
- package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
- package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
- package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
- package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
- package/templates/init/functions/java/integ/cliq/sample.java +5 -7
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +0 -1
- package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
- package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
- package/lib/serve/server/lib/web_client/utils.js +0 -10
package/docs/.DS_Store
ADDED
|
Binary file
|
package/lib/client-utils.js
CHANGED
|
@@ -27,7 +27,6 @@ const js_1 = require("./util_modules/js");
|
|
|
27
27
|
const logger_1 = require("./util_modules/logger");
|
|
28
28
|
const option_1 = require("./util_modules/option");
|
|
29
29
|
const project_1 = require("./util_modules/project");
|
|
30
|
-
const prompt_1 = __importDefault(require("./prompt"));
|
|
31
30
|
exports.clientUtils = {
|
|
32
31
|
validate: (source) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
32
|
const sourceDir = source || project_1.resolveProjectPath(config_1.clientConfig.source());
|
|
@@ -150,31 +149,5 @@ exports.clientUtils = {
|
|
|
150
149
|
}
|
|
151
150
|
conf.unset('client');
|
|
152
151
|
yield conf.save();
|
|
153
|
-
}),
|
|
154
|
-
directoryOverridePrompt: (dir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
-
const foldeExists = yield fs_1.ASYNC.dirExists(dir);
|
|
156
|
-
if (foldeExists) {
|
|
157
|
-
const overwriteAns = yield prompt_1.default.ask(prompt_1.default.question('overwrite', 'Directory ' + ansi_colors_1.underline(dir) + ' already exists. Overwrite ?', {
|
|
158
|
-
type: 'confirm',
|
|
159
|
-
defaultAns: false
|
|
160
|
-
}));
|
|
161
|
-
if (!overwriteAns.overwrite) {
|
|
162
|
-
throw new error_1.default('Skipping client setup since unable to override the already existing client', { exit: 0, errorId: 'CLIENT-UTILS-6', arg: [ansi_colors_1.italic.red(dir)] });
|
|
163
|
-
}
|
|
164
|
-
yield fs_1.ASYNC.deleteDir(dir);
|
|
165
|
-
}
|
|
166
|
-
}),
|
|
167
|
-
clientNamePrompt: (question, defaultAns) => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
|
-
const namePrompt = yield prompt_1.default.ask(prompt_1.default.question('name', question, {
|
|
169
|
-
type: 'input',
|
|
170
|
-
defaultAns,
|
|
171
|
-
validate: (ans) => {
|
|
172
|
-
if (ans.match(constants_1.REGEX.client.package_name)) {
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
return 'Invalid client name';
|
|
176
|
-
}
|
|
177
|
-
}));
|
|
178
|
-
return namePrompt.name;
|
|
179
152
|
})
|
|
180
153
|
};
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -27,14 +46,16 @@ const prompt_1 = __importDefault(require("../../prompt"));
|
|
|
27
46
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
28
47
|
const constants_1 = require("../../util_modules/constants");
|
|
29
48
|
const env_1 = require("../../util_modules/env");
|
|
30
|
-
const
|
|
49
|
+
const ASYNC = __importStar(require("../../util_modules/fs/lib/async.js"));
|
|
50
|
+
const SYNC = __importStar(require("../../util_modules/fs/lib/sync.js"));
|
|
51
|
+
const utils_js_1 = require("../../util_modules/fs/utils.js");
|
|
31
52
|
const js_1 = require("../../util_modules/js");
|
|
32
53
|
const logger_1 = require("../../util_modules/logger");
|
|
33
54
|
const option_1 = require("../../util_modules/option");
|
|
34
55
|
const shell_1 = require("../../util_modules/shell");
|
|
35
56
|
const getZipAndTemplate = (filePath, stagedDeploy) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
57
|
const zipFile = filePath
|
|
37
|
-
? yield
|
|
58
|
+
? yield ASYNC.readFile(utils_js_1.untildify(filePath), 'buffer')
|
|
38
59
|
: (stagedDeploy === null || stagedDeploy === void 0 ? void 0 : stagedDeploy.id)
|
|
39
60
|
? yield new iac_1.default().deployDownload(stagedDeploy.id)
|
|
40
61
|
: undefined;
|
|
@@ -65,7 +86,7 @@ const ensureUserAction = (deployRes) => __awaiter(void 0, void 0, void 0, functi
|
|
|
65
86
|
resp.end();
|
|
66
87
|
return;
|
|
67
88
|
}
|
|
68
|
-
const htmlFile = yield
|
|
89
|
+
const htmlFile = yield ASYNC.readFile(path_1.join(__dirname, '../../../templates/iacSuccess.html'));
|
|
69
90
|
resp.setHeader('Content-Type', 'text/html');
|
|
70
91
|
resp.writeHead(200);
|
|
71
92
|
resp.end(htmlFile, () => {
|
|
@@ -152,7 +173,7 @@ const iacImport = (filePath, projectName) => __awaiter(void 0, void 0, void 0, f
|
|
|
152
173
|
exclude: ['**/!(*.zip)', '**/.*'],
|
|
153
174
|
validate: ({ value }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
175
|
if (value && value.endsWith('.zip')) {
|
|
155
|
-
return (yield
|
|
176
|
+
return (yield ASYNC.fileExists(value)) ? true : 'File does not exists!';
|
|
156
177
|
}
|
|
157
178
|
return 'Invalid zip file!';
|
|
158
179
|
})
|
|
@@ -165,7 +186,7 @@ const iacImport = (filePath, projectName) => __awaiter(void 0, void 0, void 0, f
|
|
|
165
186
|
const [zipArchive, templateFile] = yield getZipAndTemplate(filePath);
|
|
166
187
|
const parsedJSON = js_1.JS.parseJSON(templateFile);
|
|
167
188
|
const format = parsedJSON ? constants_1.IAC.template_format.json : constants_1.IAC.template_format.yml;
|
|
168
|
-
const deployRes = yield new iac_1.default().deploy(projectName, format,
|
|
189
|
+
const deployRes = yield new iac_1.default().deploy(projectName, format, SYNC.getReadStream(filePath));
|
|
169
190
|
yield ensureUserAction(deployRes);
|
|
170
191
|
return [zipArchive, templateFile, deployRes];
|
|
171
192
|
});
|
package/lib/endpoints/lib/sdk.js
CHANGED
|
@@ -31,10 +31,10 @@ class SDK {
|
|
|
31
31
|
if (targetSDK === undefined || targetUrl === undefined) {
|
|
32
32
|
throw new error_1.default('SDK target missing', { exit: 2 });
|
|
33
33
|
}
|
|
34
|
-
const res = yield new api_1.default(this.opts).get(`/
|
|
34
|
+
const res = yield new api_1.default(this.opts).get(`/downloads/sdk/java/${targetUrl}_latest.zip`, {
|
|
35
35
|
json: false,
|
|
36
36
|
encoding: null,
|
|
37
|
-
origin: constants_1.ORIGIN.
|
|
37
|
+
origin: constants_1.ORIGIN.catalystStatic,
|
|
38
38
|
log: {
|
|
39
39
|
progress: {
|
|
40
40
|
title: targetSDK.replace(new RegExp('_', 'g'), '-')
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -16,7 +35,6 @@ const file_names_js_1 = __importDefault(require("../../../../util_modules/consta
|
|
|
16
35
|
const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
|
|
17
36
|
const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
|
|
18
37
|
const folder_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/folder-names.js"));
|
|
19
|
-
const client_utils_js_1 = require("../../../../client-utils.js");
|
|
20
38
|
const project_js_1 = require("../../../../util_modules/project.js");
|
|
21
39
|
const shell_js_1 = require("../../../../util_modules/shell.js");
|
|
22
40
|
const runtime_store_js_1 = __importDefault(require("../../../../runtime-store.js"));
|
|
@@ -25,14 +43,14 @@ const ansi_colors_1 = require("ansi-colors");
|
|
|
25
43
|
const client_js_1 = require("../../../util/client.js");
|
|
26
44
|
const path_1 = require("path");
|
|
27
45
|
const global_space_js_1 = __importDefault(require("../../../../util_modules/global-space.js"));
|
|
28
|
-
const
|
|
46
|
+
const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
|
|
29
47
|
const error_js_1 = __importDefault(require("../../../../error.js"));
|
|
30
48
|
const { angular } = plugin_js_1.default;
|
|
31
49
|
const { client } = placeholders_js_1.default;
|
|
32
50
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
const clientName = yield
|
|
51
|
+
const clientName = yield client_js_1.clientNamePrompt('Please provide a name for your Angular App:', 'angular-app');
|
|
34
52
|
const clientDirPath = project_js_1.resolveProjectPath(folder_names_js_1.default.client);
|
|
35
|
-
yield
|
|
53
|
+
yield client_js_1.directoryOverridePrompt(clientDirPath);
|
|
36
54
|
const opts = [
|
|
37
55
|
angular.runner_command[1],
|
|
38
56
|
clientName,
|
|
@@ -80,7 +98,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
80
98
|
}
|
|
81
99
|
}).ASYNC();
|
|
82
100
|
}
|
|
83
|
-
yield
|
|
101
|
+
yield ASYNC.findAndReplace(path_1.join(clientDirPath, file_names_js_1.default.client.package_json))(client.package.name, clientName);
|
|
84
102
|
runtime_store_js_1.default.set('payload.client.plugin', isModuleFound
|
|
85
103
|
? angular.plugin
|
|
86
104
|
: path_1.relative(project_js_1.getProjectRoot(), path_1.join(clientDirPath, 'node_modules', angular.plugin)));
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,20 +27,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
28
|
});
|
|
10
29
|
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
11
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
34
|
const ansi_colors_1 = require("ansi-colors");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
35
|
+
const folder_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/folder-names.js"));
|
|
36
|
+
const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
|
|
37
|
+
const template_js_1 = __importDefault(require("../../../../util_modules/constants/lib/template.js"));
|
|
38
|
+
const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
|
|
39
|
+
const logger_js_1 = require("../../../../util_modules/logger.js");
|
|
40
|
+
const project_js_1 = require("../../../../util_modules/project.js");
|
|
41
|
+
const client_js_1 = require("../../../util/client.js");
|
|
19
42
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
|
|
21
|
-
const clientDirPath =
|
|
22
|
-
yield
|
|
23
|
-
yield
|
|
24
|
-
const clientName = yield
|
|
25
|
-
yield
|
|
26
|
-
return
|
|
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);
|
|
46
|
+
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');
|
|
48
|
+
yield ASYNC.findAndReplace(clientDirPath)(placeholders_js_1.default.client.package.name, clientName);
|
|
49
|
+
return client_js_1.fillClientInitPayload(clientDirPath, clientName);
|
|
27
50
|
});
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,33 +31,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
32
|
};
|
|
14
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const constants_1 = require("../../../../util_modules/constants");
|
|
16
|
-
const fs_1 = require("../../../../util_modules/fs");
|
|
17
|
-
const project_1 = require("../../../../util_modules/project");
|
|
18
|
-
const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
|
|
19
34
|
const path_1 = require("path");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
35
|
+
const client_js_1 = require("../../../util/client.js");
|
|
36
|
+
const runtime_store_js_1 = __importDefault(require("../../../../runtime-store.js"));
|
|
37
|
+
const npm_install_js_1 = __importDefault(require("../../../dependencies/npm-install.js"));
|
|
38
|
+
const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
|
|
39
|
+
const template_js_1 = __importDefault(require("../../../../util_modules/constants/lib/template.js"));
|
|
40
|
+
const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
|
|
41
|
+
const folder_names_js_1 = __importDefault(require("../../../../util_modules/constants/lib/folder-names.js"));
|
|
42
|
+
const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
|
|
43
|
+
const project_js_1 = require("../../../../util_modules/project.js");
|
|
44
|
+
const global_space_js_1 = __importDefault(require("../../../../util_modules/global-space.js"));
|
|
45
|
+
const { lyte } = plugin_js_1.default;
|
|
46
|
+
const { client } = placeholders_js_1.default;
|
|
26
47
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
const clientName = yield
|
|
28
|
-
const clientDirPath =
|
|
29
|
-
yield
|
|
30
|
-
yield
|
|
31
|
-
const isModuleFound = yield
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
JSON.stringify({ [lyte.plugin]: 'latest' }, null, ' ').replace(/\n}/g, '\n }')
|
|
38
|
-
]);
|
|
39
|
-
yield npm_install_1.default(clientDirPath, true);
|
|
40
|
-
runtime_store_1.default.set('payload.client.plugin', isModuleFound
|
|
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
|
+
yield ASYNC.copyDir(template_js_1.default.client.lyte, clientDirPath);
|
|
52
|
+
const isModuleFound = yield global_space_js_1.default(lyte.plugin);
|
|
53
|
+
!isModuleFound &&
|
|
54
|
+
(yield client_js_1.addDevDep(path_1.join(clientDirPath, 'package.json'), { [lyte.plugin]: 'latest' }));
|
|
55
|
+
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', isModuleFound
|
|
41
58
|
? lyte.plugin
|
|
42
|
-
: path_1.relative(
|
|
43
|
-
return
|
|
59
|
+
: path_1.relative(project_js_1.getProjectRoot(), path_1.join(clientDirPath, 'node_modules', lyte.plugin)));
|
|
60
|
+
return client_js_1.fillClientInitPayload(clientDirPath, clientName);
|
|
44
61
|
});
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,42 +31,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
32
|
};
|
|
14
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
|
|
20
|
-
const fs_1 = require("../../../../util_modules/fs");
|
|
34
|
+
const project_js_1 = require("../../../../util_modules/project.js");
|
|
35
|
+
const shell_js_1 = require("../../../../util_modules/shell.js");
|
|
36
|
+
const runtime_store_js_1 = __importDefault(require("../../../../runtime-store.js"));
|
|
37
|
+
const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
|
|
21
38
|
const path_1 = require("path");
|
|
22
39
|
const os_1 = require("os");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
40
|
+
const global_space_js_1 = __importDefault(require("../../../../util_modules/global-space.js"));
|
|
41
|
+
const index_js_1 = __importDefault(require("../../../../prompt/index.js"));
|
|
42
|
+
const client_js_1 = require("../../../util/client.js");
|
|
43
|
+
const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
|
|
44
|
+
const template_js_1 = __importDefault(require("../../../../util_modules/constants/lib/template.js"));
|
|
45
|
+
const placeholders_js_1 = __importDefault(require("../../../../util_modules/constants/lib/placeholders.js"));
|
|
46
|
+
const { react } = plugin_js_1.default;
|
|
47
|
+
const { client } = placeholders_js_1.default;
|
|
28
48
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
const flavourPrompt = yield
|
|
49
|
+
const flavourPrompt = yield index_js_1.default.ask(index_js_1.default.question('flavour', `Choose an option to create the React App:`, {
|
|
30
50
|
type: 'list',
|
|
31
51
|
choices: [
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
index_js_1.default.choice('JavaScript', { value: 'js', short: 'JavaScript' }),
|
|
53
|
+
index_js_1.default.choice('TypeScript', { value: 'ts', short: 'TypeScript' })
|
|
34
54
|
]
|
|
35
55
|
}));
|
|
36
|
-
const clientName = yield
|
|
37
|
-
const clientDirPath =
|
|
38
|
-
yield
|
|
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);
|
|
39
59
|
const catalystTempDir = path_1.join(os_1.tmpdir(), '.catalyst');
|
|
40
60
|
const reactPluginDir = path_1.join(catalystTempDir, 'react');
|
|
41
|
-
yield
|
|
42
|
-
yield
|
|
43
|
-
const isModuleFound = yield
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
yield ASYNC.emptyDir(reactPluginDir);
|
|
62
|
+
yield ASYNC.copyDir(flavourPrompt.flavour === 'ts' ? template_js_1.default.client.react.ts : template_js_1.default.client.react.js, reactPluginDir);
|
|
63
|
+
const isModuleFound = yield global_space_js_1.default(react.plugin);
|
|
64
|
+
!isModuleFound &&
|
|
65
|
+
(yield client_js_1.addDevDep(path_1.join(reactPluginDir, 'template.json'), { [react.plugin]: 'latest' }, [
|
|
66
|
+
'package'
|
|
67
|
+
]));
|
|
68
|
+
yield ASYNC.findAndReplace(reactPluginDir)(client.package.name, clientName);
|
|
69
|
+
yield shell_js_1.spawn('npx', [react.runner_command[0], clientName, '--template', 'file:' + reactPluginDir], {
|
|
46
70
|
stdio: 'inherit',
|
|
47
|
-
cwd:
|
|
71
|
+
cwd: runtime_store_js_1.default.get('cwd')
|
|
48
72
|
}).ASYNC();
|
|
49
|
-
|
|
73
|
+
runtime_store_js_1.default.set('payload.client.plugin', isModuleFound
|
|
50
74
|
? react.plugin
|
|
51
|
-
: path_1.relative(
|
|
52
|
-
return
|
|
75
|
+
: path_1.relative(project_js_1.getProjectRoot(), path_1.join(clientDirPath, 'node_modules', react.plugin)));
|
|
76
|
+
return client_js_1.fillClientInitPayload(clientDirPath, clientName);
|
|
53
77
|
});
|
package/lib/init/util/client.js
CHANGED
|
@@ -1,12 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
2
30
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
32
|
};
|
|
5
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fillClientInitPayload = void 0;
|
|
7
|
-
const
|
|
34
|
+
exports.addDevDep = exports.clientNamePrompt = exports.directoryOverridePrompt = exports.fillClientInitPayload = void 0;
|
|
35
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
36
|
+
const runtime_store_js_1 = __importDefault(require("../../runtime-store.js"));
|
|
37
|
+
const error_js_1 = __importDefault(require("../../error.js"));
|
|
38
|
+
const index_js_1 = __importDefault(require("../../prompt/index.js"));
|
|
39
|
+
const regex_js_1 = __importDefault(require("../../util_modules/constants/lib/regex.js"));
|
|
40
|
+
const ASYNC = __importStar(require("../../util_modules/fs/lib/async.js"));
|
|
41
|
+
const logger_js_1 = require("../../util_modules/logger.js");
|
|
42
|
+
const js_js_1 = require("../../util_modules/js.js");
|
|
8
43
|
const fillClientInitPayload = (source, name) => {
|
|
9
|
-
|
|
10
|
-
|
|
44
|
+
runtime_store_js_1.default.set('payload.client.source', source);
|
|
45
|
+
runtime_store_js_1.default.set('payload.client.name', name);
|
|
11
46
|
};
|
|
12
47
|
exports.fillClientInitPayload = fillClientInitPayload;
|
|
48
|
+
function directoryOverridePrompt(dir) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const foldeExists = yield ASYNC.dirExists(dir);
|
|
51
|
+
if (foldeExists) {
|
|
52
|
+
const overwriteAns = yield index_js_1.default.ask(index_js_1.default.question('overwrite', 'Directory ' + ansi_colors_1.underline(dir) + ' already exists. Overwrite ?', {
|
|
53
|
+
type: 'confirm',
|
|
54
|
+
defaultAns: false
|
|
55
|
+
}));
|
|
56
|
+
if (!overwriteAns.overwrite) {
|
|
57
|
+
throw new error_js_1.default('Skipping client setup since unable to override the already existing client', { exit: 0, errorId: 'CLIENT-UTILS-6', arg: [ansi_colors_1.italic.red(dir)] });
|
|
58
|
+
}
|
|
59
|
+
yield ASYNC.deleteDir(dir);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.directoryOverridePrompt = directoryOverridePrompt;
|
|
64
|
+
function clientNamePrompt(question, defaultAns) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const namePrompt = yield index_js_1.default.ask(index_js_1.default.question('name', question, {
|
|
67
|
+
type: 'input',
|
|
68
|
+
defaultAns,
|
|
69
|
+
validate: (ans) => {
|
|
70
|
+
if (ans.match(regex_js_1.default.client.package_name)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return 'Invalid client name';
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
return namePrompt.name;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
exports.clientNamePrompt = clientNamePrompt;
|
|
80
|
+
function addDevDep(filePath, dep, depPath = []) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
try {
|
|
83
|
+
const packageJson = yield ASYNC.readJSONFile(filePath);
|
|
84
|
+
if (packageJson) {
|
|
85
|
+
depPath.push('devDependencies');
|
|
86
|
+
js_js_1.JS.set(packageJson, depPath, dep);
|
|
87
|
+
yield ASYNC.writeJSONFile(filePath, packageJson);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
const err = error_js_1.default.getErrorInstance(e, { skipHelp: true });
|
|
92
|
+
logger_js_1.debug(`unable to write to ${filePath}: ${err.message}`);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.addDevDep = addDevDep;
|
|
@@ -82,10 +82,6 @@ const proxyResponseHandler = (systemRoutes) => (proxyRes, req, res) => {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
const generateConnectionId = () => {
|
|
86
|
-
const offset = Math.floor(Math.random() * 10);
|
|
87
|
-
return Date.now() + offset + '';
|
|
88
|
-
};
|
|
89
85
|
function spinUpMaster(listenPort, otherServerDetails) {
|
|
90
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
87
|
const projectDetails = {
|
|
@@ -135,7 +131,7 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
135
131
|
})
|
|
136
132
|
.on('proxyRes', proxyResponseHandler(systemRoutes))
|
|
137
133
|
.on('proxyReq', (proxyReq) => {
|
|
138
|
-
const id =
|
|
134
|
+
const id = js_1.JS.randomNumber(4) + '';
|
|
139
135
|
connections[id] = proxyReq;
|
|
140
136
|
proxyReq.on('finish', () => {
|
|
141
137
|
delete connections[id];
|
|
@@ -235,7 +231,7 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
235
231
|
connections[connectionId].destroy();
|
|
236
232
|
}));
|
|
237
233
|
expressServer.on('connection', (socket) => {
|
|
238
|
-
const id =
|
|
234
|
+
const id = js_1.JS.randomNumber(4) + '';
|
|
239
235
|
connections[id] = socket;
|
|
240
236
|
socket.on('close', () => {
|
|
241
237
|
delete connections[id];
|
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const express_1 = __importDefault(require("express"));
|
|
16
|
-
const
|
|
16
|
+
const events_1 = require("events");
|
|
17
17
|
const chokidar_1 = require("chokidar");
|
|
18
18
|
const logger_js_1 = require("../../../../util_modules/logger.js");
|
|
19
19
|
const index_js_1 = require("../../../../util_modules/constants/index.js");
|
|
@@ -60,7 +60,7 @@ function reloadApp(event, path, liveSockets) {
|
|
|
60
60
|
}
|
|
61
61
|
function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const eventListner = new
|
|
63
|
+
const eventListner = new events_1.EventEmitter();
|
|
64
64
|
const catalystTempDir = path_1.join(source, '.catalyst');
|
|
65
65
|
const socketServerPort = yield port_resolver_js_1.default.getFreePort(httpPort, 20, true);
|
|
66
66
|
const reloadScriptSrc = enableWatch
|
|
@@ -24,12 +24,12 @@ class URL {
|
|
|
24
24
|
}
|
|
25
25
|
return URL._app.replace('.com', dc.ext);
|
|
26
26
|
}
|
|
27
|
-
static get
|
|
27
|
+
static get catalystStatic() {
|
|
28
28
|
const dc = dc_1.getActiveDCType();
|
|
29
29
|
if (dc === undefined) {
|
|
30
|
-
return URL.
|
|
30
|
+
return URL._catalystStatic;
|
|
31
31
|
}
|
|
32
|
-
return URL.
|
|
32
|
+
return URL._catalystStatic.replace('.com', dc.ext);
|
|
33
33
|
}
|
|
34
34
|
static get console() {
|
|
35
35
|
const dc = dc_1.getActiveDCType();
|
|
@@ -43,5 +43,5 @@ exports.default = URL;
|
|
|
43
43
|
URL._auth = env_1.envOverride('CATALYST_AUTH_URL', 'https://accounts.zoho.com');
|
|
44
44
|
URL._admin = env_1.envOverride('CATALYST_ADMIN_URL', 'https://api.catalyst.zoho.com');
|
|
45
45
|
URL._app = env_1.envOverride('CATALYST_APP_URL', 'https://catalystserverless.com');
|
|
46
|
-
URL.
|
|
46
|
+
URL._catalystStatic = env_1.envOverride('CATALYST_STATIC', 'https://catalyst.zoho.com');
|
|
47
47
|
URL._console = env_1.envOverride('CATALYST_CONSOLE_URL', 'https://console.catalyst.zoho.com');
|
|
@@ -18,17 +18,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.ASYNC = exports.SYNC =
|
|
26
|
-
const os_1 = __importDefault(require("os"));
|
|
22
|
+
exports.ASYNC = exports.SYNC = void 0;
|
|
27
23
|
const ASYNC = __importStar(require("./lib/async"));
|
|
28
24
|
exports.ASYNC = ASYNC;
|
|
29
25
|
const SYNC = __importStar(require("./lib/sync"));
|
|
30
26
|
exports.SYNC = SYNC;
|
|
31
|
-
const tildRegex = /^~(?=$|\/|\\)/;
|
|
32
|
-
const homeDirectory = os_1.default.homedir();
|
|
33
|
-
const untildify = (pth) => homeDirectory ? pth.replace(tildRegex, homeDirectory) : pth;
|
|
34
|
-
exports.untildify = untildify;
|