swico 0.8.2-beta3 → 0.8.2-beta5
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 +2 -2
- package/src/command/start.js +15 -13
- package/src/utils/tools.d.ts +6 -2
- package/src/utils/tools.js +6 -4
package/package.json
CHANGED
package/src/command/build.js
CHANGED
|
@@ -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();
|
package/src/command/start.js
CHANGED
|
@@ -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([
|
|
@@ -138,8 +140,8 @@ function start() {
|
|
|
138
140
|
case 0:
|
|
139
141
|
process.env.SWICO_ENV = 'dev';
|
|
140
142
|
if (RESTART !== 'true') {
|
|
141
|
-
tools_1.toast.info("v".concat(package_json_1.default.version));
|
|
142
|
-
tools_1.toast.info('Initializing development config...');
|
|
143
|
+
tools_1.toast.info("v".concat(package_json_1.default.version), { wrap: false });
|
|
144
|
+
tools_1.toast.info('Initializing development config...', { wrap: false });
|
|
143
145
|
}
|
|
144
146
|
return [4, (0, tools_1.initIndexFile)()];
|
|
145
147
|
case 1:
|
|
@@ -164,25 +166,25 @@ function start() {
|
|
|
164
166
|
oriLogger = compiler.getInfrastructureLogger;
|
|
165
167
|
compiler.getInfrastructureLogger = getMockGetLogger(compiler);
|
|
166
168
|
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
169
|
_b.label = 7;
|
|
178
170
|
case 7:
|
|
179
171
|
_b.trys.push([7, 9, , 10]);
|
|
180
172
|
return [4, devServer.start()];
|
|
181
173
|
case 8:
|
|
182
174
|
_b.sent();
|
|
175
|
+
compiler.hooks.beforeCompile.tap('beforeCompile', function () {
|
|
176
|
+
tools_1.toast.info('Compiling...', { wrap: false });
|
|
177
|
+
});
|
|
178
|
+
compiler.hooks.done.tap('done', function (stats) {
|
|
179
|
+
var info = stats.toJson();
|
|
180
|
+
if (stats.hasErrors() || stats.hasWarnings()) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
tools_1.toast.info("Compiled complete in ".concat(info.time, "ms"));
|
|
184
|
+
});
|
|
183
185
|
compiler.getInfrastructureLogger = oriLogger;
|
|
184
186
|
handleWatch(projectPath, devServer);
|
|
185
|
-
tools_1.toast.info("Project is running at\uFF1A".concat(chalk_1.default.hex('#29abe0')("".concat(startConfig.devServer.server, "://localhost:").concat(availablePort, "/"))));
|
|
187
|
+
tools_1.toast.info("Project is running at\uFF1A".concat(chalk_1.default.hex('#29abe0')("".concat(startConfig.devServer.server, "://localhost:").concat(availablePort, "/"))), { wrap: false });
|
|
186
188
|
return [3, 10];
|
|
187
189
|
case 9:
|
|
188
190
|
e_1 = _b.sent();
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -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 {};
|
package/src/utils/tools.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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"));
|