zcatalyst-cli 1.25.1 → 1.25.2

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.
@@ -25,89 +25,72 @@ const option_1 = require("../../util_modules/option");
25
25
  const urls_1 = __importDefault(require("../../util_modules/constants/lib/urls"));
26
26
  const project_1 = require("../../util_modules/project");
27
27
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
28
- const dId = process.env.ZC_APP_DEPLOYMENT_BUILD_ID;
29
28
  const env = getEnvironmentType();
30
- if (!dId) {
31
- const targets = yield config_1.slateConfig.getAllTargetDetails(false);
32
- if (!targets || targets.length === 0) {
33
- throw new error_1.default('No targets found');
34
- }
35
- const filtered = slate_utils_1.slateUtils.filterTargets(targets);
36
- const validTargets = filtered.filter((targ) => {
37
- var _a, _b;
38
- if ((_a = targ.validity) === null || _a === void 0 ? void 0 : _a.valid) {
39
- return targ;
40
- }
41
- (0, logger_1.labeled)('Slate: ', 'Invalid Slate service ' + (0, ansi_colors_1.bold)(targ.name || 'Unknown')).ERROR();
42
- (0, logger_1.error)('Reason: ' + ((_b = targ.validity) === null || _b === void 0 ? void 0 : _b.reason));
43
- (0, logger_1.info)();
44
- return false;
45
- });
46
- if (validTargets.length === 0) {
47
- throw new error_1.default('No valid Slate services found to deploy', {
48
- skipHelp: true
49
- });
29
+ const targets = yield config_1.slateConfig.getAllTargetDetails(false);
30
+ if (!targets || targets.length === 0) {
31
+ throw new error_1.default('No targets found');
32
+ }
33
+ const filtered = slate_utils_1.slateUtils.filterTargets(targets);
34
+ const validTargets = filtered.filter((targ) => {
35
+ var _a, _b;
36
+ if ((_a = targ.validity) === null || _a === void 0 ? void 0 : _a.valid) {
37
+ return targ;
50
38
  }
51
- const slateAppConfigs = yield (yield (0, endpoints_1.slateAPI)({ env })).getAllApps();
52
- const throbber = throbber_1.default.getInstance();
53
- const deployRes = yield validTargets.reduce((result, _targ) => __awaiter(void 0, void 0, void 0, function* () {
54
- var _a;
55
- const targ = _targ;
56
- const prevRes = yield result;
57
- try {
58
- const throbberName = `prepare_slate_${targ.name}`;
59
- throbber.add(throbberName, {
60
- text: `Preparing Slate[${targ.name}]`
61
- });
62
- const isAppExists = slateAppConfigs.find((app) => app.name === targ.name && app.app_type === 'cli');
63
- const configDetails = !isAppExists
64
- ? (_a = (yield config_1.slateConfig.getTargetDetails(targ))) === null || _a === void 0 ? void 0 : _a.config
65
- : undefined;
66
- const deploymentName = configDetails === null || configDetails === void 0 ? void 0 : configDetails.deployment_name;
67
- deploymentName ? configDetails === null || configDetails === void 0 ? true : delete configDetails.deployment_name : null;
68
- const readStream = yield slate_utils_1.slateUtils.pack(targ.source);
69
- throbber.remove(throbberName);
70
- const response = yield (yield (0, endpoints_1.slateAPI)({ env })).deploy(readStream.stream, readStream.length, targ.name, '', deploymentName ? deploymentName : '', isAppExists === null || isAppExists === void 0 ? void 0 : isAppExists.id, configDetails ? JSON.stringify(configDetails) : '', (0, option_1.getOptionValue)('m') || '');
71
- targ.details = response;
72
- }
73
- catch (err) {
74
- (0, logger_1.debug)(err);
75
- _targ.validity = {
76
- valid: false,
77
- reason: error_1.default.getErrorInstance(err).message
78
- };
79
- }
80
- prevRes.push(_targ);
81
- return Promise.resolve(prevRes);
82
- }), Promise.resolve([]));
83
- const deployedValidTargets = deployRes.filter((targ) => {
84
- var _a, _b, _c;
85
- if (!((_a = targ.validity) === null || _a === void 0 ? void 0 : _a.valid)) {
86
- (0, logger_1.warning)('Deploy of Slate [' +
87
- targ.name +
88
- '] was unsuccessful since ' +
89
- ((_b = targ.validity) === null || _b === void 0 ? void 0 : _b.reason));
90
- }
91
- return (_c = targ.validity) === null || _c === void 0 ? void 0 : _c.valid;
39
+ (0, logger_1.labeled)('Slate: ', 'Invalid Slate service ' + (0, ansi_colors_1.bold)(targ.name || 'Unknown')).ERROR();
40
+ (0, logger_1.error)('Reason: ' + ((_b = targ.validity) === null || _b === void 0 ? void 0 : _b.reason));
41
+ (0, logger_1.info)();
42
+ return false;
43
+ });
44
+ if (validTargets.length === 0) {
45
+ throw new error_1.default('No valid Slate services found to deploy', {
46
+ skipHelp: true
92
47
  });
93
- runtime_store_1.default.set('context.payload.slate.targets', deployedValidTargets);
94
- if (deployedValidTargets.length > 0) {
95
- runtime_store_1.default.set('context.payload.slate.deploy', true);
96
- }
97
48
  }
98
- else {
99
- const source = runtime_store_1.default.get('cwd');
100
- yield slate_utils_1.slateUtils.validate(source);
101
- const readStream = yield slate_utils_1.slateUtils.pack();
49
+ const slateAppConfigs = yield (yield (0, endpoints_1.slateAPI)({ env })).getAllApps();
50
+ const throbber = throbber_1.default.getInstance();
51
+ const deployRes = yield validTargets.reduce((result, _targ) => __awaiter(void 0, void 0, void 0, function* () {
52
+ var _a;
53
+ const targ = _targ;
54
+ const prevRes = yield result;
102
55
  try {
103
- const deployRes = yield (yield (0, endpoints_1.slateAPI)({ env })).deploy(readStream.stream, readStream.length, process.env.ZC_APP_NAME, dId);
104
- deployRes.name = process.env.ZC_APP_NAME;
105
- runtime_store_1.default.set('context.payload.slate.targets', [deployRes]);
106
- runtime_store_1.default.set('context.payload.slate.deploy', true);
56
+ const throbberName = `prepare_slate_${targ.name}`;
57
+ throbber.add(throbberName, {
58
+ text: `Preparing Slate[${targ.name}]`
59
+ });
60
+ const isAppExists = slateAppConfigs.find((app) => app.name === targ.name && app.app_type === 'cli');
61
+ const configDetails = !isAppExists
62
+ ? (_a = (yield config_1.slateConfig.getTargetDetails(targ))) === null || _a === void 0 ? void 0 : _a.config
63
+ : undefined;
64
+ const deploymentName = configDetails === null || configDetails === void 0 ? void 0 : configDetails.deployment_name;
65
+ deploymentName ? configDetails === null || configDetails === void 0 ? true : delete configDetails.deployment_name : null;
66
+ const readStream = yield slate_utils_1.slateUtils.pack(targ.source);
67
+ throbber.remove(throbberName);
68
+ const response = yield (yield (0, endpoints_1.slateAPI)({ env })).deploy(readStream.stream, readStream.length, targ.name, deploymentName ? deploymentName : '', isAppExists === null || isAppExists === void 0 ? void 0 : isAppExists.id, configDetails ? JSON.stringify(configDetails) : '', (0, option_1.getOptionValue)('m') || '');
69
+ targ.details = response;
107
70
  }
108
71
  catch (err) {
109
- throw err;
72
+ (0, logger_1.debug)(err);
73
+ _targ.validity = {
74
+ valid: false,
75
+ reason: error_1.default.getErrorInstance(err).message
76
+ };
110
77
  }
78
+ prevRes.push(_targ);
79
+ return Promise.resolve(prevRes);
80
+ }), Promise.resolve([]));
81
+ const deployedValidTargets = deployRes.filter((targ) => {
82
+ var _a, _b, _c;
83
+ if (!((_a = targ.validity) === null || _a === void 0 ? void 0 : _a.valid)) {
84
+ (0, logger_1.warning)('Deploy of Slate [' +
85
+ targ.name +
86
+ '] was unsuccessful since ' +
87
+ ((_b = targ.validity) === null || _b === void 0 ? void 0 : _b.reason));
88
+ }
89
+ return (_c = targ.validity) === null || _c === void 0 ? void 0 : _c.valid;
90
+ });
91
+ runtime_store_1.default.set('context.payload.slate.targets', deployedValidTargets);
92
+ if (deployedValidTargets.length > 0) {
93
+ runtime_store_1.default.set('context.payload.slate.deploy', true);
111
94
  }
112
95
  });
113
96
  function getEnvironmentType() {
@@ -11,6 +11,6 @@ declare class Slate {
11
11
  getFrameworks(): Promise<Array<FrameworkType>>;
12
12
  getAllApps(): Promise<Array<ISlateAppInfo>>;
13
13
  downloadTemplate(): Promise<unknown>;
14
- deploy(sourceStream: ReadStream, contentLength: number, appName: string, deployId: string, deploymentName?: string, appId?: string, config?: string, msg?: string): Promise<unknown>;
14
+ deploy(sourceStream: ReadStream, contentLength: number, appName: string, deploymentName?: string, appId?: string, config?: string, msg?: string): Promise<unknown>;
15
15
  }
16
16
  export default Slate;
@@ -62,9 +62,9 @@ class Slate {
62
62
  throw new error_1.default('Error while downloading the template', { exit: 2 });
63
63
  });
64
64
  }
65
- deploy(sourceStream, contentLength, appName, deployId, deploymentName, appId, config, msg) {
65
+ deploy(sourceStream, contentLength, appName, deploymentName, appId, config, msg) {
66
66
  return __awaiter(this, void 0, void 0, function* () {
67
- const formData = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ file: sourceStream }, (appId && { app_id: appId })), (deployId && { build_id: deployId })), (deploymentName && { deployment_name: deploymentName })), (appId || deployId ? {} : { name: appName })), (config && { configuration: config })), (msg && { message: msg }));
67
+ const formData = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ file: sourceStream }, (appId && { app_id: appId })), (deploymentName && { deployment_name: deploymentName })), (appId ? {} : { name: appName })), (config && { configuration: config })), (msg && { message: msg }));
68
68
  const res = yield new api_1.default(this.opts).post(`/slate/v1/project/${this.projectId}/app/upload`, {
69
69
  formData,
70
70
  json: false,
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.validateServeCommand = exports.slateUtils = void 0;
16
16
  const ansi_colors_1 = require("ansi-colors");
17
- const fs_extra_1 = require("fs-extra");
18
17
  const path_1 = require("path");
19
18
  const archiver_1 = __importDefault(require("./archiver"));
20
19
  const error_1 = __importDefault(require("./error"));
@@ -24,8 +23,6 @@ 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"));
27
- const env_1 = require("./util_modules/env");
28
- const async_1 = require("./util_modules/fs/lib/async");
29
26
  exports.slateUtils = {
30
27
  validate: (source) => __awaiter(void 0, void 0, void 0, function* () {
31
28
  const sourceDirExists = yield fs_1.ASYNC.dirExists(source);
@@ -101,68 +98,6 @@ exports.slateUtils = {
101
98
  return refinedTargets;
102
99
  },
103
100
  pack: (source) => __awaiter(void 0, void 0, void 0, function* () {
104
- if (env_1.isCI) {
105
- source = source !== null && source !== void 0 ? source : runtime_store_1.default.get('cwd');
106
- const tempDir = (0, path_1.resolve)(constants_1.FOLDERNAME.slate);
107
- if (!(yield (0, async_1.dirExists)(tempDir))) {
108
- (0, fs_extra_1.mkdir)(tempDir);
109
- const excludePatterns = [
110
- '**/.catalyst',
111
- `**/${constants_1.FILENAME.log}`,
112
- `**/${constants_1.FILENAME.config}`,
113
- `**/${constants_1.FILENAME.rc}`,
114
- `**/${constants_1.FILENAME.app_config}`,
115
- `**/${constants_1.FILENAME.catalyst_ignore}`
116
- ];
117
- const files = yield fs_1.ASYNC.walk(source, {
118
- filter: {
119
- exclude: (path) => __awaiter(void 0, void 0, void 0, function* () {
120
- return !!excludePatterns.find((glob) => (0, minimatch_1.default)(path.replace(source + path_1.sep, ''), glob, {
121
- dot: true
122
- }));
123
- }),
124
- excludeDir: true
125
- }
126
- });
127
- const zip = new archiver_1.default('static');
128
- const fileArr = [];
129
- files.forEach((file) => {
130
- fileArr.push({
131
- path: (0, path_1.relative)(source, file.path),
132
- type: (0, path_1.extname)(file.path).replace('.', '').toUpperCase() || '',
133
- size: file.stats.size
134
- });
135
- zip.add(file.path.replace(source + path_1.sep, ''), file.stats.isSymbolicLink()
136
- ? fs_1.SYNC.readSymLink(file.path)
137
- : fs_1.SYNC.getReadStream(file.path), {
138
- mode: file.stats.mode
139
- });
140
- });
141
- const zipFinalizer = yield zip.finalize();
142
- const staticZip = (0, path_1.join)(tempDir, constants_1.FILENAME.slate.static_zip);
143
- yield zipFinalizer.writeZip(staticZip);
144
- const content = {
145
- version: '',
146
- framework: process.env.ZC_FRAMEWORK,
147
- runtime: '',
148
- static: fileArr
149
- };
150
- const configJson = (0, path_1.join)(tempDir, constants_1.FILENAME.slate.config_json);
151
- fs_1.SYNC.writeFile(configJson, JSON.stringify(content, null, 2) + '\n');
152
- }
153
- const slateZip = yield fs_1.ASYNC.walk(tempDir, { includeDirPaths: false });
154
- const zipWithJson = new archiver_1.default();
155
- slateZip.forEach((file) => {
156
- zipWithJson.add(file.path.replace(tempDir + path_1.sep, ''), file.stats.isSymbolicLink()
157
- ? fs_1.SYNC.readSymLink(file.path)
158
- : fs_1.SYNC.getReadStream(file.path), {
159
- mode: file.stats.mode
160
- });
161
- });
162
- const zipFinalizerWithJson = yield zipWithJson.finalize();
163
- yield fs_1.ASYNC.deleteDir(tempDir);
164
- return yield zipFinalizerWithJson.fsStream();
165
- }
166
101
  const excludePatterns = [
167
102
  '**/.DS_Store',
168
103
  '**/.catalyst',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.25.1",
3
+ "version": "1.25.2",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {