swico 0.6.0-beta4 → 0.6.0-beta6

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.0-beta4",
3
+ "version": "0.6.0-beta6",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -131,6 +131,8 @@ function start() {
131
131
  switch (_b.label) {
132
132
  case 0:
133
133
  process.env.SWICO_ENV = 'dev';
134
+ tools_1.toast.info("Swico V".concat(package_json_1.default.version));
135
+ spinner.start('Initializing Swico development config...');
134
136
  if (!(envPort !== null && envPort !== void 0)) return [3, 1];
135
137
  _a = envPort;
136
138
  return [3, 3];
@@ -140,8 +142,6 @@ function start() {
140
142
  _b.label = 3;
141
143
  case 3:
142
144
  availablePort = _a;
143
- tools_1.toast.info("Swico V".concat(package_json_1.default.version));
144
- spinner.start('Initializing Swico development config...');
145
145
  return [4, (0, config_1.getProjectConfig)('dev')];
146
146
  case 4:
147
147
  projectConfig = _b.sent();
@@ -42,6 +42,6 @@ export interface GlobalData {
42
42
  prod: Pick<GlobalSwicoConfigType, 'plugins' | 'console' | 'copy' | 'devtool' | 'router'>;
43
43
  };
44
44
  }
45
- export declare const getProjectConfig: (env?: GlobalData['env']) => Promise<GlobalData>;
45
+ export declare const getProjectConfig: (env: GlobalData['env']) => Promise<GlobalData>;
46
46
  export declare const getFormatDefineVars: (defineVarsConfigData: any) => Promise<{}>;
47
47
  export declare const initConfig: Omit<GlobalSwicoConfigType, 'template'>;
@@ -172,13 +172,13 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
172
172
  case 4:
173
173
  templateType = customConfig['base'].template;
174
174
  routerConfig = __assign(__assign(__assign({}, exports.initConfig.router), customConfig['base'].router), customConfig[env].router);
175
- return [4, initTemplateConfig(routerConfig, templateType)];
175
+ return [4, initTemplateConfig(routerConfig, templateType, env)];
176
176
  case 5:
177
177
  _e.sent();
178
178
  return [4, initCliIndexFile(templateType)];
179
179
  case 6:
180
180
  _e.sent();
181
- entryPath = path_1.default.resolve(projectPath, './src/.swico/index.js');
181
+ entryPath = path_1.default.resolve(projectPath, "./src/.swico/".concat(env === 'dev' ? '' : '.prod/', "index.js"));
182
182
  templatePath = path_1.default.join(projectPath, '/src/index.ejs');
183
183
  return [2, {
184
184
  projectPath: projectPath,
@@ -246,7 +246,7 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
246
246
  }
247
247
  });
248
248
  }); };
249
- var formatRouterConfig = function (_a, templateType) {
249
+ var formatRouterConfig = function (_a, templateType, env) {
250
250
  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;
251
251
  return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
252
252
  var formatRouter, textData, modifiedText, configFilePath, replaceConfigText;
@@ -256,7 +256,7 @@ var formatRouterConfig = function (_a, templateType) {
256
256
  formatRouter = getFormatRouter(routes, templateType);
257
257
  textData = "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = ".concat(JSON.stringify(formatRouter), ";");
258
258
  modifiedText = textData.replace(/"(\(\)=>import\('[^']+'\))"/g, '$1');
259
- return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/routes.js'), modifiedText)];
259
+ return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(env === 'dev' ? '' : '/.prod', "/routes.js")), modifiedText)];
260
260
  case 1:
261
261
  _a.sent();
262
262
  configFilePath = path_1.default.resolve(projectPath, './src/.swico/config.js');
@@ -280,13 +280,14 @@ var formatRouterConfig = function (_a, templateType) {
280
280
  });
281
281
  }); });
282
282
  };
283
- var initTemplateConfig = function (routerConfig, templateType) {
283
+ var initTemplateConfig = function (routerConfig, templateType, env) {
284
+ var swicoPath = env === 'dev' ? '' : '/.prod';
284
285
  return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
285
286
  var copyTargetPath, replaceIndexText, e_1, e_2, e_3;
286
287
  return __generator(this, function (_a) {
287
288
  switch (_a.label) {
288
289
  case 0:
289
- copyTargetPath = path_1.default.resolve(projectPath, './src/.swico');
290
+ copyTargetPath = path_1.default.resolve(projectPath, "./src/.swico".concat(swicoPath));
290
291
  if (!fs_extra_1.default.existsSync(copyTargetPath)) return [3, 2];
291
292
  return [4, fs_extra_1.default.remove(copyTargetPath)];
292
293
  case 1:
@@ -298,10 +299,10 @@ var initTemplateConfig = function (routerConfig, templateType) {
298
299
  })];
299
300
  case 3:
300
301
  _a.sent();
301
- return [4, formatRouterConfig(routerConfig, templateType)];
302
+ return [4, formatRouterConfig(routerConfig, templateType, env)];
302
303
  case 4:
303
304
  _a.sent();
304
- replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, './src/.swico/index.js'), 'utf8');
305
+ replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, "./src/.swico".concat(swicoPath, "/index.js")), 'utf8');
305
306
  _a.label = 5;
306
307
  case 5:
307
308
  _a.trys.push([5, 7, , 8]);
@@ -330,7 +331,7 @@ var initTemplateConfig = function (routerConfig, templateType) {
330
331
  case 11:
331
332
  if (!(templateType === 'vue')) return [3, 13];
332
333
  replaceIndexText = replaceIndexText.replace('"./Container"', '"./Container.vue"');
333
- return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/index.js'), replaceIndexText)];
334
+ return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(swicoPath, "/index.js")), replaceIndexText)];
334
335
  case 12:
335
336
  _a.sent();
336
337
  _a.label = 13;
@@ -348,7 +349,7 @@ var initTemplateConfig = function (routerConfig, templateType) {
348
349
  e_3 = _a.sent();
349
350
  replaceIndexText = replaceIndexText.replace('"../loading"', '"./loading"');
350
351
  return [3, 19];
351
- case 17: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/index.js'), replaceIndexText)];
352
+ case 17: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(swicoPath, "/index.js")), replaceIndexText)];
352
353
  case 18:
353
354
  _a.sent();
354
355
  return [7];