swico 0.8.1-beta2 → 0.8.1-beta20
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 +1 -1
- package/src/command/build.js +1 -4
- package/src/command/start.js +28 -4
- package/src/config/webpack.base.react.js +0 -6
- package/src/config/webpack.base.vue.js +0 -6
- package/src/config/webpack.prod.js +10 -2
- package/src/utils/tools.d.ts +2 -0
- package/src/utils/tools.js +10 -4
package/package.json
CHANGED
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;
|
|
@@ -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([
|
|
@@ -122,9 +123,16 @@ 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,
|
|
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:
|
|
@@ -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
|
-
|
|
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),
|
|
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
|
});
|
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,12 +80,14 @@ 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"));
|
|
87
87
|
var chalk_1 = __importDefault(require("chalk"));
|
|
88
88
|
var process = __importStar(require("process"));
|
|
89
|
+
var ora_1 = __importDefault(require("ora"));
|
|
90
|
+
var spinner = (0, ora_1.default)();
|
|
89
91
|
var copyDirFiles = function (src, dest, filter) { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
92
|
var _copy, e_1;
|
|
91
93
|
return __generator(this, function (_a) {
|
|
@@ -204,12 +206,16 @@ var getPort = function () {
|
|
|
204
206
|
});
|
|
205
207
|
};
|
|
206
208
|
exports.getPort = getPort;
|
|
209
|
+
exports.themeColor = '#7888FCFF';
|
|
207
210
|
exports.toast = {
|
|
208
211
|
info: function (message) {
|
|
209
|
-
console.log("
|
|
212
|
+
console.log("".concat(chalk_1.default.hex(exports.themeColor)('info'), " - ").concat(message, "\n"));
|
|
213
|
+
},
|
|
214
|
+
success: function (message) {
|
|
215
|
+
console.log("".concat(chalk_1.default.hex('#32f264')('info'), " - ").concat(message, "\n"));
|
|
210
216
|
},
|
|
211
217
|
error: function (message) {
|
|
212
|
-
console.log("
|
|
218
|
+
console.log("".concat(chalk_1.default.red('error'), " - There are some errors about Swico\uFF1A \n"));
|
|
213
219
|
if (Array.isArray(message)) {
|
|
214
220
|
message.forEach(function (item) {
|
|
215
221
|
console.log(" > ".concat(chalk_1.default.red.bold(item), " \n"));
|
|
@@ -220,7 +226,7 @@ exports.toast = {
|
|
|
220
226
|
}
|
|
221
227
|
},
|
|
222
228
|
warning: function (message) {
|
|
223
|
-
console.log("
|
|
229
|
+
console.log("".concat(chalk_1.default.red('#fb8918'), " - There are some errors about Swico\uFF1A \n"));
|
|
224
230
|
if (Array.isArray(message)) {
|
|
225
231
|
message.forEach(function (item) {
|
|
226
232
|
console.log(" > ".concat(chalk_1.default.hex('#fb8918').bold(item), " \n"));
|