swico 0.8.1-beta9 → 0.8.2-beta1
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 +2 -2
- package/src/command/build.js +3 -6
- package/src/command/start.js +23 -4
- package/src/config/webpack.prod.js +2 -1
- package/src/utils/tools.d.ts +2 -0
- package/src/utils/tools.js +10 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-beta1",
|
|
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.
|
|
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",
|
package/src/command/build.js
CHANGED
|
@@ -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("
|
|
58
|
-
tools_1.toast.info('Initializing
|
|
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
|
-
|
|
86
|
+
tools_1.toast.success('Building complete');
|
|
90
87
|
});
|
|
91
88
|
return [2];
|
|
92
89
|
}
|
package/src/command/start.js
CHANGED
|
@@ -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("
|
|
140
|
-
tools_1.toast.info('Initializing
|
|
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,23 @@ 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.hooks.beforeCompile.tap('xxx', function () {
|
|
168
|
+
tools_1.toast.info('Compiling...');
|
|
169
|
+
});
|
|
170
|
+
compiler.hooks.done.tap('yyy', function (stats) {
|
|
171
|
+
var info = stats.toJson();
|
|
172
|
+
if (stats.hasErrors() || stats.hasWarnings()) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
tools_1.toast.info("Compiled successfully in ".concat(info.time, "ms"));
|
|
176
|
+
});
|
|
177
|
+
compiler.watch({}, function (err, stats) {
|
|
178
|
+
var info = stats.toJson();
|
|
179
|
+
if (err || stats.hasErrors() || stats.hasWarnings()) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
tools_1.toast.info("Compiled successfully in ".concat(info.time, "ms"));
|
|
183
|
+
});
|
|
165
184
|
_b.label = 7;
|
|
166
185
|
case 7:
|
|
167
186
|
_b.trys.push([7, 9, , 10]);
|
|
@@ -170,7 +189,7 @@ function start() {
|
|
|
170
189
|
_b.sent();
|
|
171
190
|
compiler.getInfrastructureLogger = oriLogger;
|
|
172
191
|
handleWatch(projectPath, devServer);
|
|
173
|
-
tools_1.toast.info("Project is running at
|
|
192
|
+
tools_1.toast.info("Project is running at\uFF1A".concat(chalk_1.default.hex('#29abe0')("".concat(startConfig.devServer.server, "://localhost:").concat(availablePort, "/"))));
|
|
174
193
|
return [3, 10];
|
|
175
194
|
case 9:
|
|
176
195
|
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:
|
|
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)
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -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
|
};
|
package/src/utils/tools.js
CHANGED
|
@@ -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("
|
|
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("
|
|
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("
|
|
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
|
}
|