bunup 0.8.8 → 0.8.9

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.js CHANGED
@@ -563,7 +563,7 @@ var init_new = __esm(() => {
563
563
  // src/cli/index.ts
564
564
  import { exec } from "tinyexec";
565
565
  // package.json
566
- var version = "0.8.8";
566
+ var version = "0.8.9";
567
567
 
568
568
  // src/cli/index.ts
569
569
  init_errors();
@@ -1139,7 +1139,8 @@ async function build(partialOptions, rootDir = process.cwd()) {
1139
1139
  await Promise.all(dtsPromises);
1140
1140
  }
1141
1141
  await runPluginBuildDoneHooks(bunupPlugins, options, buildOutput, {
1142
- packageJson
1142
+ packageJson,
1143
+ rootDir
1143
1144
  });
1144
1145
  if (options.onSuccess) {
1145
1146
  await options.onSuccess(options);
package/dist/index.cjs CHANGED
@@ -668,7 +668,8 @@ async function build(partialOptions, rootDir = process.cwd()) {
668
668
  await Promise.all(dtsPromises);
669
669
  }
670
670
  await runPluginBuildDoneHooks(bunupPlugins, options, buildOutput, {
671
- packageJson
671
+ packageJson,
672
+ rootDir
672
673
  });
673
674
  if (options.onSuccess) {
674
675
  await options.onSuccess(options);
package/dist/index.d.cts CHANGED
@@ -22,6 +22,8 @@ type BunupBunPlugin = {
22
22
  type BuildMeta = {
23
23
  /** The package.json file */
24
24
  packageJson: PackageJson
25
+ /** The root directory of the build */
26
+ rootDir: string
25
27
  };
26
28
  type BuildOutputFile = {
27
29
  /** Path to the generated file */
package/dist/index.d.ts CHANGED
@@ -22,6 +22,8 @@ type BunupBunPlugin = {
22
22
  type BuildMeta = {
23
23
  /** The package.json file */
24
24
  packageJson: PackageJson
25
+ /** The root directory of the build */
26
+ rootDir: string
25
27
  };
26
28
  type BuildOutputFile = {
27
29
  /** Path to the generated file */
package/dist/index.js CHANGED
@@ -635,7 +635,8 @@ async function build(partialOptions, rootDir = process.cwd()) {
635
635
  await Promise.all(dtsPromises);
636
636
  }
637
637
  await runPluginBuildDoneHooks(bunupPlugins, options, buildOutput, {
638
- packageJson
638
+ packageJson,
639
+ rootDir
639
640
  });
640
641
  if (options.onSuccess) {
641
642
  await options.onSuccess(options);
package/dist/plugins.cjs CHANGED
@@ -118,7 +118,8 @@ __export(exports_built_in, {
118
118
  report: () => report,
119
119
  injectStyles: () => injectStyles,
120
120
  filterJsDtsFiles: () => filterJsDtsFiles,
121
- exports: () => exports2
121
+ exports: () => exports2,
122
+ copy: () => copy
122
123
  });
123
124
  module.exports = __toCommonJS(exports_built_in);
124
125
 
@@ -635,4 +636,36 @@ function injectStyles(options) {
635
636
  }
636
637
  };
637
638
  }
639
+ // src/plugins/built-in/productivity/copy.ts
640
+ var import_promises = require("fs/promises");
641
+ var import_node_path3 = require("path");
642
+ function copy(patterns, outDir) {
643
+ return {
644
+ type: "bunup",
645
+ name: "copy",
646
+ hooks: {
647
+ onBuildDone: async ({ options, meta }) => {
648
+ const targetDir = outDir || options.outDir;
649
+ const baseDir = meta.rootDir;
650
+ for (const pattern of patterns) {
651
+ let globPattern = pattern;
652
+ if (!pattern.includes("*") && !pattern.includes("?")) {
653
+ try {
654
+ const stats = await import_promises.stat(`${baseDir}/${pattern}`);
655
+ if (stats.isDirectory()) {
656
+ globPattern = `${pattern}/**/*`;
657
+ }
658
+ } catch {}
659
+ }
660
+ const glob = new Bun.Glob(globPattern);
661
+ for await (const file of glob.scan(baseDir)) {
662
+ const targetPath = `${targetDir}/${file}`;
663
+ await import_promises.mkdir(import_node_path3.dirname(targetPath), { recursive: true });
664
+ await Bun.write(targetPath, Bun.file(`${baseDir}/${file}`));
665
+ }
666
+ }
667
+ }
668
+ }
669
+ };
670
+ }
638
671
  })
@@ -306,6 +306,8 @@ type BunupBunPlugin = {
306
306
  type BuildMeta = {
307
307
  /** The package.json file */
308
308
  packageJson: PackageJson
309
+ /** The root directory of the build */
310
+ rootDir: string
309
311
  };
310
312
  type BuildOutputFile = {
311
313
  /** Path to the generated file */
@@ -410,4 +412,10 @@ type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<im
410
412
  * @see https://bunup.dev/docs/plugins/css#injectstyles
411
413
  */
412
414
  declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
413
- export { shims, report, injectStyles, filterJsDtsFiles, exports };
415
+ /**
416
+ * A plugin that copies files and directories to the output directory.
417
+ *
418
+ * @see https://bunup.dev/docs/plugins/productivity#copy
419
+ */
420
+ declare function copy(patterns: string[], outDir?: string): BunupPlugin;
421
+ export { shims, report, injectStyles, filterJsDtsFiles, exports, copy };
package/dist/plugins.d.ts CHANGED
@@ -306,6 +306,8 @@ type BunupBunPlugin = {
306
306
  type BuildMeta = {
307
307
  /** The package.json file */
308
308
  packageJson: PackageJson
309
+ /** The root directory of the build */
310
+ rootDir: string
309
311
  };
310
312
  type BuildOutputFile = {
311
313
  /** Path to the generated file */
@@ -410,4 +412,10 @@ type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<im
410
412
  * @see https://bunup.dev/docs/plugins/css#injectstyles
411
413
  */
412
414
  declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
413
- export { shims, report, injectStyles, filterJsDtsFiles, exports };
415
+ /**
416
+ * A plugin that copies files and directories to the output directory.
417
+ *
418
+ * @see https://bunup.dev/docs/plugins/productivity#copy
419
+ */
420
+ declare function copy(patterns: string[], outDir?: string): BunupPlugin;
421
+ export { shims, report, injectStyles, filterJsDtsFiles, exports, copy };
package/dist/plugins.js CHANGED
@@ -600,10 +600,43 @@ function injectStyles(options) {
600
600
  }
601
601
  };
602
602
  }
603
+ // src/plugins/built-in/productivity/copy.ts
604
+ import { mkdir, stat } from "fs/promises";
605
+ import { dirname } from "path";
606
+ function copy(patterns, outDir) {
607
+ return {
608
+ type: "bunup",
609
+ name: "copy",
610
+ hooks: {
611
+ onBuildDone: async ({ options, meta }) => {
612
+ const targetDir = outDir || options.outDir;
613
+ const baseDir = meta.rootDir;
614
+ for (const pattern of patterns) {
615
+ let globPattern = pattern;
616
+ if (!pattern.includes("*") && !pattern.includes("?")) {
617
+ try {
618
+ const stats = await stat(`${baseDir}/${pattern}`);
619
+ if (stats.isDirectory()) {
620
+ globPattern = `${pattern}/**/*`;
621
+ }
622
+ } catch {}
623
+ }
624
+ const glob = new Bun.Glob(globPattern);
625
+ for await (const file of glob.scan(baseDir)) {
626
+ const targetPath = `${targetDir}/${file}`;
627
+ await mkdir(dirname(targetPath), { recursive: true });
628
+ await Bun.write(targetPath, Bun.file(`${baseDir}/${file}`));
629
+ }
630
+ }
631
+ }
632
+ }
633
+ };
634
+ }
603
635
  export {
604
636
  shims,
605
637
  report,
606
638
  injectStyles,
607
639
  filterJsDtsFiles,
608
- exports
640
+ exports,
641
+ copy
609
642
  };
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.8",
4
+ "version": "0.8.9",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",