swico 0.8.1-beta9 → 0.8.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": "0.8.1-beta9",
3
+ "version": "0.8.1",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -51,7 +51,7 @@
51
51
  "webpack-cli": "5.1.4",
52
52
  "webpack-dev-server": "4.15.2",
53
53
  "webpack-merge": "5.9.0",
54
- "webpackbar": "6.0.0",
54
+ "webpackbar": "6.0.1",
55
55
  "@babel/types": "7.23.9",
56
56
  "@commitlint/cli": "18.5.0",
57
57
  "@commitlint/config-conventional": "18.5.0",
@@ -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;
@@ -54,8 +51,8 @@ function default_1() {
54
51
  switch (_a.label) {
55
52
  case 0:
56
53
  process.env.SWICO_ENV = 'prod';
57
- tools_1.toast.info("Swico v".concat(package_json_1.default.version));
58
- tools_1.toast.info('Initializing Swico production config...');
54
+ tools_1.toast.info("v".concat(package_json_1.default.version));
55
+ tools_1.toast.info('Initializing production config...');
59
56
  return [4, (0, tools_1.initIndexFile)()];
60
57
  case 1:
61
58
  _a.sent();
@@ -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([
@@ -124,8 +125,9 @@ var restartServer = function () {
124
125
  };
125
126
  var getMockGetLogger = function (compiler) {
126
127
  var logger = compiler.getInfrastructureLogger('name');
128
+ var log = logger.log, debug = logger.debug, error = logger.error, warn = logger.warn;
127
129
  return function (name) {
128
- return __assign(__assign({}, logger), { info: function () { } });
130
+ return __assign(__assign({}, logger), { log: log, debug: debug, error: error, warn: warn, info: function () { } });
129
131
  };
130
132
  };
131
133
  function start() {
@@ -136,8 +138,8 @@ function start() {
136
138
  case 0:
137
139
  process.env.SWICO_ENV = 'dev';
138
140
  if (RESTART !== 'true') {
139
- tools_1.toast.info("Swico v".concat(package_json_1.default.version));
140
- tools_1.toast.info('Initializing Swico development config...');
141
+ tools_1.toast.info("v".concat(package_json_1.default.version));
142
+ tools_1.toast.info('Initializing development config...');
141
143
  }
142
144
  return [4, (0, tools_1.initIndexFile)()];
143
145
  case 1:
@@ -162,6 +164,13 @@ function start() {
162
164
  oriLogger = compiler.getInfrastructureLogger;
163
165
  compiler.getInfrastructureLogger = getMockGetLogger(compiler);
164
166
  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
+ });
165
174
  _b.label = 7;
166
175
  case 7:
167
176
  _b.trys.push([7, 9, , 10]);
@@ -170,7 +179,7 @@ function start() {
170
179
  _b.sent();
171
180
  compiler.getInfrastructureLogger = oriLogger;
172
181
  handleWatch(projectPath, devServer);
173
- tools_1.toast.info("Project is running at:http://localhost:".concat(availablePort, "/"));
182
+ tools_1.toast.info("Project is running at\uFF1A".concat(chalk_1.default.hex('#29abe0')("".concat(startConfig.devServer.server, "://localhost:").concat(availablePort, "/"))));
174
183
  return [3, 10];
175
184
  case 9:
176
185
  e_1 = _b.sent();
@@ -90,6 +90,7 @@ 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
92
  var webpackbar_1 = __importDefault(require("webpackbar"));
93
+ var tools_1 = require("../utils/tools");
93
94
  var BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
94
95
  var isAnalyze = process.env.ANALYZE === 'true';
95
96
  function default_1(options) {
@@ -180,7 +181,7 @@ function default_1(options) {
180
181
  : []), true), [
181
182
  new webpackbar_1.default({
182
183
  name: 'Swico',
183
- color: '#5f72f5',
184
+ color: tools_1.themeColor,
184
185
  profile: false
185
186
  })
186
187
  ], false), ((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : []), true)
@@ -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
  }