bunup 0.8.31 → 0.8.32
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/dist/cli/index.js +68 -141
- package/dist/index.js +40 -111
- package/dist/plugins.js +40 -111
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -16,7 +16,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
16
16
|
});
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
20
19
|
var __export = (target, all) => {
|
|
21
20
|
for (var name in all)
|
|
22
21
|
__defProp(target, name, {
|
|
@@ -29,77 +28,8 @@ var __export = (target, all) => {
|
|
|
29
28
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
29
|
var __require = import.meta.require;
|
|
31
30
|
|
|
32
|
-
// node_modules/picocolors/picocolors.js
|
|
33
|
-
var require_picocolors = __commonJS((exports, module) => {
|
|
34
|
-
var p = process || {};
|
|
35
|
-
var argv = p.argv || [];
|
|
36
|
-
var env = p.env || {};
|
|
37
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
38
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
39
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
40
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
41
|
-
};
|
|
42
|
-
var replaceClose = (string, close, replace, index) => {
|
|
43
|
-
let result = "", cursor = 0;
|
|
44
|
-
do {
|
|
45
|
-
result += string.substring(cursor, index) + replace;
|
|
46
|
-
cursor = index + close.length;
|
|
47
|
-
index = string.indexOf(close, cursor);
|
|
48
|
-
} while (~index);
|
|
49
|
-
return result + string.substring(cursor);
|
|
50
|
-
};
|
|
51
|
-
var createColors = (enabled = isColorSupported) => {
|
|
52
|
-
let f = enabled ? formatter : () => String;
|
|
53
|
-
return {
|
|
54
|
-
isColorSupported: enabled,
|
|
55
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
56
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
57
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
58
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
59
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
60
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
61
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
62
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
63
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
64
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
65
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
66
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
67
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
68
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
69
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
70
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
71
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
72
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
73
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
74
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
75
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
76
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
77
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
78
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
79
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
80
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
81
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
82
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
83
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
84
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
85
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
86
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
87
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
88
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
89
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
90
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
91
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
92
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
93
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
94
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
95
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
module.exports = createColors();
|
|
99
|
-
module.exports.createColors = createColors;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
31
|
// src/logger.ts
|
|
32
|
+
import pc from "picocolors";
|
|
103
33
|
function setSilent(value) {
|
|
104
34
|
silent = value ?? false;
|
|
105
35
|
}
|
|
@@ -108,23 +38,23 @@ class Logger {
|
|
|
108
38
|
static instance;
|
|
109
39
|
loggedOnceMessages = new Set;
|
|
110
40
|
MAX_LABEL_LENGTH = 3;
|
|
111
|
-
cliColor =
|
|
112
|
-
mutedColor =
|
|
113
|
-
infoColor =
|
|
114
|
-
warnColor =
|
|
115
|
-
errorColor =
|
|
116
|
-
defaultColor =
|
|
41
|
+
cliColor = pc.blue;
|
|
42
|
+
mutedColor = pc.dim;
|
|
43
|
+
infoColor = pc.cyan;
|
|
44
|
+
warnColor = pc.yellow;
|
|
45
|
+
errorColor = pc.red;
|
|
46
|
+
defaultColor = pc.white;
|
|
117
47
|
progressFgColorMap = {
|
|
118
|
-
ESM:
|
|
119
|
-
CJS:
|
|
120
|
-
IIFE:
|
|
121
|
-
DTS:
|
|
48
|
+
ESM: pc.yellow,
|
|
49
|
+
CJS: pc.green,
|
|
50
|
+
IIFE: pc.magenta,
|
|
51
|
+
DTS: pc.blue
|
|
122
52
|
};
|
|
123
53
|
progressIdentifierBgColorMap = {
|
|
124
|
-
ESM:
|
|
125
|
-
CJS:
|
|
126
|
-
IIFE:
|
|
127
|
-
DTS:
|
|
54
|
+
ESM: pc.bgYellow,
|
|
55
|
+
CJS: pc.bgGreen,
|
|
56
|
+
IIFE: pc.bgMagenta,
|
|
57
|
+
DTS: pc.bgBlue
|
|
128
58
|
};
|
|
129
59
|
labels = {
|
|
130
60
|
cli: "CLI",
|
|
@@ -160,7 +90,7 @@ class Logger {
|
|
|
160
90
|
}) {
|
|
161
91
|
const padding = " ".repeat(Math.max(0, this.MAX_LABEL_LENGTH - label.length));
|
|
162
92
|
const formattedMessage = muted ? this.mutedColor(message) : message;
|
|
163
|
-
const identifierPart = identifier ? ` ${bgColor(
|
|
93
|
+
const identifierPart = identifier ? ` ${bgColor(pc.black(` ${identifier} `))}` : "";
|
|
164
94
|
return `${fgColor(label)} ${padding}${formattedMessage}${identifierPart}`;
|
|
165
95
|
}
|
|
166
96
|
output(message, options = {}, logFn = console.log) {
|
|
@@ -175,7 +105,7 @@ class Logger {
|
|
|
175
105
|
cli(message, options = {}) {
|
|
176
106
|
const formattedMessage = this.formatMessage({
|
|
177
107
|
fgColor: this.cliColor,
|
|
178
|
-
bgColor:
|
|
108
|
+
bgColor: pc.bgBlue,
|
|
179
109
|
label: this.labels.cli,
|
|
180
110
|
message,
|
|
181
111
|
identifier: options.identifier,
|
|
@@ -186,7 +116,7 @@ class Logger {
|
|
|
186
116
|
info(message, options = {}) {
|
|
187
117
|
const formattedMessage = this.formatMessage({
|
|
188
118
|
fgColor: this.infoColor,
|
|
189
|
-
bgColor:
|
|
119
|
+
bgColor: pc.bgCyan,
|
|
190
120
|
label: this.labels.info,
|
|
191
121
|
message,
|
|
192
122
|
identifier: options.identifier,
|
|
@@ -197,7 +127,7 @@ class Logger {
|
|
|
197
127
|
warn(message, options = {}) {
|
|
198
128
|
const formattedMessage = this.formatMessage({
|
|
199
129
|
fgColor: this.warnColor,
|
|
200
|
-
bgColor:
|
|
130
|
+
bgColor: pc.bgYellow,
|
|
201
131
|
label: this.labels.warn,
|
|
202
132
|
message,
|
|
203
133
|
identifier: options.identifier,
|
|
@@ -208,7 +138,7 @@ class Logger {
|
|
|
208
138
|
error(message, options = {}) {
|
|
209
139
|
const formattedMessage = this.formatMessage({
|
|
210
140
|
fgColor: this.errorColor,
|
|
211
|
-
bgColor:
|
|
141
|
+
bgColor: pc.bgRed,
|
|
212
142
|
label: this.labels.error,
|
|
213
143
|
message,
|
|
214
144
|
identifier: options.identifier,
|
|
@@ -233,7 +163,7 @@ class Logger {
|
|
|
233
163
|
if (label.includes(key))
|
|
234
164
|
return colorFn;
|
|
235
165
|
}
|
|
236
|
-
return
|
|
166
|
+
return pc.bgWhite;
|
|
237
167
|
}
|
|
238
168
|
progress(label, message, options = {}) {
|
|
239
169
|
const fgColor = this.getProgressFgColor(label);
|
|
@@ -262,36 +192,36 @@ function logTable(columns, data, footer) {
|
|
|
262
192
|
const pad = (str, width, align) => {
|
|
263
193
|
return align === "left" ? str.padEnd(width) : str.padStart(width);
|
|
264
194
|
};
|
|
265
|
-
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(
|
|
266
|
-
console.log(
|
|
195
|
+
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(pc.gray(" | "));
|
|
196
|
+
console.log(pc.gray(headerRow));
|
|
267
197
|
const separator = columns.map((col) => "-".repeat(widths[col.header])).join(" | ");
|
|
268
|
-
console.log(
|
|
198
|
+
console.log(pc.gray(separator));
|
|
269
199
|
for (const row of data) {
|
|
270
200
|
const rowStr = columns.map((col) => {
|
|
271
201
|
const value = row[col.header] || "";
|
|
272
202
|
const padded = pad(value, widths[col.header], col.align);
|
|
273
203
|
return col.color ? col.color(padded) : padded;
|
|
274
|
-
}).join(
|
|
204
|
+
}).join(pc.gray(" | "));
|
|
275
205
|
console.log(rowStr);
|
|
276
206
|
}
|
|
277
|
-
console.log(
|
|
207
|
+
console.log(pc.gray(separator));
|
|
278
208
|
if (footer) {
|
|
279
209
|
const footerRow = columns.map((col) => {
|
|
280
210
|
const value = footer[col.header] || "";
|
|
281
211
|
const padded = pad(value, widths[col.header], col.align);
|
|
282
212
|
return padded;
|
|
283
|
-
}).join(
|
|
213
|
+
}).join(pc.gray(" | "));
|
|
284
214
|
console.log(footerRow);
|
|
285
215
|
}
|
|
286
216
|
}
|
|
287
|
-
var
|
|
217
|
+
var silent = false, logger;
|
|
288
218
|
var init_logger = __esm(() => {
|
|
289
|
-
import_picocolors = __toESM(require_picocolors(), 1);
|
|
290
219
|
logger = Logger.getInstance();
|
|
291
220
|
});
|
|
292
221
|
|
|
293
222
|
// src/errors.ts
|
|
294
|
-
|
|
223
|
+
import pc2 from "picocolors";
|
|
224
|
+
var BunupError, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage = (error) => {
|
|
295
225
|
if (error instanceof Error) {
|
|
296
226
|
return error.message;
|
|
297
227
|
}
|
|
@@ -315,7 +245,7 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
315
245
|
}
|
|
316
246
|
const knownError = KNOWN_ERRORS.find((error2) => error2.pattern.test(errorMessage) && (error2.errorType === errorType || !error2.errorType));
|
|
317
247
|
if (!knownError && errorType) {
|
|
318
|
-
console.error(`${
|
|
248
|
+
console.error(`${pc2.red(errorType)} ${contextPrefix}${errorMessage}`);
|
|
319
249
|
}
|
|
320
250
|
if (knownError) {
|
|
321
251
|
console.log(`
|
|
@@ -324,14 +254,13 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
324
254
|
console.log(`
|
|
325
255
|
`);
|
|
326
256
|
} else {
|
|
327
|
-
console.error(
|
|
257
|
+
console.error(pc2.dim(pc2.white("If you think this is a bug, please open an issue at: ") + pc2.cyan("https://github.com/arshad-yaseen/bunup/issues/new")));
|
|
328
258
|
}
|
|
329
259
|
}, handleErrorAndExit = (error, context) => {
|
|
330
260
|
handleError(error, context);
|
|
331
261
|
process.exit(1);
|
|
332
262
|
};
|
|
333
263
|
var init_errors = __esm(() => {
|
|
334
|
-
import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
335
264
|
init_logger();
|
|
336
265
|
BunupError = class BunupError extends Error {
|
|
337
266
|
constructor(message) {
|
|
@@ -374,8 +303,8 @@ var init_errors = __esm(() => {
|
|
|
374
303
|
pattern: /Could not resolve: "bun"/i,
|
|
375
304
|
errorType: "BUILD ERROR",
|
|
376
305
|
logSolution: () => {
|
|
377
|
-
logger.error(
|
|
378
|
-
`) +
|
|
306
|
+
logger.error(pc2.white("You're trying to build a project that uses Bun. ") + pc2.white("Please set the target option to ") + pc2.cyan("`bun`") + pc2.white(`.
|
|
307
|
+
`) + pc2.white("Example: ") + pc2.green("`bunup --target bun`") + pc2.white(" or in config: ") + pc2.green("{ target: 'bun' }"));
|
|
379
308
|
}
|
|
380
309
|
}
|
|
381
310
|
];
|
|
@@ -524,6 +453,7 @@ var init_utils = __esm(() => {
|
|
|
524
453
|
});
|
|
525
454
|
|
|
526
455
|
// src/cli/utils.ts
|
|
456
|
+
import pc7 from "picocolors";
|
|
527
457
|
function displayBunupGradientArt() {
|
|
528
458
|
const art = `
|
|
529
459
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
@@ -537,13 +467,11 @@ function displayBunupGradientArt() {
|
|
|
537
467
|
`);
|
|
538
468
|
logger.space();
|
|
539
469
|
for (const line of lines) {
|
|
540
|
-
logger.output(
|
|
470
|
+
logger.output(pc7.cyan(line));
|
|
541
471
|
}
|
|
542
472
|
logger.space();
|
|
543
473
|
}
|
|
544
|
-
var import_picocolors7;
|
|
545
474
|
var init_utils2 = __esm(() => {
|
|
546
|
-
import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
547
475
|
init_logger();
|
|
548
476
|
});
|
|
549
477
|
|
|
@@ -564,15 +492,16 @@ import {
|
|
|
564
492
|
text
|
|
565
493
|
} from "@clack/prompts";
|
|
566
494
|
import { downloadTemplate } from "giget";
|
|
495
|
+
import pc8 from "picocolors";
|
|
567
496
|
import { replaceInFile } from "replace-in-file";
|
|
568
497
|
async function newProject() {
|
|
569
498
|
displayBunupGradientArt();
|
|
570
|
-
intro(
|
|
499
|
+
intro(pc8.bgCyan(pc8.black(" Scaffold a new project with Bunup ")));
|
|
571
500
|
const selectedTemplateDir = await select({
|
|
572
501
|
message: "Select a template",
|
|
573
502
|
options: TEMPLATES.map((template2) => ({
|
|
574
503
|
value: template2.dir,
|
|
575
|
-
label:
|
|
504
|
+
label: pc8.blue(template2.name)
|
|
576
505
|
}))
|
|
577
506
|
});
|
|
578
507
|
const template = TEMPLATES.find((t) => t.dir === selectedTemplateDir);
|
|
@@ -656,25 +585,24 @@ async function newProject() {
|
|
|
656
585
|
}
|
|
657
586
|
]);
|
|
658
587
|
outro(`
|
|
659
|
-
${
|
|
588
|
+
${pc8.green("\u2728 Project scaffolded successfully! \u2728")}
|
|
660
589
|
|
|
661
|
-
${
|
|
590
|
+
${pc8.bold("Ready to launch your awesome new project?")}
|
|
662
591
|
|
|
663
|
-
${
|
|
664
|
-
${
|
|
665
|
-
${
|
|
592
|
+
${pc8.cyan("cd")} ${projectName}
|
|
593
|
+
${pc8.cyan("bun install")}
|
|
594
|
+
${pc8.cyan("bun run dev")}
|
|
666
595
|
|
|
667
|
-
${
|
|
596
|
+
${pc8.dim("Learn more:")} ${pc8.underline("https://bunup.dev/docs")}
|
|
668
597
|
|
|
669
|
-
${
|
|
598
|
+
${pc8.yellow("Happy coding!")} \uD83D\uDE80
|
|
670
599
|
`);
|
|
671
600
|
}
|
|
672
601
|
function getProjectPath(projectName) {
|
|
673
602
|
return path6.join(process.cwd(), projectName);
|
|
674
603
|
}
|
|
675
|
-
var
|
|
604
|
+
var TEMPLATE_OWNER = "arshad-yaseen", TEMPLATE_REPO = "bunup-new", GITHUB_USERNAME_PLACEHOLDER = "username", GITHUB_REPO_PLACEHOLDER = "repo-name", MONOREPO_FIRST_PACKAGE_NAME_PLACEHOLDER = "package-1", MONOREPO_PACKAGES_DIR = "packages", TEMPLATES;
|
|
676
605
|
var init_new = __esm(() => {
|
|
677
|
-
import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
678
606
|
init_utils();
|
|
679
607
|
init_utils2();
|
|
680
608
|
TEMPLATES = [
|
|
@@ -709,10 +637,11 @@ import {
|
|
|
709
637
|
tasks as tasks2,
|
|
710
638
|
text as text2
|
|
711
639
|
} from "@clack/prompts";
|
|
640
|
+
import pc9 from "picocolors";
|
|
712
641
|
import { exec } from "tinyexec";
|
|
713
642
|
async function init() {
|
|
714
643
|
displayBunupGradientArt();
|
|
715
|
-
intro2(
|
|
644
|
+
intro2(pc9.bgCyan(pc9.black(" Initialize bunup in an existing project ")));
|
|
716
645
|
const { path: packageJsonPath } = await loadPackageJson();
|
|
717
646
|
if (!packageJsonPath) {
|
|
718
647
|
log.error("package.json not found");
|
|
@@ -1016,19 +945,19 @@ function createBuildScripts(entryFiles, outputFormats, shouldGenerateDts, config
|
|
|
1016
945
|
};
|
|
1017
946
|
}
|
|
1018
947
|
function showSuccessOutro(isWorkspace) {
|
|
1019
|
-
const buildCommand = isWorkspace ? `${
|
|
1020
|
-
const devCommand = isWorkspace ? `${
|
|
1021
|
-
const filterCommand = isWorkspace ? `${
|
|
948
|
+
const buildCommand = isWorkspace ? `${pc9.cyan("bun run build")} - Build all packages in your workspace` : `${pc9.cyan("bun run build")} - Build your library`;
|
|
949
|
+
const devCommand = isWorkspace ? `${pc9.cyan("bun run dev")} - Start development mode (watches all packages)` : `${pc9.cyan("bun run dev")} - Start development mode`;
|
|
950
|
+
const filterCommand = isWorkspace ? `${pc9.cyan("bunup --filter core,utils")} - Build specific packages` : "";
|
|
1022
951
|
outro2(`
|
|
1023
|
-
${
|
|
952
|
+
${pc9.green("\u2728 Bunup initialized successfully! \u2728")}
|
|
1024
953
|
|
|
1025
954
|
${buildCommand}
|
|
1026
955
|
${devCommand}${isWorkspace ? `
|
|
1027
956
|
${filterCommand}` : ""}
|
|
1028
957
|
|
|
1029
|
-
${
|
|
958
|
+
${pc9.dim("Learn more:")} ${pc9.underline("https://bunup.dev/docs/")}
|
|
1030
959
|
|
|
1031
|
-
${
|
|
960
|
+
${pc9.yellow("Happy building!")} \uD83D\uDE80
|
|
1032
961
|
`);
|
|
1033
962
|
}
|
|
1034
963
|
async function installBunup() {
|
|
@@ -1036,9 +965,7 @@ async function installBunup() {
|
|
|
1036
965
|
nodeOptions: { shell: true, stdio: "pipe" }
|
|
1037
966
|
});
|
|
1038
967
|
}
|
|
1039
|
-
var import_picocolors9;
|
|
1040
968
|
var init_init = __esm(() => {
|
|
1041
|
-
import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
1042
969
|
init_loaders();
|
|
1043
970
|
init_utils();
|
|
1044
971
|
init_utils2();
|
|
@@ -1047,14 +974,14 @@ var init_init = __esm(() => {
|
|
|
1047
974
|
// src/cli/index.ts
|
|
1048
975
|
import { exec as exec2 } from "tinyexec";
|
|
1049
976
|
// package.json
|
|
1050
|
-
var version = "0.8.
|
|
977
|
+
var version = "0.8.32";
|
|
1051
978
|
|
|
1052
979
|
// src/cli/index.ts
|
|
1053
980
|
init_errors();
|
|
1054
981
|
init_logger();
|
|
1055
982
|
|
|
1056
983
|
// src/cli/options.ts
|
|
1057
|
-
|
|
984
|
+
import pc3 from "picocolors";
|
|
1058
985
|
|
|
1059
986
|
// src/constants/index.ts
|
|
1060
987
|
var BUNUP_CLI_OPTIONS_URL = "https://bunup.dev/docs/guide/cli-options";
|
|
@@ -1105,7 +1032,7 @@ function showHelp() {
|
|
|
1105
1032
|
Bunup - \u26A1\uFE0F A blazing-fast build tool for your libraries built with Bun.
|
|
1106
1033
|
`);
|
|
1107
1034
|
console.log("For more information on available options, visit:");
|
|
1108
|
-
console.log(`${
|
|
1035
|
+
console.log(`${pc3.cyan(pc3.underline(BUNUP_CLI_OPTIONS_URL))}
|
|
1109
1036
|
`);
|
|
1110
1037
|
process.exit(0);
|
|
1111
1038
|
}
|
|
@@ -1273,8 +1200,8 @@ function parseCliOptions(argv) {
|
|
|
1273
1200
|
}
|
|
1274
1201
|
|
|
1275
1202
|
// src/cli/index.ts
|
|
1276
|
-
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
1277
1203
|
import { loadConfig as loadConfig2 } from "coffi";
|
|
1204
|
+
import pc10 from "picocolors";
|
|
1278
1205
|
|
|
1279
1206
|
// src/build.ts
|
|
1280
1207
|
init_errors();
|
|
@@ -1447,8 +1374,8 @@ import path3 from "path";
|
|
|
1447
1374
|
init_logger();
|
|
1448
1375
|
|
|
1449
1376
|
// src/plugins/utils.ts
|
|
1450
|
-
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
1451
1377
|
init_errors();
|
|
1378
|
+
import pc4 from "picocolors";
|
|
1452
1379
|
function filterBunupBunPlugins(plugins) {
|
|
1453
1380
|
if (!plugins)
|
|
1454
1381
|
return [];
|
|
@@ -1482,7 +1409,7 @@ async function getPackageForPlugin(name, pluginName) {
|
|
|
1482
1409
|
try {
|
|
1483
1410
|
pkg = await import(name);
|
|
1484
1411
|
} catch {
|
|
1485
|
-
throw new BunupPluginError(`[${
|
|
1412
|
+
throw new BunupPluginError(`[${pc4.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc4.blue(`bun add ${name} --dev`)}`);
|
|
1486
1413
|
}
|
|
1487
1414
|
return pkg;
|
|
1488
1415
|
}
|
|
@@ -1571,10 +1498,10 @@ function copy(patterns, outPath) {
|
|
|
1571
1498
|
};
|
|
1572
1499
|
}
|
|
1573
1500
|
// src/plugins/internal/report.ts
|
|
1574
|
-
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
1575
1501
|
init_logger();
|
|
1576
1502
|
init_logger();
|
|
1577
1503
|
init_utils();
|
|
1504
|
+
import pc5 from "picocolors";
|
|
1578
1505
|
function report() {
|
|
1579
1506
|
return {
|
|
1580
1507
|
type: "bunup",
|
|
@@ -1601,12 +1528,12 @@ function report() {
|
|
|
1601
1528
|
const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
|
|
1602
1529
|
const formattedTotalGzipSize = formatFileSize(totalGzipSize);
|
|
1603
1530
|
const columns = [
|
|
1604
|
-
{ header: "File", align: "left", color:
|
|
1605
|
-
{ header: "Size", align: "right", color:
|
|
1531
|
+
{ header: "File", align: "left", color: pc5.blue },
|
|
1532
|
+
{ header: "Size", align: "right", color: pc5.green },
|
|
1606
1533
|
{
|
|
1607
1534
|
header: "Gzip",
|
|
1608
1535
|
align: "right",
|
|
1609
|
-
color:
|
|
1536
|
+
color: pc5.magenta
|
|
1610
1537
|
}
|
|
1611
1538
|
];
|
|
1612
1539
|
const data = files.map((file) => {
|
|
@@ -1892,8 +1819,8 @@ init_loaders();
|
|
|
1892
1819
|
init_utils();
|
|
1893
1820
|
|
|
1894
1821
|
// src/watch.ts
|
|
1895
|
-
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
1896
1822
|
import path5 from "path";
|
|
1823
|
+
import pc6 from "picocolors";
|
|
1897
1824
|
init_errors();
|
|
1898
1825
|
init_logger();
|
|
1899
1826
|
init_utils();
|
|
@@ -1927,7 +1854,7 @@ async function watch(partialOptions, rootDir) {
|
|
|
1927
1854
|
const start = performance.now();
|
|
1928
1855
|
await build(options, rootDir);
|
|
1929
1856
|
if (!initial) {
|
|
1930
|
-
logger.cli(`\uD83D\uDCE6 Rebuild finished in ${
|
|
1857
|
+
logger.cli(`\uD83D\uDCE6 Rebuild finished in ${pc6.green(formatTime(performance.now() - start))}`);
|
|
1931
1858
|
}
|
|
1932
1859
|
} catch (error) {
|
|
1933
1860
|
handleError(error);
|
|
@@ -1998,7 +1925,7 @@ async function main(args = Bun.argv.slice(2)) {
|
|
|
1998
1925
|
}));
|
|
1999
1926
|
const buildTimeMs = performance.now() - startTime;
|
|
2000
1927
|
const timeDisplay = formatTime(buildTimeMs);
|
|
2001
|
-
logger.cli(`\u26A1\uFE0F Build completed in ${
|
|
1928
|
+
logger.cli(`\u26A1\uFE0F Build completed in ${pc10.green(timeDisplay)}`);
|
|
2002
1929
|
if (cliOptions.watch) {
|
|
2003
1930
|
logger.cli("\uD83D\uDC40 Watching for file changes");
|
|
2004
1931
|
}
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
15
15
|
});
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
18
|
var __export = (target, all) => {
|
|
20
19
|
for (var name in all)
|
|
21
20
|
__defProp(target, name, {
|
|
@@ -28,77 +27,8 @@ var __export = (target, all) => {
|
|
|
28
27
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
28
|
var __require = import.meta.require;
|
|
30
29
|
|
|
31
|
-
// node_modules/picocolors/picocolors.js
|
|
32
|
-
var require_picocolors = __commonJS((exports, module) => {
|
|
33
|
-
var p = process || {};
|
|
34
|
-
var argv = p.argv || [];
|
|
35
|
-
var env = p.env || {};
|
|
36
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
37
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
38
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
39
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
40
|
-
};
|
|
41
|
-
var replaceClose = (string, close, replace, index) => {
|
|
42
|
-
let result = "", cursor = 0;
|
|
43
|
-
do {
|
|
44
|
-
result += string.substring(cursor, index) + replace;
|
|
45
|
-
cursor = index + close.length;
|
|
46
|
-
index = string.indexOf(close, cursor);
|
|
47
|
-
} while (~index);
|
|
48
|
-
return result + string.substring(cursor);
|
|
49
|
-
};
|
|
50
|
-
var createColors = (enabled = isColorSupported) => {
|
|
51
|
-
let f = enabled ? formatter : () => String;
|
|
52
|
-
return {
|
|
53
|
-
isColorSupported: enabled,
|
|
54
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
55
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
56
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
57
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
58
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
59
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
60
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
61
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
62
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
63
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
64
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
65
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
66
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
67
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
68
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
69
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
70
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
71
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
72
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
73
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
74
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
75
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
76
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
77
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
78
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
79
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
80
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
81
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
82
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
83
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
84
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
85
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
86
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
87
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
88
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
89
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
90
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
91
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
92
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
93
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
94
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
module.exports = createColors();
|
|
98
|
-
module.exports.createColors = createColors;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
30
|
// src/logger.ts
|
|
31
|
+
import pc from "picocolors";
|
|
102
32
|
function setSilent(value) {
|
|
103
33
|
silent = value ?? false;
|
|
104
34
|
}
|
|
@@ -107,23 +37,23 @@ class Logger {
|
|
|
107
37
|
static instance;
|
|
108
38
|
loggedOnceMessages = new Set;
|
|
109
39
|
MAX_LABEL_LENGTH = 3;
|
|
110
|
-
cliColor =
|
|
111
|
-
mutedColor =
|
|
112
|
-
infoColor =
|
|
113
|
-
warnColor =
|
|
114
|
-
errorColor =
|
|
115
|
-
defaultColor =
|
|
40
|
+
cliColor = pc.blue;
|
|
41
|
+
mutedColor = pc.dim;
|
|
42
|
+
infoColor = pc.cyan;
|
|
43
|
+
warnColor = pc.yellow;
|
|
44
|
+
errorColor = pc.red;
|
|
45
|
+
defaultColor = pc.white;
|
|
116
46
|
progressFgColorMap = {
|
|
117
|
-
ESM:
|
|
118
|
-
CJS:
|
|
119
|
-
IIFE:
|
|
120
|
-
DTS:
|
|
47
|
+
ESM: pc.yellow,
|
|
48
|
+
CJS: pc.green,
|
|
49
|
+
IIFE: pc.magenta,
|
|
50
|
+
DTS: pc.blue
|
|
121
51
|
};
|
|
122
52
|
progressIdentifierBgColorMap = {
|
|
123
|
-
ESM:
|
|
124
|
-
CJS:
|
|
125
|
-
IIFE:
|
|
126
|
-
DTS:
|
|
53
|
+
ESM: pc.bgYellow,
|
|
54
|
+
CJS: pc.bgGreen,
|
|
55
|
+
IIFE: pc.bgMagenta,
|
|
56
|
+
DTS: pc.bgBlue
|
|
127
57
|
};
|
|
128
58
|
labels = {
|
|
129
59
|
cli: "CLI",
|
|
@@ -159,7 +89,7 @@ class Logger {
|
|
|
159
89
|
}) {
|
|
160
90
|
const padding = " ".repeat(Math.max(0, this.MAX_LABEL_LENGTH - label.length));
|
|
161
91
|
const formattedMessage = muted ? this.mutedColor(message) : message;
|
|
162
|
-
const identifierPart = identifier ? ` ${bgColor(
|
|
92
|
+
const identifierPart = identifier ? ` ${bgColor(pc.black(` ${identifier} `))}` : "";
|
|
163
93
|
return `${fgColor(label)} ${padding}${formattedMessage}${identifierPart}`;
|
|
164
94
|
}
|
|
165
95
|
output(message, options = {}, logFn = console.log) {
|
|
@@ -174,7 +104,7 @@ class Logger {
|
|
|
174
104
|
cli(message, options = {}) {
|
|
175
105
|
const formattedMessage = this.formatMessage({
|
|
176
106
|
fgColor: this.cliColor,
|
|
177
|
-
bgColor:
|
|
107
|
+
bgColor: pc.bgBlue,
|
|
178
108
|
label: this.labels.cli,
|
|
179
109
|
message,
|
|
180
110
|
identifier: options.identifier,
|
|
@@ -185,7 +115,7 @@ class Logger {
|
|
|
185
115
|
info(message, options = {}) {
|
|
186
116
|
const formattedMessage = this.formatMessage({
|
|
187
117
|
fgColor: this.infoColor,
|
|
188
|
-
bgColor:
|
|
118
|
+
bgColor: pc.bgCyan,
|
|
189
119
|
label: this.labels.info,
|
|
190
120
|
message,
|
|
191
121
|
identifier: options.identifier,
|
|
@@ -196,7 +126,7 @@ class Logger {
|
|
|
196
126
|
warn(message, options = {}) {
|
|
197
127
|
const formattedMessage = this.formatMessage({
|
|
198
128
|
fgColor: this.warnColor,
|
|
199
|
-
bgColor:
|
|
129
|
+
bgColor: pc.bgYellow,
|
|
200
130
|
label: this.labels.warn,
|
|
201
131
|
message,
|
|
202
132
|
identifier: options.identifier,
|
|
@@ -207,7 +137,7 @@ class Logger {
|
|
|
207
137
|
error(message, options = {}) {
|
|
208
138
|
const formattedMessage = this.formatMessage({
|
|
209
139
|
fgColor: this.errorColor,
|
|
210
|
-
bgColor:
|
|
140
|
+
bgColor: pc.bgRed,
|
|
211
141
|
label: this.labels.error,
|
|
212
142
|
message,
|
|
213
143
|
identifier: options.identifier,
|
|
@@ -232,7 +162,7 @@ class Logger {
|
|
|
232
162
|
if (label.includes(key))
|
|
233
163
|
return colorFn;
|
|
234
164
|
}
|
|
235
|
-
return
|
|
165
|
+
return pc.bgWhite;
|
|
236
166
|
}
|
|
237
167
|
progress(label, message, options = {}) {
|
|
238
168
|
const fgColor = this.getProgressFgColor(label);
|
|
@@ -261,36 +191,36 @@ function logTable(columns, data, footer) {
|
|
|
261
191
|
const pad = (str, width, align) => {
|
|
262
192
|
return align === "left" ? str.padEnd(width) : str.padStart(width);
|
|
263
193
|
};
|
|
264
|
-
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(
|
|
265
|
-
console.log(
|
|
194
|
+
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(pc.gray(" | "));
|
|
195
|
+
console.log(pc.gray(headerRow));
|
|
266
196
|
const separator = columns.map((col) => "-".repeat(widths[col.header])).join(" | ");
|
|
267
|
-
console.log(
|
|
197
|
+
console.log(pc.gray(separator));
|
|
268
198
|
for (const row of data) {
|
|
269
199
|
const rowStr = columns.map((col) => {
|
|
270
200
|
const value = row[col.header] || "";
|
|
271
201
|
const padded = pad(value, widths[col.header], col.align);
|
|
272
202
|
return col.color ? col.color(padded) : padded;
|
|
273
|
-
}).join(
|
|
203
|
+
}).join(pc.gray(" | "));
|
|
274
204
|
console.log(rowStr);
|
|
275
205
|
}
|
|
276
|
-
console.log(
|
|
206
|
+
console.log(pc.gray(separator));
|
|
277
207
|
if (footer) {
|
|
278
208
|
const footerRow = columns.map((col) => {
|
|
279
209
|
const value = footer[col.header] || "";
|
|
280
210
|
const padded = pad(value, widths[col.header], col.align);
|
|
281
211
|
return padded;
|
|
282
|
-
}).join(
|
|
212
|
+
}).join(pc.gray(" | "));
|
|
283
213
|
console.log(footerRow);
|
|
284
214
|
}
|
|
285
215
|
}
|
|
286
|
-
var
|
|
216
|
+
var silent = false, logger;
|
|
287
217
|
var init_logger = __esm(() => {
|
|
288
|
-
import_picocolors = __toESM(require_picocolors(), 1);
|
|
289
218
|
logger = Logger.getInstance();
|
|
290
219
|
});
|
|
291
220
|
|
|
292
221
|
// src/errors.ts
|
|
293
|
-
|
|
222
|
+
import pc2 from "picocolors";
|
|
223
|
+
var BunupError, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage = (error) => {
|
|
294
224
|
if (error instanceof Error) {
|
|
295
225
|
return error.message;
|
|
296
226
|
}
|
|
@@ -314,7 +244,7 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
314
244
|
}
|
|
315
245
|
const knownError = KNOWN_ERRORS.find((error2) => error2.pattern.test(errorMessage) && (error2.errorType === errorType || !error2.errorType));
|
|
316
246
|
if (!knownError && errorType) {
|
|
317
|
-
console.error(`${
|
|
247
|
+
console.error(`${pc2.red(errorType)} ${contextPrefix}${errorMessage}`);
|
|
318
248
|
}
|
|
319
249
|
if (knownError) {
|
|
320
250
|
console.log(`
|
|
@@ -323,14 +253,13 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
323
253
|
console.log(`
|
|
324
254
|
`);
|
|
325
255
|
} else {
|
|
326
|
-
console.error(
|
|
256
|
+
console.error(pc2.dim(pc2.white("If you think this is a bug, please open an issue at: ") + pc2.cyan("https://github.com/arshad-yaseen/bunup/issues/new")));
|
|
327
257
|
}
|
|
328
258
|
}, handleErrorAndExit = (error, context) => {
|
|
329
259
|
handleError(error, context);
|
|
330
260
|
process.exit(1);
|
|
331
261
|
};
|
|
332
262
|
var init_errors = __esm(() => {
|
|
333
|
-
import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
334
263
|
init_logger();
|
|
335
264
|
BunupError = class BunupError extends Error {
|
|
336
265
|
constructor(message) {
|
|
@@ -373,8 +302,8 @@ var init_errors = __esm(() => {
|
|
|
373
302
|
pattern: /Could not resolve: "bun"/i,
|
|
374
303
|
errorType: "BUILD ERROR",
|
|
375
304
|
logSolution: () => {
|
|
376
|
-
logger.error(
|
|
377
|
-
`) +
|
|
305
|
+
logger.error(pc2.white("You're trying to build a project that uses Bun. ") + pc2.white("Please set the target option to ") + pc2.cyan("`bun`") + pc2.white(`.
|
|
306
|
+
`) + pc2.white("Example: ") + pc2.green("`bunup --target bun`") + pc2.white(" or in config: ") + pc2.green("{ target: 'bun' }"));
|
|
378
307
|
}
|
|
379
308
|
}
|
|
380
309
|
];
|
|
@@ -700,8 +629,8 @@ import path3 from "path";
|
|
|
700
629
|
init_logger();
|
|
701
630
|
|
|
702
631
|
// src/plugins/utils.ts
|
|
703
|
-
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
704
632
|
init_errors();
|
|
633
|
+
import pc3 from "picocolors";
|
|
705
634
|
function filterBunupBunPlugins(plugins) {
|
|
706
635
|
if (!plugins)
|
|
707
636
|
return [];
|
|
@@ -735,7 +664,7 @@ async function getPackageForPlugin(name, pluginName) {
|
|
|
735
664
|
try {
|
|
736
665
|
pkg = await import(name);
|
|
737
666
|
} catch {
|
|
738
|
-
throw new BunupPluginError(`[${
|
|
667
|
+
throw new BunupPluginError(`[${pc3.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc3.blue(`bun add ${name} --dev`)}`);
|
|
739
668
|
}
|
|
740
669
|
return pkg;
|
|
741
670
|
}
|
|
@@ -824,10 +753,10 @@ function copy(patterns, outPath) {
|
|
|
824
753
|
};
|
|
825
754
|
}
|
|
826
755
|
// src/plugins/internal/report.ts
|
|
827
|
-
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
828
756
|
init_logger();
|
|
829
757
|
init_logger();
|
|
830
758
|
init_utils();
|
|
759
|
+
import pc4 from "picocolors";
|
|
831
760
|
function report() {
|
|
832
761
|
return {
|
|
833
762
|
type: "bunup",
|
|
@@ -854,12 +783,12 @@ function report() {
|
|
|
854
783
|
const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
|
|
855
784
|
const formattedTotalGzipSize = formatFileSize(totalGzipSize);
|
|
856
785
|
const columns = [
|
|
857
|
-
{ header: "File", align: "left", color:
|
|
858
|
-
{ header: "Size", align: "right", color:
|
|
786
|
+
{ header: "File", align: "left", color: pc4.blue },
|
|
787
|
+
{ header: "Size", align: "right", color: pc4.green },
|
|
859
788
|
{
|
|
860
789
|
header: "Gzip",
|
|
861
790
|
align: "right",
|
|
862
|
-
color:
|
|
791
|
+
color: pc4.magenta
|
|
863
792
|
}
|
|
864
793
|
];
|
|
865
794
|
const data = files.map((file) => {
|
package/dist/plugins.js
CHANGED
|
@@ -15,7 +15,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
15
15
|
});
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
18
|
var __export = (target, all) => {
|
|
20
19
|
for (var name in all)
|
|
21
20
|
__defProp(target, name, {
|
|
@@ -28,77 +27,8 @@ var __export = (target, all) => {
|
|
|
28
27
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
28
|
var __require = import.meta.require;
|
|
30
29
|
|
|
31
|
-
// node_modules/picocolors/picocolors.js
|
|
32
|
-
var require_picocolors = __commonJS((exports, module) => {
|
|
33
|
-
var p = process || {};
|
|
34
|
-
var argv = p.argv || [];
|
|
35
|
-
var env = p.env || {};
|
|
36
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
37
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
38
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
39
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
40
|
-
};
|
|
41
|
-
var replaceClose = (string, close, replace, index) => {
|
|
42
|
-
let result = "", cursor = 0;
|
|
43
|
-
do {
|
|
44
|
-
result += string.substring(cursor, index) + replace;
|
|
45
|
-
cursor = index + close.length;
|
|
46
|
-
index = string.indexOf(close, cursor);
|
|
47
|
-
} while (~index);
|
|
48
|
-
return result + string.substring(cursor);
|
|
49
|
-
};
|
|
50
|
-
var createColors = (enabled = isColorSupported) => {
|
|
51
|
-
let f = enabled ? formatter : () => String;
|
|
52
|
-
return {
|
|
53
|
-
isColorSupported: enabled,
|
|
54
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
55
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
56
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
57
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
58
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
59
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
60
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
61
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
62
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
63
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
64
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
65
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
66
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
67
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
68
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
69
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
70
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
71
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
72
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
73
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
74
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
75
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
76
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
77
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
78
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
79
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
80
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
81
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
82
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
83
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
84
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
85
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
86
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
87
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
88
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
89
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
90
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
91
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
92
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
93
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
94
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
module.exports = createColors();
|
|
98
|
-
module.exports.createColors = createColors;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
30
|
// src/logger.ts
|
|
31
|
+
import pc from "picocolors";
|
|
102
32
|
function setSilent(value) {
|
|
103
33
|
silent = value ?? false;
|
|
104
34
|
}
|
|
@@ -107,23 +37,23 @@ class Logger {
|
|
|
107
37
|
static instance;
|
|
108
38
|
loggedOnceMessages = new Set;
|
|
109
39
|
MAX_LABEL_LENGTH = 3;
|
|
110
|
-
cliColor =
|
|
111
|
-
mutedColor =
|
|
112
|
-
infoColor =
|
|
113
|
-
warnColor =
|
|
114
|
-
errorColor =
|
|
115
|
-
defaultColor =
|
|
40
|
+
cliColor = pc.blue;
|
|
41
|
+
mutedColor = pc.dim;
|
|
42
|
+
infoColor = pc.cyan;
|
|
43
|
+
warnColor = pc.yellow;
|
|
44
|
+
errorColor = pc.red;
|
|
45
|
+
defaultColor = pc.white;
|
|
116
46
|
progressFgColorMap = {
|
|
117
|
-
ESM:
|
|
118
|
-
CJS:
|
|
119
|
-
IIFE:
|
|
120
|
-
DTS:
|
|
47
|
+
ESM: pc.yellow,
|
|
48
|
+
CJS: pc.green,
|
|
49
|
+
IIFE: pc.magenta,
|
|
50
|
+
DTS: pc.blue
|
|
121
51
|
};
|
|
122
52
|
progressIdentifierBgColorMap = {
|
|
123
|
-
ESM:
|
|
124
|
-
CJS:
|
|
125
|
-
IIFE:
|
|
126
|
-
DTS:
|
|
53
|
+
ESM: pc.bgYellow,
|
|
54
|
+
CJS: pc.bgGreen,
|
|
55
|
+
IIFE: pc.bgMagenta,
|
|
56
|
+
DTS: pc.bgBlue
|
|
127
57
|
};
|
|
128
58
|
labels = {
|
|
129
59
|
cli: "CLI",
|
|
@@ -159,7 +89,7 @@ class Logger {
|
|
|
159
89
|
}) {
|
|
160
90
|
const padding = " ".repeat(Math.max(0, this.MAX_LABEL_LENGTH - label.length));
|
|
161
91
|
const formattedMessage = muted ? this.mutedColor(message) : message;
|
|
162
|
-
const identifierPart = identifier ? ` ${bgColor(
|
|
92
|
+
const identifierPart = identifier ? ` ${bgColor(pc.black(` ${identifier} `))}` : "";
|
|
163
93
|
return `${fgColor(label)} ${padding}${formattedMessage}${identifierPart}`;
|
|
164
94
|
}
|
|
165
95
|
output(message, options = {}, logFn = console.log) {
|
|
@@ -174,7 +104,7 @@ class Logger {
|
|
|
174
104
|
cli(message, options = {}) {
|
|
175
105
|
const formattedMessage = this.formatMessage({
|
|
176
106
|
fgColor: this.cliColor,
|
|
177
|
-
bgColor:
|
|
107
|
+
bgColor: pc.bgBlue,
|
|
178
108
|
label: this.labels.cli,
|
|
179
109
|
message,
|
|
180
110
|
identifier: options.identifier,
|
|
@@ -185,7 +115,7 @@ class Logger {
|
|
|
185
115
|
info(message, options = {}) {
|
|
186
116
|
const formattedMessage = this.formatMessage({
|
|
187
117
|
fgColor: this.infoColor,
|
|
188
|
-
bgColor:
|
|
118
|
+
bgColor: pc.bgCyan,
|
|
189
119
|
label: this.labels.info,
|
|
190
120
|
message,
|
|
191
121
|
identifier: options.identifier,
|
|
@@ -196,7 +126,7 @@ class Logger {
|
|
|
196
126
|
warn(message, options = {}) {
|
|
197
127
|
const formattedMessage = this.formatMessage({
|
|
198
128
|
fgColor: this.warnColor,
|
|
199
|
-
bgColor:
|
|
129
|
+
bgColor: pc.bgYellow,
|
|
200
130
|
label: this.labels.warn,
|
|
201
131
|
message,
|
|
202
132
|
identifier: options.identifier,
|
|
@@ -207,7 +137,7 @@ class Logger {
|
|
|
207
137
|
error(message, options = {}) {
|
|
208
138
|
const formattedMessage = this.formatMessage({
|
|
209
139
|
fgColor: this.errorColor,
|
|
210
|
-
bgColor:
|
|
140
|
+
bgColor: pc.bgRed,
|
|
211
141
|
label: this.labels.error,
|
|
212
142
|
message,
|
|
213
143
|
identifier: options.identifier,
|
|
@@ -232,7 +162,7 @@ class Logger {
|
|
|
232
162
|
if (label.includes(key))
|
|
233
163
|
return colorFn;
|
|
234
164
|
}
|
|
235
|
-
return
|
|
165
|
+
return pc.bgWhite;
|
|
236
166
|
}
|
|
237
167
|
progress(label, message, options = {}) {
|
|
238
168
|
const fgColor = this.getProgressFgColor(label);
|
|
@@ -261,36 +191,36 @@ function logTable(columns, data, footer) {
|
|
|
261
191
|
const pad = (str, width, align) => {
|
|
262
192
|
return align === "left" ? str.padEnd(width) : str.padStart(width);
|
|
263
193
|
};
|
|
264
|
-
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(
|
|
265
|
-
console.log(
|
|
194
|
+
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(pc.gray(" | "));
|
|
195
|
+
console.log(pc.gray(headerRow));
|
|
266
196
|
const separator = columns.map((col) => "-".repeat(widths[col.header])).join(" | ");
|
|
267
|
-
console.log(
|
|
197
|
+
console.log(pc.gray(separator));
|
|
268
198
|
for (const row of data) {
|
|
269
199
|
const rowStr = columns.map((col) => {
|
|
270
200
|
const value = row[col.header] || "";
|
|
271
201
|
const padded = pad(value, widths[col.header], col.align);
|
|
272
202
|
return col.color ? col.color(padded) : padded;
|
|
273
|
-
}).join(
|
|
203
|
+
}).join(pc.gray(" | "));
|
|
274
204
|
console.log(rowStr);
|
|
275
205
|
}
|
|
276
|
-
console.log(
|
|
206
|
+
console.log(pc.gray(separator));
|
|
277
207
|
if (footer) {
|
|
278
208
|
const footerRow = columns.map((col) => {
|
|
279
209
|
const value = footer[col.header] || "";
|
|
280
210
|
const padded = pad(value, widths[col.header], col.align);
|
|
281
211
|
return padded;
|
|
282
|
-
}).join(
|
|
212
|
+
}).join(pc.gray(" | "));
|
|
283
213
|
console.log(footerRow);
|
|
284
214
|
}
|
|
285
215
|
}
|
|
286
|
-
var
|
|
216
|
+
var silent = false, logger;
|
|
287
217
|
var init_logger = __esm(() => {
|
|
288
|
-
import_picocolors = __toESM(require_picocolors(), 1);
|
|
289
218
|
logger = Logger.getInstance();
|
|
290
219
|
});
|
|
291
220
|
|
|
292
221
|
// src/errors.ts
|
|
293
|
-
|
|
222
|
+
import pc2 from "picocolors";
|
|
223
|
+
var BunupError, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage = (error) => {
|
|
294
224
|
if (error instanceof Error) {
|
|
295
225
|
return error.message;
|
|
296
226
|
}
|
|
@@ -314,7 +244,7 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
314
244
|
}
|
|
315
245
|
const knownError = KNOWN_ERRORS.find((error2) => error2.pattern.test(errorMessage) && (error2.errorType === errorType || !error2.errorType));
|
|
316
246
|
if (!knownError && errorType) {
|
|
317
|
-
console.error(`${
|
|
247
|
+
console.error(`${pc2.red(errorType)} ${contextPrefix}${errorMessage}`);
|
|
318
248
|
}
|
|
319
249
|
if (knownError) {
|
|
320
250
|
console.log(`
|
|
@@ -323,14 +253,13 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
323
253
|
console.log(`
|
|
324
254
|
`);
|
|
325
255
|
} else {
|
|
326
|
-
console.error(
|
|
256
|
+
console.error(pc2.dim(pc2.white("If you think this is a bug, please open an issue at: ") + pc2.cyan("https://github.com/arshad-yaseen/bunup/issues/new")));
|
|
327
257
|
}
|
|
328
258
|
}, handleErrorAndExit = (error, context) => {
|
|
329
259
|
handleError(error, context);
|
|
330
260
|
process.exit(1);
|
|
331
261
|
};
|
|
332
262
|
var init_errors = __esm(() => {
|
|
333
|
-
import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
334
263
|
init_logger();
|
|
335
264
|
BunupError = class BunupError extends Error {
|
|
336
265
|
constructor(message) {
|
|
@@ -373,8 +302,8 @@ var init_errors = __esm(() => {
|
|
|
373
302
|
pattern: /Could not resolve: "bun"/i,
|
|
374
303
|
errorType: "BUILD ERROR",
|
|
375
304
|
logSolution: () => {
|
|
376
|
-
logger.error(
|
|
377
|
-
`) +
|
|
305
|
+
logger.error(pc2.white("You're trying to build a project that uses Bun. ") + pc2.white("Please set the target option to ") + pc2.cyan("`bun`") + pc2.white(`.
|
|
306
|
+
`) + pc2.white("Example: ") + pc2.green("`bunup --target bun`") + pc2.white(" or in config: ") + pc2.green("{ target: 'bun' }"));
|
|
378
307
|
}
|
|
379
308
|
}
|
|
380
309
|
];
|
|
@@ -656,8 +585,8 @@ import path2 from "path";
|
|
|
656
585
|
init_logger();
|
|
657
586
|
|
|
658
587
|
// src/plugins/utils.ts
|
|
659
|
-
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
660
588
|
init_errors();
|
|
589
|
+
import pc3 from "picocolors";
|
|
661
590
|
function filterBunupBunPlugins(plugins) {
|
|
662
591
|
if (!plugins)
|
|
663
592
|
return [];
|
|
@@ -691,7 +620,7 @@ async function getPackageForPlugin(name, pluginName) {
|
|
|
691
620
|
try {
|
|
692
621
|
pkg = await import(name);
|
|
693
622
|
} catch {
|
|
694
|
-
throw new BunupPluginError(`[${
|
|
623
|
+
throw new BunupPluginError(`[${pc3.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc3.blue(`bun add ${name} --dev`)}`);
|
|
695
624
|
}
|
|
696
625
|
return pkg;
|
|
697
626
|
}
|
|
@@ -780,10 +709,10 @@ function copy(patterns, outPath) {
|
|
|
780
709
|
};
|
|
781
710
|
}
|
|
782
711
|
// src/plugins/internal/report.ts
|
|
783
|
-
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
784
712
|
init_logger();
|
|
785
713
|
init_logger();
|
|
786
714
|
init_utils();
|
|
715
|
+
import pc4 from "picocolors";
|
|
787
716
|
function report() {
|
|
788
717
|
return {
|
|
789
718
|
type: "bunup",
|
|
@@ -810,12 +739,12 @@ function report() {
|
|
|
810
739
|
const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
|
|
811
740
|
const formattedTotalGzipSize = formatFileSize(totalGzipSize);
|
|
812
741
|
const columns = [
|
|
813
|
-
{ header: "File", align: "left", color:
|
|
814
|
-
{ header: "Size", align: "right", color:
|
|
742
|
+
{ header: "File", align: "left", color: pc4.blue },
|
|
743
|
+
{ header: "Size", align: "right", color: pc4.green },
|
|
815
744
|
{
|
|
816
745
|
header: "Gzip",
|
|
817
746
|
align: "right",
|
|
818
|
-
color:
|
|
747
|
+
color: pc4.magenta
|
|
819
748
|
}
|
|
820
749
|
];
|
|
821
750
|
const data = files.map((file) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
3
|
"description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.32",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"import": "./dist/cli/index.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"main": "./dist/index.cjs",
|
|
26
25
|
"license": "MIT",
|
|
27
26
|
"author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
|
|
28
27
|
"maintainers": [
|
|
@@ -52,6 +51,7 @@
|
|
|
52
51
|
"chokidar": "^4.0.3",
|
|
53
52
|
"coffi": "^0.1.31",
|
|
54
53
|
"giget": "^2.0.0",
|
|
54
|
+
"picocolors": "^1.1.1",
|
|
55
55
|
"replace-in-file": "^8.3.0",
|
|
56
56
|
"tinyexec": "^1.0.1"
|
|
57
57
|
},
|