bunki 0.3.1 → 0.3.2

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.
Files changed (3) hide show
  1. package/dist/cli.js +35 -19
  2. package/dist/index.js +35 -19
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -28481,6 +28481,7 @@ var import_nunjucks = __toESM(require_nunjucks(), 1);
28481
28481
  var import_slugify = __toESM(require_slugify(), 1);
28482
28482
  import path6 from "path";
28483
28483
  var {Glob: Glob2 } = globalThis.Bun;
28484
+ import fs2 from "fs";
28484
28485
 
28485
28486
  // src/utils/markdown-utils.ts
28486
28487
  var import_gray_matter = __toESM(require_gray_matter(), 1);
@@ -32512,8 +32513,16 @@ class SiteGenerator {
32512
32513
  async copyStaticAssets() {
32513
32514
  const assetsDir = path6.join(this.options.templatesDir, "assets");
32514
32515
  const publicDir = path6.join(process.cwd(), "public");
32516
+ async function dirExists(p) {
32517
+ try {
32518
+ const stat = await fs2.promises.stat(p);
32519
+ return stat.isDirectory();
32520
+ } catch {
32521
+ return false;
32522
+ }
32523
+ }
32515
32524
  const assetsDirFile = Bun.file(assetsDir);
32516
- if (await assetsDirFile.exists()) {
32525
+ if (await assetsDirFile.exists() && await dirExists(assetsDir)) {
32517
32526
  const assetGlob = new Glob2("**/*.*");
32518
32527
  const assetsOutputDir = path6.join(this.options.outputDir, "assets");
32519
32528
  await ensureDir(assetsOutputDir);
@@ -32528,23 +32537,30 @@ class SiteGenerator {
32528
32537
  await copyFile(file, targetPath);
32529
32538
  }
32530
32539
  }
32531
- const publicDirFile = Bun.file(publicDir);
32532
- if (await publicDirFile.exists()) {
32533
- const publicGlob = new Glob2("**/*.*");
32534
- for await (const file of publicGlob.scan({
32535
- cwd: publicDir,
32536
- absolute: true
32537
- })) {
32538
- const relativePath = path6.relative(publicDir, file);
32539
- const targetPath = path6.join(this.options.outputDir, relativePath);
32540
- const targetDir = path6.dirname(targetPath);
32541
- await ensureDir(targetDir);
32542
- const targetFile = Bun.file(targetPath);
32543
- if (!await targetFile.exists()) {
32544
- await copyFile(file, targetPath);
32540
+ if (await dirExists(publicDir)) {
32541
+ const copyRecursive = async (srcDir) => {
32542
+ const entries = await fs2.promises.readdir(srcDir, { withFileTypes: true });
32543
+ for (const entry of entries) {
32544
+ const srcPath = path6.join(srcDir, entry.name);
32545
+ const relativePath = path6.relative(publicDir, srcPath);
32546
+ const destPath = path6.join(this.options.outputDir, relativePath);
32547
+ if (!relativePath)
32548
+ continue;
32549
+ if (entry.isDirectory()) {
32550
+ await ensureDir(destPath);
32551
+ await copyRecursive(srcPath);
32552
+ } else if (entry.isFile()) {
32553
+ const targetFile = Bun.file(destPath);
32554
+ if (!await targetFile.exists()) {
32555
+ const targetDir = path6.dirname(destPath);
32556
+ await ensureDir(targetDir);
32557
+ await copyFile(srcPath, destPath);
32558
+ }
32559
+ }
32545
32560
  }
32546
- }
32547
- console.log("Copied public files to site");
32561
+ };
32562
+ await copyRecursive(publicDir);
32563
+ console.log("Copied public files to site (including extensionless & dotfiles)");
32548
32564
  }
32549
32565
  }
32550
32566
  async generateRSSFeed() {
@@ -32679,10 +32695,10 @@ ${rssItems}
32679
32695
 
32680
32696
  // src/server.ts
32681
32697
  import path7 from "path";
32682
- import fs2 from "fs";
32698
+ import fs3 from "fs";
32683
32699
  async function startServer(outputDir = DEFAULT_OUTPUT_DIR, port = 3000) {
32684
32700
  try {
32685
- const stats = await fs2.promises.stat(outputDir);
32701
+ const stats = await fs3.promises.stat(outputDir);
32686
32702
  if (!stats.isDirectory()) {
32687
32703
  const msg = `Error: Output directory ${outputDir} does not exist or is not accessible.`;
32688
32704
  console.error(msg);
package/dist/index.js CHANGED
@@ -26002,6 +26002,7 @@ var import_nunjucks = __toESM(require_nunjucks(), 1);
26002
26002
  var import_slugify = __toESM(require_slugify(), 1);
26003
26003
  import path3 from "path";
26004
26004
  var {Glob: Glob2 } = globalThis.Bun;
26005
+ import fs2 from "fs";
26005
26006
 
26006
26007
  // src/utils/file-utils.ts
26007
26008
  var {Glob } = globalThis.Bun;
@@ -30052,8 +30053,16 @@ class SiteGenerator {
30052
30053
  async copyStaticAssets() {
30053
30054
  const assetsDir = path3.join(this.options.templatesDir, "assets");
30054
30055
  const publicDir = path3.join(process.cwd(), "public");
30056
+ async function dirExists(p) {
30057
+ try {
30058
+ const stat = await fs2.promises.stat(p);
30059
+ return stat.isDirectory();
30060
+ } catch {
30061
+ return false;
30062
+ }
30063
+ }
30055
30064
  const assetsDirFile = Bun.file(assetsDir);
30056
- if (await assetsDirFile.exists()) {
30065
+ if (await assetsDirFile.exists() && await dirExists(assetsDir)) {
30057
30066
  const assetGlob = new Glob2("**/*.*");
30058
30067
  const assetsOutputDir = path3.join(this.options.outputDir, "assets");
30059
30068
  await ensureDir(assetsOutputDir);
@@ -30068,23 +30077,30 @@ class SiteGenerator {
30068
30077
  await copyFile(file, targetPath);
30069
30078
  }
30070
30079
  }
30071
- const publicDirFile = Bun.file(publicDir);
30072
- if (await publicDirFile.exists()) {
30073
- const publicGlob = new Glob2("**/*.*");
30074
- for await (const file of publicGlob.scan({
30075
- cwd: publicDir,
30076
- absolute: true
30077
- })) {
30078
- const relativePath = path3.relative(publicDir, file);
30079
- const targetPath = path3.join(this.options.outputDir, relativePath);
30080
- const targetDir = path3.dirname(targetPath);
30081
- await ensureDir(targetDir);
30082
- const targetFile = Bun.file(targetPath);
30083
- if (!await targetFile.exists()) {
30084
- await copyFile(file, targetPath);
30080
+ if (await dirExists(publicDir)) {
30081
+ const copyRecursive = async (srcDir) => {
30082
+ const entries = await fs2.promises.readdir(srcDir, { withFileTypes: true });
30083
+ for (const entry of entries) {
30084
+ const srcPath = path3.join(srcDir, entry.name);
30085
+ const relativePath = path3.relative(publicDir, srcPath);
30086
+ const destPath = path3.join(this.options.outputDir, relativePath);
30087
+ if (!relativePath)
30088
+ continue;
30089
+ if (entry.isDirectory()) {
30090
+ await ensureDir(destPath);
30091
+ await copyRecursive(srcPath);
30092
+ } else if (entry.isFile()) {
30093
+ const targetFile = Bun.file(destPath);
30094
+ if (!await targetFile.exists()) {
30095
+ const targetDir = path3.dirname(destPath);
30096
+ await ensureDir(targetDir);
30097
+ await copyFile(srcPath, destPath);
30098
+ }
30099
+ }
30085
30100
  }
30086
- }
30087
- console.log("Copied public files to site");
30101
+ };
30102
+ await copyRecursive(publicDir);
30103
+ console.log("Copied public files to site (including extensionless & dotfiles)");
30088
30104
  }
30089
30105
  }
30090
30106
  async generateRSSFeed() {
@@ -30218,7 +30234,7 @@ ${rssItems}
30218
30234
  }
30219
30235
  // src/server.ts
30220
30236
  import path5 from "path";
30221
- import fs2 from "fs";
30237
+ import fs3 from "fs";
30222
30238
 
30223
30239
  // src/config.ts
30224
30240
  import path4 from "path";
@@ -30350,7 +30366,7 @@ export default function(): SiteConfig {
30350
30366
  // src/server.ts
30351
30367
  async function startServer(outputDir = DEFAULT_OUTPUT_DIR, port = 3000) {
30352
30368
  try {
30353
- const stats = await fs2.promises.stat(outputDir);
30369
+ const stats = await fs3.promises.stat(outputDir);
30354
30370
  if (!stats.isDirectory()) {
30355
30371
  const msg = `Error: Output directory ${outputDir} does not exist or is not accessible.`;
30356
30372
  console.error(msg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunki",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "An opinionated static site generator built with Bun featuring PostCSS integration and modern web development workflows",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",