bun-ready 0.2.0 → 0.2.3

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 (2) hide show
  1. package/dist/cli.js +108 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,11 +1,14 @@
1
- // src/cli.ts
2
- import { promises as fs3 } from "node:fs";
3
- import path5 from "node:path";
4
-
5
- // src/analyze.ts
6
- import path4 from "node:path";
7
- import os from "node:os";
8
- import { promises as fs2 } from "node:fs";
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true,
7
+ configurable: true,
8
+ set: (newValue) => all[name] = () => newValue
9
+ });
10
+ };
11
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
9
12
 
10
13
  // src/spawn.ts
11
14
  import { spawn } from "node:child_process";
@@ -18,8 +21,7 @@ var runNodeSpawn = async (cmd, args, cwd) => {
18
21
  child.stderr.on("data", (d) => err += String(d));
19
22
  child.on("close", (code) => resolve({ code: code ?? 1, stdout: out, stderr: err }));
20
23
  });
21
- };
22
- var runBunSpawn = async (cmd, args, cwd) => {
24
+ }, runBunSpawn = async (cmd, args, cwd) => {
23
25
  const BunAny = globalThis;
24
26
  const bun = BunAny.Bun;
25
27
  if (!bun)
@@ -46,10 +48,53 @@ var runBunSpawn = async (cmd, args, cwd) => {
46
48
  };
47
49
  const [stdout, stderr, code] = await Promise.all([readAll(proc.stdout), readAll(proc.stderr), proc.exited]);
48
50
  return { code, stdout, stderr };
49
- };
50
- var exec = async (cmd, args, cwd) => {
51
+ }, exec = async (cmd, args, cwd) => {
51
52
  return await runBunSpawn(cmd, args, cwd);
52
53
  };
54
+ var init_spawn = () => {};
55
+
56
+ // src/bun_check.ts
57
+ var exports_bun_check = {};
58
+ __export(exports_bun_check, {
59
+ checkBunAvailable: () => checkBunAvailable
60
+ });
61
+ async function checkBunAvailable() {
62
+ try {
63
+ const res = await exec("bun", ["--version"], process.cwd());
64
+ if (res.code === 0 && res.stdout.includes("bun")) {
65
+ return { available: true };
66
+ }
67
+ return {
68
+ available: false,
69
+ error: `Bun command returned unexpected output (exit ${res.code})`
70
+ };
71
+ } catch (error) {
72
+ const msg = error instanceof Error ? error.message : String(error);
73
+ if (msg.includes("ENOENT") || msg.includes("spawn bun ENOENT")) {
74
+ return {
75
+ available: false,
76
+ error: "Bun is not installed. Please install Bun from https://bun.sh or use --no-install and --no-test flags."
77
+ };
78
+ }
79
+ return {
80
+ available: false,
81
+ error: `Failed to check Bun availability: ${msg}`
82
+ };
83
+ }
84
+ }
85
+ var init_bun_check = __esm(() => {
86
+ init_spawn();
87
+ });
88
+
89
+ // src/cli.ts
90
+ import { promises as fs3 } from "node:fs";
91
+ import path5 from "node:path";
92
+
93
+ // src/analyze.ts
94
+ init_spawn();
95
+ import path4 from "node:path";
96
+ import os from "node:os";
97
+ import { promises as fs2 } from "node:fs";
53
98
 
54
99
  // src/util.ts
55
100
  import { promises as fs } from "node:fs";
@@ -399,7 +444,15 @@ var detectNativeAddonRiskV2 = (repo, config) => {
399
444
  const suspects = names.filter((n) => {
400
445
  if (allowlist.includes(n))
401
446
  return false;
402
- return NATIVE_SUSPECTS_V2.includes(n) || includesAny(n, ["napi", "node-gyp", "prebuild", "ffi", "bindings", "native", "native-module"]);
447
+ const inList = NATIVE_SUSPECTS_V2.includes(n);
448
+ if (inList)
449
+ return true;
450
+ const keywords = ["@napi-rs/", "napi-rs", "node-napi", "neon", "node-gyp", "prebuild", "ffi", "bindings", "native", "native-module"];
451
+ const keywordMatch = includesAny(n, keywords);
452
+ if (keywordMatch) {
453
+ return true;
454
+ }
455
+ return false;
403
456
  });
404
457
  const scriptNames = Object.keys(repo.scripts);
405
458
  const hasNodeGypRebuild = scriptNames.some((k) => {
@@ -693,6 +746,18 @@ async function copyIfExists(from, to) {
693
746
  }
694
747
  }
695
748
  async function runBunInstallDryRun(packagePath) {
749
+ const { checkBunAvailable: checkBunAvailable2 } = await Promise.resolve().then(() => (init_bun_check(), exports_bun_check));
750
+ const bunCheck = await checkBunAvailable2();
751
+ if (!bunCheck.available) {
752
+ const skipReason = bunCheck.error;
753
+ return {
754
+ ok: false,
755
+ summary: `Skipped: ${skipReason}`,
756
+ logs: [],
757
+ installAnalysis: { blockedDeps: [], trustedDepsMentioned: [], notes: [] },
758
+ skipReason
759
+ };
760
+ }
696
761
  const base = await fs2.mkdtemp(path4.join(os.tmpdir(), "bun-ready-"));
697
762
  const cleanup = async () => {
698
763
  try {
@@ -726,6 +791,17 @@ function shouldRunBunTest(scripts) {
726
791
  return t.toLowerCase().includes("bun test") || t.toLowerCase().trim() === "bun test";
727
792
  }
728
793
  async function runBunTest(packagePath) {
794
+ const { checkBunAvailable: checkBunAvailable2 } = await Promise.resolve().then(() => (init_bun_check(), exports_bun_check));
795
+ const bunCheck = await checkBunAvailable2();
796
+ if (!bunCheck.available) {
797
+ const skipReason = bunCheck.error;
798
+ return {
799
+ ok: false,
800
+ summary: `Skipped: ${skipReason}`,
801
+ logs: [],
802
+ skipReason
803
+ };
804
+ }
729
805
  const res = await exec("bun", ["test"], packagePath);
730
806
  const combined = [...res.stdout ? res.stdout.split(`
731
807
  `) : [], ...res.stderr ? res.stderr.split(`
@@ -758,7 +834,8 @@ async function analyzeSinglePackage(packagePath, opts, config, pkgName) {
758
834
  install = {
759
835
  ok: installResult.ok,
760
836
  summary: installResult.summary,
761
- logs: installResult.logs
837
+ logs: installResult.logs,
838
+ ...installResult.skipReason !== undefined ? { skipReason: installResult.skipReason } : {}
762
839
  };
763
840
  installOk = installResult.ok;
764
841
  if (installResult.installAnalysis.blockedDeps.length > 0) {
@@ -794,7 +871,8 @@ async function analyzeSinglePackage(packagePath, opts, config, pkgName) {
794
871
  test = {
795
872
  ok: testResult.ok,
796
873
  summary: testResult.summary,
797
- logs: testResult.logs
874
+ logs: testResult.logs,
875
+ ...testResult.skipReason !== undefined ? { skipReason: testResult.skipReason } : {}
798
876
  };
799
877
  testOk = testResult.ok;
800
878
  }
@@ -1283,6 +1361,21 @@ var main = async () => {
1283
1361
  scanOpts.failOn = opts.failOn;
1284
1362
  }
1285
1363
  const res = await analyzeRepoOverall(scanOpts);
1364
+ if (res.install?.skipReason || res.test?.skipReason) {
1365
+ const skipWarnings = [];
1366
+ if (res.install?.skipReason) {
1367
+ skipWarnings.push(`Install check skipped: ${res.install.skipReason}`);
1368
+ }
1369
+ if (res.test?.skipReason) {
1370
+ skipWarnings.push(`Test run skipped: ${res.test.skipReason}`);
1371
+ }
1372
+ if (skipWarnings.length > 0) {
1373
+ process.stderr.write(`WARNING:
1374
+ ${skipWarnings.map((w) => ` - ${w}`).join(`
1375
+ `)}
1376
+ `);
1377
+ }
1378
+ }
1286
1379
  const out = opts.format === "json" ? renderJson(res) : renderMarkdown(res);
1287
1380
  const target = opts.outFile ?? (opts.format === "json" ? "bun-ready.json" : "bun-ready.md");
1288
1381
  const resolved = path5.resolve(process.cwd(), target);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-ready",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "CLI that estimates how painful migrating a Node.js repo to Bun might be. Generates a green/yellow/red Markdown report with reasons.",
5
5
  "author": "Pas7 Studio",
6
6
  "license": "Apache-2.0",