@olegkuibar/plunk 0.2.3 → 0.3.0-canary.0807dec

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 (78) hide show
  1. package/dist/add-4LHIITHV.mjs +14 -0
  2. package/dist/chokidar-LVDD2IK4.mjs +4 -0
  3. package/dist/chunk-2VCW5RWI.mjs +3 -0
  4. package/dist/chunk-4QWBGXB5.mjs +15 -0
  5. package/dist/chunk-4TNTNSAB.mjs +4 -0
  6. package/dist/chunk-6YX2BGO2.mjs +3 -0
  7. package/dist/chunk-7JG555TZ.mjs +3 -0
  8. package/dist/chunk-AR7AKSKG.mjs +3 -0
  9. package/dist/chunk-HW7AEGI3.mjs +3 -0
  10. package/dist/chunk-KVVUZ6KL.mjs +4 -0
  11. package/dist/chunk-LI4HG26F.mjs +4 -0
  12. package/dist/chunk-MBKCCWSD.mjs +3 -0
  13. package/dist/chunk-OL7SNXMX.mjs +7 -0
  14. package/dist/chunk-QUI5JAIH.mjs +3 -0
  15. package/dist/chunk-RITKSDMP.mjs +3 -0
  16. package/dist/chunk-UAGG5WMD.mjs +3 -0
  17. package/dist/chunk-UDONDVIM.mjs +7 -0
  18. package/dist/chunk-ZAUWE3N7.mjs +12 -0
  19. package/dist/chunk-ZIXSXQRE.mjs +3 -0
  20. package/dist/chunk-ZJMZKJNW.mjs +3 -0
  21. package/dist/clean-EWBL6FW2.mjs +3 -0
  22. package/dist/cli.mjs +2 -56
  23. package/dist/dev-NCLIWE2E.mjs +3 -0
  24. package/dist/doctor-PXC45S34.mjs +4 -0
  25. package/dist/index.d.ts +19 -2
  26. package/dist/index.mjs +572 -244
  27. package/dist/init-TZ76GAWN.mjs +7 -0
  28. package/dist/list-CCR7QD7N.mjs +5 -0
  29. package/dist/migrate-6RZ3SEU5.mjs +8 -0
  30. package/dist/publish-4TDT6TTS.mjs +3 -0
  31. package/dist/push-M4RSFETI.mjs +3 -0
  32. package/dist/remove-R55FIXPL.mjs +3 -0
  33. package/dist/restore-XBFOHISI.mjs +11 -0
  34. package/dist/status-GCATYK2I.mjs +4 -0
  35. package/dist/tailwind-source-VPNLLSRJ.mjs +5 -0
  36. package/dist/update-6PLGM37S.mjs +3 -0
  37. package/dist/vite-config-ZMDIOTXC.mjs +10 -0
  38. package/dist/vite-plugin.mjs +2 -1
  39. package/dist/workspace-VREEJZ76.mjs +3 -0
  40. package/package.json +2 -8
  41. package/dist/add-5ZRFUL6Z.mjs +0 -258
  42. package/dist/chokidar-XGAEDN45.mjs +0 -1746
  43. package/dist/chunk-34UXZ622.mjs +0 -98
  44. package/dist/chunk-4O2QOKVO.mjs +0 -1958
  45. package/dist/chunk-CSMZ6DZA.mjs +0 -367
  46. package/dist/chunk-CZM4TNAI.mjs +0 -292
  47. package/dist/chunk-EDUXIQ5W.mjs +0 -1729
  48. package/dist/chunk-GAAB2TLH.mjs +0 -160
  49. package/dist/chunk-HKNM3UWU.mjs +0 -496
  50. package/dist/chunk-I6SN7BBN.mjs +0 -1131
  51. package/dist/chunk-KYDBD2KQ.mjs +0 -39
  52. package/dist/chunk-LKQINKH4.mjs +0 -130
  53. package/dist/chunk-PUSXMPOF.mjs +0 -82
  54. package/dist/chunk-S4HJSJ32.mjs +0 -69
  55. package/dist/chunk-W3C72UKC.mjs +0 -113
  56. package/dist/chunk-WSECI6M7.mjs +0 -85
  57. package/dist/chunk-XMIZ7OUZ.mjs +0 -26
  58. package/dist/chunk-XZK5T4GK.mjs +0 -23
  59. package/dist/chunk-ZOYNYK5Y.mjs +0 -23
  60. package/dist/chunk-ZQCGJUBJ.mjs +0 -92
  61. package/dist/clean-LTR5MZTY.mjs +0 -84
  62. package/dist/dev-LFXQP6SA.mjs +0 -194
  63. package/dist/dist-DUFCZSIL.mjs +0 -813
  64. package/dist/doctor-R7ZVR7PY.mjs +0 -230
  65. package/dist/hash-worker.mjs +0 -65
  66. package/dist/init-SWCNRISY.mjs +0 -310
  67. package/dist/list-B77L2F34.mjs +0 -119
  68. package/dist/migrate-X5TIC5SS.mjs +0 -124
  69. package/dist/prompt-HTPH6HQ7.mjs +0 -756
  70. package/dist/publish-UXCLPNM6.mjs +0 -63
  71. package/dist/push-JI6HGCFG.mjs +0 -197
  72. package/dist/remove-DCR7KKD5.mjs +0 -149
  73. package/dist/restore-SUN3WGSW.mjs +0 -124
  74. package/dist/status-MESRBH54.mjs +0 -103
  75. package/dist/tailwind-source-JBBEIXIJ.mjs +0 -89
  76. package/dist/update-SKDSA673.mjs +0 -100
  77. package/dist/vite-config-BAK67JHB.mjs +0 -128
  78. package/dist/workspace-76HJPAK2.mjs +0 -97
@@ -1,230 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
- import {
4
- detectBundler,
5
- detectPackageManager,
6
- detectYarnNodeLinker,
7
- hasYarnrcYml
8
- } from "./chunk-34UXZ622.mjs";
9
- import {
10
- readConsumerState,
11
- readConsumersRegistry
12
- } from "./chunk-GAAB2TLH.mjs";
13
- import {
14
- getStoreEntry,
15
- listStoreEntries
16
- } from "./chunk-W3C72UKC.mjs";
17
- import {
18
- require_picocolors
19
- } from "./chunk-PUSXMPOF.mjs";
20
- import {
21
- getConsumersPath,
22
- getStorePath
23
- } from "./chunk-EDUXIQ5W.mjs";
24
- import {
25
- output,
26
- suppressHumanOutput
27
- } from "./chunk-ZOYNYK5Y.mjs";
28
- import {
29
- defineCommand
30
- } from "./chunk-CSMZ6DZA.mjs";
31
- import {
32
- exists
33
- } from "./chunk-HKNM3UWU.mjs";
34
- import {
35
- consola
36
- } from "./chunk-I6SN7BBN.mjs";
37
- import {
38
- __toESM
39
- } from "./chunk-KYDBD2KQ.mjs";
40
-
41
- // src/commands/doctor.ts
42
- import { resolve, join } from "path";
43
- var import_picocolors = __toESM(require_picocolors(), 1);
44
- var doctor_default = defineCommand({
45
- meta: {
46
- name: "doctor",
47
- description: "Run diagnostic checks on your plunk setup"
48
- },
49
- async run() {
50
- suppressHumanOutput();
51
- const consumerPath = resolve(".");
52
- const results = [];
53
- consola.info("Running plunk diagnostics...\n");
54
- const storePath = getStorePath();
55
- if (await exists(storePath)) {
56
- const entries = await listStoreEntries();
57
- results.push({
58
- name: "Store directory",
59
- status: "pass",
60
- message: `${entries.length} entries in ${storePath}`
61
- });
62
- } else {
63
- results.push({
64
- name: "Store directory",
65
- status: "warn",
66
- message: `Store not found at ${storePath}. Run 'plunk publish' to create it.`
67
- });
68
- }
69
- const consumersPath = getConsumersPath();
70
- if (await exists(consumersPath)) {
71
- const registry = await readConsumersRegistry();
72
- const total = Object.values(registry).flat().length;
73
- results.push({
74
- name: "Global registry",
75
- status: "pass",
76
- message: `${Object.keys(registry).length} packages, ${total} consumer registrations`
77
- });
78
- } else {
79
- results.push({
80
- name: "Global registry",
81
- status: "warn",
82
- message: "No consumers registered yet. Use 'plunk add' to link packages."
83
- });
84
- }
85
- const state = await readConsumerState(consumerPath);
86
- const links = Object.entries(state.links);
87
- if (links.length > 0) {
88
- results.push({
89
- name: "Consumer state",
90
- status: "pass",
91
- message: `${links.length} linked package(s)`
92
- });
93
- for (const [name, link] of links) {
94
- const entry = await getStoreEntry(name, link.version);
95
- if (!entry) {
96
- results.push({
97
- name: `Store: ${name}`,
98
- status: "fail",
99
- message: `Store entry missing for ${name}@${link.version}. Re-publish it.`
100
- });
101
- } else if (entry.meta.contentHash !== link.contentHash) {
102
- results.push({
103
- name: `Store: ${name}`,
104
- status: "warn",
105
- message: `Store has newer content. Run 'plunk update' to sync.`
106
- });
107
- } else {
108
- results.push({
109
- name: `Store: ${name}`,
110
- status: "pass",
111
- message: `${name}@${link.version} in sync`
112
- });
113
- }
114
- const nmPath = join(consumerPath, "node_modules", name);
115
- if (!await exists(nmPath)) {
116
- results.push({
117
- name: `node_modules: ${name}`,
118
- status: "fail",
119
- message: `Missing from node_modules. Run 'plunk restore'.`
120
- });
121
- }
122
- }
123
- } else {
124
- results.push({
125
- name: "Consumer state",
126
- status: "warn",
127
- message: "No packages linked. Use 'plunk add' to link a package."
128
- });
129
- }
130
- const pm = await detectPackageManager(consumerPath);
131
- results.push({
132
- name: "Package manager",
133
- status: "pass",
134
- message: pm
135
- });
136
- if (pm === "yarn") {
137
- const linker = await detectYarnNodeLinker(consumerPath);
138
- const yarnrcExists = await hasYarnrcYml(consumerPath);
139
- if (!yarnrcExists) {
140
- results.push({
141
- name: "Yarn linker",
142
- status: "pass",
143
- message: "Yarn Classic, node_modules mode"
144
- });
145
- } else if (linker === "node-modules") {
146
- results.push({
147
- name: "Yarn linker",
148
- status: "pass",
149
- message: "Yarn Berry with node-modules linker"
150
- });
151
- } else if (linker === "pnpm") {
152
- results.push({
153
- name: "Yarn linker",
154
- status: "pass",
155
- message: "Yarn pnpm linker mode (plunk handles this)"
156
- });
157
- } else if (linker === "pnp") {
158
- results.push({
159
- name: "Yarn linker",
160
- status: "fail",
161
- message: "Yarn PnP is not compatible. Set `nodeLinker: node-modules` in .yarnrc.yml"
162
- });
163
- } else {
164
- results.push({
165
- name: "Yarn linker",
166
- status: "warn",
167
- message: "Yarn Berry defaults to PnP. Add `nodeLinker: node-modules` to .yarnrc.yml"
168
- });
169
- }
170
- }
171
- const bundler = await detectBundler(consumerPath);
172
- if (bundler.type) {
173
- results.push({
174
- name: "Bundler",
175
- status: "pass",
176
- message: `${bundler.type}${bundler.configFile ? ` (${bundler.configFile})` : ""}`
177
- });
178
- } else {
179
- results.push({
180
- name: "Bundler",
181
- status: "warn",
182
- message: "No bundler config detected"
183
- });
184
- }
185
- const gitignorePath = join(consumerPath, ".gitignore");
186
- if (await exists(gitignorePath)) {
187
- const { readFile } = await import("fs/promises");
188
- const content = await readFile(gitignorePath, "utf-8");
189
- if (content.includes(".plunk")) {
190
- results.push({
191
- name: ".gitignore",
192
- status: "pass",
193
- message: ".plunk/ is ignored"
194
- });
195
- } else {
196
- results.push({
197
- name: ".gitignore",
198
- status: "warn",
199
- message: ".plunk/ not in .gitignore. Run 'plunk init' to fix."
200
- });
201
- }
202
- }
203
- const icons = {
204
- pass: import_picocolors.default.green("PASS"),
205
- fail: import_picocolors.default.red("FAIL"),
206
- warn: import_picocolors.default.yellow("WARN")
207
- };
208
- for (const r of results) {
209
- console.log(` ${icons[r.status]} ${r.name}: ${import_picocolors.default.dim(r.message)}`);
210
- }
211
- const failCount = results.filter((r) => r.status === "fail").length;
212
- const warnCount = results.filter((r) => r.status === "warn").length;
213
- console.log("");
214
- if (failCount > 0) {
215
- consola.error(`${failCount} issue(s) found that need attention`);
216
- } else if (warnCount > 0) {
217
- consola.warn(`${warnCount} warning(s), but no critical issues`);
218
- } else {
219
- consola.success("All checks passed!");
220
- }
221
- output({
222
- results: results.map(({ name, status, message }) => ({ name, status, message })),
223
- failures: failCount,
224
- warnings: warnCount
225
- });
226
- }
227
- });
228
- export {
229
- doctor_default as default
230
- };
@@ -1,65 +0,0 @@
1
- import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
2
-
3
- // src/utils/hash-worker.ts
4
- import { readFile } from "fs/promises";
5
- import { createHash } from "crypto";
6
- import { createReadStream } from "fs";
7
-
8
- // node_modules/.pnpm/xxhash-wasm@1.1.0/node_modules/xxhash-wasm/esm/xxhash-wasm.js
9
- var t = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 48, 8, 96, 3, 127, 127, 127, 1, 127, 96, 3, 127, 127, 127, 0, 96, 2, 127, 127, 0, 96, 1, 127, 1, 127, 96, 3, 127, 127, 126, 1, 126, 96, 3, 126, 127, 127, 1, 126, 96, 2, 127, 126, 0, 96, 1, 127, 1, 126, 3, 11, 10, 0, 0, 2, 1, 3, 4, 5, 6, 1, 7, 5, 3, 1, 0, 1, 7, 85, 9, 3, 109, 101, 109, 2, 0, 5, 120, 120, 104, 51, 50, 0, 0, 6, 105, 110, 105, 116, 51, 50, 0, 2, 8, 117, 112, 100, 97, 116, 101, 51, 50, 0, 3, 8, 100, 105, 103, 101, 115, 116, 51, 50, 0, 4, 5, 120, 120, 104, 54, 52, 0, 5, 6, 105, 110, 105, 116, 54, 52, 0, 7, 8, 117, 112, 100, 97, 116, 101, 54, 52, 0, 8, 8, 100, 105, 103, 101, 115, 116, 54, 52, 0, 9, 10, 251, 22, 10, 242, 1, 1, 4, 127, 32, 0, 32, 1, 106, 33, 3, 32, 1, 65, 16, 79, 4, 127, 32, 3, 65, 16, 107, 33, 6, 32, 2, 65, 168, 136, 141, 161, 2, 106, 33, 3, 32, 2, 65, 137, 235, 208, 208, 7, 107, 33, 4, 32, 2, 65, 207, 140, 162, 142, 6, 106, 33, 5, 3, 64, 32, 3, 32, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 3, 32, 4, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 4, 32, 2, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 2, 32, 5, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 5, 32, 6, 32, 0, 65, 4, 106, 34, 0, 79, 13, 0, 11, 32, 2, 65, 12, 119, 32, 5, 65, 18, 119, 106, 32, 4, 65, 7, 119, 106, 32, 3, 65, 1, 119, 106, 5, 32, 2, 65, 177, 207, 217, 178, 1, 106, 11, 32, 1, 106, 32, 0, 32, 1, 65, 15, 113, 16, 1, 11, 146, 1, 0, 32, 1, 32, 2, 106, 33, 2, 3, 64, 32, 1, 65, 4, 106, 32, 2, 75, 69, 4, 64, 32, 0, 32, 1, 40, 2, 0, 65, 189, 220, 202, 149, 124, 108, 106, 65, 17, 119, 65, 175, 214, 211, 190, 2, 108, 33, 0, 32, 1, 65, 4, 106, 33, 1, 12, 1, 11, 11, 3, 64, 32, 1, 32, 2, 79, 69, 4, 64, 32, 0, 32, 1, 45, 0, 0, 65, 177, 207, 217, 178, 1, 108, 106, 65, 11, 119, 65, 177, 243, 221, 241, 121, 108, 33, 0, 32, 1, 65, 1, 106, 33, 1, 12, 1, 11, 11, 32, 0, 32, 0, 65, 15, 118, 115, 65, 247, 148, 175, 175, 120, 108, 34, 0, 65, 13, 118, 32, 0, 115, 65, 189, 220, 202, 149, 124, 108, 34, 0, 65, 16, 118, 32, 0, 115, 11, 63, 0, 32, 0, 65, 8, 106, 32, 1, 65, 168, 136, 141, 161, 2, 106, 54, 2, 0, 32, 0, 65, 12, 106, 32, 1, 65, 137, 235, 208, 208, 7, 107, 54, 2, 0, 32, 0, 65, 16, 106, 32, 1, 54, 2, 0, 32, 0, 65, 20, 106, 32, 1, 65, 207, 140, 162, 142, 6, 106, 54, 2, 0, 11, 195, 4, 1, 6, 127, 32, 1, 32, 2, 106, 33, 6, 32, 0, 65, 24, 106, 33, 4, 32, 0, 65, 40, 106, 40, 2, 0, 33, 3, 32, 0, 32, 0, 40, 2, 0, 32, 2, 106, 54, 2, 0, 32, 0, 65, 4, 106, 34, 5, 32, 5, 40, 2, 0, 32, 2, 65, 16, 79, 32, 0, 40, 2, 0, 65, 16, 79, 114, 114, 54, 2, 0, 32, 2, 32, 3, 106, 65, 16, 73, 4, 64, 32, 3, 32, 4, 106, 32, 1, 32, 2, 252, 10, 0, 0, 32, 0, 65, 40, 106, 32, 2, 32, 3, 106, 54, 2, 0, 15, 11, 32, 3, 4, 64, 32, 3, 32, 4, 106, 32, 1, 65, 16, 32, 3, 107, 34, 2, 252, 10, 0, 0, 32, 0, 65, 8, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 12, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 4, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 16, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 8, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 20, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 12, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 40, 106, 65, 0, 54, 2, 0, 32, 1, 32, 2, 106, 33, 1, 11, 32, 1, 32, 6, 65, 16, 107, 77, 4, 64, 32, 6, 65, 16, 107, 33, 8, 32, 0, 65, 8, 106, 40, 2, 0, 33, 2, 32, 0, 65, 12, 106, 40, 2, 0, 33, 3, 32, 0, 65, 16, 106, 40, 2, 0, 33, 5, 32, 0, 65, 20, 106, 40, 2, 0, 33, 7, 3, 64, 32, 2, 32, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 2, 32, 3, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 3, 32, 5, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 5, 32, 7, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 7, 32, 8, 32, 1, 65, 4, 106, 34, 1, 79, 13, 0, 11, 32, 0, 65, 8, 106, 32, 2, 54, 2, 0, 32, 0, 65, 12, 106, 32, 3, 54, 2, 0, 32, 0, 65, 16, 106, 32, 5, 54, 2, 0, 32, 0, 65, 20, 106, 32, 7, 54, 2, 0, 11, 32, 1, 32, 6, 73, 4, 64, 32, 4, 32, 1, 32, 6, 32, 1, 107, 34, 1, 252, 10, 0, 0, 32, 0, 65, 40, 106, 32, 1, 54, 2, 0, 11, 11, 97, 1, 1, 127, 32, 0, 65, 16, 106, 40, 2, 0, 33, 1, 32, 0, 65, 4, 106, 40, 2, 0, 4, 127, 32, 1, 65, 12, 119, 32, 0, 65, 20, 106, 40, 2, 0, 65, 18, 119, 106, 32, 0, 65, 12, 106, 40, 2, 0, 65, 7, 119, 106, 32, 0, 65, 8, 106, 40, 2, 0, 65, 1, 119, 106, 5, 32, 1, 65, 177, 207, 217, 178, 1, 106, 11, 32, 0, 40, 2, 0, 106, 32, 0, 65, 24, 106, 32, 0, 65, 40, 106, 40, 2, 0, 16, 1, 11, 255, 3, 2, 3, 126, 1, 127, 32, 0, 32, 1, 106, 33, 6, 32, 1, 65, 32, 79, 4, 126, 32, 6, 65, 32, 107, 33, 6, 32, 2, 66, 214, 235, 130, 238, 234, 253, 137, 245, 224, 0, 124, 33, 3, 32, 2, 66, 177, 169, 172, 193, 173, 184, 212, 166, 61, 125, 33, 4, 32, 2, 66, 249, 234, 208, 208, 231, 201, 161, 228, 225, 0, 124, 33, 5, 3, 64, 32, 3, 32, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 3, 32, 4, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 4, 32, 2, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 2, 32, 5, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 5, 32, 6, 32, 0, 65, 8, 106, 34, 0, 79, 13, 0, 11, 32, 2, 66, 12, 137, 32, 5, 66, 18, 137, 124, 32, 4, 66, 7, 137, 124, 32, 3, 66, 1, 137, 124, 32, 3, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 4, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 2, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 5, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 5, 32, 2, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 124, 11, 32, 1, 173, 124, 32, 0, 32, 1, 65, 31, 113, 16, 6, 11, 134, 2, 0, 32, 1, 32, 2, 106, 33, 2, 3, 64, 32, 2, 32, 1, 65, 8, 106, 79, 4, 64, 32, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 32, 0, 133, 66, 27, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 33, 0, 32, 1, 65, 8, 106, 33, 1, 12, 1, 11, 11, 32, 1, 65, 4, 106, 32, 2, 77, 4, 64, 32, 0, 32, 1, 53, 2, 0, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 23, 137, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 249, 243, 221, 241, 153, 246, 153, 171, 22, 124, 33, 0, 32, 1, 65, 4, 106, 33, 1, 11, 3, 64, 32, 1, 32, 2, 73, 4, 64, 32, 0, 32, 1, 49, 0, 0, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 126, 133, 66, 11, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 0, 32, 1, 65, 1, 106, 33, 1, 12, 1, 11, 11, 32, 0, 32, 0, 66, 33, 136, 133, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 34, 0, 32, 0, 66, 29, 136, 133, 66, 249, 243, 221, 241, 153, 246, 153, 171, 22, 126, 34, 0, 32, 0, 66, 32, 136, 133, 11, 77, 0, 32, 0, 65, 8, 106, 32, 1, 66, 214, 235, 130, 238, 234, 253, 137, 245, 224, 0, 124, 55, 3, 0, 32, 0, 65, 16, 106, 32, 1, 66, 177, 169, 172, 193, 173, 184, 212, 166, 61, 125, 55, 3, 0, 32, 0, 65, 24, 106, 32, 1, 55, 3, 0, 32, 0, 65, 32, 106, 32, 1, 66, 249, 234, 208, 208, 231, 201, 161, 228, 225, 0, 124, 55, 3, 0, 11, 244, 4, 2, 3, 127, 4, 126, 32, 1, 32, 2, 106, 33, 5, 32, 0, 65, 40, 106, 33, 4, 32, 0, 65, 200, 0, 106, 40, 2, 0, 33, 3, 32, 0, 32, 0, 41, 3, 0, 32, 2, 173, 124, 55, 3, 0, 32, 2, 32, 3, 106, 65, 32, 73, 4, 64, 32, 3, 32, 4, 106, 32, 1, 32, 2, 252, 10, 0, 0, 32, 0, 65, 200, 0, 106, 32, 2, 32, 3, 106, 54, 2, 0, 15, 11, 32, 3, 4, 64, 32, 3, 32, 4, 106, 32, 1, 65, 32, 32, 3, 107, 34, 2, 252, 10, 0, 0, 32, 0, 65, 8, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 16, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 8, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 24, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 16, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 32, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 24, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 200, 0, 106, 65, 0, 54, 2, 0, 32, 1, 32, 2, 106, 33, 1, 11, 32, 1, 65, 32, 106, 32, 5, 77, 4, 64, 32, 5, 65, 32, 107, 33, 2, 32, 0, 65, 8, 106, 41, 3, 0, 33, 6, 32, 0, 65, 16, 106, 41, 3, 0, 33, 7, 32, 0, 65, 24, 106, 41, 3, 0, 33, 8, 32, 0, 65, 32, 106, 41, 3, 0, 33, 9, 3, 64, 32, 6, 32, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 6, 32, 7, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 7, 32, 8, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 8, 32, 9, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 9, 32, 2, 32, 1, 65, 8, 106, 34, 1, 79, 13, 0, 11, 32, 0, 65, 8, 106, 32, 6, 55, 3, 0, 32, 0, 65, 16, 106, 32, 7, 55, 3, 0, 32, 0, 65, 24, 106, 32, 8, 55, 3, 0, 32, 0, 65, 32, 106, 32, 9, 55, 3, 0, 11, 32, 1, 32, 5, 73, 4, 64, 32, 4, 32, 1, 32, 5, 32, 1, 107, 34, 1, 252, 10, 0, 0, 32, 0, 65, 200, 0, 106, 32, 1, 54, 2, 0, 11, 11, 188, 2, 1, 5, 126, 32, 0, 65, 24, 106, 41, 3, 0, 33, 1, 32, 0, 41, 3, 0, 34, 2, 66, 32, 90, 4, 126, 32, 0, 65, 8, 106, 41, 3, 0, 34, 3, 66, 1, 137, 32, 0, 65, 16, 106, 41, 3, 0, 34, 4, 66, 7, 137, 124, 32, 1, 66, 12, 137, 32, 0, 65, 32, 106, 41, 3, 0, 34, 5, 66, 18, 137, 124, 124, 32, 3, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 4, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 1, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 5, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 5, 32, 1, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 124, 11, 32, 2, 124, 32, 0, 65, 40, 106, 32, 2, 66, 31, 131, 167, 16, 6, 11]);
10
- async function e() {
11
- return (function(t2) {
12
- const { exports: { mem: e2, xxh32: n, xxh64: r, init32: i, update32: a, digest32: o, init64: s, update64: u, digest64: c } } = t2;
13
- let h = new Uint8Array(e2.buffer);
14
- function g(t3, n2) {
15
- if (e2.buffer.byteLength < t3 + n2) {
16
- const r2 = Math.ceil((t3 + n2 - e2.buffer.byteLength) / 65536);
17
- e2.grow(r2), h = new Uint8Array(e2.buffer);
18
- }
19
- }
20
- function f(t3, e3, n2, r2, i2, a2) {
21
- g(t3);
22
- const o2 = new Uint8Array(t3);
23
- return h.set(o2), n2(0, e3), o2.set(h.subarray(0, t3)), { update(e4) {
24
- let n3;
25
- return h.set(o2), "string" == typeof e4 ? (g(3 * e4.length, t3), n3 = w.encodeInto(e4, h.subarray(t3)).written) : (g(e4.byteLength, t3), h.set(e4, t3), n3 = e4.byteLength), r2(0, t3, n3), o2.set(h.subarray(0, t3)), this;
26
- }, digest: () => (h.set(o2), a2(i2(0))) };
27
- }
28
- function y(t3) {
29
- return t3 >>> 0;
30
- }
31
- const b = 2n ** 64n - 1n;
32
- function d(t3) {
33
- return t3 & b;
34
- }
35
- const w = new TextEncoder(), l = 0, p = 0n;
36
- function x(t3, e3 = l) {
37
- return g(3 * t3.length, 0), y(n(0, w.encodeInto(t3, h).written, e3));
38
- }
39
- function L(t3, e3 = p) {
40
- return g(3 * t3.length, 0), d(r(0, w.encodeInto(t3, h).written, e3));
41
- }
42
- return { h32: x, h32ToString: (t3, e3 = l) => x(t3, e3).toString(16).padStart(8, "0"), h32Raw: (t3, e3 = l) => (g(t3.byteLength, 0), h.set(t3), y(n(0, t3.byteLength, e3))), create32: (t3 = l) => f(48, t3, i, a, o, y), h64: L, h64ToString: (t3, e3 = p) => L(t3, e3).toString(16).padStart(16, "0"), h64Raw: (t3, e3 = p) => (g(t3.byteLength, 0), h.set(t3), d(r(0, t3.byteLength, e3))), create64: (t3 = p) => f(88, t3, s, u, c, d) };
43
- })((await WebAssembly.instantiate(t)).instance);
44
- }
45
-
46
- // src/utils/hash-worker.ts
47
- var STREAM_THRESHOLD = 1024 * 1024;
48
- var xxhReady = e();
49
- async function hashFileWorker(filePath, size) {
50
- if (size > STREAM_THRESHOLD) {
51
- return new Promise((resolve, reject) => {
52
- const hash = createHash("sha256");
53
- const stream = createReadStream(filePath);
54
- stream.on("data", (chunk) => hash.update(chunk));
55
- stream.on("end", () => resolve(hash.digest("hex")));
56
- stream.on("error", reject);
57
- });
58
- }
59
- const { h64Raw } = await xxhReady;
60
- const content = await readFile(filePath);
61
- return h64Raw(content).toString(16);
62
- }
63
- export {
64
- hashFileWorker as default
65
- };
@@ -1,310 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
- import {
4
- addPostinstall,
5
- ensureGitignore
6
- } from "./chunk-ZQCGJUBJ.mjs";
7
- import {
8
- detectBuildCommand
9
- } from "./chunk-XMIZ7OUZ.mjs";
10
- import {
11
- detectBundler,
12
- detectPackageManager
13
- } from "./chunk-34UXZ622.mjs";
14
- import {
15
- readConsumerState,
16
- writeConsumerState
17
- } from "./chunk-GAAB2TLH.mjs";
18
- import {
19
- Timer
20
- } from "./chunk-XZK5T4GK.mjs";
21
- import {
22
- require_picocolors
23
- } from "./chunk-PUSXMPOF.mjs";
24
- import "./chunk-EDUXIQ5W.mjs";
25
- import {
26
- output,
27
- suppressHumanOutput
28
- } from "./chunk-ZOYNYK5Y.mjs";
29
- import {
30
- defineCommand
31
- } from "./chunk-CSMZ6DZA.mjs";
32
- import {
33
- ensureDir,
34
- exists
35
- } from "./chunk-HKNM3UWU.mjs";
36
- import {
37
- consola
38
- } from "./chunk-I6SN7BBN.mjs";
39
- import {
40
- __toESM
41
- } from "./chunk-KYDBD2KQ.mjs";
42
-
43
- // src/commands/init.ts
44
- import { resolve, join, basename } from "path";
45
- import { readFile, writeFile } from "fs/promises";
46
- var import_picocolors = __toESM(require_picocolors(), 1);
47
- var init_default = defineCommand({
48
- meta: {
49
- name: "init",
50
- description: "Set up plunk in the current project"
51
- },
52
- args: {
53
- yes: {
54
- type: "boolean",
55
- alias: "y",
56
- description: "Skip confirmation prompts",
57
- default: false
58
- },
59
- role: {
60
- type: "string",
61
- description: 'Project role: "consumer" or "library"'
62
- }
63
- },
64
- async run({ args }) {
65
- suppressHumanOutput();
66
- const timer = new Timer();
67
- const projectDir = resolve(".");
68
- const skipPrompts = args.yes;
69
- consola.info(`Initializing plunk in ${import_picocolors.default.cyan(projectDir)}
70
- `);
71
- const detectedPm = await detectPackageManager(projectDir);
72
- const lockfileNames = {
73
- pnpm: "pnpm-lock.yaml",
74
- bun: "bun.lockb",
75
- yarn: "yarn.lock",
76
- npm: "package-lock.json"
77
- };
78
- consola.success(
79
- `Detected package manager: ${import_picocolors.default.cyan(detectedPm)}` + (lockfileNames[detectedPm] ? ` (from ${lockfileNames[detectedPm]})` : "")
80
- );
81
- let pm = detectedPm;
82
- if (!skipPrompts) {
83
- const confirm = await consola.prompt(`Use ${detectedPm}?`, {
84
- type: "confirm",
85
- initial: true
86
- });
87
- if (confirm === false) {
88
- const choices = ["npm", "pnpm", "yarn", "bun"].filter(
89
- (p) => p !== detectedPm
90
- );
91
- const selected = await consola.prompt("Select package manager:", {
92
- type: "select",
93
- options: choices.map((p) => ({ label: p, value: p }))
94
- });
95
- if (typeof selected === "string") {
96
- pm = selected;
97
- }
98
- }
99
- }
100
- let role = "consumer";
101
- if (args.role === "consumer" || args.role === "library") {
102
- role = args.role;
103
- } else if (!skipPrompts) {
104
- const selected = await consola.prompt(
105
- "How will you use plunk in this project?",
106
- {
107
- type: "select",
108
- options: [
109
- {
110
- label: "Consumer (app) \u2014 I want to link packages INTO this project",
111
- value: "consumer"
112
- },
113
- {
114
- label: "Library (package) \u2014 I want to publish this package FOR other projects",
115
- value: "library"
116
- }
117
- ]
118
- }
119
- );
120
- if (selected === "library") {
121
- role = "library";
122
- }
123
- }
124
- consola.success(`Project role: ${import_picocolors.default.cyan(role)}`);
125
- const gitignorePath = join(projectDir, ".gitignore");
126
- const gitignoreUpdated = await ensureGitignore(gitignorePath);
127
- if (gitignoreUpdated) {
128
- consola.success("Added .plunk/ to .gitignore");
129
- }
130
- const pkgPath = join(projectDir, "package.json");
131
- let libraryBuildCmd;
132
- if (await exists(pkgPath)) {
133
- if (role === "consumer") {
134
- const postinstallAdded = await addPostinstall(pkgPath);
135
- if (postinstallAdded) {
136
- consola.success(
137
- 'Added "postinstall": "plunk restore" to package.json scripts'
138
- );
139
- }
140
- let packageName = "{package-name}";
141
- if (!skipPrompts) {
142
- const input = await consola.prompt(
143
- "Package name to link (leave blank to skip):",
144
- { type: "text", default: "" }
145
- );
146
- if (typeof input === "string" && input.trim()) {
147
- packageName = input.trim();
148
- }
149
- }
150
- const addScriptAdded = await addScript(
151
- pkgPath,
152
- "plunk:add",
153
- `plunk add ${packageName}`
154
- );
155
- if (addScriptAdded) {
156
- consola.success(
157
- `Added "plunk:add": "plunk add ${packageName}" to package.json scripts`
158
- );
159
- }
160
- } else {
161
- libraryBuildCmd = await detectBuildCommand2(pkgPath, pm, skipPrompts);
162
- const added = await addLibraryScripts(pkgPath);
163
- for (const name of added) {
164
- consola.success(`Added "${name}" script to package.json`);
165
- }
166
- }
167
- }
168
- const plunkDir = join(projectDir, ".plunk");
169
- if (!await exists(plunkDir)) {
170
- await ensureDir(plunkDir);
171
- await writeFile(
172
- join(plunkDir, "state.json"),
173
- JSON.stringify(
174
- { version: "1", packageManager: pm, role, links: {} },
175
- null,
176
- 2
177
- )
178
- );
179
- consola.success("Created .plunk/ state directory");
180
- } else {
181
- const state = await readConsumerState(projectDir);
182
- state.packageManager = pm;
183
- state.role = role;
184
- await writeConsumerState(projectDir, state);
185
- }
186
- if (role === "consumer") {
187
- const bundler = await detectBundler(projectDir);
188
- if (bundler.type === "vite" && bundler.configFile) {
189
- consola.success(
190
- `Detected bundler: ${import_picocolors.default.cyan("Vite")} (${basename(bundler.configFile)})`
191
- );
192
- const { addPlunkVitePlugin } = await import("./vite-config-BAK67JHB.mjs");
193
- const viteResult = await addPlunkVitePlugin(bundler.configFile);
194
- if (viteResult.modified) {
195
- consola.success(`Added plunk plugin to ${basename(bundler.configFile)}`);
196
- } else if (viteResult.error) {
197
- consola.info(
198
- `Add the Vite plugin for automatic dev server restarts:
199
- ${import_picocolors.default.cyan('import plunk from "@olegkuibar/plunk/vite"')}
200
- ${import_picocolors.default.cyan("plugins: [plunk()]")}`
201
- );
202
- }
203
- } else if (bundler.type === "next" && bundler.configFile) {
204
- consola.success(
205
- `Detected bundler: ${import_picocolors.default.cyan("Next.js")} (${basename(bundler.configFile)})`
206
- );
207
- consola.info(
208
- `Next.js transpilePackages will be auto-configured when you run ${import_picocolors.default.cyan("plunk add")}`
209
- );
210
- } else if (bundler.type) {
211
- const names = {
212
- webpack: "Webpack",
213
- turbo: "Turbopack",
214
- rollup: "Rollup"
215
- };
216
- consola.success(
217
- `Detected bundler: ${import_picocolors.default.cyan(names[bundler.type] || bundler.type)} \u2014 no config needed, works out of the box`
218
- );
219
- }
220
- console.log("");
221
- consola.info(`${import_picocolors.default.bold("Next steps:")}`);
222
- console.log(
223
- ` 1. ${import_picocolors.default.cyan("cd ../my-lib && plunk publish")}`
224
- );
225
- console.log(
226
- ` 2. ${import_picocolors.default.cyan("plunk add my-lib")}${bundler.type === "vite" ? " \u2190 auto-updates vite config" : bundler.type === "next" ? " \u2190 auto-updates next config" : ""}`
227
- );
228
- console.log(
229
- ` 3. ${import_picocolors.default.cyan("cd ../my-lib && plunk dev")} \u2190 watch + rebuild + auto-push`
230
- );
231
- } else {
232
- console.log("");
233
- consola.info(`${import_picocolors.default.bold("Next steps:")}`);
234
- console.log(
235
- ` 1. ${import_picocolors.default.cyan("plunk publish")} \u2190 copy built files to plunk store`
236
- );
237
- console.log(
238
- ` 2. ${import_picocolors.default.cyan(`${pm} run plunk:dev`)} \u2190 watch + rebuild + auto-push to consumers`
239
- );
240
- console.log(
241
- ` 3. In consumer project: ${import_picocolors.default.cyan("plunk add " + await readPkgName(pkgPath))}`
242
- );
243
- }
244
- consola.info(`Done in ${timer.elapsed()}`);
245
- output({
246
- packageManager: pm,
247
- role,
248
- elapsed: timer.elapsedMs()
249
- });
250
- }
251
- });
252
- async function addScript(pkgPath, name, command) {
253
- const content = await readFile(pkgPath, "utf-8");
254
- const pkg = JSON.parse(content);
255
- if (pkg.scripts?.[name]) return false;
256
- if (!pkg.scripts) pkg.scripts = {};
257
- pkg.scripts[name] = command;
258
- const indent = content.match(/^(\s+)"/m)?.[1] || " ";
259
- await writeFile(pkgPath, JSON.stringify(pkg, null, indent) + "\n");
260
- return true;
261
- }
262
- async function detectBuildCommand2(pkgPath, pm, skipPrompts) {
263
- const packageDir = join(pkgPath, "..");
264
- const detected = await detectBuildCommand(packageDir, pm);
265
- if (detected) {
266
- consola.success(`Detected build script: ${import_picocolors.default.cyan(detected)}`);
267
- return detected;
268
- }
269
- const runPrefix = pm === "npm" ? "npm run " : `${pm} `;
270
- if (!skipPrompts) {
271
- consola.warn("No build script found in package.json");
272
- const input = await consola.prompt(
273
- "Build command (e.g. tsc, tsup, rollup -c):",
274
- { type: "text", default: "" }
275
- );
276
- if (typeof input === "string" && input.trim()) {
277
- return input.trim();
278
- }
279
- }
280
- const fallback = `${runPrefix}build`;
281
- consola.warn(
282
- `Using ${import_picocolors.default.cyan(fallback)} as placeholder \u2014 add a "build" script to package.json`
283
- );
284
- return fallback;
285
- }
286
- async function addLibraryScripts(pkgPath) {
287
- const added = [];
288
- if (await addScript(pkgPath, "plunk:publish", "plunk publish")) {
289
- added.push("plunk:publish");
290
- }
291
- if (await addScript(
292
- pkgPath,
293
- "plunk:dev",
294
- "plunk dev"
295
- )) {
296
- added.push("plunk:dev");
297
- }
298
- return added;
299
- }
300
- async function readPkgName(pkgPath) {
301
- try {
302
- const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
303
- return pkg.name || "my-package";
304
- } catch {
305
- return "my-package";
306
- }
307
- }
308
- export {
309
- init_default as default
310
- };