swico 0.8.1 → 0.8.2-beta10

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",
3
+ "version": "0.8.2-beta10",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -51,8 +51,8 @@ function default_1() {
51
51
  switch (_a.label) {
52
52
  case 0:
53
53
  process.env.SWICO_ENV = 'prod';
54
- tools_1.toast.info("v".concat(package_json_1.default.version));
55
- tools_1.toast.info('Initializing production config...');
54
+ tools_1.toast.info("v".concat(package_json_1.default.version), { wrap: false });
55
+ tools_1.toast.info('Initializing production config...', { wrap: false });
56
56
  return [4, (0, tools_1.initIndexFile)()];
57
57
  case 1:
58
58
  _a.sent();
@@ -57,10 +57,12 @@ var tools_1 = require("../utils/tools");
57
57
  var config_1 = require("../utils/config");
58
58
  var chokidar_1 = __importDefault(require("chokidar"));
59
59
  var path_1 = __importDefault(require("path"));
60
+ var ora_1 = __importDefault(require("ora"));
60
61
  var cross_spawn_1 = __importDefault(require("cross-spawn"));
61
62
  var _a = process.env, envPort = _a.PORT, RESTART = _a.RESTART;
62
63
  var package_json_1 = __importDefault(require("../../package.json"));
63
64
  var chalk_1 = __importDefault(require("chalk"));
65
+ var spinner = (0, ora_1.default)();
64
66
  var handleWatch = function (projectPath, devServer) {
65
67
  var configFilesWatcher = chokidar_1.default
66
68
  .watch([
@@ -130,6 +132,33 @@ var getMockGetLogger = function (compiler) {
130
132
  return __assign(__assign({}, logger), { log: log, debug: debug, error: error, warn: warn, info: function () { } });
131
133
  };
132
134
  };
135
+ var createCompileListener = function (compiler) {
136
+ compiler.hooks.beforeCompile.tap('beforeCompile', function () {
137
+ tools_1.toast.info('Compiling...', { wrap: false });
138
+ });
139
+ compiler.hooks;
140
+ compiler.hooks.done.tap('done', function (stats) {
141
+ console.log('done');
142
+ var info = stats === null || stats === void 0 ? void 0 : stats.toJson();
143
+ if (stats === null || stats === void 0 ? void 0 : stats.hasErrors()) {
144
+ tools_1.toast.error(info === null || info === void 0 ? void 0 : info.errors.map(function (item) { return item.stack; }));
145
+ return;
146
+ }
147
+ if (stats === null || stats === void 0 ? void 0 : stats.hasWarnings()) {
148
+ tools_1.toast.warning(info === null || info === void 0 ? void 0 : info.warnings.map(function (item) { return item.stack; }));
149
+ }
150
+ tools_1.toast.info("Compiled complete in ".concat(info === null || info === void 0 ? void 0 : info.time, "ms"));
151
+ });
152
+ compiler.watch({}, function (err, stats) {
153
+ var _a, _b;
154
+ console.log('watch');
155
+ var info = stats === null || stats === void 0 ? void 0 : stats.toJson();
156
+ if (err || ((_a = stats === null || stats === void 0 ? void 0 : stats.hasErrors) === null || _a === void 0 ? void 0 : _a.call(stats)) || ((_b = stats.hasWarnings) === null || _b === void 0 ? void 0 : _b.call(stats))) {
157
+ return;
158
+ }
159
+ tools_1.toast.info("Compiled successfully in ".concat(info === null || info === void 0 ? void 0 : info.time, "ms"), { wrap: false });
160
+ });
161
+ };
133
162
  function start() {
134
163
  return __awaiter(this, void 0, void 0, function () {
135
164
  var _a, projectConfig, projectPath, startConfig, compiler, oriLogger, devServer, e_1, strErr;
@@ -138,8 +167,8 @@ function start() {
138
167
  case 0:
139
168
  process.env.SWICO_ENV = 'dev';
140
169
  if (RESTART !== 'true') {
141
- tools_1.toast.info("v".concat(package_json_1.default.version));
142
- tools_1.toast.info('Initializing development config...');
170
+ tools_1.toast.info("v".concat(package_json_1.default.version), { wrap: false });
171
+ tools_1.toast.info('Initializing development config...', { wrap: false });
143
172
  }
144
173
  return [4, (0, tools_1.initIndexFile)()];
145
174
  case 1:
@@ -164,22 +193,16 @@ function start() {
164
193
  oriLogger = compiler.getInfrastructureLogger;
165
194
  compiler.getInfrastructureLogger = getMockGetLogger(compiler);
166
195
  devServer = new webpack_dev_server_1.default(__assign(__assign({}, startConfig.devServer), { port: availablePort }), compiler);
167
- compiler.watch({}, function (err, stats) {
168
- var info = stats.toJson();
169
- if (err || stats.hasErrors() || stats.hasWarnings()) {
170
- return;
171
- }
172
- tools_1.toast.info("Compiled successfully in ".concat(info.time, "ms"));
173
- });
174
196
  _b.label = 7;
175
197
  case 7:
176
198
  _b.trys.push([7, 9, , 10]);
177
199
  return [4, devServer.start()];
178
200
  case 8:
179
201
  _b.sent();
202
+ createCompileListener(compiler);
180
203
  compiler.getInfrastructureLogger = oriLogger;
181
204
  handleWatch(projectPath, devServer);
182
- tools_1.toast.info("Project is running at\uFF1A".concat(chalk_1.default.hex('#29abe0')("".concat(startConfig.devServer.server, "://localhost:").concat(availablePort, "/"))));
205
+ tools_1.toast.info("Project is running at\uFF1A".concat(chalk_1.default.hex('#29abe0')("".concat(startConfig.devServer.server, "://localhost:").concat(availablePort, "/"))), { wrap: false });
183
206
  return [3, 10];
184
207
  case 9:
185
208
  e_1 = _b.sent();
@@ -128,6 +128,8 @@ function default_1(options) {
128
128
  plugins: __spreadArray([
129
129
  new eslint_webpack_plugin_1.default({
130
130
  context: path_1.default.join(projectPath, '/src'),
131
+ failOnError: false,
132
+ failOnWarning: false,
131
133
  extensions: templateType === 'vue' ? ['vue', 'ts', 'js'] : ['tsx', 'ts', 'js'],
132
134
  cache: true
133
135
  })
@@ -3,10 +3,14 @@ export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any
3
3
  export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType['routes'], templateType: any) => any[];
4
4
  export declare const getPort: () => Promise<number>;
5
5
  export declare const themeColor = "#7888FCFF";
6
+ interface ToastOptions {
7
+ wrap: boolean;
8
+ }
6
9
  export declare const toast: {
7
- info: (message: string) => void;
8
- success: (message: string) => void;
10
+ info: (message: string, options?: ToastOptions) => void;
11
+ success: (message: string, options?: ToastOptions) => void;
9
12
  error: (message: string | string[]) => void;
10
13
  warning: (message: string | string[]) => void;
11
14
  };
12
15
  export declare const initIndexFile: () => Promise<void>;
16
+ export {};
@@ -206,11 +206,13 @@ var getPort = function () {
206
206
  exports.getPort = getPort;
207
207
  exports.themeColor = '#7888FCFF';
208
208
  exports.toast = {
209
- info: function (message) {
210
- console.log("".concat(chalk_1.default.hex(exports.themeColor).bold('swico'), " - ").concat(message, "\n"));
209
+ info: function (message, options) {
210
+ var _a = (options || {}).wrap, wrap = _a === void 0 ? true : _a;
211
+ console.log("".concat(chalk_1.default.hex(exports.themeColor).bold('swico'), " - ").concat(message).concat(wrap ? '\n' : ''));
211
212
  },
212
- success: function (message) {
213
- console.log("".concat(chalk_1.default.hex('#32f264').bold('swico'), " - ").concat(message, "\n"));
213
+ success: function (message, options) {
214
+ var _a = (options || {}).wrap, wrap = _a === void 0 ? true : _a;
215
+ console.log("".concat(chalk_1.default.hex('#32f264').bold('swico'), " - ").concat(message).concat(wrap ? '\n' : ''));
214
216
  },
215
217
  error: function (message) {
216
218
  console.log("".concat(chalk_1.default.red.bold('error'), " - There are some errors about Swico\uFF1A \n"));