@jayjiang/byoao 1.0.4 → 1.0.6

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.
@@ -1,53 +1,64 @@
1
- /**
2
- * Bun CJS interop shim.
3
- *
4
- * Bun 1.3.x cannot reliably load the CJS build of packages that have an
5
- * `exports` field (e.g. fs-extra): `import default` gives "Missing 'default'
6
- * export" and `createRequire` gives "require() async module".
7
- *
8
- * For fs-extra we build a combined ESM-native namespace from node:fs,
9
- * node:fs/promises, and fs-extra's own ESM subpath (which deliberately
10
- * excludes node:fs re-exports).
11
- *
12
- * For packages without an `exports` field (handlebars, gray-matter, semver)
13
- * createRequire works fine in both Bun and Node.js.
14
- */
15
- import { createRequire } from "node:module";
16
- // ── node:fs ──────────────────────────────────────────────────────────────────
17
- import { existsSync, readFileSync, readdirSync, } from "node:fs";
18
- // ── node:fs/promises ─────────────────────────────────────────────────────────
19
- import { readFile, writeFile, readdir, } from "node:fs/promises";
20
- // ── fs-extra ESM subpath ─────────────────────────────────────────────────────
21
- // "fs-extra/esm" is a proper ESM module with named + default exports.
22
- // It intentionally omits node:fs re-exports (those come from node:fs above).
23
- import { copy, ensureDir, pathExists, pathExistsSync, readJson, readJsonSync, writeJson, writeJsonSync, remove, removeSync, } from "fs-extra/esm";
24
- // Expose a unified `fs` object that matches the subset the codebase uses.
25
- // Typed as FsExtra so callers keep full type-safety without changing their code.
1
+ // ── native Node.js fs replacement ─────────────────────────────────────────────
2
+ import * as nodeFs from "node:fs";
3
+ import * as nodeFsPromises from "node:fs/promises";
4
+ import nodePath from "node:path";
5
+ async function copy(src, dest) {
6
+ await nodeFsPromises.cp(src, dest, { recursive: true });
7
+ }
8
+ async function ensureDir(dirPath) {
9
+ await nodeFsPromises.mkdir(dirPath, { recursive: true });
10
+ }
11
+ async function pathExists(filePath) {
12
+ try {
13
+ await nodeFsPromises.access(filePath);
14
+ return true;
15
+ }
16
+ catch {
17
+ return false;
18
+ }
19
+ }
20
+ function pathExistsSync(filePath) {
21
+ return nodeFs.existsSync(filePath);
22
+ }
23
+ async function readJson(filePath) {
24
+ return JSON.parse(await nodeFsPromises.readFile(filePath, "utf-8"));
25
+ }
26
+ function readJsonSync(filePath) {
27
+ return JSON.parse(nodeFs.readFileSync(filePath, "utf-8"));
28
+ }
29
+ async function writeJson(filePath, data, options) {
30
+ const indent = options?.spaces ?? 2;
31
+ await nodeFsPromises.mkdir(nodePath.dirname(filePath), { recursive: true });
32
+ await nodeFsPromises.writeFile(filePath, JSON.stringify(data, null, indent));
33
+ }
34
+ function writeJsonSync(filePath, data, options) {
35
+ const indent = options?.spaces ?? 2;
36
+ nodeFs.mkdirSync(nodePath.dirname(filePath), { recursive: true });
37
+ nodeFs.writeFileSync(filePath, JSON.stringify(data, null, indent));
38
+ }
39
+ async function remove(filePath) {
40
+ await nodeFsPromises.rm(filePath, { recursive: true, force: true });
41
+ }
42
+ function removeSync(filePath) {
43
+ nodeFs.rmSync(filePath, { recursive: true, force: true });
44
+ }
26
45
  export const fs = {
27
- existsSync,
28
- readFileSync,
29
- readdirSync,
30
- readFile,
31
- writeFile,
32
- readdir,
33
- copy,
34
- ensureDir,
35
- pathExists,
36
- pathExistsSync,
37
- readJson,
38
- readJsonSync,
39
- writeJson,
40
- writeJsonSync,
41
- remove,
42
- removeSync,
46
+ existsSync: nodeFs.existsSync,
47
+ readFileSync: nodeFs.readFileSync,
48
+ readdirSync: nodeFs.readdirSync,
49
+ readFile: nodeFsPromises.readFile,
50
+ writeFile: nodeFsPromises.writeFile,
51
+ readdir: nodeFsPromises.readdir,
52
+ mkdir: nodeFsPromises.mkdir,
53
+ copy, ensureDir, pathExists, pathExistsSync,
54
+ readJson, readJsonSync, writeJson, writeJsonSync,
55
+ remove, removeSync,
43
56
  };
44
- // ── CJS-only packages (no `exports` field createRequire works in Bun) ──────
45
- const _require = createRequire(import.meta.url);
46
- const _matter = _require("gray-matter");
47
- const _Handlebars = _require("handlebars");
48
- const _semver = _require("semver");
49
- const unwrap = (v) => (v["default"] ?? v);
50
- export const matter = unwrap(_matter);
51
- export const Handlebars = unwrap(_Handlebars);
52
- export const semver = unwrap(_semver);
57
+ // ── CJS packages — bundled inline by esbuild ─────────────────────────────────
58
+ import _matter from "gray-matter";
59
+ import _Handlebars from "handlebars";
60
+ import * as _semver from "semver";
61
+ export const matter = _matter;
62
+ export const Handlebars = _Handlebars;
63
+ export const semver = _semver;
53
64
  //# sourceMappingURL=cjs-modules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cjs-modules.js","sourceRoot":"","sources":["../../src/lib/cjs-modules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,gFAAgF;AAChF,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,gFAAgF;AAChF,OAAO,EACL,QAAQ,EACR,SAAS,EACT,OAAO,GACR,MAAM,kBAAkB,CAAC;AAE1B,gFAAgF;AAChF,sEAAsE;AACtE,6EAA6E;AAC7E,OAAO,EACL,IAAI,EACJ,SAAS,EACT,UAAU,EACV,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,aAAa,EACb,MAAM,EACN,UAAU,GACX,MAAM,cAAc,CAAC;AAOtB,0EAA0E;AAC1E,iFAAiF;AACjF,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,UAAU;IACV,YAAY;IACZ,WAAW;IACX,QAAQ;IACR,SAAS;IACT,OAAO;IACP,IAAI;IACJ,SAAS;IACT,UAAU;IACV,cAAc;IACd,QAAQ;IACR,YAAY;IACZ,SAAS;IACT,aAAa;IACb,MAAM;IACN,UAAU;CACkB,CAAC;AAE/B,gFAAgF;AAChF,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhD,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAA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AC;AACD,SAAS,UAAU,CAAC,QAAgB;IAClC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC,UAAU;IAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;IACjC,WAAW,EAAE,MAAM,CAAC,WAAW;IAC/B,QAAQ,EAAE,cAAc,CAAC,QAAQ;IACjC,SAAS,EAAE,cAAc,CAAC,SAAS;IACnC,OAAO,EAAE,cAAc,CAAC,OAAO;IAC/B,KAAK,EAAE,cAAc,CAAC,KAAK;IAC3B,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc;IAC3C,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa;IAChD,MAAM,EAAE,UAAU;CACU,CAAC;AAE/B,gFAAgF;AAChF,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,WAAW,MAAM,YAAY,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,QAAQ,CAAC;AAElC,MAAM,CAAC,MAAM,MAAM,GAAG,OAA4B,CAAC;AACnD,MAAM,CAAC,MAAM,UAAU,GAAG,WAAoC,CAAC;AAC/D,MAAM,CAAC,MAAM,MAAM,GAAG,OAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayjiang/byoao",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Build Your Own AI OS — Obsidian + AI Agent",
5
5
  "type": "module",
6
6
  "engines": {
@@ -12,7 +12,7 @@
12
12
  "byoao": "dist/cli/cli-program.js"
13
13
  },
14
14
  "scripts": {
15
- "build": "tsc",
15
+ "build": "node build.mjs",
16
16
  "dev": "node --import tsx src/cli/cli-program.ts",
17
17
  "test": "vitest run",
18
18
  "typecheck": "tsc --noEmit",
@@ -58,6 +58,7 @@
58
58
  "@types/inquirer": "^9.0.0",
59
59
  "@types/node": "^20.0.0",
60
60
  "@types/semver": "^7.7.1",
61
+ "esbuild": "^0.27.7",
61
62
  "tsx": "^4.21.0",
62
63
  "typescript": "^5.4.0",
63
64
  "vitest": "^4.1.0"