esa-cli 1.0.4-beta.4 → 1.0.5
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/config.js +1 -13
- package/dist/commands/dev/build.js +11 -2
- package/dist/commands/init/helper.js +10 -10
- package/dist/commands/routine/index.js +2 -2
- package/dist/i18n/locales.json +1 -1
- package/dist/utils/compress.js +2 -2
- package/dist/utils/installEw2.js +3 -3
- package/package.json +8 -7
package/dist/commands/config.js
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import os from 'os';
|
|
3
2
|
import spawn from 'cross-spawn';
|
|
4
3
|
import t from '../i18n/index.js';
|
|
5
4
|
import logger from '../libs/logger.js';
|
|
6
5
|
import { projectConfigPath, cliConfigPath } from '../utils/fileUtils/index.js';
|
|
7
|
-
const getDefaultEditor = () => {
|
|
8
|
-
// Use environment variable if set
|
|
9
|
-
if (process.env.EDITOR) {
|
|
10
|
-
return process.env.EDITOR;
|
|
11
|
-
}
|
|
12
|
-
// Platform-specific default editors
|
|
13
|
-
if (os.platform() === 'win32') {
|
|
14
|
-
return 'notepad';
|
|
15
|
-
}
|
|
16
|
-
return 'vi';
|
|
17
|
-
};
|
|
18
6
|
const editConfigFile = (configPath) => {
|
|
19
|
-
const editor =
|
|
7
|
+
const editor = process.env.EDITOR || 'vi';
|
|
20
8
|
spawn(editor, [configPath], {
|
|
21
9
|
stdio: 'inherit'
|
|
22
10
|
});
|
|
@@ -21,9 +21,18 @@ const renameMock = {
|
|
|
21
21
|
});
|
|
22
22
|
traverse(ast, {
|
|
23
23
|
Identifier(path) {
|
|
24
|
+
var _a;
|
|
24
25
|
const name = path.node.name;
|
|
25
|
-
if (replacements.hasOwnProperty(name)) {
|
|
26
|
-
|
|
26
|
+
if (!replacements.hasOwnProperty(name)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (((_a = path.parentPath) === null || _a === void 0 ? void 0 : _a.type) === 'MemberExpression' &&
|
|
30
|
+
path.key === 'object' &&
|
|
31
|
+
path.node.name === 'cache') {
|
|
32
|
+
path.node.name = 'mockCache';
|
|
33
|
+
}
|
|
34
|
+
else if (path.node.name === 'EdgeKV') {
|
|
35
|
+
path.node.name = 'mockKV';
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
38
|
});
|
|
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { execSync } from 'child_process';
|
|
11
|
-
import os from 'os';
|
|
12
11
|
import path from 'path';
|
|
13
12
|
import { exit } from 'process';
|
|
14
13
|
import { confirm as clackConfirm, isCancel, log, outro } from '@clack/prompts';
|
|
@@ -112,8 +111,9 @@ export function checkAndUpdatePackage(packageName) {
|
|
|
112
111
|
}
|
|
113
112
|
catch (e) {
|
|
114
113
|
spinner.text = t('template_updating').d('Updating templates to latest...');
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
execSync(`rm -rf node_modules/${packageName}`, {
|
|
115
|
+
cwd: packageJsonPath
|
|
116
|
+
});
|
|
117
117
|
execSync(`npm install ${packageName}@latest`, {
|
|
118
118
|
cwd: packageJsonPath,
|
|
119
119
|
stdio: 'inherit'
|
|
@@ -143,9 +143,12 @@ export function checkAndUpdatePackage(packageName) {
|
|
|
143
143
|
});
|
|
144
144
|
if (!isCancel(isUpdate) && isUpdate) {
|
|
145
145
|
spinner.start(t('template_updating').d('Updating templates to latest...'));
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
execSync(`rm -rf node_modules/${packageName}`, {
|
|
147
|
+
cwd: packageJsonPath
|
|
148
|
+
});
|
|
149
|
+
execSync(`rm -rf package-lock.json`, {
|
|
150
|
+
cwd: packageJsonPath
|
|
151
|
+
});
|
|
149
152
|
execSync(`npm install ${packageName}@latest`, {
|
|
150
153
|
cwd: packageJsonPath,
|
|
151
154
|
stdio: 'inherit'
|
|
@@ -726,9 +729,6 @@ export function initializeProject(selectedTemplatePath, name) {
|
|
|
726
729
|
}
|
|
727
730
|
const targetPath = path.join(process.cwd(), name);
|
|
728
731
|
if (fs.existsSync(targetPath)) {
|
|
729
|
-
// Cross-platform delete command hint
|
|
730
|
-
const isWindows = os.platform() === 'win32';
|
|
731
|
-
const deleteCmd = isWindows ? `rmdir /s /q "${name}"` : `rm -rf "${name}"`;
|
|
732
732
|
logger.block();
|
|
733
733
|
logger.tree([
|
|
734
734
|
`${chalk.bgRed(' ERROR ')} ${chalk.bold.red(t('init_abort').d('Initialization aborted'))}`,
|
|
@@ -736,7 +736,7 @@ export function initializeProject(selectedTemplatePath, name) {
|
|
|
736
736
|
`${chalk.gray(t('path').d('Path:'))} ${chalk.cyan(targetPath)}`,
|
|
737
737
|
chalk.gray(t('try').d('Try one of the following:')),
|
|
738
738
|
`- ${chalk.white(t('try_diff_name').d('Choose a different project name'))}`,
|
|
739
|
-
`- ${chalk.white(t('try_remove').d('Remove the directory:'))} ${chalk.yellow(
|
|
739
|
+
`- ${chalk.white(t('try_remove').d('Remove the directory:'))} ${chalk.yellow(`rm -rf "${name}”`)}`,
|
|
740
740
|
`- ${chalk.white(t('try_another_dir').d('Run the command in another directory'))}`
|
|
741
741
|
]);
|
|
742
742
|
logger.block();
|
|
@@ -4,8 +4,8 @@ import routineList from './list.js';
|
|
|
4
4
|
let yargsIns;
|
|
5
5
|
const routineCommand = {
|
|
6
6
|
command: 'project [script]',
|
|
7
|
-
aliases: ['
|
|
8
|
-
describe: `🧭 ${t('routine_describe').d('Manage your
|
|
7
|
+
aliases: ['routine'],
|
|
8
|
+
describe: `🧭 ${t('routine_describe').d('Manage your project')}`,
|
|
9
9
|
builder: (yargs) => {
|
|
10
10
|
yargsIns = yargs;
|
|
11
11
|
return yargs
|
package/dist/i18n/locales.json
CHANGED
package/dist/utils/compress.js
CHANGED
|
@@ -47,8 +47,8 @@ const compress = (scriptEntry_1, assetsDir_1, ...args_1) => __awaiter(void 0, [s
|
|
|
47
47
|
'esa.jsonc (recommended) or esa.toml is not found and script entry or assets directory is not provided by command line',
|
|
48
48
|
'',
|
|
49
49
|
'See configuration guide:',
|
|
50
|
-
`- English: ${chalk.underline('https://github.com/aliyun/alibabacloud-esa-cli/blob/
|
|
51
|
-
`- 中文: ${chalk.underline('https://github.com/aliyun/alibabacloud-esa-cli/blob/
|
|
50
|
+
`- English: ${chalk.underline('https://github.com/aliyun/alibabacloud-esa-cli/blob/main/docs/Config_en.md')}`,
|
|
51
|
+
`- 中文: ${chalk.underline('https://github.com/aliyun/alibabacloud-esa-cli/blob/main/docs/Config_zh_CN.md')}`
|
|
52
52
|
].join('\n'));
|
|
53
53
|
exit(1);
|
|
54
54
|
}
|
package/dist/utils/installEw2.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { execSync } from 'child_process';
|
|
11
|
-
import
|
|
11
|
+
import http from 'http';
|
|
12
12
|
import os from 'os';
|
|
13
13
|
import path from 'path';
|
|
14
14
|
import util from 'util';
|
|
@@ -65,8 +65,8 @@ export function preCheckEw2() {
|
|
|
65
65
|
}
|
|
66
66
|
export function fetchRemoteManifest() {
|
|
67
67
|
return new Promise((resolve, reject) => {
|
|
68
|
-
|
|
69
|
-
.get('
|
|
68
|
+
http
|
|
69
|
+
.get('http://esa-runtime.myalicdn.com/ew2/manifest.json', (res) => {
|
|
70
70
|
let data = '';
|
|
71
71
|
res.on('data', (chunk) => (data += chunk));
|
|
72
72
|
res.on('end', () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esa-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A CLI for operating Alibaba Cloud ESA Functions and Pages.",
|
|
5
5
|
"main": "bin/enter.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "
|
|
18
|
+
"build": "rm -rf ./dist && rm -rf ./build && node ./genLocale.cjs && tsc && node ./copy.cjs",
|
|
19
19
|
"dev": "tsc --watch",
|
|
20
20
|
"eslint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
|
|
21
21
|
"prepare": "husky install",
|
|
22
|
+
"prepublishOnly": "npm run build",
|
|
22
23
|
"lint-staged": "lint-staged",
|
|
23
24
|
"test": "vitest --coverage",
|
|
24
25
|
"coverage": "vitest --coverage",
|
|
@@ -63,6 +64,9 @@
|
|
|
63
64
|
"jsdom": "^25.0.1",
|
|
64
65
|
"lint-staged": "^15.0.2",
|
|
65
66
|
"prettier": "^3.0.3",
|
|
67
|
+
"react": "^18.2.0",
|
|
68
|
+
"react-dom": "^18.2.0",
|
|
69
|
+
"rimraf": "^6.0.1",
|
|
66
70
|
"tsc-files": "^1.1.4",
|
|
67
71
|
"typescript": "^5.2.2",
|
|
68
72
|
"vitest": "^2.0.4"
|
|
@@ -82,7 +86,7 @@
|
|
|
82
86
|
"chokidar": "^3.5.3",
|
|
83
87
|
"cli-table3": "^0.6.5",
|
|
84
88
|
"cross-spawn": "^7.0.3",
|
|
85
|
-
"esa-template": "0.0.
|
|
89
|
+
"esa-template": "^0.0.9",
|
|
86
90
|
"esbuild": "^0.21.1",
|
|
87
91
|
"esbuild-plugin-less": "^1.3.8",
|
|
88
92
|
"form-data": "^4.0.0",
|
|
@@ -102,10 +106,7 @@
|
|
|
102
106
|
"portscanner": "^2.2.0",
|
|
103
107
|
"winston": "^3.11.0",
|
|
104
108
|
"winston-daily-rotate-file": "^5.0.0",
|
|
105
|
-
"yargs": "^17.7.2"
|
|
106
|
-
"react": "^18.2.0",
|
|
107
|
-
"react-dom": "^18.2.0",
|
|
108
|
-
"rimraf": "^6.0.1"
|
|
109
|
+
"yargs": "^17.7.2"
|
|
109
110
|
},
|
|
110
111
|
"lint-staged": {
|
|
111
112
|
"src/**/*.{ts,tsx,js,jsx}": [
|