esa-cli 0.0.2-beta.2 β 0.0.2-beta.20
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 +48 -115
- package/dist/commands/commit/prodBuild.js +2 -3
- package/dist/commands/common/constant.js +0 -19
- package/dist/commands/common/utils.js +416 -0
- package/dist/commands/config.js +1 -1
- package/dist/commands/deploy/helper.js +51 -72
- package/dist/commands/deploy/index.js +50 -188
- package/dist/commands/deployments/delete.js +32 -22
- package/dist/commands/deployments/index.js +2 -2
- package/dist/commands/deployments/list.js +22 -38
- package/dist/commands/dev/build.js +3 -3
- package/dist/commands/dev/doProcess.js +5 -5
- 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 +39 -43
- 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 +165 -29
- package/dist/commands/dev/index.js +17 -17
- package/dist/commands/dev/mockWorker/devPack.js +35 -24
- package/dist/commands/dev/mockWorker/server.js +7 -6
- package/dist/commands/domain/add.js +2 -2
- package/dist/commands/domain/delete.js +7 -7
- package/dist/commands/domain/index.js +2 -2
- package/dist/commands/domain/list.js +10 -10
- package/dist/commands/init/helper.js +759 -0
- package/dist/commands/init/index.js +88 -220
- package/dist/commands/init/snippets/nextjs/next.config.mjs +6 -0
- package/dist/commands/init/snippets/nextjs/next.config.ts +7 -0
- package/dist/commands/init/snippets/react-router/react-router.config.ts +7 -0
- package/dist/commands/init/template.jsonc +84 -0
- package/dist/commands/init/types.js +1 -0
- package/dist/commands/lang.js +2 -2
- package/dist/commands/login/index.js +74 -34
- package/dist/commands/logout.js +5 -5
- package/dist/commands/route/add.js +105 -49
- package/dist/commands/route/delete.js +33 -27
- package/dist/commands/route/helper.js +123 -0
- package/dist/commands/route/index.js +2 -2
- package/dist/commands/route/list.js +56 -17
- package/dist/commands/routine/delete.js +2 -2
- package/dist/commands/routine/index.js +2 -2
- package/dist/commands/routine/list.js +43 -37
- package/dist/commands/site/index.js +1 -1
- package/dist/commands/site/list.js +6 -7
- package/dist/commands/utils.js +59 -23
- package/dist/components/descriptionInput.js +1 -1
- package/dist/components/filterSelector.js +1 -1
- package/dist/components/mutiLevelSelect.js +43 -55
- package/dist/components/mutiSelectTable.js +1 -1
- package/dist/components/routeBuilder.js +68 -0
- package/dist/components/selectInput.js +2 -3
- package/dist/components/selectItem.js +1 -1
- package/dist/docs/Commands_en.md +142 -131
- package/dist/docs/Commands_zh_CN.md +139 -127
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/locales.json +435 -23
- package/dist/index.js +27 -20
- package/dist/libs/api.js +32 -9
- package/dist/libs/apiService.js +267 -88
- package/dist/libs/git/index.js +86 -9
- package/dist/libs/interface.js +0 -1
- package/dist/libs/logger.js +162 -10
- package/dist/libs/service.js +2 -2
- package/dist/libs/templates/index.js +3 -2
- package/dist/utils/checkAssetsExist.js +80 -0
- package/dist/utils/checkDevPort.js +3 -17
- package/dist/utils/checkEntryFileExist.js +10 -0
- package/dist/utils/checkIsRoutineCreated.js +28 -27
- package/dist/utils/checkVersion.js +119 -1
- package/dist/utils/command.js +149 -0
- package/dist/utils/compress.js +136 -0
- package/dist/utils/download.js +182 -0
- package/dist/utils/fileMd5.js +1 -1
- package/dist/utils/fileUtils/base.js +1 -1
- package/dist/utils/fileUtils/index.js +136 -44
- package/dist/utils/installDeno.js +8 -8
- package/dist/utils/installEw2.js +7 -7
- package/dist/utils/openInBrowser.js +1 -1
- package/dist/utils/prompt.js +97 -0
- package/package.json +19 -12
|
@@ -7,37 +7,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import moment from 'moment';
|
|
10
12
|
import SelectItems from '../../components/selectInput.js';
|
|
11
|
-
import
|
|
13
|
+
import t from '../../i18n/index.js';
|
|
12
14
|
import { PublishType } from '../../libs/interface.js';
|
|
13
|
-
import { ApiService } from '../../libs/apiService.js';
|
|
14
|
-
import { descriptionInput } from '../../components/descriptionInput.js';
|
|
15
|
-
import { readEdgeRoutineFile } from '../../utils/fileUtils/index.js';
|
|
16
|
-
import { displaySelectSpec } from './index.js';
|
|
17
|
-
import { createEdgeRoutine, releaseOfficialVersion, uploadEdgeRoutineCode } from '../commit/index.js';
|
|
18
15
|
import logger from '../../libs/logger.js';
|
|
19
|
-
import
|
|
20
|
-
import prodBuild from '../commit/prodBuild.js';
|
|
16
|
+
import promptParameter from '../../utils/prompt.js';
|
|
21
17
|
export function yesNoPromptAndExecute(message, execute) {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const confirmed = (yield promptParameter({
|
|
20
|
+
type: 'confirm',
|
|
21
|
+
question: message,
|
|
22
|
+
label: 'Confirm',
|
|
23
|
+
defaultValue: true
|
|
24
|
+
}));
|
|
25
|
+
if (!confirmed)
|
|
26
|
+
return false;
|
|
27
|
+
return yield execute();
|
|
32
28
|
});
|
|
33
29
|
}
|
|
34
30
|
export function promptSelectVersion(versionList) {
|
|
35
31
|
const items = versionList
|
|
36
|
-
.filter((version) => version.
|
|
37
|
-
.map((version, index) =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
.filter((version) => version.codeVersion !== 'unstable')
|
|
33
|
+
.map((version, index) => {
|
|
34
|
+
var _a;
|
|
35
|
+
return ({
|
|
36
|
+
label: (_a = version.codeVersion) !== null && _a !== void 0 ? _a : '',
|
|
37
|
+
value: String(index)
|
|
38
|
+
});
|
|
39
|
+
});
|
|
41
40
|
return new Promise((resolve) => {
|
|
42
41
|
const handleSelection = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
43
42
|
resolve(item.label);
|
|
@@ -45,15 +44,14 @@ export function promptSelectVersion(versionList) {
|
|
|
45
44
|
SelectItems({ items, handleSelect: handleSelection });
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
|
-
export function
|
|
47
|
+
export function displaySelectDeployEnv() {
|
|
49
48
|
logger.log(`π ${t('deploy_env_select_description').d('Please select which environment you want to deploy')}`);
|
|
50
49
|
const selectItems = [
|
|
51
50
|
{ label: t('deploy_env_staging').d('Staging'), value: PublishType.Staging },
|
|
52
51
|
{
|
|
53
52
|
label: t('deploy_env_production').d('Production'),
|
|
54
53
|
value: PublishType.Production
|
|
55
|
-
}
|
|
56
|
-
{ label: t('deploy_env_canary').d('Canary'), value: PublishType.Canary }
|
|
54
|
+
}
|
|
57
55
|
];
|
|
58
56
|
return new Promise((resolve) => {
|
|
59
57
|
const handleSelection = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -62,52 +60,33 @@ export function displaySelectDeployType() {
|
|
|
62
60
|
SelectItems({ items: selectItems, handleSelect: handleSelection });
|
|
63
61
|
});
|
|
64
62
|
}
|
|
65
|
-
export function
|
|
66
|
-
return __awaiter(this,
|
|
67
|
-
var _a, _b, _c
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
const edgeRoutine = {
|
|
91
|
-
name: projectConfig.name,
|
|
92
|
-
code: code || '',
|
|
93
|
-
description: description,
|
|
94
|
-
specName: specName
|
|
95
|
-
};
|
|
96
|
-
if (createUnstable) {
|
|
97
|
-
return yield createEdgeRoutine(edgeRoutine);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const uploadResult = yield uploadEdgeRoutineCode(edgeRoutine);
|
|
101
|
-
if (!uploadResult) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
return yield releaseOfficialVersion(edgeRoutine);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
logger.error(`
|
|
109
|
-
${t('deploy_error').d('An error occurred during the creation or publishing process')}: ${error}`);
|
|
110
|
-
return false;
|
|
63
|
+
export function displayVersionList(allVersions, stagingVersions, productionVersions) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
var _a, _b, _c;
|
|
66
|
+
logger.log(`${chalk.bgYellow('Active')} ${t('deploy_env_staging').d('Staging')}`);
|
|
67
|
+
logger.log(`${chalk.bgGreen('Active')} ${t('deploy_env_production').d('Production')}`);
|
|
68
|
+
const data = [];
|
|
69
|
+
for (let i = 0; i < allVersions.length; i++) {
|
|
70
|
+
const version = allVersions[i];
|
|
71
|
+
const createTime = moment(version.createTime).format('YYYY/MM/DD HH:mm:ss');
|
|
72
|
+
const tags = [
|
|
73
|
+
stagingVersions.includes((_a = version.codeVersion) !== null && _a !== void 0 ? _a : '')
|
|
74
|
+
? chalk.bgYellow('Active')
|
|
75
|
+
: '',
|
|
76
|
+
productionVersions.includes((_b = version.codeVersion) !== null && _b !== void 0 ? _b : '')
|
|
77
|
+
? chalk.bgGreen('Active')
|
|
78
|
+
: ''
|
|
79
|
+
];
|
|
80
|
+
data.push([
|
|
81
|
+
`${version.codeVersion} ${tags.join(' ')}`,
|
|
82
|
+
createTime,
|
|
83
|
+
(_c = version.codeDescription) !== null && _c !== void 0 ? _c : ''
|
|
84
|
+
]);
|
|
111
85
|
}
|
|
86
|
+
logger.table([
|
|
87
|
+
t('deploy_table_header_version').d('Version'),
|
|
88
|
+
t('deploy_table_header_created').d('Created'),
|
|
89
|
+
t('deploy_table_header_description').d('Description')
|
|
90
|
+
], data);
|
|
112
91
|
});
|
|
113
92
|
}
|
|
@@ -7,22 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import chalk from 'chalk';
|
|
11
|
-
import { getProjectConfig, readEdgeRoutineFile } from '../../utils/fileUtils/index.js';
|
|
12
|
-
import SelectItems from '../../components/selectInput.js';
|
|
13
|
-
import { Environment, PublishType } from '../../libs/interface.js';
|
|
14
|
-
import logger from '../../libs/logger.js';
|
|
15
|
-
import { checkDirectory, checkIsLoginSuccess, getRoutineVersionList } from '../utils.js';
|
|
16
|
-
import { displayMultiSelectTable } from '../../components/mutiSelectTable.js';
|
|
17
|
-
import { Base64 } from 'js-base64';
|
|
18
|
-
import { ApiService } from '../../libs/apiService.js';
|
|
19
|
-
import { createAndDeployVersion, displaySelectDeployType, promptSelectVersion, yesNoPromptAndExecute } from './helper.js';
|
|
20
|
-
import t from '../../i18n/index.js';
|
|
21
|
-
import prodBuild from '../commit/prodBuild.js';
|
|
22
10
|
import { exit } from 'process';
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
11
|
+
import { intro, outro } from '@clack/prompts';
|
|
12
|
+
import t from '../../i18n/index.js';
|
|
13
|
+
import { getRoot } from '../../utils/fileUtils/base.js';
|
|
14
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
15
|
+
import { commitAndDeployVersion, displayDeploySuccess } from '../common/utils.js';
|
|
26
16
|
const deploy = {
|
|
27
17
|
command: 'deploy [entry]',
|
|
28
18
|
builder: (yargs) => {
|
|
@@ -32,188 +22,60 @@ const deploy = {
|
|
|
32
22
|
type: 'string',
|
|
33
23
|
demandOption: false
|
|
34
24
|
})
|
|
35
|
-
.option('
|
|
36
|
-
alias: '
|
|
25
|
+
.option('version', {
|
|
26
|
+
alias: 'v',
|
|
27
|
+
describe: t('deploy_option_version').d('Version to deploy (skip interactive selection)'),
|
|
28
|
+
type: 'string'
|
|
29
|
+
})
|
|
30
|
+
.option('environment', {
|
|
31
|
+
alias: 'e',
|
|
32
|
+
describe: t('deploy_option_environment').d('Environment to deploy to: staging or production (skip interactive selection)'),
|
|
33
|
+
type: 'string',
|
|
34
|
+
choices: ['staging', 'production']
|
|
35
|
+
})
|
|
36
|
+
.option('name', {
|
|
37
|
+
alias: 'n',
|
|
38
|
+
describe: t('deploy_option_name').d('Name of the routine'),
|
|
39
|
+
type: 'string'
|
|
40
|
+
})
|
|
41
|
+
.option('assets', {
|
|
42
|
+
alias: 'a',
|
|
43
|
+
describe: t('deploy_option_assets').d('Deploy assets'),
|
|
44
|
+
type: 'string'
|
|
45
|
+
})
|
|
46
|
+
.option('description', {
|
|
47
|
+
alias: 'd',
|
|
48
|
+
describe: t('deploy_option_description').d('Description of the version'),
|
|
49
|
+
type: 'string'
|
|
50
|
+
})
|
|
51
|
+
.option('minify', {
|
|
52
|
+
alias: 'm',
|
|
53
|
+
describe: t('deploy_option_minify').d('Minify the code'),
|
|
37
54
|
type: 'boolean'
|
|
38
55
|
});
|
|
39
56
|
},
|
|
40
57
|
describe: `π ${t('deploy_describe').d('Deploy your project')}`,
|
|
41
58
|
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
handleDeploy(argv);
|
|
59
|
+
yield handleDeploy(argv);
|
|
60
|
+
exit();
|
|
43
61
|
})
|
|
44
62
|
};
|
|
45
|
-
export default deploy;
|
|
46
|
-
export function quickDeploy(entry, projectConfig) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const server = yield ApiService.getInstance();
|
|
49
|
-
const entryFile = path.resolve(entry !== null && entry !== void 0 ? entry : '', 'src/index.js');
|
|
50
|
-
yield prodBuild(false, entryFile, entry);
|
|
51
|
-
const code = readEdgeRoutineFile(entry) || '';
|
|
52
|
-
const res = yield server.quickDeployRoutine({
|
|
53
|
-
name: projectConfig.name,
|
|
54
|
-
code: code
|
|
55
|
-
});
|
|
56
|
-
if (res) {
|
|
57
|
-
logger.success(t('quick_deploy_success').d('Your code has been successfully deployed'));
|
|
58
|
-
logger.log(`π ${t('quick_deploy_success_guide').d('Run this command to add domains')}: ${chalk.green('esa domain add <DOMAIN>')}`);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
logger.error(t('quick_deploy_failed').d('Quick deploy failed'));
|
|
62
|
-
process.exit(0);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
63
|
export function handleDeploy(argv) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
var _a, _b, _c, _d, _e;
|
|
69
|
-
if (!checkDirectory()) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const projectConfig = getProjectConfig();
|
|
73
|
-
if (!projectConfig)
|
|
74
|
-
return logger.notInProject();
|
|
75
|
-
const isSuccess = yield checkIsLoginSuccess();
|
|
76
|
-
if (!isSuccess)
|
|
77
|
-
return;
|
|
78
|
-
const server = yield ApiService.getInstance();
|
|
79
|
-
const entry = argv.entry;
|
|
80
|
-
yield checkRoutineExist(projectConfig.name, entry);
|
|
81
|
-
const req = { Name: projectConfig.name };
|
|
82
|
-
const routineDetail = yield server.getRoutine(req, false);
|
|
83
|
-
const versionList = ((_a = routineDetail === null || routineDetail === void 0 ? void 0 : routineDetail.data) === null || _a === void 0 ? void 0 : _a.CodeVersions) || [];
|
|
84
|
-
const customEntry = argv.entry;
|
|
85
|
-
const stagingVersion = (_c = (_b = routineDetail === null || routineDetail === void 0 ? void 0 : routineDetail.data) === null || _b === void 0 ? void 0 : _b.Envs[1]) === null || _c === void 0 ? void 0 : _c.CodeVersion;
|
|
86
|
-
const productionVersion = (_e = (_d = routineDetail === null || routineDetail === void 0 ? void 0 : routineDetail.data) === null || _d === void 0 ? void 0 : _d.Envs[0]) === null || _e === void 0 ? void 0 : _e.CodeVersion;
|
|
87
|
-
if (argv.quick) {
|
|
88
|
-
yield quickDeploy(customEntry, projectConfig);
|
|
89
|
-
exit(0);
|
|
90
|
-
}
|
|
91
|
-
if (versionList.length === 0) {
|
|
92
|
-
logger.log(t('no_formal_version_found').d('No formal version found, you need to create a version first.'));
|
|
93
|
-
yield handleOnlyUnstableVersionFound(projectConfig, customEntry);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
yield displayVersionList(versionList, stagingVersion, productionVersion);
|
|
97
|
-
logger.log(chalk.bold(`${t('deploy_version_select').d('Select the version you want to publish')}:`));
|
|
98
|
-
const selectedVersion = yield promptSelectVersion(versionList);
|
|
99
|
-
const selectedType = yield displaySelectDeployType();
|
|
100
|
-
yield deploySelectedCodeVersion(projectConfig.name, selectedType, selectedVersion);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
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
|
-
function handleNoVersionsFound(projectConfig, customEntry) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
logger.log(`π ${t('deploy_first_time').d("This is first time to deploy. Let's create a version first!")}`);
|
|
121
|
-
const created = yield yesNoPromptAndExecute(`π ${t('deploy_create_formal_version_ques').d('Do you want to create an unstable version now?')}`, () => createAndDeployVersion(projectConfig, true));
|
|
122
|
-
if (created) {
|
|
123
|
-
yield handleOnlyUnstableVersionFound(projectConfig);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function promptAndDeployVersion(projectConfig) {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
const versionList = yield getRoutineVersionList(projectConfig.name);
|
|
130
|
-
yield displayVersionList(versionList);
|
|
131
|
-
logger.log(`π ${t('deploy_select_version').d("Select which version you'd like to deploy")}`);
|
|
132
|
-
const selectedVersion = yield promptSelectVersion(versionList);
|
|
133
|
-
const selectedType = yield displaySelectDeployType();
|
|
134
|
-
yield deploySelectedCodeVersion(projectConfig.name, selectedType, selectedVersion);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
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
|
-
export function handleOnlyUnstableVersionFound(projectConfig, customEntry) {
|
|
152
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
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));
|
|
154
|
-
if (created) {
|
|
155
|
-
yield promptAndDeployVersion(projectConfig);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
export function deploySelectedCodeVersion(name, selectedType, version) {
|
|
160
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
65
|
var _a;
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
const selectedCanaryList = yield displayMultiSelectTable(specialAreaTransfer(canaryAreaSelectList));
|
|
177
|
-
param.CanaryAreaList = selectedCanaryList;
|
|
178
|
-
param.CanaryCodeVersion = version;
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
param.CodeVersion = version;
|
|
182
|
-
}
|
|
183
|
-
try {
|
|
184
|
-
const res = yield server.publishRoutineCodeVersion(param);
|
|
185
|
-
if (res) {
|
|
186
|
-
logger.success(t('deploy_success').d('Your code has been successfully deployed'));
|
|
187
|
-
logger.log(`π ${t('deploy_success_guide').d('Run this command to add domains')}: ${chalk.green('esa domain add <DOMAIN>')}`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
catch (e) {
|
|
191
|
-
console.error(e);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
export function displayVersionList(versionList_1) {
|
|
196
|
-
return __awaiter(this, arguments, void 0, function* (versionList, stagingVersion = 'unstable', productionVersion = 'unstable') {
|
|
197
|
-
logger.log(`${chalk.bgYellow('Active')} ${t('deploy_env_staging').d('Staging')}`);
|
|
198
|
-
logger.log(`${chalk.bgGreen('Active')} ${t('deploy_env_production').d('Production')}`);
|
|
199
|
-
const data = [];
|
|
200
|
-
for (let i = 0; i < versionList.length; i++) {
|
|
201
|
-
const version = versionList[i];
|
|
202
|
-
const createTime = moment(version.CreateTime).format('YYYY/MM/DD HH:mm:ss');
|
|
203
|
-
const tags = [
|
|
204
|
-
version.CodeVersion === stagingVersion ? chalk.bgYellow('Active') : '',
|
|
205
|
-
version.CodeVersion === productionVersion ? chalk.bgGreen('Active') : ''
|
|
206
|
-
];
|
|
207
|
-
data.push([
|
|
208
|
-
`${version.CodeVersion} ${tags.join(' ')}`,
|
|
209
|
-
createTime,
|
|
210
|
-
Base64.decode(version.CodeDescription)
|
|
211
|
-
]);
|
|
212
|
-
}
|
|
213
|
-
logger.table([
|
|
214
|
-
t('deploy_table_header_version').d('Version'),
|
|
215
|
-
t('deploy_table_header_created').d('Created'),
|
|
216
|
-
t('deploy_table_header_description').d('Description')
|
|
217
|
-
], data, [30, 25, 15]);
|
|
66
|
+
const entry = argv.entry;
|
|
67
|
+
const assets = (_a = argv.assets) !== null && _a !== void 0 ? _a : undefined;
|
|
68
|
+
intro(`Deploy an application with ESA`);
|
|
69
|
+
const success = yield commitAndDeployVersion(argv.name || undefined, entry, assets, argv.description || '', getRoot(), argv.environment || 'all', argv.minify, argv.version);
|
|
70
|
+
outro(success ? 'Deploy finished' : 'Deploy failed');
|
|
71
|
+
if (success) {
|
|
72
|
+
const projectConfig = getProjectConfig(getRoot());
|
|
73
|
+
yield displayDeploySuccess(argv.name ||
|
|
74
|
+
(projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.name) ||
|
|
75
|
+
getRoot().split(/[\\/]/).pop() ||
|
|
76
|
+
'', true, true);
|
|
77
|
+
}
|
|
78
|
+
exit(success ? 0 : 1);
|
|
218
79
|
});
|
|
219
80
|
}
|
|
81
|
+
export default deploy;
|
|
@@ -7,14 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import { ApiService } from '../../libs/apiService.js';
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import { displayMultiSelectTable } from '../../components/mutiSelectTable.js';
|
|
13
12
|
import t from '../../i18n/index.js';
|
|
13
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
14
14
|
import logger from '../../libs/logger.js';
|
|
15
|
-
import { displayMultiSelectTable } from '../../components/mutiSelectTable.js';
|
|
16
|
-
import { Base64 } from 'js-base64';
|
|
17
15
|
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
16
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
17
|
+
import { checkDirectory, checkIsLoginSuccess, getRoutineCodeVersions } from '../utils.js';
|
|
18
18
|
const deploymentsDelete = {
|
|
19
19
|
command: 'delete [deploymentId..]',
|
|
20
20
|
describe: `π ${t('deployments_delete_describe').d('Delete one or more deployment versions')}`,
|
|
@@ -49,29 +49,39 @@ export function handleDeleteDeployments(argv) {
|
|
|
49
49
|
yield validRoutine(projectConfig.name);
|
|
50
50
|
const server = yield ApiService.getInstance();
|
|
51
51
|
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
52
|
const isInteractive = argv.i;
|
|
67
53
|
if (isInteractive) {
|
|
68
|
-
const
|
|
54
|
+
const { allVersions, stagingVersions, productionVersions } = yield getRoutineCodeVersions(projectConfig.name);
|
|
55
|
+
// Show information about versions being deployed
|
|
56
|
+
if (stagingVersions.length > 0 || productionVersions.length > 0) {
|
|
57
|
+
logger.log(chalk.yellow('β οΈ Currently deploying versions:'));
|
|
58
|
+
if (stagingVersions.length > 0) {
|
|
59
|
+
logger.log(chalk.yellow(` Staging: ${stagingVersions.join(',')}`));
|
|
60
|
+
}
|
|
61
|
+
if (productionVersions.length > 0) {
|
|
62
|
+
logger.log(chalk.yellow(` Production: ${productionVersions.join(',')}`));
|
|
63
|
+
}
|
|
64
|
+
logger.log('');
|
|
65
|
+
}
|
|
69
66
|
logger.log(t('delete_deployments_table_title').d(' Version ID Description'));
|
|
70
|
-
|
|
67
|
+
// Filter out versions being deployed
|
|
68
|
+
const selectList = allVersions
|
|
69
|
+
.filter((item) => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
if (stagingVersions.length === 0 && productionVersions.length === 0)
|
|
72
|
+
return true;
|
|
73
|
+
return (!stagingVersions.includes((_a = item.codeVersion) !== null && _a !== void 0 ? _a : '') &&
|
|
74
|
+
!productionVersions.includes((_b = item.codeVersion) !== null && _b !== void 0 ? _b : ''));
|
|
75
|
+
})
|
|
76
|
+
.map((item) => {
|
|
71
77
|
return {
|
|
72
|
-
label: item.
|
|
78
|
+
label: item.codeVersion + ' ' + item.codeDescription
|
|
73
79
|
};
|
|
74
80
|
});
|
|
81
|
+
if (selectList.length === 0) {
|
|
82
|
+
logger.error('No deletable versions found. All versions are currently deployed.');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
75
85
|
versions = (yield displayMultiSelectTable(selectList, 1, 100)).map((item) => item.slice(0, item.indexOf(' ')));
|
|
76
86
|
}
|
|
77
87
|
for (let i = 0; i < versions.length; i++) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import deploymentsList from './list.js';
|
|
2
|
-
import deploymentsDelete from './delete.js';
|
|
3
1
|
import t from '../../i18n/index.js';
|
|
2
|
+
import deploymentsDelete from './delete.js';
|
|
3
|
+
import deploymentsList from './list.js';
|
|
4
4
|
let yargsIns;
|
|
5
5
|
const deploymentsCommand = {
|
|
6
6
|
command: 'deployments [script]',
|
|
@@ -7,28 +7,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { displayVersionList } from '../deploy/index.js';
|
|
11
|
-
import { checkDirectory, checkIsLoginSuccess, getRoutineVersionList } from '../utils.js';
|
|
12
|
-
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
13
10
|
import chalk from 'chalk';
|
|
14
|
-
import { ApiService } from '../../libs/apiService.js';
|
|
15
11
|
import t from '../../i18n/index.js';
|
|
12
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
16
13
|
import logger from '../../libs/logger.js';
|
|
17
14
|
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
15
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
16
|
+
import { displayVersionList } from '../deploy/helper.js';
|
|
17
|
+
import { checkIsLoginSuccess, getRoutineCodeVersions } from '../utils.js';
|
|
18
18
|
const deploymentsList = {
|
|
19
19
|
command: 'list',
|
|
20
20
|
describe: `π ${t('deployments_list_describe').d('List all deployments')}`,
|
|
21
|
-
handler: (
|
|
22
|
-
handleListDeployments(
|
|
21
|
+
handler: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
handleListDeployments();
|
|
23
23
|
})
|
|
24
24
|
};
|
|
25
25
|
export default deploymentsList;
|
|
26
|
-
export function handleListDeployments(
|
|
26
|
+
export function handleListDeployments() {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
var _a, _b, _c, _d;
|
|
29
|
-
if (!checkDirectory()) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
28
|
const projectConfig = getProjectConfig();
|
|
33
29
|
if (!projectConfig)
|
|
34
30
|
return logger.notInProject();
|
|
@@ -37,52 +33,40 @@ export function handleListDeployments(argv) {
|
|
|
37
33
|
return;
|
|
38
34
|
yield validRoutine(projectConfig.name);
|
|
39
35
|
const server = yield ApiService.getInstance();
|
|
40
|
-
const versionList = yield getRoutineVersionList(projectConfig.name);
|
|
41
36
|
const req = { Name: projectConfig.name };
|
|
42
37
|
const routineDetail = yield server.getRoutine(req);
|
|
43
38
|
if (!routineDetail)
|
|
44
39
|
return;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
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;
|
|
49
|
-
yield displayListPrompt(routineDetail);
|
|
50
|
-
yield displayVersionList(versionList, stagingVersion, productionVersion);
|
|
40
|
+
const { allVersions, stagingVersions, productionVersions } = yield getRoutineCodeVersions(projectConfig.name);
|
|
41
|
+
yield displayDeployingVersions(routineDetail, stagingVersions, productionVersions);
|
|
42
|
+
yield displayVersionList(allVersions, stagingVersions, productionVersions);
|
|
51
43
|
});
|
|
52
44
|
}
|
|
53
|
-
function
|
|
45
|
+
function displayDeployingVersions(routineDetail, stagingVersions, productionVersions) {
|
|
54
46
|
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];
|
|
58
|
-
const stagingEnv = routineDetail.data.Envs[1];
|
|
47
|
+
var _a, _b;
|
|
59
48
|
const server = yield ApiService.getInstance();
|
|
60
49
|
const res = yield server.getRoutineStagingEnvIp();
|
|
61
|
-
const stagingIpList = (
|
|
50
|
+
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
51
|
const coloredStagingIpList = stagingIpList.map((ip) => {
|
|
63
52
|
return chalk.green(ip);
|
|
64
53
|
});
|
|
65
|
-
const showEnvTable = (version
|
|
66
|
-
const data = [
|
|
67
|
-
{ Version: version },
|
|
68
|
-
{ Specification: spec }
|
|
69
|
-
];
|
|
70
|
-
if (region) {
|
|
71
|
-
data.push({ Region: region });
|
|
72
|
-
}
|
|
54
|
+
const showEnvTable = (version) => {
|
|
55
|
+
const data = [{ Version: version }];
|
|
73
56
|
logger.table([], data);
|
|
74
57
|
};
|
|
75
58
|
logger.log(chalk.bold(t('deploy_env_staging').d('Staging')));
|
|
76
59
|
if (stagingIpList.length > 0) {
|
|
77
60
|
logger.log(`Staging IP: ${coloredStagingIpList.join(', ')}`);
|
|
78
61
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
showEnvTable(canaryEnv.CodeVersion, canaryEnv.SpecName);
|
|
62
|
+
if (stagingVersions.length > 0) {
|
|
63
|
+
showEnvTable(stagingVersions.join(','));
|
|
64
|
+
}
|
|
83
65
|
logger.block();
|
|
84
|
-
logger.log(`${chalk.bold(`${t('
|
|
85
|
-
|
|
66
|
+
logger.log(`${chalk.bold(`${t('deploy_env_production').d('Production')} ${chalk.green('β')}`)}`);
|
|
67
|
+
if (productionVersions.length > 0) {
|
|
68
|
+
showEnvTable(productionVersions.join(','));
|
|
69
|
+
}
|
|
86
70
|
logger.log(`${t('show_default_url').d(`You can visit:`)} ${chalk.yellowBright(routineDetail.data.DefaultRelatedRecord)}`);
|
|
87
71
|
logger.info(routineDetail.data.DefaultRelatedRecord);
|
|
88
72
|
logger.block();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import _generator from '@babel/generator';
|
|
4
|
+
import parser from '@babel/parser';
|
|
5
|
+
import _traverse from '@babel/traverse';
|
|
3
6
|
import esbuild from 'esbuild';
|
|
4
7
|
import { lessLoader } from 'esbuild-plugin-less';
|
|
5
8
|
import { getRoot } from '../../utils/fileUtils/base.js';
|
|
6
9
|
import { NODE_EXTERNALS } from '../common/constant.js';
|
|
7
|
-
import parser from '@babel/parser';
|
|
8
|
-
import _traverse from '@babel/traverse';
|
|
9
|
-
import _generator from '@babel/generator';
|
|
10
10
|
const replacements = { cache: 'mockCache', EdgeKV: 'mockKV' };
|
|
11
11
|
const traverse = _traverse.default;
|
|
12
12
|
const generator = _generator.default;
|
|
@@ -7,14 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import React, { useEffect } from 'react';
|
|
11
|
-
import { Box, Text, useApp, useInput, render } from 'ink';
|
|
12
10
|
import chalk from 'chalk';
|
|
11
|
+
import { Box, Text, useApp, useInput, render } from 'ink';
|
|
12
|
+
import React, { useEffect } from 'react';
|
|
13
|
+
import t from '../../i18n/index.js';
|
|
13
14
|
import logger from '../../libs/logger.js';
|
|
14
|
-
import openInBrowser from '../../utils/openInBrowser.js';
|
|
15
|
-
import { getDevOpenBrowserUrl } from '../../utils/fileUtils/index.js';
|
|
16
15
|
import { checkOS, Platforms } from '../../utils/checkOS.js';
|
|
17
|
-
import
|
|
16
|
+
import { getDevOpenBrowserUrl } from '../../utils/fileUtils/index.js';
|
|
17
|
+
import openInBrowser from '../../utils/openInBrowser.js';
|
|
18
18
|
const InteractionBox = ({ worker }) => {
|
|
19
19
|
const { exit } = useApp();
|
|
20
20
|
const inspectLink = chalk.underline.blue('chrome://inspect/#devices');
|