@tushi11/elpis 1.0.38 → 1.0.39

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/app/middleware.js CHANGED
@@ -43,7 +43,7 @@ module.exports = (app) => {
43
43
  return new RegExp(`^${escapedPrefix}`);
44
44
  }
45
45
 
46
- const { proxyOption } = app.config?.requestSetting;
46
+ const { proxyOption } = app?.config?.requestSetting || {};
47
47
  if (proxyOption && proxyOption.length > 0) {
48
48
  proxyOption.forEach((item) => {
49
49
  if (item?.match) {
@@ -0,0 +1,21 @@
1
+ const semver = require('semver'); // Node.js内置的版本对比工具
2
+ const requiredVersion = '>=20.19.6'; // 定义所需的最低Node版本
3
+
4
+ module.exports = function checkNodeVersion() {
5
+ // 获取当前Node版本
6
+ const currentVersion = process.version;
7
+ // console.log(`当前Node.js版本:${currentVersion}`);
8
+
9
+ // 检查版本是否满足要求
10
+ if (!semver.satisfies(currentVersion, requiredVersion)) {
11
+ console.error(
12
+ `\x1B[31m错误:Node.js版本要求不低于 ${requiredVersion},当前版本为 ${currentVersion}\x1B[0m`
13
+ );
14
+ console.error(
15
+ '\x1B[33m请升级Node.js版本后重试,推荐使用nvm管理Node版本:https://github.com/nvm-sh/nvm\x1B[0m'
16
+ );
17
+ process.exit(1); // 终止进程,阻止项目启动
18
+ } else {
19
+ // console.log(`\x1B[32mNode.js版本检查通过 ✔️\x1B[0m`);
20
+ }
21
+ };
package/index.js CHANGED
@@ -3,6 +3,8 @@ const ElpisCore = require('./elpis-core');
3
3
  // 引入 前端工程化构建方法
4
4
  const FEBuildDev = require('./app/webpack/dev.js');
5
5
  const FEbuildProd = require('./app/webpack/prod.js');
6
+ // 引入 Node版本检查模块
7
+ const checkNodeVersion = require('./check-node-version');
6
8
 
7
9
  module.exports = {
8
10
  /**
@@ -20,6 +22,7 @@ module.exports = {
20
22
  * @param env 环境变量 local/prod
21
23
  */
22
24
  frontendBuild(env) {
25
+ checkNodeVersion();
23
26
  if (env === 'local') {
24
27
  FEBuildDev();
25
28
  } else if (env === 'production') {
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@tushi11/elpis",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "",
5
5
  "main": "index.js",
6
+ "engines": {
7
+ "node": ">=20.19.6"
8
+ },
6
9
  "scripts": {
7
10
  "lint": "eslint --quiet --ext js,vue .",
8
11
  "test": "cross-env _ENV='local' PORT=8082 mocha 'test/**/*.js'"