swico 0.8.1-beta22 → 0.8.1-beta4
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 +6 -3
- package/src/command/start.js +5 -19
- package/src/config/webpack.base.react.js +6 -0
- package/src/config/webpack.base.vue.js +6 -0
- package/src/config/webpack.prod.js +2 -10
- package/src/utils/tools.d.ts +0 -2
- package/src/utils/tools.js +6 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "0.8.1-
|
|
3
|
+
"version": "0.8.1-beta4",
|
|
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.0",
|
|
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,8 +42,11 @@ 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"));
|
|
45
47
|
var tools_1 = require("../utils/tools");
|
|
46
48
|
var package_json_1 = __importDefault(require("../../package.json"));
|
|
49
|
+
var spinner = (0, ora_1.default)();
|
|
47
50
|
function default_1() {
|
|
48
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
49
52
|
var projectConfig, entryPath, templatePath, projectPath, customConfig, templateType, buildConfig, compiler;
|
|
@@ -51,8 +54,8 @@ function default_1() {
|
|
|
51
54
|
switch (_a.label) {
|
|
52
55
|
case 0:
|
|
53
56
|
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...');
|
|
57
|
+
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
58
|
+
tools_1.toast.info('Initializing Swico production config...');
|
|
56
59
|
return [4, (0, tools_1.initIndexFile)()];
|
|
57
60
|
case 1:
|
|
58
61
|
_a.sent();
|
|
@@ -83,7 +86,7 @@ function default_1() {
|
|
|
83
86
|
if (stats.hasWarnings()) {
|
|
84
87
|
tools_1.toast.warning(info.warnings.map(function (item) { return item.stack; }));
|
|
85
88
|
}
|
|
86
|
-
|
|
89
|
+
spinner.succeed("".concat(chalk_1.default.green.bold('Building complete'), " \n"));
|
|
87
90
|
});
|
|
88
91
|
return [2];
|
|
89
92
|
}
|
package/src/command/start.js
CHANGED
|
@@ -60,7 +60,6 @@ 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"));
|
|
64
63
|
var handleWatch = function (projectPath, devServer) {
|
|
65
64
|
var configFilesWatcher = chokidar_1.default
|
|
66
65
|
.watch([
|
|
@@ -123,13 +122,6 @@ var restartServer = function () {
|
|
|
123
122
|
process.exit(1);
|
|
124
123
|
}
|
|
125
124
|
};
|
|
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
|
-
};
|
|
133
125
|
function start() {
|
|
134
126
|
return __awaiter(this, void 0, void 0, function () {
|
|
135
127
|
var _a, projectConfig, projectPath, startConfig, compiler, oriLogger, devServer, e_1, strErr;
|
|
@@ -138,8 +130,8 @@ function start() {
|
|
|
138
130
|
case 0:
|
|
139
131
|
process.env.SWICO_ENV = 'dev';
|
|
140
132
|
if (RESTART !== 'true') {
|
|
141
|
-
tools_1.toast.info("v".concat(package_json_1.default.version));
|
|
142
|
-
tools_1.toast.info('Initializing development config...');
|
|
133
|
+
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
134
|
+
tools_1.toast.info('Initializing Swico development config...');
|
|
143
135
|
}
|
|
144
136
|
return [4, (0, tools_1.initIndexFile)()];
|
|
145
137
|
case 1:
|
|
@@ -162,15 +154,10 @@ function start() {
|
|
|
162
154
|
startConfig = _b.sent();
|
|
163
155
|
compiler = (0, webpack_1.default)(startConfig);
|
|
164
156
|
oriLogger = compiler.getInfrastructureLogger;
|
|
165
|
-
compiler.getInfrastructureLogger =
|
|
157
|
+
compiler.getInfrastructureLogger = function (name) { return ({
|
|
158
|
+
info: function () { }
|
|
159
|
+
}); };
|
|
166
160
|
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
161
|
_b.label = 7;
|
|
175
162
|
case 7:
|
|
176
163
|
_b.trys.push([7, 9, , 10]);
|
|
@@ -179,7 +166,6 @@ function start() {
|
|
|
179
166
|
_b.sent();
|
|
180
167
|
compiler.getInfrastructureLogger = oriLogger;
|
|
181
168
|
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, "/"))));
|
|
183
169
|
return [3, 10];
|
|
184
170
|
case 9:
|
|
185
171
|
e_1 = _b.sent();
|
|
@@ -62,6 +62,7 @@ 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"));
|
|
65
66
|
var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
66
67
|
var fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
67
68
|
var webpack_1 = __importDefault(require("webpack"));
|
|
@@ -270,6 +271,11 @@ function default_1(_a) {
|
|
|
270
271
|
new mini_css_extract_plugin_1.default({
|
|
271
272
|
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
272
273
|
ignoreOrder: true
|
|
274
|
+
}),
|
|
275
|
+
new webpackbar_1.default({
|
|
276
|
+
name: 'Swico',
|
|
277
|
+
color: '#5f72f5',
|
|
278
|
+
profile: false
|
|
273
279
|
})
|
|
274
280
|
], false), ((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins), true)
|
|
275
281
|
}];
|
|
@@ -62,6 +62,7 @@ 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"));
|
|
65
66
|
var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
66
67
|
var fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
67
68
|
var webpack_1 = __importDefault(require("webpack"));
|
|
@@ -287,6 +288,11 @@ function default_1(_a) {
|
|
|
287
288
|
new mini_css_extract_plugin_1.default({
|
|
288
289
|
filename: env === 'dev' ? 'css/[name].css' : 'css/[name].[contenthash].css',
|
|
289
290
|
ignoreOrder: true
|
|
291
|
+
}),
|
|
292
|
+
new webpackbar_1.default({
|
|
293
|
+
name: 'Swico',
|
|
294
|
+
color: '#5f72f5',
|
|
295
|
+
profile: false
|
|
290
296
|
})
|
|
291
297
|
], false), ((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins), true)
|
|
292
298
|
}];
|
|
@@ -89,8 +89,6 @@ 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");
|
|
94
92
|
var BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
|
|
95
93
|
var isAnalyze = process.env.ANALYZE === 'true';
|
|
96
94
|
function default_1(options) {
|
|
@@ -157,7 +155,7 @@ function default_1(options) {
|
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
157
|
},
|
|
160
|
-
plugins: __spreadArray(__spreadArray(__spreadArray(
|
|
158
|
+
plugins: __spreadArray(__spreadArray(__spreadArray([], (isPublicDirExist || copyConfig.length > 0
|
|
161
159
|
? [
|
|
162
160
|
new copy_webpack_plugin_1.default({
|
|
163
161
|
patterns: __spreadArray(__spreadArray([], (isPublicDirExist ? [path_1.default.join(projectPath, '/public')] : []), true), copyConfig, true)
|
|
@@ -178,13 +176,7 @@ function default_1(options) {
|
|
|
178
176
|
logLevel: 'info'
|
|
179
177
|
})
|
|
180
178
|
]
|
|
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)
|
|
179
|
+
: []), true), ((_g = (_f = customConfig.prod) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : []), true)
|
|
188
180
|
})];
|
|
189
181
|
}
|
|
190
182
|
});
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -2,10 +2,8 @@ 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";
|
|
6
5
|
export declare const toast: {
|
|
7
6
|
info: (message: string) => void;
|
|
8
|
-
success: (message: string) => void;
|
|
9
7
|
error: (message: string | string[]) => void;
|
|
10
8
|
warning: (message: string | string[]) => void;
|
|
11
9
|
};
|
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.
|
|
83
|
+
exports.initIndexFile = exports.toast = 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,33 +204,29 @@ var getPort = function () {
|
|
|
204
204
|
});
|
|
205
205
|
};
|
|
206
206
|
exports.getPort = getPort;
|
|
207
|
-
exports.themeColor = '#7888FCFF';
|
|
208
207
|
exports.toast = {
|
|
209
208
|
info: function (message) {
|
|
210
|
-
console.log("".concat(chalk_1.default.hex(
|
|
211
|
-
},
|
|
212
|
-
success: function (message) {
|
|
213
|
-
console.log("".concat(chalk_1.default.hex('#32f264').bold('swico'), " - ").concat(message, "\n"));
|
|
209
|
+
console.log("> ".concat(chalk_1.default.hex('#5f72f5')(message), "\n"));
|
|
214
210
|
},
|
|
215
211
|
error: function (message) {
|
|
216
|
-
console.log("".concat(chalk_1.default.
|
|
212
|
+
console.log("\n> ".concat(chalk_1.default.hex('#5f72f5')('There are some errors about Swico:'), " \n"));
|
|
217
213
|
if (Array.isArray(message)) {
|
|
218
214
|
message.forEach(function (item) {
|
|
219
215
|
console.log(" > ".concat(chalk_1.default.red.bold(item), " \n"));
|
|
220
216
|
});
|
|
221
217
|
}
|
|
222
|
-
else
|
|
218
|
+
else {
|
|
223
219
|
console.log(" > ".concat(chalk_1.default.red.bold(message), " \n"));
|
|
224
220
|
}
|
|
225
221
|
},
|
|
226
222
|
warning: function (message) {
|
|
227
|
-
console.log("".concat(chalk_1.default.
|
|
223
|
+
console.log("\n> ".concat(chalk_1.default.hex('#5f72f5')('There are some warnings about Swico:'), " \n"));
|
|
228
224
|
if (Array.isArray(message)) {
|
|
229
225
|
message.forEach(function (item) {
|
|
230
226
|
console.log(" > ".concat(chalk_1.default.hex('#fb8918').bold(item), " \n"));
|
|
231
227
|
});
|
|
232
228
|
}
|
|
233
|
-
else
|
|
229
|
+
else {
|
|
234
230
|
console.log(" > ".concat(chalk_1.default.hex('#fb8918').bold(message), " \n"));
|
|
235
231
|
}
|
|
236
232
|
}
|