zcatalyst-cli 1.26.0 → 1.26.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/lib/deploy/features/slate.js +9 -5
- package/lib/docs/serve/server/lib/slate/index.toml +5 -0
- package/lib/init/features/slate/index.js +4 -2
- package/lib/serve/server/lib/appsail/start.js +5 -12
- package/lib/serve/server/lib/slate/index.js +7 -0
- package/lib/slate-utils.js +23 -14
- package/lib/util_modules/config/lib/slate.d.ts +2 -1
- package/lib/util_modules/config/lib/slate.js +23 -8
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@ const urls_1 = __importDefault(require("../../util_modules/constants/lib/urls"))
|
|
|
27
27
|
const project_1 = require("../../util_modules/project");
|
|
28
28
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
29
|
const env = getEnvironmentType();
|
|
30
|
-
const targets = yield config_1.slateConfig.getAllTargetDetails(false);
|
|
30
|
+
const targets = yield config_1.slateConfig.getAllTargetDetails(false, false);
|
|
31
31
|
if (!targets || targets.length === 0) {
|
|
32
32
|
throw new error_1.default('No targets found');
|
|
33
33
|
}
|
|
@@ -50,7 +50,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
50
50
|
const slateAppConfigs = yield (yield (0, endpoints_1.slateAPI)({ env })).getAllApps();
|
|
51
51
|
const throbber = throbber_1.default.getInstance();
|
|
52
52
|
const deployRes = yield validTargets.reduce((result, _targ) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
var _a;
|
|
54
53
|
const targ = _targ;
|
|
55
54
|
const prevRes = yield result;
|
|
56
55
|
try {
|
|
@@ -59,9 +58,14 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
59
58
|
text: `Preparing Slate[${targ.name}]`
|
|
60
59
|
});
|
|
61
60
|
const isAppExists = slateAppConfigs.find((app) => app.name === targ.name && app.app_type === 'cli');
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
let configDetails;
|
|
62
|
+
if (!isAppExists) {
|
|
63
|
+
const targetWithConfig = yield config_1.slateConfig.getTargetDetails(targ);
|
|
64
|
+
if (!targetWithConfig.config) {
|
|
65
|
+
throw new error_1.default('Unable to read slate configuration for deploy');
|
|
66
|
+
}
|
|
67
|
+
configDetails = targetWithConfig.config;
|
|
68
|
+
}
|
|
65
69
|
const deploymentName = configDetails === null || configDetails === void 0 ? void 0 : configDetails.deployment_name;
|
|
66
70
|
deploymentName ? configDetails === null || configDetails === void 0 ? true : delete configDetails.deployment_name : null;
|
|
67
71
|
const readStream = yield slate_utils_1.slateUtils.pack(targ.source);
|
|
@@ -13,3 +13,8 @@ context = '''Error when installing the dependencies.'''
|
|
|
13
13
|
aid = '''Please install the necessary packages before running the command ${arg[0]}'''
|
|
14
14
|
link = 'https://docs.catalyst.zoho.com/en/cli/v1/serve-resources/serve-all-resources/#serve-a-slate-app'
|
|
15
15
|
|
|
16
|
+
[SERVE-SLATE-4]
|
|
17
|
+
context = '''The cli-config.json file was not found in the slate source directory ${arg[0]}.'''
|
|
18
|
+
aid = '''Please ensure cli-config.json exists in the slate source directory with a valid dev_command using ZC_SLATE_PORT.'''
|
|
19
|
+
link = 'https://docs.catalyst.zoho.com/en/cli/v1/serve-resources/serve-all-resources/#serve-a-slate-app'
|
|
20
|
+
|
|
@@ -202,9 +202,11 @@ function addExistingSlate(existingSlates) {
|
|
|
202
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
203
203
|
const projectRoot = (0, project_1.getProjectRoot)();
|
|
204
204
|
const sourceOpt = (0, option_1.getOptionValue)('source');
|
|
205
|
+
const isDuplicate = (candidateAbs) => existingSlates.findIndex((targ) => (0, path_1.resolve)(projectRoot, targ.source) === candidateAbs) !==
|
|
206
|
+
-1;
|
|
205
207
|
if (sourceOpt) {
|
|
206
208
|
const buildPath = (0, path_1.resolve)(projectRoot, sourceOpt);
|
|
207
|
-
if (
|
|
209
|
+
if (isDuplicate(buildPath)) {
|
|
208
210
|
throw new error_1.default(`Path ${(0, ansi_colors_1.bold)(buildPath)} is already linked to a Slate app.`, {
|
|
209
211
|
exit: 1
|
|
210
212
|
});
|
|
@@ -221,7 +223,7 @@ function addExistingSlate(existingSlates) {
|
|
|
221
223
|
type: 'file-path',
|
|
222
224
|
validate: (pth) => __awaiter(this, void 0, void 0, function* () {
|
|
223
225
|
const buildPath = (0, path_1.resolve)(projectRoot, pth.value);
|
|
224
|
-
if (
|
|
226
|
+
if (isDuplicate(buildPath))
|
|
225
227
|
return 'Path is already linked.';
|
|
226
228
|
if (yield fs_1.ASYNC.dirExists(buildPath)) {
|
|
227
229
|
return true;
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// exit codes
|
|
5
5
|
// 150 - start up command failure
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const EXEC = require('child_process').exec;
|
|
8
|
+
|
|
8
9
|
const WAR = 'war';
|
|
9
10
|
const JAVASE = 'javase';
|
|
10
11
|
const NODEJS = 'nodejs';
|
|
@@ -61,12 +62,7 @@ function main() {
|
|
|
61
62
|
throw new Error(`invalid runtime type: ${CMD_ARGS.rtType}`);
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
const _process =
|
|
65
|
-
cwd,
|
|
66
|
-
env: process.env,
|
|
67
|
-
stdio: 'pipe',
|
|
68
|
-
detached: true
|
|
69
|
-
});
|
|
65
|
+
const _process = EXEC(command.toString(), { cwd });
|
|
70
66
|
|
|
71
67
|
_process.on('error', (error) => {
|
|
72
68
|
// eslint-disable-next-line no-console
|
|
@@ -77,11 +73,8 @@ function main() {
|
|
|
77
73
|
_process.stdout.pipe(process.stdout);
|
|
78
74
|
_process.stderr.pipe(process.stderr);
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
process.kill(-_process.pid, signal);
|
|
83
|
-
process.exit();
|
|
84
|
-
});
|
|
76
|
+
process.once('SIGINT', () => {
|
|
77
|
+
_process.kill('SIGINT');
|
|
85
78
|
});
|
|
86
79
|
}
|
|
87
80
|
|
|
@@ -51,6 +51,13 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
|
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
const configFile = (0, path_1.join)(targetSlate.source, file_names_1.default.cli_config);
|
|
54
|
+
if (!(yield (0, async_1.fileExists)(configFile))) {
|
|
55
|
+
throw new error_1.default('cli-config.json file not found in source directory', {
|
|
56
|
+
exit: 1,
|
|
57
|
+
errorId: 'SERVE-SLATE-4',
|
|
58
|
+
arg: [targetSlate.source]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
54
61
|
const configJson = yield (0, async_1.readJSONFile)(configFile);
|
|
55
62
|
const installDeps = (0, shell_1.spawn)('npm', ['install'], {
|
|
56
63
|
cwd: targetSlate.source
|
package/lib/slate-utils.js
CHANGED
|
@@ -18,12 +18,13 @@ const ansi_colors_1 = require("ansi-colors");
|
|
|
18
18
|
const path_1 = require("path");
|
|
19
19
|
const archiver_1 = __importDefault(require("./archiver"));
|
|
20
20
|
const error_1 = __importDefault(require("./error"));
|
|
21
|
-
const runtime_store_1 = __importDefault(require("./runtime-store"));
|
|
22
21
|
const fs_1 = require("./util_modules/fs");
|
|
23
22
|
const option_1 = require("./util_modules/option");
|
|
24
23
|
const constants_1 = require("./util_modules/constants");
|
|
25
24
|
const logger_1 = require("./util_modules/logger");
|
|
26
25
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
26
|
+
const sync_1 = require("./util_modules/fs/lib/sync");
|
|
27
|
+
const project_1 = require("./util_modules/project");
|
|
27
28
|
exports.slateUtils = {
|
|
28
29
|
validate: (source) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
30
|
const sourceDirExists = yield fs_1.ASYNC.dirExists(source);
|
|
@@ -92,11 +93,10 @@ exports.slateUtils = {
|
|
|
92
93
|
}
|
|
93
94
|
return refined.matched;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
return refinedTargets;
|
|
96
|
+
return allTargets.filter((app) => {
|
|
97
|
+
const rel = (0, path_1.relative)((0, project_1.getProjectRoot)(), app.source);
|
|
98
|
+
return rel === '' || (!rel.startsWith('..') && !rel.startsWith(path_1.sep + '..'));
|
|
99
|
+
});
|
|
100
100
|
},
|
|
101
101
|
pack: (source) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
102
|
const excludePatterns = [
|
|
@@ -135,18 +135,27 @@ function validateServeCommand(targDetails) {
|
|
|
135
135
|
targDetails.forEach((targ) => {
|
|
136
136
|
var _a, _b, _c;
|
|
137
137
|
if (((_a = targ.config) === null || _a === void 0 ? void 0 : _a.framework) !== 'static') {
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
138
|
+
const configPath = (0, path_1.join)(targ.source, constants_1.FILENAME.cli_config);
|
|
139
|
+
if (!(0, sync_1.fileExists)(configPath)) {
|
|
140
140
|
targ.validity = {
|
|
141
141
|
valid: false,
|
|
142
|
-
reason: '
|
|
142
|
+
reason: 'Missing cli-config.json file in source directory'
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
else {
|
|
146
|
+
const serveConfig = fs_1.SYNC.readJSONFile(configPath);
|
|
147
|
+
if (targ.validity.valid && !((_b = serveConfig === null || serveConfig === void 0 ? void 0 : serveConfig.slate) === null || _b === void 0 ? void 0 : _b.dev_command)) {
|
|
148
|
+
targ.validity = {
|
|
149
|
+
valid: false,
|
|
150
|
+
reason: 'Development command missing'
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (!((_c = serveConfig === null || serveConfig === void 0 ? void 0 : serveConfig.slate) === null || _c === void 0 ? void 0 : _c.dev_command).includes('ZC_SLATE_PORT')) {
|
|
154
|
+
targ.validity = {
|
|
155
|
+
valid: false,
|
|
156
|
+
reason: `Port configuration is missing. Please set the ${(0, ansi_colors_1.bold)('ZC_SLATE_PORT')} as the port value in ${(0, ansi_colors_1.bold)('cli-config.json')} under your development command.`
|
|
157
|
+
};
|
|
158
|
+
}
|
|
150
159
|
}
|
|
151
160
|
}
|
|
152
161
|
});
|
|
@@ -95,6 +95,7 @@ export interface ISlateConfig {
|
|
|
95
95
|
config?: ISlateConfigDetails;
|
|
96
96
|
details?: ISlateUploadResponse;
|
|
97
97
|
source: string;
|
|
98
|
+
originalSource?: string;
|
|
98
99
|
name: string;
|
|
99
100
|
validity: {
|
|
100
101
|
valid?: boolean;
|
|
@@ -103,4 +104,4 @@ export interface ISlateConfig {
|
|
|
103
104
|
}
|
|
104
105
|
export declare function raw(throwError?: boolean): Array<ISlateConfig> | undefined;
|
|
105
106
|
export declare function getTargetDetails(targ: ISlateConfig): Promise<ISlateConfig>;
|
|
106
|
-
export declare function getAllTargetDetails(throwErr?: boolean): Promise<Array<ISlateConfig> | undefined>;
|
|
107
|
+
export declare function getAllTargetDetails(throwErr?: boolean, loadConfig?: boolean): Promise<Array<ISlateConfig> | undefined>;
|
|
@@ -33,6 +33,11 @@ function raw(throwError = false) {
|
|
|
33
33
|
}
|
|
34
34
|
return config.get('slate');
|
|
35
35
|
}
|
|
36
|
+
function normalizeTarget(target) {
|
|
37
|
+
const originalSource = target.source;
|
|
38
|
+
const resolvedSource = (0, project_1.resolveProjectPath)(originalSource);
|
|
39
|
+
return Object.assign(Object.assign({}, target), { source: resolvedSource, originalSource });
|
|
40
|
+
}
|
|
36
41
|
function getTargetDetails(targ) {
|
|
37
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
43
|
const rawTargets = raw();
|
|
@@ -40,18 +45,22 @@ function getTargetDetails(targ) {
|
|
|
40
45
|
if (!target) {
|
|
41
46
|
return Object.assign(Object.assign({}, targ), { validity: { valid: false, reason: 'Slate not found' } });
|
|
42
47
|
}
|
|
43
|
-
const
|
|
48
|
+
const normalized = normalizeTarget(target);
|
|
49
|
+
const slateConfigPth = (0, path_1.join)(normalized.source, '.catalyst', constants_1.FILENAME.slate_config);
|
|
50
|
+
if (!fs_1.SYNC.fileExists(slateConfigPth)) {
|
|
51
|
+
return Object.assign(Object.assign({}, normalized), { validity: { valid: false, reason: 'Config file not present' } });
|
|
52
|
+
}
|
|
44
53
|
const slateConfigJson = fs_1.SYNC.readFile(slateConfigPth);
|
|
45
54
|
const slateConfig = (0, toml_1.parseTOML)(slateConfigJson);
|
|
46
55
|
if (!slateConfig) {
|
|
47
|
-
return Object.assign(Object.assign({},
|
|
56
|
+
return Object.assign(Object.assign({}, normalized), { validity: { valid: false, reason: 'Config file is empty' } });
|
|
48
57
|
}
|
|
49
|
-
|
|
50
|
-
return Object.assign({},
|
|
58
|
+
normalized.config = slateConfig;
|
|
59
|
+
return Object.assign({}, normalized);
|
|
51
60
|
});
|
|
52
61
|
}
|
|
53
62
|
function getAllTargetDetails() {
|
|
54
|
-
return __awaiter(this, arguments, void 0, function* (throwErr = true) {
|
|
63
|
+
return __awaiter(this, arguments, void 0, function* (throwErr = true, loadConfig = true) {
|
|
55
64
|
const rawTargets = raw();
|
|
56
65
|
if (!rawTargets) {
|
|
57
66
|
if (throwErr) {
|
|
@@ -59,16 +68,22 @@ function getAllTargetDetails() {
|
|
|
59
68
|
}
|
|
60
69
|
return;
|
|
61
70
|
}
|
|
62
|
-
return Promise.all(rawTargets.reduce((resArr,
|
|
71
|
+
return Promise.all(rawTargets.reduce((resArr, rawTarget) => {
|
|
72
|
+
var _a;
|
|
73
|
+
const target = normalizeTarget(rawTarget);
|
|
63
74
|
const isPath = fs_1.SYNC.dirExists(target.source);
|
|
64
75
|
if (!isPath) {
|
|
65
76
|
resArr.push(Promise.resolve(Object.assign(Object.assign({}, target), { validity: {
|
|
66
77
|
valid: false,
|
|
67
|
-
reason: `Invalid source path: (${(0, ansi_colors_1.bold)(target.source)}) directory not found`
|
|
78
|
+
reason: `Invalid source path: (${(0, ansi_colors_1.bold)((_a = target.originalSource) !== null && _a !== void 0 ? _a : target.source)}) directory not found`
|
|
68
79
|
} })));
|
|
69
80
|
return resArr;
|
|
70
81
|
}
|
|
71
|
-
|
|
82
|
+
if (!loadConfig) {
|
|
83
|
+
resArr.push(Promise.resolve(Object.assign(Object.assign({}, target), { validity: { valid: true } })));
|
|
84
|
+
return resArr;
|
|
85
|
+
}
|
|
86
|
+
const slateConfigPth = (0, path_1.join)(target.source, '.catalyst', constants_1.FILENAME.slate_config);
|
|
72
87
|
const isConfigPath = fs_1.SYNC.fileExists(slateConfigPth);
|
|
73
88
|
if (!isConfigPath) {
|
|
74
89
|
resArr.push(Promise.resolve(Object.assign(Object.assign({}, target), { validity: {
|