bun-ready 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,16 @@
1
+ bun-ready
2
+ Copyright (c) Pas7 Studio
3
+
4
+ This product includes software developed by Pas7 Studio (https://pas7.com.ua/).
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # bun-ready
2
+
3
+ [![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/pas7studio)
4
+ PayPal: https://www.paypal.com/ncp/payment/KDSSNKK8REDM8
5
+
6
+ CLI that estimates whether a repository will "survive" migrating to **Bun** — quickly.
7
+ It inspects `package.json`, lockfiles, scripts, and can run `bun install --dry-run` in a temp directory. It then generates a **green / yellow / red** Markdown report with reasons.
8
+
9
+ ## Why
10
+ Bun moves fast. People need a fast risk signal before they try to migrate a repo.
11
+
12
+ ## Install
13
+ ### Run without installing (recommended)
14
+ ```bash
15
+ bunx bun-ready scan .
16
+ ```
17
+
18
+ ### Install globally
19
+ ```bash
20
+ bun install -g bun-ready
21
+ bun-ready scan .
22
+ ```
23
+
24
+ ## Usage
25
+ ```bash
26
+ bun-ready scan <path> [--format md|json] [--out <file>] [--no-install] [--no-test] [--verbose]
27
+ ```
28
+
29
+ ## Examples:
30
+ ```bash
31
+ bun-ready scan .
32
+ bun-ready scan . --out bun-ready.md
33
+ bun-ready scan ./packages/api --format json
34
+ bun-ready scan . --no-install --no-test
35
+ ```
36
+
37
+ ## Exit codes
38
+ - 0 → GREEN
39
+ - 2 → YELLOW
40
+ - 3 → RED
41
+
42
+ ## What it checks (MVP)
43
+ - package.json presence & shape
44
+ - lockfiles (npm/yarn/pnpm/bun)
45
+ - scripts (postinstall/prepare, npm-specific patterns)
46
+ - heuristics for native addons / node-gyp risk
47
+ - optional: bun install --dry-run in a temp dir
48
+ - optional: bun test if tests appear Bun-compatible
49
+
50
+ ## Contributing
51
+ See CONTRIBUTING.md. For security issues, see SECURITY.md.
52
+
53
+ ## Support
54
+ If this tool saves you time, consider supporting:
55
+ - Ko-fi: https://ko-fi.com/pas7studio
56
+ - PayPal: https://www.paypal.com/ncp/payment/KDSSNKK8REDM8
57
+
58
+ ## Attribution
59
+ Created and maintained by Pas7 Studio
60
+ Website: https://pas7.com.ua/
61
+ LinkedIn: https://www.linkedin.com/company/pas7-studio
package/TRADEMARKS.md ADDED
@@ -0,0 +1,5 @@
1
+ # Trademarks
2
+
3
+ "Pas7 Studio" and related marks are trademarks of Pas7 Studio.
4
+
5
+ This project is an open-source tool and is not affiliated with, endorsed by, or sponsored by Bun or Oven (Bun's creators). All third-party trademarks are the property of their respective owners.
package/dist/cli.js ADDED
@@ -0,0 +1,513 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { promises as fs3 } from "node:fs";
5
+ import path3 from "node:path";
6
+
7
+ // src/analyze.ts
8
+ import path2 from "node:path";
9
+ import os from "node:os";
10
+ import { promises as fs2 } from "node:fs";
11
+
12
+ // src/spawn.ts
13
+ import { spawn } from "node:child_process";
14
+ var runNodeSpawn = async (cmd, args, cwd) => {
15
+ return await new Promise((resolve) => {
16
+ const child = spawn(cmd, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
17
+ let out = "";
18
+ let err = "";
19
+ child.stdout.on("data", (d) => out += String(d));
20
+ child.stderr.on("data", (d) => err += String(d));
21
+ child.on("close", (code) => resolve({ code: code ?? 1, stdout: out, stderr: err }));
22
+ });
23
+ };
24
+ var runBunSpawn = async (cmd, args, cwd) => {
25
+ const BunAny = globalThis;
26
+ const bun = BunAny.Bun;
27
+ if (!bun)
28
+ return await runNodeSpawn(cmd, args, cwd);
29
+ const proc = bun.spawn([cmd, ...args], { cwd, stdout: "pipe", stderr: "pipe" });
30
+ const readAll = async (s) => {
31
+ const r = s.getReader();
32
+ const chunks = [];
33
+ while (true) {
34
+ const { done, value } = await r.read();
35
+ if (done)
36
+ break;
37
+ if (value)
38
+ chunks.push(value);
39
+ }
40
+ const total = chunks.reduce((n, c) => n + c.length, 0);
41
+ const buf = new Uint8Array(total);
42
+ let off = 0;
43
+ for (const c of chunks) {
44
+ buf.set(c, off);
45
+ off += c.length;
46
+ }
47
+ return new TextDecoder().decode(buf);
48
+ };
49
+ const [stdout, stderr, code] = await Promise.all([readAll(proc.stdout), readAll(proc.stderr), proc.exited]);
50
+ return { code, stdout, stderr };
51
+ };
52
+ var exec = async (cmd, args, cwd) => {
53
+ return await runBunSpawn(cmd, args, cwd);
54
+ };
55
+
56
+ // src/util.ts
57
+ import { promises as fs } from "node:fs";
58
+ import path from "node:path";
59
+ var stableSort = (arr, key) => {
60
+ return [...arr].sort((a, b) => key(a).localeCompare(key(b), "en"));
61
+ };
62
+ var readJsonFile = async (p) => {
63
+ const raw = await fs.readFile(p, "utf8");
64
+ return JSON.parse(raw);
65
+ };
66
+ var fileExists = async (p) => {
67
+ try {
68
+ await fs.access(p);
69
+ return true;
70
+ } catch {
71
+ return false;
72
+ }
73
+ };
74
+ var normalizeRepoPath = (p) => {
75
+ return path.resolve(process.cwd(), p);
76
+ };
77
+ var truncateLines = (lines, max) => {
78
+ if (lines.length <= max)
79
+ return lines;
80
+ return [...lines.slice(0, max), `… (${lines.length - max} more lines)`];
81
+ };
82
+
83
+ // src/heuristics.ts
84
+ var NATIVE_SUSPECTS = [
85
+ "node-gyp",
86
+ "node-pre-gyp",
87
+ "prebuild-install",
88
+ "bindings",
89
+ "nan",
90
+ "node-addon-api",
91
+ "node-sass",
92
+ "sharp",
93
+ "canvas",
94
+ "better-sqlite3",
95
+ "sqlite3",
96
+ "bcrypt",
97
+ "argon2",
98
+ "bufferutil",
99
+ "utf-8-validate",
100
+ "fsevents"
101
+ ];
102
+ var includesAny = (s, needles) => {
103
+ const lower = s.toLowerCase();
104
+ return needles.some((n) => lower.includes(n));
105
+ };
106
+ var maxSeverity = (a, b) => {
107
+ if (a === "red" || b === "red")
108
+ return "red";
109
+ if (a === "yellow" || b === "yellow")
110
+ return "yellow";
111
+ return "green";
112
+ };
113
+ var detectScriptRisks = (repo) => {
114
+ const findings = [];
115
+ const scriptNames = Object.keys(repo.scripts);
116
+ const lifecycle = ["preinstall", "install", "postinstall", "preprepare", "prepare", "postprepare"];
117
+ const hits = stableSort(scriptNames.filter((s) => lifecycle.includes(s)), (x) => x);
118
+ if (hits.length > 0) {
119
+ const details = hits.map((k) => `${k}: ${repo.scripts[k] ?? ""}`.trim());
120
+ findings.push({
121
+ id: "scripts.lifecycle",
122
+ title: "Lifecycle scripts in the root project",
123
+ severity: "yellow",
124
+ details,
125
+ hints: [
126
+ "Bun runs your project lifecycle scripts during install. Verify they don't rely on npm-specific behavior.",
127
+ "If scripts compile native deps, expect migration friction."
128
+ ]
129
+ });
130
+ }
131
+ const npmSpecificNeedles = ["npm ", "npx ", "pnpm ", "yarn ", "npm_config_", "corepack", "npm ci"];
132
+ const npmish = stableSort(scriptNames.filter((k) => includesAny(repo.scripts[k] ?? "", npmSpecificNeedles)), (x) => x);
133
+ if (npmish.length > 0) {
134
+ findings.push({
135
+ id: "scripts.npm_specific",
136
+ title: "Scripts reference npm/yarn/pnpm-specific commands or env",
137
+ severity: "yellow",
138
+ details: npmish.map((k) => `${k}: ${repo.scripts[k] ?? ""}`.trim()),
139
+ hints: [
140
+ "Consider rewriting scripts to be runner-agnostic, or provide a Bun path.",
141
+ "If using npm-only flags/behavior, verify equivalence on Bun."
142
+ ]
143
+ });
144
+ }
145
+ return findings;
146
+ };
147
+ var detectNativeAddonRisk = (repo) => {
148
+ const allDeps = {
149
+ ...repo.dependencies,
150
+ ...repo.devDependencies,
151
+ ...repo.optionalDependencies
152
+ };
153
+ const names = Object.keys(allDeps);
154
+ const suspects = stableSort(names.filter((n) => NATIVE_SUSPECTS.includes(n) || includesAny(n, ["napi", "node-gyp", "prebuild", "ffi"])), (x) => x);
155
+ if (suspects.length === 0)
156
+ return [];
157
+ const hardRed = suspects.some((n) => n === "node-gyp" || n === "node-sass");
158
+ const severity = hardRed ? "red" : "yellow";
159
+ return [
160
+ {
161
+ id: "deps.native_addons",
162
+ title: "Potential native addons / node-gyp toolchain risk",
163
+ severity,
164
+ details: suspects.map((n) => `${n}@${allDeps[n] ?? ""}`.trim()),
165
+ hints: [
166
+ "Native addons often require toolchains and can be sensitive to runtime differences.",
167
+ "If you see install/build failures, try upgrading these packages or switching to pure-JS alternatives."
168
+ ]
169
+ }
170
+ ];
171
+ };
172
+ var detectLockfileSignals = (repo) => {
173
+ const { bunLock, bunLockb, npmLock, yarnLock, pnpmLock } = repo.lockfiles;
174
+ if (bunLock || bunLockb)
175
+ return [];
176
+ const anyOther = npmLock || yarnLock || pnpmLock;
177
+ if (!anyOther) {
178
+ return [
179
+ {
180
+ id: "lockfile.missing",
181
+ title: "No lockfile found",
182
+ severity: "yellow",
183
+ details: ["No bun.lock/bun.lockb, package-lock.json, yarn.lock, or pnpm-lock.yaml detected."],
184
+ hints: [
185
+ "Lockfiles improve reproducibility. Consider committing one before migration.",
186
+ "If you migrate to Bun, generate bun.lock and verify installs are stable."
187
+ ]
188
+ }
189
+ ];
190
+ }
191
+ const present = [];
192
+ if (npmLock)
193
+ present.push("package-lock.json");
194
+ if (yarnLock)
195
+ present.push("yarn.lock");
196
+ if (pnpmLock)
197
+ present.push("pnpm-lock.yaml");
198
+ return [
199
+ {
200
+ id: "lockfile.migration",
201
+ title: "Non-Bun lockfile detected (Bun will likely migrate on first install)",
202
+ severity: "yellow",
203
+ details: [`Detected: ${present.join(", ")}`],
204
+ hints: [
205
+ "Run bun install once on a branch and review the generated bun.lock.",
206
+ "Compare resolved versions and run your test suite."
207
+ ]
208
+ }
209
+ ];
210
+ };
211
+ var summarizeSeverity = (findings, installOk, testOk) => {
212
+ let sev = "green";
213
+ for (const f of findings)
214
+ sev = maxSeverity(sev, f.severity);
215
+ if (installOk === false)
216
+ sev = "red";
217
+ if (testOk === false)
218
+ sev = "red";
219
+ return sev;
220
+ };
221
+
222
+ // src/analyze.ts
223
+ var readRepoInfo = async (repoPath) => {
224
+ const packageJsonPath = path2.join(repoPath, "package.json");
225
+ const pkg = await readJsonFile(packageJsonPath);
226
+ const scripts = pkg.scripts ?? {};
227
+ const dependencies = pkg.dependencies ?? {};
228
+ const devDependencies = pkg.devDependencies ?? {};
229
+ const optionalDependencies = pkg.optionalDependencies ?? {};
230
+ const hasWorkspaces = Boolean(pkg.workspaces);
231
+ const lockfiles = {
232
+ bunLock: await fileExists(path2.join(repoPath, "bun.lock")),
233
+ bunLockb: await fileExists(path2.join(repoPath, "bun.lockb")),
234
+ npmLock: await fileExists(path2.join(repoPath, "package-lock.json")),
235
+ yarnLock: await fileExists(path2.join(repoPath, "yarn.lock")),
236
+ pnpmLock: await fileExists(path2.join(repoPath, "pnpm-lock.yaml"))
237
+ };
238
+ return { packageJsonPath, lockfiles, scripts, dependencies, devDependencies, optionalDependencies, hasWorkspaces };
239
+ };
240
+ var copyIfExists = async (from, to) => {
241
+ try {
242
+ await fs2.copyFile(from, to);
243
+ } catch {
244
+ return;
245
+ }
246
+ };
247
+ var runBunInstallDryRun = async (repoPath) => {
248
+ const base = await fs2.mkdtemp(path2.join(os.tmpdir(), "bun-ready-"));
249
+ const cleanup = async () => {
250
+ try {
251
+ await fs2.rm(base, { recursive: true, force: true });
252
+ } catch {
253
+ return;
254
+ }
255
+ };
256
+ try {
257
+ await copyIfExists(path2.join(repoPath, "package.json"), path2.join(base, "package.json"));
258
+ await copyIfExists(path2.join(repoPath, "bun.lock"), path2.join(base, "bun.lock"));
259
+ await copyIfExists(path2.join(repoPath, "bun.lockb"), path2.join(base, "bun.lockb"));
260
+ await copyIfExists(path2.join(repoPath, "package-lock.json"), path2.join(base, "package-lock.json"));
261
+ await copyIfExists(path2.join(repoPath, "yarn.lock"), path2.join(base, "yarn.lock"));
262
+ await copyIfExists(path2.join(repoPath, "pnpm-lock.yaml"), path2.join(base, "pnpm-lock.yaml"));
263
+ const res = await exec("bun", ["install", "--dry-run"], base);
264
+ const combined = [...res.stdout ? res.stdout.split(`
265
+ `) : [], ...res.stderr ? res.stderr.split(`
266
+ `) : []].filter((l) => l.trim().length > 0);
267
+ const logs = truncateLines(combined, 60);
268
+ return res.code === 0 ? { ok: true, summary: "bun install --dry-run succeeded", logs } : { ok: false, summary: `bun install --dry-run failed (exit ${res.code})`, logs };
269
+ } finally {
270
+ await cleanup();
271
+ }
272
+ };
273
+ var shouldRunBunTest = (repo) => {
274
+ const t = repo.scripts["test"];
275
+ if (!t)
276
+ return false;
277
+ return t.toLowerCase().includes("bun test") || t.toLowerCase().trim() === "bun test";
278
+ };
279
+ var runBunTest = async (repoPath) => {
280
+ const res = await exec("bun", ["test"], repoPath);
281
+ const combined = [...res.stdout ? res.stdout.split(`
282
+ `) : [], ...res.stderr ? res.stderr.split(`
283
+ `) : []].filter((l) => l.trim().length > 0);
284
+ const logs = truncateLines(combined, 120);
285
+ return res.code === 0 ? { ok: true, summary: "bun test succeeded", logs } : { ok: false, summary: `bun test failed (exit ${res.code})`, logs };
286
+ };
287
+ var analyzeRepo = async (opts) => {
288
+ const repoPath = normalizeRepoPath(opts.repoPath);
289
+ const packageJsonPath = path2.join(repoPath, "package.json");
290
+ const hasPkg = await fileExists(packageJsonPath);
291
+ if (!hasPkg) {
292
+ return {
293
+ severity: "red",
294
+ summaryLines: ["package.json not found"],
295
+ findings: [
296
+ {
297
+ id: "repo.no_package_json",
298
+ title: "Missing package.json",
299
+ severity: "red",
300
+ details: [`Expected at: ${packageJsonPath.replace(/\\/g, "/")}`],
301
+ hints: ["Run bun-ready in a Node.js project root (where package.json exists)."]
302
+ }
303
+ ],
304
+ install: null,
305
+ test: null,
306
+ repo: {
307
+ packageJsonPath,
308
+ lockfiles: { bunLock: false, bunLockb: false, npmLock: false, yarnLock: false, pnpmLock: false },
309
+ scripts: {},
310
+ dependencies: {},
311
+ devDependencies: {},
312
+ optionalDependencies: {},
313
+ hasWorkspaces: false
314
+ }
315
+ };
316
+ }
317
+ const repo = await readRepoInfo(repoPath);
318
+ const findings = [
319
+ ...detectLockfileSignals(repo),
320
+ ...detectScriptRisks(repo),
321
+ ...detectNativeAddonRisk(repo)
322
+ ];
323
+ const install = opts.runInstall ? await runBunInstallDryRun(repoPath) : null;
324
+ const allowTest = opts.runTest && shouldRunBunTest(repo);
325
+ const test = allowTest ? await runBunTest(repoPath) : null;
326
+ const installOk = install ? install.ok : null;
327
+ const testOk = test ? test.ok : null;
328
+ const severity = summarizeSeverity(findings, installOk, testOk);
329
+ const summaryLines = [];
330
+ summaryLines.push(`Lockfiles: ${repo.lockfiles.bunLock || repo.lockfiles.bunLockb ? "bun" : "non-bun or missing"}`);
331
+ summaryLines.push(`Lifecycle scripts: ${Object.keys(repo.scripts).some((k) => ["postinstall", "prepare", "preinstall", "install"].includes(k)) ? "present" : "none"}`);
332
+ summaryLines.push(`Native addon risk: ${findings.some((f) => f.id === "deps.native_addons") ? "yes" : "no"}`);
333
+ summaryLines.push(`bun install dry-run: ${install ? install.ok ? "ok" : "failed" : "skipped"}`);
334
+ summaryLines.push(`bun test: ${test ? test.ok ? "ok" : "failed" : allowTest ? "running" : "skipped"}`);
335
+ return { severity, summaryLines, findings, install, test, repo };
336
+ };
337
+
338
+ // src/report_md.ts
339
+ var badge = (s) => {
340
+ if (s === "green")
341
+ return "\uD83D\uDFE2 GREEN";
342
+ if (s === "yellow")
343
+ return "\uD83D\uDFE1 YELLOW";
344
+ return "\uD83D\uDD34 RED";
345
+ };
346
+ var renderMarkdown = (r) => {
347
+ const lines = [];
348
+ lines.push(`# bun-ready report`);
349
+ lines.push(``);
350
+ lines.push(`**Overall:** ${badge(r.severity)}`);
351
+ lines.push(``);
352
+ lines.push(`## Summary`);
353
+ for (const l of r.summaryLines)
354
+ lines.push(`- ${l}`);
355
+ lines.push(``);
356
+ lines.push(`## Repo`);
357
+ lines.push(`- Path: \`${r.repo.packageJsonPath.replace(/\\/g, "/")}\``);
358
+ lines.push(`- Workspaces: ${r.repo.hasWorkspaces ? "yes" : "no"}`);
359
+ const lock = [];
360
+ if (r.repo.lockfiles.bunLock)
361
+ lock.push("bun.lock");
362
+ if (r.repo.lockfiles.bunLockb)
363
+ lock.push("bun.lockb");
364
+ if (r.repo.lockfiles.npmLock)
365
+ lock.push("package-lock.json");
366
+ if (r.repo.lockfiles.yarnLock)
367
+ lock.push("yarn.lock");
368
+ if (r.repo.lockfiles.pnpmLock)
369
+ lock.push("pnpm-lock.yaml");
370
+ lines.push(`- Lockfiles: ${lock.length === 0 ? "none" : lock.join(", ")}`);
371
+ lines.push(``);
372
+ if (r.install) {
373
+ lines.push(`## bun install (dry-run)`);
374
+ lines.push(`- Result: ${r.install.ok ? "ok" : "failed"}`);
375
+ lines.push(`- Summary: ${r.install.summary}`);
376
+ if (r.install.logs.length > 0) {
377
+ lines.push(``);
378
+ lines.push("```text");
379
+ for (const l of r.install.logs)
380
+ lines.push(l);
381
+ lines.push("```");
382
+ }
383
+ lines.push(``);
384
+ }
385
+ if (r.test) {
386
+ lines.push(`## bun test`);
387
+ lines.push(`- Result: ${r.test.ok ? "ok" : "failed"}`);
388
+ lines.push(`- Summary: ${r.test.summary}`);
389
+ if (r.test.logs.length > 0) {
390
+ lines.push(``);
391
+ lines.push("```text");
392
+ for (const l of r.test.logs)
393
+ lines.push(l);
394
+ lines.push("```");
395
+ }
396
+ lines.push(``);
397
+ }
398
+ lines.push(`## Findings`);
399
+ if (r.findings.length === 0) {
400
+ lines.push(`No findings. Looks good.`);
401
+ lines.push(``);
402
+ return lines.join(`
403
+ `);
404
+ }
405
+ const findings = stableSort(r.findings, (f) => `${f.severity}:${f.id}`);
406
+ for (const f of findings) {
407
+ lines.push(`### ${f.title} (${badge(f.severity)})`);
408
+ lines.push(``);
409
+ for (const d of f.details)
410
+ lines.push(`- ${d}`);
411
+ if (f.hints.length > 0) {
412
+ lines.push(``);
413
+ lines.push(`**Hints:**`);
414
+ for (const h of f.hints)
415
+ lines.push(`- ${h}`);
416
+ }
417
+ lines.push(``);
418
+ }
419
+ return lines.join(`
420
+ `);
421
+ };
422
+
423
+ // src/report_json.ts
424
+ var renderJson = (r) => {
425
+ return JSON.stringify(r, null, 2);
426
+ };
427
+
428
+ // src/cli.ts
429
+ var usage = () => {
430
+ return [
431
+ "bun-ready",
432
+ "",
433
+ "Usage:",
434
+ " bun-ready scan <path> [--format md|json] [--out <file>] [--no-install] [--no-test] [--verbose]",
435
+ "",
436
+ "Exit codes:",
437
+ " 0 green, 2 yellow, 3 red"
438
+ ].join(`
439
+ `);
440
+ };
441
+ var parseArgs = (argv) => {
442
+ const args = argv.slice(2);
443
+ const cmd = args[0] ?? "";
444
+ if (cmd !== "scan") {
445
+ return {
446
+ cmd,
447
+ opts: { repoPath: ".", format: "md", outFile: null, runInstall: true, runTest: true, verbose: false }
448
+ };
449
+ }
450
+ const repoPath = args[1] && !args[1].startsWith("-") ? args[1] : ".";
451
+ let format = "md";
452
+ let outFile = null;
453
+ let runInstall = true;
454
+ let runTest = true;
455
+ let verbose = false;
456
+ for (let i = 2;i < args.length; i++) {
457
+ const a = args[i] ?? "";
458
+ if (a === "--format") {
459
+ const v = args[i + 1] ?? "";
460
+ if (v === "md" || v === "json")
461
+ format = v;
462
+ i++;
463
+ continue;
464
+ }
465
+ if (a === "--out") {
466
+ outFile = args[i + 1] ?? null;
467
+ i++;
468
+ continue;
469
+ }
470
+ if (a === "--no-install") {
471
+ runInstall = false;
472
+ continue;
473
+ }
474
+ if (a === "--no-test") {
475
+ runTest = false;
476
+ continue;
477
+ }
478
+ if (a === "--verbose") {
479
+ verbose = true;
480
+ continue;
481
+ }
482
+ }
483
+ return { cmd, opts: { repoPath, format, outFile, runInstall, runTest, verbose } };
484
+ };
485
+ var exitCode = (sev) => {
486
+ if (sev === "green")
487
+ return 0;
488
+ if (sev === "yellow")
489
+ return 2;
490
+ return 3;
491
+ };
492
+ var main = async () => {
493
+ const { cmd, opts } = parseArgs(process.argv);
494
+ if (cmd !== "scan") {
495
+ process.stderr.write(usage() + `
496
+ `);
497
+ process.exit(1);
498
+ }
499
+ const res = await analyzeRepo(opts);
500
+ const out = opts.format === "json" ? renderJson(res) : renderMarkdown(res);
501
+ const target = opts.outFile ?? (opts.format === "json" ? "bun-ready.json" : "bun-ready.md");
502
+ const resolved = path3.resolve(process.cwd(), target);
503
+ await fs3.writeFile(resolved, out, "utf8");
504
+ process.stdout.write(`Wrote ${opts.format.toUpperCase()} report to ${resolved}
505
+ `);
506
+ process.exit(exitCode(res.severity));
507
+ };
508
+ main().catch((e) => {
509
+ const msg = e instanceof Error ? e.message : String(e);
510
+ process.stderr.write(`bun-ready failed: ${msg}
511
+ `);
512
+ process.exit(3);
513
+ });
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "bun-ready",
3
+ "version": "0.1.0",
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
+ "author": "Pas7 Studio",
6
+ "license": "Apache-2.0",
7
+ "homepage": "https://pas7.com.ua/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/pas7studio/bun-ready"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/pas7studio/bun-ready/issues"
14
+ },
15
+ "keywords": [
16
+ "bun",
17
+ "migration",
18
+ "audit",
19
+ "cli",
20
+ "nodejs",
21
+ "package-manager"
22
+ ],
23
+ "type": "module",
24
+ "bin": {
25
+ "bun-ready": "dist/cli.js"
26
+ },
27
+ "files": [
28
+ "dist/",
29
+ "README.md",
30
+ "LICENSE",
31
+ "NOTICE",
32
+ "TRADEMARKS.md"
33
+ ],
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "scripts": {
38
+ "test": "bun test",
39
+ "check": "bunx --yes tsc -p tsconfig.json --noEmit",
40
+ "build": "bun build ./src/cli.ts --outdir ./dist --target=node",
41
+ "dev": "bun run ./src/cli.ts scan . --no-install --no-test --format md",
42
+ "prepack": "bun run build"
43
+ },
44
+ "devDependencies": {
45
+ "typescript": "^5.6.3",
46
+ "@types/node": "^22.0.0",
47
+ "bun-types": "^1.2.22"
48
+ }
49
+ }