esa-cli 0.0.2-beta.10 → 0.0.2-beta.13
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 +26 -115
- package/dist/commands/commit/prodBuild.js +2 -3
- package/dist/commands/common/routineUtils.js +276 -0
- package/dist/commands/config.js +1 -1
- package/dist/commands/deploy/helper.js +40 -61
- package/dist/commands/deploy/index.js +90 -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 +22 -11
- 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 +162 -27
- package/dist/commands/dev/index.js +14 -15
- package/dist/commands/dev/mockWorker/devPack.js +16 -7
- 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 +87 -13
- package/dist/commands/init/index.js +461 -57
- package/dist/commands/init/template.jsonc +34 -0
- package/dist/commands/lang.js +2 -2
- package/dist/commands/login/index.js +57 -7
- package/dist/commands/logout.js +5 -5
- package/dist/commands/route/add.js +138 -49
- package/dist/commands/route/delete.js +33 -27
- package/dist/commands/route/helper.js +124 -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 +9 -21
- package/dist/commands/site/index.js +1 -1
- package/dist/commands/site/list.js +6 -7
- package/dist/commands/utils.js +55 -19
- package/dist/components/descriptionInput.js +1 -1
- package/dist/components/mutiSelectTable.js +1 -1
- package/dist/components/selectInput.js +2 -3
- package/dist/components/selectItem.js +1 -1
- package/dist/docs/Commands_en.md +25 -15
- package/dist/docs/Commands_zh_CN.md +12 -2
- package/dist/docs/eslint-config-en.md +1 -0
- package/dist/docs/eslint-config.md +73 -0
- package/dist/docs/init-command-quick-test.md +208 -0
- package/dist/docs/init-command-test-guide.md +598 -0
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/locales.json +261 -17
- package/dist/index.js +17 -12
- package/dist/libs/api.js +32 -9
- package/dist/libs/apiService.js +258 -85
- package/dist/libs/git/index.js +8 -4
- package/dist/libs/interface.js +0 -1
- package/dist/libs/logger.js +63 -7
- package/dist/libs/service.js +2 -2
- package/dist/libs/templates/index.js +1 -1
- 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 +16 -31
- package/dist/utils/checkVersion.js +1 -1
- package/dist/utils/compress.js +80 -0
- package/dist/utils/download.js +5 -5
- package/dist/utils/fileMd5.js +1 -1
- package/dist/utils/fileUtils/index.js +71 -22
- package/dist/utils/installDeno.js +3 -3
- package/dist/utils/installEw2.js +7 -7
- package/dist/utils/openInBrowser.js +1 -1
- package/package.json +11 -6
|
@@ -7,16 +7,16 @@ 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 fs from 'fs-extra';
|
|
11
|
-
import path from 'path';
|
|
12
|
-
import Template from '../../libs/templates/index.js';
|
|
13
|
-
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
14
|
-
import logger from '../../libs/logger.js';
|
|
15
10
|
import { execSync } from 'child_process';
|
|
16
|
-
import
|
|
11
|
+
import path from 'path';
|
|
17
12
|
import chalk from 'chalk';
|
|
18
|
-
import
|
|
13
|
+
import fs from 'fs-extra';
|
|
19
14
|
import inquirer from 'inquirer';
|
|
15
|
+
import t from '../../i18n/index.js';
|
|
16
|
+
import logger from '../../libs/logger.js';
|
|
17
|
+
import Template from '../../libs/templates/index.js';
|
|
18
|
+
import { getDirName } from '../../utils/fileUtils/base.js';
|
|
19
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
20
20
|
export const getTemplateInstances = (templateHubPath) => {
|
|
21
21
|
return fs
|
|
22
22
|
.readdirSync(templateHubPath)
|
|
@@ -66,22 +66,66 @@ export const preInstallDependencies = (targetPath) => __awaiter(void 0, void 0,
|
|
|
66
66
|
else {
|
|
67
67
|
logger.log(t('no_build_script').d('No build script found in package.json, skipping build step.'));
|
|
68
68
|
}
|
|
69
|
+
// After build, try to infer assets directory if not explicitly known
|
|
70
|
+
try {
|
|
71
|
+
const candidates = ['dist', 'build', 'out'];
|
|
72
|
+
for (const dir of candidates) {
|
|
73
|
+
const abs = path.join(targetPath, dir);
|
|
74
|
+
if (fs.existsSync(abs) && fs.statSync(abs).isDirectory()) {
|
|
75
|
+
// Update config file if present and assets not set
|
|
76
|
+
const projectConfig = getProjectConfig(targetPath);
|
|
77
|
+
if (projectConfig) {
|
|
78
|
+
const { updateProjectConfigFile } = yield import('../../utils/fileUtils/index.js');
|
|
79
|
+
if (!projectConfig.assets || !projectConfig.assets.directory) {
|
|
80
|
+
yield updateProjectConfigFile({ assets: { directory: dir } }, targetPath);
|
|
81
|
+
logger.success(`Detected build output "${dir}" and updated assets.directory`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (_a) { }
|
|
69
89
|
}
|
|
70
90
|
});
|
|
71
91
|
export function checkAndUpdatePackage(packageName) {
|
|
72
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
93
|
try {
|
|
94
|
+
const spinner = logger.ora;
|
|
95
|
+
spinner.text = t('checking_template_update').d('Checking esa-template updates...');
|
|
96
|
+
spinner.start();
|
|
74
97
|
// 获取当前安装的版本
|
|
75
98
|
const __dirname = getDirName(import.meta.url);
|
|
76
99
|
const packageJsonPath = path.join(__dirname, '../../../');
|
|
77
|
-
|
|
100
|
+
let versionInfo;
|
|
101
|
+
try {
|
|
102
|
+
versionInfo = execSync(`npm list ${packageName}`, {
|
|
103
|
+
cwd: packageJsonPath
|
|
104
|
+
}).toString();
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
spinner.text = t('template_updating').d('Updating templates to latest...');
|
|
108
|
+
execSync(`rm -rf node_modules/${packageName}`, {
|
|
109
|
+
cwd: packageJsonPath
|
|
110
|
+
});
|
|
111
|
+
execSync(`npm install ${packageName}@latest`, {
|
|
112
|
+
cwd: packageJsonPath,
|
|
113
|
+
stdio: 'inherit'
|
|
114
|
+
});
|
|
115
|
+
spinner.stop();
|
|
116
|
+
logger.log(`├ ${t('template_updated_to_latest').d('Templates updated to latest.')}`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
78
119
|
const match = versionInfo.match(new RegExp(`(${packageName})@([0-9.]+)`));
|
|
79
120
|
const currentVersion = match ? match[2] : '';
|
|
80
121
|
// 获取最新版本
|
|
81
|
-
const latestVersion = execSync(`npm view ${packageName} version
|
|
122
|
+
const latestVersion = execSync(`npm view ${packageName} version`, {
|
|
123
|
+
cwd: packageJsonPath
|
|
124
|
+
})
|
|
82
125
|
.toString()
|
|
83
126
|
.trim();
|
|
84
127
|
if (currentVersion !== latestVersion) {
|
|
128
|
+
spinner.stop();
|
|
85
129
|
logger.log(t('display_current_esa_template_version').d(`Current esa-template version:`) +
|
|
86
130
|
chalk.green(currentVersion) +
|
|
87
131
|
' ' +
|
|
@@ -93,21 +137,51 @@ export function checkAndUpdatePackage(packageName) {
|
|
|
93
137
|
message: t('is_update_to_latest_version').d('Do you want to update templates to latest version?')
|
|
94
138
|
});
|
|
95
139
|
if (isUpdate) {
|
|
96
|
-
|
|
140
|
+
spinner.start(t('template_updating').d('Updating templates to latest...'));
|
|
141
|
+
execSync(`rm -rf node_modules/${packageName}`, {
|
|
142
|
+
cwd: packageJsonPath
|
|
143
|
+
});
|
|
144
|
+
execSync(`rm -rf package-lock.json`, {
|
|
97
145
|
cwd: packageJsonPath
|
|
98
146
|
});
|
|
99
|
-
|
|
147
|
+
execSync(`npm install ${packageName}@latest`, {
|
|
148
|
+
cwd: packageJsonPath,
|
|
149
|
+
stdio: 'inherit'
|
|
150
|
+
});
|
|
151
|
+
spinner.stop();
|
|
152
|
+
logger.log(`├ ${t('updated_esa_template_to_latest_version', { packageName }).d(`${packageName} updated successfully`)}`);
|
|
100
153
|
}
|
|
101
154
|
}
|
|
102
155
|
else {
|
|
103
|
-
|
|
156
|
+
spinner.stop();
|
|
157
|
+
logger.log(` ${t('checking_esa_template_finished').d(`Checking esa-template finished.`)}`);
|
|
158
|
+
t('esa_template_is_latest_version', { packageName }).d(`${packageName} is latest.`);
|
|
159
|
+
logger.divider();
|
|
104
160
|
}
|
|
105
161
|
}
|
|
106
162
|
catch (error) {
|
|
107
163
|
console.log(error);
|
|
108
164
|
if (error instanceof Error) {
|
|
109
|
-
logger.
|
|
165
|
+
logger.ora.fail(t('check_and_update_package_error').d('Error: An error occurred while checking and updating the package, skipping template update'));
|
|
110
166
|
}
|
|
111
167
|
}
|
|
112
168
|
});
|
|
113
169
|
}
|
|
170
|
+
export const getFrameworkConfig = (framework) => {
|
|
171
|
+
// 从init目录读取template.jsonc
|
|
172
|
+
const templatePath = path.join(getDirName(import.meta.url), 'template.jsonc');
|
|
173
|
+
const jsonc = fs.readFileSync(templatePath, 'utf-8');
|
|
174
|
+
const json = JSON.parse(jsonc);
|
|
175
|
+
return json[framework];
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* 获取框架全部配置
|
|
179
|
+
* @returns 框架全部配置
|
|
180
|
+
*/
|
|
181
|
+
export const getAllFrameworkConfig = () => {
|
|
182
|
+
// 从init目录读取template.jsonc
|
|
183
|
+
const templatePath = path.join(getDirName(import.meta.url), 'template.jsonc');
|
|
184
|
+
const jsonc = fs.readFileSync(templatePath, 'utf-8');
|
|
185
|
+
const json = JSON.parse(jsonc);
|
|
186
|
+
return json;
|
|
187
|
+
};
|