esa-cli 1.0.5 → 1.0.7
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 +13 -1
- package/dist/commands/dev/index.js +0 -2
- package/dist/commands/init/helper.js +25 -10
- package/dist/commands/init/index.js +5 -0
- package/dist/commands/routine/index.js +2 -2
- package/dist/i18n/locales.json +1 -1
- package/dist/utils/command.js +1 -1
- package/dist/utils/compress.js +2 -2
- package/package.json +7 -7
package/dist/commands/config.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
2
3
|
import spawn from 'cross-spawn';
|
|
3
4
|
import t from '../i18n/index.js';
|
|
4
5
|
import logger from '../libs/logger.js';
|
|
5
6
|
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
|
+
};
|
|
6
18
|
const editConfigFile = (configPath) => {
|
|
7
|
-
const editor =
|
|
19
|
+
const editor = getDefaultEditor();
|
|
8
20
|
spawn(editor, [configPath], {
|
|
9
21
|
stdio: 'inherit'
|
|
10
22
|
});
|
|
@@ -8,6 +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 os from 'os';
|
|
11
12
|
import path from 'path';
|
|
12
13
|
import { exit } from 'process';
|
|
13
14
|
import { confirm as clackConfirm, isCancel, log, outro } from '@clack/prompts';
|
|
@@ -111,9 +112,8 @@ export function checkAndUpdatePackage(packageName) {
|
|
|
111
112
|
}
|
|
112
113
|
catch (e) {
|
|
113
114
|
spinner.text = t('template_updating').d('Updating templates to latest...');
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
115
|
+
// Cross-platform: use fs-extra.removeSync instead of rm -rf
|
|
116
|
+
fs.removeSync(path.join(packageJsonPath, 'node_modules', packageName));
|
|
117
117
|
execSync(`npm install ${packageName}@latest`, {
|
|
118
118
|
cwd: packageJsonPath,
|
|
119
119
|
stdio: 'inherit'
|
|
@@ -143,12 +143,9 @@ 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
|
-
|
|
149
|
-
execSync(`rm -rf package-lock.json`, {
|
|
150
|
-
cwd: packageJsonPath
|
|
151
|
-
});
|
|
146
|
+
// Cross-platform: use fs-extra.removeSync instead of rm -rf
|
|
147
|
+
fs.removeSync(path.join(packageJsonPath, 'node_modules', packageName));
|
|
148
|
+
fs.removeSync(path.join(packageJsonPath, 'package-lock.json'));
|
|
152
149
|
execSync(`npm install ${packageName}@latest`, {
|
|
153
150
|
cwd: packageJsonPath,
|
|
154
151
|
stdio: 'inherit'
|
|
@@ -205,6 +202,7 @@ export function getInitParamsFromArgv(argv) {
|
|
|
205
202
|
params.framework = undefined;
|
|
206
203
|
params.language = undefined;
|
|
207
204
|
params.yes = true;
|
|
205
|
+
params.installEsaCli = false;
|
|
208
206
|
}
|
|
209
207
|
if (typeof a.name === 'string')
|
|
210
208
|
params.name = a.name;
|
|
@@ -229,6 +227,8 @@ export function getInitParamsFromArgv(argv) {
|
|
|
229
227
|
params.git = Boolean(a.git);
|
|
230
228
|
if (typeof a.deploy === 'boolean')
|
|
231
229
|
params.deploy = Boolean(a.deploy);
|
|
230
|
+
if (typeof a['install-esa-cli'] === 'boolean')
|
|
231
|
+
params.installEsaCli = Boolean(a['install-esa-cli']);
|
|
232
232
|
return params;
|
|
233
233
|
}
|
|
234
234
|
// Configure project name
|
|
@@ -497,6 +497,18 @@ export const applyFileEdits = (initParams) => __awaiter(void 0, void 0, void 0,
|
|
|
497
497
|
}
|
|
498
498
|
});
|
|
499
499
|
export const installESACli = (initParams) => __awaiter(void 0, void 0, void 0, function* () {
|
|
500
|
+
if (!initParams.installEsaCli) {
|
|
501
|
+
const install = (yield promptParameter({
|
|
502
|
+
type: 'confirm',
|
|
503
|
+
question: 'Do you want to install esa-cli as a dev dependency?',
|
|
504
|
+
label: 'Install ESA CLI',
|
|
505
|
+
defaultValue: false
|
|
506
|
+
}));
|
|
507
|
+
initParams.installEsaCli = install;
|
|
508
|
+
}
|
|
509
|
+
if (!initParams.installEsaCli) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
500
512
|
const targetPath = path.join(process.cwd(), initParams.name);
|
|
501
513
|
const res = yield execCommand(['npm', 'install', '-D', 'esa-cli'], {
|
|
502
514
|
cwd: targetPath,
|
|
@@ -729,6 +741,9 @@ export function initializeProject(selectedTemplatePath, name) {
|
|
|
729
741
|
}
|
|
730
742
|
const targetPath = path.join(process.cwd(), name);
|
|
731
743
|
if (fs.existsSync(targetPath)) {
|
|
744
|
+
// Cross-platform delete command hint
|
|
745
|
+
const isWindows = os.platform() === 'win32';
|
|
746
|
+
const deleteCmd = isWindows ? `rmdir /s /q "${name}"` : `rm -rf "${name}"`;
|
|
732
747
|
logger.block();
|
|
733
748
|
logger.tree([
|
|
734
749
|
`${chalk.bgRed(' ERROR ')} ${chalk.bold.red(t('init_abort').d('Initialization aborted'))}`,
|
|
@@ -736,7 +751,7 @@ export function initializeProject(selectedTemplatePath, name) {
|
|
|
736
751
|
`${chalk.gray(t('path').d('Path:'))} ${chalk.cyan(targetPath)}`,
|
|
737
752
|
chalk.gray(t('try').d('Try one of the following:')),
|
|
738
753
|
`- ${chalk.white(t('try_diff_name').d('Choose a different project name'))}`,
|
|
739
|
-
`- ${chalk.white(t('try_remove').d('Remove the directory:'))} ${chalk.yellow(
|
|
754
|
+
`- ${chalk.white(t('try_remove').d('Remove the directory:'))} ${chalk.yellow(deleteCmd)}`,
|
|
740
755
|
`- ${chalk.white(t('try_another_dir').d('Run the command in another directory'))}`
|
|
741
756
|
]);
|
|
742
757
|
logger.block();
|
|
@@ -54,6 +54,11 @@ const init = {
|
|
|
54
54
|
alias: 'd',
|
|
55
55
|
describe: 'Deploy after initialization',
|
|
56
56
|
type: 'boolean'
|
|
57
|
+
})
|
|
58
|
+
.option('install-esa-cli', {
|
|
59
|
+
describe: 'Install esa-cli as a dev dependency',
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
default: false
|
|
57
62
|
});
|
|
58
63
|
},
|
|
59
64
|
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -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 project')}`,
|
|
7
|
+
aliases: ['Functions & Pages'],
|
|
8
|
+
describe: `🧭 ${t('routine_describe').d('Manage your Functions & Pages project')}`,
|
|
9
9
|
builder: (yargs) => {
|
|
10
10
|
yargsIns = yargs;
|
|
11
11
|
return yargs
|
package/dist/i18n/locales.json
CHANGED
package/dist/utils/command.js
CHANGED
|
@@ -16,7 +16,7 @@ export const isWindows = platform() === 'win32';
|
|
|
16
16
|
* Execute a shell command with rich options (spinner, capture, env, cwd).
|
|
17
17
|
*/
|
|
18
18
|
export const execCommand = (command_1, ...args_1) => __awaiter(void 0, [command_1, ...args_1], void 0, function* (command, options = {}) {
|
|
19
|
-
const { startText, doneText, silent = false, captureOutput = false, useSpinner = true, realtimeOutput = false, interactive = false, env, cwd, transformOutput, fallbackOutput, errorMessage, shell =
|
|
19
|
+
const { startText, doneText, silent = false, captureOutput = false, useSpinner = true, realtimeOutput = false, interactive = false, env, cwd, transformOutput, fallbackOutput, errorMessage, shell = isWindows } = options;
|
|
20
20
|
// Determine stdio mode based on options
|
|
21
21
|
// If realtimeOutput is true, we need to pipe to capture and display output in real-time
|
|
22
22
|
// If spinner is used without realtimeOutput, pipe to avoid TTY contention
|
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/master/docs/Config_en.md')}`,
|
|
51
|
+
`- 中文: ${chalk.underline('https://github.com/aliyun/alibabacloud-esa-cli/blob/master/docs/Config_zh_CN.md')}`
|
|
52
52
|
].join('\n'));
|
|
53
53
|
exit(1);
|
|
54
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esa-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "A CLI for operating Alibaba Cloud ESA Functions and Pages.",
|
|
5
5
|
"main": "bin/enter.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "
|
|
18
|
+
"build": "rimraf ./dist ./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",
|
|
@@ -64,9 +64,6 @@
|
|
|
64
64
|
"jsdom": "^25.0.1",
|
|
65
65
|
"lint-staged": "^15.0.2",
|
|
66
66
|
"prettier": "^3.0.3",
|
|
67
|
-
"react": "^18.2.0",
|
|
68
|
-
"react-dom": "^18.2.0",
|
|
69
|
-
"rimraf": "^6.0.1",
|
|
70
67
|
"tsc-files": "^1.1.4",
|
|
71
68
|
"typescript": "^5.2.2",
|
|
72
69
|
"vitest": "^2.0.4"
|
|
@@ -86,7 +83,7 @@
|
|
|
86
83
|
"chokidar": "^3.5.3",
|
|
87
84
|
"cli-table3": "^0.6.5",
|
|
88
85
|
"cross-spawn": "^7.0.3",
|
|
89
|
-
"esa-template": "^0.0.
|
|
86
|
+
"esa-template": "^0.0.10",
|
|
90
87
|
"esbuild": "^0.21.1",
|
|
91
88
|
"esbuild-plugin-less": "^1.3.8",
|
|
92
89
|
"form-data": "^4.0.0",
|
|
@@ -106,7 +103,10 @@
|
|
|
106
103
|
"portscanner": "^2.2.0",
|
|
107
104
|
"winston": "^3.11.0",
|
|
108
105
|
"winston-daily-rotate-file": "^5.0.0",
|
|
109
|
-
"yargs": "^17.7.2"
|
|
106
|
+
"yargs": "^17.7.2",
|
|
107
|
+
"react": "^18.2.0",
|
|
108
|
+
"react-dom": "^18.2.0",
|
|
109
|
+
"rimraf": "^6.0.1"
|
|
110
110
|
},
|
|
111
111
|
"lint-staged": {
|
|
112
112
|
"src/**/*.{ts,tsx,js,jsx}": [
|