zcatalyst-cli 1.9.1 → 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/README.md +3 -3
- package/docs/.DS_Store +0 -0
- package/docs/client-utils.toml +5 -0
- package/docs/command_needs/auth.toml +5 -0
- package/docs/commands/iac/export.toml +4 -0
- package/docs/commands/iac/import.toml +4 -0
- package/docs/commands/iac/status.toml +4 -0
- package/docs/commands/project/use.toml +6 -0
- package/docs/iac/status/bundle.toml +4 -0
- package/docs/plugin-loader.toml +4 -0
- package/docs/serve/server/index.toml +4 -0
- package/docs/serve/server/lib/web_client/server.toml +4 -0
- package/lib/api-timer.js +81 -0
- package/lib/apig-utils.js +17 -14
- package/lib/archiver.js +83 -45
- package/lib/authentication/login.js +4 -2
- package/lib/bin/catalyst.js +0 -1
- package/lib/client-utils.js +28 -26
- package/lib/client.js +0 -3
- package/lib/command_needs/auth.js +12 -3
- package/lib/command_needs/rc.js +12 -7
- package/lib/commands/apig/status.js +6 -4
- package/lib/commands/client/delete.js +3 -4
- package/lib/commands/client/setup.js +1 -1
- package/lib/commands/deploy.js +3 -1
- package/lib/commands/ds/export.js +3 -1
- package/lib/commands/ds/import.js +3 -1
- package/lib/commands/ds/status.js +145 -149
- package/lib/commands/event/generate/index.js +4 -13
- package/lib/commands/functions/config.js +1 -1
- package/lib/commands/functions/setup.js +1 -1
- package/lib/commands/help.js +1 -23
- package/lib/commands/iac/export.js +85 -0
- package/lib/commands/iac/import.js +210 -0
- package/lib/commands/iac/pack.js +129 -0
- package/lib/commands/iac/status.js +63 -0
- package/lib/commands/index.js +4 -0
- package/lib/commands/init.js +34 -27
- package/lib/commands/project/list.js +10 -6
- package/lib/commands/project/use.js +42 -25
- package/lib/commands/pull.js +1 -1
- package/lib/commands/serve.js +2 -1
- package/lib/deploy/features/functions/index.js +2 -1
- package/lib/deploy/index.js +3 -1
- package/lib/endpoints/lib/iac.js +134 -0
- package/lib/endpoints/lib/sdk.js +2 -2
- package/lib/error.js +33 -3
- package/lib/errorOut.js +4 -3
- package/lib/fn-utils/lib/common.js +37 -16
- package/lib/fn-utils/lib/java.js +7 -9
- package/lib/fn-utils/lib/node.js +7 -1
- package/lib/iac/status/bundle.js +82 -0
- package/lib/iac/status/deploy.js +74 -0
- package/lib/iac/status/util/index.js +26 -0
- package/lib/index.js +8 -14
- package/lib/init/dependencies/npm-install.js +2 -9
- package/lib/init/features/client/index.js +47 -0
- package/lib/init/features/client/initializers/angular.js +106 -0
- package/lib/init/features/client/initializers/basic.js +50 -0
- package/lib/init/features/client/initializers/lyte.js +61 -0
- package/lib/init/features/client/initializers/react.js +77 -0
- package/lib/init/features/functions/languages/java.js +2 -5
- package/lib/init/features/functions/languages/node.js +5 -6
- package/lib/init/features/index.js +18 -6
- package/lib/init/features/project.js +72 -34
- package/lib/init/util/client.js +96 -0
- package/lib/init/util/functions.js +20 -0
- package/lib/init/util/project.js +35 -0
- package/lib/internal/api.js +6 -9
- package/lib/internal/command.js +6 -3
- package/lib/internal/config.js +7 -4
- package/lib/migration/index.js +10 -6
- package/lib/option-filter.js +4 -1
- package/lib/optional-import.js +11 -25
- package/lib/plugin-loader.js +8 -2
- package/lib/port-resolver.js +20 -16
- package/lib/prompt/index.js +92 -0
- package/lib/prompt/types/file-path.js +95 -0
- package/lib/pull/features/client.js +1 -1
- package/lib/pull/features/functions/index.js +5 -7
- package/lib/pull/index.js +4 -1
- package/lib/serve/features/index.js +3 -1
- package/lib/serve/index.js +6 -1
- package/lib/serve/server/index.js +52 -8
- package/lib/serve/server/lib/master.js +24 -12
- package/lib/serve/server/lib/web_client/index.js +30 -0
- package/lib/serve/server/lib/web_client/server.js +171 -0
- package/lib/shell/dependencies/http-functions.js +1 -1
- package/lib/shell/index.js +3 -1
- package/lib/track.js +3 -1
- package/lib/util_modules/char.js +1 -1
- package/lib/util_modules/config/lib/apig.js +2 -1
- package/lib/util_modules/constants/index.js +5 -1
- package/lib/util_modules/constants/lib/file-names.js +2 -1
- package/lib/util_modules/constants/lib/iac.js +8 -0
- package/lib/util_modules/constants/lib/placeholders.js +1 -0
- package/lib/util_modules/constants/lib/plugin.js +28 -0
- package/lib/util_modules/constants/lib/regex.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +5 -0
- package/lib/util_modules/constants/lib/template.js +11 -1
- package/lib/util_modules/constants/lib/urls.js +12 -4
- package/lib/util_modules/constants/project.js +6 -0
- package/lib/util_modules/{contextHelp.js → context-help.js} +5 -1
- package/lib/util_modules/env.js +14 -16
- package/lib/util_modules/fs/lib/async.js +29 -22
- package/lib/util_modules/fs/utils.js +8 -0
- package/lib/util_modules/global-space.js +99 -0
- package/lib/util_modules/js.js +6 -0
- package/lib/util_modules/option.js +5 -1
- package/lib/util_modules/parser/toml.js +5 -1
- package/lib/util_modules/project.js +3 -0
- package/lib/util_modules/shell.js +9 -8
- package/lib/winston.js +1 -1
- package/package.json +11 -5
- package/templates/.DS_Store +0 -0
- package/templates/iacSuccess.html +391 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
- package/templates/init/client/{index.html → basic/index.html} +0 -0
- package/templates/init/client/{main.css → basic/main.css} +0 -0
- package/templates/init/client/{main.js → basic/main.js} +0 -0
- package/templates/init/client/lyte/build/build.js +301 -0
- package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
- package/templates/init/client/lyte/client-package.json +5 -0
- package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
- package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
- package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
- package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
- package/templates/init/client/lyte/index.html +17 -0
- package/templates/init/client/lyte/package.json +12 -0
- package/templates/init/client/lyte/router.js +14 -0
- package/templates/init/client/lyte/routes/index.js +54 -0
- package/templates/init/client/react/.DS_Store +0 -0
- package/templates/init/client/react/react_js/package.json +11 -0
- package/templates/init/client/react/react_js/template/README.md +70 -0
- package/templates/init/client/react/react_js/template/client-package.json +5 -0
- package/templates/init/client/react/react_js/template/gitignore +23 -0
- package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_js/template/public/index.html +43 -0
- package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_js/template/src/App.css +38 -0
- package/templates/init/client/react/react_js/template/src/App.js +25 -0
- package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
- package/templates/init/client/react/react_js/template/src/index.css +13 -0
- package/templates/init/client/react/react_js/template/src/index.js +17 -0
- package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
- package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
- package/templates/init/client/react/react_js/template.json +13 -0
- package/templates/init/client/react/react_ts/package.json +11 -0
- package/templates/init/client/react/react_ts/template/README.md +46 -0
- package/templates/init/client/react/react_ts/template/client-package.json +5 -0
- package/templates/init/client/react/react_ts/template/gitignore +23 -0
- package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_ts/template/public/index.html +43 -0
- package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_ts/template/src/App.css +38 -0
- package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
- package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
- package/templates/init/client/react/react_ts/template/src/index.css +13 -0
- package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
- package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
- package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
- package/templates/init/client/react/react_ts/template.json +18 -0
- 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/templates/web-socket.txt +21 -0
- package/lib/init/features/client.js +0 -51
- package/lib/prompt.js +0 -49
- package/lib/serve/server/lib/client.js +0 -30
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
};
|
|
30
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
31
|
+
var t = {};
|
|
32
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
33
|
+
t[p] = s[p];
|
|
34
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
35
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
36
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
37
|
+
t[p[i]] = s[p[i]];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
46
|
+
const error_1 = __importDefault(require("../error"));
|
|
47
|
+
const choice = (name, _a = {}) => {
|
|
48
|
+
var { value = name, short = name, disabled = false, checked = false } = _a, otherOpts = __rest(_a, ["value", "short", "disabled", "checked"]);
|
|
49
|
+
return Object.assign({ name,
|
|
50
|
+
value,
|
|
51
|
+
short,
|
|
52
|
+
disabled,
|
|
53
|
+
checked }, otherOpts);
|
|
54
|
+
};
|
|
55
|
+
exports.default = {
|
|
56
|
+
register: (type) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
switch (type) {
|
|
58
|
+
case 'file-path':
|
|
59
|
+
const filePathExt = yield Promise.resolve().then(() => __importStar(require('./types/file-path')));
|
|
60
|
+
inquirer_1.default.registerPrompt('file-path', filePathExt.default);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
throw new error_1.default('No such type registered', { exit: 2 });
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
seperator: (line) => {
|
|
67
|
+
return new inquirer_1.default.Separator(line);
|
|
68
|
+
},
|
|
69
|
+
choice,
|
|
70
|
+
ask: (...questions) => {
|
|
71
|
+
return inquirer_1.default.prompt(questions);
|
|
72
|
+
},
|
|
73
|
+
question: (name, question, _a = {}) => {
|
|
74
|
+
var { type = 'input', defaultAns, choices = [], validate = () => {
|
|
75
|
+
return true;
|
|
76
|
+
}, filter = (ans) => {
|
|
77
|
+
return ans;
|
|
78
|
+
}, when = () => {
|
|
79
|
+
return true;
|
|
80
|
+
}, prefix = '', suffix = '' } = _a, otheropts = __rest(_a, ["type", "defaultAns", "choices", "validate", "filter", "when", "prefix", "suffix"]);
|
|
81
|
+
if (choices.length > 0 && typeof choices[0] === 'string') {
|
|
82
|
+
choices = choices.map((strChoice) => choice(strChoice));
|
|
83
|
+
}
|
|
84
|
+
return Object.assign({ type,
|
|
85
|
+
name, message: question, default: defaultAns, choices,
|
|
86
|
+
validate,
|
|
87
|
+
filter,
|
|
88
|
+
when,
|
|
89
|
+
prefix,
|
|
90
|
+
suffix }, otheropts);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
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 choices_1 = __importDefault(require("inquirer/lib/objects/choices"));
|
|
16
|
+
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
17
|
+
const fuzzy_1 = __importDefault(require("fuzzy"));
|
|
18
|
+
const fs_1 = require("../../util_modules/fs");
|
|
19
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
20
|
+
function getPaths(rootPath, pattern, exclude, defaultItem) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const nodeList = yield fs_1.ASYNC.walk(rootPath, { exclude, excludeDir: false });
|
|
23
|
+
const filteredNodes = fuzzy_1.default.filter(pattern || '', nodeList).map((e) => e.string);
|
|
24
|
+
if (!pattern && defaultItem) {
|
|
25
|
+
filteredNodes.unshift(defaultItem);
|
|
26
|
+
}
|
|
27
|
+
return filteredNodes;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
class InquirerFilePath extends inquirer_autocomplete_prompt_1.default {
|
|
31
|
+
constructor(question, rl, answers) {
|
|
32
|
+
const { rootPath = '.', exclude = [] } = question;
|
|
33
|
+
const questionBase = Object.assign({
|
|
34
|
+
emptyText: 'No valid file inside current directory!. Try giving the entire path and press ' +
|
|
35
|
+
ansi_colors_1.cyan('<return> ') +
|
|
36
|
+
'key'
|
|
37
|
+
}, question, {
|
|
38
|
+
source: (_, pattern) => getPaths(rootPath, pattern, exclude, question.default)
|
|
39
|
+
});
|
|
40
|
+
super(questionBase, rl, answers);
|
|
41
|
+
}
|
|
42
|
+
search(searchTerm) {
|
|
43
|
+
const _super = Object.create(null, {
|
|
44
|
+
search: { get: () => super.search }
|
|
45
|
+
});
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
yield _super.search.call(this, searchTerm);
|
|
48
|
+
this.currentChoices.getChoice = (choiceIndex) => {
|
|
49
|
+
const choice = choices_1.default.prototype.getChoice.call(this.currentChoices, choiceIndex);
|
|
50
|
+
return {
|
|
51
|
+
value: choice === null || choice === void 0 ? void 0 : choice.value,
|
|
52
|
+
name: choice === null || choice === void 0 ? void 0 : choice.name,
|
|
53
|
+
short: choice === null || choice === void 0 ? void 0 : choice.short
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
onSubmitAfterValidation(line) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const choice = this.currentChoices.getChoice(this.selected);
|
|
61
|
+
const value = (choice === null || choice === void 0 ? void 0 : choice.value) || line;
|
|
62
|
+
this.answerName = (choice === null || choice === void 0 ? void 0 : choice.name) || line;
|
|
63
|
+
this.shortAnswer = (choice === null || choice === void 0 ? void 0 : choice.short) || line;
|
|
64
|
+
this.answer = this.opt.filter ? this.opt.filter(value, this.answers) : value;
|
|
65
|
+
choice.value = this.answer;
|
|
66
|
+
this.status = 'answered';
|
|
67
|
+
this.render(undefined);
|
|
68
|
+
this.screen.done();
|
|
69
|
+
if (this.done) {
|
|
70
|
+
this.done(choice.value);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
checkValidationResult(validationResult, lineOrRl) {
|
|
75
|
+
if (validationResult !== true) {
|
|
76
|
+
this.render(validationResult || 'try giving valid complete path..');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.onSubmitAfterValidation(lineOrRl);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
onSubmit(line) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const lineOrRl = line || this.rl.line;
|
|
85
|
+
if (typeof this.opt.validate !== 'function') {
|
|
86
|
+
return this.onSubmitAfterValidation(lineOrRl);
|
|
87
|
+
}
|
|
88
|
+
const choice = this.currentChoices.getChoice(this.selected);
|
|
89
|
+
choice.value = choice.value ? choice.value : lineOrRl;
|
|
90
|
+
const validationResult = yield this.opt.validate(choice, this.answers);
|
|
91
|
+
this.checkValidationResult(validationResult, lineOrRl);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = InquirerFilePath;
|
|
@@ -59,7 +59,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
59
59
|
choices
|
|
60
60
|
}));
|
|
61
61
|
const clientZip = (yield webappAPI.download(historyAns.history));
|
|
62
|
-
yield new archiver_1.default().load(clientZip).extract(
|
|
62
|
+
yield new archiver_1.default().load(clientZip).extract(clientDirPath).finalize();
|
|
63
63
|
yield client_utils_1.clientUtils.validate();
|
|
64
64
|
runtime_store_1.default.set('payload.client', runtime_store_1.default.get('context.client'));
|
|
65
65
|
runtime_store_1.default.set('payload.client.source', project_1.resolveProjectPath(clientDirName));
|
|
@@ -26,6 +26,7 @@ const js_1 = require("../../../util_modules/js");
|
|
|
26
26
|
const logger_1 = require("../../../util_modules/logger");
|
|
27
27
|
const project_1 = require("../../../util_modules/project");
|
|
28
28
|
const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/runtime"));
|
|
29
|
+
const error_1 = __importDefault(require("../../../error"));
|
|
29
30
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
31
|
const fnAPI = yield endpoints_1.functionsAPI();
|
|
31
32
|
const fnDirName = config_1.functionsConfig.source();
|
|
@@ -108,10 +109,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
108
109
|
var _a, _b;
|
|
109
110
|
yield fs_1.ASYNC.ensureDir(fn.source);
|
|
110
111
|
const buffer = (yield fnAPI.download(fn.id));
|
|
111
|
-
yield new archiver_1.default()
|
|
112
|
-
.load(buffer)
|
|
113
|
-
.extract('/', path_1.join(fnDirPath, fn.name), { isFolder: true })
|
|
114
|
-
.finalize();
|
|
112
|
+
yield new archiver_1.default().load(buffer).extract(path_1.join(fnDirPath, fn.name)).finalize();
|
|
115
113
|
if ((_a = fn.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.nodejs)) {
|
|
116
114
|
yield languages_1.node(fn);
|
|
117
115
|
}
|
|
@@ -122,9 +120,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
122
120
|
})));
|
|
123
121
|
targets = targets.filter((target) => {
|
|
124
122
|
if (!target.valid) {
|
|
125
|
-
logger_1.debug('Invalid target : ' + target + ' reason : ' + target.failure_reason);
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
logger_1.debug('Invalid target : ' + target.name + ' reason : ' + target.failure_reason);
|
|
124
|
+
logger_1.warning(`skipping pull of function(${target.name}) since the package is invalid. \nContact catalyst support with debug log.`);
|
|
125
|
+
new error_1.default('invalid package: ' + target.name, { exit: 2 });
|
|
128
126
|
}
|
|
129
127
|
return target.valid;
|
|
130
128
|
});
|
package/lib/pull/index.js
CHANGED
|
@@ -39,7 +39,10 @@ function pull() {
|
|
|
39
39
|
}
|
|
40
40
|
const MODULE = features_1.default[feature];
|
|
41
41
|
logger_1.info(ansi_colors_1.bold('\n' + ansi_colors_1.white('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
|
|
42
|
-
yield MODULE()
|
|
42
|
+
yield MODULE().catch((err) => {
|
|
43
|
+
logger_1.info();
|
|
44
|
+
logger_1.warning(`Skipping pull of ${feature}. Since ${err.message}.\nContact Catalyst Support with catalyst-debug.log file.`);
|
|
45
|
+
});
|
|
43
46
|
if (runtime_store_1.default.get('payload.' + feature, false)) {
|
|
44
47
|
runtime_store_1.default.set('payload.features', runtime_store_1.default.get('payload.features', []).concat(feature));
|
|
45
48
|
}
|
|
@@ -32,6 +32,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
32
32
|
};
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.apig = exports.functions = exports.client = void 0;
|
|
35
|
+
const error_1 = __importDefault(require("../../error"));
|
|
35
36
|
const port_resolver_1 = __importDefault(require("../../port-resolver"));
|
|
36
37
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
37
38
|
const constants_1 = require("../../util_modules/constants");
|
|
@@ -42,7 +43,8 @@ function client() {
|
|
|
42
43
|
try {
|
|
43
44
|
yield clientModule.default();
|
|
44
45
|
}
|
|
45
|
-
catch (
|
|
46
|
+
catch (e) {
|
|
47
|
+
const err = error_1.default.getErrorInstance(e);
|
|
46
48
|
logger_1.info();
|
|
47
49
|
logger_1.warning('Skipping the serve of Client because of the error: ' + err.message);
|
|
48
50
|
logger_1.info();
|
package/lib/serve/index.js
CHANGED
|
@@ -54,7 +54,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
54
54
|
runtime_store_1.default.set('context.port.http.master', masterPort);
|
|
55
55
|
yield Promise.all(serveTargets.map((target) => features[target]()));
|
|
56
56
|
const rawTargets = runtime_store_1.default.get('context.functions.targets', []);
|
|
57
|
-
|
|
57
|
+
const watchOpt = option_1.getOptionValue('watch', false);
|
|
58
|
+
if (watchOpt) {
|
|
58
59
|
yield Promise.all(rawTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () { return (target.valid ? fn_watcher_1.default(target) : undefined); })));
|
|
59
60
|
}
|
|
60
61
|
const funtionTargets = rawTargets.filter((target) => {
|
|
@@ -73,6 +74,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
73
74
|
if (serveTargets.includes('client')) {
|
|
74
75
|
const client = runtime_store_1.default.get('context.client', false);
|
|
75
76
|
if (client && client.valid) {
|
|
77
|
+
client.opts = {
|
|
78
|
+
open: option_1.getOptionValue('open', false),
|
|
79
|
+
watch: watchOpt
|
|
80
|
+
};
|
|
76
81
|
advancedServer.add('client', client);
|
|
77
82
|
}
|
|
78
83
|
else {
|
|
@@ -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) {
|
|
@@ -35,6 +54,7 @@ const js_1 = require("../../util_modules/js");
|
|
|
35
54
|
const logger_1 = require("../../util_modules/logger");
|
|
36
55
|
const shell_1 = require("../../util_modules/shell");
|
|
37
56
|
const master_1 = __importDefault(require("./lib/master"));
|
|
57
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
38
58
|
class Server {
|
|
39
59
|
constructor() {
|
|
40
60
|
this.targetDetailsArr = [];
|
|
@@ -85,8 +105,8 @@ class Server {
|
|
|
85
105
|
opts.push(details.httpPort + '');
|
|
86
106
|
const targetSource = (_c = details.target) === null || _c === void 0 ? void 0 : _c.source;
|
|
87
107
|
const configType = details.type === 'server' ? 'functions' : details.type;
|
|
88
|
-
const servePlugin = yield plugin_loader_1.default(configType, 'start', targetSource);
|
|
89
|
-
if (servePlugin
|
|
108
|
+
const servePlugin = yield plugin_loader_1.default(configType, 'start', targetSource).catch((err) => logger_1.debug(err));
|
|
109
|
+
if (typeof servePlugin === 'function') {
|
|
90
110
|
const event = servePlugin(details, masterPort);
|
|
91
111
|
logger_1.labeled(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
|
|
92
112
|
return event;
|
|
@@ -111,7 +131,7 @@ class Server {
|
|
|
111
131
|
const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
|
|
112
132
|
const _d = details.target, { ['watcher']: _ } = _d, serialisableTarget = __rest(_d, ['watcher']);
|
|
113
133
|
const opts = [
|
|
114
|
-
path_1.join(__dirname, 'lib',
|
|
134
|
+
path_1.join(__dirname, 'lib', 'node.js'),
|
|
115
135
|
details.httpPort + '',
|
|
116
136
|
JSON.stringify(serialisableTarget)
|
|
117
137
|
];
|
|
@@ -121,12 +141,28 @@ class Server {
|
|
|
121
141
|
}
|
|
122
142
|
const targetSource = (_b = details.target) === null || _b === void 0 ? void 0 : _b.source;
|
|
123
143
|
const configType = details.type === 'server' ? 'functions' : details.type;
|
|
124
|
-
const servePlugin = yield plugin_loader_1.default(configType, 'start', targetSource);
|
|
125
|
-
if (servePlugin
|
|
126
|
-
const event = servePlugin(details, masterPort)
|
|
144
|
+
const servePlugin = yield plugin_loader_1.default(configType, 'start', targetSource).catch((err) => logger_1.debug(err));
|
|
145
|
+
if (typeof servePlugin === 'function') {
|
|
146
|
+
const event = servePlugin(details, masterPort).catch((e) => {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
const err = error_1.default.getErrorInstance(e, {
|
|
149
|
+
fileName: __filename,
|
|
150
|
+
skipHelp: false
|
|
151
|
+
});
|
|
152
|
+
err.errorId = 'SERVE-IDX-1';
|
|
153
|
+
err.arg = [
|
|
154
|
+
configType,
|
|
155
|
+
ansi_colors_1.bold(((_b = (_a = details.target) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b.start)[targetSource] || 'start'),
|
|
156
|
+
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(err.message)
|
|
157
|
+
];
|
|
158
|
+
throw err;
|
|
159
|
+
});
|
|
127
160
|
logger_1.labeled(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
|
|
128
161
|
return event;
|
|
129
162
|
}
|
|
163
|
+
if (details.type === 'client') {
|
|
164
|
+
return yield (yield Promise.resolve().then(() => __importStar(require('./lib/web_client/index.js')))).default(details, masterPort);
|
|
165
|
+
}
|
|
130
166
|
const child = shell_1.spawn('node', opts, {
|
|
131
167
|
cwd: targetSource,
|
|
132
168
|
stdio: 'pipe',
|
|
@@ -136,7 +172,7 @@ class Server {
|
|
|
136
172
|
X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
|
|
137
173
|
}
|
|
138
174
|
}).RAW();
|
|
139
|
-
logger_1.labeled(label, `URL : http://localhost:${masterPort}/${
|
|
175
|
+
logger_1.labeled(label, `URL : http://localhost:${masterPort}/server/${(_c = details.target) === null || _c === void 0 ? void 0 : _c.name}/`).MESSAGE();
|
|
140
176
|
logger_1.info();
|
|
141
177
|
return child;
|
|
142
178
|
});
|
|
@@ -196,7 +232,15 @@ class Server {
|
|
|
196
232
|
this.masterServer = server;
|
|
197
233
|
return new Promise((res) => {
|
|
198
234
|
server.on('listening', () => {
|
|
199
|
-
this.targetDetailsArr.forEach((targetDetails) => {
|
|
235
|
+
this.targetDetailsArr.forEach((targetDetails) => {
|
|
236
|
+
var _a;
|
|
237
|
+
if (targetDetails.process &&
|
|
238
|
+
'send' in targetDetails.process) {
|
|
239
|
+
targetDetails.process.send('start');
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
(_a = targetDetails.process) === null || _a === void 0 ? void 0 : _a.emit('start');
|
|
243
|
+
});
|
|
200
244
|
res();
|
|
201
245
|
});
|
|
202
246
|
});
|
|
@@ -122,26 +122,36 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
122
122
|
app.use('/', apig_matcher_1.default, auth_checker_1.default, url_rewriter_1.default);
|
|
123
123
|
}
|
|
124
124
|
const proxy = http_proxy_1.createProxyServer()
|
|
125
|
-
.on('error', (err, req) => {
|
|
125
|
+
.on('error', (err, req, res) => {
|
|
126
|
+
res.writeHead(503, { 'Content-Type': 'json' });
|
|
127
|
+
res.write(JSON.stringify({ error: 'unable to proxy request' }));
|
|
128
|
+
res.end();
|
|
126
129
|
console.log('unable to proxy request ', req.url);
|
|
127
130
|
console.error(err);
|
|
128
131
|
})
|
|
129
|
-
.on('proxyRes', proxyResponseHandler(systemRoutes))
|
|
132
|
+
.on('proxyRes', proxyResponseHandler(systemRoutes))
|
|
133
|
+
.on('proxyReq', (proxyReq) => {
|
|
134
|
+
const id = js_1.JS.randomNumber(4) + '';
|
|
135
|
+
connections[id] = proxyReq;
|
|
136
|
+
proxyReq.on('finish', () => {
|
|
137
|
+
delete connections[id];
|
|
138
|
+
});
|
|
139
|
+
})
|
|
140
|
+
.on('close', () => logger_2.debug('proxy closed'));
|
|
130
141
|
otherServerDetails.forEach((serverDetail) => {
|
|
131
142
|
var _a, _b, _c, _d, _e, _f;
|
|
132
143
|
switch (serverDetail.type) {
|
|
133
144
|
case 'client':
|
|
134
145
|
const appTarget = `http://127.0.0.1:${serverDetail.httpPort}/app/`;
|
|
135
146
|
app.use('/app', (req, res) => {
|
|
136
|
-
|
|
137
|
-
if (req.url.startsWith('/local-redirect') &&
|
|
138
|
-
|
|
139
|
-
const isUrl = serverDetail.target.login_redirect.startsWith('/');
|
|
147
|
+
const target = serverDetail.target;
|
|
148
|
+
if (req.url.startsWith('/local-redirect') && target.login_redirect) {
|
|
149
|
+
const isUrl = target.login_redirect.startsWith('/');
|
|
140
150
|
if (isUrl) {
|
|
141
|
-
res.redirect(
|
|
151
|
+
res.redirect(target.login_redirect);
|
|
142
152
|
}
|
|
143
153
|
else {
|
|
144
|
-
res.redirect('/app/' +
|
|
154
|
+
res.redirect('/app/' + target.login_redirect);
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
157
|
else {
|
|
@@ -192,7 +202,8 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
192
202
|
ws: true
|
|
193
203
|
});
|
|
194
204
|
});
|
|
195
|
-
app.use('/baas/v1/project/:projectId/function/' +
|
|
205
|
+
app.use('/baas/v1/project/:projectId/function/' +
|
|
206
|
+
((_f = serverDetail.target) === null || _f === void 0 ? void 0 : _f.id), (req, res) => {
|
|
196
207
|
var _a;
|
|
197
208
|
proxy.web(req, res, {
|
|
198
209
|
target: `http://127.0.0.1:${serverDetail.httpPort}/server/${(_a = serverDetail.target) === null || _a === void 0 ? void 0 : _a.id}`,
|
|
@@ -216,10 +227,11 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
216
227
|
console.error(err);
|
|
217
228
|
});
|
|
218
229
|
expressServer.maxConnections = 100;
|
|
219
|
-
process.
|
|
230
|
+
process.on('SIGINT', () => Object.keys(connections).forEach((connectionId) => {
|
|
231
|
+
connections[connectionId].destroy();
|
|
232
|
+
}));
|
|
220
233
|
expressServer.on('connection', (socket) => {
|
|
221
|
-
const
|
|
222
|
-
const id = Date.now() + offset + '';
|
|
234
|
+
const id = js_1.JS.randomNumber(4) + '';
|
|
223
235
|
connections[id] = socket;
|
|
224
236
|
socket.on('close', () => {
|
|
225
237
|
delete connections[id];
|
|
@@ -0,0 +1,30 @@
|
|
|
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 open_1 = __importDefault(require("open"));
|
|
16
|
+
const logger_1 = require("../../../../util_modules/logger");
|
|
17
|
+
const server_js_1 = __importDefault(require("./server.js"));
|
|
18
|
+
exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
var _a;
|
|
20
|
+
const target = details.target;
|
|
21
|
+
const clientListner = yield server_js_1.default(details.httpPort, target.source, target.homepage, ((_a = target.opts) === null || _a === void 0 ? void 0 : _a.watch) || false);
|
|
22
|
+
clientListner.addListener('start', () => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const appUrl = 'http://localhost:' + masterPort;
|
|
25
|
+
const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
|
|
26
|
+
logger_1.labeled(label, `URL : ${appUrl}/app/`).MESSAGE();
|
|
27
|
+
((_b = details.target.opts) === null || _b === void 0 ? void 0 : _b.open) && open_1.default(appUrl).catch();
|
|
28
|
+
});
|
|
29
|
+
return clientListner;
|
|
30
|
+
});
|