esa-cli 0.0.2-beta.10 โ 0.0.2-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/dist/commands/commit/index.js +34 -24
- package/dist/commands/deploy/helper.js +10 -26
- package/dist/commands/deploy/index.js +49 -60
- package/dist/commands/deployments/delete.js +1 -16
- package/dist/commands/deployments/index.js +1 -1
- package/dist/commands/deployments/list.js +8 -15
- package/dist/commands/dev/ew2/cacheService.js +33 -0
- package/dist/commands/dev/ew2/devEntry.js +2 -1
- package/dist/commands/dev/ew2/devPack.js +5 -3
- package/dist/commands/dev/ew2/kvService.js +27 -0
- package/dist/commands/dev/ew2/mock/cache.js +99 -15
- package/dist/commands/dev/ew2/mock/kv.js +142 -21
- package/dist/commands/dev/ew2/server.js +150 -18
- package/dist/commands/dev/index.js +2 -3
- package/dist/commands/domain/add.js +1 -1
- package/dist/commands/domain/delete.js +4 -4
- package/dist/commands/domain/index.js +1 -1
- package/dist/commands/domain/list.js +3 -3
- package/dist/commands/init/helper.js +28 -4
- package/dist/commands/init/index.js +78 -14
- package/dist/commands/login/index.js +49 -3
- package/dist/commands/logout.js +1 -1
- package/dist/commands/route/add.js +50 -52
- package/dist/commands/route/delete.js +29 -23
- package/dist/commands/route/helper.js +124 -0
- package/dist/commands/route/index.js +1 -1
- package/dist/commands/route/list.js +53 -14
- package/dist/commands/routine/index.js +1 -1
- package/dist/commands/routine/list.js +4 -5
- package/dist/commands/site/index.js +1 -1
- package/dist/commands/utils.js +5 -5
- package/dist/docs/Commands_en.md +27 -13
- package/dist/docs/Commands_zh_CN.md +14 -0
- package/dist/docs/Dev_en.md +0 -0
- package/dist/docs/Dev_zh_CN.md +0 -0
- package/dist/i18n/locales.json +102 -10
- package/dist/index.js +6 -1
- package/dist/libs/api.js +32 -9
- package/dist/libs/apiService.js +88 -78
- package/dist/libs/interface.js +0 -1
- package/dist/utils/checkIsRoutineCreated.js +0 -16
- package/package.json +3 -4
|
@@ -9,15 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { getProjectConfig, readEdgeRoutineFile } from '../../utils/fileUtils/index.js';
|
|
11
11
|
import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
|
|
12
|
-
import { displaySelectSpec } from '../deploy/index.js';
|
|
13
12
|
import { descriptionInput } from '../../components/descriptionInput.js';
|
|
14
13
|
import { ApiService } from '../../libs/apiService.js';
|
|
15
14
|
import prodBuild from './prodBuild.js';
|
|
16
15
|
import logger from '../../libs/logger.js';
|
|
17
16
|
import t from '../../i18n/index.js';
|
|
17
|
+
import { exit } from 'process';
|
|
18
18
|
const commit = {
|
|
19
19
|
command: 'commit [entry]',
|
|
20
|
-
describe:
|
|
20
|
+
describe: `๐ฆ ${t('commit_describe').d('Commit your code, save as a new version')}`,
|
|
21
21
|
builder: (yargs) => {
|
|
22
22
|
return yargs
|
|
23
23
|
.option('minify', {
|
|
@@ -25,6 +25,11 @@ const commit = {
|
|
|
25
25
|
describe: t('commit_option_minify').d('Minify code before committing'),
|
|
26
26
|
type: 'boolean',
|
|
27
27
|
default: false
|
|
28
|
+
})
|
|
29
|
+
.option('description', {
|
|
30
|
+
alias: 'd',
|
|
31
|
+
describe: t('commit_option_description').d('Description for the routine/version (skip interactive input)'),
|
|
32
|
+
type: 'string'
|
|
28
33
|
})
|
|
29
34
|
.positional('entry', {
|
|
30
35
|
describe: t('dev_entry_describe').d('Entry file of the Routine'),
|
|
@@ -33,13 +38,13 @@ const commit = {
|
|
|
33
38
|
});
|
|
34
39
|
},
|
|
35
40
|
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
handleCommit(argv);
|
|
41
|
+
yield handleCommit(argv);
|
|
42
|
+
exit();
|
|
37
43
|
})
|
|
38
44
|
};
|
|
39
45
|
export default commit;
|
|
40
46
|
export function handleCommit(argv) {
|
|
41
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
var _a, _b, _c;
|
|
43
48
|
if (!checkDirectory())
|
|
44
49
|
return;
|
|
45
50
|
const projectConfig = getProjectConfig();
|
|
@@ -52,39 +57,44 @@ export function handleCommit(argv) {
|
|
|
52
57
|
const server = yield ApiService.getInstance();
|
|
53
58
|
const req = { Name: projectConfig.name };
|
|
54
59
|
const response = yield server.getRoutine(req, false);
|
|
55
|
-
let specName = (_a = response === null || response === void 0 ? void 0 : response.data.Envs[0].SpecName) !== null && _a !== void 0 ? _a : '50ms';
|
|
56
60
|
let action = 'Creating';
|
|
57
61
|
let description;
|
|
58
62
|
if (!response) {
|
|
59
63
|
logger.log(`๐
${t('commit_er_not_exist').d('No routine found, creating a new one')}`);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
}, []);
|
|
67
|
-
specName = yield displaySelectSpec(specList);
|
|
64
|
+
if (argv.description) {
|
|
65
|
+
description = argv.description;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
description = yield descriptionInput(`๐๏ธ ${t('commit_er_description').d('Enter a description for the routine')}:`, false);
|
|
69
|
+
}
|
|
68
70
|
}
|
|
69
71
|
else {
|
|
70
72
|
logger.log(`๐ ${t('commit_er_exist').d('Routine exists, updating the code')}`);
|
|
71
|
-
|
|
73
|
+
if (argv.description) {
|
|
74
|
+
description = argv.description;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
description = yield descriptionInput(`๐๏ธ ${t('commit_version_description').d('Enter a description for the version')}:`, false);
|
|
78
|
+
}
|
|
72
79
|
action = 'Updating';
|
|
73
80
|
}
|
|
74
81
|
const code = readEdgeRoutineFile() || '';
|
|
75
|
-
|
|
82
|
+
if (action === 'Creating') {
|
|
83
|
+
const edgeRoutineProps = {
|
|
84
|
+
name: projectConfig.name,
|
|
85
|
+
code,
|
|
86
|
+
description: ''
|
|
87
|
+
};
|
|
88
|
+
yield createEdgeRoutine(edgeRoutineProps);
|
|
89
|
+
}
|
|
90
|
+
const versionProps = {
|
|
76
91
|
name: projectConfig.name,
|
|
77
92
|
code,
|
|
78
|
-
description
|
|
79
|
-
specName
|
|
93
|
+
description: description
|
|
80
94
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
else {
|
|
85
|
-
if (!(yield uploadEdgeRoutineCode(edgeRoutine)))
|
|
86
|
-
return;
|
|
87
|
-
yield releaseOfficialVersion(edgeRoutine);
|
|
95
|
+
const uploadResult = yield uploadEdgeRoutineCode(versionProps);
|
|
96
|
+
if (uploadResult) {
|
|
97
|
+
yield releaseOfficialVersion(versionProps);
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
catch (error) {
|
|
@@ -13,7 +13,6 @@ import { PublishType } from '../../libs/interface.js';
|
|
|
13
13
|
import { ApiService } from '../../libs/apiService.js';
|
|
14
14
|
import { descriptionInput } from '../../components/descriptionInput.js';
|
|
15
15
|
import { readEdgeRoutineFile } from '../../utils/fileUtils/index.js';
|
|
16
|
-
import { displaySelectSpec } from './index.js';
|
|
17
16
|
import { createEdgeRoutine, releaseOfficialVersion, uploadEdgeRoutineCode } from '../commit/index.js';
|
|
18
17
|
import logger from '../../libs/logger.js';
|
|
19
18
|
import t from '../../i18n/index.js';
|
|
@@ -33,11 +32,14 @@ export function yesNoPromptAndExecute(message, execute) {
|
|
|
33
32
|
}
|
|
34
33
|
export function promptSelectVersion(versionList) {
|
|
35
34
|
const items = versionList
|
|
36
|
-
.filter((version) => version.
|
|
37
|
-
.map((version, index) =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
.filter((version) => version.codeVersion !== 'unstable')
|
|
36
|
+
.map((version, index) => {
|
|
37
|
+
var _a;
|
|
38
|
+
return ({
|
|
39
|
+
label: (_a = version.codeVersion) !== null && _a !== void 0 ? _a : '',
|
|
40
|
+
value: String(index)
|
|
41
|
+
});
|
|
42
|
+
});
|
|
41
43
|
return new Promise((resolve) => {
|
|
42
44
|
const handleSelection = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
43
45
|
resolve(item.label);
|
|
@@ -52,8 +54,7 @@ export function displaySelectDeployType() {
|
|
|
52
54
|
{
|
|
53
55
|
label: t('deploy_env_production').d('Production'),
|
|
54
56
|
value: PublishType.Production
|
|
55
|
-
}
|
|
56
|
-
{ label: t('deploy_env_canary').d('Canary'), value: PublishType.Canary }
|
|
57
|
+
}
|
|
57
58
|
];
|
|
58
59
|
return new Promise((resolve) => {
|
|
59
60
|
const handleSelection = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -64,7 +65,6 @@ export function displaySelectDeployType() {
|
|
|
64
65
|
}
|
|
65
66
|
export function createAndDeployVersion(projectConfig_1) {
|
|
66
67
|
return __awaiter(this, arguments, void 0, function* (projectConfig, createUnstable = false, customEntry) {
|
|
67
|
-
var _a, _b, _c, _d;
|
|
68
68
|
try {
|
|
69
69
|
const server = yield ApiService.getInstance();
|
|
70
70
|
const description = yield descriptionInput(createUnstable
|
|
@@ -72,26 +72,10 @@ export function createAndDeployVersion(projectConfig_1) {
|
|
|
72
72
|
: `๐๏ธ ${t('deploy_description_version').d('Enter the description of the code version')}:`, false);
|
|
73
73
|
yield prodBuild(false, customEntry);
|
|
74
74
|
const code = readEdgeRoutineFile();
|
|
75
|
-
const specList = ((_b = (_a = (yield server.ListRoutineOptionalSpecs())) === null || _a === void 0 ? void 0 : _a.data.Specs) !== null && _b !== void 0 ? _b : []).reduce((acc, item) => {
|
|
76
|
-
if (item.IsAvailable) {
|
|
77
|
-
acc.push(item.SpecName);
|
|
78
|
-
}
|
|
79
|
-
return acc;
|
|
80
|
-
}, []);
|
|
81
|
-
let specName;
|
|
82
|
-
if (createUnstable) {
|
|
83
|
-
specName = yield displaySelectSpec(specList);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
const req = { Name: (_c = projectConfig.name) !== null && _c !== void 0 ? _c : '' };
|
|
87
|
-
const response = yield server.getRoutine(req);
|
|
88
|
-
specName = (_d = response === null || response === void 0 ? void 0 : response.data.Envs[0].SpecName) !== null && _d !== void 0 ? _d : '50ms';
|
|
89
|
-
}
|
|
90
75
|
const edgeRoutine = {
|
|
91
76
|
name: projectConfig.name,
|
|
92
77
|
code: code || '',
|
|
93
|
-
description: description
|
|
94
|
-
specName: specName
|
|
78
|
+
description: description
|
|
95
79
|
};
|
|
96
80
|
if (createUnstable) {
|
|
97
81
|
return yield createEdgeRoutine(edgeRoutine);
|
|
@@ -9,12 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import chalk from 'chalk';
|
|
11
11
|
import { getProjectConfig, readEdgeRoutineFile } from '../../utils/fileUtils/index.js';
|
|
12
|
-
import SelectItems from '../../components/selectInput.js';
|
|
13
12
|
import { Environment, PublishType } from '../../libs/interface.js';
|
|
14
13
|
import logger from '../../libs/logger.js';
|
|
15
14
|
import { checkDirectory, checkIsLoginSuccess, getRoutineVersionList } from '../utils.js';
|
|
16
|
-
import { displayMultiSelectTable } from '../../components/mutiSelectTable.js';
|
|
17
|
-
import { Base64 } from 'js-base64';
|
|
18
15
|
import { ApiService } from '../../libs/apiService.js';
|
|
19
16
|
import { createAndDeployVersion, displaySelectDeployType, promptSelectVersion, yesNoPromptAndExecute } from './helper.js';
|
|
20
17
|
import t from '../../i18n/index.js';
|
|
@@ -34,12 +31,25 @@ const deploy = {
|
|
|
34
31
|
})
|
|
35
32
|
.option('quick', {
|
|
36
33
|
alias: 'q',
|
|
34
|
+
describe: t('deploy_quick_describe').d('Quick deploy the routine to production environment'),
|
|
37
35
|
type: 'boolean'
|
|
36
|
+
})
|
|
37
|
+
.option('version', {
|
|
38
|
+
alias: 'v',
|
|
39
|
+
describe: t('deploy_option_version').d('Version to deploy (skip interactive selection)'),
|
|
40
|
+
type: 'string'
|
|
41
|
+
})
|
|
42
|
+
.option('environment', {
|
|
43
|
+
alias: 'e',
|
|
44
|
+
describe: t('deploy_option_environment').d('Environment to deploy to: staging or production (skip interactive selection)'),
|
|
45
|
+
type: 'string',
|
|
46
|
+
choices: ['staging', 'production']
|
|
38
47
|
});
|
|
39
48
|
},
|
|
40
49
|
describe: `๐ ${t('deploy_describe').d('Deploy your project')}`,
|
|
41
50
|
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
handleDeploy(argv);
|
|
51
|
+
yield handleDeploy(argv);
|
|
52
|
+
exit();
|
|
43
53
|
})
|
|
44
54
|
};
|
|
45
55
|
export default deploy;
|
|
@@ -59,13 +69,13 @@ export function quickDeploy(entry, projectConfig) {
|
|
|
59
69
|
}
|
|
60
70
|
else {
|
|
61
71
|
logger.error(t('quick_deploy_failed').d('Quick deploy failed'));
|
|
62
|
-
|
|
72
|
+
throw Error(t('quick_deploy_failed').d('Quick deploy failed'));
|
|
63
73
|
}
|
|
64
74
|
});
|
|
65
75
|
}
|
|
66
76
|
export function handleDeploy(argv) {
|
|
67
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
var _a, _b, _c, _d
|
|
78
|
+
var _a, _b, _c, _d;
|
|
69
79
|
if (!checkDirectory()) {
|
|
70
80
|
return;
|
|
71
81
|
}
|
|
@@ -80,10 +90,10 @@ export function handleDeploy(argv) {
|
|
|
80
90
|
yield checkRoutineExist(projectConfig.name, entry);
|
|
81
91
|
const req = { Name: projectConfig.name };
|
|
82
92
|
const routineDetail = yield server.getRoutine(req, false);
|
|
83
|
-
const versionList = (
|
|
93
|
+
const versionList = yield getRoutineVersionList(projectConfig.name);
|
|
84
94
|
const customEntry = argv.entry;
|
|
85
|
-
const stagingVersion = (
|
|
86
|
-
const productionVersion = (
|
|
95
|
+
const stagingVersion = (_b = (_a = routineDetail === null || routineDetail === void 0 ? void 0 : routineDetail.data) === null || _a === void 0 ? void 0 : _a.Envs[1]) === null || _b === void 0 ? void 0 : _b.CodeVersion;
|
|
96
|
+
const productionVersion = (_d = (_c = routineDetail === null || routineDetail === void 0 ? void 0 : routineDetail.data) === null || _c === void 0 ? void 0 : _c.Envs[0]) === null || _d === void 0 ? void 0 : _d.CodeVersion;
|
|
87
97
|
if (argv.quick) {
|
|
88
98
|
yield quickDeploy(customEntry, projectConfig);
|
|
89
99
|
exit(0);
|
|
@@ -94,27 +104,33 @@ export function handleDeploy(argv) {
|
|
|
94
104
|
}
|
|
95
105
|
else {
|
|
96
106
|
yield displayVersionList(versionList, stagingVersion, productionVersion);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
let selectedVersion;
|
|
108
|
+
let selectedType;
|
|
109
|
+
// Check if version and environment are provided via command line arguments
|
|
110
|
+
if (argv.version && argv.environment) {
|
|
111
|
+
// Validate version exists
|
|
112
|
+
const versionExists = versionList.some((v) => v.codeVersion === argv.version);
|
|
113
|
+
if (!versionExists) {
|
|
114
|
+
logger.error(t('deploy_version_not_found').d(`Version '${argv.version}' not found`));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
selectedVersion = argv.version;
|
|
118
|
+
selectedType =
|
|
119
|
+
argv.environment === 'staging'
|
|
120
|
+
? PublishType.Staging
|
|
121
|
+
: PublishType.Production;
|
|
122
|
+
logger.log(chalk.bold(`${t('deploy_using_version').d('Using version')}: ${selectedVersion}`));
|
|
123
|
+
logger.log(chalk.bold(`${t('deploy_using_environment').d('Using environment')}: ${argv.environment}`));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
logger.log(chalk.bold(`${t('deploy_version_select').d('Select the version you want to publish')}:`));
|
|
127
|
+
selectedVersion = yield promptSelectVersion(versionList);
|
|
128
|
+
selectedType = yield displaySelectDeployType();
|
|
129
|
+
}
|
|
100
130
|
yield deploySelectedCodeVersion(projectConfig.name, selectedType, selectedVersion);
|
|
101
131
|
}
|
|
102
132
|
});
|
|
103
133
|
}
|
|
104
|
-
export function displaySelectSpec(specList) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
logger.log(`๐ ${t('deploy_spec_select').d('Please select the spec of the routine you want to create')}`);
|
|
107
|
-
const selectItems = specList.map((spec) => {
|
|
108
|
-
return { label: spec, value: spec };
|
|
109
|
-
});
|
|
110
|
-
return new Promise((resolve) => {
|
|
111
|
-
const handleSelection = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
resolve(item.value);
|
|
113
|
-
});
|
|
114
|
-
SelectItems({ items: selectItems, handleSelect: handleSelection });
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
134
|
function handleNoVersionsFound(projectConfig, customEntry) {
|
|
119
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
136
|
logger.log(`๐ ${t('deploy_first_time').d("This is first time to deploy. Let's create a version first!")}`);
|
|
@@ -134,20 +150,6 @@ function promptAndDeployVersion(projectConfig) {
|
|
|
134
150
|
yield deploySelectedCodeVersion(projectConfig.name, selectedType, selectedVersion);
|
|
135
151
|
});
|
|
136
152
|
}
|
|
137
|
-
const specialAreaTransfer = (canaryAreaSelectList) => {
|
|
138
|
-
return canaryAreaSelectList.map((item) => {
|
|
139
|
-
if (item.label === 'HongKong') {
|
|
140
|
-
return { label: 'HongKong(China)' };
|
|
141
|
-
}
|
|
142
|
-
if (item.label === 'Macau') {
|
|
143
|
-
return { label: 'Macau(China)' };
|
|
144
|
-
}
|
|
145
|
-
if (item.label === 'Taiwan') {
|
|
146
|
-
return { label: 'Taiwan(China)' };
|
|
147
|
-
}
|
|
148
|
-
return { label: item.label };
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
153
|
export function handleOnlyUnstableVersionFound(projectConfig, customEntry) {
|
|
152
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
155
|
const created = yield yesNoPromptAndExecute(`๐ ${t('deploy_create_formal_version_ques').d('Do you want to create a formal version to deploy on production environment?')}`, () => createAndDeployVersion(projectConfig));
|
|
@@ -158,7 +160,6 @@ export function handleOnlyUnstableVersionFound(projectConfig, customEntry) {
|
|
|
158
160
|
}
|
|
159
161
|
export function deploySelectedCodeVersion(name, selectedType, version) {
|
|
160
162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
var _a;
|
|
162
163
|
const server = yield ApiService.getInstance();
|
|
163
164
|
const param = {
|
|
164
165
|
Name: name,
|
|
@@ -166,20 +167,7 @@ export function deploySelectedCodeVersion(name, selectedType, version) {
|
|
|
166
167
|
? Environment.Staging
|
|
167
168
|
: Environment.Production
|
|
168
169
|
};
|
|
169
|
-
|
|
170
|
-
const res = yield server.listRoutineCanaryAreas();
|
|
171
|
-
const canaryList = (_a = res === null || res === void 0 ? void 0 : res.CanaryAreas) !== null && _a !== void 0 ? _a : [];
|
|
172
|
-
logger.log(`๐ ${t('deploy_select_canary').d('Please select the canary area(s) you want to deploy to')}`);
|
|
173
|
-
const canaryAreaSelectList = canaryList.map((area) => {
|
|
174
|
-
return { label: area };
|
|
175
|
-
});
|
|
176
|
-
const selectedCanaryList = yield displayMultiSelectTable(specialAreaTransfer(canaryAreaSelectList));
|
|
177
|
-
param.CanaryAreaList = selectedCanaryList;
|
|
178
|
-
param.CanaryCodeVersion = version;
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
param.CodeVersion = version;
|
|
182
|
-
}
|
|
170
|
+
param.CodeVersion = version;
|
|
183
171
|
try {
|
|
184
172
|
const res = yield server.publishRoutineCodeVersion(param);
|
|
185
173
|
if (res) {
|
|
@@ -194,20 +182,21 @@ export function deploySelectedCodeVersion(name, selectedType, version) {
|
|
|
194
182
|
}
|
|
195
183
|
export function displayVersionList(versionList_1) {
|
|
196
184
|
return __awaiter(this, arguments, void 0, function* (versionList, stagingVersion = 'unstable', productionVersion = 'unstable') {
|
|
185
|
+
var _a;
|
|
197
186
|
logger.log(`${chalk.bgYellow('Active')} ${t('deploy_env_staging').d('Staging')}`);
|
|
198
187
|
logger.log(`${chalk.bgGreen('Active')} ${t('deploy_env_production').d('Production')}`);
|
|
199
188
|
const data = [];
|
|
200
189
|
for (let i = 0; i < versionList.length; i++) {
|
|
201
190
|
const version = versionList[i];
|
|
202
|
-
const createTime = moment(version.
|
|
191
|
+
const createTime = moment(version.createTime).format('YYYY/MM/DD HH:mm:ss');
|
|
203
192
|
const tags = [
|
|
204
|
-
version.
|
|
205
|
-
version.
|
|
193
|
+
version.codeVersion === stagingVersion ? chalk.bgYellow('Active') : '',
|
|
194
|
+
version.codeVersion === productionVersion ? chalk.bgGreen('Active') : ''
|
|
206
195
|
];
|
|
207
196
|
data.push([
|
|
208
|
-
`${version.
|
|
197
|
+
`${version.codeVersion} ${tags.join(' ')}`,
|
|
209
198
|
createTime,
|
|
210
|
-
|
|
199
|
+
(_a = version.codeDescription) !== null && _a !== void 0 ? _a : ''
|
|
211
200
|
]);
|
|
212
201
|
}
|
|
213
202
|
logger.table([
|
|
@@ -13,7 +13,6 @@ import { ApiService } from '../../libs/apiService.js';
|
|
|
13
13
|
import t from '../../i18n/index.js';
|
|
14
14
|
import logger from '../../libs/logger.js';
|
|
15
15
|
import { displayMultiSelectTable } from '../../components/mutiSelectTable.js';
|
|
16
|
-
import { Base64 } from 'js-base64';
|
|
17
16
|
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
18
17
|
const deploymentsDelete = {
|
|
19
18
|
command: 'delete [deploymentId..]',
|
|
@@ -49,27 +48,13 @@ export function handleDeleteDeployments(argv) {
|
|
|
49
48
|
yield validRoutine(projectConfig.name);
|
|
50
49
|
const server = yield ApiService.getInstance();
|
|
51
50
|
let versions = argv.deploymentId;
|
|
52
|
-
// const req: DeleteRoutineCodeVersionReq = {
|
|
53
|
-
// Name: projectConfig.name,
|
|
54
|
-
// CodeVersion: version
|
|
55
|
-
// };
|
|
56
|
-
// const res = await server.deleteRoutineCodeVersion(req);
|
|
57
|
-
// if (res?.Status === 'OK') {
|
|
58
|
-
// logger.success(
|
|
59
|
-
// `${t('deployments_delete_success').d('Delete success')}: ${version}`
|
|
60
|
-
// );
|
|
61
|
-
// } else {
|
|
62
|
-
// logger.error(
|
|
63
|
-
// `๐
${t('deployments_delete_failed').d('Delete failed')}: ${version}`
|
|
64
|
-
// );
|
|
65
|
-
// }
|
|
66
51
|
const isInteractive = argv.i;
|
|
67
52
|
if (isInteractive) {
|
|
68
53
|
const versionList = yield getRoutineVersionList(projectConfig.name);
|
|
69
54
|
logger.log(t('delete_deployments_table_title').d(' Version ID Description'));
|
|
70
55
|
const selectList = versionList.map((item) => {
|
|
71
56
|
return {
|
|
72
|
-
label: item.
|
|
57
|
+
label: item.codeVersion + ' ' + item.codeDescription
|
|
73
58
|
};
|
|
74
59
|
});
|
|
75
60
|
versions = (yield displayMultiSelectTable(selectList, 1, 100)).map((item) => item.slice(0, item.indexOf(' ')));
|
|
@@ -4,7 +4,7 @@ import t from '../../i18n/index.js';
|
|
|
4
4
|
let yargsIns;
|
|
5
5
|
const deploymentsCommand = {
|
|
6
6
|
command: 'deployments [script]',
|
|
7
|
-
describe:
|
|
7
|
+
describe: `๐ ${t('deployments_describe').d('Manage your deployments')}`,
|
|
8
8
|
builder: (yargs) => {
|
|
9
9
|
yargsIns = yargs;
|
|
10
10
|
return yargs
|
|
@@ -52,21 +52,17 @@ export function handleListDeployments(argv) {
|
|
|
52
52
|
}
|
|
53
53
|
function displayListPrompt(routineDetail) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
var _a, _b
|
|
56
|
-
const isCanary = ((_a = routineDetail.data.Envs[0].CanaryAreaList) !== null && _a !== void 0 ? _a : []).length !== 0;
|
|
57
|
-
const canaryEnv = routineDetail.data.Envs[0];
|
|
55
|
+
var _a, _b;
|
|
58
56
|
const stagingEnv = routineDetail.data.Envs[1];
|
|
57
|
+
const prodEnv = routineDetail.data.Envs[0];
|
|
59
58
|
const server = yield ApiService.getInstance();
|
|
60
59
|
const res = yield server.getRoutineStagingEnvIp();
|
|
61
|
-
const stagingIpList = (
|
|
60
|
+
const stagingIpList = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.IPV4) !== null && _b !== void 0 ? _b : [];
|
|
62
61
|
const coloredStagingIpList = stagingIpList.map((ip) => {
|
|
63
62
|
return chalk.green(ip);
|
|
64
63
|
});
|
|
65
|
-
const showEnvTable = (version,
|
|
66
|
-
const data = [
|
|
67
|
-
{ Version: version },
|
|
68
|
-
{ Specification: spec }
|
|
69
|
-
];
|
|
64
|
+
const showEnvTable = (version, region) => {
|
|
65
|
+
const data = [{ Version: version }];
|
|
70
66
|
if (region) {
|
|
71
67
|
data.push({ Region: region });
|
|
72
68
|
}
|
|
@@ -76,13 +72,10 @@ function displayListPrompt(routineDetail) {
|
|
|
76
72
|
if (stagingIpList.length > 0) {
|
|
77
73
|
logger.log(`Staging IP: ${coloredStagingIpList.join(', ')}`);
|
|
78
74
|
}
|
|
79
|
-
showEnvTable(stagingEnv.CodeVersion
|
|
75
|
+
showEnvTable(stagingEnv.CodeVersion);
|
|
80
76
|
logger.block();
|
|
81
|
-
logger.log(`${chalk.bold(`${t('deploy_env_production').d('Production')} ${
|
|
82
|
-
showEnvTable(
|
|
83
|
-
logger.block();
|
|
84
|
-
logger.log(`${chalk.bold(`${t('deploy_env_canary').d('Canary')} ${isCanary ? chalk.green('โ') : ''}`)}`);
|
|
85
|
-
showEnvTable((_d = canaryEnv.CanaryCodeVersion) !== null && _d !== void 0 ? _d : '', canaryEnv.SpecName, (_e = canaryEnv.CanaryAreaList) === null || _e === void 0 ? void 0 : _e.join(', '));
|
|
77
|
+
logger.log(`${chalk.bold(`${t('deploy_env_production').d('Production')} ${chalk.green('โ')}`)}`);
|
|
78
|
+
showEnvTable(prodEnv.CodeVersion);
|
|
86
79
|
logger.log(`${t('show_default_url').d(`You can visit:`)} ${chalk.yellowBright(routineDetail.data.DefaultRelatedRecord)}`);
|
|
87
80
|
logger.info(routineDetail.data.DefaultRelatedRecord);
|
|
88
81
|
logger.block();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class CacheService {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.store = new Map();
|
|
4
|
+
this.maxQuota = 100 * 1024 * 1024;
|
|
5
|
+
}
|
|
6
|
+
put(key, serializedResponse) {
|
|
7
|
+
const expires = serializedResponse.ttl === 0
|
|
8
|
+
? Infinity
|
|
9
|
+
: Date.now() + serializedResponse.ttl * 1000;
|
|
10
|
+
this.store.set(key, {
|
|
11
|
+
serializedResponse,
|
|
12
|
+
expires: expires,
|
|
13
|
+
lastUsed: Date.now()
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
get(key) {
|
|
17
|
+
const entry = this.store.get(key);
|
|
18
|
+
if (!entry || Date.now() > entry.expires) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
entry.lastUsed = Date.now();
|
|
22
|
+
return entry;
|
|
23
|
+
}
|
|
24
|
+
delete(key) {
|
|
25
|
+
return this.deleteEntry(key);
|
|
26
|
+
}
|
|
27
|
+
deleteEntry(key) {
|
|
28
|
+
if (!this.store.has(key))
|
|
29
|
+
return false;
|
|
30
|
+
return this.store.delete(key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export default CacheService;
|
|
@@ -2,8 +2,9 @@ import worker from '$userPath';
|
|
|
2
2
|
import Cache from './mock/cache.js';
|
|
3
3
|
import mockKV from './mock/kv.js';
|
|
4
4
|
|
|
5
|
-
var mock_cache =
|
|
5
|
+
var mock_cache = new Cache($userPort);
|
|
6
6
|
globalThis.mockCache = mock_cache;
|
|
7
|
+
mockKV.port = $userPort;
|
|
7
8
|
globalThis.mockKV = mockKV;
|
|
8
9
|
|
|
9
10
|
export default worker;
|
|
@@ -61,7 +61,7 @@ conf_path = "${erConfPath}"
|
|
|
61
61
|
]);
|
|
62
62
|
};
|
|
63
63
|
// ็ๆๅ
ฅๅฃๆไปถ
|
|
64
|
-
const generateEntry = (id, projectEntry, userRoot) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
const generateEntry = (id, projectEntry, userRoot, port) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
65
|
const __dirname = getDirName(import.meta.url);
|
|
66
66
|
const devDir = path.resolve(userRoot, '.dev');
|
|
67
67
|
const devEntry = path.resolve(devDir, `devEntry-${id}.js`);
|
|
@@ -81,7 +81,9 @@ const generateEntry = (id, projectEntry, userRoot) => __awaiter(void 0, void 0,
|
|
|
81
81
|
const destPath = path.resolve(mockDevDir, file);
|
|
82
82
|
yield fs.promises.copyFile(srcPath, destPath);
|
|
83
83
|
}
|
|
84
|
-
return fs.promises.writeFile(devEntry, devEntryTempFile
|
|
84
|
+
return fs.promises.writeFile(devEntry, devEntryTempFile
|
|
85
|
+
.replace(/'\$userPath'/g, `'${projectEntry.replace(/\\/g, '/')}'`)
|
|
86
|
+
.replace(/\$userPort/g, `${port}`));
|
|
85
87
|
});
|
|
86
88
|
// ๅๆๅๅค
|
|
87
89
|
const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -92,7 +94,7 @@ const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(
|
|
|
92
94
|
// @ts-ignore
|
|
93
95
|
global.id = id;
|
|
94
96
|
// ็ๆๅ
ฅๅฃๆไปถ
|
|
95
|
-
yield generateEntry(id, entry, userRoot);
|
|
97
|
+
yield generateEntry(id, entry, userRoot, port);
|
|
96
98
|
// ็ๆ Ew2 ้
็ฝฎ
|
|
97
99
|
const ew2port = yield generateEw2Port();
|
|
98
100
|
yield writeEw2config(id, ew2port, userRoot);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class EdgeKV {
|
|
2
|
+
constructor() { }
|
|
3
|
+
get(key, namespace) {
|
|
4
|
+
const store = EdgeKV.store.get(namespace);
|
|
5
|
+
if (!store || !store.has(key)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
return store.get(key);
|
|
9
|
+
}
|
|
10
|
+
put(key, value, namespace) {
|
|
11
|
+
let store = EdgeKV.store.get(namespace);
|
|
12
|
+
if (!store) {
|
|
13
|
+
EdgeKV.store.set(namespace, new Map([[key, value]]));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
store.set(key, value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
delete(key, namespace) {
|
|
20
|
+
const store = EdgeKV.store.get(namespace);
|
|
21
|
+
if (!store)
|
|
22
|
+
return false;
|
|
23
|
+
return store.delete(key);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
EdgeKV.store = new Map();
|
|
27
|
+
export default EdgeKV;
|