swico 0.6.2-beta2 → 0.6.2-beta3

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": "0.6.2-beta2",
3
+ "version": "0.6.2-beta3",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -56,7 +56,7 @@ function default_1() {
56
56
  process.env.SWICO_ENV = 'prod';
57
57
  tools_1.toast.info("Swico v".concat(package_json_1.default.version));
58
58
  tools_1.toast.info('Initializing Swico production config...');
59
- return [4, (0, tools_1.initIndexFile)()];
59
+ return [4, (0, tools_1.initIndexFile)('prod')];
60
60
  case 1:
61
61
  _a.sent();
62
62
  return [4, (0, config_1.getProjectConfig)('prod')];
@@ -133,7 +133,7 @@ function start() {
133
133
  tools_1.toast.info("Swico v".concat(package_json_1.default.version));
134
134
  tools_1.toast.info('Initializing Swico development config...');
135
135
  }
136
- return [4, (0, tools_1.initIndexFile)()];
136
+ return [4, (0, tools_1.initIndexFile)('dev')];
137
137
  case 1:
138
138
  _b.sent();
139
139
  if (!(envPort !== null && envPort !== void 0)) return [3, 2];
@@ -111,7 +111,6 @@ var getFormatHistoryOption = function (to, formatRouterBase, pathList, type) {
111
111
  obj.pathname = "".concat(formatRouterBase).concat(path);
112
112
  }
113
113
  if (name) {
114
- console.log('pathList', pathList);
115
114
  var fullPath = (_a = pathList.find(function (item) { return item.name === name; })) === null || _a === void 0 ? void 0 : _a.path;
116
115
  var targetPath = fullPath ? interpolatePath(fullPath, params) : null;
117
116
  if (targetPath) {
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import '../../global';
3
- export declare let history: SwicoHistoryType;
3
+ export declare const history: SwicoHistoryType;
4
4
  export type RoutesItemType = {
5
5
  component?: () => Promise<{
6
6
  default: FC;
@@ -21,7 +21,6 @@ var app = (0, vue_1.createApp)(Container_1.default);
21
21
  var Swico = { history: null };
22
22
  exports.history = {
23
23
  push: function (options) {
24
- console.log('routes', routes_1.default);
25
24
  if (typeof options === 'string') {
26
25
  router.push(options);
27
26
  }
@@ -177,7 +177,7 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
177
177
  return [4, initTemplateConfig(routerConfig, templateType, env)];
178
178
  case 5:
179
179
  _e.sent();
180
- return [4, initCliIndexFile(templateType)];
180
+ return [4, initCliIndexFile(templateType, env)];
181
181
  case 6:
182
182
  _e.sent();
183
183
  envPath = env === 'dev' ? '.dev/' : '.prod/';
@@ -222,8 +222,8 @@ var getFormatRouter = function (routes, templateType) {
222
222
  return _main(item);
223
223
  });
224
224
  };
225
- var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0, void 0, function () {
226
- var targetPath, targetTypesPath, replaceFileText, fileTypesText, formatHooksPath;
225
+ var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, void 0, void 0, function () {
226
+ var targetPath, targetTypesPath, replaceFileText, fileTypesText, formatHooksPath, formatHistoryPath, formatHistoryPath;
227
227
  return __generator(this, function (_a) {
228
228
  switch (_a.label) {
229
229
  case 0:
@@ -240,6 +240,16 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
240
240
  .resolve(projectPath, './src/.swico/react-hooks')
241
241
  .replaceAll('\\', '/');
242
242
  replaceFileText = replaceFileText.replaceAll('require("./template/react/react-hooks");', "require(\"".concat(formatHooksPath, "\");"));
243
+ formatHistoryPath = path_1.default
244
+ .resolve(projectPath, "./src/.swico/.".concat(env, "/index"))
245
+ .replaceAll('\\', '/');
246
+ replaceFileText = replaceFileText.replaceAll('require("./template/react/$env/index");', "require(\"".concat(formatHistoryPath, "\");"));
247
+ }
248
+ else {
249
+ formatHistoryPath = path_1.default
250
+ .resolve(projectPath, "./src/.swico/.".concat(env, "/index"))
251
+ .replaceAll('\\', '/');
252
+ replaceFileText = replaceFileText.replaceAll('require("./template/vue/$env/index");', "require(\"".concat(formatHistoryPath, "\");"));
243
253
  }
244
254
  return [4, fs_extra_1.default.writeFile(targetPath, replaceFileText)];
245
255
  case 3:
@@ -1,3 +1,4 @@
1
+ import { GlobalData } from './config';
1
2
  export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
2
3
  export declare const getPort: () => Promise<number>;
3
4
  export declare const toast: {
@@ -5,4 +6,4 @@ export declare const toast: {
5
6
  error: (message: string | string[]) => void;
6
7
  warning: (message: string | string[]) => void;
7
8
  };
8
- export declare const initIndexFile: () => Promise<void>;
9
+ export declare const initIndexFile: (env: GlobalData['env']) => Promise<void>;
@@ -191,8 +191,8 @@ exports.toast = {
191
191
  }
192
192
  }
193
193
  };
194
- var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, function () {
195
- var fileText, targetPath, formatHooksPath;
194
+ var initIndexFile = function (env) { return __awaiter(void 0, void 0, void 0, function () {
195
+ var fileText, targetPath, formatHooksPath, formatHistoryPath;
196
196
  return __generator(this, function (_a) {
197
197
  switch (_a.label) {
198
198
  case 0: return [4, fs_extra_1.default.readFile(path_1.default.resolve(__dirname, '../index.js'), 'utf8')];
@@ -208,7 +208,17 @@ var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, funct
208
208
  case 2:
209
209
  _a.sent();
210
210
  _a.label = 3;
211
- case 3: return [2];
211
+ case 3:
212
+ formatHistoryPath = path_1.default
213
+ .resolve(process.cwd(), "./src/.swico/.".concat(env, "/index"))
214
+ .replaceAll('\\', '/');
215
+ if (!fileText.includes("require(\"".concat(formatHistoryPath, "\");"))) return [3, 5];
216
+ fileText = fileText.replaceAll("require(\"".concat(formatHistoryPath, "\");"), 'require("./template/react/$env/index");');
217
+ return [4, fs_extra_1.default.writeFile(targetPath, fileText)];
218
+ case 4:
219
+ _a.sent();
220
+ _a.label = 5;
221
+ case 5: return [2];
212
222
  }
213
223
  });
214
224
  }); };