bunup 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -6
- package/dist/cli/index.js +16 -34
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -4
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +11 -10
- package/dist/shared/{chunk-xfc23vg1.js → chunk-66717fpt.js} +57 -101
- package/dist/shared/{chunk-rvksjvnx.js → chunk-jkkyf16j.js} +42 -18
- package/package.json +4 -9
- package/dist/shared/chunk-295440tx.js +0 -30
- package/dist/shared/chunk-ab3kjqce.js +0 -45
- package/dist/shared/chunk-mwk1z7nf.js +0 -156
- package/dist/shared/chunk-tcevarkq.js +0 -25
- package/dist/shared/chunk-v8c39y5z.js +0 -341
- /package/dist/shared/{chunk-wpey1xte.d.ts → chunk-d8x7sy99.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -20,15 +20,13 @@ Bunup is the **blazing-fast build tool** for TypeScript libraries, designed for
|
|
|
20
20
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
23
|
-
- ⚡ **
|
|
23
|
+
- ⚡ **Instant Builds**: Instant builds and rebuilds by default.
|
|
24
24
|
- 📝 **Top-Notch TypeScript Declarations**: Clean, minimal, accurate `.d.ts` files generated automatically.
|
|
25
25
|
- 📦 **ESM by Default**: Modern ESM output by default.
|
|
26
|
-
- 🪓 **Declaration Splitting**: Splits shared types for smaller, cleaner
|
|
27
|
-
- 🔥 **Declaration Minification**: Aggressively minifies and shortens type names while preserving public API
|
|
28
|
-
- 🔋 **Batteries Included**: Auto-generates package exports, detects unused dependencies
|
|
29
|
-
- 🚀 **Zero-Config Simplicity**: Preconfigured for productivity—just code and build.
|
|
26
|
+
- 🪓 **[Declaration Splitting](https://bunup.dev/docs/guide/typescript-declarations#declaration-splitting)**: Splits shared types for smaller, cleaner `.d.ts` files.
|
|
27
|
+
- 🔥 **[Declaration Minification](https://bunup.dev/docs/guide/typescript-declarations#minification)**: Aggressively minifies and shortens type names while preserving public API.
|
|
28
|
+
- 🔋 **Batteries Included**: Auto-generates package exports, detects unused dependencies, and more.
|
|
30
29
|
- 🏗️ **[Workspace](https://bunup.dev/docs/guide/workspaces) Ready**: Builds multiple packages from one config and command.
|
|
31
|
-
- 🔄 **Tsup Familiarity**: Familiar CLI and config for easy migration from tsup.
|
|
32
30
|
|
|
33
31
|
## 📚 Documentation
|
|
34
32
|
|
package/dist/cli/index.js
CHANGED
|
@@ -2,32 +2,29 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
import {
|
|
4
4
|
build,
|
|
5
|
-
createBuildOptions
|
|
6
|
-
} from "../shared/chunk-rvksjvnx.js";
|
|
7
|
-
import"../shared/chunk-ab3kjqce.js";
|
|
8
|
-
import {
|
|
5
|
+
createBuildOptions,
|
|
9
6
|
processLoadedConfigs
|
|
10
|
-
} from "../shared/chunk-
|
|
7
|
+
} from "../shared/chunk-jkkyf16j.js";
|
|
11
8
|
import {
|
|
12
9
|
BunupCLIError,
|
|
13
10
|
BunupWatchError,
|
|
14
11
|
__require,
|
|
15
12
|
__toESM,
|
|
16
13
|
ensureArray,
|
|
17
|
-
formatTime,
|
|
18
14
|
getShortFilePath,
|
|
19
15
|
handleError,
|
|
20
16
|
handleErrorAndExit,
|
|
17
|
+
logTime,
|
|
21
18
|
logger,
|
|
22
19
|
parseErrorMessage,
|
|
23
20
|
setSilent
|
|
24
|
-
} from "../shared/chunk-
|
|
21
|
+
} from "../shared/chunk-66717fpt.js";
|
|
25
22
|
|
|
26
23
|
// src/cli/index.ts
|
|
27
24
|
import { loadConfig } from "coffi";
|
|
28
25
|
import pc3 from "picocolors";
|
|
29
26
|
// package.json
|
|
30
|
-
var version = "0.
|
|
27
|
+
var version = "0.10.0";
|
|
31
28
|
|
|
32
29
|
// src/watch.ts
|
|
33
30
|
import path from "path";
|
|
@@ -52,7 +49,8 @@ async function watch(partialOptions, rootDir) {
|
|
|
52
49
|
]
|
|
53
50
|
});
|
|
54
51
|
let isRebuilding = false;
|
|
55
|
-
|
|
52
|
+
let rebuildCount = 0;
|
|
53
|
+
const triggerRebuild = async (initial, changed) => {
|
|
56
54
|
if (isRebuilding) {
|
|
57
55
|
return;
|
|
58
56
|
}
|
|
@@ -60,20 +58,20 @@ async function watch(partialOptions, rootDir) {
|
|
|
60
58
|
try {
|
|
61
59
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
62
60
|
const start = performance.now();
|
|
63
|
-
await build(options, rootDir);
|
|
61
|
+
await build({ ...options, silent: !initial }, rootDir);
|
|
64
62
|
if (!initial) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
63
|
+
console.clear();
|
|
64
|
+
console.log(`${rebuildCount > 1 ? pc.magenta(`[x${rebuildCount}] `) : ""}${pc.green(`Rebuilt in ${logTime(performance.now() - start)}`)}: ${changed}`);
|
|
68
65
|
}
|
|
66
|
+
rebuildCount++;
|
|
69
67
|
} catch (error) {
|
|
70
68
|
handleError(error);
|
|
71
69
|
} finally {
|
|
72
70
|
isRebuilding = false;
|
|
73
71
|
}
|
|
74
72
|
};
|
|
75
|
-
watcher.on("change", () => {
|
|
76
|
-
triggerRebuild();
|
|
73
|
+
watcher.on("change", (path2) => {
|
|
74
|
+
triggerRebuild(false, getShortFilePath(path2));
|
|
77
75
|
});
|
|
78
76
|
watcher.on("error", (error) => {
|
|
79
77
|
throw new BunupWatchError(`Watcher error: ${parseErrorMessage(error)}`);
|
|
@@ -480,16 +478,6 @@ var parseCliOptions = (argv) => {
|
|
|
480
478
|
// src/cli/index.ts
|
|
481
479
|
async function main(args = Bun.argv.slice(2)) {
|
|
482
480
|
const cliOptions = parseCliOptions(args);
|
|
483
|
-
if (cliOptions.new) {
|
|
484
|
-
const { newProject } = await import("../shared/chunk-mwk1z7nf.js");
|
|
485
|
-
await newProject();
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
if (cliOptions.init) {
|
|
489
|
-
const { init } = await import("../shared/chunk-v8c39y5z.js");
|
|
490
|
-
await init();
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
481
|
setSilent(cliOptions.silent);
|
|
494
482
|
const cwd = process.cwd();
|
|
495
483
|
const { config, filepath } = await loadConfig({
|
|
@@ -525,13 +513,9 @@ async function main(args = Bun.argv.slice(2)) {
|
|
|
525
513
|
});
|
|
526
514
|
}));
|
|
527
515
|
const buildTimeMs = performance.now() - startTime;
|
|
528
|
-
|
|
529
|
-
logger.success(`Build completed in ${pc3.green(timeDisplay)}`);
|
|
516
|
+
logger.success(`Build completed in ${pc3.green(logTime(buildTimeMs))}`);
|
|
530
517
|
if (cliOptions.watch) {
|
|
531
|
-
logger.info("Watching for file changes..."
|
|
532
|
-
icon: "\uD83D\uDC40",
|
|
533
|
-
verticalSpace: true
|
|
534
|
-
});
|
|
518
|
+
logger.info(pc3.dim("Watching for file changes..."));
|
|
535
519
|
}
|
|
536
520
|
if (!cliOptions.watch) {
|
|
537
521
|
process.exit(process.exitCode ?? 0);
|
|
@@ -541,9 +525,7 @@ function removeCliOnlyOptions(options) {
|
|
|
541
525
|
return {
|
|
542
526
|
...options,
|
|
543
527
|
config: undefined,
|
|
544
|
-
filter: undefined
|
|
545
|
-
new: undefined,
|
|
546
|
-
init: undefined
|
|
528
|
+
filter: undefined
|
|
547
529
|
};
|
|
548
530
|
}
|
|
549
531
|
main().catch((error) => handleErrorAndExit(error));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin, WithOptional } from "./shared/chunk-
|
|
1
|
+
import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin, WithOptional } from "./shared/chunk-d8x7sy99";
|
|
2
2
|
declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
|
|
3
3
|
declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
|
|
4
|
-
declare function defineWorkspace(options: WithOptional<DefineWorkspaceItem, "config">[], sharedOptions?: DefineConfigItem): DefineWorkspaceItem[];
|
|
4
|
+
declare function defineWorkspace(options: WithOptional<DefineWorkspaceItem, "config">[], sharedOptions?: Partial<DefineConfigItem>): DefineWorkspaceItem[];
|
|
5
5
|
export { defineWorkspace, defineConfig, build, Plugin, DefineWorkspaceItem, DefineConfigItem, BuildOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
build
|
|
4
|
-
} from "./shared/chunk-
|
|
5
|
-
import"./shared/chunk-
|
|
6
|
-
import"./shared/chunk-295440tx.js";
|
|
7
|
-
import"./shared/chunk-xfc23vg1.js";
|
|
4
|
+
} from "./shared/chunk-jkkyf16j.js";
|
|
5
|
+
import"./shared/chunk-66717fpt.js";
|
|
8
6
|
// src/define.ts
|
|
9
7
|
function defineConfig(options) {
|
|
10
8
|
return options;
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./shared/chunk-
|
|
1
|
+
import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./shared/chunk-d8x7sy99";
|
|
2
2
|
/**
|
|
3
3
|
* A plugin that copies files and directories to the output directory.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
5
|
+
* @param pattern - String or array of glob patterns to match files for copying. Patterns starting with '!' exclude matching files.
|
|
6
6
|
* @param outPath - Optional output path. If not provided, uses the build output directory
|
|
7
7
|
* @see https://bunup.dev/docs/plugins/copy
|
|
8
8
|
*/
|
|
9
|
-
declare function copy(
|
|
9
|
+
declare function copy(pattern: string | string[], outPath?: string): BunupPlugin;
|
|
10
10
|
type CustomExports = Record<string, string | Record<string, string | Record<string, string>>>;
|
|
11
11
|
type Exclude = ((ctx: BuildContext) => string[] | undefined) | string[];
|
|
12
12
|
interface ExportsPluginOptions {
|
package/dist/plugins.js
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import {
|
|
3
|
-
getPackageForPlugin
|
|
4
|
-
} from "./shared/chunk-ab3kjqce.js";
|
|
5
2
|
import {
|
|
6
3
|
CSS_RE,
|
|
7
4
|
JS_DTS_RE,
|
|
8
5
|
JS_TS_RE,
|
|
9
6
|
cleanPath,
|
|
7
|
+
ensureArray,
|
|
10
8
|
formatListWithAnd,
|
|
9
|
+
getPackageForPlugin,
|
|
11
10
|
isDirectoryPath,
|
|
12
11
|
logger
|
|
13
|
-
} from "./shared/chunk-
|
|
12
|
+
} from "./shared/chunk-66717fpt.js";
|
|
14
13
|
|
|
15
14
|
// src/plugins/built-in/copy.ts
|
|
16
15
|
import { basename, join } from "path";
|
|
17
|
-
function copy(
|
|
16
|
+
function copy(pattern, outPath) {
|
|
18
17
|
return {
|
|
19
18
|
type: "bunup",
|
|
20
19
|
name: "copy",
|
|
21
20
|
hooks: {
|
|
22
21
|
onBuildDone: async ({ options, meta }) => {
|
|
23
22
|
const destinationPath = outPath || options.outDir;
|
|
24
|
-
for (const
|
|
25
|
-
const glob = new Bun.Glob(
|
|
23
|
+
for (const p of ensureArray(pattern)) {
|
|
24
|
+
const glob = new Bun.Glob(p);
|
|
26
25
|
for await (const filePath of glob.scan({
|
|
27
26
|
cwd: meta.rootDir,
|
|
28
27
|
dot: true
|
|
29
28
|
})) {
|
|
30
29
|
const sourceFile = Bun.file(join(meta.rootDir, filePath));
|
|
31
|
-
await Bun.write(
|
|
30
|
+
await Bun.write(isDirectoryPath(destinationPath) ? join(meta.rootDir, destinationPath, basename(filePath)) : join(meta.rootDir, destinationPath), sourceFile);
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
}
|
|
@@ -37,7 +36,6 @@ function copy(patterns, outPath) {
|
|
|
37
36
|
}
|
|
38
37
|
// src/plugins/built-in/exports.ts
|
|
39
38
|
import path from "path";
|
|
40
|
-
import equal from "fast-deep-equal";
|
|
41
39
|
function exports(options = {}) {
|
|
42
40
|
return {
|
|
43
41
|
type: "bunup",
|
|
@@ -59,7 +57,7 @@ async function processPackageJsonExports(ctx, options) {
|
|
|
59
57
|
const updatedFiles = createUpdatedFilesArray(meta.packageJson.data, buildOptions.outDir);
|
|
60
58
|
const mergedExports = mergeCustomExportsWithGenerated(exportsField, options.customExports, ctx);
|
|
61
59
|
const newPackageJson = createUpdatedPackageJson(meta.packageJson.data, entryPoints, mergedExports, updatedFiles);
|
|
62
|
-
if (
|
|
60
|
+
if (Bun.deepEquals(newPackageJson, meta.packageJson.data)) {
|
|
63
61
|
return;
|
|
64
62
|
}
|
|
65
63
|
await Bun.write(meta.packageJson.path, JSON.stringify(newPackageJson, null, 2));
|
|
@@ -386,6 +384,9 @@ function unused(options = {}) {
|
|
|
386
384
|
hooks: {
|
|
387
385
|
onBuildDone: async (ctx) => {
|
|
388
386
|
const { options: buildOptions, output, meta } = ctx;
|
|
387
|
+
if (buildOptions.watch) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
389
390
|
const transpiler = new Bun.Transpiler({
|
|
390
391
|
loader: "js"
|
|
391
392
|
});
|
|
@@ -141,28 +141,31 @@ function logTable(columns, data, footer) {
|
|
|
141
141
|
const pad = (str, width, align) => {
|
|
142
142
|
return align === "left" ? str.padEnd(width) : str.padStart(width);
|
|
143
143
|
};
|
|
144
|
-
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(pc.
|
|
145
|
-
console.log(pc.
|
|
144
|
+
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(pc.dim(" | "));
|
|
145
|
+
console.log(pc.dim(headerRow));
|
|
146
146
|
const separator = columns.map((col) => "-".repeat(widths[col.header])).join(" | ");
|
|
147
|
-
console.log(pc.
|
|
147
|
+
console.log(pc.dim(separator));
|
|
148
148
|
for (const row of data) {
|
|
149
149
|
const rowStr = columns.map((col) => {
|
|
150
150
|
const value = row[col.header] || "";
|
|
151
151
|
const padded = pad(value, widths[col.header], col.align);
|
|
152
152
|
return col.color ? col.color(padded) : padded;
|
|
153
|
-
}).join(pc.
|
|
153
|
+
}).join(pc.dim(" | "));
|
|
154
154
|
console.log(rowStr);
|
|
155
155
|
}
|
|
156
|
-
console.log(pc.
|
|
156
|
+
console.log(pc.dim(separator));
|
|
157
157
|
if (footer) {
|
|
158
158
|
const footerRow = columns.map((col) => {
|
|
159
159
|
const value = footer[col.header] || "";
|
|
160
160
|
const padded = pad(value, widths[col.header], col.align);
|
|
161
161
|
return padded;
|
|
162
|
-
}).join(pc.
|
|
162
|
+
}).join(pc.dim(" | "));
|
|
163
163
|
console.log(footerRow);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
+
function logTime(ms) {
|
|
167
|
+
return ms >= 1000 ? pc.green(`${(ms / 1000).toFixed(2)}s`) : pc.green(`${Math.round(ms)}ms`);
|
|
168
|
+
}
|
|
166
169
|
var link = (url, label) => {
|
|
167
170
|
if (!label) {
|
|
168
171
|
label = url;
|
|
@@ -233,7 +236,7 @@ var KNOWN_ERRORS = [
|
|
|
233
236
|
pattern: /has already been exported. Exported identifiers must be unique./i,
|
|
234
237
|
errorType: "DTS ERROR",
|
|
235
238
|
logSolution: () => {
|
|
236
|
-
logger.log("An error occurred while bundling dts files. This issue occurs when dts splitting is enabled due to a bug in the Bun bundler. Please ping the GitHub issue to help get it fixed faster: " + link("https://github.com/oven-sh/bun/issues/5344") + ". To fix this issue for now, you can disable dts splitting by removing " + pc2.
|
|
239
|
+
logger.log("An error occurred while bundling dts files. This issue occurs when dts splitting is enabled due to a bug in the Bun bundler. Please ping the GitHub issue to help get it fixed faster: " + link("https://github.com/oven-sh/bun/issues/5344") + ". To fix this issue for now, you can disable dts splitting by removing " + pc2.dim("dts: { splitting: true }") + " from your config." + " You can re-enable it once the issue is fixed.");
|
|
237
240
|
}
|
|
238
241
|
}
|
|
239
242
|
];
|
|
@@ -287,85 +290,9 @@ var handleErrorAndExit = (error, context) => {
|
|
|
287
290
|
};
|
|
288
291
|
|
|
289
292
|
// src/utils.ts
|
|
290
|
-
import fsSync from "fs";
|
|
291
293
|
import fs from "fs/promises";
|
|
292
294
|
import path, { normalize } from "path";
|
|
293
295
|
|
|
294
|
-
// node_modules/std-env/dist/index.mjs
|
|
295
|
-
var r = Object.create(null);
|
|
296
|
-
var i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
|
|
297
|
-
var o = new Proxy(r, { get(e, s) {
|
|
298
|
-
return i()[s] ?? r[s];
|
|
299
|
-
}, has(e, s) {
|
|
300
|
-
const E = i();
|
|
301
|
-
return s in E || s in r;
|
|
302
|
-
}, set(e, s, E) {
|
|
303
|
-
const B = i(true);
|
|
304
|
-
return B[s] = E, true;
|
|
305
|
-
}, deleteProperty(e, s) {
|
|
306
|
-
if (!s)
|
|
307
|
-
return false;
|
|
308
|
-
const E = i(true);
|
|
309
|
-
return delete E[s], true;
|
|
310
|
-
}, ownKeys() {
|
|
311
|
-
const e = i(true);
|
|
312
|
-
return Object.keys(e);
|
|
313
|
-
} });
|
|
314
|
-
var t = typeof process < "u" && process.env && "development" || "";
|
|
315
|
-
var f = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CLOUDFLARE_WORKERS", "WORKERS_CI", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
|
|
316
|
-
function b() {
|
|
317
|
-
if (globalThis.process?.env)
|
|
318
|
-
for (const e of f) {
|
|
319
|
-
const s = e[1] || e[0];
|
|
320
|
-
if (globalThis.process?.env[s])
|
|
321
|
-
return { name: e[0].toLowerCase(), ...e[2] };
|
|
322
|
-
}
|
|
323
|
-
return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
|
|
324
|
-
}
|
|
325
|
-
var l = b();
|
|
326
|
-
var p = l.name;
|
|
327
|
-
function n(e) {
|
|
328
|
-
return e ? e !== "false" : false;
|
|
329
|
-
}
|
|
330
|
-
var I = globalThis.process?.platform || "";
|
|
331
|
-
var T = n(o.CI) || l.ci !== false;
|
|
332
|
-
var R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
|
|
333
|
-
var U = typeof window < "u";
|
|
334
|
-
var d = n(o.DEBUG);
|
|
335
|
-
var a = t === "test" || n(o.TEST);
|
|
336
|
-
var v = n(o.MINIMAL) || T || a || !R;
|
|
337
|
-
var A = /^win/i.test(I);
|
|
338
|
-
var M = /^linux/i.test(I);
|
|
339
|
-
var m = /^darwin/i.test(I);
|
|
340
|
-
var Y = !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (R || A) && o.TERM !== "dumb" || T);
|
|
341
|
-
var C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
|
|
342
|
-
var V = Number(C?.split(".")[0]) || null;
|
|
343
|
-
var W = globalThis.process || Object.create(null);
|
|
344
|
-
var _ = { versions: {} };
|
|
345
|
-
var y = new Proxy(W, { get(e, s) {
|
|
346
|
-
if (s === "env")
|
|
347
|
-
return o;
|
|
348
|
-
if (s in e)
|
|
349
|
-
return e[s];
|
|
350
|
-
if (s in _)
|
|
351
|
-
return _[s];
|
|
352
|
-
} });
|
|
353
|
-
var O = globalThis.process?.release?.name === "node";
|
|
354
|
-
var c = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
|
|
355
|
-
var D = !!globalThis.Deno;
|
|
356
|
-
var L = !!globalThis.fastly;
|
|
357
|
-
var S = !!globalThis.Netlify;
|
|
358
|
-
var u = !!globalThis.EdgeRuntime;
|
|
359
|
-
var N = globalThis.navigator?.userAgent === "Cloudflare-Workers";
|
|
360
|
-
var F = [[S, "netlify"], [u, "edge-light"], [N, "workerd"], [L, "fastly"], [D, "deno"], [c, "bun"], [O, "node"]];
|
|
361
|
-
function G() {
|
|
362
|
-
const e = F.find((s) => s[0]);
|
|
363
|
-
if (e)
|
|
364
|
-
return { name: e[1] };
|
|
365
|
-
}
|
|
366
|
-
var P = G();
|
|
367
|
-
var K = P?.name || "";
|
|
368
|
-
|
|
369
296
|
// src/constants/re.ts
|
|
370
297
|
var JS_RE = /\.(js|jsx|cjs|mjs)$/;
|
|
371
298
|
var TS_RE = /\.(ts|tsx|mts|cts)$/;
|
|
@@ -403,9 +330,6 @@ function getDefaultDtsExtention(format, packageType, kind) {
|
|
|
403
330
|
function isModulePackage(packageType) {
|
|
404
331
|
return packageType === "module";
|
|
405
332
|
}
|
|
406
|
-
function formatTime(ms) {
|
|
407
|
-
return ms >= 1000 ? `${(ms / 1000).toFixed(2)}s` : `${Math.round(ms)}ms`;
|
|
408
|
-
}
|
|
409
333
|
function getPackageDeps(packageJson) {
|
|
410
334
|
if (!packageJson)
|
|
411
335
|
return [];
|
|
@@ -418,10 +342,10 @@ function formatFileSize(bytes) {
|
|
|
418
342
|
if (bytes === 0)
|
|
419
343
|
return "0 B";
|
|
420
344
|
const units = ["B", "KB", "MB", "GB"];
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
423
|
-
return `${bytes} ${units[
|
|
424
|
-
return `${(bytes / 1024 **
|
|
345
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
346
|
+
if (i === 0)
|
|
347
|
+
return `${bytes} ${units[i]}`;
|
|
348
|
+
return `${(bytes / 1024 ** i).toFixed(2)} ${units[i]}`;
|
|
425
349
|
}
|
|
426
350
|
function getShortFilePath(filePath, maxLength = 3) {
|
|
427
351
|
const fileParts = filePath.split("/");
|
|
@@ -447,14 +371,6 @@ function cleanPath(path2) {
|
|
|
447
371
|
function isDirectoryPath(filePath) {
|
|
448
372
|
return path.extname(filePath) === "";
|
|
449
373
|
}
|
|
450
|
-
function pathExistsSync(filePath) {
|
|
451
|
-
try {
|
|
452
|
-
fsSync.accessSync(filePath);
|
|
453
|
-
return true;
|
|
454
|
-
} catch {
|
|
455
|
-
return false;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
374
|
function formatListWithAnd(arr) {
|
|
459
375
|
return new Intl.ListFormat("en", {
|
|
460
376
|
style: "long",
|
|
@@ -462,8 +378,8 @@ function formatListWithAnd(arr) {
|
|
|
462
378
|
}).format(arr);
|
|
463
379
|
}
|
|
464
380
|
async function getFilesFromGlobs(patterns, cwd) {
|
|
465
|
-
const includePatterns = patterns.filter((
|
|
466
|
-
const excludePatterns = patterns.filter((
|
|
381
|
+
const includePatterns = patterns.filter((p) => !p.startsWith("!"));
|
|
382
|
+
const excludePatterns = patterns.filter((p) => p.startsWith("!")).map((p) => p.slice(1));
|
|
467
383
|
const includedFiles = new Set;
|
|
468
384
|
for (const pattern of includePatterns) {
|
|
469
385
|
const glob = new Bun.Glob(pattern);
|
|
@@ -487,4 +403,44 @@ function isTypeScriptFile(path2) {
|
|
|
487
403
|
return TS_RE.test(path2);
|
|
488
404
|
}
|
|
489
405
|
|
|
490
|
-
|
|
406
|
+
// src/plugins/utils.ts
|
|
407
|
+
import pc3 from "picocolors";
|
|
408
|
+
function filterBunupBunPlugins(plugins) {
|
|
409
|
+
if (!plugins)
|
|
410
|
+
return [];
|
|
411
|
+
return plugins.filter((p) => p.type === "bun");
|
|
412
|
+
}
|
|
413
|
+
function filterBunupPlugins(plugins) {
|
|
414
|
+
if (!plugins)
|
|
415
|
+
return [];
|
|
416
|
+
return plugins.filter((p) => p.type === "bunup");
|
|
417
|
+
}
|
|
418
|
+
async function runPluginBuildStartHooks(bunupPlugins, options) {
|
|
419
|
+
if (!bunupPlugins)
|
|
420
|
+
return;
|
|
421
|
+
for (const plugin of bunupPlugins) {
|
|
422
|
+
if (plugin.hooks.onBuildStart) {
|
|
423
|
+
await plugin.hooks.onBuildStart(options);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
async function runPluginBuildDoneHooks(bunupPlugins, options, output, meta) {
|
|
428
|
+
if (!bunupPlugins)
|
|
429
|
+
return;
|
|
430
|
+
for (const plugin of bunupPlugins) {
|
|
431
|
+
if (plugin.hooks.onBuildDone) {
|
|
432
|
+
await plugin.hooks.onBuildDone({ options, output, meta });
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
async function getPackageForPlugin(name, pluginName) {
|
|
437
|
+
let pkg;
|
|
438
|
+
try {
|
|
439
|
+
pkg = await import(name);
|
|
440
|
+
} catch {
|
|
441
|
+
throw new BunupPluginError(`[${pc3.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc3.blue(`bun add ${name} --dev`)}`);
|
|
442
|
+
}
|
|
443
|
+
return pkg;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export { __toESM, __require, silent, setSilent, logTable, logTime, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, formatListWithAnd, getFilesFromGlobs, isTypeScriptFile, filterBunupBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, getPackageForPlugin };
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
filterBunupBunPlugins,
|
|
3
|
-
filterBunupPlugins,
|
|
4
|
-
runPluginBuildDoneHooks,
|
|
5
|
-
runPluginBuildStartHooks
|
|
6
|
-
} from "./chunk-ab3kjqce.js";
|
|
7
|
-
import {
|
|
8
|
-
loadPackageJson
|
|
9
|
-
} from "./chunk-295440tx.js";
|
|
10
1
|
import {
|
|
11
2
|
BunupBuildError,
|
|
12
3
|
BunupDTSBuildError,
|
|
13
4
|
cleanOutDir,
|
|
14
5
|
cleanPath,
|
|
15
6
|
ensureArray,
|
|
7
|
+
filterBunupBunPlugins,
|
|
8
|
+
filterBunupPlugins,
|
|
16
9
|
formatFileSize,
|
|
17
10
|
getDefaultDtsExtention,
|
|
18
11
|
getDefaultOutputExtension,
|
|
@@ -23,12 +16,43 @@ import {
|
|
|
23
16
|
logTable,
|
|
24
17
|
logger,
|
|
25
18
|
parseErrorMessage,
|
|
19
|
+
runPluginBuildDoneHooks,
|
|
20
|
+
runPluginBuildStartHooks,
|
|
26
21
|
setSilent,
|
|
27
22
|
silent
|
|
28
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-66717fpt.js";
|
|
29
24
|
|
|
30
|
-
// src/
|
|
25
|
+
// src/loaders.ts
|
|
31
26
|
import path from "path";
|
|
27
|
+
import { loadConfig } from "coffi";
|
|
28
|
+
async function processLoadedConfigs(config, cwd, filter) {
|
|
29
|
+
return Array.isArray(config) && "root" in config[0] ? config.filter((c) => filter ? filter.includes(c.name) : true).map((c) => ({
|
|
30
|
+
rootDir: path.resolve(cwd, c.root),
|
|
31
|
+
options: addField(c.config, "name", c.name)
|
|
32
|
+
})) : [
|
|
33
|
+
{
|
|
34
|
+
rootDir: cwd,
|
|
35
|
+
options: config
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
function addField(objectOrArray, field, value) {
|
|
40
|
+
return Array.isArray(objectOrArray) ? objectOrArray.map((o) => ({ ...o, [field]: value })) : { ...objectOrArray, [field]: value };
|
|
41
|
+
}
|
|
42
|
+
async function loadPackageJson(cwd = process.cwd()) {
|
|
43
|
+
const { config, filepath } = await loadConfig({
|
|
44
|
+
name: "package",
|
|
45
|
+
cwd,
|
|
46
|
+
extensions: [".json"]
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
data: config,
|
|
50
|
+
path: filepath
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/build.ts
|
|
55
|
+
import path2 from "path";
|
|
32
56
|
import pc2 from "picocolors";
|
|
33
57
|
import { generateDts, logIsolatedDeclarationErrors } from "typeroll";
|
|
34
58
|
|
|
@@ -226,13 +250,13 @@ function getResolvedEnv(env) {
|
|
|
226
250
|
function getPackageDepsPatterns(packageJson) {
|
|
227
251
|
return getPackageDeps(packageJson).map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`));
|
|
228
252
|
}
|
|
229
|
-
function matchesPattern(
|
|
230
|
-
return typeof pattern === "string" ? pattern ===
|
|
253
|
+
function matchesPattern(path2, pattern) {
|
|
254
|
+
return typeof pattern === "string" ? pattern === path2 : pattern.test(path2);
|
|
231
255
|
}
|
|
232
|
-
function isExternal(
|
|
256
|
+
function isExternal(path2, options, packageJson) {
|
|
233
257
|
const packageDepsPatterns = getPackageDepsPatterns(packageJson);
|
|
234
|
-
const matchesExternalPattern = packageDepsPatterns.some((pattern) => pattern.test(
|
|
235
|
-
const isExcludedFromExternal = options.noExternal?.some((pattern) => matchesPattern(
|
|
258
|
+
const matchesExternalPattern = packageDepsPatterns.some((pattern) => pattern.test(path2)) || options.external?.some((pattern) => matchesPattern(path2, pattern));
|
|
259
|
+
const isExcludedFromExternal = options.noExternal?.some((pattern) => matchesPattern(path2, pattern));
|
|
236
260
|
return matchesExternalPattern && !isExcludedFromExternal;
|
|
237
261
|
}
|
|
238
262
|
|
|
@@ -373,7 +397,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
373
397
|
identifier: options.name
|
|
374
398
|
});
|
|
375
399
|
}
|
|
376
|
-
const fullPath =
|
|
400
|
+
const fullPath = path2.join(rootDir, relativePathToRootDir);
|
|
377
401
|
await Bun.write(fullPath, file.dts);
|
|
378
402
|
buildOutput.files.push({
|
|
379
403
|
fullPath,
|
|
@@ -405,4 +429,4 @@ function getRelativePathToOutputDir(relativePathToRootDir, outDir) {
|
|
|
405
429
|
return cleanPath(relativePathToRootDir).replace(`${cleanPath(outDir)}/`, "");
|
|
406
430
|
}
|
|
407
431
|
|
|
408
|
-
export { createBuildOptions, build };
|
|
432
|
+
export { processLoadedConfigs, createBuildOptions, build };
|
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.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -46,21 +46,16 @@
|
|
|
46
46
|
"bunup": "dist/cli/index.js"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@clack/prompts": "^0.10.1",
|
|
50
49
|
"chokidar": "^4.0.3",
|
|
51
50
|
"coffi": "^0.1.31",
|
|
52
|
-
"fast-deep-equal": "^3.1.3",
|
|
53
|
-
"giget": "^2.0.0",
|
|
54
51
|
"picocolors": "^1.1.1",
|
|
55
|
-
"replace-in-file": "^8.3.0",
|
|
56
52
|
"tinyexec": "^1.0.1",
|
|
57
53
|
"tree-kill": "^1.2.2",
|
|
58
54
|
"typeroll": "^0.6.22"
|
|
59
55
|
},
|
|
60
56
|
"devDependencies": {
|
|
61
|
-
"@babel/types": "^7.28.2",
|
|
62
57
|
"@biomejs/biome": "2.0.0",
|
|
63
|
-
"@types/bun": "^1.2.
|
|
58
|
+
"@types/bun": "^1.2.20",
|
|
64
59
|
"bumpp": "^10.2.2",
|
|
65
60
|
"husky": "^9.1.7",
|
|
66
61
|
"lightningcss": "^1.30.1",
|
|
@@ -80,9 +75,9 @@
|
|
|
80
75
|
}
|
|
81
76
|
},
|
|
82
77
|
"scripts": {
|
|
83
|
-
"build": "
|
|
78
|
+
"build": "bun run src/cli/index.ts",
|
|
84
79
|
"build:docs": "bun run --cwd docs build",
|
|
85
|
-
"dev": "
|
|
80
|
+
"dev": "bun run src/cli/index.ts --watch",
|
|
86
81
|
"dev:docs": "bun run --cwd docs dev",
|
|
87
82
|
"format": "biome format .",
|
|
88
83
|
"format:fix": "biome format --write .",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// src/loaders.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { loadConfig } from "coffi";
|
|
4
|
-
async function processLoadedConfigs(config, cwd, filter) {
|
|
5
|
-
return Array.isArray(config) && "root" in config[0] ? config.filter((c) => filter ? filter.includes(c.name) : true).map((c) => ({
|
|
6
|
-
rootDir: path.resolve(cwd, c.root),
|
|
7
|
-
options: addField(c.config, "name", c.name)
|
|
8
|
-
})) : [
|
|
9
|
-
{
|
|
10
|
-
rootDir: cwd,
|
|
11
|
-
options: config
|
|
12
|
-
}
|
|
13
|
-
];
|
|
14
|
-
}
|
|
15
|
-
function addField(objectOrArray, field, value) {
|
|
16
|
-
return Array.isArray(objectOrArray) ? objectOrArray.map((o) => ({ ...o, [field]: value })) : { ...objectOrArray, [field]: value };
|
|
17
|
-
}
|
|
18
|
-
async function loadPackageJson(cwd = process.cwd()) {
|
|
19
|
-
const { config, filepath } = await loadConfig({
|
|
20
|
-
name: "package",
|
|
21
|
-
cwd,
|
|
22
|
-
extensions: [".json"]
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
data: config,
|
|
26
|
-
path: filepath
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { processLoadedConfigs, loadPackageJson };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BunupPluginError
|
|
3
|
-
} from "./chunk-xfc23vg1.js";
|
|
4
|
-
|
|
5
|
-
// src/plugins/utils.ts
|
|
6
|
-
import pc from "picocolors";
|
|
7
|
-
function filterBunupBunPlugins(plugins) {
|
|
8
|
-
if (!plugins)
|
|
9
|
-
return [];
|
|
10
|
-
return plugins.filter((p) => p.type === "bun");
|
|
11
|
-
}
|
|
12
|
-
function filterBunupPlugins(plugins) {
|
|
13
|
-
if (!plugins)
|
|
14
|
-
return [];
|
|
15
|
-
return plugins.filter((p) => p.type === "bunup");
|
|
16
|
-
}
|
|
17
|
-
async function runPluginBuildStartHooks(bunupPlugins, options) {
|
|
18
|
-
if (!bunupPlugins)
|
|
19
|
-
return;
|
|
20
|
-
for (const plugin of bunupPlugins) {
|
|
21
|
-
if (plugin.hooks.onBuildStart) {
|
|
22
|
-
await plugin.hooks.onBuildStart(options);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async function runPluginBuildDoneHooks(bunupPlugins, options, output, meta) {
|
|
27
|
-
if (!bunupPlugins)
|
|
28
|
-
return;
|
|
29
|
-
for (const plugin of bunupPlugins) {
|
|
30
|
-
if (plugin.hooks.onBuildDone) {
|
|
31
|
-
await plugin.hooks.onBuildDone({ options, output, meta });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async function getPackageForPlugin(name, pluginName) {
|
|
36
|
-
let pkg;
|
|
37
|
-
try {
|
|
38
|
-
pkg = await import(name);
|
|
39
|
-
} catch {
|
|
40
|
-
throw new BunupPluginError(`[${pc.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc.blue(`bun add ${name} --dev`)}`);
|
|
41
|
-
}
|
|
42
|
-
return pkg;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { filterBunupBunPlugins, filterBunupPlugins, runPluginBuildStartHooks, runPluginBuildDoneHooks, getPackageForPlugin };
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
displayBunupGradientArt
|
|
4
|
-
} from "./chunk-tcevarkq.js";
|
|
5
|
-
import {
|
|
6
|
-
link,
|
|
7
|
-
pathExistsSync
|
|
8
|
-
} from "./chunk-xfc23vg1.js";
|
|
9
|
-
|
|
10
|
-
// src/cli/new.ts
|
|
11
|
-
import { renameSync } from "fs";
|
|
12
|
-
import path from "path";
|
|
13
|
-
import {
|
|
14
|
-
cancel,
|
|
15
|
-
confirm,
|
|
16
|
-
intro,
|
|
17
|
-
outro,
|
|
18
|
-
select,
|
|
19
|
-
tasks,
|
|
20
|
-
text
|
|
21
|
-
} from "@clack/prompts";
|
|
22
|
-
import { downloadTemplate } from "giget";
|
|
23
|
-
import pc from "picocolors";
|
|
24
|
-
import { replaceInFile } from "replace-in-file";
|
|
25
|
-
var TEMPLATE_OWNER = "arshad-yaseen";
|
|
26
|
-
var TEMPLATE_REPO = "bunup-new";
|
|
27
|
-
var GITHUB_USERNAME_PLACEHOLDER = "username";
|
|
28
|
-
var GITHUB_REPO_PLACEHOLDER = "repo-name";
|
|
29
|
-
var MONOREPO_FIRST_PACKAGE_NAME_PLACEHOLDER = "package-1";
|
|
30
|
-
var MONOREPO_PACKAGES_DIR = "packages";
|
|
31
|
-
var TEMPLATES = [
|
|
32
|
-
{
|
|
33
|
-
type: "typescript",
|
|
34
|
-
defaultName: "my-ts-lib",
|
|
35
|
-
name: "TypeScript Library",
|
|
36
|
-
dir: "ts-lib",
|
|
37
|
-
monorepoDir: "ts-lib-monorepo"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: "react",
|
|
41
|
-
defaultName: "my-react-lib",
|
|
42
|
-
name: "React Library",
|
|
43
|
-
dir: "react-lib"
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
async function newProject() {
|
|
47
|
-
displayBunupGradientArt();
|
|
48
|
-
intro(pc.bgCyan(pc.black(" Scaffold a new project with Bunup ")));
|
|
49
|
-
const selectedTemplateDir = await select({
|
|
50
|
-
message: "Select a template",
|
|
51
|
-
options: TEMPLATES.map((template2) => ({
|
|
52
|
-
value: template2.dir,
|
|
53
|
-
label: pc.blue(template2.name)
|
|
54
|
-
}))
|
|
55
|
-
});
|
|
56
|
-
const template = TEMPLATES.find((t) => t.dir === selectedTemplateDir);
|
|
57
|
-
if (!template) {
|
|
58
|
-
cancel("Invalid template");
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
const hasMonorepo = template.monorepoDir !== undefined;
|
|
62
|
-
const projectName = await text({
|
|
63
|
-
message: "Enter the project name",
|
|
64
|
-
placeholder: template.defaultName,
|
|
65
|
-
defaultValue: template.defaultName,
|
|
66
|
-
validate: (value) => {
|
|
67
|
-
if (!value) {
|
|
68
|
-
return "Project name is required";
|
|
69
|
-
}
|
|
70
|
-
if (value.includes(" ")) {
|
|
71
|
-
return "Project name cannot contain spaces";
|
|
72
|
-
}
|
|
73
|
-
if (pathExistsSync(getProjectPath(value))) {
|
|
74
|
-
return "Project already exists";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const projectPath = getProjectPath(projectName);
|
|
79
|
-
let useMonorepo = false;
|
|
80
|
-
let monorepoFirstPackageName;
|
|
81
|
-
if (hasMonorepo) {
|
|
82
|
-
useMonorepo = await confirm({
|
|
83
|
-
message: "Do you want to create a monorepo?",
|
|
84
|
-
initialValue: false
|
|
85
|
-
});
|
|
86
|
-
if (useMonorepo) {
|
|
87
|
-
monorepoFirstPackageName = await text({
|
|
88
|
-
message: "Enter the name of the first package",
|
|
89
|
-
placeholder: MONOREPO_FIRST_PACKAGE_NAME_PLACEHOLDER,
|
|
90
|
-
defaultValue: MONOREPO_FIRST_PACKAGE_NAME_PLACEHOLDER
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const githubRepoInfo = await text({
|
|
95
|
-
message: "GitHub username and repo name (username/repo):",
|
|
96
|
-
placeholder: `${GITHUB_USERNAME_PLACEHOLDER}/${GITHUB_REPO_PLACEHOLDER}`,
|
|
97
|
-
defaultValue: `${GITHUB_USERNAME_PLACEHOLDER}/${GITHUB_REPO_PLACEHOLDER}`
|
|
98
|
-
});
|
|
99
|
-
const [githubUsername, githubRepoName] = githubRepoInfo.split("/");
|
|
100
|
-
await tasks([
|
|
101
|
-
{
|
|
102
|
-
title: "Downloading template",
|
|
103
|
-
task: async () => {
|
|
104
|
-
const templatePath = useMonorepo ? template.monorepoDir : template.dir;
|
|
105
|
-
await downloadTemplate(`github:${TEMPLATE_OWNER}/${TEMPLATE_REPO}/${templatePath}`, {
|
|
106
|
-
dir: projectPath
|
|
107
|
-
});
|
|
108
|
-
return "Template downloaded";
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
title: "Making the project yours",
|
|
113
|
-
task: async () => {
|
|
114
|
-
await replaceInFile({
|
|
115
|
-
files: path.join(projectPath, "**/*"),
|
|
116
|
-
from: [
|
|
117
|
-
new RegExp(GITHUB_REPO_PLACEHOLDER, "g"),
|
|
118
|
-
new RegExp(GITHUB_USERNAME_PLACEHOLDER, "g"),
|
|
119
|
-
new RegExp(template.defaultName, "g")
|
|
120
|
-
],
|
|
121
|
-
to: [githubRepoName, githubUsername, projectName],
|
|
122
|
-
ignore: ["node_modules", "dist", "bun.lock"]
|
|
123
|
-
});
|
|
124
|
-
if (useMonorepo && monorepoFirstPackageName) {
|
|
125
|
-
await replaceInFile({
|
|
126
|
-
files: path.join(projectPath, "**/*"),
|
|
127
|
-
from: [new RegExp(MONOREPO_FIRST_PACKAGE_NAME_PLACEHOLDER, "g")],
|
|
128
|
-
to: [monorepoFirstPackageName],
|
|
129
|
-
ignore: ["node_modules", "dist", "bun.lock"]
|
|
130
|
-
});
|
|
131
|
-
renameSync(path.join(projectPath, MONOREPO_PACKAGES_DIR, MONOREPO_FIRST_PACKAGE_NAME_PLACEHOLDER), path.join(projectPath, MONOREPO_PACKAGES_DIR, monorepoFirstPackageName));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
]);
|
|
136
|
-
outro(`
|
|
137
|
-
${pc.green("\u2728 Project scaffolded successfully! \u2728")}
|
|
138
|
-
|
|
139
|
-
${pc.bold("Ready to launch your awesome new project?")}
|
|
140
|
-
|
|
141
|
-
${pc.cyan("cd")} ${projectName}
|
|
142
|
-
${pc.cyan("bun install")}
|
|
143
|
-
${pc.cyan("bun run dev")}${pc.dim(" (watch mode for development)")}${template.type === "react" ? `
|
|
144
|
-
${pc.cyan("bun run dev:test")} ${pc.dim("(preview components in a test Next.js app)")} ` : ""}
|
|
145
|
-
|
|
146
|
-
${pc.dim("Learn more:")} ${link("https://bunup.dev/")}
|
|
147
|
-
|
|
148
|
-
${pc.yellow("Happy coding!")} \uD83D\uDE80
|
|
149
|
-
`);
|
|
150
|
-
}
|
|
151
|
-
function getProjectPath(projectName) {
|
|
152
|
-
return path.join(process.cwd(), projectName);
|
|
153
|
-
}
|
|
154
|
-
export {
|
|
155
|
-
newProject
|
|
156
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
logger
|
|
3
|
-
} from "./chunk-xfc23vg1.js";
|
|
4
|
-
|
|
5
|
-
// src/cli/utils.ts
|
|
6
|
-
import pc from "picocolors";
|
|
7
|
-
function displayBunupGradientArt() {
|
|
8
|
-
const art = `
|
|
9
|
-
\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
|
|
10
|
-
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
|
|
11
|
-
\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D
|
|
12
|
-
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u255D
|
|
13
|
-
\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551
|
|
14
|
-
\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D
|
|
15
|
-
`.trim();
|
|
16
|
-
const lines = art.split(`
|
|
17
|
-
`);
|
|
18
|
-
logger.space();
|
|
19
|
-
for (const line of lines) {
|
|
20
|
-
console.log(pc.cyan(line));
|
|
21
|
-
}
|
|
22
|
-
logger.space();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { displayBunupGradientArt };
|
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
loadPackageJson
|
|
4
|
-
} from "./chunk-295440tx.js";
|
|
5
|
-
import {
|
|
6
|
-
displayBunupGradientArt
|
|
7
|
-
} from "./chunk-tcevarkq.js";
|
|
8
|
-
import {
|
|
9
|
-
formatListWithAnd,
|
|
10
|
-
link
|
|
11
|
-
} from "./chunk-xfc23vg1.js";
|
|
12
|
-
|
|
13
|
-
// src/cli/init.ts
|
|
14
|
-
import fs from "fs";
|
|
15
|
-
import path from "path";
|
|
16
|
-
import {
|
|
17
|
-
confirm,
|
|
18
|
-
intro,
|
|
19
|
-
log,
|
|
20
|
-
multiselect,
|
|
21
|
-
outro,
|
|
22
|
-
select,
|
|
23
|
-
tasks,
|
|
24
|
-
text
|
|
25
|
-
} from "@clack/prompts";
|
|
26
|
-
import pc from "picocolors";
|
|
27
|
-
import { exec } from "tinyexec";
|
|
28
|
-
async function init() {
|
|
29
|
-
displayBunupGradientArt();
|
|
30
|
-
intro(pc.bgCyan(pc.black(" Initialize bunup in an existing project ")));
|
|
31
|
-
const { path: packageJsonPath } = await loadPackageJson();
|
|
32
|
-
if (!packageJsonPath) {
|
|
33
|
-
log.error("package.json not found");
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
const shouldSetupWorkspace = await promptForWorkspace();
|
|
37
|
-
if (shouldSetupWorkspace) {
|
|
38
|
-
await initializeWorkspace(packageJsonPath);
|
|
39
|
-
} else {
|
|
40
|
-
await initializeSinglePackage(packageJsonPath);
|
|
41
|
-
}
|
|
42
|
-
await tasks([
|
|
43
|
-
{
|
|
44
|
-
title: "Installing bunup",
|
|
45
|
-
task: async () => {
|
|
46
|
-
await installBunup();
|
|
47
|
-
return "Bunup installed";
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
]);
|
|
51
|
-
showSuccessOutro(shouldSetupWorkspace);
|
|
52
|
-
}
|
|
53
|
-
async function promptForWorkspace() {
|
|
54
|
-
return await confirm({
|
|
55
|
-
message: "Do you want to setup a Bunup workspace? (for building multiple packages with one command)",
|
|
56
|
-
initialValue: false
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
async function initializeWorkspace(packageJsonPath) {
|
|
60
|
-
const workspacePackages = await collectWorkspacePackages();
|
|
61
|
-
const configMethod = await selectWorkspaceConfigurationMethod();
|
|
62
|
-
await generateWorkspaceConfiguration(configMethod, workspacePackages);
|
|
63
|
-
await handleWorkspaceBuildScripts(packageJsonPath);
|
|
64
|
-
}
|
|
65
|
-
async function initializeSinglePackage(packageJsonPath) {
|
|
66
|
-
const entryFiles = await collectEntryFiles();
|
|
67
|
-
const outputFormats = await selectOutputFormats();
|
|
68
|
-
const configMethod = await selectConfigurationMethod();
|
|
69
|
-
await generateConfiguration(configMethod, entryFiles, outputFormats, packageJsonPath);
|
|
70
|
-
await handleBuildScripts(packageJsonPath, entryFiles, outputFormats, configMethod);
|
|
71
|
-
}
|
|
72
|
-
async function collectWorkspacePackages() {
|
|
73
|
-
const packages = [];
|
|
74
|
-
while (true) {
|
|
75
|
-
const packageName = await text({
|
|
76
|
-
message: packages.length > 0 ? "Enter the next package name:" : "Enter the first package name:",
|
|
77
|
-
placeholder: "core",
|
|
78
|
-
validate: (value) => {
|
|
79
|
-
if (!value)
|
|
80
|
-
return "Package name is required";
|
|
81
|
-
if (packages.some((pkg) => pkg.name === value))
|
|
82
|
-
return "Package name already exists";
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
const packageRoot = await text({
|
|
86
|
-
message: `Enter the root directory for "${packageName}":`,
|
|
87
|
-
placeholder: `packages/${packageName}`,
|
|
88
|
-
defaultValue: `packages/${packageName}`,
|
|
89
|
-
validate: (value) => {
|
|
90
|
-
if (!value)
|
|
91
|
-
return "Package root is required";
|
|
92
|
-
if (!fs.existsSync(value))
|
|
93
|
-
return "Package root directory does not exist";
|
|
94
|
-
if (!fs.statSync(value).isDirectory())
|
|
95
|
-
return "Package root must be a directory";
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
const entryFiles = await collectEntryFilesForPackage(packageRoot, packageName);
|
|
99
|
-
const outputFormats = await selectOutputFormats();
|
|
100
|
-
packages.push({
|
|
101
|
-
name: packageName,
|
|
102
|
-
root: packageRoot,
|
|
103
|
-
entryFiles,
|
|
104
|
-
outputFormats
|
|
105
|
-
});
|
|
106
|
-
const shouldAddMore = await confirm({
|
|
107
|
-
message: "Do you want to add another package?",
|
|
108
|
-
initialValue: true
|
|
109
|
-
});
|
|
110
|
-
if (!shouldAddMore)
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
return packages;
|
|
114
|
-
}
|
|
115
|
-
async function collectEntryFilesForPackage(packageRoot, packageName) {
|
|
116
|
-
const entryFiles = [];
|
|
117
|
-
while (true) {
|
|
118
|
-
const entryFile = await text({
|
|
119
|
-
message: entryFiles.length > 0 ? `Where is the next entry file for "${packageName}"? (relative to ${packageRoot})` : `Where is the entry file for "${packageName}"? (relative to ${packageRoot})`,
|
|
120
|
-
placeholder: "src/index.ts",
|
|
121
|
-
defaultValue: "src/index.ts",
|
|
122
|
-
validate: (value) => {
|
|
123
|
-
if (!value)
|
|
124
|
-
return "Entry file is required";
|
|
125
|
-
const fullPath = path.join(packageRoot, value);
|
|
126
|
-
if (!fs.existsSync(fullPath))
|
|
127
|
-
return `Entry file does not exist at ${fullPath}`;
|
|
128
|
-
if (!fs.statSync(fullPath).isFile())
|
|
129
|
-
return "Entry file must be a file";
|
|
130
|
-
if (entryFiles.includes(value))
|
|
131
|
-
return "You have already added this entry file";
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
entryFiles.push(entryFile);
|
|
135
|
-
const shouldAddMore = await confirm({
|
|
136
|
-
message: "Do you want to add another entry file for this package?",
|
|
137
|
-
initialValue: false
|
|
138
|
-
});
|
|
139
|
-
if (!shouldAddMore)
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
return entryFiles;
|
|
143
|
-
}
|
|
144
|
-
async function collectEntryFiles() {
|
|
145
|
-
const entryFiles = [];
|
|
146
|
-
while (true) {
|
|
147
|
-
const entryFile = await text({
|
|
148
|
-
message: entryFiles.length > 0 ? "Where is your next entry file?" : "Where is your entry file?",
|
|
149
|
-
placeholder: "src/index.ts",
|
|
150
|
-
defaultValue: "src/index.ts",
|
|
151
|
-
validate: (value) => {
|
|
152
|
-
if (!value)
|
|
153
|
-
return "Entry file is required";
|
|
154
|
-
if (!fs.existsSync(value))
|
|
155
|
-
return "Entry file does not exist";
|
|
156
|
-
if (!fs.statSync(value).isFile())
|
|
157
|
-
return "Entry file must be a file";
|
|
158
|
-
if (entryFiles.includes(value))
|
|
159
|
-
return "You have already added this entry file";
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
entryFiles.push(entryFile);
|
|
163
|
-
const shouldAddMore = await confirm({
|
|
164
|
-
message: "Do you want to add another entry file?",
|
|
165
|
-
initialValue: false
|
|
166
|
-
});
|
|
167
|
-
if (!shouldAddMore)
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
return entryFiles;
|
|
171
|
-
}
|
|
172
|
-
async function selectOutputFormats() {
|
|
173
|
-
return await multiselect({
|
|
174
|
-
message: "Select the output formats",
|
|
175
|
-
options: [
|
|
176
|
-
{ value: "esm", label: "ESM (.mjs)" },
|
|
177
|
-
{ value: "cjs", label: "CommonJS (.cjs)" },
|
|
178
|
-
{ value: "iife", label: "IIFE (.global.js)" }
|
|
179
|
-
],
|
|
180
|
-
initialValues: ["esm", "cjs"]
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
async function selectWorkspaceConfigurationMethod() {
|
|
184
|
-
return await select({
|
|
185
|
-
message: "How would you like to configure your workspace?",
|
|
186
|
-
options: [
|
|
187
|
-
{ value: "ts", label: "bunup.config.ts", hint: "Recommended" },
|
|
188
|
-
{ value: "js", label: "bunup.config.js" }
|
|
189
|
-
],
|
|
190
|
-
initialValue: "ts"
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
async function selectConfigurationMethod() {
|
|
194
|
-
return await select({
|
|
195
|
-
message: "How would you like to configure Bunup?",
|
|
196
|
-
options: [
|
|
197
|
-
{ value: "ts", label: "bunup.config.ts", hint: "Recommended" },
|
|
198
|
-
{ value: "js", label: "bunup.config.js" },
|
|
199
|
-
{ value: "json", label: 'package.json "bunup" property' },
|
|
200
|
-
{
|
|
201
|
-
value: "none",
|
|
202
|
-
label: "No config file",
|
|
203
|
-
hint: "Configure via CLI only"
|
|
204
|
-
}
|
|
205
|
-
],
|
|
206
|
-
initialValue: "ts"
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
async function generateWorkspaceConfiguration(configMethod, workspacePackages) {
|
|
210
|
-
const configContent = createWorkspaceConfigFileContent(workspacePackages);
|
|
211
|
-
await Bun.write(`bunup.config.${configMethod}`, configContent);
|
|
212
|
-
}
|
|
213
|
-
async function generateConfiguration(configMethod, entryFiles, outputFormats, packageJsonPath) {
|
|
214
|
-
if (configMethod === "none") {
|
|
215
|
-
log.info("If you need more control (such as adding plugins or customizing output), you can always create a config file later.");
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (configMethod === "ts" || configMethod === "js") {
|
|
219
|
-
await Bun.write(`bunup.config.${configMethod}`, createConfigFileContent(entryFiles, outputFormats));
|
|
220
|
-
} else if (configMethod === "json") {
|
|
221
|
-
const { data: packageJsonConfig } = await loadPackageJson();
|
|
222
|
-
const updatedConfig = {
|
|
223
|
-
...packageJsonConfig,
|
|
224
|
-
bunup: createPackageJsonConfig(entryFiles, outputFormats)
|
|
225
|
-
};
|
|
226
|
-
await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
async function handleWorkspaceBuildScripts(packageJsonPath) {
|
|
230
|
-
const { data: packageJsonConfig } = await loadPackageJson();
|
|
231
|
-
const existingScripts = packageJsonConfig?.scripts ?? {};
|
|
232
|
-
const newScripts = createWorkspaceBuildScripts();
|
|
233
|
-
const conflictingScripts = Object.keys(newScripts).filter((script) => existingScripts[script]);
|
|
234
|
-
if (conflictingScripts.length > 0) {
|
|
235
|
-
const shouldOverride = await confirm({
|
|
236
|
-
message: `The ${formatListWithAnd(conflictingScripts)} ${conflictingScripts.length > 1 ? "scripts already exist" : "script already exists"} in package.json. Override ${conflictingScripts.length > 1 ? "them" : "it"}?`,
|
|
237
|
-
initialValue: true
|
|
238
|
-
});
|
|
239
|
-
if (!shouldOverride) {
|
|
240
|
-
log.info("Skipped adding build scripts to avoid conflicts.");
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
const updatedConfig = {
|
|
245
|
-
...packageJsonConfig,
|
|
246
|
-
scripts: { ...existingScripts, ...newScripts }
|
|
247
|
-
};
|
|
248
|
-
await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
|
|
249
|
-
}
|
|
250
|
-
async function handleBuildScripts(packageJsonPath, entryFiles, outputFormats, configMethod) {
|
|
251
|
-
const { data: packageJsonConfig } = await loadPackageJson();
|
|
252
|
-
const existingScripts = packageJsonConfig?.scripts ?? {};
|
|
253
|
-
const newScripts = createBuildScripts(entryFiles, outputFormats, configMethod);
|
|
254
|
-
const conflictingScripts = Object.keys(newScripts).filter((script) => existingScripts[script]);
|
|
255
|
-
if (conflictingScripts.length > 0) {
|
|
256
|
-
const shouldOverride = await confirm({
|
|
257
|
-
message: `The ${formatListWithAnd(conflictingScripts)} ${conflictingScripts.length > 1 ? "scripts already exist" : "script already exists"} in package.json. Override ${conflictingScripts.length > 1 ? "them" : "it"}?`,
|
|
258
|
-
initialValue: true
|
|
259
|
-
});
|
|
260
|
-
if (!shouldOverride) {
|
|
261
|
-
log.info("Skipped adding build scripts to avoid conflicts.");
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
const updatedConfig = {
|
|
266
|
-
...packageJsonConfig,
|
|
267
|
-
scripts: { ...existingScripts, ...newScripts }
|
|
268
|
-
};
|
|
269
|
-
await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
|
|
270
|
-
}
|
|
271
|
-
function createWorkspaceConfigFileContent(workspacePackages) {
|
|
272
|
-
const packagesConfig = workspacePackages.map((pkg) => {
|
|
273
|
-
return ` {
|
|
274
|
-
name: '${pkg.name}',
|
|
275
|
-
root: '${pkg.root}',
|
|
276
|
-
config: {
|
|
277
|
-
entry: [${pkg.entryFiles.map((file) => `'${file}'`).join(", ")}],
|
|
278
|
-
format: [${pkg.outputFormats.map((format) => `'${format}'`).join(", ")}],
|
|
279
|
-
},
|
|
280
|
-
}`;
|
|
281
|
-
}).join(`,
|
|
282
|
-
`);
|
|
283
|
-
return `import { defineWorkspace } from 'bunup'
|
|
284
|
-
|
|
285
|
-
export default defineWorkspace([
|
|
286
|
-
${packagesConfig}
|
|
287
|
-
])
|
|
288
|
-
`;
|
|
289
|
-
}
|
|
290
|
-
function createConfigFileContent(entryFiles, outputFormats) {
|
|
291
|
-
return `import { defineConfig } from 'bunup'
|
|
292
|
-
|
|
293
|
-
export default defineConfig({
|
|
294
|
-
entry: [${entryFiles.map((file) => `'${file}'`).join(", ")}],
|
|
295
|
-
format: [${outputFormats.map((format) => `'${format}'`).join(", ")}],
|
|
296
|
-
})
|
|
297
|
-
`;
|
|
298
|
-
}
|
|
299
|
-
function createPackageJsonConfig(entryFiles, outputFormats) {
|
|
300
|
-
return {
|
|
301
|
-
entry: entryFiles,
|
|
302
|
-
format: outputFormats
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
function createWorkspaceBuildScripts() {
|
|
306
|
-
return {
|
|
307
|
-
build: "bunup",
|
|
308
|
-
dev: "bunup --watch"
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
function createBuildScripts(entryFiles, outputFormats, configMethod) {
|
|
312
|
-
const cliOptions = configMethod === "none" ? ` ${entryFiles.join(" ")} --format ${outputFormats.join(",")}` : "";
|
|
313
|
-
return {
|
|
314
|
-
build: `bunup${cliOptions}`,
|
|
315
|
-
dev: `bunup${cliOptions} --watch`
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
function showSuccessOutro(isWorkspace) {
|
|
319
|
-
const buildCommand = isWorkspace ? `${pc.cyan("bun run build")} - Build all packages in your workspace` : `${pc.cyan("bun run build")} - Build your library`;
|
|
320
|
-
const devCommand = isWorkspace ? `${pc.cyan("bun run dev")} - Start development mode (watches all packages)` : `${pc.cyan("bun run dev")} - Start development mode`;
|
|
321
|
-
const filterCommand = isWorkspace ? `${pc.cyan("bunup --filter core,utils")} - Build specific packages` : "";
|
|
322
|
-
outro(`
|
|
323
|
-
${pc.green("\u2728 Bunup initialized successfully! \u2728")}
|
|
324
|
-
|
|
325
|
-
${buildCommand}
|
|
326
|
-
${devCommand}${isWorkspace ? `
|
|
327
|
-
${filterCommand}` : ""}
|
|
328
|
-
|
|
329
|
-
${pc.dim("Learn more:")} ${link("https://bunup.dev/")}
|
|
330
|
-
|
|
331
|
-
${pc.yellow("Happy building!")} \uD83D\uDE80
|
|
332
|
-
`);
|
|
333
|
-
}
|
|
334
|
-
async function installBunup() {
|
|
335
|
-
await exec("bun add -d bunup", [], {
|
|
336
|
-
nodeOptions: { shell: true, stdio: "pipe" }
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
export {
|
|
340
|
-
init
|
|
341
|
-
};
|
|
File without changes
|