@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.
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/add-5ZRFUL6Z.mjs +258 -0
- package/dist/chokidar-XGAEDN45.mjs +1746 -0
- package/dist/chunk-34UXZ622.mjs +98 -0
- package/dist/chunk-4O2QOKVO.mjs +1958 -0
- package/dist/chunk-CSMZ6DZA.mjs +367 -0
- package/dist/chunk-CZM4TNAI.mjs +292 -0
- package/dist/chunk-EDUXIQ5W.mjs +1729 -0
- package/dist/chunk-GAAB2TLH.mjs +160 -0
- package/dist/chunk-HKNM3UWU.mjs +496 -0
- package/dist/chunk-I6SN7BBN.mjs +1131 -0
- package/dist/chunk-KYDBD2KQ.mjs +39 -0
- package/dist/chunk-LKQINKH4.mjs +130 -0
- package/dist/chunk-PUSXMPOF.mjs +82 -0
- package/dist/chunk-S4HJSJ32.mjs +69 -0
- package/dist/chunk-W3C72UKC.mjs +113 -0
- package/dist/chunk-WSECI6M7.mjs +85 -0
- package/dist/chunk-XMIZ7OUZ.mjs +26 -0
- package/dist/chunk-XZK5T4GK.mjs +23 -0
- package/dist/chunk-ZOYNYK5Y.mjs +23 -0
- package/dist/chunk-ZQCGJUBJ.mjs +92 -0
- package/dist/clean-LTR5MZTY.mjs +84 -0
- package/dist/cli.mjs +57 -0
- package/dist/dev-LFXQP6SA.mjs +194 -0
- package/dist/dist-DUFCZSIL.mjs +813 -0
- package/dist/doctor-R7ZVR7PY.mjs +230 -0
- package/dist/hash-worker.mjs +65 -0
- package/dist/index.d.ts +194 -0
- package/dist/index.mjs +9486 -0
- package/dist/init-SWCNRISY.mjs +310 -0
- package/dist/list-B77L2F34.mjs +119 -0
- package/dist/migrate-X5TIC5SS.mjs +124 -0
- package/dist/prompt-HTPH6HQ7.mjs +756 -0
- package/dist/publish-UXCLPNM6.mjs +63 -0
- package/dist/push-JI6HGCFG.mjs +197 -0
- package/dist/remove-DCR7KKD5.mjs +149 -0
- package/dist/restore-SUN3WGSW.mjs +124 -0
- package/dist/status-MESRBH54.mjs +103 -0
- package/dist/tailwind-source-JBBEIXIJ.mjs +89 -0
- package/dist/update-SKDSA673.mjs +100 -0
- package/dist/vite-config-BAK67JHB.mjs +128 -0
- package/dist/vite-plugin.d.ts +5 -0
- package/dist/vite-plugin.mjs +42 -0
- package/dist/workspace-76HJPAK2.mjs +97 -0
- package/package.json +96 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
publish
|
|
5
|
+
} from "./chunk-4O2QOKVO.mjs";
|
|
6
|
+
import {
|
|
7
|
+
errorWithSuggestion
|
|
8
|
+
} from "./chunk-S4HJSJ32.mjs";
|
|
9
|
+
import "./chunk-W3C72UKC.mjs";
|
|
10
|
+
import {
|
|
11
|
+
Timer
|
|
12
|
+
} from "./chunk-XZK5T4GK.mjs";
|
|
13
|
+
import "./chunk-PUSXMPOF.mjs";
|
|
14
|
+
import "./chunk-EDUXIQ5W.mjs";
|
|
15
|
+
import {
|
|
16
|
+
output,
|
|
17
|
+
suppressHumanOutput
|
|
18
|
+
} from "./chunk-ZOYNYK5Y.mjs";
|
|
19
|
+
import {
|
|
20
|
+
defineCommand
|
|
21
|
+
} from "./chunk-CSMZ6DZA.mjs";
|
|
22
|
+
import "./chunk-HKNM3UWU.mjs";
|
|
23
|
+
import {
|
|
24
|
+
verbose
|
|
25
|
+
} from "./chunk-I6SN7BBN.mjs";
|
|
26
|
+
import "./chunk-KYDBD2KQ.mjs";
|
|
27
|
+
|
|
28
|
+
// src/commands/publish.ts
|
|
29
|
+
import { resolve } from "path";
|
|
30
|
+
var publish_default = defineCommand({
|
|
31
|
+
meta: {
|
|
32
|
+
name: "publish",
|
|
33
|
+
description: "Publish current package to the plunk store"
|
|
34
|
+
},
|
|
35
|
+
args: {
|
|
36
|
+
dir: {
|
|
37
|
+
type: "positional",
|
|
38
|
+
description: "Package directory (default: current directory)",
|
|
39
|
+
required: false
|
|
40
|
+
},
|
|
41
|
+
private: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
description: "Allow publishing private packages",
|
|
44
|
+
default: false
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
async run({ args }) {
|
|
48
|
+
suppressHumanOutput();
|
|
49
|
+
const timer = new Timer();
|
|
50
|
+
const dir = resolve(args.dir || ".");
|
|
51
|
+
verbose(`[publish] Publishing from ${dir}`);
|
|
52
|
+
try {
|
|
53
|
+
const result = await publish(dir, { allowPrivate: args.private });
|
|
54
|
+
output({ ...result, elapsed: timer.elapsedMs() });
|
|
55
|
+
} catch (err) {
|
|
56
|
+
errorWithSuggestion(err instanceof Error ? err.message : String(err));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
export {
|
|
62
|
+
publish_default as default
|
|
63
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
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/push.ts
|
|
51
|
+
import { readFile } from "fs/promises";
|
|
52
|
+
import { resolve, join } from "path";
|
|
53
|
+
var consumerLimit = pLimit(4);
|
|
54
|
+
var push_default = defineCommand({
|
|
55
|
+
meta: {
|
|
56
|
+
name: "push",
|
|
57
|
+
description: "Publish and push to all consumers. Use --watch for continuous mode."
|
|
58
|
+
},
|
|
59
|
+
args: {
|
|
60
|
+
watch: {
|
|
61
|
+
type: "boolean",
|
|
62
|
+
description: "Watch for changes and auto-push",
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
build: {
|
|
66
|
+
type: "string",
|
|
67
|
+
description: "Build command to run before publishing (watch mode)"
|
|
68
|
+
},
|
|
69
|
+
"skip-build": {
|
|
70
|
+
type: "boolean",
|
|
71
|
+
description: "Watch output dirs directly, skip build command detection",
|
|
72
|
+
default: false
|
|
73
|
+
},
|
|
74
|
+
debounce: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: "Debounce delay in ms for watch mode (default: 300)"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
async run({ args }) {
|
|
80
|
+
suppressHumanOutput();
|
|
81
|
+
const packageDir = resolve(".");
|
|
82
|
+
const doPush = async () => {
|
|
83
|
+
const timer = new Timer();
|
|
84
|
+
const result = await publish(packageDir);
|
|
85
|
+
if (result.skipped) {
|
|
86
|
+
consola.info("No changes to push");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const entry = await getStoreEntry(result.name, result.version);
|
|
90
|
+
if (!entry) {
|
|
91
|
+
errorWithSuggestion("Failed to read store entry after publish");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const consumers = await getConsumers(result.name);
|
|
95
|
+
if (consumers.length === 0) {
|
|
96
|
+
consola.info(
|
|
97
|
+
"No consumers registered. Use 'plunk add' in a consumer project first."
|
|
98
|
+
);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let totalCopied = 0;
|
|
102
|
+
let totalSkipped = 0;
|
|
103
|
+
let pushCount = 0;
|
|
104
|
+
const results = await Promise.all(
|
|
105
|
+
consumers.map(
|
|
106
|
+
(consumerPath) => consumerLimit(async () => {
|
|
107
|
+
const link = await getLink(consumerPath, result.name);
|
|
108
|
+
if (!link) {
|
|
109
|
+
verbose(`[push] No link found for ${result.name} in ${consumerPath}, skipping`);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const injectResult = await inject(
|
|
114
|
+
entry,
|
|
115
|
+
consumerPath,
|
|
116
|
+
link.packageManager
|
|
117
|
+
);
|
|
118
|
+
if (injectResult.copied > 0 || injectResult.removed > 0) {
|
|
119
|
+
await addLink(consumerPath, result.name, {
|
|
120
|
+
...link,
|
|
121
|
+
contentHash: entry.meta.contentHash,
|
|
122
|
+
linkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
123
|
+
buildId: entry.meta.buildId ?? ""
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return injectResult;
|
|
127
|
+
} catch (err) {
|
|
128
|
+
consola.warn(`Failed to push to ${consumerPath}: ${err}`);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
)
|
|
133
|
+
);
|
|
134
|
+
for (const r of results) {
|
|
135
|
+
if (r) {
|
|
136
|
+
totalCopied += r.copied;
|
|
137
|
+
totalSkipped += r.skipped;
|
|
138
|
+
pushCount++;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const buildTag = result.buildId ? ` [${result.buildId}]` : "";
|
|
142
|
+
consola.success(
|
|
143
|
+
`Pushed ${result.name}@${result.version}${buildTag} to ${pushCount} consumer(s) in ${timer.elapsed()} (${totalCopied} files changed, ${totalSkipped} unchanged)`
|
|
144
|
+
);
|
|
145
|
+
output({
|
|
146
|
+
name: result.name,
|
|
147
|
+
version: result.version,
|
|
148
|
+
buildId: result.buildId,
|
|
149
|
+
consumers: pushCount,
|
|
150
|
+
copied: totalCopied,
|
|
151
|
+
skipped: totalSkipped,
|
|
152
|
+
elapsed: timer.elapsedMs()
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
await doPush();
|
|
156
|
+
if (args.watch) {
|
|
157
|
+
let buildCmd = args.build;
|
|
158
|
+
let patterns;
|
|
159
|
+
if (args.build) {
|
|
160
|
+
} else if (args["skip-build"]) {
|
|
161
|
+
} else {
|
|
162
|
+
const pm = await detectPackageManager(packageDir);
|
|
163
|
+
const detected = await detectBuildCommand(packageDir, pm);
|
|
164
|
+
if (detected) {
|
|
165
|
+
buildCmd = detected;
|
|
166
|
+
consola.info(`Auto-detected build command: ${detected}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!buildCmd) {
|
|
170
|
+
try {
|
|
171
|
+
const pkg = JSON.parse(
|
|
172
|
+
await readFile(join(packageDir, "package.json"), "utf-8")
|
|
173
|
+
);
|
|
174
|
+
if (pkg.files && pkg.files.length > 0) {
|
|
175
|
+
patterns = pkg.files;
|
|
176
|
+
verbose(`[watch] Using package.json files field: ${patterns.join(", ")}`);
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
await startWatcher(
|
|
182
|
+
packageDir,
|
|
183
|
+
{
|
|
184
|
+
patterns,
|
|
185
|
+
buildCmd,
|
|
186
|
+
debounce: args.debounce ? parseInt(args.debounce, 10) : void 0
|
|
187
|
+
},
|
|
188
|
+
doPush
|
|
189
|
+
);
|
|
190
|
+
await new Promise(() => {
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
export {
|
|
196
|
+
push_default as default
|
|
197
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
removeFromTranspilePackages
|
|
5
|
+
} from "./chunk-WSECI6M7.mjs";
|
|
6
|
+
import {
|
|
7
|
+
removeInjected,
|
|
8
|
+
restoreBackup
|
|
9
|
+
} from "./chunk-CZM4TNAI.mjs";
|
|
10
|
+
import {
|
|
11
|
+
detectBundler
|
|
12
|
+
} from "./chunk-34UXZ622.mjs";
|
|
13
|
+
import {
|
|
14
|
+
getLink,
|
|
15
|
+
readConsumerState,
|
|
16
|
+
removeLink,
|
|
17
|
+
unregisterConsumer
|
|
18
|
+
} from "./chunk-GAAB2TLH.mjs";
|
|
19
|
+
import {
|
|
20
|
+
errorWithSuggestion
|
|
21
|
+
} from "./chunk-S4HJSJ32.mjs";
|
|
22
|
+
import {
|
|
23
|
+
Timer
|
|
24
|
+
} from "./chunk-XZK5T4GK.mjs";
|
|
25
|
+
import "./chunk-PUSXMPOF.mjs";
|
|
26
|
+
import "./chunk-EDUXIQ5W.mjs";
|
|
27
|
+
import {
|
|
28
|
+
output,
|
|
29
|
+
suppressHumanOutput
|
|
30
|
+
} from "./chunk-ZOYNYK5Y.mjs";
|
|
31
|
+
import {
|
|
32
|
+
defineCommand
|
|
33
|
+
} from "./chunk-CSMZ6DZA.mjs";
|
|
34
|
+
import "./chunk-HKNM3UWU.mjs";
|
|
35
|
+
import {
|
|
36
|
+
consola,
|
|
37
|
+
verbose
|
|
38
|
+
} from "./chunk-I6SN7BBN.mjs";
|
|
39
|
+
import "./chunk-KYDBD2KQ.mjs";
|
|
40
|
+
|
|
41
|
+
// src/commands/remove.ts
|
|
42
|
+
import { resolve, basename } from "path";
|
|
43
|
+
var remove_default = defineCommand({
|
|
44
|
+
meta: {
|
|
45
|
+
name: "remove",
|
|
46
|
+
description: "Remove a plunk-linked package and restore the original"
|
|
47
|
+
},
|
|
48
|
+
args: {
|
|
49
|
+
package: {
|
|
50
|
+
type: "positional",
|
|
51
|
+
description: "Package name to remove",
|
|
52
|
+
required: false
|
|
53
|
+
},
|
|
54
|
+
all: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Remove all linked packages",
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
force: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
description: "Skip error checking",
|
|
62
|
+
default: false
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async run({ args }) {
|
|
66
|
+
suppressHumanOutput();
|
|
67
|
+
const timer = new Timer();
|
|
68
|
+
const consumerPath = resolve(".");
|
|
69
|
+
if (args.all) {
|
|
70
|
+
const state = await readConsumerState(consumerPath);
|
|
71
|
+
const links = Object.entries(state.links);
|
|
72
|
+
if (links.length === 0) {
|
|
73
|
+
consola.info("No linked packages to remove");
|
|
74
|
+
output({ removed: 0 });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let removed = 0;
|
|
78
|
+
for (const [packageName2, link2] of links) {
|
|
79
|
+
await removeSinglePackage(consumerPath, packageName2, link2);
|
|
80
|
+
removed++;
|
|
81
|
+
}
|
|
82
|
+
consola.success(`Removed ${removed} plunk link(s) in ${timer.elapsed()}`);
|
|
83
|
+
output({ removed, elapsed: timer.elapsedMs() });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const packageName = args.package;
|
|
87
|
+
if (!packageName) {
|
|
88
|
+
errorWithSuggestion("Package name required. Use --all to remove all linked packages.");
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
const link = await getLink(consumerPath, packageName);
|
|
92
|
+
if (!link) {
|
|
93
|
+
if (args.force) {
|
|
94
|
+
consola.warn(`Package "${packageName}" is not linked, skipping`);
|
|
95
|
+
output({ removed: 0 });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
errorWithSuggestion(`Package "${packageName}" is not linked in this project`);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
await removeSinglePackage(consumerPath, packageName, link);
|
|
102
|
+
consola.success(`Removed plunk link for ${packageName} in ${timer.elapsed()}`);
|
|
103
|
+
output({ removed: 1, package: packageName, elapsed: timer.elapsedMs() });
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
async function removeSinglePackage(consumerPath, packageName, link) {
|
|
107
|
+
verbose(`[remove] Removing ${packageName}`);
|
|
108
|
+
await removeInjected(consumerPath, packageName, link.packageManager);
|
|
109
|
+
if (link.backupExists) {
|
|
110
|
+
const restored = await restoreBackup(
|
|
111
|
+
consumerPath,
|
|
112
|
+
packageName,
|
|
113
|
+
link.packageManager
|
|
114
|
+
);
|
|
115
|
+
if (restored) {
|
|
116
|
+
consola.success(`Restored original ${packageName} from backup`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const bundler = await detectBundler(consumerPath);
|
|
120
|
+
if (bundler.type === "next" && bundler.configFile) {
|
|
121
|
+
const result = await removeFromTranspilePackages(bundler.configFile, packageName);
|
|
122
|
+
if (result.modified) {
|
|
123
|
+
verbose(`[remove] Removed ${packageName} from ${basename(bundler.configFile)}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const { findTailwindCss, removeTailwindSource } = await import("./tailwind-source-JBBEIXIJ.mjs");
|
|
127
|
+
const tailwindCss = await findTailwindCss(consumerPath);
|
|
128
|
+
if (tailwindCss) {
|
|
129
|
+
const twResult = await removeTailwindSource(tailwindCss, packageName);
|
|
130
|
+
if (twResult.modified) {
|
|
131
|
+
verbose(`[remove] Removed @source for ${packageName} from ${basename(tailwindCss)}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
await removeLink(consumerPath, packageName);
|
|
135
|
+
await unregisterConsumer(packageName, consumerPath);
|
|
136
|
+
if (bundler.type === "vite" && bundler.configFile) {
|
|
137
|
+
const state = await readConsumerState(consumerPath);
|
|
138
|
+
if (Object.keys(state.links).length === 0) {
|
|
139
|
+
const { removeFromViteConfig } = await import("./vite-config-BAK67JHB.mjs");
|
|
140
|
+
const result = await removeFromViteConfig(bundler.configFile);
|
|
141
|
+
if (result.modified) {
|
|
142
|
+
verbose(`[remove] Removed plunk plugin from ${basename(bundler.configFile)}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
remove_default as default
|
|
149
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
inject
|
|
5
|
+
} from "./chunk-CZM4TNAI.mjs";
|
|
6
|
+
import {
|
|
7
|
+
detectPackageManager,
|
|
8
|
+
detectYarnNodeLinker,
|
|
9
|
+
hasYarnrcYml
|
|
10
|
+
} from "./chunk-34UXZ622.mjs";
|
|
11
|
+
import {
|
|
12
|
+
readConsumerState
|
|
13
|
+
} from "./chunk-GAAB2TLH.mjs";
|
|
14
|
+
import {
|
|
15
|
+
getStoreEntry
|
|
16
|
+
} from "./chunk-W3C72UKC.mjs";
|
|
17
|
+
import {
|
|
18
|
+
Timer
|
|
19
|
+
} from "./chunk-XZK5T4GK.mjs";
|
|
20
|
+
import "./chunk-EDUXIQ5W.mjs";
|
|
21
|
+
import {
|
|
22
|
+
output,
|
|
23
|
+
suppressHumanOutput
|
|
24
|
+
} from "./chunk-ZOYNYK5Y.mjs";
|
|
25
|
+
import {
|
|
26
|
+
defineCommand
|
|
27
|
+
} from "./chunk-CSMZ6DZA.mjs";
|
|
28
|
+
import {
|
|
29
|
+
pLimit
|
|
30
|
+
} from "./chunk-HKNM3UWU.mjs";
|
|
31
|
+
import {
|
|
32
|
+
consola,
|
|
33
|
+
verbose
|
|
34
|
+
} from "./chunk-I6SN7BBN.mjs";
|
|
35
|
+
import "./chunk-KYDBD2KQ.mjs";
|
|
36
|
+
|
|
37
|
+
// src/commands/restore.ts
|
|
38
|
+
import { resolve } from "path";
|
|
39
|
+
var restoreLimit = pLimit(4);
|
|
40
|
+
var restore_default = defineCommand({
|
|
41
|
+
meta: {
|
|
42
|
+
name: "restore",
|
|
43
|
+
description: "Re-inject all linked packages (use after npm install wipes overrides)"
|
|
44
|
+
},
|
|
45
|
+
args: {
|
|
46
|
+
silent: {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description: "Suppress output when no packages are linked (for postinstall scripts)",
|
|
49
|
+
default: false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
async run({ args }) {
|
|
53
|
+
suppressHumanOutput();
|
|
54
|
+
const timer = new Timer();
|
|
55
|
+
const consumerPath = resolve(".");
|
|
56
|
+
const state = await readConsumerState(consumerPath);
|
|
57
|
+
const pm = await detectPackageManager(consumerPath);
|
|
58
|
+
if (pm === "yarn") {
|
|
59
|
+
const linker = await detectYarnNodeLinker(consumerPath);
|
|
60
|
+
if (linker === "pnp" || linker === null && await hasYarnrcYml(consumerPath)) {
|
|
61
|
+
consola.error(
|
|
62
|
+
`Yarn PnP mode is not compatible with plunk.
|
|
63
|
+
|
|
64
|
+
plunk works by copying files into node_modules/, but PnP eliminates
|
|
65
|
+
node_modules/ entirely. To use plunk with Yarn Berry, add this to
|
|
66
|
+
.yarnrc.yml:
|
|
67
|
+
|
|
68
|
+
nodeLinker: node-modules
|
|
69
|
+
|
|
70
|
+
Then run: yarn install`
|
|
71
|
+
);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const links = Object.entries(state.links);
|
|
76
|
+
if (links.length === 0) {
|
|
77
|
+
if (!args.silent) {
|
|
78
|
+
consola.info("No linked packages in this project");
|
|
79
|
+
}
|
|
80
|
+
output({ restored: 0, failed: 0 });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
let restored = 0;
|
|
84
|
+
let failed = 0;
|
|
85
|
+
const results = await Promise.all(
|
|
86
|
+
links.map(
|
|
87
|
+
([packageName, link]) => restoreLimit(async () => {
|
|
88
|
+
const entry = await getStoreEntry(packageName, link.version);
|
|
89
|
+
if (!entry) {
|
|
90
|
+
consola.warn(
|
|
91
|
+
`Store entry missing for ${packageName}@${link.version}. Re-publish it.`
|
|
92
|
+
);
|
|
93
|
+
return { packageName, success: false };
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const result = await inject(entry, consumerPath, link.packageManager);
|
|
97
|
+
verbose(`[restore] ${packageName}@${link.version}: ${result.copied} files`);
|
|
98
|
+
return { packageName, success: true, copied: result.copied };
|
|
99
|
+
} catch (err) {
|
|
100
|
+
consola.error(`Failed to restore ${packageName}: ${err}`);
|
|
101
|
+
return { packageName, success: false };
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
for (const r of results) {
|
|
107
|
+
if (r.success) {
|
|
108
|
+
consola.success(
|
|
109
|
+
`Restored ${r.packageName} (${r.copied} files)`
|
|
110
|
+
);
|
|
111
|
+
restored++;
|
|
112
|
+
} else {
|
|
113
|
+
failed++;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
consola.info(
|
|
117
|
+
`Restore complete: ${restored} restored, ${failed} failed in ${timer.elapsed()}`
|
|
118
|
+
);
|
|
119
|
+
output({ restored, failed, elapsed: timer.elapsedMs() });
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
export {
|
|
123
|
+
restore_default as default
|
|
124
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
readConsumerState
|
|
5
|
+
} from "./chunk-GAAB2TLH.mjs";
|
|
6
|
+
import {
|
|
7
|
+
getStoreEntry
|
|
8
|
+
} from "./chunk-W3C72UKC.mjs";
|
|
9
|
+
import {
|
|
10
|
+
require_picocolors
|
|
11
|
+
} from "./chunk-PUSXMPOF.mjs";
|
|
12
|
+
import "./chunk-EDUXIQ5W.mjs";
|
|
13
|
+
import {
|
|
14
|
+
output,
|
|
15
|
+
suppressHumanOutput
|
|
16
|
+
} from "./chunk-ZOYNYK5Y.mjs";
|
|
17
|
+
import {
|
|
18
|
+
defineCommand
|
|
19
|
+
} from "./chunk-CSMZ6DZA.mjs";
|
|
20
|
+
import {
|
|
21
|
+
exists,
|
|
22
|
+
pLimit
|
|
23
|
+
} from "./chunk-HKNM3UWU.mjs";
|
|
24
|
+
import {
|
|
25
|
+
consola
|
|
26
|
+
} from "./chunk-I6SN7BBN.mjs";
|
|
27
|
+
import {
|
|
28
|
+
__toESM
|
|
29
|
+
} from "./chunk-KYDBD2KQ.mjs";
|
|
30
|
+
|
|
31
|
+
// src/commands/status.ts
|
|
32
|
+
import { resolve, join } from "path";
|
|
33
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
34
|
+
var checkLimit = pLimit(4);
|
|
35
|
+
var status_default = defineCommand({
|
|
36
|
+
meta: {
|
|
37
|
+
name: "status",
|
|
38
|
+
description: "Show status of linked packages with health checks"
|
|
39
|
+
},
|
|
40
|
+
async run() {
|
|
41
|
+
suppressHumanOutput();
|
|
42
|
+
const consumerPath = resolve(".");
|
|
43
|
+
const state = await readConsumerState(consumerPath);
|
|
44
|
+
const links = Object.entries(state.links);
|
|
45
|
+
if (links.length === 0) {
|
|
46
|
+
consola.info("No linked packages in this project");
|
|
47
|
+
output({ packages: [] });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
consola.info(`Package status (${links.length} linked):
|
|
51
|
+
`);
|
|
52
|
+
const statuses = await Promise.all(
|
|
53
|
+
links.map(
|
|
54
|
+
([name, link]) => checkLimit(async () => {
|
|
55
|
+
const issues = [];
|
|
56
|
+
const entry = await getStoreEntry(name, link.version);
|
|
57
|
+
if (!entry) {
|
|
58
|
+
issues.push("store entry missing");
|
|
59
|
+
} else if (entry.meta.contentHash !== link.contentHash) {
|
|
60
|
+
issues.push("unpublished changes in store");
|
|
61
|
+
}
|
|
62
|
+
const nmPath = join(consumerPath, "node_modules", name);
|
|
63
|
+
if (!await exists(nmPath)) {
|
|
64
|
+
issues.push("missing from node_modules (run plunk restore)");
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
name,
|
|
68
|
+
version: link.version,
|
|
69
|
+
buildId: link.buildId ?? "",
|
|
70
|
+
issues,
|
|
71
|
+
linkedAt: link.linkedAt,
|
|
72
|
+
sourcePath: link.sourcePath
|
|
73
|
+
};
|
|
74
|
+
})
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
for (const s of statuses) {
|
|
78
|
+
const statusIcon = s.issues.length === 0 ? import_picocolors.default.green("\u2713") : import_picocolors.default.yellow("!");
|
|
79
|
+
const buildTag = s.buildId ? `[${s.buildId}]` : "[--------]";
|
|
80
|
+
console.log(
|
|
81
|
+
` ${statusIcon} ${import_picocolors.default.cyan(s.name)} ${import_picocolors.default.dim("@" + s.version)} ${import_picocolors.default.dim(buildTag)}`
|
|
82
|
+
);
|
|
83
|
+
console.log(
|
|
84
|
+
` ${import_picocolors.default.dim(`linked ${new Date(s.linkedAt).toLocaleString()} from ${s.sourcePath}`)}`
|
|
85
|
+
);
|
|
86
|
+
for (const issue of s.issues) {
|
|
87
|
+
console.log(` ${import_picocolors.default.yellow("\u26A0")} ${issue}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
output({
|
|
91
|
+
packages: statuses.map(({ name, version, buildId, issues }) => ({
|
|
92
|
+
name,
|
|
93
|
+
version,
|
|
94
|
+
buildId: buildId || null,
|
|
95
|
+
healthy: issues.length === 0,
|
|
96
|
+
issues
|
|
97
|
+
}))
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
export {
|
|
102
|
+
status_default as default
|
|
103
|
+
};
|