bunup 0.8.30 → 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.d.cts → chunk-8sqm3fje.d.ts} +89 -90
- package/dist/cli/index.js +68 -141
- package/dist/index.d.ts +1 -358
- package/dist/index.js +40 -111
- package/dist/plugins.d.ts +1 -347
- package/dist/plugins.js +40 -111
- package/package.json +102 -96
- package/dist/cli/index.cjs +0 -2030
- package/dist/cli/index.d.ts +0 -360
- package/dist/index.cjs +0 -1168
- package/dist/index.d.cts +0 -362
- package/dist/plugins.cjs +0 -866
- package/dist/plugins.d.cts +0 -385
|
@@ -1,92 +1,4 @@
|
|
|
1
1
|
import _Bun from "bun";
|
|
2
|
-
type PackageJson = {
|
|
3
|
-
/** The parsed content of the package.json file */
|
|
4
|
-
data: Record<string, any> | null
|
|
5
|
-
/** The path to the package.json file */
|
|
6
|
-
path: string | null
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Represents a Bun plugin that can be used with Bunup
|
|
10
|
-
*/
|
|
11
|
-
type BunupBunPlugin = {
|
|
12
|
-
/** Identifies this as a native Bun plugin */
|
|
13
|
-
type: "bun"
|
|
14
|
-
/** Optional name for the plugin */
|
|
15
|
-
name?: string
|
|
16
|
-
/** The actual Bun plugin implementation */
|
|
17
|
-
plugin: BunPlugin
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Represents the meta data of the build
|
|
21
|
-
*/
|
|
22
|
-
type BuildMeta = {
|
|
23
|
-
/** The package.json file */
|
|
24
|
-
packageJson: PackageJson
|
|
25
|
-
/** The root directory of the build */
|
|
26
|
-
rootDir: string
|
|
27
|
-
};
|
|
28
|
-
type BuildOutputFile = {
|
|
29
|
-
/** The kind of the file */
|
|
30
|
-
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
|
|
31
|
-
/** Path to the generated file */
|
|
32
|
-
fullPath: string
|
|
33
|
-
/** Path to the generated file relative to the root directory */
|
|
34
|
-
relativePathToRootDir: string
|
|
35
|
-
/** Path to the generated file relative to the output directory */
|
|
36
|
-
relativePathToOutputDir: string
|
|
37
|
-
/** Whether the file is a dts file */
|
|
38
|
-
dts: boolean
|
|
39
|
-
/** The format of the output file */
|
|
40
|
-
format: Format
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Represents the output of a build operation
|
|
44
|
-
*/
|
|
45
|
-
type BuildOutput = {
|
|
46
|
-
/** Array of generated files with their paths and contents */
|
|
47
|
-
files: BuildOutputFile[]
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Context provided to build hooks
|
|
51
|
-
*/
|
|
52
|
-
type BuildContext = {
|
|
53
|
-
/** The build options that were used */
|
|
54
|
-
options: BuildOptions
|
|
55
|
-
/** The output of the build */
|
|
56
|
-
output: BuildOutput
|
|
57
|
-
/** The meta data of the build */
|
|
58
|
-
meta: BuildMeta
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Hooks that can be implemented by Bunup plugins
|
|
62
|
-
*/
|
|
63
|
-
type BunupPluginHooks = {
|
|
64
|
-
/**
|
|
65
|
-
* Called when a build is successfully completed
|
|
66
|
-
* @param ctx Build context containing options and output
|
|
67
|
-
*/
|
|
68
|
-
onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
|
|
69
|
-
/**
|
|
70
|
-
* Called before a build starts
|
|
71
|
-
* @param options Build options that will be used
|
|
72
|
-
*/
|
|
73
|
-
onBuildStart?: (options: BuildOptions) => MaybePromise<void>
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Represents a Bunup-specific plugin
|
|
77
|
-
*/
|
|
78
|
-
type BunupPlugin = {
|
|
79
|
-
/** Identifies this as a Bunup-specific plugin */
|
|
80
|
-
type: "bunup"
|
|
81
|
-
/** Optional name for the plugin */
|
|
82
|
-
name?: string
|
|
83
|
-
/** The hooks implemented by this plugin */
|
|
84
|
-
hooks: BunupPluginHooks
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Union type representing all supported plugin types
|
|
88
|
-
*/
|
|
89
|
-
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
90
2
|
type Loader = NonNullable<BunBuildOptions["loader"]>[string];
|
|
91
3
|
type Define = BunBuildOptions["define"];
|
|
92
4
|
type Sourcemap = BunBuildOptions["sourcemap"];
|
|
@@ -356,5 +268,92 @@ type DefineWorkspaceItem = {
|
|
|
356
268
|
root: string
|
|
357
269
|
config: DefineConfigItem | DefineConfigItem[]
|
|
358
270
|
};
|
|
359
|
-
type
|
|
360
|
-
|
|
271
|
+
type PackageJson = {
|
|
272
|
+
/** The parsed content of the package.json file */
|
|
273
|
+
data: Record<string, any> | null
|
|
274
|
+
/** The path to the package.json file */
|
|
275
|
+
path: string | null
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Represents a Bun plugin that can be used with Bunup
|
|
279
|
+
*/
|
|
280
|
+
type BunupBunPlugin = {
|
|
281
|
+
/** Identifies this as a native Bun plugin */
|
|
282
|
+
type: "bun"
|
|
283
|
+
/** Optional name for the plugin */
|
|
284
|
+
name?: string
|
|
285
|
+
/** The actual Bun plugin implementation */
|
|
286
|
+
plugin: BunPlugin
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Represents the meta data of the build
|
|
290
|
+
*/
|
|
291
|
+
type BuildMeta = {
|
|
292
|
+
/** The package.json file */
|
|
293
|
+
packageJson: PackageJson
|
|
294
|
+
/** The root directory of the build */
|
|
295
|
+
rootDir: string
|
|
296
|
+
};
|
|
297
|
+
type BuildOutputFile = {
|
|
298
|
+
/** The kind of the file */
|
|
299
|
+
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
|
|
300
|
+
/** Path to the generated file */
|
|
301
|
+
fullPath: string
|
|
302
|
+
/** Path to the generated file relative to the root directory */
|
|
303
|
+
relativePathToRootDir: string
|
|
304
|
+
/** Path to the generated file relative to the output directory */
|
|
305
|
+
relativePathToOutputDir: string
|
|
306
|
+
/** Whether the file is a dts file */
|
|
307
|
+
dts: boolean
|
|
308
|
+
/** The format of the output file */
|
|
309
|
+
format: Format
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Represents the output of a build operation
|
|
313
|
+
*/
|
|
314
|
+
type BuildOutput = {
|
|
315
|
+
/** Array of generated files with their paths and contents */
|
|
316
|
+
files: BuildOutputFile[]
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Context provided to build hooks
|
|
320
|
+
*/
|
|
321
|
+
type BuildContext = {
|
|
322
|
+
/** The build options that were used */
|
|
323
|
+
options: BuildOptions
|
|
324
|
+
/** The output of the build */
|
|
325
|
+
output: BuildOutput
|
|
326
|
+
/** The meta data of the build */
|
|
327
|
+
meta: BuildMeta
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Hooks that can be implemented by Bunup plugins
|
|
331
|
+
*/
|
|
332
|
+
type BunupPluginHooks = {
|
|
333
|
+
/**
|
|
334
|
+
* Called when a build is successfully completed
|
|
335
|
+
* @param ctx Build context containing options and output
|
|
336
|
+
*/
|
|
337
|
+
onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
|
|
338
|
+
/**
|
|
339
|
+
* Called before a build starts
|
|
340
|
+
* @param options Build options that will be used
|
|
341
|
+
*/
|
|
342
|
+
onBuildStart?: (options: BuildOptions) => MaybePromise<void>
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* Represents a Bunup-specific plugin
|
|
346
|
+
*/
|
|
347
|
+
type BunupPlugin = {
|
|
348
|
+
/** Identifies this as a Bunup-specific plugin */
|
|
349
|
+
type: "bunup"
|
|
350
|
+
/** Optional name for the plugin */
|
|
351
|
+
name?: string
|
|
352
|
+
/** The hooks implemented by this plugin */
|
|
353
|
+
hooks: BunupPluginHooks
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Union type representing all supported plugin types
|
|
357
|
+
*/
|
|
358
|
+
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
359
|
+
export { BunupPlugin, Plugin, BuildOptions, MaybePromise, Arrayable, DefineConfigItem, DefineWorkspaceItem };
|
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
|
}
|