@autobest-ui/scripts 1.9.1-alpha.1 → 1.9.1-alpha.3

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/bin/spa.js CHANGED
File without changes
package/bin/ssr.js CHANGED
File without changes
package/common/start.js CHANGED
@@ -45,7 +45,7 @@ function openStartRun(webpackFactory) {
45
45
  try {
46
46
  const config = extendWebpackConfigFromProject(
47
47
  webpackFactory,
48
- { ...appConfig, port: PORT, startOpenPath },
48
+ { ...appConfig, startOpenPath, ...parseArgsToJson, port: PORT },
49
49
  extendEnv,
50
50
  { isProd: false, isServer: false, isHotServer: false }
51
51
  );
package/common/utils.js CHANGED
@@ -4,6 +4,8 @@ const fs = require('fs');
4
4
  // 执行node命令时候的文件绝对路径
5
5
  const root = process.cwd();
6
6
 
7
+ const argsReg = /^--[0-9a-z]+$/;
8
+
7
9
  /**
8
10
  * 从根目录开始获取文件绝对地址路径
9
11
  * @param filePath 文件参数
@@ -15,21 +17,35 @@ function getProjectPath(...filePath) {
15
17
 
16
18
  function getParseArgsToJson() {
17
19
  const args = process.argv.slice(2);
18
- const length = args.length - 1;
19
20
  const result = {};
20
- let count = 0;
21
- while (count <= length) {
22
- if (!/^--[0-9a-z]+$/.test(args[count])) {
23
- throw Error('Run args error, example: --port 3030');
24
- }
25
- const key = args[count].substring(2);
26
- count++;
27
- if (count > length) {
28
- result[key] = '';
21
+ const length = args.length;
22
+ for (let count = 0; count < args.length; count++) {
23
+ if (!length || count >= length) {
29
24
  break;
30
25
  }
31
- result[key] = isNaN(Number(args[count])) ? args[count] : Number(args[count]);
32
- count++;
26
+ if (!argsReg.test(args[0])) {
27
+ throw Error('Run args error, example: "--port 3030" or "--eslint"');
28
+ }
29
+ const currentItem = args[count];
30
+ if (argsReg.test(currentItem)) {
31
+ const key = currentItem.substring(2);
32
+ if (count + 1 >= length) {
33
+ result[key] = true;
34
+ break;
35
+ }
36
+ const nextItem = args[count + 1];
37
+ if (argsReg.test(nextItem)) {
38
+ result[key] = true;
39
+ continue;
40
+ }
41
+ result[key] = isNaN(Number(nextItem))
42
+ ? nextItem === 'false'
43
+ ? false
44
+ : nextItem === 'true'
45
+ ? true
46
+ : nextItem
47
+ : Number(nextItem);
48
+ }
33
49
  }
34
50
  return result;
35
51
  }
@@ -1,4 +1,5 @@
1
1
  const webpack = require('webpack');
2
+ const ESLintPlugin = require('eslint-webpack-plugin');
2
3
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
3
4
  const ProgressBarPlugin = require('progress-bar-webpack-plugin');
4
5
  const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
@@ -231,6 +232,17 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer }) => {
231
232
  })
232
233
  );
233
234
  }
235
+ if (!isProd && appConfig.eslint) {
236
+ result.plugins.push(
237
+ new ESLintPlugin({
238
+ exclude: 'node_modules',
239
+ threads: 4,
240
+ failOnError: false,
241
+ lintDirtyModulesOnly: false,
242
+ extensions: ['tsx', 'ts', 'js']
243
+ })
244
+ );
245
+ }
234
246
 
235
247
  if (isProd && !isServer) {
236
248
  result.optimization = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobest-ui/scripts",
3
- "version": "1.9.1-alpha.1",
3
+ "version": "1.9.1-alpha.3",
4
4
  "private": false,
5
5
  "description": "utils for project tools",
6
6
  "bin": {
@@ -91,7 +91,7 @@
91
91
  "sass-loader": "12.6.0",
92
92
  "style-loader": "3.3.1",
93
93
  "terser-webpack-plugin": "5.3.1",
94
- "ts-node": "9.1.1",
94
+ "ts-node": "10.9.1",
95
95
  "typescript": "4.8.3",
96
96
  "webpack": "5.70.0",
97
97
  "webpack-dev-server": "4.7.4",
@@ -102,5 +102,5 @@
102
102
  "eslint": "^8.23.1",
103
103
  "typescript": "4.8.3"
104
104
  },
105
- "gitHead": "5d24f38a613e7257710fd753d4a4596c16226f13"
105
+ "gitHead": "f6715e41b33688a797b38983f0b19da9992ab88d"
106
106
  }
@@ -1,5 +1,4 @@
1
1
  const { merge } = require('webpack-merge');
2
- const ESLintPlugin = require('eslint-webpack-plugin');
3
2
  const ip = require('ip');
4
3
  const FriendlyErrorsPlugin = require('@soda/friendly-errors-webpack-plugin');
5
4
  const { getProjectPath } = require('../common/utils');
@@ -18,14 +17,6 @@ module.exports = function (appConfig, extendEnv) {
18
17
  chunkFilename: '[name].chunk.js'
19
18
  },
20
19
  plugins: [
21
- // eslint只在本地开发时检测
22
- new ESLintPlugin({
23
- exclude: 'node_modules',
24
- threads: 4,
25
- failOnError: false,
26
- lintDirtyModulesOnly: false,
27
- extensions: ['tsx', 'ts', 'js']
28
- }),
29
20
  // 相关配置文档:https://github.com/geowarin/friendly-errors-webpack-plugin
30
21
  new FriendlyErrorsPlugin({
31
22
  compilationSuccessInfo: {
@@ -1,5 +1,4 @@
1
1
  const { merge } = require('webpack-merge');
2
- const ESLintPlugin = require('eslint-webpack-plugin');
3
2
  const LoadablePlugin = require('@loadable/webpack-plugin');
4
3
  const { getProjectPath } = require('../common/utils');
5
4
  const baseConfig = require('./webpack.base');
@@ -27,17 +26,7 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
27
26
  filename: `${appConfig.baseStaticJsPath}/[name].js`,
28
27
  chunkFilename: `${appConfig.baseStaticJsPath}/[name].js`
29
28
  },
30
- plugins: [
31
- // eslint只在本地开发时检测
32
- new ESLintPlugin({
33
- exclude: 'node_modules',
34
- threads: 4,
35
- failOnError: false,
36
- lintDirtyModulesOnly: isProd,
37
- extensions: ['tsx', 'ts', 'js']
38
- }),
39
- new LoadablePlugin()
40
- ]
29
+ plugins: [new LoadablePlugin()]
41
30
  }
42
31
  );
43
32
  };
@@ -1,5 +1,4 @@
1
1
  const { merge } = require('webpack-merge');
2
- const ESLintPlugin = require('eslint-webpack-plugin');
3
2
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
3
  const ip = require('ip');
5
4
  const FriendlyErrorsPlugin = require('@soda/friendly-errors-webpack-plugin');
@@ -25,14 +24,6 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
25
24
  chunkFilename: '[name].chunk.js'
26
25
  },
27
26
  plugins: [
28
- // eslint只在本地开发时检测
29
- new ESLintPlugin({
30
- exclude: 'node_modules',
31
- threads: 4,
32
- failOnError: false,
33
- lintDirtyModulesOnly: isProd,
34
- extensions: ['tsx', 'ts', 'js']
35
- }),
36
27
  // 相关配置文档:https://github.com/geowarin/friendly-errors-webpack-plugin
37
28
  new FriendlyErrorsPlugin({
38
29
  compilationSuccessInfo: {
@@ -1,5 +1,4 @@
1
1
  const webpack = require('webpack');
2
- const ESLintPlugin = require('eslint-webpack-plugin');
3
2
  const nodeExternals = require('webpack-node-externals');
4
3
  const { merge } = require('webpack-merge');
5
4
  const { getProjectPath } = require('../common/utils');
@@ -47,17 +46,7 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
47
46
  ]
48
47
  },
49
48
  // 覆盖查找规则, 减少无用模块
50
- plugins: [
51
- // eslint只在本地开发时检测
52
- new ESLintPlugin({
53
- exclude: 'node_modules',
54
- threads: 4,
55
- failOnError: false,
56
- lintDirtyModulesOnly: isProd,
57
- extensions: ['tsx', 'ts', 'js']
58
- }),
59
- new webpack.ContextReplacementPlugin(/any-promise/)
60
- ],
49
+ plugins: [new webpack.ContextReplacementPlugin(/any-promise/)],
61
50
  // 避免路径丢失
62
51
  node: {
63
52
  __filename: true,