@olegkuibar/plunk 0.2.0-canary.04ff96f

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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/dist/add-5ZRFUL6Z.mjs +258 -0
  4. package/dist/chokidar-XGAEDN45.mjs +1746 -0
  5. package/dist/chunk-34UXZ622.mjs +98 -0
  6. package/dist/chunk-4O2QOKVO.mjs +1958 -0
  7. package/dist/chunk-CSMZ6DZA.mjs +367 -0
  8. package/dist/chunk-CZM4TNAI.mjs +292 -0
  9. package/dist/chunk-EDUXIQ5W.mjs +1729 -0
  10. package/dist/chunk-GAAB2TLH.mjs +160 -0
  11. package/dist/chunk-HKNM3UWU.mjs +496 -0
  12. package/dist/chunk-I6SN7BBN.mjs +1131 -0
  13. package/dist/chunk-KYDBD2KQ.mjs +39 -0
  14. package/dist/chunk-LKQINKH4.mjs +130 -0
  15. package/dist/chunk-PUSXMPOF.mjs +82 -0
  16. package/dist/chunk-S4HJSJ32.mjs +69 -0
  17. package/dist/chunk-W3C72UKC.mjs +113 -0
  18. package/dist/chunk-WSECI6M7.mjs +85 -0
  19. package/dist/chunk-XMIZ7OUZ.mjs +26 -0
  20. package/dist/chunk-XZK5T4GK.mjs +23 -0
  21. package/dist/chunk-ZOYNYK5Y.mjs +23 -0
  22. package/dist/chunk-ZQCGJUBJ.mjs +92 -0
  23. package/dist/clean-LTR5MZTY.mjs +84 -0
  24. package/dist/cli.mjs +57 -0
  25. package/dist/dev-LFXQP6SA.mjs +194 -0
  26. package/dist/dist-DUFCZSIL.mjs +813 -0
  27. package/dist/doctor-R7ZVR7PY.mjs +230 -0
  28. package/dist/hash-worker.mjs +65 -0
  29. package/dist/index.d.ts +194 -0
  30. package/dist/index.mjs +9486 -0
  31. package/dist/init-SWCNRISY.mjs +310 -0
  32. package/dist/list-B77L2F34.mjs +119 -0
  33. package/dist/migrate-X5TIC5SS.mjs +124 -0
  34. package/dist/prompt-HTPH6HQ7.mjs +756 -0
  35. package/dist/publish-UXCLPNM6.mjs +63 -0
  36. package/dist/push-JI6HGCFG.mjs +197 -0
  37. package/dist/remove-DCR7KKD5.mjs +149 -0
  38. package/dist/restore-SUN3WGSW.mjs +124 -0
  39. package/dist/status-MESRBH54.mjs +103 -0
  40. package/dist/tailwind-source-JBBEIXIJ.mjs +89 -0
  41. package/dist/update-SKDSA673.mjs +100 -0
  42. package/dist/vite-config-BAK67JHB.mjs +128 -0
  43. package/dist/vite-plugin.d.ts +5 -0
  44. package/dist/vite-plugin.mjs +42 -0
  45. package/dist/workspace-76HJPAK2.mjs +97 -0
  46. package/package.json +96 -0
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ import {
4
+ cleanStaleConsumers,
5
+ readConsumerState,
6
+ readConsumersRegistry
7
+ } from "./chunk-GAAB2TLH.mjs";
8
+ import {
9
+ listStoreEntries,
10
+ removeStoreEntry
11
+ } from "./chunk-W3C72UKC.mjs";
12
+ import {
13
+ Timer
14
+ } from "./chunk-XZK5T4GK.mjs";
15
+ import "./chunk-EDUXIQ5W.mjs";
16
+ import {
17
+ output,
18
+ suppressHumanOutput
19
+ } from "./chunk-ZOYNYK5Y.mjs";
20
+ import {
21
+ defineCommand
22
+ } from "./chunk-CSMZ6DZA.mjs";
23
+ import "./chunk-HKNM3UWU.mjs";
24
+ import {
25
+ consola,
26
+ verbose
27
+ } from "./chunk-I6SN7BBN.mjs";
28
+ import "./chunk-KYDBD2KQ.mjs";
29
+
30
+ // src/commands/clean.ts
31
+ var clean_default = defineCommand({
32
+ meta: {
33
+ name: "clean",
34
+ description: "Remove unreferenced store entries and stale consumer registrations"
35
+ },
36
+ async run() {
37
+ suppressHumanOutput();
38
+ const timer = new Timer();
39
+ consola.start("Checking consumer registrations...");
40
+ const { removedConsumers, removedPackages } = await cleanStaleConsumers();
41
+ if (removedConsumers > 0) {
42
+ consola.success(
43
+ `Removed ${removedConsumers} stale consumer registration(s) across ${removedPackages} package(s)`
44
+ );
45
+ }
46
+ const registry = await readConsumersRegistry();
47
+ const referenced = /* @__PURE__ */ new Set();
48
+ for (const [, consumers] of Object.entries(registry)) {
49
+ for (const consumerPath of consumers) {
50
+ const state = await readConsumerState(consumerPath);
51
+ for (const [pkgName, link] of Object.entries(state.links)) {
52
+ referenced.add(`${pkgName}@${link.version}`);
53
+ }
54
+ }
55
+ }
56
+ verbose(`[clean] Referenced entries: ${[...referenced].join(", ") || "(none)"}`);
57
+ const storeEntries = await listStoreEntries();
58
+ let removedEntries = 0;
59
+ for (const entry of storeEntries) {
60
+ const key = `${entry.name}@${entry.version}`;
61
+ if (!referenced.has(key)) {
62
+ verbose(`[clean] Removing unreferenced store entry: ${key}`);
63
+ await removeStoreEntry(entry.name, entry.version);
64
+ removedEntries++;
65
+ }
66
+ }
67
+ if (removedEntries > 0) {
68
+ consola.success(`Removed ${removedEntries} unreferenced store entry(ies)`);
69
+ }
70
+ if (removedConsumers === 0 && removedEntries === 0) {
71
+ consola.info("Nothing to clean up");
72
+ }
73
+ consola.info(`Clean complete in ${timer.elapsed()}`);
74
+ output({
75
+ removedConsumers,
76
+ removedPackages,
77
+ removedEntries,
78
+ elapsed: timer.elapsedMs()
79
+ });
80
+ }
81
+ });
82
+ export {
83
+ clean_default as default
84
+ };
package/dist/cli.mjs ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ import {
4
+ defineCommand,
5
+ runMain
6
+ } from "./chunk-CSMZ6DZA.mjs";
7
+ import {
8
+ initFlags
9
+ } from "./chunk-I6SN7BBN.mjs";
10
+ import "./chunk-KYDBD2KQ.mjs";
11
+
12
+ // src/cli.ts
13
+ import { availableParallelism } from "os";
14
+ process.env.UV_THREADPOOL_SIZE ??= String(Math.max(availableParallelism(), 8));
15
+ initFlags();
16
+ var main = defineCommand({
17
+ meta: {
18
+ name: "plunk",
19
+ version: "0.1.0",
20
+ description: "Modern local package development tool. Smart file copying for node_modules injection."
21
+ },
22
+ args: {
23
+ verbose: {
24
+ type: "boolean",
25
+ alias: "v",
26
+ description: "Enable verbose debug logging",
27
+ default: false
28
+ },
29
+ "dry-run": {
30
+ type: "boolean",
31
+ description: "Preview changes without writing files",
32
+ default: false
33
+ },
34
+ json: {
35
+ type: "boolean",
36
+ description: "Output machine-readable JSON",
37
+ default: false
38
+ }
39
+ },
40
+ subCommands: {
41
+ init: () => import("./init-SWCNRISY.mjs").then((m) => m.default),
42
+ publish: () => import("./publish-UXCLPNM6.mjs").then((m) => m.default),
43
+ add: () => import("./add-5ZRFUL6Z.mjs").then((m) => m.default),
44
+ remove: () => import("./remove-DCR7KKD5.mjs").then((m) => m.default),
45
+ push: () => import("./push-JI6HGCFG.mjs").then((m) => m.default),
46
+ dev: () => import("./dev-LFXQP6SA.mjs").then((m) => m.default),
47
+ restore: () => import("./restore-SUN3WGSW.mjs").then((m) => m.default),
48
+ list: () => import("./list-B77L2F34.mjs").then((m) => m.default),
49
+ status: () => import("./status-MESRBH54.mjs").then((m) => m.default),
50
+ update: () => import("./update-SKDSA673.mjs").then((m) => m.default),
51
+ clean: () => import("./clean-LTR5MZTY.mjs").then((m) => m.default),
52
+ gc: () => import("./clean-LTR5MZTY.mjs").then((m) => m.default),
53
+ doctor: () => import("./doctor-R7ZVR7PY.mjs").then((m) => m.default),
54
+ migrate: () => import("./migrate-X5TIC5SS.mjs").then((m) => m.default)
55
+ }
56
+ });
57
+ runMain(main);
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ import {
4
+ startWatcher
5
+ } from "./chunk-LKQINKH4.mjs";
6
+ import {
7
+ inject
8
+ } from "./chunk-CZM4TNAI.mjs";
9
+ import {
10
+ detectBuildCommand
11
+ } from "./chunk-XMIZ7OUZ.mjs";
12
+ import {
13
+ detectPackageManager
14
+ } from "./chunk-34UXZ622.mjs";
15
+ import {
16
+ addLink,
17
+ getConsumers,
18
+ getLink
19
+ } from "./chunk-GAAB2TLH.mjs";
20
+ import {
21
+ publish
22
+ } from "./chunk-4O2QOKVO.mjs";
23
+ import {
24
+ errorWithSuggestion
25
+ } from "./chunk-S4HJSJ32.mjs";
26
+ import {
27
+ getStoreEntry
28
+ } from "./chunk-W3C72UKC.mjs";
29
+ import {
30
+ Timer
31
+ } from "./chunk-XZK5T4GK.mjs";
32
+ import "./chunk-PUSXMPOF.mjs";
33
+ import "./chunk-EDUXIQ5W.mjs";
34
+ import {
35
+ output,
36
+ suppressHumanOutput
37
+ } from "./chunk-ZOYNYK5Y.mjs";
38
+ import {
39
+ defineCommand
40
+ } from "./chunk-CSMZ6DZA.mjs";
41
+ import {
42
+ pLimit
43
+ } from "./chunk-HKNM3UWU.mjs";
44
+ import {
45
+ consola,
46
+ verbose
47
+ } from "./chunk-I6SN7BBN.mjs";
48
+ import "./chunk-KYDBD2KQ.mjs";
49
+
50
+ // src/commands/dev.ts
51
+ import { readFile } from "fs/promises";
52
+ import { resolve, join } from "path";
53
+ var consumerLimit = pLimit(4);
54
+ var dev_default = defineCommand({
55
+ meta: {
56
+ name: "dev",
57
+ description: "Watch, rebuild, and push to all consumers. Auto-detects build command."
58
+ },
59
+ args: {
60
+ build: {
61
+ type: "string",
62
+ description: "Override build command (default: auto-detect from package.json)"
63
+ },
64
+ "skip-build": {
65
+ type: "boolean",
66
+ description: "Watch output dirs directly, skip build command detection",
67
+ default: false
68
+ },
69
+ debounce: {
70
+ type: "string",
71
+ description: "Debounce delay in ms (default: 100)"
72
+ }
73
+ },
74
+ async run({ args }) {
75
+ suppressHumanOutput();
76
+ const packageDir = resolve(".");
77
+ const doPush = async () => {
78
+ const timer = new Timer();
79
+ const result = await publish(packageDir);
80
+ if (result.skipped) {
81
+ consola.info("No changes to push");
82
+ return;
83
+ }
84
+ const entry = await getStoreEntry(result.name, result.version);
85
+ if (!entry) {
86
+ errorWithSuggestion("Failed to read store entry after publish");
87
+ return;
88
+ }
89
+ const consumers = await getConsumers(result.name);
90
+ if (consumers.length === 0) {
91
+ consola.info(
92
+ "No consumers registered. Use 'plunk add' in a consumer project first."
93
+ );
94
+ return;
95
+ }
96
+ let totalCopied = 0;
97
+ let totalSkipped = 0;
98
+ let pushCount = 0;
99
+ const results = await Promise.all(
100
+ consumers.map(
101
+ (consumerPath) => consumerLimit(async () => {
102
+ const link = await getLink(consumerPath, result.name);
103
+ if (!link) {
104
+ verbose(
105
+ `[push] No link found for ${result.name} in ${consumerPath}, skipping`
106
+ );
107
+ return null;
108
+ }
109
+ try {
110
+ const injectResult = await inject(
111
+ entry,
112
+ consumerPath,
113
+ link.packageManager
114
+ );
115
+ if (injectResult.copied > 0 || injectResult.removed > 0) {
116
+ await addLink(consumerPath, result.name, {
117
+ ...link,
118
+ contentHash: entry.meta.contentHash,
119
+ linkedAt: (/* @__PURE__ */ new Date()).toISOString(),
120
+ buildId: entry.meta.buildId ?? ""
121
+ });
122
+ }
123
+ return injectResult;
124
+ } catch (err) {
125
+ consola.warn(`Failed to push to ${consumerPath}: ${err}`);
126
+ return null;
127
+ }
128
+ })
129
+ )
130
+ );
131
+ for (const r of results) {
132
+ if (r) {
133
+ totalCopied += r.copied;
134
+ totalSkipped += r.skipped;
135
+ pushCount++;
136
+ }
137
+ }
138
+ const buildTag = result.buildId ? ` [${result.buildId}]` : "";
139
+ consola.success(
140
+ `Pushed ${result.name}@${result.version}${buildTag} to ${pushCount} consumer(s) in ${timer.elapsed()} (${totalCopied} files changed, ${totalSkipped} unchanged)`
141
+ );
142
+ output({
143
+ name: result.name,
144
+ version: result.version,
145
+ buildId: result.buildId,
146
+ consumers: pushCount,
147
+ copied: totalCopied,
148
+ skipped: totalSkipped,
149
+ elapsed: timer.elapsedMs()
150
+ });
151
+ };
152
+ let buildCmd = args.build;
153
+ let patterns;
154
+ if (args.build) {
155
+ } else if (args["skip-build"]) {
156
+ } else {
157
+ const pm = await detectPackageManager(packageDir);
158
+ const detected = await detectBuildCommand(packageDir, pm);
159
+ if (detected) {
160
+ buildCmd = detected;
161
+ consola.info(`Auto-detected build command: ${detected}`);
162
+ }
163
+ }
164
+ if (!buildCmd) {
165
+ try {
166
+ const pkg = JSON.parse(
167
+ await readFile(join(packageDir, "package.json"), "utf-8")
168
+ );
169
+ if (pkg.files && pkg.files.length > 0) {
170
+ patterns = pkg.files;
171
+ verbose(
172
+ `[watch] Using package.json files field: ${patterns.join(", ")}`
173
+ );
174
+ }
175
+ } catch {
176
+ }
177
+ }
178
+ await doPush();
179
+ await startWatcher(
180
+ packageDir,
181
+ {
182
+ patterns,
183
+ buildCmd,
184
+ debounce: args.debounce ? parseInt(args.debounce, 10) : void 0
185
+ },
186
+ doPush
187
+ );
188
+ await new Promise(() => {
189
+ });
190
+ }
191
+ });
192
+ export {
193
+ dev_default as default
194
+ };