@qingtian/qtcli 1.0.0
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/README.md +193 -0
- package/dist/bin/cli.js +11 -0
- package/dist/package.json +209 -0
- package/dist/qt.conf.js +101 -0
- package/dist/src/App.js +10 -0
- package/dist/src/commands/build.js +74 -0
- package/dist/src/commands/dev.js +68 -0
- package/dist/src/commands/index.js +83 -0
- package/dist/src/commands/init.js +128 -0
- package/dist/src/cores/context.js +123 -0
- package/dist/src/index.js +29 -0
- package/dist/src/processEnv/index.js +23 -0
- package/dist/src/processEnv/injector.js +39 -0
- package/dist/src/processEnv/loader.js +201 -0
- package/dist/src/processEnv/manager.js +122 -0
- package/dist/src/processEnv/types.js +2 -0
- package/dist/src/proxys/build/index.js +225 -0
- package/dist/src/proxys/dev/index.js +284 -0
- package/dist/src/proxys/init/index.js +90 -0
- package/dist/src/servers/server.js +46 -0
- package/dist/src/types/baseInterface.js +46 -0
- package/dist/src/types/contextModel.js +21 -0
- package/dist/src/utils/childProcess.js +134 -0
- package/dist/src/utils/env.js +56 -0
- package/dist/src/utils/fileUtils.js +121 -0
- package/dist/src/utils/format.js +23 -0
- package/dist/src/utils/formatOutput.js +242 -0
- package/dist/src/utils/logger.js +70 -0
- package/dist/src/utils/printer.js +148 -0
- package/dist/src/utils/sleep.js +11 -0
- package/dist/src/utils/url.js +42 -0
- package/dist/src/webpack/npm/es.js +127 -0
- package/dist/src/webpack/npm/index.js +100 -0
- package/dist/src/webpack/npm/lib.js +128 -0
- package/dist/src/webpack/npm/webpack.base.js +221 -0
- package/dist/src/webpack/npm/webpack.prod.js +76 -0
- package/dist/src/webpack/plugins/DonePlugin.js +14 -0
- package/dist/src/webpack/plugins/FileListPlugin.js +28 -0
- package/dist/src/webpack/plugins/InjectScriptPlugin.js +33 -0
- package/dist/src/webpack/web/index.js +130 -0
- package/dist/src/webpack/web/webpack.analy.js +10 -0
- package/dist/src/webpack/web/webpack.base.js +419 -0
- package/dist/src/webpack/web/webpack.dev.js +38 -0
- package/dist/src/webpack/web/webpack.prod.js +82 -0
- package/package.json +209 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.formatOutput = exports.formatNode = void 0;
|
|
52
|
+
/* eslint-disable default-case */
|
|
53
|
+
var colors_1 = __importDefault(require("colors"));
|
|
54
|
+
var formatNode = function (node) {
|
|
55
|
+
var type = node.type, title = node.title, content = node.content, _a = node.status, status = _a === void 0 ? 'info' : _a;
|
|
56
|
+
var icon = {
|
|
57
|
+
info: colors_1.default.blue('โ'),
|
|
58
|
+
success: colors_1.default.green('โ'),
|
|
59
|
+
warning: colors_1.default.yellow('โ'),
|
|
60
|
+
error: colors_1.default.red('โ'),
|
|
61
|
+
}[status];
|
|
62
|
+
var titleIcon = {
|
|
63
|
+
start: '๐',
|
|
64
|
+
process: '๐ซ',
|
|
65
|
+
process3: '๐ธ',
|
|
66
|
+
complete: 'โ
',
|
|
67
|
+
info: 'โน๏ธ',
|
|
68
|
+
error: 'โ',
|
|
69
|
+
warning: 'โ ๏ธ',
|
|
70
|
+
success: 'โ
',
|
|
71
|
+
}[type];
|
|
72
|
+
switch (type) {
|
|
73
|
+
case 'start':
|
|
74
|
+
return "\n\u250C ".concat(titleIcon, " ").concat(colors_1.default.magenta(title), "\n\u2502");
|
|
75
|
+
case 'process': {
|
|
76
|
+
if (content) {
|
|
77
|
+
// ๅค่กๅ
ๅฎนๆ ผๅผ
|
|
78
|
+
var contentLines = content
|
|
79
|
+
.split('\n')
|
|
80
|
+
.map(function (line) { return "\u2502 ".concat(colors_1.default.gray(line)); })
|
|
81
|
+
.join('\n');
|
|
82
|
+
return "\u2502\n".concat(icon, " ").concat(titleIcon, " ").concat(colors_1.default.green(title), "\n\u2502\n").concat(contentLines);
|
|
83
|
+
}
|
|
84
|
+
// ๅ่กๅ
ๅฎนๆ ผๅผ
|
|
85
|
+
return "\u2502\n".concat(icon, " ").concat(titleIcon, " ").concat(colors_1.default.green(title), "\n\u2502");
|
|
86
|
+
}
|
|
87
|
+
case 'process3': {
|
|
88
|
+
// ๆ ้ขๅๅ
ๅฎนๅจๅไธ่ก
|
|
89
|
+
if (!content) {
|
|
90
|
+
return "\u2502\n".concat(icon, " ").concat(titleIcon, " ").concat(colors_1.default.green(title), "\n\u2502");
|
|
91
|
+
}
|
|
92
|
+
return "\u2502\n".concat(icon, " ").concat(titleIcon, " ").concat(colors_1.default.green(title), " ").concat(colors_1.default.gray(content));
|
|
93
|
+
}
|
|
94
|
+
case 'complete': {
|
|
95
|
+
return "\u2502\n\u2514 ".concat(titleIcon, " ").concat(colors_1.default.magenta(title), "\n");
|
|
96
|
+
}
|
|
97
|
+
case 'info':
|
|
98
|
+
case 'error':
|
|
99
|
+
case 'warning':
|
|
100
|
+
case 'success': {
|
|
101
|
+
return "\u2502\n".concat(icon, " ").concat(titleIcon, " ").concat(colors_1.default.green(title), "\n\u2502");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return '';
|
|
105
|
+
};
|
|
106
|
+
exports.formatNode = formatNode;
|
|
107
|
+
var formatESLintMessages = function (results, severity) {
|
|
108
|
+
return results
|
|
109
|
+
.filter(function (r) { return r.messages.some(function (m) { return m.severity === severity; }); })
|
|
110
|
+
.map(function (r) {
|
|
111
|
+
var messages = r.messages
|
|
112
|
+
.filter(function (m) { return m.severity === severity; })
|
|
113
|
+
.map(function (m) {
|
|
114
|
+
var severityText = m.severity === 2 ? colors_1.default.red('error') : colors_1.default.yellow('warning');
|
|
115
|
+
var location = colors_1.default.gray.underline("".concat(m.line, ":").concat(m.column));
|
|
116
|
+
var ruleId = m.ruleId ? colors_1.default.cyan(" ".concat(m.ruleId)) : '';
|
|
117
|
+
return "".concat(severityText, " in ").concat(colors_1.default.white(r.filePath), "\n").concat(colors_1.default.gray(m.message)).concat(ruleId, " ").concat(location);
|
|
118
|
+
});
|
|
119
|
+
return messages.join('\n');
|
|
120
|
+
})
|
|
121
|
+
.join('\n');
|
|
122
|
+
};
|
|
123
|
+
exports.formatOutput = {
|
|
124
|
+
build: function (output) { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
+
var nodes, errorMessages, warningMessages, errorText, warningText, timeText, status;
|
|
126
|
+
var _a, _b;
|
|
127
|
+
return __generator(this, function (_c) {
|
|
128
|
+
nodes = [];
|
|
129
|
+
errorMessages = output.errors > 0
|
|
130
|
+
? ((_a = output.buildErrors) === null || _a === void 0 ? void 0 : _a.map(function (error) { return "".concat(colors_1.default.red('ERROR'), " in ").concat(colors_1.default.white("".concat(error.moduleName, "\n").concat(error.message)), "\n").concat(error === null || error === void 0 ? void 0 : error.stack); }).join('\n')) || "".concat(colors_1.default.red(String(output.errors)), " \u4E2A\u9519\u8BEF")
|
|
131
|
+
: 'ๆ ้่ฏฏ';
|
|
132
|
+
nodes.push((0, exports.formatNode)({
|
|
133
|
+
type: 'process',
|
|
134
|
+
title: 'ๆๅปบ้่ฏฏ',
|
|
135
|
+
content: errorMessages,
|
|
136
|
+
status: output.errors > 0 ? 'error' : 'success',
|
|
137
|
+
}));
|
|
138
|
+
warningMessages = output.warnings > 0
|
|
139
|
+
? ((_b = output.buildWarnings) === null || _b === void 0 ? void 0 : _b.map(function (warning) {
|
|
140
|
+
return "".concat(colors_1.default.yellow('WARNING'), " in ").concat(warning.moduleName, "\n").concat(warning.message);
|
|
141
|
+
}).join('\n')) || "".concat(colors_1.default.yellow(String(output.warnings)), " \u4E2A\u8B66\u544A")
|
|
142
|
+
: 'ๆ ่ญฆๅ';
|
|
143
|
+
nodes.push((0, exports.formatNode)({
|
|
144
|
+
type: 'process',
|
|
145
|
+
title: 'ๆๅปบ่ญฆๅ',
|
|
146
|
+
content: warningMessages,
|
|
147
|
+
status: output.warnings > 0 ? 'warning' : 'success',
|
|
148
|
+
}));
|
|
149
|
+
errorText = colors_1.default.red("".concat(output.errors, " \u9519\u8BEF"));
|
|
150
|
+
warningText = colors_1.default.yellow("".concat(output.warnings, " \u8B66\u544A"));
|
|
151
|
+
timeText = colors_1.default.green("\u8017\u65F6 ".concat((output.time / 1000).toFixed(2), "s"));
|
|
152
|
+
status = 'success';
|
|
153
|
+
if (output.errors > 0) {
|
|
154
|
+
status = 'error';
|
|
155
|
+
}
|
|
156
|
+
else if (output.warnings > 0) {
|
|
157
|
+
status = 'warning';
|
|
158
|
+
}
|
|
159
|
+
nodes.push((0, exports.formatNode)({
|
|
160
|
+
type: 'process',
|
|
161
|
+
title: 'ๆๅปบๅฎๆ',
|
|
162
|
+
content: "".concat(errorText, " ").concat(warningText, " ").concat(timeText),
|
|
163
|
+
status: status,
|
|
164
|
+
}));
|
|
165
|
+
return [2 /*return*/, nodes.join('\n')];
|
|
166
|
+
});
|
|
167
|
+
}); },
|
|
168
|
+
buildFiles: function (files) { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
+
var content;
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
content = files
|
|
172
|
+
.map(function (f) { return "".concat(colors_1.default.white(f.name), " ").concat(colors_1.default.gray("(".concat(f.size, ")"))); })
|
|
173
|
+
.join('\n');
|
|
174
|
+
return [2 /*return*/, (0, exports.formatNode)({ type: 'process', title: 'ๆๅปบไบง็ฉ', content: content })];
|
|
175
|
+
});
|
|
176
|
+
}); },
|
|
177
|
+
eslint: function (output) { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
+
var nodes, errorMessages, warningMessages, errorText, warningText, timeText, status;
|
|
179
|
+
return __generator(this, function (_a) {
|
|
180
|
+
nodes = [];
|
|
181
|
+
errorMessages = output.errorCount > 0
|
|
182
|
+
? formatESLintMessages(output.results, 2) ||
|
|
183
|
+
"".concat(colors_1.default.red(String(output.errorCount)), " \u4E2A\u9519\u8BEF")
|
|
184
|
+
: 'ๆ ้่ฏฏ';
|
|
185
|
+
nodes.push((0, exports.formatNode)({
|
|
186
|
+
type: 'process',
|
|
187
|
+
title: 'ESLint้่ฏฏ',
|
|
188
|
+
content: errorMessages,
|
|
189
|
+
status: output.errorCount > 0 ? 'error' : 'success',
|
|
190
|
+
}));
|
|
191
|
+
warningMessages = output.warningCount > 0
|
|
192
|
+
? formatESLintMessages(output.results, 1) ||
|
|
193
|
+
"".concat(colors_1.default.yellow(String(output.warningCount)), " \u4E2A\u8B66\u544A")
|
|
194
|
+
: 'ๆ ่ญฆๅ';
|
|
195
|
+
nodes.push((0, exports.formatNode)({
|
|
196
|
+
type: 'process',
|
|
197
|
+
title: 'ESLint่ญฆๅ',
|
|
198
|
+
content: warningMessages,
|
|
199
|
+
status: output.warningCount > 0 ? 'warning' : 'success',
|
|
200
|
+
}));
|
|
201
|
+
errorText = colors_1.default.red("".concat(output.errorCount, " \u9519\u8BEF"));
|
|
202
|
+
warningText = colors_1.default.yellow("".concat(output.warningCount, " \u8B66\u544A"));
|
|
203
|
+
timeText = output.time ? colors_1.default.green("\u8017\u65F6 ".concat((output.time / 1000).toFixed(2), "s")) : '';
|
|
204
|
+
status = 'success';
|
|
205
|
+
if (output.errorCount > 0) {
|
|
206
|
+
status = 'error';
|
|
207
|
+
}
|
|
208
|
+
else if (output.warningCount > 0) {
|
|
209
|
+
status = 'warning';
|
|
210
|
+
}
|
|
211
|
+
nodes.push((0, exports.formatNode)({
|
|
212
|
+
type: 'process',
|
|
213
|
+
title: 'ESLintๆฃๆฅๅฎๆ',
|
|
214
|
+
content: "".concat(errorText, " ").concat(warningText, " ").concat(timeText),
|
|
215
|
+
status: status,
|
|
216
|
+
}));
|
|
217
|
+
return [2 /*return*/, nodes.join('\n')];
|
|
218
|
+
});
|
|
219
|
+
}); },
|
|
220
|
+
service: function (output) { return __awaiter(void 0, void 0, void 0, function () {
|
|
221
|
+
var stats, _a, errors, warnings, time, errorText, warningText, timeText, _b, errors, warnings, time, errorText, warningText, timeText, content;
|
|
222
|
+
return __generator(this, function (_c) {
|
|
223
|
+
stats = [];
|
|
224
|
+
if (output.buildStats) {
|
|
225
|
+
_a = output.buildStats, errors = _a.errors, warnings = _a.warnings, time = _a.time;
|
|
226
|
+
errorText = colors_1.default.red("".concat(errors, " \u9519\u8BEF"));
|
|
227
|
+
warningText = colors_1.default.yellow("".concat(warnings, " \u8B66\u544A"));
|
|
228
|
+
timeText = colors_1.default.green("".concat((time / 1000).toFixed(2), "s"));
|
|
229
|
+
stats.push("".concat(colors_1.default.white('ๆๅปบ'), " ").concat(errorText, " ").concat(warningText, " ").concat(timeText));
|
|
230
|
+
}
|
|
231
|
+
if (output.eslintStats) {
|
|
232
|
+
_b = output.eslintStats, errors = _b.errors, warnings = _b.warnings, time = _b.time;
|
|
233
|
+
errorText = colors_1.default.red("".concat(errors, " \u9519\u8BEF"));
|
|
234
|
+
warningText = colors_1.default.yellow("".concat(warnings, " \u8B66\u544A"));
|
|
235
|
+
timeText = colors_1.default.green("".concat((time / 1000).toFixed(2), "s"));
|
|
236
|
+
stats.push("".concat(colors_1.default.white('ESLint'), " ").concat(errorText, " ").concat(warningText, " ").concat(timeText));
|
|
237
|
+
}
|
|
238
|
+
content = __spreadArray(__spreadArray([], stats, true), ["".concat(colors_1.default.white('ๅผๅๆๅกๅจ'), " ").concat(colors_1.default.cyan(output.url))], false).join('\n');
|
|
239
|
+
return [2 /*return*/, (0, exports.formatNode)({ type: 'process', title: 'ๆๅกๅฏๅจ', content: content })];
|
|
240
|
+
});
|
|
241
|
+
}); },
|
|
242
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.logMemoryUsage = exports.logInfo = exports.logError = exports.logSuccess = exports.logStart = void 0;
|
|
27
|
+
var pkg = __importStar(require("../../package.json"));
|
|
28
|
+
var formatOutput_1 = require("../utils/formatOutput");
|
|
29
|
+
var logStart = function () {
|
|
30
|
+
console.log((0, formatOutput_1.formatNode)({
|
|
31
|
+
type: 'start',
|
|
32
|
+
title: 'QTCli ๅทฅ็จๅบๅบง',
|
|
33
|
+
}));
|
|
34
|
+
console.log((0, formatOutput_1.formatNode)({
|
|
35
|
+
type: 'process3',
|
|
36
|
+
title: '็ๆฌ',
|
|
37
|
+
content: pkg.version,
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
exports.logStart = logStart;
|
|
41
|
+
var logSuccess = function (message) {
|
|
42
|
+
console.log((0, formatOutput_1.formatNode)({
|
|
43
|
+
type: 'success',
|
|
44
|
+
title: message,
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
exports.logSuccess = logSuccess;
|
|
48
|
+
var logError = function (message) {
|
|
49
|
+
console.log((0, formatOutput_1.formatNode)({
|
|
50
|
+
type: 'error',
|
|
51
|
+
title: message,
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
exports.logError = logError;
|
|
55
|
+
var logInfo = function (message) {
|
|
56
|
+
console.log((0, formatOutput_1.formatNode)({
|
|
57
|
+
type: 'info',
|
|
58
|
+
title: message,
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
exports.logInfo = logInfo;
|
|
62
|
+
var logMemoryUsage = function () {
|
|
63
|
+
var used = process.memoryUsage();
|
|
64
|
+
console.log((0, formatOutput_1.formatNode)({
|
|
65
|
+
type: 'info',
|
|
66
|
+
title: 'Memory Usage',
|
|
67
|
+
content: "\n heapTotal: ".concat(Math.round(used.heapTotal / 1024 / 1024), "MB\n heapUsed: ").concat(Math.round(used.heapUsed / 1024 / 1024), "MB\n rss: ").concat(Math.round(used.rss / 1024 / 1024), "MB\n "),
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
exports.logMemoryUsage = logMemoryUsage;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// var colors = require('colors');
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.printer = exports.upArrow = exports.downArrow = void 0;
|
|
8
|
+
var colors_1 = __importDefault(require("colors"));
|
|
9
|
+
exports.downArrow = 'โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ';
|
|
10
|
+
exports.upArrow = 'โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ';
|
|
11
|
+
colors_1.default.setTheme({
|
|
12
|
+
log: 'white',
|
|
13
|
+
info: 'green',
|
|
14
|
+
data: 'blue',
|
|
15
|
+
help: 'cyan',
|
|
16
|
+
warn: 'yellow',
|
|
17
|
+
debug: 'magenta',
|
|
18
|
+
error: 'red',
|
|
19
|
+
tip: 'cyan',
|
|
20
|
+
mix: 'rainbow',
|
|
21
|
+
});
|
|
22
|
+
function warn() {
|
|
23
|
+
var args = [];
|
|
24
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
25
|
+
args[_i] = arguments[_i];
|
|
26
|
+
}
|
|
27
|
+
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
|
28
|
+
var arg = args_1[_a];
|
|
29
|
+
exports.printer.data(colors_1.default.yellow(arg.toString()));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function mix() {
|
|
33
|
+
var args = [];
|
|
34
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
35
|
+
args[_i] = arguments[_i];
|
|
36
|
+
}
|
|
37
|
+
for (var _a = 0, args_2 = args; _a < args_2.length; _a++) {
|
|
38
|
+
var arg = args_2[_a];
|
|
39
|
+
exports.printer.data(colors_1.default.america(arg.toString()));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function error() {
|
|
43
|
+
var args = [];
|
|
44
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
45
|
+
args[_i] = arguments[_i];
|
|
46
|
+
}
|
|
47
|
+
for (var _a = 0, args_3 = args; _a < args_3.length; _a++) {
|
|
48
|
+
var arg = args_3[_a];
|
|
49
|
+
exports.printer.data(colors_1.default.red(arg.toString()));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function debug() {
|
|
53
|
+
var args = [];
|
|
54
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
55
|
+
args[_i] = arguments[_i];
|
|
56
|
+
}
|
|
57
|
+
for (var _a = 0, args_4 = args; _a < args_4.length; _a++) {
|
|
58
|
+
var arg = args_4[_a];
|
|
59
|
+
exports.printer.data(colors_1.default.yellow(arg.toString()));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function data() {
|
|
63
|
+
var args = [];
|
|
64
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
65
|
+
args[_i] = arguments[_i];
|
|
66
|
+
}
|
|
67
|
+
for (var _a = 0, args_5 = args; _a < args_5.length; _a++) {
|
|
68
|
+
var arg = args_5[_a];
|
|
69
|
+
console.log(colors_1.default.gray("\uD83D\uDC33 ".concat(arg.toString())));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function help() {
|
|
73
|
+
var args = [];
|
|
74
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
75
|
+
args[_i] = arguments[_i];
|
|
76
|
+
}
|
|
77
|
+
for (var _a = 0, args_6 = args; _a < args_6.length; _a++) {
|
|
78
|
+
var arg = args_6[_a];
|
|
79
|
+
exports.printer.data(colors_1.default.cyan(arg.toString()));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function info() {
|
|
83
|
+
var args = [];
|
|
84
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
85
|
+
args[_i] = arguments[_i];
|
|
86
|
+
}
|
|
87
|
+
for (var _a = 0, args_7 = args; _a < args_7.length; _a++) {
|
|
88
|
+
var arg = args_7[_a];
|
|
89
|
+
exports.printer.data(colors_1.default.green(arg.toString()));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function log() {
|
|
93
|
+
var args = [];
|
|
94
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
95
|
+
args[_i] = arguments[_i];
|
|
96
|
+
}
|
|
97
|
+
for (var _a = 0, args_8 = args; _a < args_8.length; _a++) {
|
|
98
|
+
var arg = args_8[_a];
|
|
99
|
+
exports.printer.data(colors_1.default.gray(arg.toString()));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function tip() {
|
|
103
|
+
var args = [];
|
|
104
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
105
|
+
args[_i] = arguments[_i];
|
|
106
|
+
}
|
|
107
|
+
for (var _a = 0, args_9 = args; _a < args_9.length; _a++) {
|
|
108
|
+
var arg = args_9[_a];
|
|
109
|
+
exports.printer.data(colors_1.default.blue(arg.toString()));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function format(fmt) {
|
|
113
|
+
var date = new Date();
|
|
114
|
+
var o = {
|
|
115
|
+
'M+': date.getMonth() + 1,
|
|
116
|
+
'd+': date.getDate(),
|
|
117
|
+
'H+': date.getHours(),
|
|
118
|
+
'm+': date.getMinutes(),
|
|
119
|
+
's+': date.getSeconds(),
|
|
120
|
+
'q+': Math.floor((date.getMonth() + 3) / 3),
|
|
121
|
+
S: date.getMilliseconds(), // ๆฏซ็ง
|
|
122
|
+
};
|
|
123
|
+
// ๅค็ๅนดไปฝ
|
|
124
|
+
fmt = fmt.replace(/(y+)/, function (match) {
|
|
125
|
+
var year = date.getFullYear().toString();
|
|
126
|
+
return year.substr(4 - match.length);
|
|
127
|
+
});
|
|
128
|
+
var _loop_1 = function (k) {
|
|
129
|
+
var regex = new RegExp("(".concat(k, ")"));
|
|
130
|
+
fmt = fmt.replace(regex, function (match) {
|
|
131
|
+
var value = o[k].toString();
|
|
132
|
+
return match.length === 1 ? value : value.padStart(2, '0');
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
// ๅค็ๅ
ถไปๆฅๆ้จๅ
|
|
136
|
+
for (var k in o) {
|
|
137
|
+
_loop_1(k);
|
|
138
|
+
}
|
|
139
|
+
return fmt;
|
|
140
|
+
}
|
|
141
|
+
function bundle(title, type) {
|
|
142
|
+
if (type === 'up')
|
|
143
|
+
console.log('\n');
|
|
144
|
+
exports.printer.log("".concat(type === 'up' ? exports.upArrow : exports.downArrow).concat(title).concat(type === 'up' ? exports.upArrow : exports.downArrow));
|
|
145
|
+
if (type === 'down')
|
|
146
|
+
console.log('\n');
|
|
147
|
+
}
|
|
148
|
+
exports.printer = { warn: warn, error: error, debug: debug, data: data, help: help, info: info, log: log, tip: tip, mix: mix, bundle: bundle, format: format };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function default_1(fun, delay) {
|
|
4
|
+
return new Promise(function (resolve) {
|
|
5
|
+
setTimeout(function () {
|
|
6
|
+
fun();
|
|
7
|
+
resolve(1);
|
|
8
|
+
}, delay);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.utils = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-shadow */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
6
|
+
var utils;
|
|
7
|
+
(function (utils) {
|
|
8
|
+
var url;
|
|
9
|
+
(function (url_1) {
|
|
10
|
+
function parseURL(url) {
|
|
11
|
+
var pattern =
|
|
12
|
+
// eslint-disable-next-line no-useless-escape
|
|
13
|
+
/^(?:(\w+):\/\/)?(?:(\w+):?(\w+)?@)?([^:\/\?#]+)(?::(\d+))?(\/[^\?#]+)?(?:\?([^#]+))?(?:#(\w+))?/;
|
|
14
|
+
var arr = pattern.exec(url) || [];
|
|
15
|
+
var hostname = arr[4];
|
|
16
|
+
var port = arr[5];
|
|
17
|
+
var protocol = "".concat(arr[1], ":");
|
|
18
|
+
var host = port ? "".concat(hostname, ":").concat(port) : hostname;
|
|
19
|
+
var href = arr[0];
|
|
20
|
+
var origin = "".concat(protocol, "//").concat(host);
|
|
21
|
+
var hash = "#".concat(arr[8]);
|
|
22
|
+
var hostnameKey = arr[2];
|
|
23
|
+
var hostnameValue = arr[3];
|
|
24
|
+
var path = arr[6];
|
|
25
|
+
var search = "?".concat(arr[7]);
|
|
26
|
+
return {
|
|
27
|
+
hash: hash,
|
|
28
|
+
host: host,
|
|
29
|
+
hostname: hostname,
|
|
30
|
+
href: href,
|
|
31
|
+
origin: origin,
|
|
32
|
+
path: path,
|
|
33
|
+
port: port,
|
|
34
|
+
protocol: protocol,
|
|
35
|
+
search: search,
|
|
36
|
+
hosenameKey: hostnameKey,
|
|
37
|
+
hostnameValue: hostnameValue,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
url_1.parseURL = parseURL;
|
|
41
|
+
})(url = utils.url || (utils.url = {}));
|
|
42
|
+
})(utils = exports.utils || (exports.utils = {}));
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
/* eslint-disable no-async-promise-executor */
|
|
40
|
+
var babelDir = require('@babel/cli/lib/babel/dir').default;
|
|
41
|
+
var _a = require('../../utils/childProcess'), execPromise = _a.execPromise, forkPromise = _a.forkPromise;
|
|
42
|
+
var path = require('path');
|
|
43
|
+
var rimraf = require('rimraf').rimraf;
|
|
44
|
+
exports.default = (function () {
|
|
45
|
+
return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var rm, err_1;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
_a.trys.push([0, 2, , 3]);
|
|
51
|
+
return [4 /*yield*/, rimraf.rimraf('es', {})];
|
|
52
|
+
case 1:
|
|
53
|
+
rm = _a.sent();
|
|
54
|
+
if (rm) {
|
|
55
|
+
console.log('ๅ ้คes/ๆๅ');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log('ๅ ้คes/ๅคฑ่ดฅ');
|
|
59
|
+
}
|
|
60
|
+
babelDir({
|
|
61
|
+
cliOptions: {
|
|
62
|
+
filenames: ['src/'],
|
|
63
|
+
outDir: 'es/',
|
|
64
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
|
65
|
+
copyFiles: true,
|
|
66
|
+
},
|
|
67
|
+
babelOptions: {
|
|
68
|
+
ignore: ['**/.d.ts'],
|
|
69
|
+
sourceMaps: true,
|
|
70
|
+
presets: [
|
|
71
|
+
[
|
|
72
|
+
require.resolve('@babel/preset-env'),
|
|
73
|
+
{
|
|
74
|
+
modules: false,
|
|
75
|
+
targets: {
|
|
76
|
+
node: 'current',
|
|
77
|
+
},
|
|
78
|
+
corejs: 3,
|
|
79
|
+
useBuiltIns: 'entry',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
require.resolve('@babel/preset-react'),
|
|
84
|
+
{
|
|
85
|
+
runtime: 'automatic',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
require.resolve('@babel/preset-flow'),
|
|
89
|
+
require.resolve('@babel/preset-typescript'),
|
|
90
|
+
],
|
|
91
|
+
plugins: [
|
|
92
|
+
[
|
|
93
|
+
require.resolve('@babel/plugin-transform-runtime'),
|
|
94
|
+
{
|
|
95
|
+
useEsModules: true,
|
|
96
|
+
absoluteRuntime: false,
|
|
97
|
+
corejs: false,
|
|
98
|
+
helpers: true,
|
|
99
|
+
regenerator: true,
|
|
100
|
+
version: '7.0.0-beta.0',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
require.resolve('@babel/plugin-syntax-flow'),
|
|
104
|
+
require.resolve('@babel/plugin-transform-typescript'),
|
|
105
|
+
require.resolve('@babel/plugin-transform-flow-strip-types'),
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
forkPromise('node_modules/.bin/tsc', ['--outDir', 'es', '--declaration', '--emitDeclarationOnly', '--listEmittedFiles'], {
|
|
110
|
+
cwd: path.resolve(process.cwd(), './'),
|
|
111
|
+
}).then(function () {
|
|
112
|
+
console.log('็ๆ.d.tsๅฎๆ');
|
|
113
|
+
execPromise('cp src/global.d.ts es/');
|
|
114
|
+
resolve(true);
|
|
115
|
+
}, function (err) {
|
|
116
|
+
reject(err);
|
|
117
|
+
});
|
|
118
|
+
return [3 /*break*/, 3];
|
|
119
|
+
case 2:
|
|
120
|
+
err_1 = _a.sent();
|
|
121
|
+
reject(err_1);
|
|
122
|
+
return [3 /*break*/, 3];
|
|
123
|
+
case 3: return [2 /*return*/];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}); });
|
|
127
|
+
});
|