swico 1.5.0-beta.9 → 1.6.0-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swico",
3
- "version": "1.5.0-beta.9",
3
+ "version": "1.6.0-beta.1",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -30,61 +30,59 @@
30
30
  "author": "scw",
31
31
  "license": "ISC",
32
32
  "dependencies": {
33
- "qs": "6.13.0",
34
- "react": "~18.2.0",
35
- "react-dom": "~18.2.0",
36
- "react-router-dom": "6.23.0",
37
- "vue": "~3.4.14",
38
- "vue-router": "^4.2.5",
39
33
  "@babel/types": "7.23.9",
40
- "@commitlint/cli": "18.5.0",
41
- "@commitlint/config-conventional": "18.5.0",
42
34
  "@swc/core": "1.4.6",
43
- "@types/react": "18.2.79",
44
- "@types/react-dom": "18.2.25",
45
- "@typescript-eslint/eslint-plugin": "6.19.0",
46
- "@typescript-eslint/parser": "6.19.0",
47
35
  "@vue/compiler-sfc": "3.4.14",
48
36
  "autoprefixer": "10.3.7",
49
37
  "chalk": "4.1.2",
50
38
  "chokidar": "3.6.0",
51
39
  "commander": "12.0.0",
52
40
  "copy-webpack-plugin": "12.0.2",
53
- "cross-env": "7.0.3",
54
- "cross-spawn": "7.0.3",
41
+ "cross-spawn": "7.0.5",
55
42
  "css-loader": "6.3.0",
56
43
  "esbuild-loader": "4.0.3",
57
- "eslint": "8.48.0",
58
44
  "eslint-plugin-react": "7.33.2",
59
45
  "eslint-plugin-react-hooks": "4.3.0",
60
46
  "eslint-plugin-vue": "9.19.2",
61
47
  "eslint-webpack-plugin": "4.0.0",
62
48
  "fork-ts-checker-webpack-plugin": "9.0.2",
49
+ "fs-extra": "11.3.0",
63
50
  "html-loader": "5.0.0",
64
51
  "html-webpack-plugin": "5.3.2",
65
- "husky": "9.0.10",
66
52
  "less": "4.1.2",
67
53
  "less-loader": "12.2.0",
68
- "lint-staged": "15.2.1",
69
54
  "mini-css-extract-plugin": "2.4.2",
70
55
  "ora": "5.4.1",
71
56
  "portfinder": "1.0.32",
72
57
  "postcss-loader": "8.1.0",
73
58
  "postcss-preset-env": "9.3.0",
74
- "prettier": "3.2.5",
59
+ "qs": "6.13.0",
60
+ "react-router-dom": "6.23.0",
75
61
  "sass": "1.77.5",
76
62
  "sass-loader": "14.2.1",
77
63
  "style-loader": "3.3.0",
78
64
  "swc-loader": "0.2.6",
79
65
  "ts-node": "10.9.1",
80
- "typescript": "5.3.3",
81
66
  "vue-loader": "17.4.2",
67
+ "vue-router": "^4.2.5",
82
68
  "vue-style-loader": "4.1.3",
83
- "webpack": "5.88.2",
84
69
  "webpack-bundle-analyzer": "4.9.1",
85
70
  "webpack-cli": "5.1.4",
86
71
  "webpack-dev-server": "4.15.2",
87
72
  "webpack-merge": "5.9.0",
88
73
  "webpackbar": "6.0.1"
74
+ },
75
+ "devDependencies": {
76
+ "@types/node": "22.13.10",
77
+ "@types/react": "18.2.79",
78
+ "@types/react-dom": "18.2.25",
79
+ "@typescript-eslint/eslint-plugin": "6.19.0",
80
+ "@typescript-eslint/parser": "6.19.0",
81
+ "eslint": "8.48.0",
82
+ "react": "~18.2.0",
83
+ "react-dom": "~18.2.0",
84
+ "typescript": "5.3.3",
85
+ "vue": "~3.4.14",
86
+ "webpack": "5.94.0"
89
87
  }
90
88
  }
@@ -106,7 +106,7 @@ var handleWatch = function (projectPath, devServer, env) {
106
106
  var replaceIndexText, _a;
107
107
  return __generator(this, function (_b) {
108
108
  switch (_b.label) {
109
- case 0: return [4, fs_extra_1.default.readFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8')];
109
+ case 0: return [4, fs_extra_1.default.readFile(path_1.default.resolve(projectPath, "./.swico".concat(envPath, "index.js")), 'utf8')];
110
110
  case 1:
111
111
  replaceIndexText = _b.sent();
112
112
  if (!['add', 'unlink'].includes(eventName)) return [3, 9];
@@ -153,7 +153,7 @@ var restartServer = function () {
153
153
  stdio: 'inherit'
154
154
  });
155
155
  if (result.error) {
156
- tools_1.toast.error(result.error.message());
156
+ tools_1.toast.error(result.error.message);
157
157
  process.exit(1);
158
158
  }
159
159
  };
@@ -165,9 +165,9 @@ var getMockGetLogger = function (compiler) {
165
165
  };
166
166
  };
167
167
  var filterStyleFileList = [
168
- "Can't resolve '../../global.less'",
169
- "Can't resolve '../../global.css'",
170
- "Can't resolve '../../global.scss'"
168
+ 'Can\'t resolve \'../../global.less\'',
169
+ 'Can\'t resolve \'../../global.css\'',
170
+ 'Can\'t resolve \'../../global.scss\''
171
171
  ];
172
172
  var createCompileListener = function (compiler) {
173
173
  compiler.hooks.beforeCompile.tap('beforeCompile', function () {
@@ -189,7 +189,7 @@ var createCompileListener = function (compiler) {
189
189
  }
190
190
  });
191
191
  }
192
- tools_1.toast.info("Compiled successfully ".concat((info === null || info === void 0 ? void 0 : info.time) ? "in ".concat((info.time / 1000).toFixed(2), "s") : ''));
192
+ tools_1.toast.info("Compiled ".concat((info === null || info === void 0 ? void 0 : info.time) ? "in ".concat((info.time / 1000).toFixed(2), "s") : ''));
193
193
  });
194
194
  };
195
195
  function start() {
@@ -75,11 +75,8 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
75
75
  extensions: string[];
76
76
  alias: {
77
77
  '@': string;
78
- react: string;
79
- 'react-dom': string;
80
78
  'react-router-dom': string;
81
79
  qs: string;
82
- husky: string;
83
80
  };
84
81
  };
85
82
  externals: any;
@@ -64,7 +64,11 @@ var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin
64
64
  var config_1 = require("../utils/config");
65
65
  var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
66
66
  var webpack_1 = __importDefault(require("webpack"));
67
- var tools_1 = require("../utils/tools");
67
+ var styleLoader = require.resolve('style-loader');
68
+ var cssLoader = require.resolve('css-loader');
69
+ var lessLoader = require.resolve('less-loader');
70
+ var sassLoader = require.resolve('sass-loader');
71
+ var postcssLoader = require.resolve('postcss-loader');
68
72
  function default_1(_a) {
69
73
  var _b, _c, _d;
70
74
  var projectPath = _a.projectPath, entryPath = _a.entryPath, env = _a.env, customConfig = _a.customConfig;
@@ -114,7 +118,7 @@ function default_1(_a) {
114
118
  exclude: /node_modules/,
115
119
  use: [
116
120
  {
117
- loader: (0, tools_1.getLoaderPath)('swc-loader'),
121
+ loader: require.resolve('swc-loader'),
118
122
  options: {
119
123
  jsc: {
120
124
  parser: {
@@ -141,11 +145,9 @@ function default_1(_a) {
141
145
  {
142
146
  test: /\.module\.css$/,
143
147
  use: [
144
- env === 'dev'
145
- ? (0, tools_1.getLoaderPath)('style-loader')
146
- : mini_css_extract_plugin_1.default.loader,
148
+ env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
147
149
  {
148
- loader: (0, tools_1.getLoaderPath)('css-loader'),
150
+ loader: cssLoader,
149
151
  options: {
150
152
  modules: {
151
153
  localIdentName: 'moduleStyle_[local]_[contenthash:8]'
@@ -153,7 +155,7 @@ function default_1(_a) {
153
155
  }
154
156
  },
155
157
  {
156
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
158
+ loader: postcssLoader,
157
159
  options: {
158
160
  postcssOptions: {
159
161
  plugins: [['autoprefixer']]
@@ -165,12 +167,10 @@ function default_1(_a) {
165
167
  {
166
168
  test: /\.css$/,
167
169
  use: [
168
- env === 'dev'
169
- ? (0, tools_1.getLoaderPath)('style-loader')
170
- : mini_css_extract_plugin_1.default.loader,
171
- (0, tools_1.getLoaderPath)('css-loader'),
170
+ env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
171
+ cssLoader,
172
172
  {
173
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
173
+ loader: postcssLoader,
174
174
  options: {
175
175
  postcssOptions: {
176
176
  plugins: [['autoprefixer']]
@@ -182,11 +182,9 @@ function default_1(_a) {
182
182
  {
183
183
  test: /\.module\.less$/,
184
184
  use: [
185
- env === 'dev'
186
- ? (0, tools_1.getLoaderPath)('style-loader')
187
- : mini_css_extract_plugin_1.default.loader,
185
+ env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
188
186
  {
189
- loader: (0, tools_1.getLoaderPath)('css-loader'),
187
+ loader: cssLoader,
190
188
  options: {
191
189
  modules: {
192
190
  localIdentName: 'moduleStyle_[local]_[contenthash:8]'
@@ -194,42 +192,38 @@ function default_1(_a) {
194
192
  }
195
193
  },
196
194
  {
197
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
195
+ loader: postcssLoader,
198
196
  options: {
199
197
  postcssOptions: {
200
198
  plugins: [['postcss-preset-env', 'autoprefixer']]
201
199
  }
202
200
  }
203
201
  },
204
- (0, tools_1.getLoaderPath)('less-loader')
202
+ lessLoader
205
203
  ]
206
204
  },
207
205
  {
208
206
  test: /\.less$/,
209
207
  use: [
210
- env === 'dev'
211
- ? (0, tools_1.getLoaderPath)('style-loader')
212
- : mini_css_extract_plugin_1.default.loader,
213
- (0, tools_1.getLoaderPath)('css-loader'),
208
+ env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
209
+ cssLoader,
214
210
  {
215
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
211
+ loader: postcssLoader,
216
212
  options: {
217
213
  postcssOptions: {
218
214
  plugins: [['autoprefixer']]
219
215
  }
220
216
  }
221
217
  },
222
- (0, tools_1.getLoaderPath)('less-loader')
218
+ lessLoader
223
219
  ]
224
220
  },
225
221
  {
226
222
  test: /\.module\.scss$/,
227
223
  use: [
228
- env === 'dev'
229
- ? (0, tools_1.getLoaderPath)('style-loader')
230
- : mini_css_extract_plugin_1.default.loader,
224
+ env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
231
225
  {
232
- loader: (0, tools_1.getLoaderPath)('css-loader'),
226
+ loader: cssLoader,
233
227
  options: {
234
228
  modules: {
235
229
  localIdentName: 'moduleStyle_[local]_[contenthash:8]'
@@ -237,32 +231,30 @@ function default_1(_a) {
237
231
  }
238
232
  },
239
233
  {
240
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
234
+ loader: postcssLoader,
241
235
  options: {
242
236
  postcssOptions: {
243
237
  plugins: [['postcss-preset-env', 'autoprefixer']]
244
238
  }
245
239
  }
246
240
  },
247
- (0, tools_1.getLoaderPath)('sass-loader')
241
+ sassLoader
248
242
  ]
249
243
  },
250
244
  {
251
245
  test: /\.scss$/,
252
246
  use: [
253
- env === 'dev'
254
- ? (0, tools_1.getLoaderPath)('style-loader')
255
- : mini_css_extract_plugin_1.default.loader,
256
- (0, tools_1.getLoaderPath)('css-loader'),
247
+ env === 'dev' ? styleLoader : mini_css_extract_plugin_1.default.loader,
248
+ cssLoader,
257
249
  {
258
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
250
+ loader: postcssLoader,
259
251
  options: {
260
252
  postcssOptions: {
261
253
  plugins: [['autoprefixer']]
262
254
  }
263
255
  }
264
256
  },
265
- (0, tools_1.getLoaderPath)('sass-loader')
257
+ lessLoader
266
258
  ]
267
259
  },
268
260
  {
@@ -285,7 +277,7 @@ function default_1(_a) {
285
277
  },
286
278
  {
287
279
  test: /\.html$/,
288
- loader: (0, tools_1.getLoaderPath)('html-loader')
280
+ loader: require.resolve('html-loader')
289
281
  }
290
282
  ]
291
283
  }
@@ -293,7 +285,7 @@ function default_1(_a) {
293
285
  },
294
286
  resolve: {
295
287
  extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
296
- alias: __assign({ '@': path_1.default.join(projectPath, '/src'), react: path_1.default.dirname(require.resolve('react')), 'react-dom': path_1.default.dirname(require.resolve('react-dom')), 'react-router-dom': path_1.default.dirname(require.resolve('react-router-dom')), qs: path_1.default.dirname(require.resolve('qs')), husky: path_1.default.dirname(require.resolve('husky')) }, getCustomAliasConfig())
288
+ alias: __assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router-dom': path_1.default.dirname(require.resolve('react-router-dom')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
297
289
  },
298
290
  externals: customConfig.base.externals,
299
291
  plugins: __spreadArray(__spreadArray(__spreadArray([], basicPlugins, true), [
@@ -101,7 +101,6 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
101
101
  vue: string;
102
102
  'vue-router': string;
103
103
  qs: string;
104
- husky: string;
105
104
  };
106
105
  };
107
106
  externals: any;
@@ -65,7 +65,11 @@ var config_1 = require("../utils/config");
65
65
  var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
66
66
  var webpack_1 = __importDefault(require("webpack"));
67
67
  var vue_loader_1 = require("vue-loader");
68
- var tools_1 = require("../utils/tools");
68
+ var vueStyleLoader = require.resolve('vue-style-loader');
69
+ var cssLoader = require.resolve('css-loader');
70
+ var lessLoader = require.resolve('less-loader');
71
+ var sassLoader = require.resolve('sass-loader');
72
+ var postcssLoader = require.resolve('postcss-loader');
69
73
  function default_1(_a) {
70
74
  var _b, _c, _d;
71
75
  var projectPath = _a.projectPath, entryPath = _a.entryPath, env = _a.env, customConfig = _a.customConfig;
@@ -112,7 +116,7 @@ function default_1(_a) {
112
116
  rules: [
113
117
  {
114
118
  test: /\.vue$/,
115
- loader: (0, tools_1.getLoaderPath)('vue-loader'),
119
+ loader: require.resolve('vue-loader'),
116
120
  exclude: /node_modules/
117
121
  },
118
122
  {
@@ -120,7 +124,7 @@ function default_1(_a) {
120
124
  exclude: /node_modules/,
121
125
  use: [
122
126
  {
123
- loader: (0, tools_1.getLoaderPath)('swc-loader'),
127
+ loader: require.resolve('swc-loader'),
124
128
  options: {
125
129
  jsc: {
126
130
  parser: {
@@ -143,9 +147,9 @@ function default_1(_a) {
143
147
  {
144
148
  resourceQuery: /module/,
145
149
  use: [
146
- (0, tools_1.getLoaderPath)('vue-style-loader'),
150
+ vueStyleLoader,
147
151
  {
148
- loader: (0, tools_1.getLoaderPath)('css-loader'),
152
+ loader: cssLoader,
149
153
  options: {
150
154
  modules: {
151
155
  localIdentName: 'moduleStyle_[local]_[contenthash:8]'
@@ -153,7 +157,7 @@ function default_1(_a) {
153
157
  }
154
158
  },
155
159
  {
156
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
160
+ loader: postcssLoader,
157
161
  options: {
158
162
  postcssOptions: {
159
163
  plugins: [['autoprefixer']]
@@ -165,11 +169,11 @@ function default_1(_a) {
165
169
  {
166
170
  use: [
167
171
  env === 'dev'
168
- ? (0, tools_1.getLoaderPath)('vue-style-loader')
172
+ ? vueStyleLoader
169
173
  : mini_css_extract_plugin_1.default.loader,
170
- (0, tools_1.getLoaderPath)('css-loader'),
174
+ cssLoader,
171
175
  {
172
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
176
+ loader: postcssLoader,
173
177
  options: {
174
178
  postcssOptions: {
175
179
  plugins: [['autoprefixer']]
@@ -186,9 +190,9 @@ function default_1(_a) {
186
190
  {
187
191
  resourceQuery: /module/,
188
192
  use: [
189
- (0, tools_1.getLoaderPath)('vue-style-loader'),
193
+ vueStyleLoader,
190
194
  {
191
- loader: (0, tools_1.getLoaderPath)('css-loader'),
195
+ loader: cssLoader,
192
196
  options: {
193
197
  modules: {
194
198
  localIdentName: 'moduleStyle_[local]_[contenthash:8]'
@@ -196,31 +200,31 @@ function default_1(_a) {
196
200
  }
197
201
  },
198
202
  {
199
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
203
+ loader: postcssLoader,
200
204
  options: {
201
205
  postcssOptions: {
202
206
  plugins: [['autoprefixer']]
203
207
  }
204
208
  }
205
209
  },
206
- (0, tools_1.getLoaderPath)('less-loader')
210
+ lessLoader
207
211
  ]
208
212
  },
209
213
  {
210
214
  use: [
211
215
  env === 'dev'
212
- ? (0, tools_1.getLoaderPath)('vue-style-loader')
216
+ ? vueStyleLoader
213
217
  : mini_css_extract_plugin_1.default.loader,
214
- (0, tools_1.getLoaderPath)('css-loader'),
218
+ cssLoader,
215
219
  {
216
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
220
+ loader: postcssLoader,
217
221
  options: {
218
222
  postcssOptions: {
219
223
  plugins: [['autoprefixer']]
220
224
  }
221
225
  }
222
226
  },
223
- (0, tools_1.getLoaderPath)('less-loader')
227
+ lessLoader
224
228
  ]
225
229
  }
226
230
  ]
@@ -231,9 +235,9 @@ function default_1(_a) {
231
235
  {
232
236
  resourceQuery: /module/,
233
237
  use: [
234
- (0, tools_1.getLoaderPath)('vue-style-loader'),
238
+ vueStyleLoader,
235
239
  {
236
- loader: (0, tools_1.getLoaderPath)('css-loader'),
240
+ loader: cssLoader,
237
241
  options: {
238
242
  modules: {
239
243
  localIdentName: 'moduleStyle_[local]_[contenthash:8]'
@@ -241,31 +245,31 @@ function default_1(_a) {
241
245
  }
242
246
  },
243
247
  {
244
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
248
+ loader: postcssLoader,
245
249
  options: {
246
250
  postcssOptions: {
247
251
  plugins: [['autoprefixer']]
248
252
  }
249
253
  }
250
254
  },
251
- (0, tools_1.getLoaderPath)('sass-loader')
255
+ sassLoader
252
256
  ]
253
257
  },
254
258
  {
255
259
  use: [
256
260
  env === 'dev'
257
- ? (0, tools_1.getLoaderPath)('vue-style-loader')
261
+ ? vueStyleLoader
258
262
  : mini_css_extract_plugin_1.default.loader,
259
- (0, tools_1.getLoaderPath)('css-loader'),
263
+ cssLoader,
260
264
  {
261
- loader: (0, tools_1.getLoaderPath)('postcss-loader'),
265
+ loader: postcssLoader,
262
266
  options: {
263
267
  postcssOptions: {
264
268
  plugins: [['autoprefixer']]
265
269
  }
266
270
  }
267
271
  },
268
- (0, tools_1.getLoaderPath)('sass-loader')
272
+ sassLoader
269
273
  ]
270
274
  }
271
275
  ]
@@ -290,7 +294,7 @@ function default_1(_a) {
290
294
  },
291
295
  {
292
296
  test: /\.html$/,
293
- loader: (0, tools_1.getLoaderPath)('html-loader')
297
+ loader: require.resolve('html-loader')
294
298
  }
295
299
  ]
296
300
  }
@@ -298,7 +302,7 @@ function default_1(_a) {
298
302
  },
299
303
  resolve: {
300
304
  extensions: ['.ts', '.js', '.vue', '.json'],
301
- alias: __assign({ '@': path_1.default.join(projectPath, '/src'), vue: path_1.default.dirname(require.resolve('vue')), 'vue-router': path_1.default.dirname(require.resolve('vue-router')), qs: path_1.default.dirname(require.resolve('qs')), husky: path_1.default.dirname(require.resolve('husky')) }, getCustomAliasConfig())
305
+ alias: __assign({ '@': path_1.default.join(projectPath, '/src'), vue: 'vue/dist/vue.esm-bundler.js', 'vue-router': path_1.default.dirname(require.resolve('vue-router')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
302
306
  },
303
307
  externals: customConfig.base.externals,
304
308
  plugins: __spreadArray(__spreadArray(__spreadArray([], basicPlugins, true), [
@@ -15,7 +15,6 @@ export type ConfigRouterType = {
15
15
  };
16
16
  export interface GlobalSwicoConfigType {
17
17
  template: 'react' | 'vue';
18
- npmType?: 'npm' | 'pnpm';
19
18
  plugins?: any[];
20
19
  publicPath?: string;
21
20
  console?: boolean;
@@ -38,7 +37,7 @@ export interface GlobalData {
38
37
  templatePath: string;
39
38
  env?: 'dev' | 'prod';
40
39
  customConfig: {
41
- base: Pick<GlobalSwicoConfigType, 'plugins' | 'publicPath' | 'alias' | 'define' | 'devtool' | 'externals' | 'npmType' | 'router' | 'template'>;
40
+ base: Pick<GlobalSwicoConfigType, 'plugins' | 'publicPath' | 'alias' | 'define' | 'devtool' | 'externals' | 'router' | 'template'>;
42
41
  dev: Pick<GlobalSwicoConfigType, 'plugins' | 'proxy' | 'https' | 'devtool' | 'router'>;
43
42
  prod: Pick<GlobalSwicoConfigType, 'plugins' | 'console' | 'copy' | 'devtool' | 'router'>;
44
43
  };
@@ -78,13 +78,13 @@ var fs_extra_1 = __importDefault(require("fs-extra"));
78
78
  var path_1 = __importDefault(require("path"));
79
79
  var chalk_1 = __importDefault(require("chalk"));
80
80
  var tools_1 = require("./tools");
81
- var projectPath = process.cwd();
82
81
  var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0, function () {
83
- var configDir, configPath, customConfig, _loop_1, _i, _a, key, templateType, routerConfig, envPath, entryPath, templatePath;
84
- var _b, _c, _d;
85
- return __generator(this, function (_e) {
86
- switch (_e.label) {
82
+ var projectPath, configDir, configPath, customConfig, _loop_1, _i, _a, key, templateType, routerConfig, envPath, entryPath, templatePath;
83
+ var _b, _c;
84
+ return __generator(this, function (_d) {
85
+ switch (_d.label) {
87
86
  case 0:
87
+ projectPath = process.cwd();
88
88
  configDir = path_1.default.join(projectPath, '/config');
89
89
  configPath = {
90
90
  dev: path_1.default.join(configDir, '/swico.dev.ts'),
@@ -93,18 +93,18 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
93
93
  };
94
94
  customConfig = {};
95
95
  _loop_1 = function (key) {
96
- var curConfigFilePath, exists, configObj, configFields, supportedFieldList_1, configFileName, toastTitle, unSupportedField, msgText, _f, _g;
97
- return __generator(this, function (_h) {
98
- switch (_h.label) {
96
+ var curConfigFilePath, exists, configObj, configFields, supportedFieldList_1, configFileName, toastTitle, unSupportedField, msgText, _e, _f;
97
+ return __generator(this, function (_g) {
98
+ switch (_g.label) {
99
99
  case 0:
100
100
  curConfigFilePath = configPath[key];
101
101
  return [4, fs_extra_1.default.exists(curConfigFilePath)];
102
102
  case 1:
103
- exists = _h.sent();
103
+ exists = _g.sent();
104
104
  if (!exists) return [3, 4];
105
105
  return [4, Promise.resolve("".concat(curConfigFilePath)).then(function (s) { return __importStar(require(s)); })];
106
106
  case 2:
107
- configObj = (_h.sent()).default;
107
+ configObj = (_g.sent()).default;
108
108
  configFields = Object.keys(configObj);
109
109
  configFileName = void 0;
110
110
  switch (key) {
@@ -116,7 +116,6 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
116
116
  'define',
117
117
  'devtool',
118
118
  'externals',
119
- 'npmType',
120
119
  'router',
121
120
  'template'
122
121
  ];
@@ -141,34 +140,29 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
141
140
  tools_1.toast.error("The field '".concat(chalk_1.default.blue('template'), "' does not support the value '").concat(chalk_1.default.red(configObj['template']), "',the value should be 'vue' or 'react' "), { title: toastTitle });
142
141
  process.exit(1);
143
142
  }
144
- if (key === 'base' &&
145
- !['npm', 'pnpm'].includes((_b = configObj['npmType']) !== null && _b !== void 0 ? _b : exports.initConfig.npmType)) {
146
- tools_1.toast.error("The field '".concat(chalk_1.default.blue('npmType'), "' does not support the value '").concat(chalk_1.default.red(configObj['npmType']), "',the value should be 'npm' or 'pnpm' "), { title: toastTitle });
147
- process.exit(1);
148
- }
149
- if (!['hash', 'browser'].includes((_d = (_c = configObj['router']) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : exports.initConfig.router.type)) {
143
+ if (!['hash', 'browser'].includes((_c = (_b = configObj['router']) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : exports.initConfig.router.type)) {
150
144
  tools_1.toast.error("The field '".concat(chalk_1.default.blue('router.type'), "' does not support the value '").concat(chalk_1.default.red(configObj['router'].type), "',the value should be 'browser' or 'hash' "), { title: toastTitle });
151
145
  process.exit(1);
152
146
  }
153
- _f = customConfig;
154
- _g = key;
147
+ _e = customConfig;
148
+ _f = key;
155
149
  return [4, Promise.resolve("".concat(curConfigFilePath)).then(function (s) { return __importStar(require(s)); })];
156
150
  case 3:
157
- _f[_g] = (_h.sent()).default;
158
- _h.label = 4;
151
+ _e[_f] = (_g.sent()).default;
152
+ _g.label = 4;
159
153
  case 4: return [2];
160
154
  }
161
155
  });
162
156
  };
163
157
  _i = 0, _a = Object.keys(configPath);
164
- _e.label = 1;
158
+ _d.label = 1;
165
159
  case 1:
166
160
  if (!(_i < _a.length)) return [3, 4];
167
161
  key = _a[_i];
168
162
  return [5, _loop_1(key)];
169
163
  case 2:
170
- _e.sent();
171
- _e.label = 3;
164
+ _d.sent();
165
+ _d.label = 3;
172
166
  case 3:
173
167
  _i++;
174
168
  return [3, 1];
@@ -177,12 +171,12 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
177
171
  routerConfig = __assign(__assign(__assign({}, exports.initConfig.router), customConfig['base'].router), customConfig[env].router);
178
172
  return [4, initTemplateConfig(routerConfig, templateType, env)];
179
173
  case 5:
180
- _e.sent();
174
+ _d.sent();
181
175
  return [4, initCliIndexFile(templateType, env)];
182
176
  case 6:
183
- _e.sent();
177
+ _d.sent();
184
178
  envPath = env === 'dev' ? '.dev/' : '.prod/';
185
- entryPath = path_1.default.resolve(projectPath, "./src/.swico/".concat(envPath, "index.js"));
179
+ entryPath = path_1.default.resolve(projectPath, "./.swico/".concat(envPath, "index.js"));
186
180
  templatePath = path_1.default.join(projectPath, '/src/index.ejs');
187
181
  return [2, {
188
182
  env: env,
@@ -197,10 +191,11 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
197
191
  }); };
198
192
  exports.getProjectConfig = getProjectConfig;
199
193
  var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, void 0, void 0, function () {
200
- var targetPath, targetTypesPath, replaceFileText, fileTypesText, formatHooksPath, formatHistoryPath;
194
+ var projectPath, targetPath, targetTypesPath, replaceFileText, fileTypesText, formatHooksPath, formatHistoryPath;
201
195
  return __generator(this, function (_a) {
202
196
  switch (_a.label) {
203
197
  case 0:
198
+ projectPath = process.cwd();
204
199
  targetPath = path_1.default.resolve(__dirname, '../index.js');
205
200
  targetTypesPath = path_1.default.resolve(__dirname, '../index.d.ts');
206
201
  return [4, fs_extra_1.default.readFile(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".js")), 'utf8')];
@@ -210,11 +205,11 @@ var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, v
210
205
  case 2:
211
206
  fileTypesText = _a.sent();
212
207
  formatHooksPath = path_1.default
213
- .resolve(projectPath, './src/.swico/react-hooks')
208
+ .resolve(projectPath, './.swico/react-hooks')
214
209
  .replaceAll('\\', '/');
215
210
  replaceFileText = replaceFileText.replaceAll('require("./template/react/react-hooks");', "require(\"".concat(formatHooksPath, "\");"));
216
211
  formatHistoryPath = path_1.default
217
- .resolve(projectPath, "./src/.swico/.".concat(env, "/history"))
212
+ .resolve(projectPath, "./.swico/.".concat(env, "/history"))
218
213
  .replaceAll('\\', '/');
219
214
  replaceFileText = replaceFileText.replaceAll('require("./mock-history");', "require(\"".concat(formatHistoryPath, "\");"));
220
215
  return [4, fs_extra_1.default.writeFile(targetPath, replaceFileText)];
@@ -229,6 +224,7 @@ var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, v
229
224
  }); };
230
225
  var formatRouterConfig = function (_a, templateType, env) {
231
226
  var _b = _a.routes, routes = _b === void 0 ? [] : _b, _c = _a.type, type = _c === void 0 ? 'browser' : _c, _d = _a.base, base = _d === void 0 ? '/' : _d;
227
+ var projectPath = process.cwd();
232
228
  var envPath = env === 'dev' ? '/.dev/' : '/.prod/';
233
229
  return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
234
230
  var formatRouter, textData, modifiedText, configFilePath, replaceConfigText;
@@ -238,10 +234,10 @@ var formatRouterConfig = function (_a, templateType, env) {
238
234
  formatRouter = (0, tools_1.getFormatRouter)(projectPath, routes, templateType);
239
235
  textData = "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = ".concat(JSON.stringify(formatRouter), ";");
240
236
  modifiedText = textData.replace(/"(\(\)=>import\('[^']+'\))"/g, '$1');
241
- return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "routes.js")), modifiedText)];
237
+ return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./.swico".concat(envPath, "routes.js")), modifiedText)];
242
238
  case 1:
243
239
  _a.sent();
244
- configFilePath = path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "config.js"));
240
+ configFilePath = path_1.default.resolve(projectPath, "./.swico".concat(envPath, "config.js"));
245
241
  return [4, fs_extra_1.default.readFile(configFilePath, 'utf8')];
246
242
  case 2:
247
243
  replaceConfigText = _a.sent();
@@ -265,6 +261,7 @@ var formatRouterConfig = function (_a, templateType, env) {
265
261
  }); });
266
262
  };
267
263
  var getGlobalStyleFilePath = function () {
264
+ var projectPath = process.cwd();
268
265
  var filePath, fileType;
269
266
  var cssPath = path_1.default.resolve(projectPath, './src/global.css');
270
267
  var lessPath = path_1.default.resolve(projectPath, './src/global.less');
@@ -288,10 +285,11 @@ var getGlobalStyleFilePath = function () {
288
285
  return { filePath: filePath, fileType: fileType };
289
286
  };
290
287
  var handleLoadingFile = function (replaceIndexText, envPath) { return __awaiter(void 0, void 0, void 0, function () {
291
- var newReplaceIndexText, e_1;
288
+ var projectPath, newReplaceIndexText, e_1;
292
289
  return __generator(this, function (_a) {
293
290
  switch (_a.label) {
294
291
  case 0:
292
+ projectPath = process.cwd();
295
293
  newReplaceIndexText = replaceIndexText;
296
294
  _a.label = 1;
297
295
  case 1:
@@ -299,11 +297,11 @@ var handleLoadingFile = function (replaceIndexText, envPath) { return __awaiter(
299
297
  return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
300
298
  case 2:
301
299
  _a.sent();
302
- newReplaceIndexText = newReplaceIndexText.replace('"../loading"', '"../../loading"');
300
+ newReplaceIndexText = newReplaceIndexText.replace('"../loading"', '"../../../src/loading"');
303
301
  return [3, 4];
304
302
  case 3:
305
303
  e_1 = _a.sent();
306
- newReplaceIndexText = newReplaceIndexText.replace('"../../loading"', '"../loading"');
304
+ newReplaceIndexText = newReplaceIndexText.replace('"../../../src/loading"', '"../loading"');
307
305
  return [3, 4];
308
306
  case 4: return [2, newReplaceIndexText];
309
307
  }
@@ -315,7 +313,7 @@ var handleGlobalStyleFile = function (replaceIndexText) {
315
313
  var newReplaceIndexText = replaceIndexText;
316
314
  if (styleFilePath) {
317
315
  newReplaceIndexText = newReplaceIndexText.replaceAll("require(\"../../global.".concat(styleFileType, "\");"), '');
318
- newReplaceIndexText = "require(\"../../global.".concat(styleFileType, "\");\n").concat(replaceIndexText);
316
+ newReplaceIndexText = "require(\"../../../src/global.".concat(styleFileType, "\");\n").concat(replaceIndexText);
319
317
  }
320
318
  else {
321
319
  newReplaceIndexText = newReplaceIndexText.replaceAll(/require\("\.\.\/\.\.\/global.(less|scss|css)"\);/g, '');
@@ -324,9 +322,12 @@ var handleGlobalStyleFile = function (replaceIndexText) {
324
322
  };
325
323
  exports.handleGlobalStyleFile = handleGlobalStyleFile;
326
324
  var updateIndexFileText = function (envPath, newFileText) { return __awaiter(void 0, void 0, void 0, function () {
325
+ var projectPath;
327
326
  return __generator(this, function (_a) {
328
327
  switch (_a.label) {
329
- case 0: return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), newFileText)];
328
+ case 0:
329
+ projectPath = process.cwd();
330
+ return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./.swico".concat(envPath, "index.js")), newFileText)];
330
331
  case 1:
331
332
  _a.sent();
332
333
  return [2];
@@ -335,13 +336,14 @@ var updateIndexFileText = function (envPath, newFileText) { return __awaiter(voi
335
336
  }); };
336
337
  exports.updateIndexFileText = updateIndexFileText;
337
338
  var initTemplateConfig = function (routerConfig, templateType, env) {
339
+ var projectPath = process.cwd();
338
340
  var envPath = env === 'dev' ? '/.dev/' : '/.prod/';
339
341
  return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
340
342
  var copyTargetPath, replaceIndexText, hooksFilePath, replaceHooksText, newReplaceIndexText;
341
343
  return __generator(this, function (_a) {
342
344
  switch (_a.label) {
343
345
  case 0:
344
- copyTargetPath = path_1.default.resolve(projectPath, "./src/.swico".concat(envPath));
346
+ copyTargetPath = path_1.default.resolve(projectPath, "./.swico".concat(envPath));
345
347
  return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType, "/$env")), copyTargetPath, function (fileName) {
346
348
  return !fileName.endsWith('.d.ts') &&
347
349
  (templateType === 'vue'
@@ -350,7 +352,7 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
350
352
  })];
351
353
  case 1:
352
354
  _a.sent();
353
- return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), path_1.default.resolve(projectPath, './src/.swico'), function (fileName) {
355
+ return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), path_1.default.resolve(projectPath, './.swico'), function (fileName) {
354
356
  return ['react-hooks.js', 'vue-hooks.js', 'loading.js', 'Container.vue'].includes(fileName);
355
357
  })];
356
358
  case 2:
@@ -358,10 +360,10 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
358
360
  return [4, formatRouterConfig(routerConfig, templateType, env)];
359
361
  case 3:
360
362
  _a.sent();
361
- return [4, fs_extra_1.default.readFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8')];
363
+ return [4, fs_extra_1.default.readFile(path_1.default.resolve(projectPath, "./.swico".concat(envPath, "index.js")), 'utf8')];
362
364
  case 4:
363
365
  replaceIndexText = _a.sent();
364
- hooksFilePath = path_1.default.resolve(projectPath, "./src/.swico/".concat(templateType, "-hooks.js"));
366
+ hooksFilePath = path_1.default.resolve(projectPath, "./.swico/".concat(templateType, "-hooks.js"));
365
367
  return [4, fs_extra_1.default.readFile(hooksFilePath, 'utf8')];
366
368
  case 5:
367
369
  replaceHooksText = _a.sent();
@@ -415,7 +417,6 @@ var getFormatDefineVars = function (defineVarsConfigData) { return __awaiter(voi
415
417
  }); };
416
418
  exports.getFormatDefineVars = getFormatDefineVars;
417
419
  exports.initConfig = {
418
- npmType: 'npm',
419
420
  console: true,
420
421
  plugins: [],
421
422
  publicPath: '/',
@@ -2,7 +2,6 @@ import { ConfigRouterType } from './config';
2
2
  export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
3
3
  export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType['routes'], templateType: any) => any[];
4
4
  export declare const getPort: () => Promise<number>;
5
- export declare const getLoaderPath: (loader: any) => string;
6
5
  export declare const colorConfig: {
7
6
  theme: string;
8
7
  warning: string;
@@ -80,7 +80,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
80
80
  return (mod && mod.__esModule) ? mod : { "default": mod };
81
81
  };
82
82
  Object.defineProperty(exports, "__esModule", { value: true });
83
- exports.initIndexFile = exports.toast = exports.colorConfig = exports.getLoaderPath = exports.getPort = exports.getFormatRouter = exports.copyDirFiles = void 0;
83
+ exports.initIndexFile = exports.toast = exports.colorConfig = exports.getPort = exports.getFormatRouter = exports.copyDirFiles = void 0;
84
84
  var portfinder_1 = __importDefault(require("portfinder"));
85
85
  var fs_extra_1 = __importDefault(require("fs-extra"));
86
86
  var path_1 = __importDefault(require("path"));
@@ -198,8 +198,6 @@ var getPort = function () {
198
198
  });
199
199
  };
200
200
  exports.getPort = getPort;
201
- var getLoaderPath = function (loader) { return require.resolve(loader); };
202
- exports.getLoaderPath = getLoaderPath;
203
201
  exports.colorConfig = {
204
202
  theme: '#7888FCFF',
205
203
  warning: '#fb8918',
@@ -252,15 +250,16 @@ exports.toast = {
252
250
  }
253
251
  };
254
252
  var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, function () {
255
- var fileText, targetPath, formatHooksPath, formatDevHistoryPath, formatProdHistoryPath;
253
+ var fileText, targetPath, projectPath, formatHooksPath, formatDevHistoryPath, formatProdHistoryPath;
256
254
  return __generator(this, function (_a) {
257
255
  switch (_a.label) {
258
256
  case 0: return [4, fs_extra_1.default.readFile(path_1.default.resolve(__dirname, '../index.js'), 'utf8')];
259
257
  case 1:
260
258
  fileText = _a.sent();
261
259
  targetPath = path_1.default.resolve(__dirname, '../index.js');
260
+ projectPath = process.cwd();
262
261
  formatHooksPath = path_1.default
263
- .resolve(process.cwd(), './src/.swico/react-hooks')
262
+ .resolve(projectPath, './.swico/react-hooks')
264
263
  .replaceAll('\\', '/');
265
264
  if (!fileText.includes("require(\"".concat(formatHooksPath, "\");"))) return [3, 3];
266
265
  fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/react-hooks");');
@@ -270,10 +269,10 @@ var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, funct
270
269
  _a.label = 3;
271
270
  case 3:
272
271
  formatDevHistoryPath = path_1.default
273
- .resolve(process.cwd(), './src/.swico/.dev/history')
272
+ .resolve(projectPath, './.swico/.dev/history')
274
273
  .replaceAll('\\', '/');
275
274
  formatProdHistoryPath = path_1.default
276
- .resolve(process.cwd(), './src/.swico/.prod/history')
275
+ .resolve(projectPath, './.swico/.prod/history')
277
276
  .replaceAll('\\', '/');
278
277
  if (!fileText.includes("require(\"".concat(formatDevHistoryPath, "\");"))) return [3, 5];
279
278
  fileText = fileText.replaceAll("require(\"".concat(formatDevHistoryPath, "\");"), 'require("./mock-history");');