zcatalyst-cli 1.18.0-beta.11 → 1.18.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/commands/slate/unlink.toml +9 -0
- package/docs/endpoints/lib/env.toml +3 -1
- package/docs/serve/server/lib/slate/index.toml +14 -0
- package/docs/slate-utils.toml +4 -0
- package/lib/archiver.js +18 -9
- package/lib/authentication/login.js +3 -2
- package/lib/command_needs/auth.js +1 -1
- package/lib/command_needs/rc.js +40 -3
- package/lib/commands/deploy/index.js +6 -1
- package/lib/commands/deploy/slate.js +58 -0
- package/lib/commands/index.js +3 -0
- package/lib/commands/init.js +4 -10
- package/lib/commands/slate/create.js +59 -0
- package/lib/commands/slate/link.js +59 -0
- package/lib/commands/slate/unlink.js +75 -0
- package/lib/config-store.js +2 -1
- package/lib/deploy/features/index.js +3 -0
- package/lib/deploy/features/slate.js +123 -0
- package/lib/endpoints/index.js +8 -1
- package/lib/endpoints/lib/env.js +2 -1
- package/lib/endpoints/lib/slate.js +91 -0
- package/lib/fn-utils/lib/common.js +1 -1
- package/lib/init/features/appsail/index.js +1 -1
- package/lib/init/features/index.js +15 -2
- package/lib/init/features/project.js +1 -1
- package/lib/init/features/slate/index.js +313 -0
- package/lib/internal/api.js +1 -1
- package/lib/internal/command.js +9 -5
- package/lib/option-filter.js +8 -2
- package/lib/port-resolver.js +7 -0
- package/lib/prompt/index.js +22 -6
- package/lib/prompt/types/file-path.js +10 -7
- package/lib/serve/features/index.js +8 -1
- package/lib/serve/features/slate.js +47 -0
- package/lib/serve/index.js +19 -0
- package/lib/serve/server/index.js +61 -1
- package/lib/serve/server/lib/appsail/index.js +1 -1
- package/lib/serve/server/lib/master/index.js +25 -21
- package/lib/serve/server/lib/master/slate.js +45 -0
- package/lib/serve/server/lib/master/utils.js +2 -2
- package/lib/serve/server/lib/slate/index.js +115 -0
- package/lib/serve/server/lib/slate/static-server.js +193 -0
- package/lib/slate-utils.js +212 -0
- package/lib/util_modules/config/index.js +3 -1
- package/lib/util_modules/config/lib/slate.js +94 -0
- package/lib/util_modules/constants/lib/dc-type.js +8 -0
- package/lib/util_modules/constants/lib/default.js +4 -0
- package/lib/util_modules/constants/lib/file-names.js +7 -1
- package/lib/util_modules/constants/lib/folder-names.js +1 -0
- package/lib/util_modules/constants/lib/scopes.js +3 -1
- package/lib/util_modules/context-help.js +2 -2
- package/lib/util_modules/fs/lib/async.js +14 -3
- package/lib/util_modules/fs/lib/sync.js +6 -1
- package/lib/util_modules/parser/toml.js +20 -5
- package/package.json +2 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[SLULK-1]
|
|
2
|
+
context = '''No app linked to the Catalyst Slate service.'''
|
|
3
|
+
aid = '''Please link your existing slate app by running the command ${arg[0]}.'''
|
|
4
|
+
link = ''
|
|
5
|
+
|
|
6
|
+
[SLULK-2]
|
|
7
|
+
context = '''No slate app linked with the given name.'''
|
|
8
|
+
aid = '''Please check the available slate apps by running the command ${arg[0]} without any options.'''
|
|
9
|
+
link = ''
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[SERVE-SLATE-1]
|
|
2
|
+
context = '''The given app is not configured with catalyst project.'''
|
|
3
|
+
aid = '''Please run the command ${arg[1]} to link your app with catalyst project.'''
|
|
4
|
+
link = ''
|
|
5
|
+
|
|
6
|
+
[SERVE-SLATE-2]
|
|
7
|
+
context = '''Not able to start the server using the given development command ${arg[1]}.'''
|
|
8
|
+
aid = '''Please provide a valid development command'''
|
|
9
|
+
link = ''
|
|
10
|
+
|
|
11
|
+
[SERVE-SLATE-3]
|
|
12
|
+
context = '''Error when installing the dependencies.'''
|
|
13
|
+
aid = '''Please install the necessary packages before running the command ${arg[1]}'''
|
|
14
|
+
link = ''
|
package/lib/archiver.js
CHANGED
|
@@ -55,25 +55,34 @@ class Archiver {
|
|
|
55
55
|
this.jszip = (0, jszip_1.loadAsync)(content, { createFolders });
|
|
56
56
|
return this;
|
|
57
57
|
}
|
|
58
|
-
_writeFolder(folder, to, recursive = false,
|
|
58
|
+
_writeFolder(folder, to, recursive = false, ignoreLevel = 1) {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
return this._writeAllFile(folder.filter((_relPath, file) => !file.dir), to, recursive,
|
|
60
|
+
return this._writeAllFile(folder.filter((_relPath, file) => !file.dir), to, recursive, ignoreLevel);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
_writeAllFile(files, to, recursive = false,
|
|
63
|
+
_writeAllFile(files, to, recursive = false, ignoreLevel = 0) {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
65
|
while (files.length > 0) {
|
|
66
66
|
const limit = files.length < Archiver.maxWriteLimit ? files.length : Archiver.maxWriteLimit;
|
|
67
67
|
yield Promise.all(files.splice(0, limit).map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const
|
|
68
|
+
const findIgnoreIndex = () => {
|
|
69
|
+
let index = 0, level = ignoreLevel;
|
|
70
|
+
while (level > 0) {
|
|
71
|
+
index = file.name.indexOf('/', index + 1);
|
|
72
|
+
level--;
|
|
73
|
+
}
|
|
74
|
+
return index;
|
|
75
|
+
};
|
|
76
|
+
const filePath = (0, path_1.join)(to, (0, path_1.dirname)(ignoreLevel !== 0
|
|
77
|
+
? file.name.substring(findIgnoreIndex() + 1)
|
|
78
|
+
: file.name));
|
|
69
79
|
yield fs_1.ASYNC.ensureDir(filePath);
|
|
70
80
|
if (file.name.endsWith('.zip') && recursive) {
|
|
71
81
|
const zipContent = yield file.async('nodebuffer');
|
|
72
82
|
return new Archiver()
|
|
73
83
|
.load(zipContent)
|
|
74
84
|
.extract((0, path_1.join)(filePath, (0, path_1.basename)(file.name).replace('.zip', '')), '/', {
|
|
75
|
-
recursive
|
|
76
|
-
ignoreInitial
|
|
85
|
+
recursive
|
|
77
86
|
})
|
|
78
87
|
.finalize();
|
|
79
88
|
}
|
|
@@ -127,7 +136,7 @@ class Archiver {
|
|
|
127
136
|
return fileObjArr[0].async('string');
|
|
128
137
|
});
|
|
129
138
|
}
|
|
130
|
-
extract(to, from = '/', { isFolder = true, recursive = false,
|
|
139
|
+
extract(to, from = '/', { isFolder = true, recursive = false, ignoreLevel = 0 } = {}) {
|
|
131
140
|
const extractPromise = this.jszip.then((zip) => __awaiter(this, void 0, void 0, function* () {
|
|
132
141
|
if (isFolder) {
|
|
133
142
|
let folder = null;
|
|
@@ -152,7 +161,7 @@ class Archiver {
|
|
|
152
161
|
exit: 2
|
|
153
162
|
});
|
|
154
163
|
}
|
|
155
|
-
yield this._writeFolder(folder, to, recursive,
|
|
164
|
+
yield this._writeFolder(folder, to, recursive, ignoreLevel);
|
|
156
165
|
return true;
|
|
157
166
|
}
|
|
158
167
|
const fromFileObj = [];
|
|
@@ -170,7 +179,7 @@ class Archiver {
|
|
|
170
179
|
exit: 2
|
|
171
180
|
});
|
|
172
181
|
}
|
|
173
|
-
yield this._writeAllFile(fromFileObj, to, recursive,
|
|
182
|
+
yield this._writeAllFile(fromFileObj, to, recursive, ignoreLevel);
|
|
174
183
|
return true;
|
|
175
184
|
}));
|
|
176
185
|
this.promiseArr.push(extractPromise);
|
|
@@ -34,10 +34,11 @@ const option_1 = require("../util_modules/option");
|
|
|
34
34
|
const crypto_1 = require("crypto");
|
|
35
35
|
exports.missingScopes = {
|
|
36
36
|
[constants_1.DC_TYPE.in.value]: getScopes(['zest', 'dataverse']),
|
|
37
|
-
[constants_1.DC_TYPE.eu.value]: getScopes(['zest', '
|
|
37
|
+
[constants_1.DC_TYPE.eu.value]: getScopes(['zest', 'dataverse']),
|
|
38
38
|
[constants_1.DC_TYPE.au.value]: getScopes(['zest', 'dataverse']),
|
|
39
39
|
[constants_1.DC_TYPE.ca.value]: getScopes(['zest', 'quick_ml', 'dataverse']),
|
|
40
|
-
[constants_1.DC_TYPE.sa.value]: getScopes(['zest', 'quick_ml', 'dataverse'])
|
|
40
|
+
[constants_1.DC_TYPE.sa.value]: getScopes(['zest', 'quick_ml', 'dataverse']),
|
|
41
|
+
[constants_1.DC_TYPE.jp.value]: getScopes(['zest', 'dataverse'])
|
|
41
42
|
};
|
|
42
43
|
function getScopes(keys) {
|
|
43
44
|
return Object.keys(constants_1.SCOPE).filter((scope) => keys.some((prefix) => scope.startsWith(prefix)));
|
package/lib/command_needs/rc.js
CHANGED
|
@@ -27,13 +27,26 @@ const project_2 = require("../util_modules/project");
|
|
|
27
27
|
const config_store_1 = __importDefault(require("../config-store"));
|
|
28
28
|
const dc_1 = require("../dc");
|
|
29
29
|
const env_1 = require("../util_modules/env");
|
|
30
|
-
|
|
30
|
+
const features_1 = require("../init/features");
|
|
31
|
+
exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck = true, skipProjectCheck = true, generateRc = false } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
32
|
const globOrgOpt = (0, option_1.getGlobalOptionValue)('org', null);
|
|
32
|
-
const orgOpt = globOrgOpt
|
|
33
|
+
const orgOpt = globOrgOpt
|
|
34
|
+
? globOrgOpt
|
|
35
|
+
: (0, env_1.getEnvVariable)('CATALYST_ORG', (0, env_1.getEnvVariable)('ZC_ORG_ID', null));
|
|
33
36
|
const globProjectOpt = (0, option_1.getGlobalOptionValue)('project', null);
|
|
34
37
|
const projectOpt = globProjectOpt
|
|
35
38
|
? globProjectOpt
|
|
36
|
-
: (0, env_1.getEnvVariable)('CATALYST_PROJECT_ID', (0, env_1.getEnvVariable)('CATALYST_PROJECT', null));
|
|
39
|
+
: (0, env_1.getEnvVariable)('CATALYST_PROJECT_ID', (0, env_1.getEnvVariable)('CATALYST_PROJECT', (0, env_1.getEnvVariable)('ZC_PROJECT_ID', null)));
|
|
40
|
+
if (env_1.isCI) {
|
|
41
|
+
if (orgOpt && projectOpt) {
|
|
42
|
+
runtime_store_1.default.set('project.id', projectOpt);
|
|
43
|
+
runtime_store_1.default.set('project.env.id', orgOpt + '');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
throw new error_1.default('Org and Project Id cannot be empty.', {
|
|
47
|
+
exit: 1
|
|
48
|
+
});
|
|
49
|
+
}
|
|
37
50
|
const orgApi = yield (0, endpoints_1.orgAPI)();
|
|
38
51
|
if (orgOpt !== null) {
|
|
39
52
|
const orgList = yield orgApi.getAllOrgs();
|
|
@@ -139,6 +152,30 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
|
|
|
139
152
|
const selectedOrg = orgAns.org || orgList[0];
|
|
140
153
|
runtime_store_1.default.set('project.env.id', selectedOrg.id);
|
|
141
154
|
}
|
|
155
|
+
if (!skipProjectCheck) {
|
|
156
|
+
const projectList = yield (yield (0, endpoints_1.projectAPI)()).getAllProjects();
|
|
157
|
+
const projectChoice = projectList.map((project) => prompt_1.default.choice(project.project_name + ' (' + project.id + ')', {
|
|
158
|
+
value: project,
|
|
159
|
+
short: project.project_name
|
|
160
|
+
}));
|
|
161
|
+
const projectAns = yield prompt_1.default.ask(prompt_1.default.question('project', 'Select a Catalyst Project to continue: ', {
|
|
162
|
+
type: 'list',
|
|
163
|
+
choices: js_1.JS.reverse(projectChoice),
|
|
164
|
+
when: projectChoice.length > 0
|
|
165
|
+
}));
|
|
166
|
+
const selectedProject = projectAns.project || projectList[0];
|
|
167
|
+
runtime_store_1.default.set('project.id', selectedProject.id);
|
|
168
|
+
}
|
|
169
|
+
if (generateRc) {
|
|
170
|
+
(0, logger_1.warning)('Not in Catalyst app directory!!!');
|
|
171
|
+
const stagedAns = yield prompt_1.default.ask(prompt_1.default.question('consent', 'Do you wish to initialize the catalyst project in this directory?', {
|
|
172
|
+
type: 'confirm',
|
|
173
|
+
defaultAns: true
|
|
174
|
+
}));
|
|
175
|
+
if (stagedAns.consent) {
|
|
176
|
+
yield (0, features_1.project)();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
142
179
|
if (optional || ignoreRC) {
|
|
143
180
|
return;
|
|
144
181
|
}
|
|
@@ -36,11 +36,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
const utils_1 = require("../../deploy/features/appsail/utils");
|
|
39
|
+
const slate_1 = require("../../deploy/features/slate");
|
|
39
40
|
const command_1 = __importDefault(require("../../internal/command"));
|
|
40
41
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
41
42
|
const constants_1 = require("../../util_modules/constants");
|
|
42
43
|
const logger_1 = require("../../util_modules/logger");
|
|
43
44
|
const appsail_1 = __importDefault(require("./appsail"));
|
|
45
|
+
const slate_2 = __importDefault(require("./slate"));
|
|
44
46
|
exports.default = new command_1.default('deploy')
|
|
45
47
|
.description('Deploy the Catalyst project and project resources to the Catalyst development environment from the local directory')
|
|
46
48
|
.option('--only <targets>', 'only deploy specified, comma-separated targets (e.g. "functions,client,appsail").' +
|
|
@@ -51,7 +53,7 @@ exports.default = new command_1.default('deploy')
|
|
|
51
53
|
.needs('auth', [constants_1.SCOPE.functions, constants_1.SCOPE.webapp, constants_1.SCOPE.appsail_update])
|
|
52
54
|
.needs('config')
|
|
53
55
|
.needs('rc', { optional: true })
|
|
54
|
-
.addSubCommand(appsail_1.default)
|
|
56
|
+
.addSubCommand(appsail_1.default, slate_2.default)
|
|
55
57
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
58
|
const optionFilter = yield Promise.resolve().then(() => __importStar(require('../../option-filter')));
|
|
57
59
|
optionFilter.filterTargets();
|
|
@@ -74,6 +76,9 @@ exports.default = new command_1.default('deploy')
|
|
|
74
76
|
(0, logger_1.labeled)(deploytarget, 'URL => ' + runtime_store_1.default.get('payload.client.url')).MESSAGE();
|
|
75
77
|
(0, logger_1.info)();
|
|
76
78
|
break;
|
|
79
|
+
case 'slate':
|
|
80
|
+
(0, slate_1.slateLogger)();
|
|
81
|
+
break;
|
|
77
82
|
case 'apig':
|
|
78
83
|
(0, logger_1.labeled)(deploytarget, 'deploy scheduled successfully').SUCCESS();
|
|
79
84
|
(0, logger_1.info)();
|
|
@@ -0,0 +1,58 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const slate_1 = require("../../deploy/features/slate");
|
|
39
|
+
const command_1 = __importDefault(require("../../internal/command"));
|
|
40
|
+
const logger_1 = require("../../util_modules/logger");
|
|
41
|
+
exports.default = new command_1.default('slate')
|
|
42
|
+
.description('Deploy your Catalyst Slate service to Catalyst Development environment')
|
|
43
|
+
.option('-m <msg>', 'Please provide the description for your app deployment.')
|
|
44
|
+
.option('--production', 'Deploy the slate app to production environment.')
|
|
45
|
+
.needs('auth')
|
|
46
|
+
.needs('config', { optional: true })
|
|
47
|
+
.needs('rc', { optional: true })
|
|
48
|
+
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
yield (yield Promise.resolve().then(() => __importStar(require('../../deploy')))).default('slate');
|
|
50
|
+
(0, logger_1.info)();
|
|
51
|
+
const deployTargets = (0, slate_1.slateLogger)();
|
|
52
|
+
if (deployTargets.length === 0) {
|
|
53
|
+
(0, logger_1.error)('Slate Deploy failed');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
(0, logger_1.success)('Catalyst Slate Deploy completed successfully');
|
|
57
|
+
}
|
|
58
|
+
}));
|
package/lib/commands/index.js
CHANGED
|
@@ -77,6 +77,9 @@ exports.default = (client) => {
|
|
|
77
77
|
loadCommand('functions:shell'),
|
|
78
78
|
loadCommand('functions:config'),
|
|
79
79
|
loadCommand('appsail:add'),
|
|
80
|
+
loadCommand('slate:link'),
|
|
81
|
+
loadCommand('slate:create'),
|
|
82
|
+
loadCommand('slate:unlink'),
|
|
80
83
|
loadCommand('codelib:install'),
|
|
81
84
|
loadCommand('event:generate'),
|
|
82
85
|
loadCommand('event:generate:integ'),
|
package/lib/commands/init.js
CHANGED
|
@@ -41,7 +41,6 @@ const command_1 = __importDefault(require("../internal/command"));
|
|
|
41
41
|
const prompt_1 = __importDefault(require("../prompt"));
|
|
42
42
|
const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
43
43
|
const constants_1 = require("../util_modules/constants");
|
|
44
|
-
const env_1 = require("../util_modules/env");
|
|
45
44
|
const fs_1 = require("../util_modules/fs");
|
|
46
45
|
const js_1 = require("../util_modules/js");
|
|
47
46
|
const logger_1 = require("../util_modules/logger");
|
|
@@ -90,15 +89,6 @@ exports.default = new command_1.default('init [feature]')
|
|
|
90
89
|
(0, ansi_colors_1.bold)(runtime_store_1.default.get('project.root')) +
|
|
91
90
|
'\n' +
|
|
92
91
|
warningText);
|
|
93
|
-
const windownConfirmation = env_1.isWindows
|
|
94
|
-
? yield prompt_1.default.ask(prompt_1.default.question('confirmation', 'Are you ready to proceed?', {
|
|
95
|
-
type: 'confirm'
|
|
96
|
-
}))
|
|
97
|
-
: { confirmation: true };
|
|
98
|
-
if (!windownConfirmation.confirmation) {
|
|
99
|
-
(0, logger_1.message)('Aborted by user.');
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
92
|
if (feature !== 'project') {
|
|
103
93
|
try {
|
|
104
94
|
yield (0, features_1.project)();
|
|
@@ -125,6 +115,10 @@ exports.default = new command_1.default('init [feature]')
|
|
|
125
115
|
prompt_1.default.choice('AppSail: Configure and deploy AppSail services', {
|
|
126
116
|
value: 'appsail',
|
|
127
117
|
short: 'AppSail'
|
|
118
|
+
}),
|
|
119
|
+
prompt_1.default.choice('Slate: Configure and deploy slate apps', {
|
|
120
|
+
value: 'slate',
|
|
121
|
+
short: 'Slate'
|
|
128
122
|
})
|
|
129
123
|
],
|
|
130
124
|
when: !runtime_store_1.default.get('payload.project.import', false) &&
|
|
@@ -0,0 +1,59 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
39
|
+
const command_1 = __importDefault(require("../../internal/command"));
|
|
40
|
+
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
41
|
+
const constants_1 = require("../../util_modules/constants");
|
|
42
|
+
const logger_1 = require("../../util_modules/logger");
|
|
43
|
+
exports.default = new command_1.default('slate:create')
|
|
44
|
+
.description('Configure a new slate service in catalyst')
|
|
45
|
+
.option('--name <app_name>', 'Please provide name for your slate')
|
|
46
|
+
.option('--framework <framework_name>', 'Specify framework name for your slate')
|
|
47
|
+
.option('--template <template_url>', 'Provide template url for your slate')
|
|
48
|
+
.option('--default', 'Set default app configurations')
|
|
49
|
+
.needs('auth')
|
|
50
|
+
.needs('config', { optional: true })
|
|
51
|
+
.needs('rc', { optional: true, generateRc: true })
|
|
52
|
+
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const config = runtime_store_1.default.get('config');
|
|
54
|
+
yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).slate();
|
|
55
|
+
yield config.save();
|
|
56
|
+
(0, logger_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.config) + ' file has been successfully updated with slate details.');
|
|
57
|
+
(0, logger_1.info)();
|
|
58
|
+
(0, logger_1.success)('Slate created successfully');
|
|
59
|
+
}));
|
|
@@ -0,0 +1,59 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
39
|
+
const command_1 = __importDefault(require("../../internal/command"));
|
|
40
|
+
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
41
|
+
const constants_1 = require("../../util_modules/constants");
|
|
42
|
+
const logger_1 = require("../../util_modules/logger");
|
|
43
|
+
exports.default = new command_1.default('slate:link')
|
|
44
|
+
.description('Configure your existing app in slate service')
|
|
45
|
+
.option('--name <app_name>', 'Please provide name for your slate')
|
|
46
|
+
.option('--framework <framework_name>', 'Specify frame work name for your slate')
|
|
47
|
+
.option('--template <template_url>', 'Provide template url for your slate')
|
|
48
|
+
.option('--default', 'Set default app configurations')
|
|
49
|
+
.needs('auth')
|
|
50
|
+
.needs('config', { optional: true })
|
|
51
|
+
.needs('rc', { optional: true, generateRc: true })
|
|
52
|
+
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const config = runtime_store_1.default.get('config');
|
|
54
|
+
yield (yield Promise.resolve().then(() => __importStar(require('../../init/features')))).slate(true);
|
|
55
|
+
yield config.save();
|
|
56
|
+
(0, logger_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.config) + ' file has been successfully updated with slate details.');
|
|
57
|
+
(0, logger_1.info)();
|
|
58
|
+
(0, logger_1.success)('Slate linked successfully');
|
|
59
|
+
}));
|
|
@@ -0,0 +1,75 @@
|
|
|
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 ansi_colors_1 = require("ansi-colors");
|
|
16
|
+
const command_1 = __importDefault(require("../../internal/command"));
|
|
17
|
+
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
18
|
+
const constants_1 = require("../../util_modules/constants");
|
|
19
|
+
const logger_1 = require("../../util_modules/logger");
|
|
20
|
+
const option_1 = require("../../util_modules/option");
|
|
21
|
+
const prompt_1 = __importDefault(require("../../prompt"));
|
|
22
|
+
const config_1 = require("../../util_modules/config");
|
|
23
|
+
const fs_1 = require("../../util_modules/fs");
|
|
24
|
+
const error_1 = __importDefault(require("../../error"));
|
|
25
|
+
const path_1 = require("path");
|
|
26
|
+
exports.default = new command_1.default('slate:unlink')
|
|
27
|
+
.description('Unlink your existing slate app')
|
|
28
|
+
.option('--name <app_name>', 'Please provide name for your slate app')
|
|
29
|
+
.needs('auth')
|
|
30
|
+
.needs('config')
|
|
31
|
+
.needs('rc')
|
|
32
|
+
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const config = runtime_store_1.default.get('config');
|
|
34
|
+
let appName = (0, option_1.getOptionValue)('name', false);
|
|
35
|
+
const slateServices = config_1.slateConfig.raw();
|
|
36
|
+
if ((slateServices === null || slateServices === void 0 ? void 0 : slateServices.length) === 0 || !slateServices) {
|
|
37
|
+
throw new error_1.default('No slates found.', {
|
|
38
|
+
exit: 1,
|
|
39
|
+
errorId: 'SLULK-1',
|
|
40
|
+
arg: [(0, ansi_colors_1.bold)('catalyst slate:link')]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (!appName) {
|
|
44
|
+
const { name } = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please select the slate app you want to delete', {
|
|
45
|
+
type: 'list',
|
|
46
|
+
choices: slateServices
|
|
47
|
+
}));
|
|
48
|
+
appName = name;
|
|
49
|
+
}
|
|
50
|
+
const slateDetails = slateServices.find((slate) => slate.name === appName);
|
|
51
|
+
if (!slateDetails) {
|
|
52
|
+
throw new error_1.default(`No slates match the given name ${appName}.`, {
|
|
53
|
+
exit: 1,
|
|
54
|
+
errorId: 'SLULK-2',
|
|
55
|
+
arg: [(0, ansi_colors_1.bold)('catalyst slate:unlink')]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const { removeSource } = yield prompt_1.default.ask(prompt_1.default.question('removeSource', `Do you want to delete the source?`, {
|
|
59
|
+
type: 'confirm',
|
|
60
|
+
default: false
|
|
61
|
+
}));
|
|
62
|
+
yield fs_1.ASYNC.deleteDir((0, path_1.join)(slateDetails.source, constants_1.FILENAME.cli_config));
|
|
63
|
+
if (removeSource) {
|
|
64
|
+
yield fs_1.ASYNC.deleteDir(slateDetails.source);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
yield fs_1.ASYNC.deleteDir((0, path_1.join)(slateDetails.source, '.catalyst'));
|
|
68
|
+
}
|
|
69
|
+
config.unset('slate');
|
|
70
|
+
config.set('slate', slateServices.filter((slateCon) => slateCon.name !== appName));
|
|
71
|
+
yield config.save();
|
|
72
|
+
(0, logger_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.config) + ' file has been updated.');
|
|
73
|
+
(0, logger_1.info)();
|
|
74
|
+
(0, logger_1.success)('Slate unlinked successfully');
|
|
75
|
+
}));
|
package/lib/config-store.js
CHANGED
|
@@ -6,4 +6,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const conf_1 = __importDefault(require("conf"));
|
|
7
7
|
const runtime_store_1 = __importDefault(require("./runtime-store"));
|
|
8
8
|
const name = runtime_store_1.default.get('context.cli.package.name');
|
|
9
|
-
|
|
9
|
+
const path = process.env['X_ZC_CREDENTIAL_PATH'];
|
|
10
|
+
exports.default = new conf_1.default({ configName: name, projectName: name, cwd: path });
|
|
@@ -39,6 +39,9 @@ exports.default = {
|
|
|
39
39
|
client: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
return (yield Promise.resolve().then(() => __importStar(require('./client')))).default();
|
|
41
41
|
}),
|
|
42
|
+
slate: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
return (yield Promise.resolve().then(() => __importStar(require('./slate')))).default();
|
|
44
|
+
}),
|
|
42
45
|
apig: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
46
|
return (yield Promise.resolve().then(() => __importStar(require('./apig')))).default();
|
|
44
47
|
}),
|