swico 0.8.1-beta2 → 0.8.1-beta21

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.8.1-beta2",
3
+ "version": "0.8.1-beta21",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -42,11 +42,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  var webpack_1 = __importDefault(require("webpack"));
43
43
  var webpack_prod_1 = __importDefault(require("../config/webpack.prod"));
44
44
  var config_1 = require("../utils/config");
45
- var chalk_1 = __importDefault(require("chalk"));
46
- var ora_1 = __importDefault(require("ora"));
47
45
  var tools_1 = require("../utils/tools");
48
46
  var package_json_1 = __importDefault(require("../../package.json"));
49
- var spinner = (0, ora_1.default)();
50
47
  function default_1() {
51
48
  return __awaiter(this, void 0, void 0, function () {
52
49
  var projectConfig, entryPath, templatePath, projectPath, customConfig, templateType, buildConfig, compiler;
@@ -86,7 +83,7 @@ function default_1() {
86
83
  if (stats.hasWarnings()) {
87
84
  tools_1.toast.warning(info.warnings.map(function (item) { return item.stack; }));
88
85
  }
89
- spinner.succeed("".concat(chalk_1.default.green.bold('Building complete'), " \n"));
86
+ tools_1.toast.success('Building complete');
90
87
  });
91
88
  return [2];
92
89
  }
@@ -60,6 +60,7 @@ var path_1 = __importDefault(require("path"));
60
60
  var cross_spawn_1 = __importDefault(require("cross-spawn"));
61
61
  var _a = process.env, envPort = _a.PORT, RESTART = _a.RESTART;
62
62
  var package_json_1 = __importDefault(require("../../package.json"));
63
+ var chalk_1 = __importDefault(require("chalk"));
63
64
  var handleWatch = function (projectPath, devServer) {
64
65
  var configFilesWatcher = chokidar_1.default
65
66
  .watch([
@@ -122,15 +123,22 @@ var restartServer = function () {
122
123
  process.exit(1);
123
124
  }
124
125
  };
126
+ var getMockGetLogger = function (compiler) {
127
+ var logger = compiler.getInfrastructureLogger('name');
128
+ var log = logger.log, debug = logger.debug, error = logger.error, warn = logger.warn;
129
+ return function (name) {
130
+ return __assign(__assign({}, logger), { log: log, debug: debug, error: error, warn: warn, info: function () { } });
131
+ };
132
+ };
125
133
  function start() {
126
134
  return __awaiter(this, void 0, void 0, function () {
127
- var _a, projectConfig, projectPath, startConfig, compiler, devServer, oriConsoleLog, e_1, strErr;
135
+ var _a, projectConfig, projectPath, startConfig, compiler, oriLogger, devServer, e_1, strErr;
128
136
  return __generator(this, function (_b) {
129
137
  switch (_b.label) {
130
138
  case 0:
131
139
  process.env.SWICO_ENV = 'dev';
132
140
  if (RESTART !== 'true') {
133
- tools_1.toast.info("Swico v".concat(package_json_1.default.version));
141
+ tools_1.toast.info("v".concat(package_json_1.default.version));
134
142
  tools_1.toast.info('Initializing Swico development config...');
135
143
  }
136
144
  return [4, (0, tools_1.initIndexFile)()];
@@ -153,17 +161,33 @@ function start() {
153
161
  case 6:
154
162
  startConfig = _b.sent();
155
163
  compiler = (0, webpack_1.default)(startConfig);
164
+ oriLogger = compiler.getInfrastructureLogger;
165
+ compiler.getInfrastructureLogger = getMockGetLogger(compiler);
156
166
  devServer = new webpack_dev_server_1.default(__assign(__assign({}, startConfig.devServer), { port: availablePort }), compiler);
167
+ compiler.watch({}, function (err, stats) {
168
+ if (err) {
169
+ tools_1.toast.error(err.stack || err.toString());
170
+ return;
171
+ }
172
+ var info = stats.toJson();
173
+ if (stats.hasErrors()) {
174
+ tools_1.toast.error(info.errors.map(function (item) { return item.stack; }));
175
+ return;
176
+ }
177
+ if (stats.hasWarnings()) {
178
+ tools_1.toast.warning(info.warnings.map(function (item) { return item.stack; }));
179
+ }
180
+ tools_1.toast.info("Compiled successfully in ".concat(info.time, "ms"));
181
+ });
157
182
  _b.label = 7;
158
183
  case 7:
159
184
  _b.trys.push([7, 9, , 10]);
160
- oriConsoleLog = console.log;
161
- console.log = function () { };
162
185
  return [4, devServer.start()];
163
186
  case 8:
164
187
  _b.sent();
165
- console.log = oriConsoleLog;
188
+ compiler.getInfrastructureLogger = oriLogger;
166
189
  handleWatch(projectPath, devServer);
190
+ tools_1.toast.info("Project is running at\uFF1A".concat(chalk_1.default.hex('#29abe0')("".concat(startConfig.devServer.server, "://localhost:").concat(availablePort, "/"))));
167
191
  return [3, 10];
168
192
  case 9:
169
193
  e_1 = _b.sent();
@@ -62,7 +62,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
62
62
  var path_1 = __importDefault(require("path"));
63
63
  var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
64
64
  var config_1 = require("../utils/config");
65
- var webpackbar_1 = __importDefault(require("webpackbar"));
66
65
  var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
67
66
  var fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
68
67
  var webpack_1 = __importDefault(require("webpack"));
@@ -271,11 +270,6 @@ function default_1(_a) {
271
270
  new mini_css_extract_plugin_1.default({
272
271
  filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
273
272
  ignoreOrder: true
274
- }),
275
- new webpackbar_1.default({
276
- name: 'Swico',
277
- color: '#5f72f5',
278
- profile: false
279
273
  })
280
274
  ], false), ((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins), true)
281
275
  }];
@@ -62,7 +62,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
62
62
  var path_1 = __importDefault(require("path"));
63
63
  var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
64
64
  var config_1 = require("../utils/config");
65
- var webpackbar_1 = __importDefault(require("webpackbar"));
66
65
  var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
67
66
  var fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
68
67
  var webpack_1 = __importDefault(require("webpack"));
@@ -288,11 +287,6 @@ function default_1(_a) {
288
287
  new mini_css_extract_plugin_1.default({
289
288
  filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
290
289
  ignoreOrder: true
291
- }),
292
- new webpackbar_1.default({
293
- name: 'Swico',
294
- color: '#5f72f5',
295
- profile: false
296
290
  })
297
291
  ], false), ((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins), true)
298
292
  }];
@@ -89,6 +89,8 @@ var fs_extra_1 = __importDefault(require("fs-extra"));
89
89
  var config_1 = require("../utils/config");
90
90
  var webpack_merge_1 = require("webpack-merge");
91
91
  var esbuild_loader_1 = require("esbuild-loader");
92
+ var webpackbar_1 = __importDefault(require("webpackbar"));
93
+ var tools_1 = require("../utils/tools");
92
94
  var BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
93
95
  var isAnalyze = process.env.ANALYZE === 'true';
94
96
  function default_1(options) {
@@ -155,7 +157,7 @@ function default_1(options) {
155
157
  }
156
158
  }
157
159
  },
158
- plugins: __spreadArray(__spreadArray(__spreadArray([], (isPublicDirExist || copyConfig.length > 0
160
+ plugins: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], (isPublicDirExist || copyConfig.length > 0
159
161
  ? [
160
162
  new copy_webpack_plugin_1.default({
161
163
  patterns: __spreadArray(__spreadArray([], (isPublicDirExist ? [path_1.default.join(projectPath, '/public')] : []), true), copyConfig, true)
@@ -176,7 +178,13 @@ function default_1(options) {
176
178
  logLevel: 'info'
177
179
  })
178
180
  ]
179
- : []), true), ((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : []), true)
181
+ : []), true), [
182
+ new webpackbar_1.default({
183
+ name: 'Swico',
184
+ color: tools_1.themeColor,
185
+ profile: false
186
+ })
187
+ ], false), ((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : []), true)
180
188
  })];
181
189
  }
182
190
  });
@@ -2,8 +2,10 @@ 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 themeColor = "#7888FCFF";
5
6
  export declare const toast: {
6
7
  info: (message: string) => void;
8
+ success: (message: string) => void;
7
9
  error: (message: string | string[]) => void;
8
10
  warning: (message: string | string[]) => void;
9
11
  };
@@ -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.getPort = exports.getFormatRouter = exports.copyDirFiles = void 0;
83
+ exports.initIndexFile = exports.toast = exports.themeColor = 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"));
@@ -204,29 +204,33 @@ var getPort = function () {
204
204
  });
205
205
  };
206
206
  exports.getPort = getPort;
207
+ exports.themeColor = '#7888FCFF';
207
208
  exports.toast = {
208
209
  info: function (message) {
209
- console.log("> ".concat(chalk_1.default.hex('#5f72f5')(message), "\n"));
210
+ console.log("".concat(chalk_1.default.hex(exports.themeColor).bold('swico'), " - ").concat(message, "\n"));
211
+ },
212
+ success: function (message) {
213
+ console.log("".concat(chalk_1.default.hex('#32f264').bold('swico'), " - ").concat(message, "\n"));
210
214
  },
211
215
  error: function (message) {
212
- console.log("\n> ".concat(chalk_1.default.hex('#5f72f5')('There are some errors about Swico:'), " \n"));
216
+ console.log("".concat(chalk_1.default.red.bold('error'), " - There are some errors about Swico\uFF1A \n"));
213
217
  if (Array.isArray(message)) {
214
218
  message.forEach(function (item) {
215
219
  console.log(" > ".concat(chalk_1.default.red.bold(item), " \n"));
216
220
  });
217
221
  }
218
- else {
222
+ else if (message) {
219
223
  console.log(" > ".concat(chalk_1.default.red.bold(message), " \n"));
220
224
  }
221
225
  },
222
226
  warning: function (message) {
223
- console.log("\n> ".concat(chalk_1.default.hex('#5f72f5')('There are some warnings about Swico:'), " \n"));
227
+ console.log("".concat(chalk_1.default.red.bold('#fb8918'), " - There are some errors about Swico\uFF1A \n"));
224
228
  if (Array.isArray(message)) {
225
229
  message.forEach(function (item) {
226
230
  console.log(" > ".concat(chalk_1.default.hex('#fb8918').bold(item), " \n"));
227
231
  });
228
232
  }
229
- else {
233
+ else if (message) {
230
234
  console.log(" > ".concat(chalk_1.default.hex('#fb8918').bold(message), " \n"));
231
235
  }
232
236
  }