bunup 0.8.13 → 0.8.14

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 CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  [![NPM Downloads](https://img.shields.io/npm/dm/bunup?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAtOTYwIDk2MCA5NjAiIHdpZHRoPSIyNHB4IiBmaWxsPSIjMDAwMDAwIj48cGF0aCBkPSJNNDgwLTMyMCAyODAtNTIwbDU2LTU4IDEwNCAxMDR2LTMyNmg4MHYzMjZsMTA0LTEwNCA1NiA1OC0yMDAgMjAwWk0xNjAtMTYwdi0yMDBoODB2MTIwaDQ4MHYtMTIwaDgwdjIwMEgxNjBaIi8%2BPC9zdmc%2B&labelColor=ffc44e&color=212121)](https://www.npmjs.com/package/bunup) [![NPM Version](https://img.shields.io/npm/v/bunup?logo=npm&logoColor=212121&label=version&labelColor=ffc44e&color=212121)](https://npmjs.com/package/bunup) [![Built with Bun](https://img.shields.io/badge/Built_with-Bun-fbf0df?logo=bun&labelColor=212121)](https://bun.sh) [![sponsor](https://img.shields.io/badge/sponsor-EA4AAA?logo=githubsponsors&labelColor=FAFAFA)](https://github.com/sponsors/arshad-yaseen)
14
14
 
15
- Bunup is the **blazing-fast build tool** for TypeScript and JavaScript libraries, designed for flawless developer experience and speed, **powered by Bun** — up to **~100× faster than Tsup**.
15
+ Bunup is the **blazing-fast build tool** for TypeScript and JavaScript libraries, designed for flawless developer experience and speed, **powered by Bun**.
16
16
 
17
17
  | Bundler | Format | Build Time | Build Time (with dts) |
18
18
  | --------- | ------------ | -------------- | --------------------- |
package/dist/cli.js CHANGED
@@ -464,10 +464,70 @@ function pathExistsSync(filePath) {
464
464
  return false;
465
465
  }
466
466
  }
467
+ function formatListWithAnd(arr) {
468
+ return new Intl.ListFormat("en", {
469
+ style: "long",
470
+ type: "conjunction"
471
+ }).format(arr);
472
+ }
467
473
  var init_utils = __esm(() => {
468
474
  init_errors();
469
475
  });
470
476
 
477
+ // src/loaders.ts
478
+ import path2 from "path";
479
+ import { loadConfig } from "coffi";
480
+ async function processLoadedConfigs(config, cwd, filter) {
481
+ return Array.isArray(config) && "root" in config[0] ? config.filter((c) => filter ? filter.includes(c.name) : true).map((c) => ({
482
+ rootDir: path2.resolve(cwd, c.root),
483
+ options: addField(c.config, "name", c.name)
484
+ })) : [
485
+ {
486
+ rootDir: cwd,
487
+ options: config
488
+ }
489
+ ];
490
+ }
491
+ function addField(objectOrArray, field, value) {
492
+ return Array.isArray(objectOrArray) ? objectOrArray.map((o) => ({ ...o, [field]: value })) : { ...objectOrArray, [field]: value };
493
+ }
494
+ async function loadPackageJson(cwd = process.cwd()) {
495
+ const { config, filepath } = await loadConfig({
496
+ name: "package",
497
+ cwd,
498
+ extensions: [".json"]
499
+ });
500
+ return {
501
+ data: config,
502
+ path: filepath
503
+ };
504
+ }
505
+ var init_loaders = () => {};
506
+
507
+ // src/cli/utils.ts
508
+ function displayBunupGradientArt() {
509
+ const art = `
510
+ \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
511
+ \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
512
+ \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
513
+ \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
514
+ \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
515
+ \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
516
+ `.trim();
517
+ const lines = art.split(`
518
+ `);
519
+ logger.space();
520
+ for (const line of lines) {
521
+ logger.output(import_picocolors7.default.cyan(line));
522
+ }
523
+ logger.space();
524
+ }
525
+ var import_picocolors7;
526
+ var init_utils2 = __esm(() => {
527
+ import_picocolors7 = __toESM(require_picocolors(), 1);
528
+ init_logger();
529
+ });
530
+
471
531
  // src/cli/new.ts
472
532
  var exports_new = {};
473
533
  __export(exports_new, {
@@ -486,31 +546,14 @@ import {
486
546
  } from "@clack/prompts";
487
547
  import { downloadTemplate } from "giget";
488
548
  import { replaceInFile } from "replace-in-file";
489
- function displayBunupGradientArt() {
490
- const art = `
491
- \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
492
- \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
493
- \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
494
- \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
495
- \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
496
- \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
497
- `.trim();
498
- const lines = art.split(`
499
- `);
500
- logger.space();
501
- for (const line of lines) {
502
- logger.output(import_picocolors7.default.cyan(line));
503
- }
504
- logger.space();
505
- }
506
549
  async function newProject() {
507
550
  displayBunupGradientArt();
508
- intro(import_picocolors7.default.bgCyan(import_picocolors7.default.black(" Scaffold a new project with Bunup ")));
551
+ intro(import_picocolors8.default.bgCyan(import_picocolors8.default.black(" Scaffold a new project with Bunup ")));
509
552
  const selectedTemplateDir = await select({
510
553
  message: "Select a template",
511
554
  options: TEMPLATES.map((template2) => ({
512
555
  value: template2.dir,
513
- label: import_picocolors7.default.blue(template2.name)
556
+ label: import_picocolors8.default.blue(template2.name)
514
557
  }))
515
558
  });
516
559
  const template = TEMPLATES.find((t) => t.dir === selectedTemplateDir);
@@ -594,25 +637,27 @@ async function newProject() {
594
637
  }
595
638
  ]);
596
639
  outro(`
597
- ${import_picocolors7.default.green("\u2728 Project scaffolded successfully! \u2728")}
598
-
599
- ${import_picocolors7.default.bold("Ready to launch your awesome new project?")}
600
-
601
- ${import_picocolors7.default.cyan("cd")} ${projectName}
602
- ${import_picocolors7.default.cyan("bun install")}
603
- ${import_picocolors7.default.cyan("bun run dev")}
604
-
605
- ${import_picocolors7.default.yellow("Happy coding!")} \uD83D\uDE80
606
- `);
640
+ ${import_picocolors8.default.green("\u2728 Project scaffolded successfully! \u2728")}
641
+
642
+ ${import_picocolors8.default.bold("Ready to launch your awesome new project?")}
643
+
644
+ ${import_picocolors8.default.cyan("cd")} ${projectName}
645
+ ${import_picocolors8.default.cyan("bun install")}
646
+ ${import_picocolors8.default.cyan("bun run dev")}
647
+
648
+ ${import_picocolors8.default.dim("Learn more:")} ${import_picocolors8.default.underline("https://bunup.dev/docs")}
649
+
650
+ ${import_picocolors8.default.yellow("Happy coding!")} \uD83D\uDE80
651
+ `);
607
652
  }
608
653
  function getProjectPath(projectName) {
609
654
  return path5.join(process.cwd(), projectName);
610
655
  }
611
- var import_picocolors7, 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;
656
+ var import_picocolors8, 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;
612
657
  var init_new = __esm(() => {
613
- import_picocolors7 = __toESM(require_picocolors(), 1);
614
- init_logger();
658
+ import_picocolors8 = __toESM(require_picocolors(), 1);
615
659
  init_utils();
660
+ init_utils2();
616
661
  TEMPLATES = [
617
662
  {
618
663
  defaultName: "my-ts-lib",
@@ -628,10 +673,362 @@ var init_new = __esm(() => {
628
673
  ];
629
674
  });
630
675
 
631
- // src/cli/index.ts
676
+ // src/cli/init.ts
677
+ var exports_init = {};
678
+ __export(exports_init, {
679
+ init: () => init
680
+ });
681
+ import fs2 from "fs";
682
+ import path6 from "path";
683
+ import {
684
+ confirm as confirm2,
685
+ intro as intro2,
686
+ log,
687
+ multiselect,
688
+ outro as outro2,
689
+ select as select2,
690
+ tasks as tasks2,
691
+ text as text2
692
+ } from "@clack/prompts";
632
693
  import { exec } from "tinyexec";
694
+ async function init() {
695
+ displayBunupGradientArt();
696
+ intro2(import_picocolors9.default.bgCyan(import_picocolors9.default.black(" Initialize bunup in an existing project ")));
697
+ const { path: packageJsonPath } = await loadPackageJson();
698
+ if (!packageJsonPath) {
699
+ log.error("package.json not found");
700
+ process.exit(1);
701
+ }
702
+ const shouldSetupWorkspace = await promptForWorkspace();
703
+ if (shouldSetupWorkspace) {
704
+ await initializeWorkspace(packageJsonPath);
705
+ } else {
706
+ await initializeSinglePackage(packageJsonPath);
707
+ }
708
+ await tasks2([
709
+ {
710
+ title: "Installing bunup",
711
+ task: async () => {
712
+ await installBunup();
713
+ return "Bunup installed";
714
+ }
715
+ }
716
+ ]);
717
+ showSuccessOutro(shouldSetupWorkspace);
718
+ }
719
+ async function promptForWorkspace() {
720
+ return await confirm2({
721
+ message: "Do you want to setup a Bunup workspace? (for building multiple packages with one command)",
722
+ initialValue: false
723
+ });
724
+ }
725
+ async function initializeWorkspace(packageJsonPath) {
726
+ const workspacePackages = await collectWorkspacePackages();
727
+ const configMethod = await selectWorkspaceConfigurationMethod();
728
+ await generateWorkspaceConfiguration(configMethod, workspacePackages);
729
+ await handleWorkspaceBuildScripts(packageJsonPath);
730
+ }
731
+ async function initializeSinglePackage(packageJsonPath) {
732
+ const entryFiles = await collectEntryFiles();
733
+ const outputFormats = await selectOutputFormats();
734
+ const shouldGenerateDts = await promptForTypeScriptDeclarations(entryFiles);
735
+ const configMethod = await selectConfigurationMethod();
736
+ await generateConfiguration(configMethod, entryFiles, outputFormats, shouldGenerateDts, packageJsonPath);
737
+ await handleBuildScripts(packageJsonPath, entryFiles, outputFormats, shouldGenerateDts, configMethod);
738
+ }
739
+ async function collectWorkspacePackages() {
740
+ const packages = [];
741
+ while (true) {
742
+ const packageName = await text2({
743
+ message: packages.length > 0 ? "Enter the next package name:" : "Enter the first package name:",
744
+ placeholder: "core",
745
+ validate: (value) => {
746
+ if (!value)
747
+ return "Package name is required";
748
+ if (packages.some((pkg) => pkg.name === value))
749
+ return "Package name already exists";
750
+ }
751
+ });
752
+ const packageRoot = await text2({
753
+ message: `Enter the root directory for "${packageName}":`,
754
+ placeholder: `packages/${packageName}`,
755
+ defaultValue: `packages/${packageName}`,
756
+ validate: (value) => {
757
+ if (!value)
758
+ return "Package root is required";
759
+ if (!fs2.existsSync(value))
760
+ return "Package root directory does not exist";
761
+ if (!fs2.statSync(value).isDirectory())
762
+ return "Package root must be a directory";
763
+ }
764
+ });
765
+ const entryFiles = await collectEntryFilesForPackage(packageRoot, packageName);
766
+ const outputFormats = await selectOutputFormats();
767
+ const shouldGenerateDts = await promptForTypeScriptDeclarations(entryFiles);
768
+ packages.push({
769
+ name: packageName,
770
+ root: packageRoot,
771
+ entryFiles,
772
+ outputFormats,
773
+ shouldGenerateDts
774
+ });
775
+ const shouldAddMore = await confirm2({
776
+ message: "Do you want to add another package?",
777
+ initialValue: true
778
+ });
779
+ if (!shouldAddMore)
780
+ break;
781
+ }
782
+ return packages;
783
+ }
784
+ async function collectEntryFilesForPackage(packageRoot, packageName) {
785
+ const entryFiles = [];
786
+ while (true) {
787
+ const entryFile = await text2({
788
+ 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})`,
789
+ placeholder: "src/index.ts",
790
+ defaultValue: "src/index.ts",
791
+ validate: (value) => {
792
+ if (!value)
793
+ return "Entry file is required";
794
+ const fullPath = path6.join(packageRoot, value);
795
+ if (!fs2.existsSync(fullPath))
796
+ return `Entry file does not exist at ${fullPath}`;
797
+ if (!fs2.statSync(fullPath).isFile())
798
+ return "Entry file must be a file";
799
+ if (entryFiles.includes(value))
800
+ return "You have already added this entry file";
801
+ }
802
+ });
803
+ entryFiles.push(entryFile);
804
+ const shouldAddMore = await confirm2({
805
+ message: "Do you want to add another entry file for this package?",
806
+ initialValue: false
807
+ });
808
+ if (!shouldAddMore)
809
+ break;
810
+ }
811
+ return entryFiles;
812
+ }
813
+ async function collectEntryFiles() {
814
+ const entryFiles = [];
815
+ while (true) {
816
+ const entryFile = await text2({
817
+ message: entryFiles.length > 0 ? "Where is your next entry file?" : "Where is your entry file?",
818
+ placeholder: "src/index.ts",
819
+ defaultValue: "src/index.ts",
820
+ validate: (value) => {
821
+ if (!value)
822
+ return "Entry file is required";
823
+ if (!fs2.existsSync(value))
824
+ return "Entry file does not exist";
825
+ if (!fs2.statSync(value).isFile())
826
+ return "Entry file must be a file";
827
+ if (entryFiles.includes(value))
828
+ return "You have already added this entry file";
829
+ }
830
+ });
831
+ entryFiles.push(entryFile);
832
+ const shouldAddMore = await confirm2({
833
+ message: "Do you want to add another entry file?",
834
+ initialValue: false
835
+ });
836
+ if (!shouldAddMore)
837
+ break;
838
+ }
839
+ return entryFiles;
840
+ }
841
+ async function selectOutputFormats() {
842
+ return await multiselect({
843
+ message: "Select the output formats",
844
+ options: [
845
+ { value: "esm", label: "ESM (.mjs)" },
846
+ { value: "cjs", label: "CommonJS (.cjs)" },
847
+ { value: "iife", label: "IIFE (.global.js)" }
848
+ ],
849
+ initialValues: ["esm", "cjs"]
850
+ });
851
+ }
852
+ async function promptForTypeScriptDeclarations(entryFiles) {
853
+ const hasTypeScriptFiles = entryFiles.some((file) => file.endsWith(".ts") || file.endsWith(".tsx"));
854
+ if (!hasTypeScriptFiles)
855
+ return false;
856
+ return await confirm2({
857
+ message: "Generate TypeScript declarations?",
858
+ initialValue: true
859
+ });
860
+ }
861
+ async function selectWorkspaceConfigurationMethod() {
862
+ return await select2({
863
+ message: "How would you like to configure your workspace?",
864
+ options: [
865
+ { value: "ts", label: "bunup.config.ts", hint: "Recommended" },
866
+ { value: "js", label: "bunup.config.js" }
867
+ ],
868
+ initialValue: "ts"
869
+ });
870
+ }
871
+ async function selectConfigurationMethod() {
872
+ return await select2({
873
+ message: "How would you like to configure Bunup?",
874
+ options: [
875
+ { value: "ts", label: "bunup.config.ts", hint: "Recommended" },
876
+ { value: "js", label: "bunup.config.js" },
877
+ { value: "json", label: 'package.json "bunup" property' },
878
+ {
879
+ value: "none",
880
+ label: "No config file",
881
+ hint: "Configure via CLI only"
882
+ }
883
+ ],
884
+ initialValue: "ts"
885
+ });
886
+ }
887
+ async function generateWorkspaceConfiguration(configMethod, workspacePackages) {
888
+ const configContent = createWorkspaceConfigFileContent(workspacePackages);
889
+ await Bun.write(`bunup.config.${configMethod}`, configContent);
890
+ }
891
+ async function generateConfiguration(configMethod, entryFiles, outputFormats, shouldGenerateDts, packageJsonPath) {
892
+ if (configMethod === "none") {
893
+ log.info("If you need more control (such as adding plugins or customizing output), you can always create a config file later.");
894
+ return;
895
+ }
896
+ if (configMethod === "ts" || configMethod === "js") {
897
+ await Bun.write(`bunup.config.${configMethod}`, createConfigFileContent(entryFiles, outputFormats, shouldGenerateDts));
898
+ } else if (configMethod === "json") {
899
+ const { data: packageJsonConfig } = await loadPackageJson();
900
+ const updatedConfig = {
901
+ ...packageJsonConfig,
902
+ bunup: createPackageJsonConfig(entryFiles, outputFormats, shouldGenerateDts)
903
+ };
904
+ await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
905
+ }
906
+ }
907
+ async function handleWorkspaceBuildScripts(packageJsonPath) {
908
+ const { data: packageJsonConfig } = await loadPackageJson();
909
+ const existingScripts = packageJsonConfig?.scripts ?? {};
910
+ const newScripts = createWorkspaceBuildScripts();
911
+ const conflictingScripts = Object.keys(newScripts).filter((script) => existingScripts[script]);
912
+ if (conflictingScripts.length > 0) {
913
+ const shouldOverride = await confirm2({
914
+ message: `The ${formatListWithAnd(conflictingScripts)} ${conflictingScripts.length > 1 ? "scripts already exist" : "script already exists"} in package.json. Override ${conflictingScripts.length > 1 ? "them" : "it"}?`,
915
+ initialValue: true
916
+ });
917
+ if (!shouldOverride) {
918
+ log.info("Skipped adding build scripts to avoid conflicts.");
919
+ return;
920
+ }
921
+ }
922
+ const updatedConfig = {
923
+ ...packageJsonConfig,
924
+ scripts: { ...existingScripts, ...newScripts }
925
+ };
926
+ await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
927
+ }
928
+ async function handleBuildScripts(packageJsonPath, entryFiles, outputFormats, shouldGenerateDts, configMethod) {
929
+ const { data: packageJsonConfig } = await loadPackageJson();
930
+ const existingScripts = packageJsonConfig?.scripts ?? {};
931
+ const newScripts = createBuildScripts(entryFiles, outputFormats, shouldGenerateDts, configMethod);
932
+ const conflictingScripts = Object.keys(newScripts).filter((script) => existingScripts[script]);
933
+ if (conflictingScripts.length > 0) {
934
+ const shouldOverride = await confirm2({
935
+ message: `The ${formatListWithAnd(conflictingScripts)} ${conflictingScripts.length > 1 ? "scripts already exist" : "script already exists"} in package.json. Override ${conflictingScripts.length > 1 ? "them" : "it"}?`,
936
+ initialValue: true
937
+ });
938
+ if (!shouldOverride) {
939
+ log.info("Skipped adding build scripts to avoid conflicts.");
940
+ return;
941
+ }
942
+ }
943
+ const updatedConfig = {
944
+ ...packageJsonConfig,
945
+ scripts: { ...existingScripts, ...newScripts }
946
+ };
947
+ await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
948
+ }
949
+ function createWorkspaceConfigFileContent(workspacePackages) {
950
+ const packagesConfig = workspacePackages.map((pkg) => {
951
+ return ` {
952
+ name: '${pkg.name}',
953
+ root: '${pkg.root}',
954
+ config: {
955
+ entry: [${pkg.entryFiles.map((file) => `'${file}'`).join(", ")}],
956
+ format: [${pkg.outputFormats.map((format) => `'${format}'`).join(", ")}],${pkg.shouldGenerateDts ? `
957
+ dts: true,` : ""}
958
+ },
959
+ }`;
960
+ }).join(`,
961
+ `);
962
+ return `import { defineWorkspace } from 'bunup'
963
+
964
+ export default defineWorkspace([
965
+ ${packagesConfig}
966
+ ])
967
+ `;
968
+ }
969
+ function createConfigFileContent(entryFiles, outputFormats, shouldGenerateDts) {
970
+ return `import { defineConfig } from 'bunup'
971
+
972
+ export default defineConfig({
973
+ entry: [${entryFiles.map((file) => `'${file}'`).join(", ")}],
974
+ format: [${outputFormats.map((format) => `'${format}'`).join(", ")}],${shouldGenerateDts ? `
975
+ dts: true,` : ""}
976
+ })
977
+ `;
978
+ }
979
+ function createPackageJsonConfig(entryFiles, outputFormats, shouldGenerateDts) {
980
+ return {
981
+ entry: entryFiles,
982
+ format: outputFormats,
983
+ ...shouldGenerateDts && { dts: true }
984
+ };
985
+ }
986
+ function createWorkspaceBuildScripts() {
987
+ return {
988
+ build: "bunup",
989
+ dev: "bunup --watch"
990
+ };
991
+ }
992
+ function createBuildScripts(entryFiles, outputFormats, shouldGenerateDts, configMethod) {
993
+ const cliOptions = configMethod === "none" ? ` ${entryFiles.join(" ")} --format ${outputFormats.join(",")}${shouldGenerateDts ? " --dts" : ""}` : "";
994
+ return {
995
+ build: `bunup${cliOptions}`,
996
+ dev: `bunup${cliOptions} --watch`
997
+ };
998
+ }
999
+ function showSuccessOutro(isWorkspace) {
1000
+ const buildCommand = isWorkspace ? `${import_picocolors9.default.cyan("bun run build")} - Build all packages in your workspace` : `${import_picocolors9.default.cyan("bun run build")} - Build your library`;
1001
+ const devCommand = isWorkspace ? `${import_picocolors9.default.cyan("bun run dev")} - Start development mode (watches all packages)` : `${import_picocolors9.default.cyan("bun run dev")} - Start development mode`;
1002
+ const filterCommand = isWorkspace ? `${import_picocolors9.default.cyan("bunup --filter core,utils")} - Build specific packages` : "";
1003
+ outro2(`
1004
+ ${import_picocolors9.default.green("\u2728 Bunup initialized successfully! \u2728")}
1005
+
1006
+ ${buildCommand}
1007
+ ${devCommand}${isWorkspace ? `
1008
+ ${filterCommand}` : ""}
1009
+
1010
+ ${import_picocolors9.default.dim("Learn more:")} ${import_picocolors9.default.underline("https://bunup.dev/docs/")}
1011
+
1012
+ ${import_picocolors9.default.yellow("Happy building!")} \uD83D\uDE80
1013
+ `);
1014
+ }
1015
+ async function installBunup() {
1016
+ await exec("bun add -d bunup", [], {
1017
+ nodeOptions: { shell: true, stdio: "pipe" }
1018
+ });
1019
+ }
1020
+ var import_picocolors9;
1021
+ var init_init = __esm(() => {
1022
+ import_picocolors9 = __toESM(require_picocolors(), 1);
1023
+ init_loaders();
1024
+ init_utils();
1025
+ init_utils2();
1026
+ });
1027
+
1028
+ // src/cli/index.ts
1029
+ import { exec as exec2 } from "tinyexec";
633
1030
  // package.json
634
- var version = "0.8.13";
1031
+ var version = "0.8.14";
635
1032
 
636
1033
  // src/cli/index.ts
637
1034
  init_errors();
@@ -758,6 +1155,7 @@ var optionConfigs = {
758
1155
  },
759
1156
  filter: { flags: ["filter"], handler: arrayHandler("filter") },
760
1157
  new: { flags: ["new"], handler: booleanHandler("new") },
1158
+ init: { flags: ["init"], handler: booleanHandler("init") },
761
1159
  dtsOnly: { flags: ["dts-only"], handler: booleanHandler("dtsOnly") },
762
1160
  entry: {
763
1161
  flags: ["entry"],
@@ -862,7 +1260,7 @@ function parseCliOptions(argv) {
862
1260
  }
863
1261
 
864
1262
  // src/cli/index.ts
865
- var import_picocolors8 = __toESM(require_picocolors(), 1);
1263
+ var import_picocolors10 = __toESM(require_picocolors(), 1);
866
1264
  import { loadConfig as loadConfig2 } from "coffi";
867
1265
 
868
1266
  // src/build.ts
@@ -904,36 +1302,8 @@ function getResolvedNaming(outputBasePath, extension) {
904
1302
  };
905
1303
  }
906
1304
 
907
- // src/loaders.ts
908
- import path2 from "path";
909
- import { loadConfig } from "coffi";
910
- async function processLoadedConfigs(config, cwd, filter) {
911
- return Array.isArray(config) && "root" in config[0] ? config.filter((c) => filter ? filter.includes(c.name) : true).map((c) => ({
912
- rootDir: path2.resolve(cwd, c.root),
913
- options: addField(c.config, "name", c.name)
914
- })) : [
915
- {
916
- rootDir: cwd,
917
- options: config
918
- }
919
- ];
920
- }
921
- function addField(objectOrArray, field, value) {
922
- return Array.isArray(objectOrArray) ? objectOrArray.map((o) => ({ ...o, [field]: value })) : { ...objectOrArray, [field]: value };
923
- }
924
- async function loadPackageJson(cwd) {
925
- const { config, filepath } = await loadConfig({
926
- name: "package",
927
- cwd,
928
- extensions: [".json"]
929
- });
930
- return {
931
- data: config,
932
- path: filepath
933
- };
934
- }
935
-
936
1305
  // src/build.ts
1306
+ init_loaders();
937
1307
  init_logger();
938
1308
 
939
1309
  // src/constants/re.ts
@@ -1294,6 +1664,7 @@ function getRelativePathToRootDir(filePath, rootDir) {
1294
1664
  }
1295
1665
 
1296
1666
  // src/cli/index.ts
1667
+ init_loaders();
1297
1668
  init_utils();
1298
1669
 
1299
1670
  // src/watch.ts
@@ -1368,6 +1739,11 @@ async function main(args = Bun.argv.slice(2)) {
1368
1739
  await newProject2();
1369
1740
  return;
1370
1741
  }
1742
+ if (cliOptions.init) {
1743
+ const { init: init2 } = await Promise.resolve().then(() => (init_init(), exports_init));
1744
+ await init2();
1745
+ return;
1746
+ }
1371
1747
  setSilent(cliOptions.silent);
1372
1748
  const cwd = process.cwd();
1373
1749
  const { config, filepath } = await loadConfig2({
@@ -1404,7 +1780,7 @@ async function main(args = Bun.argv.slice(2)) {
1404
1780
  }));
1405
1781
  const buildTimeMs = performance.now() - startTime;
1406
1782
  const timeDisplay = formatTime(buildTimeMs);
1407
- logger.cli(`\u26A1\uFE0F Build completed in ${import_picocolors8.default.green(timeDisplay)}`);
1783
+ logger.cli(`\u26A1\uFE0F Build completed in ${import_picocolors10.default.green(timeDisplay)}`);
1408
1784
  if (cliOptions.watch) {
1409
1785
  logger.cli("\uD83D\uDC40 Watching for file changes");
1410
1786
  }
@@ -1412,7 +1788,7 @@ async function main(args = Bun.argv.slice(2)) {
1412
1788
  logger.cli(`Running command: ${cliOptions.onSuccess}`, {
1413
1789
  muted: true
1414
1790
  });
1415
- await exec(cliOptions.onSuccess, [], {
1791
+ await exec2(cliOptions.onSuccess, [], {
1416
1792
  nodeOptions: { shell: true, stdio: "inherit" }
1417
1793
  });
1418
1794
  }
@@ -1426,7 +1802,8 @@ function removeCliOnlyOptions(options) {
1426
1802
  onSuccess: undefined,
1427
1803
  config: undefined,
1428
1804
  filter: undefined,
1429
- new: undefined
1805
+ new: undefined,
1806
+ init: undefined
1430
1807
  };
1431
1808
  }
1432
1809
  main().catch((error) => handleErrorAndExit(error));
package/dist/index.cjs CHANGED
@@ -437,7 +437,7 @@ function getResolvedNaming(outputBasePath, extension) {
437
437
 
438
438
  // src/loaders.ts
439
439
  var import_coffi = require("coffi");
440
- async function loadPackageJson(cwd) {
440
+ async function loadPackageJson(cwd = process.cwd()) {
441
441
  const { config, filepath } = await import_coffi.loadConfig({
442
442
  name: "package",
443
443
  cwd,
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import _Bun from "bun";
2
2
  type PackageJson = {
3
3
  /** The parsed content of the package.json file */
4
- data: Record<string, unknown> | null
4
+ data: Record<string, any> | null
5
5
  /** The path to the package.json file */
6
6
  path: string | null
7
7
  };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import _Bun from "bun";
2
2
  type PackageJson = {
3
3
  /** The parsed content of the package.json file */
4
- data: Record<string, unknown> | null
4
+ data: Record<string, any> | null
5
5
  /** The path to the package.json file */
6
6
  path: string | null
7
7
  };
package/dist/index.js CHANGED
@@ -404,7 +404,7 @@ function getResolvedNaming(outputBasePath, extension) {
404
404
 
405
405
  // src/loaders.ts
406
406
  import { loadConfig } from "coffi";
407
- async function loadPackageJson(cwd) {
407
+ async function loadPackageJson(cwd = process.cwd()) {
408
408
  const { config, filepath } = await loadConfig({
409
409
  name: "package",
410
410
  cwd,
@@ -285,7 +285,7 @@ type BunBuildOptions = Parameters<Bun["build"]>[0];
285
285
  type BunPlugin = Exclude<BunBuildOptions["plugins"], undefined>[number];
286
286
  type PackageJson = {
287
287
  /** The parsed content of the package.json file */
288
- data: Record<string, unknown> | null
288
+ data: Record<string, any> | null
289
289
  /** The path to the package.json file */
290
290
  path: string | null
291
291
  };
package/dist/plugins.d.ts CHANGED
@@ -285,7 +285,7 @@ type BunBuildOptions = Parameters<Bun["build"]>[0];
285
285
  type BunPlugin = Exclude<BunBuildOptions["plugins"], undefined>[number];
286
286
  type PackageJson = {
287
287
  /** The parsed content of the package.json file */
288
- data: Record<string, unknown> | null
288
+ data: Record<string, any> | null
289
289
  /** The path to the package.json file */
290
290
  path: string | null
291
291
  };
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.13",
4
+ "version": "0.8.14",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",