prebundle 1.4.2 → 1.6.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/bin.js +25 -1
- package/compiled/fast-glob/index.js +190 -190
- package/compiled/fs-extra/index.d.ts +3 -2
- package/compiled/fs-extra/index.js +180 -157
- package/compiled/fs-extra/package.json +1 -1
- package/compiled/rslog/index.d.ts +4 -3
- package/compiled/rslog/index.js +145 -183
- package/compiled/rslog/package.json +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +27 -23
- package/package.json +17 -12
|
@@ -32,7 +32,7 @@ declare let LOG_TYPES: {
|
|
|
32
32
|
color: ColorFn;
|
|
33
33
|
};
|
|
34
34
|
log: {
|
|
35
|
-
level: "
|
|
35
|
+
level: "info";
|
|
36
36
|
};
|
|
37
37
|
debug: {
|
|
38
38
|
label: string;
|
|
@@ -41,7 +41,7 @@ declare let LOG_TYPES: {
|
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
type LogLevel = 'error' | 'warn' | 'info' | 'log' | 'verbose';
|
|
44
|
+
type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
|
|
45
45
|
type LogMessage = unknown;
|
|
46
46
|
interface LogType {
|
|
47
47
|
label?: string;
|
|
@@ -63,4 +63,5 @@ declare let createLogger: (options?: Options) => Logger;
|
|
|
63
63
|
|
|
64
64
|
declare let logger: Logger;
|
|
65
65
|
|
|
66
|
-
export {
|
|
66
|
+
export { createLogger, logger };
|
|
67
|
+
export type { LogFunction, LogLevel, LogMessage, LogType, Logger, Options };
|
package/compiled/rslog/index.js
CHANGED
|
@@ -1,110 +1,97 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
module.exports = require("os");
|
|
4
|
+
161: (module) => {
|
|
5
|
+
module.exports = require("node:os");
|
|
6
6
|
},
|
|
7
|
-
|
|
8
|
-
module.exports = require("process");
|
|
7
|
+
708: (module) => {
|
|
8
|
+
module.exports = require("node:process");
|
|
9
9
|
},
|
|
10
|
-
|
|
11
|
-
module.exports = require("tty");
|
|
10
|
+
66: (module) => {
|
|
11
|
+
module.exports = require("node:tty");
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if ((from && typeof from === "object") || typeof from === "function") {
|
|
26
|
-
for (let key of __getOwnPropNames(from))
|
|
27
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
-
__defProp(to, key, {
|
|
29
|
-
get: () => from[key],
|
|
30
|
-
enumerable:
|
|
31
|
-
!(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
13
|
+
838: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
14
|
+
var __nested_webpack_require_18__ = {};
|
|
15
|
+
(() => {
|
|
16
|
+
__nested_webpack_require_18__.d = (exports1, definition) => {
|
|
17
|
+
for (var key in definition)
|
|
18
|
+
if (
|
|
19
|
+
__nested_webpack_require_18__.o(definition, key) &&
|
|
20
|
+
!__nested_webpack_require_18__.o(exports1, key)
|
|
21
|
+
)
|
|
22
|
+
Object.defineProperty(exports1, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: definition[key],
|
|
32
25
|
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
(() => {
|
|
29
|
+
__nested_webpack_require_18__.o = (obj, prop) =>
|
|
30
|
+
Object.prototype.hasOwnProperty.call(obj, prop);
|
|
31
|
+
})();
|
|
32
|
+
(() => {
|
|
33
|
+
__nested_webpack_require_18__.r = (exports1) => {
|
|
34
|
+
if ("undefined" != typeof Symbol && Symbol.toStringTag)
|
|
35
|
+
Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
36
|
+
value: "Module",
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports1, "__esModule", { value: true });
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __nested_webpack_exports__ = {};
|
|
42
|
+
__nested_webpack_require_18__.r(__nested_webpack_exports__);
|
|
43
|
+
__nested_webpack_require_18__.d(__nested_webpack_exports__, {
|
|
44
|
+
logger: () => src_logger,
|
|
49
45
|
createLogger: () => createLogger,
|
|
50
|
-
logger: () => logger,
|
|
51
46
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var import_node_tty = __toESM(__nccwpck_require__(18));
|
|
47
|
+
const external_node_process_namespaceObject = __nccwpck_require__(708);
|
|
48
|
+
const external_node_os_namespaceObject = __nccwpck_require__(161);
|
|
49
|
+
const external_node_tty_namespaceObject = __nccwpck_require__(66);
|
|
56
50
|
function hasFlag(
|
|
57
51
|
flag,
|
|
58
52
|
argv = globalThis.Deno
|
|
59
53
|
? globalThis.Deno.args
|
|
60
|
-
:
|
|
54
|
+
: external_node_process_namespaceObject.argv,
|
|
61
55
|
) {
|
|
62
56
|
const prefix = flag.startsWith("-")
|
|
63
57
|
? ""
|
|
64
|
-
: flag.length
|
|
58
|
+
: 1 === flag.length
|
|
65
59
|
? "-"
|
|
66
60
|
: "--";
|
|
67
61
|
const position = argv.indexOf(prefix + flag);
|
|
68
62
|
const terminatorPosition = argv.indexOf("--");
|
|
69
63
|
return (
|
|
70
|
-
|
|
71
|
-
(
|
|
64
|
+
-1 !== position &&
|
|
65
|
+
(-1 === terminatorPosition || position < terminatorPosition)
|
|
72
66
|
);
|
|
73
67
|
}
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
const { env } = external_node_process_namespaceObject;
|
|
69
|
+
let flagForceColor;
|
|
76
70
|
if (
|
|
77
71
|
hasFlag("no-color") ||
|
|
78
72
|
hasFlag("no-colors") ||
|
|
79
73
|
hasFlag("color=false") ||
|
|
80
74
|
hasFlag("color=never")
|
|
81
|
-
)
|
|
75
|
+
)
|
|
82
76
|
flagForceColor = 0;
|
|
83
|
-
|
|
77
|
+
else if (
|
|
84
78
|
hasFlag("color") ||
|
|
85
79
|
hasFlag("colors") ||
|
|
86
80
|
hasFlag("color=true") ||
|
|
87
81
|
hasFlag("color=always")
|
|
88
|
-
)
|
|
82
|
+
)
|
|
89
83
|
flagForceColor = 1;
|
|
90
|
-
}
|
|
91
84
|
function envForceColor() {
|
|
92
|
-
if ("FORCE_COLOR" in env)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return env.FORCE_COLOR.length === 0
|
|
100
|
-
? 1
|
|
101
|
-
: Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
102
|
-
}
|
|
85
|
+
if (!("FORCE_COLOR" in env)) return;
|
|
86
|
+
if ("true" === env.FORCE_COLOR) return 1;
|
|
87
|
+
if ("false" === env.FORCE_COLOR) return 0;
|
|
88
|
+
if (0 === env.FORCE_COLOR.length) return 1;
|
|
89
|
+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
90
|
+
if (![0, 1, 2, 3].includes(level)) return;
|
|
91
|
+
return level;
|
|
103
92
|
}
|
|
104
93
|
function translateLevel(level) {
|
|
105
|
-
if (
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
94
|
+
if (0 === level) return false;
|
|
108
95
|
return {
|
|
109
96
|
level,
|
|
110
97
|
hasBasic: true,
|
|
@@ -117,99 +104,73 @@
|
|
|
117
104
|
{ streamIsTTY, sniffFlags = true } = {},
|
|
118
105
|
) {
|
|
119
106
|
const noFlagForceColor = envForceColor();
|
|
120
|
-
if (
|
|
121
|
-
flagForceColor = noFlagForceColor;
|
|
122
|
-
}
|
|
107
|
+
if (void 0 !== noFlagForceColor) flagForceColor = noFlagForceColor;
|
|
123
108
|
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
124
|
-
if (
|
|
125
|
-
return 0;
|
|
126
|
-
}
|
|
109
|
+
if (0 === forceColor) return 0;
|
|
127
110
|
if (sniffFlags) {
|
|
128
111
|
if (
|
|
129
112
|
hasFlag("color=16m") ||
|
|
130
113
|
hasFlag("color=full") ||
|
|
131
114
|
hasFlag("color=truecolor")
|
|
132
|
-
)
|
|
115
|
+
)
|
|
133
116
|
return 3;
|
|
134
|
-
|
|
135
|
-
if (hasFlag("color=256")) {
|
|
136
|
-
return 2;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
140
|
-
return 1;
|
|
141
|
-
}
|
|
142
|
-
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
143
|
-
return 0;
|
|
117
|
+
if (hasFlag("color=256")) return 2;
|
|
144
118
|
}
|
|
119
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) return 1;
|
|
120
|
+
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
145
121
|
const min = forceColor || 0;
|
|
146
|
-
if (env.TERM
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586)
|
|
122
|
+
if ("dumb" === env.TERM) return min;
|
|
123
|
+
if ("win32" === external_node_process_namespaceObject.platform) {
|
|
124
|
+
const osRelease = external_node_os_namespaceObject
|
|
125
|
+
.release()
|
|
126
|
+
.split(".");
|
|
127
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586)
|
|
152
128
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
153
|
-
}
|
|
154
129
|
return 1;
|
|
155
130
|
}
|
|
156
131
|
if ("CI" in env) {
|
|
157
|
-
if (
|
|
132
|
+
if (
|
|
133
|
+
["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some(
|
|
134
|
+
(key) => key in env,
|
|
135
|
+
)
|
|
136
|
+
)
|
|
158
137
|
return 3;
|
|
159
|
-
}
|
|
160
138
|
if (
|
|
161
|
-
[
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
"BUILDKITE",
|
|
167
|
-
"DRONE",
|
|
168
|
-
].some((sign) => sign in env) ||
|
|
169
|
-
env.CI_NAME === "codeship"
|
|
170
|
-
) {
|
|
139
|
+
["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some(
|
|
140
|
+
(sign) => sign in env,
|
|
141
|
+
) ||
|
|
142
|
+
"codeship" === env.CI_NAME
|
|
143
|
+
)
|
|
171
144
|
return 1;
|
|
172
|
-
}
|
|
173
145
|
return min;
|
|
174
146
|
}
|
|
175
|
-
if ("TEAMCITY_VERSION" in env)
|
|
147
|
+
if ("TEAMCITY_VERSION" in env)
|
|
176
148
|
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION)
|
|
177
149
|
? 1
|
|
178
150
|
: 0;
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
if (env.TERM === "xterm-kitty") {
|
|
184
|
-
return 3;
|
|
185
|
-
}
|
|
151
|
+
if ("truecolor" === env.COLORTERM) return 3;
|
|
152
|
+
if ("xterm-kitty" === env.TERM) return 3;
|
|
153
|
+
if ("xterm-ghostty" === env.TERM) return 3;
|
|
186
154
|
if ("TERM_PROGRAM" in env) {
|
|
187
155
|
const version = Number.parseInt(
|
|
188
156
|
(env.TERM_PROGRAM_VERSION || "").split(".")[0],
|
|
189
157
|
10,
|
|
190
158
|
);
|
|
191
159
|
switch (env.TERM_PROGRAM) {
|
|
192
|
-
case "iTerm.app":
|
|
160
|
+
case "iTerm.app":
|
|
193
161
|
return version >= 3 ? 3 : 2;
|
|
194
|
-
|
|
195
|
-
case "Apple_Terminal": {
|
|
162
|
+
case "Apple_Terminal":
|
|
196
163
|
return 2;
|
|
197
|
-
}
|
|
198
164
|
}
|
|
199
165
|
}
|
|
200
|
-
if (/-256(color)?$/i.test(env.TERM))
|
|
201
|
-
return 2;
|
|
202
|
-
}
|
|
166
|
+
if (/-256(color)?$/i.test(env.TERM)) return 2;
|
|
203
167
|
if (
|
|
204
168
|
/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
|
|
205
169
|
env.TERM,
|
|
206
170
|
)
|
|
207
|
-
)
|
|
208
|
-
return 1;
|
|
209
|
-
}
|
|
210
|
-
if ("COLORTERM" in env) {
|
|
171
|
+
)
|
|
211
172
|
return 1;
|
|
212
|
-
|
|
173
|
+
if ("COLORTERM" in env) return 1;
|
|
213
174
|
return min;
|
|
214
175
|
}
|
|
215
176
|
function createSupportsColor(stream, options = {}) {
|
|
@@ -219,24 +180,24 @@
|
|
|
219
180
|
});
|
|
220
181
|
return translateLevel(level);
|
|
221
182
|
}
|
|
222
|
-
|
|
183
|
+
const supportsColor = {
|
|
223
184
|
stdout: createSupportsColor({
|
|
224
|
-
isTTY:
|
|
185
|
+
isTTY: external_node_tty_namespaceObject.isatty(1),
|
|
225
186
|
}),
|
|
226
187
|
stderr: createSupportsColor({
|
|
227
|
-
isTTY:
|
|
188
|
+
isTTY: external_node_tty_namespaceObject.isatty(2),
|
|
228
189
|
}),
|
|
229
190
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
?
|
|
191
|
+
const supports_color = supportsColor;
|
|
192
|
+
const colorLevel = supports_color.stdout
|
|
193
|
+
? supports_color.stdout.level
|
|
233
194
|
: 0;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
195
|
+
let errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
|
|
196
|
+
let anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
|
|
197
|
+
let isErrorStackMessage = (message) =>
|
|
237
198
|
errorStackRegExp.test(message) ||
|
|
238
199
|
anonymousErrorStackRegExp.test(message);
|
|
239
|
-
|
|
200
|
+
let formatter = (open, close, replace = open) =>
|
|
240
201
|
colorLevel >= 2
|
|
241
202
|
? (input) => {
|
|
242
203
|
let string = "" + input;
|
|
@@ -246,7 +207,7 @@
|
|
|
246
207
|
: open + string + close;
|
|
247
208
|
}
|
|
248
209
|
: String;
|
|
249
|
-
|
|
210
|
+
let replaceClose = (string, close, replace, index) => {
|
|
250
211
|
let start = string.substring(0, index) + replace;
|
|
251
212
|
let end = string.substring(index + close.length);
|
|
252
213
|
let nextIndex = end.indexOf(close);
|
|
@@ -254,20 +215,19 @@
|
|
|
254
215
|
? start + replaceClose(end, close, replace, nextIndex)
|
|
255
216
|
: start + end;
|
|
256
217
|
};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (colorLevel < 3)
|
|
269
|
-
return
|
|
270
|
-
}
|
|
218
|
+
const bold = formatter("[1m", "[22m", "[22m[1m");
|
|
219
|
+
const red = formatter("[31m", "[39m");
|
|
220
|
+
const green = formatter("[32m", "[39m");
|
|
221
|
+
const yellow = formatter("[33m", "[39m");
|
|
222
|
+
const magenta = formatter("[35m", "[39m");
|
|
223
|
+
const cyan = formatter("[36m", "[39m");
|
|
224
|
+
const gray = formatter("[90m", "[39m");
|
|
225
|
+
let startColor = [189, 255, 243];
|
|
226
|
+
let endColor = [74, 194, 154];
|
|
227
|
+
let isWord = (char) => !/[\s\n]/.test(char);
|
|
228
|
+
let gradient = (message) => {
|
|
229
|
+
if (colorLevel < 3)
|
|
230
|
+
return 2 === colorLevel ? bold(cyan(message)) : message;
|
|
271
231
|
let chars = [...message];
|
|
272
232
|
let steps = chars.filter(isWord).length;
|
|
273
233
|
let r = startColor[0];
|
|
@@ -287,26 +247,29 @@
|
|
|
287
247
|
}
|
|
288
248
|
return bold(output);
|
|
289
249
|
};
|
|
290
|
-
|
|
291
|
-
|
|
250
|
+
let LOG_LEVEL = {
|
|
251
|
+
silent: -1,
|
|
252
|
+
error: 0,
|
|
253
|
+
warn: 1,
|
|
254
|
+
info: 2,
|
|
255
|
+
log: 2,
|
|
256
|
+
verbose: 3,
|
|
257
|
+
};
|
|
258
|
+
let LOG_TYPES = {
|
|
292
259
|
error: { label: "error", level: "error", color: red },
|
|
293
260
|
warn: { label: "warn", level: "warn", color: yellow },
|
|
294
261
|
info: { label: "info", level: "info", color: cyan },
|
|
295
262
|
start: { label: "start", level: "info", color: cyan },
|
|
296
263
|
ready: { label: "ready", level: "info", color: green },
|
|
297
264
|
success: { label: "success", level: "info", color: green },
|
|
298
|
-
log: { level: "
|
|
265
|
+
log: { level: "info" },
|
|
299
266
|
debug: { label: "debug", level: "verbose", color: magenta },
|
|
300
267
|
};
|
|
301
|
-
|
|
302
|
-
let maxLevel = options.level || "
|
|
268
|
+
let createLogger = (options = {}) => {
|
|
269
|
+
let maxLevel = options.level || "info";
|
|
303
270
|
let log = (type, message, ...args) => {
|
|
304
|
-
if (LOG_LEVEL[LOG_TYPES[type].level] > LOG_LEVEL[maxLevel])
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
if (message === void 0 || message === null) {
|
|
308
|
-
return console.log();
|
|
309
|
-
}
|
|
271
|
+
if (LOG_LEVEL[LOG_TYPES[type].level] > LOG_LEVEL[maxLevel]) return;
|
|
272
|
+
if (null == message) return console.log();
|
|
310
273
|
let logType = LOG_TYPES[type];
|
|
311
274
|
let label = "";
|
|
312
275
|
let text = "";
|
|
@@ -314,43 +277,42 @@
|
|
|
314
277
|
label = (logType.label || "").padEnd(7);
|
|
315
278
|
label = bold(logType.color ? logType.color(label) : label);
|
|
316
279
|
}
|
|
317
|
-
if (message instanceof Error)
|
|
280
|
+
if (message instanceof Error)
|
|
318
281
|
if (message.stack) {
|
|
319
282
|
let [name, ...rest] = message.stack.split("\n");
|
|
320
|
-
if (name.startsWith("Error: "))
|
|
321
|
-
name = name.slice(7);
|
|
322
|
-
}
|
|
283
|
+
if (name.startsWith("Error: ")) name = name.slice(7);
|
|
323
284
|
text = `${name}\n${gray(rest.join("\n"))}`;
|
|
324
|
-
} else
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
} else if (logType.level === "error" && typeof message === "string") {
|
|
285
|
+
} else text = message.message;
|
|
286
|
+
else if ("error" === logType.level && "string" == typeof message) {
|
|
328
287
|
let lines = message.split("\n");
|
|
329
288
|
text = lines
|
|
330
289
|
.map((line) => (isErrorStackMessage(line) ? gray(line) : line))
|
|
331
290
|
.join("\n");
|
|
332
|
-
} else {
|
|
333
|
-
text = `${message}`;
|
|
334
|
-
}
|
|
291
|
+
} else text = `${message}`;
|
|
335
292
|
console.log(label.length ? `${label} ${text}` : text, ...args);
|
|
336
293
|
};
|
|
337
|
-
let
|
|
294
|
+
let logger = { greet: (message) => log("log", gradient(message)) };
|
|
338
295
|
Object.keys(LOG_TYPES).forEach((key) => {
|
|
339
|
-
|
|
296
|
+
logger[key] = (...args) => log(key, ...args);
|
|
340
297
|
});
|
|
341
|
-
Object.defineProperty(
|
|
298
|
+
Object.defineProperty(logger, "level", {
|
|
342
299
|
get: () => maxLevel,
|
|
343
300
|
set(val) {
|
|
344
301
|
maxLevel = val;
|
|
345
302
|
},
|
|
346
303
|
});
|
|
347
|
-
|
|
348
|
-
Object.assign(
|
|
304
|
+
logger.override = (customLogger) => {
|
|
305
|
+
Object.assign(logger, customLogger);
|
|
349
306
|
};
|
|
350
|
-
return
|
|
307
|
+
return logger;
|
|
351
308
|
};
|
|
352
|
-
|
|
353
|
-
|
|
309
|
+
let src_logger = createLogger();
|
|
310
|
+
exports.createLogger = __nested_webpack_exports__.createLogger;
|
|
311
|
+
exports.logger = __nested_webpack_exports__.logger;
|
|
312
|
+
for (var __webpack_i__ in __nested_webpack_exports__)
|
|
313
|
+
if (-1 === ["createLogger", "logger"].indexOf(__webpack_i__))
|
|
314
|
+
exports[__webpack_i__] = __nested_webpack_exports__[__webpack_i__];
|
|
315
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
354
316
|
},
|
|
355
317
|
};
|
|
356
318
|
var __webpack_module_cache__ = {};
|
|
@@ -375,6 +337,6 @@
|
|
|
375
337
|
}
|
|
376
338
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
377
339
|
__nccwpck_require__.ab = __dirname + "/";
|
|
378
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
340
|
+
var __webpack_exports__ = __nccwpck_require__(838);
|
|
379
341
|
module.exports = __webpack_exports__;
|
|
380
342
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"rslog","version":"1.2.
|
|
1
|
+
{"name":"rslog","version":"1.2.11","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config, DependencyConfig, ParsedTask } from './types.js';
|
|
2
2
|
export declare function findDepPath(name: string): string | null;
|
|
3
|
-
export declare const resolveConfig: () => Promise<Config>;
|
|
3
|
+
export declare const resolveConfig: (configFile?: string) => Promise<Config>;
|
|
4
4
|
export declare function parseTasks(dependencies: Array<string | DependencyConfig>, globalPrettier?: boolean): ParsedTask[];
|
|
5
5
|
export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>): Pick<T, U>;
|
|
6
6
|
export declare function replaceFileContent(filePath: string, replaceFn: (content: string) => string): void;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dirname, extname, join } from "node:path";
|
|
1
|
+
import { dirname, extname, join, resolve } from "node:path";
|
|
2
2
|
import fs_extra from "../compiled/fs-extra/index.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -60,7 +60,7 @@ const cwd = process.cwd();
|
|
|
60
60
|
const helper_require = createRequire(import.meta.url);
|
|
61
61
|
function findDepPath(name) {
|
|
62
62
|
try {
|
|
63
|
-
let entry = dirname(helper_require.resolve(
|
|
63
|
+
let entry = dirname(helper_require.resolve(name, {
|
|
64
64
|
paths: [
|
|
65
65
|
cwd
|
|
66
66
|
]
|
|
@@ -72,10 +72,21 @@ function findDepPath(name) {
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
const resolveConfig = async ()=>{
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const resolveConfig = async (configFile)=>{
|
|
76
|
+
const configFiles = configFile ? [
|
|
77
|
+
resolve(cwd, configFile)
|
|
78
|
+
] : [
|
|
79
|
+
'prebundle.config.ts',
|
|
80
|
+
'prebundle.config.mts',
|
|
81
|
+
'prebundle.config.mjs',
|
|
82
|
+
'prebundle.config.js'
|
|
83
|
+
].map((filename)=>join(cwd, filename));
|
|
84
|
+
for (const filename of configFiles)if (fs_extra.existsSync(filename)) {
|
|
85
|
+
const config = await import(pathToFileURL(filename).href);
|
|
86
|
+
return config.default ?? config;
|
|
87
|
+
}
|
|
88
|
+
if (configFile) throw new Error(`Unable to locate prebundle config file at: ${configFile}`);
|
|
89
|
+
throw new Error('Unable to locate prebundle config file.');
|
|
79
90
|
};
|
|
80
91
|
function parseTasks(dependencies, globalPrettier) {
|
|
81
92
|
const result = [];
|
|
@@ -191,10 +202,7 @@ async function emitIndex(code, distPath, prettier) {
|
|
|
191
202
|
await fs_extra.outputFile(distIndex, formatted);
|
|
192
203
|
} else await fs_extra.outputFile(distIndex, code);
|
|
193
204
|
}
|
|
194
|
-
const getTypes = (json)=>
|
|
195
|
-
var _json_exports;
|
|
196
|
-
return json && (json.types || json.typing || json.typings || getTypes(null == (_json_exports = json.exports) ? void 0 : _json_exports['.'])) || null;
|
|
197
|
-
};
|
|
205
|
+
const getTypes = (json)=>json && (json.types || json.typing || json.typings || getTypes(json.exports?.['.'])) || null;
|
|
198
206
|
async function emitDts(task, externals) {
|
|
199
207
|
const outputDefaultDts = ()=>{
|
|
200
208
|
fs_extra.outputFileSync(join(task.distPath, 'index.d.ts'), 'export = any;\n');
|
|
@@ -306,20 +314,15 @@ function renameDistFolder(task) {
|
|
|
306
314
|
'types',
|
|
307
315
|
'typing',
|
|
308
316
|
'typings'
|
|
309
|
-
]){
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const typesFolder = join(task.distPath, 'types');
|
|
315
|
-
if (fs_extra.existsSync(distFolder)) fs_extra.renameSync(distFolder, typesFolder);
|
|
316
|
-
}
|
|
317
|
+
])if (pkgJson[key]?.startsWith('dist/')) {
|
|
318
|
+
pkgJson[key] = pkgJson[key].replace('dist/', 'types/');
|
|
319
|
+
const distFolder = join(task.distPath, 'dist');
|
|
320
|
+
const typesFolder = join(task.distPath, 'types');
|
|
321
|
+
if (fs_extra.existsSync(distFolder)) fs_extra.renameSync(distFolder, typesFolder);
|
|
317
322
|
}
|
|
318
323
|
fs_extra.writeJSONSync(pkgPath, pkgJson);
|
|
319
324
|
}
|
|
320
|
-
const pkgName = process.argv[2];
|
|
321
325
|
async function prebundle(task, commonExternals = {}) {
|
|
322
|
-
if (pkgName && task.depName !== pkgName) return;
|
|
323
326
|
logger.start(`prebundle: ${task.depName}`);
|
|
324
327
|
fs_extra.removeSync(task.distPath);
|
|
325
328
|
if (task.beforeBundle) await task.beforeBundle(task);
|
|
@@ -351,9 +354,10 @@ async function prebundle(task, commonExternals = {}) {
|
|
|
351
354
|
if (task.afterBundle) await task.afterBundle(task);
|
|
352
355
|
logger.success(`prebundle: ${task.depName}\n\n`);
|
|
353
356
|
}
|
|
354
|
-
async function run() {
|
|
355
|
-
const config = await resolveConfig();
|
|
357
|
+
async function run(options = {}) {
|
|
358
|
+
const config = await resolveConfig(options.config);
|
|
356
359
|
const parsedTasks = parseTasks(config.dependencies, config.prettier);
|
|
357
|
-
|
|
360
|
+
const filters = options.packages?.length ? new Set(options.packages) : null;
|
|
361
|
+
for (const task of parsedTasks)if (!filters || filters.has(task.depName)) await prebundle(task, config.externals);
|
|
358
362
|
}
|
|
359
363
|
export { run };
|