zcatalyst-cli 1.26.1 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/appsail-utils.d.ts +1 -1
- package/lib/appsail-utils.js +170 -129
- package/lib/authentication/credential.d.ts +2 -1
- package/lib/authentication/credential.js +20 -3
- package/lib/authentication/crypt.d.ts +7 -3
- package/lib/authentication/crypt.js +87 -16
- package/lib/authentication/index.js +1 -0
- package/lib/authentication/key-manager.d.ts +7 -0
- package/lib/authentication/key-manager.js +62 -0
- package/lib/authentication/login.js +20 -20
- package/lib/bin/catalyst.js +1 -15
- package/lib/client.d.ts +3 -1
- package/lib/client.js +16 -5
- package/lib/command_needs/rc.js +13 -3
- package/lib/commands/appsail/add.js +10 -0
- package/lib/commands/client/delete.js +18 -6
- package/lib/commands/client/setup.js +7 -0
- package/lib/commands/deploy/index.js +3 -3
- package/lib/commands/deploy/slate.js +65 -4
- package/lib/commands/functions/add.js +7 -0
- package/lib/commands/functions/delete.js +22 -4
- package/lib/commands/functions/execute.js +39 -71
- package/lib/commands/functions/setup.js +13 -0
- package/lib/commands/functions/shell.js +15 -1
- package/lib/commands/iac/import.js +2 -2
- package/lib/commands/init.js +34 -20
- package/lib/commands/login.js +1 -0
- package/lib/commands/pull.js +22 -1
- package/lib/commands/serve.js +2 -1
- package/lib/commands/slate/create.js +7 -4
- package/lib/commands/slate/link.js +11 -5
- package/lib/commands/slate/unlink.js +7 -0
- package/lib/commands/zest/generate/index.js +28 -35
- package/lib/deploy/features/appsail/index.js +2 -1
- package/lib/deploy/features/slate.d.ts +3 -1
- package/lib/deploy/features/slate.js +204 -5
- package/lib/docs/client-utils.toml +0 -5
- package/lib/docs/command_needs/rc.toml +9 -1
- package/lib/docs/commands/client/delete.toml +4 -0
- package/lib/docs/commands/deploy/slate.toml +3 -0
- package/lib/docs/commands/functions/delete.toml +10 -0
- package/lib/docs/commands/functions/execute.toml +1 -16
- package/lib/docs/commands/functions/setup.toml +3 -0
- package/lib/docs/commands/functions/shell.toml +8 -0
- package/lib/docs/commands/init.toml +3 -0
- package/lib/docs/commands/pull.toml +6 -0
- package/lib/docs/commands/slate/unlink.toml +6 -0
- package/lib/docs/execute/command-utils.toml +14 -0
- package/lib/docs/execute/execute-input-resolver.toml +37 -0
- package/lib/docs/init/features/project.toml +20 -0
- package/lib/docs/init/util/client.toml +4 -0
- package/lib/docs/prompt/index.toml +15 -0
- package/lib/docs/pull/features/apig.toml +6 -0
- package/lib/docs/pull/features/client.toml +20 -0
- package/lib/docs/pull/features/functions/index.toml +24 -0
- package/lib/endpoints/lib/slate.d.ts +14 -1
- package/lib/endpoints/lib/slate.js +35 -0
- package/lib/error/context-help.js +1 -1
- package/lib/error/index.js +9 -13
- package/lib/execute/command-utils.d.ts +5 -0
- package/lib/execute/command-utils.js +86 -0
- package/lib/execute/execute-input-resolver.d.ts +29 -0
- package/lib/execute/execute-input-resolver.js +207 -0
- package/lib/execute/index.d.ts +4 -1
- package/lib/execute/index.js +3 -2
- package/lib/fn-utils/lib/integ.js +22 -17
- package/lib/index.js +1 -0
- package/lib/init/dependencies/package-json.js +11 -7
- package/lib/init/features/appsail/index.js +75 -26
- package/lib/init/features/appsail/prompt-fields.d.ts +43 -0
- package/lib/init/features/appsail/prompt-fields.js +55 -0
- package/lib/init/features/appsail/utils/custom-runtime.d.ts +3 -0
- package/lib/init/features/appsail/utils/custom-runtime.js +161 -0
- package/lib/init/features/appsail/{utils.d.ts → utils/index.d.ts} +2 -2
- package/lib/init/features/appsail/utils/index.js +170 -0
- package/lib/init/features/client/index.js +4 -3
- package/lib/init/features/client/initializers/angular.js +3 -2
- package/lib/init/features/client/initializers/react.js +4 -3
- package/lib/init/features/client/prompt-fields.d.ts +37 -0
- package/lib/init/features/client/prompt-fields.js +48 -0
- package/lib/init/features/functions/index.js +37 -8
- package/lib/init/features/functions/languages/java.js +42 -7
- package/lib/init/features/functions/languages/node.js +42 -10
- package/lib/init/features/functions/languages/python.js +42 -7
- package/lib/init/features/functions/prompt-fields.d.ts +25 -0
- package/lib/init/features/functions/prompt-fields.js +34 -0
- package/lib/init/features/project.js +41 -6
- package/lib/init/features/slate/index.js +2 -0
- package/lib/init/features/slate/prompt-fields.d.ts +31 -0
- package/lib/init/features/slate/prompt-fields.js +41 -0
- package/lib/init/index.js +2 -1
- package/lib/init/util/client.js +11 -8
- package/lib/init/util/common.d.ts +2 -0
- package/lib/init/util/common.js +33 -3
- package/lib/init/util/prompt-fields.d.ts +7 -0
- package/lib/init/util/prompt-fields.js +13 -0
- package/lib/internal/command.d.ts +3 -0
- package/lib/internal/command.js +26 -3
- package/lib/migration/global/1.27.0.d.ts +2 -0
- package/lib/migration/global/1.27.0.js +39 -0
- package/lib/prompt/choice.d.ts +2 -0
- package/lib/prompt/choice.js +24 -0
- package/lib/prompt/cli-option-key.d.ts +1 -0
- package/lib/prompt/cli-option-key.js +10 -0
- package/lib/prompt/index.d.ts +6 -22
- package/lib/prompt/index.js +264 -67
- package/lib/prompt/overwrite-prompt.d.ts +11 -0
- package/lib/prompt/overwrite-prompt.js +16 -0
- package/lib/prompt/question-factory.d.ts +34 -0
- package/lib/prompt/question-factory.js +41 -0
- package/lib/prompt/register-fields.d.ts +24 -0
- package/lib/prompt/register-fields.js +37 -0
- package/lib/pull/features/apig.js +57 -6
- package/lib/pull/features/client.js +107 -24
- package/lib/pull/features/functions/index.js +100 -4
- package/lib/pull/index.js +1 -1
- package/lib/pull/utils.d.ts +13 -0
- package/lib/pull/utils.js +20 -0
- package/lib/repl-server.d.ts +4 -0
- package/lib/repl-server.js +9 -0
- package/lib/serve/features/appsail.js +2 -45
- package/lib/serve/server/lib/master/index.js +3 -3
- package/lib/serve/server/lib/slate/static-server.js +2 -2
- package/lib/serve/server/lib/web_client/server.js +2 -2
- package/lib/shell/format-functions.d.ts +4 -0
- package/lib/shell/format-functions.js +59 -0
- package/lib/shell/index.js +18 -0
- package/lib/util_modules/config/lib/appsail.d.ts +3 -2
- package/lib/util_modules/config/lib/appsail.js +21 -5
- package/lib/util_modules/config/lib/slate.d.ts +19 -0
- package/lib/util_modules/config-store.d.ts +1 -0
- package/lib/util_modules/config-store.js +29 -10
- package/lib/util_modules/constants/index.d.ts +0 -1
- package/lib/util_modules/constants/index.js +1 -3
- package/lib/util_modules/constants/lib/urls.d.ts +2 -0
- package/lib/util_modules/constants/lib/urls.js +4 -0
- package/lib/util_modules/dc.d.ts +6 -1
- package/lib/util_modules/dc.js +21 -8
- package/lib/util_modules/env.d.ts +3 -0
- package/lib/util_modules/env.js +41 -0
- package/lib/util_modules/fs/lib/sync.d.ts +1 -0
- package/lib/util_modules/fs/lib/sync.js +19 -0
- package/lib/util_modules/logger/utils.d.ts +1 -0
- package/lib/util_modules/logger/utils.js +5 -1
- package/lib/util_modules/option.d.ts +1 -0
- package/lib/util_modules/option.js +8 -0
- package/lib/util_modules/{server.js → server/index.js} +3 -3
- package/lib/util_modules/server/needed-scopes.d.ts +1 -0
- package/lib/util_modules/{constants/lib → server}/needed-scopes.js +7 -7
- package/package.json +3 -2
- package/lib/init/features/appsail/utils.js +0 -273
- package/lib/util_modules/constants/lib/needed-scopes.d.ts +0 -4
- /package/lib/docs/{dc.toml → util_modules/dc.toml} +0 -0
- /package/lib/util_modules/{server.d.ts → server/index.d.ts} +0 -0
|
@@ -32,6 +32,7 @@ exports.emptyDir = emptyDir;
|
|
|
32
32
|
exports.readJSONFile = readJSONFile;
|
|
33
33
|
exports.writeJSONFile = writeJSONFile;
|
|
34
34
|
exports.readPackageJson = readPackageJson;
|
|
35
|
+
exports.getStdinType = getStdinType;
|
|
35
36
|
exports.isDirEmpty = isDirEmpty;
|
|
36
37
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
37
38
|
const os_1 = __importDefault(require("os"));
|
|
@@ -199,6 +200,24 @@ function readPackageJson() {
|
|
|
199
200
|
});
|
|
200
201
|
return pkg;
|
|
201
202
|
}
|
|
203
|
+
function getStdinType() {
|
|
204
|
+
if (process.stdin.isTTY) {
|
|
205
|
+
return 'tty';
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
const stdinStat = fs_extra_1.default.fstatSync(process.stdin.fd);
|
|
209
|
+
if (stdinStat.isFIFO()) {
|
|
210
|
+
return 'pipe';
|
|
211
|
+
}
|
|
212
|
+
if (stdinStat.isFile()) {
|
|
213
|
+
return 'file';
|
|
214
|
+
}
|
|
215
|
+
return 'other';
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
return 'other';
|
|
219
|
+
}
|
|
220
|
+
}
|
|
202
221
|
function isDirEmpty(pth) {
|
|
203
222
|
const files = fs_extra_1.default.readdirSync(pth);
|
|
204
223
|
return files.length === 0;
|
|
@@ -7,10 +7,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
7
7
|
var _a, _LogStreamFactory_logStream;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.LogStreamFactory = exports.TTYPassThrough = exports.CHAR = void 0;
|
|
10
|
+
exports.shellCommand = shellCommand;
|
|
10
11
|
const ansi_colors_1 = require("ansi-colors");
|
|
11
|
-
const env_js_1 = require("../env.js");
|
|
12
12
|
const readline_1 = require("readline");
|
|
13
13
|
const stream_1 = require("stream");
|
|
14
|
+
const env_js_1 = require("../env.js");
|
|
14
15
|
const option_1 = require("../option");
|
|
15
16
|
const isSupported = !env_js_1.isWindows || process.env.CI || process.env.TERM === 'xterm-256color';
|
|
16
17
|
exports.CHAR = {
|
|
@@ -19,6 +20,9 @@ exports.CHAR = {
|
|
|
19
20
|
info: isSupported ? ansi_colors_1.bold.cyan('ℹ') : ansi_colors_1.bold.cyan('i'),
|
|
20
21
|
error: isSupported ? ansi_colors_1.bold.red('✖') : ansi_colors_1.bold.red('×')
|
|
21
22
|
};
|
|
23
|
+
function shellCommand(cmd) {
|
|
24
|
+
return `${(0, ansi_colors_1.dim)('>')} ${(0, ansi_colors_1.italic)(cmd)} `;
|
|
25
|
+
}
|
|
22
26
|
class TTYPassThrough extends stream_1.PassThrough {
|
|
23
27
|
constructor() {
|
|
24
28
|
super(...arguments);
|
|
@@ -3,3 +3,4 @@ export declare function getOptionValue<T = string | boolean>(key: string, fallba
|
|
|
3
3
|
export declare function setGlobalOption(key: string, value: unknown): void;
|
|
4
4
|
export declare function getGlobalOptionValue<T>(key: string, fallback?: T): T | string;
|
|
5
5
|
export declare function getUnknownOpts<T>(fallback?: T): T | Array<string>;
|
|
6
|
+
export declare function unsetOption(optKey: string): void;
|
|
@@ -8,6 +8,7 @@ exports.getOptionValue = getOptionValue;
|
|
|
8
8
|
exports.setGlobalOption = setGlobalOption;
|
|
9
9
|
exports.getGlobalOptionValue = getGlobalOptionValue;
|
|
10
10
|
exports.getUnknownOpts = getUnknownOpts;
|
|
11
|
+
exports.unsetOption = unsetOption;
|
|
11
12
|
const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
12
13
|
function getCurrentCommand(fallback) {
|
|
13
14
|
return runtime_store_1.default.get('context.opts._name', fallback);
|
|
@@ -24,3 +25,10 @@ function getGlobalOptionValue(key, fallback) {
|
|
|
24
25
|
function getUnknownOpts(fallback) {
|
|
25
26
|
return runtime_store_1.default.get('context.opts.unknownOpts', fallback);
|
|
26
27
|
}
|
|
28
|
+
function unsetOption(optKey) {
|
|
29
|
+
const opts = runtime_store_1.default.get('context.opts', {});
|
|
30
|
+
if (opts[optKey] !== undefined) {
|
|
31
|
+
delete opts[optKey];
|
|
32
|
+
runtime_store_1.default.set('context.opts', opts);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -51,10 +51,10 @@ exports.getHostIP = getHostIP;
|
|
|
51
51
|
exports.isPortListening = isPortListening;
|
|
52
52
|
const http_proxy_1 = __importDefault(require("http-proxy"));
|
|
53
53
|
const net_1 = require("net");
|
|
54
|
-
const env_1 = require("./env");
|
|
55
54
|
const child_process_1 = require("child_process");
|
|
56
|
-
const
|
|
57
|
-
const
|
|
55
|
+
const env_1 = require("../env");
|
|
56
|
+
const logger_1 = require("../logger");
|
|
57
|
+
const error_1 = __importDefault(require("../../error"));
|
|
58
58
|
class ConnectionDestroyer {
|
|
59
59
|
constructor(server) {
|
|
60
60
|
this.server = server;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SERVE_SCOPES: ("ZohoCatalyst.apigateway.apis.READ" | "ZohoCatalyst.apigateway.READ" | "ZohoCatalyst.segments.ALL" | "ZohoCatalyst.cache.READ" | "ZohoCatalyst.cache.CREATE" | "ZohoCatalyst.cache.DELETE" | "ZohoCatalyst.projects.ALL" | "ZohoCatalyst.cron.ALL" | "ZohoCatalyst.zcql.CREATE" | "ZohoCatalyst.projects.users.READ" | "ZohoCatalyst.projects.users.CREATE" | "ZohoCatalyst.projects.users.DELETE" | "ZohoCatalyst.projects.users.UPDATE" | "ZohoCatalyst.authentication.CREATE" | "ZohoCatalyst.email.CREATE" | "ZohoCatalyst.tables.ALL" | "ZohoCatalyst.tables.rows.ALL" | "ZohoCatalyst.tables.columns.ALL" | "ZohoCatalyst.tables.bulk.READ" | "ZohoCatalyst.tables.bulk.CREATE" | "ZohoCatalyst.nosql.READ" | "ZohoCatalyst.nosql.rows.ALL" | "ZohoCatalyst.folders.ALL" | "ZohoCatalyst.files.CREATE" | "ZohoCatalyst.files.READ" | "ZohoCatalyst.files.DELETE" | "ZohoCatalyst.functions.ALL" | "ZohoCatalyst.functions.EXECUTE" | "ZohoCatalyst.eventlistners.ALL" | "ZohoCatalyst.eventlisteners.produce" | "ZohoCatalyst.security.rules.Read" | "ZohoCatalyst.security.rules.Update" | "ZohoCatalyst.notifications.mobile" | "ZohoCatalyst.notifications.web" | "ZohoCatalyst.search.READ" | "ZohoCatalyst.mlkit.READ" | "QuickML.deployment.READ" | "ZohoCatalyst.pdfshot.execute" | "ZohoCatalyst.dataverse.execute" | "ZohoCatalyst.grid.READ" | "ZohoCatalyst.grid.terminate" | "ZohoCatalyst.circuits.execute" | "ZohoCatalyst.circuits.execution.READ" | "ZohoCatalyst.circuits.execution.DELETE" | "ZohoCatalyst.appsail.Read" | "ZohoCatalyst.jobpool.READ" | "ZohoCatalyst.job.ALL")[];
|
|
@@ -4,9 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
7
|
+
exports.SERVE_SCOPES = void 0;
|
|
8
|
+
const scopes_1 = __importDefault(require("../../authentication/constants/scopes"));
|
|
9
|
+
const login_1 = require("../../authentication/login");
|
|
10
|
+
const dc_1 = require("../dc");
|
|
10
11
|
const serveScopes = [
|
|
11
12
|
scopes_1.default.api_read,
|
|
12
13
|
scopes_1.default.apig_read,
|
|
@@ -56,7 +57,6 @@ const serveScopes = [
|
|
|
56
57
|
scopes_1.default.nosql_table,
|
|
57
58
|
scopes_1.default.nosql_rows
|
|
58
59
|
];
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
60
|
+
const dc = (0, dc_1.getActiveDC)({ throwError: false });
|
|
61
|
+
const _missingScope = (dc && ((_a = login_1.missingScopes[dc]) === null || _a === void 0 ? void 0 : _a.map((dvScope) => scopes_1.default[dvScope]))) || [];
|
|
62
|
+
exports.SERVE_SCOPES = serveScopes.filter((scope) => !_missingScope.includes(scope));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcatalyst-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"description": "Command Line Tool for CATALYST",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -97,11 +97,12 @@
|
|
|
97
97
|
"build:watch": "gulp watch",
|
|
98
98
|
"clean": "gulp cleanup",
|
|
99
99
|
"test:unit": "jest --config jest.config.js",
|
|
100
|
+
"test:integration": "npm run build && jest --config jest.config.js --testPathPattern=test/integration --no-coverage",
|
|
100
101
|
"lint:nofix": "eslint --ext .ts src/ --color",
|
|
101
102
|
"lint:src": "eslint --ext .ts src/ --fix --color",
|
|
102
103
|
"lint:unit": "eslint --ext .js,.ts test/ --fix --color",
|
|
103
104
|
"lint": "run-p lint:src lint:unit",
|
|
104
|
-
"test": "run-s lint:unit test:unit",
|
|
105
|
+
"test": "run-s lint:unit test:unit test:integration",
|
|
105
106
|
"prepare": "npm run build",
|
|
106
107
|
"prepublishOnly": "npm test && npm run lint",
|
|
107
108
|
"preversion": "npm run lint",
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.getAppSailZip = getAppSailZip;
|
|
49
|
-
exports.getAppSailName = getAppSailName;
|
|
50
|
-
exports.getContainerImageTag = getContainerImageTag;
|
|
51
|
-
exports.getCustomAppSailSource = getCustomAppSailSource;
|
|
52
|
-
const image_1 = require("@zcatalyst/container-plugin/out/endpoints/image");
|
|
53
|
-
const ansi_colors_1 = require("ansi-colors");
|
|
54
|
-
const inquirer = __importStar(require("inquirer"));
|
|
55
|
-
const path_1 = require("path");
|
|
56
|
-
const archiver_1 = __importDefault(require("../../../archiver"));
|
|
57
|
-
const endpoints_1 = require("../../../endpoints");
|
|
58
|
-
const error_1 = __importDefault(require("../../../error"));
|
|
59
|
-
const prompt_1 = __importDefault(require("../../../prompt"));
|
|
60
|
-
const config_1 = require("../../../util_modules/config");
|
|
61
|
-
const constants_1 = require("../../../util_modules/constants");
|
|
62
|
-
const container_1 = require("../../../util_modules/container");
|
|
63
|
-
const fs_1 = require("../../../util_modules/fs");
|
|
64
|
-
const js_1 = require("../../../util_modules/js");
|
|
65
|
-
const logger_1 = require("../../../util_modules/logger");
|
|
66
|
-
const project_1 = require("../../../util_modules/project");
|
|
67
|
-
function getAppSailZip() {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
const _gitHubAPI = yield (0, endpoints_1.gitHubAPI)();
|
|
70
|
-
const gitRepo = yield prompt_1.default.ask(prompt_1.default.question('repo', 'Please choose from the list of recommended projects to get started', {
|
|
71
|
-
type: 'list',
|
|
72
|
-
choices: [
|
|
73
|
-
prompt_1.default.choice(`appsail-nodejs - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-nodejs')}`, {
|
|
74
|
-
value: {
|
|
75
|
-
api: _gitHubAPI.appsailNodejs.bind(_gitHubAPI),
|
|
76
|
-
command: 'node index.js',
|
|
77
|
-
source: (0, project_1.resolveProjectPath)('appsail-nodejs'),
|
|
78
|
-
build: './',
|
|
79
|
-
stack: {
|
|
80
|
-
runtime: 'node16',
|
|
81
|
-
lang: 'node'
|
|
82
|
-
},
|
|
83
|
-
scripts: {
|
|
84
|
-
preserve: 'npm install',
|
|
85
|
-
predeploy: 'npm install'
|
|
86
|
-
},
|
|
87
|
-
memory: 256
|
|
88
|
-
},
|
|
89
|
-
short: 'appsail-nodejs'
|
|
90
|
-
}),
|
|
91
|
-
prompt_1.default.choice(`appsail-java - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-java')}`, {
|
|
92
|
-
value: {
|
|
93
|
-
api: _gitHubAPI.appsailJava.bind(_gitHubAPI),
|
|
94
|
-
command: 'java -jar demo-0.0.1-SNAPSHOT.jar',
|
|
95
|
-
source: (0, project_1.resolveProjectPath)('appsail-java'),
|
|
96
|
-
build: (0, path_1.join)('target', 'demo-0.0.1-SNAPSHOT.jar'),
|
|
97
|
-
stack: {
|
|
98
|
-
runtime: 'java8',
|
|
99
|
-
lang: 'java'
|
|
100
|
-
},
|
|
101
|
-
scripts: {
|
|
102
|
-
preserve: './mvnw clean install',
|
|
103
|
-
predeploy: './mvnw clean install'
|
|
104
|
-
},
|
|
105
|
-
memory: 512,
|
|
106
|
-
platform: 'javase'
|
|
107
|
-
},
|
|
108
|
-
short: 'appsail-java'
|
|
109
|
-
}),
|
|
110
|
-
prompt_1.default.choice(`appsail-python - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-python')}`, {
|
|
111
|
-
value: {
|
|
112
|
-
api: _gitHubAPI.appsailPython.bind(_gitHubAPI),
|
|
113
|
-
command: 'python3 app.py',
|
|
114
|
-
source: (0, project_1.resolveProjectPath)('appsail-python'),
|
|
115
|
-
build: './',
|
|
116
|
-
stack: {
|
|
117
|
-
runtime: 'python_3_9',
|
|
118
|
-
lang: 'python'
|
|
119
|
-
},
|
|
120
|
-
scripts: {
|
|
121
|
-
preserve: 'python3 -m pip install -r ./requirements.txt -t ./ --upgrade',
|
|
122
|
-
predeploy: 'python3 -m pip install -r ./requirements.txt -t ./ --upgrade'
|
|
123
|
-
},
|
|
124
|
-
memory: 256
|
|
125
|
-
},
|
|
126
|
-
short: 'appsail-python'
|
|
127
|
-
})
|
|
128
|
-
]
|
|
129
|
-
}));
|
|
130
|
-
(0, logger_1.info)();
|
|
131
|
-
(0, logger_1.info)((0, ansi_colors_1.white)('=>') + ' Downloading code');
|
|
132
|
-
const code = (yield gitRepo.repo.api());
|
|
133
|
-
const repoDir = gitRepo.repo.source;
|
|
134
|
-
yield fs_1.ASYNC.ensureDir(repoDir);
|
|
135
|
-
const zip = new archiver_1.default();
|
|
136
|
-
zip.load(code);
|
|
137
|
-
zip.extract(repoDir, '/', {
|
|
138
|
-
isFolder: true,
|
|
139
|
-
ignoreLevel: 1
|
|
140
|
-
});
|
|
141
|
-
yield zip.finalize();
|
|
142
|
-
(0, logger_1.success)(`Successfully downloaded the code to ${ansi_colors_1.bold.green(gitRepo.repo.source)}`);
|
|
143
|
-
return {
|
|
144
|
-
source: gitRepo.repo.source,
|
|
145
|
-
build: gitRepo.repo.build,
|
|
146
|
-
stack: gitRepo.repo.stack,
|
|
147
|
-
command: gitRepo.repo.command,
|
|
148
|
-
scripts: gitRepo.repo.scripts,
|
|
149
|
-
memory: gitRepo.repo.memory,
|
|
150
|
-
platform: gitRepo.repo.platform
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function getAppSailName() {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
const existingSails = config_1.appSailConfig.raw() || [];
|
|
157
|
-
const appName = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please provide the name for your AppSail: ', {
|
|
158
|
-
type: 'input',
|
|
159
|
-
default: 'AppSail',
|
|
160
|
-
validate: (name) => {
|
|
161
|
-
const exists = existingSails.findIndex((appSail) => appSail.name === name) !== -1
|
|
162
|
-
? 'AppSail already exists'
|
|
163
|
-
: true;
|
|
164
|
-
const match = name.match(constants_1.REGEX.appsail.name)
|
|
165
|
-
? true
|
|
166
|
-
: 'Invalid AppSail name: Name must contain only alphanumeric and hyphen';
|
|
167
|
-
return typeof exists === 'string'
|
|
168
|
-
? exists
|
|
169
|
-
: typeof match === 'string'
|
|
170
|
-
? match
|
|
171
|
-
: true;
|
|
172
|
-
}
|
|
173
|
-
}));
|
|
174
|
-
return appName.name;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
function getContainerImageTag() {
|
|
178
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
-
yield (0, container_1.isSocketAccessible)();
|
|
180
|
-
const images = (yield (0, image_1.getAllLocalImages)()).reduce((_images, img) => {
|
|
181
|
-
var _a;
|
|
182
|
-
(_a = img.RepoTags) === null || _a === void 0 ? void 0 : _a.forEach((tag) => _images.push({ imgName: tag, id: img.Id }));
|
|
183
|
-
return _images;
|
|
184
|
-
}, []);
|
|
185
|
-
const searchImages = (filter) => {
|
|
186
|
-
const filteredImages = [];
|
|
187
|
-
images.forEach((img) => {
|
|
188
|
-
var _a;
|
|
189
|
-
if (filter === '' ||
|
|
190
|
-
img.id.includes(filter) ||
|
|
191
|
-
((_a = img.imgName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(filter.toLowerCase()))) {
|
|
192
|
-
filteredImages.push({
|
|
193
|
-
name: `${img.imgName} ${(0, ansi_colors_1.dim)(img.id.substring(7, 17))}`,
|
|
194
|
-
value: img.imgName || img.id
|
|
195
|
-
});
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
return filteredImages;
|
|
200
|
-
};
|
|
201
|
-
yield prompt_1.default.register('search-box');
|
|
202
|
-
const image = yield inquirer.prompt([
|
|
203
|
-
{
|
|
204
|
-
type: 'search-box',
|
|
205
|
-
boxType: 'list',
|
|
206
|
-
name: 'name',
|
|
207
|
-
searchable: true,
|
|
208
|
-
pageSize: 10,
|
|
209
|
-
highlight: true,
|
|
210
|
-
notFoundMsg: 'No Images found!',
|
|
211
|
-
searchMsg: 'Searching images...',
|
|
212
|
-
message: 'Please search and select the image to link:',
|
|
213
|
-
source(_answersSoFar, input) {
|
|
214
|
-
input || (input = '');
|
|
215
|
-
return Promise.resolve(searchImages(input));
|
|
216
|
-
},
|
|
217
|
-
validate: (ansArr) => {
|
|
218
|
-
if (js_1.JS.isEmpty(ansArr)) {
|
|
219
|
-
return 'Must select an Image';
|
|
220
|
-
}
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
]);
|
|
225
|
-
return `docker://${image.name}`;
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
function getCustomAppSailSource() {
|
|
229
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
const dockerProtocol = yield prompt_1.default.ask(prompt_1.default.question('type', 'Please choose one of the supported protocols:', {
|
|
231
|
-
type: 'list',
|
|
232
|
-
choices: [
|
|
233
|
-
prompt_1.default.choice(`Docker image ${(0, ansi_colors_1.italic)('(docker://)')}`, {
|
|
234
|
-
value: 'image',
|
|
235
|
-
short: 'Docker image'
|
|
236
|
-
}),
|
|
237
|
-
prompt_1.default.choice(`Docker archive ${(0, ansi_colors_1.italic)('(docker-archive://)')}`, {
|
|
238
|
-
value: 'docker-archive',
|
|
239
|
-
short: 'Docker archive'
|
|
240
|
-
})
|
|
241
|
-
]
|
|
242
|
-
}));
|
|
243
|
-
switch (dockerProtocol.type) {
|
|
244
|
-
case 'image': {
|
|
245
|
-
return getContainerImageTag();
|
|
246
|
-
}
|
|
247
|
-
case 'docker-archive': {
|
|
248
|
-
const archivePath = yield prompt_1.default.ask(prompt_1.default.question('archive', 'Please provide the path to the docker archive file: ', {
|
|
249
|
-
type: 'input',
|
|
250
|
-
validate: (pth) => __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
if (!(0, path_1.isAbsolute)(pth)) {
|
|
252
|
-
return 'Please provide an absolute path';
|
|
253
|
-
}
|
|
254
|
-
if (!(yield fs_1.ASYNC.fileExists(pth))) {
|
|
255
|
-
return 'Provided path does not exists';
|
|
256
|
-
}
|
|
257
|
-
if (!pth.endsWith('.tar')) {
|
|
258
|
-
return 'Provided file is not a valid docker archive. Please provide a .tar file';
|
|
259
|
-
}
|
|
260
|
-
return true;
|
|
261
|
-
})
|
|
262
|
-
}));
|
|
263
|
-
const path = (0, path_1.relative)((0, project_1.getProjectRoot)(), archivePath.archive);
|
|
264
|
-
return `docker-archive://${path}`;
|
|
265
|
-
}
|
|
266
|
-
default: {
|
|
267
|
-
throw new error_1.default('Unsupported protocol selected for AppSail source', {
|
|
268
|
-
exit: 2
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
declare const _default: Readonly<{
|
|
2
|
-
SERVE: ("ZohoCatalyst.apigateway.apis.READ" | "ZohoCatalyst.apigateway.READ" | "ZohoCatalyst.segments.ALL" | "ZohoCatalyst.cache.READ" | "ZohoCatalyst.cache.CREATE" | "ZohoCatalyst.cache.DELETE" | "ZohoCatalyst.projects.ALL" | "ZohoCatalyst.cron.ALL" | "ZohoCatalyst.zcql.CREATE" | "ZohoCatalyst.projects.users.READ" | "ZohoCatalyst.projects.users.CREATE" | "ZohoCatalyst.projects.users.DELETE" | "ZohoCatalyst.projects.users.UPDATE" | "ZohoCatalyst.authentication.CREATE" | "ZohoCatalyst.email.CREATE" | "ZohoCatalyst.tables.ALL" | "ZohoCatalyst.tables.rows.ALL" | "ZohoCatalyst.tables.columns.ALL" | "ZohoCatalyst.tables.bulk.READ" | "ZohoCatalyst.tables.bulk.CREATE" | "ZohoCatalyst.nosql.READ" | "ZohoCatalyst.nosql.rows.ALL" | "ZohoCatalyst.folders.ALL" | "ZohoCatalyst.files.CREATE" | "ZohoCatalyst.files.READ" | "ZohoCatalyst.files.DELETE" | "ZohoCatalyst.functions.ALL" | "ZohoCatalyst.functions.EXECUTE" | "ZohoCatalyst.eventlistners.ALL" | "ZohoCatalyst.eventlisteners.produce" | "ZohoCatalyst.security.rules.Read" | "ZohoCatalyst.security.rules.Update" | "ZohoCatalyst.notifications.mobile" | "ZohoCatalyst.notifications.web" | "ZohoCatalyst.search.READ" | "ZohoCatalyst.mlkit.READ" | "QuickML.deployment.READ" | "ZohoCatalyst.pdfshot.execute" | "ZohoCatalyst.dataverse.execute" | "ZohoCatalyst.grid.READ" | "ZohoCatalyst.grid.terminate" | "ZohoCatalyst.circuits.execute" | "ZohoCatalyst.circuits.execution.READ" | "ZohoCatalyst.circuits.execution.DELETE" | "ZohoCatalyst.appsail.Read" | "ZohoCatalyst.jobpool.READ" | "ZohoCatalyst.job.ALL")[];
|
|
3
|
-
}>;
|
|
4
|
-
export default _default;
|
|
File without changes
|
|
File without changes
|