knarr 0.1.3 → 0.3.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.
Files changed (139) hide show
  1. package/README.md +66 -107
  2. package/dist/add-B_xzUp5y.mjs +3 -0
  3. package/dist/add-flow-cvrMO_aV.mjs +5 -0
  4. package/dist/batch-push-DXtZxRx0.mjs +3 -0
  5. package/dist/build-detect-BTHh2OBm.mjs +3 -0
  6. package/dist/bundler-detect-Dq-QAbQj.mjs +3 -0
  7. package/dist/check-CbVdpTsw.mjs +3 -0
  8. package/dist/chokidar-BkIWf7Ix.mjs +3 -0
  9. package/dist/clean-CyDDqbBD.mjs +3 -0
  10. package/dist/cli.mjs +4 -4
  11. package/dist/config-BJsL6NqN.mjs +4 -0
  12. package/dist/console-CIiXr7ge.mjs +3 -0
  13. package/dist/console-CyaBcUd-.mjs +98 -0
  14. package/dist/dev-kqgY9NjI.mjs +3 -0
  15. package/dist/dist-CFkjiIqD.mjs +7 -0
  16. package/dist/doctor-D-S1P0UG.mjs +6 -0
  17. package/dist/dry-run-BkdMYSIx.mjs +3 -0
  18. package/dist/errors-BlOfexcH.mjs +3 -0
  19. package/dist/explain-9Y4SZHjC.mjs +3 -0
  20. package/dist/format-DRqD29u-.mjs +3 -0
  21. package/dist/fs-C4juVCTd.mjs +3 -0
  22. package/dist/fs-CPnWm9CR.mjs +3 -0
  23. package/dist/fs-DzsciYAL.mjs +757 -0
  24. package/dist/hints-Hz3V4h3A.mjs +3 -0
  25. package/dist/history-DRhLwzhq.mjs +3 -0
  26. package/dist/history-vS3w4EGu.mjs +3 -0
  27. package/dist/index.d.ts +249 -264
  28. package/dist/index.mjs +3426 -4668
  29. package/dist/init-TN84d5jM.mjs +4 -0
  30. package/dist/init-helpers-CYYWQm-P.mjs +15 -0
  31. package/dist/injector-nt40JxVt.mjs +3 -0
  32. package/dist/json-DbSkpxtr.mjs +3 -0
  33. package/dist/list-9hWJjw19.mjs +3 -0
  34. package/dist/logger-9C6B9Na8.mjs +3 -0
  35. package/dist/migrate-Co4qcFt6.mjs +5 -0
  36. package/dist/nextjs-config-BQgTWZ96.mjs +3 -0
  37. package/dist/nextjs-config-dUw2J6B9.mjs +4 -0
  38. package/dist/output-BxR2v-jn.mjs +3 -0
  39. package/dist/package-manager-DJ8CE0zL.mjs +13 -0
  40. package/dist/picomatch-B0_Pxgms.mjs +3 -0
  41. package/dist/preflight-BDsxR2Ct.mjs +3 -0
  42. package/dist/preflight-MzNjLXiy.mjs +3 -0
  43. package/dist/publish-C7ZUvHkE.mjs +3 -0
  44. package/dist/publisher-CvXTbkLP.mjs +4 -0
  45. package/dist/push-B5KrkILW.mjs +3 -0
  46. package/dist/push-engine-BpNr8qXR.mjs +3 -0
  47. package/dist/remove-DkOgVQMZ.mjs +3 -0
  48. package/dist/remove-J5tY_BFk.mjs +3 -0
  49. package/dist/reset-ClGouUb5.mjs +3 -0
  50. package/dist/restore-Bx2V59SL.mjs +3 -0
  51. package/dist/rollback-RPjHZWtG.mjs +3 -0
  52. package/dist/rolldown-runtime-BZbIAPMk.mjs +3 -0
  53. package/dist/shell-RQ7Hf1kp.mjs +3 -0
  54. package/dist/status-Rnvw6dG2.mjs +3 -0
  55. package/dist/store-DjPdOKqg.mjs +3 -0
  56. package/dist/tailwind-source-D1cUiG-t.mjs +5 -0
  57. package/dist/timer-DqgB175x.mjs +3 -0
  58. package/dist/topo-sort-DOCpHjT7.mjs +3 -0
  59. package/dist/topo-sort-yd4jxr_E.mjs +3 -0
  60. package/dist/tracker-89eW0ArT.mjs +3 -0
  61. package/dist/tracker-B3Fqx94J.mjs +3 -0
  62. package/dist/update-CAKFICZu.mjs +3 -0
  63. package/dist/use-CCx6J0mc.mjs +3 -0
  64. package/dist/vite-config-BHmawlD2.mjs +12 -0
  65. package/dist/vite-config-BRlYc4ni.mjs +3 -0
  66. package/dist/vite-plugin.d.ts +6 -5
  67. package/dist/vite-plugin.mjs +206 -211
  68. package/dist/watch-orchestrator-BfuCaZLA.mjs +3 -0
  69. package/dist/watcher-T123sBDg.mjs +3 -0
  70. package/dist/webpack-plugin.d.ts +29 -30
  71. package/dist/webpack-plugin.mjs +140 -138
  72. package/dist/workspace-CdLSxPFS.mjs +3 -0
  73. package/dist/workspace-DBxNrowu.mjs +3 -0
  74. package/dist/xxhash-wasm-D_QjdUuv.mjs +3 -0
  75. package/package.json +23 -31
  76. package/dist/add-LQ6WMCGD.mjs +0 -3
  77. package/dist/bell-SIN4ERLS.mjs +0 -2
  78. package/dist/check-7CJHAF6Y.mjs +0 -6
  79. package/dist/chokidar-2G63V464.mjs +0 -4
  80. package/dist/chunk-3SXN6MQL.mjs +0 -4
  81. package/dist/chunk-7GCKCCHU.mjs +0 -3
  82. package/dist/chunk-BH2WXCLS.mjs +0 -4
  83. package/dist/chunk-CBOYKBSM.mjs +0 -13
  84. package/dist/chunk-E3HZCU3S.mjs +0 -5
  85. package/dist/chunk-G7HFTV5Y.mjs +0 -3
  86. package/dist/chunk-HVN6HBWZ.mjs +0 -3
  87. package/dist/chunk-ICU4V73X.mjs +0 -3
  88. package/dist/chunk-IP5ROSRE.mjs +0 -3
  89. package/dist/chunk-J6HZHQVL.mjs +0 -3
  90. package/dist/chunk-K6OAYJKS.mjs +0 -6
  91. package/dist/chunk-KRX4JX6V.mjs +0 -4
  92. package/dist/chunk-KUQULMM6.mjs +0 -3
  93. package/dist/chunk-L7O2RSTN.mjs +0 -3
  94. package/dist/chunk-M3TRMEJV.mjs +0 -3
  95. package/dist/chunk-MN4DV2NO.mjs +0 -3
  96. package/dist/chunk-N3B2JO4H.mjs +0 -13
  97. package/dist/chunk-NGPAGRK4.mjs +0 -7
  98. package/dist/chunk-NV3ASN6X.mjs +0 -3
  99. package/dist/chunk-OQDZJP55.mjs +0 -3
  100. package/dist/chunk-QEH5VHRO.mjs +0 -13
  101. package/dist/chunk-QFHYSC3K.mjs +0 -3
  102. package/dist/chunk-QHNHLR6T.mjs +0 -3
  103. package/dist/chunk-RIHOZDFW.mjs +0 -22
  104. package/dist/chunk-SMR4HT6A.mjs +0 -3
  105. package/dist/chunk-SPHWZS5P.mjs +0 -3
  106. package/dist/chunk-U6O35NZ7.mjs +0 -3
  107. package/dist/chunk-W2MMKBWU.mjs +0 -3
  108. package/dist/chunk-WBTSRLB6.mjs +0 -7
  109. package/dist/chunk-WN3DOKIM.mjs +0 -3
  110. package/dist/chunk-XDWZZBCM.mjs +0 -3
  111. package/dist/chunk-Z5K6DFA6.mjs +0 -3
  112. package/dist/clean-EJIYYQZM.mjs +0 -3
  113. package/dist/dev-WU5KB5PJ.mjs +0 -3
  114. package/dist/doctor-W2G34POC.mjs +0 -6
  115. package/dist/explain-LZLNIMVZ.mjs +0 -5
  116. package/dist/fs-NU36NNEG.mjs +0 -2
  117. package/dist/history-MLJHRV3Q.mjs +0 -2
  118. package/dist/init-SNG5LBZK.mjs +0 -7
  119. package/dist/list-4PTHMIQ4.mjs +0 -5
  120. package/dist/migrate-USY26Y5R.mjs +0 -8
  121. package/dist/nextjs-config-T5D6LOJE.mjs +0 -2
  122. package/dist/preflight-IXICTR6G.mjs +0 -2
  123. package/dist/publish-2IH7IQV4.mjs +0 -3
  124. package/dist/push-W3TM2QYK.mjs +0 -3
  125. package/dist/remove-MVQOIN2I.mjs +0 -2
  126. package/dist/reset-BTOJ54MJ.mjs +0 -3
  127. package/dist/restore-TWOOF2BN.mjs +0 -3
  128. package/dist/rollback-CFYSE5YG.mjs +0 -3
  129. package/dist/status-3ZXM3CRH.mjs +0 -4
  130. package/dist/tailwind-source-HCTY2XDU.mjs +0 -5
  131. package/dist/topo-sort-ZNGR6D7M.mjs +0 -2
  132. package/dist/tracker-QAKEXYUJ.mjs +0 -2
  133. package/dist/update-TGGCUOOO.mjs +0 -3
  134. package/dist/use-4Z5KXRVR.mjs +0 -3
  135. package/dist/vite-config-XOGAKYGQ.mjs +0 -2
  136. package/dist/watch-orchestrator-6BQYU5YS.mjs +0 -3
  137. package/dist/watcher-ES2APFH4.mjs +0 -3
  138. package/dist/workspace-T6PNO4L3.mjs +0 -2
  139. package/dist/xxhash-wasm-I6Q3T2SL.mjs +0 -3
@@ -1,143 +1,145 @@
1
+ import { join, normalize } from "node:path";
2
+ import { readFileSync } from "node:fs";
3
+ // src/utils/json.ts
4
+ function isJsonObject(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6
+ }
7
+ /** Parse JSON to `unknown`; callers must validate before use. */
8
+ function parseJson(text) {
9
+ return JSON.parse(text);
10
+ }
11
+ /** Parse JSON that must be an object (package.json, state files). Throws otherwise. */
12
+ function parseJsonObject(text, label = "JSON") {
13
+ const value = parseJson(text);
14
+ if (!isJsonObject(value)) throw new Error(`${label} must contain a JSON object`);
15
+ return value;
16
+ }
17
+ /** `obj[key]` when it is a JSON object. */
18
+ function objectField(obj, key) {
19
+ const value = obj[key];
20
+ return isJsonObject(value) ? value : void 0;
21
+ }
1
22
  // src/webpack-plugin.ts
2
- import { join, normalize } from "path";
3
- import { readFileSync } from "fs";
23
+ /** Synchronously read linked package names from state.json */
4
24
  function readLinkedPackagesSync(stateFile) {
5
- try {
6
- const content = readFileSync(stateFile, "utf-8");
7
- const state = JSON.parse(content);
8
- return Object.keys(state.links ?? {});
9
- } catch {
10
- return [];
11
- }
25
+ try {
26
+ const links = objectField(parseJsonObject(readFileSync(stateFile, "utf-8"), stateFile), "links");
27
+ return links ? Object.keys(links) : [];
28
+ } catch {
29
+ return [];
30
+ }
12
31
  }
32
+ /**
33
+ * Webpack/rspack plugin for knarr.
34
+ *
35
+ * - Excludes linked packages from webpack's snapshot cache (managedPaths)
36
+ * - Watches .knarr/state.json and linked package directories
37
+ * - Invalidates the compiler on changes to trigger a rebuild
38
+ * - Works with webpack 5 and rspack (uses loose typing, no webpack import)
39
+ */
13
40
  var KnarrWebpackPlugin = class {
14
- options;
15
- constructor(options = {}) {
16
- this.options = options;
17
- }
18
- apply(compiler) {
19
- const root = this.options.root ?? compiler.options.context ?? process.cwd();
20
- const stateFile = normalize(join(root, ".knarr", "state.json"));
21
- const nodeModulesDir = join(root, "node_modules");
22
- let watcher = null;
23
- let pollTimer;
24
- let debounceTimer = null;
25
- let lastStateContent = "";
26
- const watchedPackages = /* @__PURE__ */ new Set();
27
- const invalidate = () => {
28
- if (debounceTimer) clearTimeout(debounceTimer);
29
- debounceTimer = setTimeout(() => {
30
- debounceTimer = null;
31
- if (compiler.watching) {
32
- compiler.watching.invalidate();
33
- }
34
- }, 200);
35
- };
36
- const syncPackages = () => {
37
- let changed = false;
38
- for (const pkg of readLinkedPackagesSync(stateFile)) {
39
- if (!watchedPackages.has(pkg)) {
40
- watchedPackages.add(pkg);
41
- changed = true;
42
- }
43
- }
44
- return changed;
45
- };
46
- compiler.hooks.afterEnvironment.tap("KnarrWebpackPlugin", () => {
47
- syncPackages();
48
- if (watchedPackages.size === 0) return;
49
- const snapshot = compiler.options.snapshot ??= {};
50
- const managedPaths = snapshot.managedPaths ??= [];
51
- const escaped = [...watchedPackages].sort((a, b) => b.length - a.length).map((p) => p.replace(/[/\\.*+?^${}()|[\]]/g, "\\$&")).join("|");
52
- const excludeRegex = new RegExp(
53
- `node_modules[\\\\/](?!(?:${escaped})(?:[\\\\/]|$))`
54
- );
55
- const filtered = managedPaths.filter((p) => {
56
- if (typeof p === "string") return !p.includes("node_modules");
57
- return !p.source?.includes("node_modules");
58
- });
59
- filtered.push(excludeRegex);
60
- snapshot.managedPaths = filtered;
61
- });
62
- compiler.hooks.watchRun.tapPromise(
63
- "KnarrWebpackPlugin",
64
- async () => {
65
- if (watcher) return;
66
- const usePolling = !!process.versions?.webcontainer;
67
- if (usePolling) {
68
- try {
69
- lastStateContent = readFileSync(stateFile, "utf-8");
70
- } catch {
71
- }
72
- pollTimer = setInterval(() => {
73
- try {
74
- const content = readFileSync(stateFile, "utf-8");
75
- if (lastStateContent && content !== lastStateContent) {
76
- lastStateContent = content;
77
- syncPackages();
78
- invalidate();
79
- }
80
- if (!lastStateContent) lastStateContent = content;
81
- } catch {
82
- }
83
- }, 1e3);
84
- }
85
- const { watch } = await import("chokidar");
86
- const watchPaths = [stateFile];
87
- for (const pkg of watchedPackages) {
88
- watchPaths.push(join(nodeModulesDir, pkg));
89
- }
90
- const chokidarWatcher = watch(watchPaths, {
91
- ignoreInitial: true,
92
- ignored: [/[/\\]\.git[/\\]/],
93
- usePolling,
94
- ...usePolling && { interval: 1e3 }
95
- });
96
- chokidarWatcher.on("change", (changedPath) => {
97
- const normalized = normalize(changedPath);
98
- if (normalized === stateFile) {
99
- const changed = syncPackages();
100
- if (changed) {
101
- for (const pkg of watchedPackages) {
102
- chokidarWatcher.add(join(nodeModulesDir, pkg));
103
- }
104
- }
105
- }
106
- invalidate();
107
- });
108
- chokidarWatcher.on("add", () => invalidate());
109
- chokidarWatcher.on("unlink", () => invalidate());
110
- watcher = {
111
- close: () => chokidarWatcher.close()
112
- };
113
- }
114
- );
115
- compiler.hooks.afterCompile.tapPromise(
116
- "KnarrWebpackPlugin",
117
- async (compilation) => {
118
- for (const pkg of watchedPackages) {
119
- compilation.contextDependencies.add(join(nodeModulesDir, pkg));
120
- }
121
- }
122
- );
123
- compiler.hooks.watchClose.tap("KnarrWebpackPlugin", () => {
124
- if (debounceTimer) {
125
- clearTimeout(debounceTimer);
126
- debounceTimer = null;
127
- }
128
- if (pollTimer) {
129
- clearInterval(pollTimer);
130
- pollTimer = void 0;
131
- }
132
- if (watcher) {
133
- watcher.close();
134
- watcher = null;
135
- }
136
- });
137
- }
138
- };
139
- var webpack_plugin_default = KnarrWebpackPlugin;
140
- export {
141
- KnarrWebpackPlugin,
142
- webpack_plugin_default as default
41
+ options;
42
+ constructor(options = {}) {
43
+ this.options = options;
44
+ }
45
+ apply(compiler) {
46
+ const root = this.options.root ?? compiler.options.context ?? process.cwd();
47
+ const stateFile = normalize(join(root, ".knarr", "state.json"));
48
+ const nodeModulesDir = join(root, "node_modules");
49
+ let watcher = null;
50
+ let pollTimer;
51
+ let debounceTimer = null;
52
+ let lastStateContent = "";
53
+ const watchedPackages = /* @__PURE__ */ new Set();
54
+ const invalidate = () => {
55
+ if (debounceTimer) clearTimeout(debounceTimer);
56
+ debounceTimer = setTimeout(() => {
57
+ debounceTimer = null;
58
+ if (compiler.watching) compiler.watching.invalidate();
59
+ }, 200);
60
+ };
61
+ const syncPackages = () => {
62
+ let changed = false;
63
+ for (const pkg of readLinkedPackagesSync(stateFile)) if (!watchedPackages.has(pkg)) {
64
+ watchedPackages.add(pkg);
65
+ changed = true;
66
+ }
67
+ return changed;
68
+ };
69
+ compiler.hooks.afterEnvironment.tap("KnarrWebpackPlugin", () => {
70
+ syncPackages();
71
+ if (watchedPackages.size === 0) return;
72
+ const snapshot = compiler.options.snapshot ??= {};
73
+ const managedPaths = snapshot.managedPaths ??= [];
74
+ const escaped = [...watchedPackages].sort((a, b) => b.length - a.length).map((p) => p.replace(/[/\\.*+?^${}()|[\]]/g, "\\$&")).join("|");
75
+ const excludeRegex = new RegExp(`node_modules[\\\\/](?!(?:${escaped})(?:[\\\\/]|$))`);
76
+ const filtered = managedPaths.filter((p) => {
77
+ if (typeof p === "string") return !p.includes("node_modules");
78
+ return !p.source?.includes("node_modules");
79
+ });
80
+ filtered.push(excludeRegex);
81
+ snapshot.managedPaths = filtered;
82
+ });
83
+ compiler.hooks.watchRun.tapPromise("KnarrWebpackPlugin", async () => {
84
+ if (watcher) return;
85
+ const usePolling = !!process.versions?.webcontainer;
86
+ if (usePolling) {
87
+ try {
88
+ lastStateContent = readFileSync(stateFile, "utf-8");
89
+ } catch {}
90
+ pollTimer = setInterval(() => {
91
+ try {
92
+ const content = readFileSync(stateFile, "utf-8");
93
+ if (lastStateContent && content !== lastStateContent) {
94
+ lastStateContent = content;
95
+ syncPackages();
96
+ invalidate();
97
+ }
98
+ if (!lastStateContent) lastStateContent = content;
99
+ } catch {}
100
+ }, 1e3);
101
+ }
102
+ const { watch } = await import("chokidar");
103
+ const watchPaths = [stateFile];
104
+ for (const pkg of watchedPackages) watchPaths.push(join(nodeModulesDir, pkg));
105
+ const chokidarWatcher = watch(watchPaths, {
106
+ ignoreInitial: true,
107
+ ignored: [/[/\\]\.git[/\\]/],
108
+ backend: usePolling ? "polling" : "auto",
109
+ ...usePolling && { pollingInterval: 1e3 }
110
+ });
111
+ let chokidarClosed = false;
112
+ chokidarWatcher.on("change", (changedPath) => {
113
+ if (normalize(changedPath) === stateFile) {
114
+ if (syncPackages() && !chokidarClosed) for (const pkg of watchedPackages) chokidarWatcher.add(join(nodeModulesDir, pkg));
115
+ }
116
+ invalidate();
117
+ });
118
+ chokidarWatcher.on("add", () => invalidate());
119
+ chokidarWatcher.on("unlink", () => invalidate());
120
+ watcher = { close: () => {
121
+ chokidarClosed = true;
122
+ return chokidarWatcher.close();
123
+ } };
124
+ });
125
+ compiler.hooks.afterCompile.tapPromise("KnarrWebpackPlugin", (compilation) => {
126
+ for (const pkg of watchedPackages) compilation.contextDependencies.add(join(nodeModulesDir, pkg));
127
+ return Promise.resolve();
128
+ });
129
+ compiler.hooks.watchClose.tap("KnarrWebpackPlugin", () => {
130
+ if (debounceTimer) {
131
+ clearTimeout(debounceTimer);
132
+ debounceTimer = null;
133
+ }
134
+ if (pollTimer) {
135
+ clearInterval(pollTimer);
136
+ pollTimer = void 0;
137
+ }
138
+ if (watcher) {
139
+ watcher.close().catch(() => {});
140
+ watcher = null;
141
+ }
142
+ });
143
+ }
143
144
  };
145
+ export { KnarrWebpackPlugin, KnarrWebpackPlugin as default };
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ import{r as e}from"./rolldown-runtime-BZbIAPMk.mjs";import{t}from"./picomatch-B0_Pxgms.mjs";import{D as n,c as r}from"./fs-CPnWm9CR.mjs";import{a as i,c as a,r as o,t as s}from"./json-DbSkpxtr.mjs";import{readFile as c,readdir as l}from"node:fs/promises";import{dirname as u,join as d,relative as f,resolve as p}from"node:path";var m=/* @__PURE__ */ e(t(),1);async function findWorkspaceRoot(e){let t=e;for(;;){if(await r(d(t,`pnpm-workspace.yaml`)))return t;let e=u(t);if(e===t)return null;t=e}}async function findWorkspacePackageRoot(e){return await findWorkspaceRoot(e)??await findPackageJsonWorkspaceRoot(e)}async function parseCatalogs(e){let t={default:i(),named:i()},n=d(e,`pnpm-workspace.yaml`),r;try{r=await c(n,`utf-8`)}catch{return t}let a=r.split(/\r?\n/),o=`top`,s=``;for(let e of a){if(e.trim()===``||e.trim().startsWith(`#`))continue;let n=e.length-e.trimStart().length;if(n===0){if(e.startsWith(`catalog:`)){o=`default-catalog`;continue}if(e.startsWith(`catalogs:`)){o=`named-catalogs`;continue}o=`top`}else if(o===`default-catalog`&&n>=2){let n=parseKeyValue(e);n&&(t.default[n[0]]=n[1])}else if(o===`named-catalogs`&&n>=2&&n<4){let n=e.trim();n.endsWith(`:`)&&(s=n.slice(0,-1),t.named[s]=i(),o=`named-catalog-entries`)}else if(o===`named-catalog-entries`&&n>=4){let n=parseKeyValue(e),r=s?t.named[s]:void 0;n&&r&&(r[n[0]]=n[1])}else if(o===`named-catalog-entries`&&n>=2&&n<4){let n=e.trim();n.endsWith(`:`)?(s=n.slice(0,-1),t.named[s]=i()):o=`named-catalogs`}}return t}async function findWorkspacePackages(e){let t=await findWorkspaceRoot(e);if(t){let e=await parsePnpmWorkspacePackages(t),n=e.filter(e=>!e.startsWith(`!`)),r=e.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(n.length>0)return resolveWorkspaceGlobs(t,n,r)}let n=t??await findPackageJsonWorkspaceRoot(e);if(!n)return[];try{let e=(await a(d(n,`package.json`))).workspaces,t=Array.isArray(e)?e:o(e)?e.packages:[],r=Array.isArray(t)?t.filter(e=>typeof e==`string`):[];return r.length===0?[]:resolveWorkspaceGlobs(n,r.filter(e=>!e.startsWith(`!`)),r.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1)))}catch{return[]}}async function parsePnpmWorkspacePackages(e){let t=d(e,`pnpm-workspace.yaml`),n;try{n=await c(t,`utf-8`)}catch{return[]}let r=[],i=!1;for(let e of n.split(/\r?\n/)){let t=e.trim();if(t===``||t.startsWith(`#`))continue;let n=e.length-e.trimStart().length;if(n===0)i=t===`packages:`;else if(i&&n>=2){let e=t.match(/^-\s+["']?([^"']+)["']?$/);e?.[1]&&r.push(e[1])}}return r}async function findPackageJsonWorkspaceRoot(e){let t=e;for(;;){try{if((await a(d(t,`package.json`))).workspaces)return t}catch{}let e=u(t);if(e===t)return null;t=e}}async function resolveWorkspaceGlobs(e,t,i=[]){let a=[];for(let i of t)if(i.includes(`*`)){let t=i.split(`/`),o=e,s=[],c=!1;for(let e of t)c||e.includes(`*`)?(c=!0,s.push(e)):o=d(o,e);if(s.length===1&&s[0]===`*`)try{let e=await l(o,{withFileTypes:!0});for(let t of e)if(t.isDirectory()){let e=d(o,t.name);await r(d(e,`package.json`))&&a.push(e)}}catch{}else{let t=(0,m.default)(i),o=await collectDirs(e,8);for(let i of o)t(n(f(e,i)))&&await r(d(i,`package.json`))&&a.push(i)}}else{let t=p(e,i);await r(d(t,`package.json`))&&a.push(t)}let o=[...new Set(a)];if(i.length===0)return o;let s=(0,m.default)(i);return o.filter(t=>{let r=n(f(e,t));return!s(r)})}async function collectDirs(e,t){if(t<=0)return[];let n=[];try{let r=await l(e,{withFileTypes:!0});for(let i of r){if(!i.isDirectory()||i.name===`node_modules`||i.name===`.git`)continue;let r=d(e,i.name);n.push(r),n.push(...await collectDirs(r,t-1))}}catch{}return n}async function buildWorkspaceGraph(e){let t=await findWorkspacePackages(e),n=[];for(let e of t)try{let t=s(await a(d(e,`package.json`)));t?.name&&t.version&&n.push({name:t.name,version:t.version,dir:e,pkg:t})}catch{}let r=new Set(n.map(e=>e.name)),i=/* @__PURE__ */ new Map;for(let e of n){let t=/* @__PURE__ */ new Set;for(let n of[`dependencies`,`devDependencies`]){let i=e.pkg[n];if(i)for(let e of Object.keys(i))r.has(e)&&t.add(e)}i.set(e.name,t)}return{packages:n,adjacency:i}}function filterPublishableWorkspaceGraph(e){let t=e.packages.filter(e=>!e.pkg.private),n=new Set(t.map(e=>e.name)),r=/* @__PURE__ */ new Map;for(let i of t){let t=e.adjacency.get(i.name)??/* @__PURE__ */ new Set;r.set(i.name,new Set([...t].filter(e=>n.has(e))))}return{packages:t,adjacency:r}}function buildReverseAdjacency(e){let t=/* @__PURE__ */ new Map;for(let n of e.keys())t.set(n,/* @__PURE__ */ new Set);for(let[n,r]of e)for(let e of r){let r=t.get(e);r||(r=/* @__PURE__ */ new Set,t.set(e,r)),r.add(n)}return t}function parseKeyValue(e){let t=e.trim(),n=t.indexOf(`:`);if(n<=0)return null;let r=t.slice(0,n).trim(),i=stripYamlInlineComment(t.slice(n+1)).trim();return!r||!i?null:[r.replace(/^["']|["']$/g,``),i.replace(/^["']|["']$/g,``)]}function stripYamlInlineComment(e){let t=null;for(let n=0;n<e.length;n++){let r=e[n];if((r===`"`||r===`'`)&&e[n-1]!==`\\`)t=t===r?null:t??r;else if(!t&&r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return e.slice(0,n)}return e}export{findWorkspacePackages as a,findWorkspacePackageRoot as i,buildWorkspaceGraph as n,findWorkspaceRoot as o,filterPublishableWorkspaceGraph as r,parseCatalogs as s,buildReverseAdjacency as t};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ export{t as buildReverseAdjacency,n as buildWorkspaceGraph,r as filterPublishableWorkspaceGraph,i as findWorkspacePackageRoot,a as findWorkspacePackages,s as parseCatalogs}from"./workspace-CdLSxPFS.mjs";
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ import"./rolldown-runtime-BZbIAPMk.mjs";const 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]);async function e(){return function(t){let{exports:{mem:n,xxh32:r,xxh64:i,init32:a,update32:o,digest32:s,init64:c,update64:l,digest64:u}}=t,p=new Uint8Array(n.buffer);function g(t,r){if(n.buffer.byteLength<t+r){let i=Math.ceil((t+r-n.buffer.byteLength)/65536);n.grow(i),p=new Uint8Array(n.buffer)}}function f(t,n,r,i,a,o){g(t);let s=new Uint8Array(t);return p.set(s),r(0,n),s.set(p.subarray(0,t)),{update(n){let r;return p.set(s),typeof n==`string`?(g(3*n.length,t),r=h.encodeInto(n,p.subarray(t)).written):(g(n.byteLength,t),p.set(n,t),r=n.byteLength),i(0,t,r),s.set(p.subarray(0,t)),this},digest:()=>(p.set(s),o(a(0)))}}function y(t){return t>>>0}let m=2n**64n-1n;function d(t){return t&m}let h=new TextEncoder,_=0n;function x(t,n=0){return g(3*t.length,0),y(r(0,h.encodeInto(t,p).written,n))}function L(t,n=_){return g(3*t.length,0),d(i(0,h.encodeInto(t,p).written,n))}return{h32:x,h32ToString:(t,n=0)=>x(t,n).toString(16).padStart(8,`0`),h32Raw:(t,n=0)=>(g(t.byteLength,0),p.set(t),y(r(0,t.byteLength,n))),create32:(t=0)=>f(48,t,a,o,s,y),h64:L,h64ToString:(t,n=_)=>L(t,n).toString(16).padStart(16,`0`),h64Raw:(t,n=_)=>(g(t.byteLength,0),p.set(t),d(i(0,t.byteLength,n))),create64:(t=_)=>f(88,t,c,l,u,d)}}((await WebAssembly.instantiate(t)).instance)}export{e as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knarr",
3
- "version": "0.1.3",
3
+ "version": "0.3.0",
4
4
  "description": "Copy local npm package builds into consumer node_modules with incremental sync and watch mode.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -39,14 +39,16 @@
39
39
  ],
40
40
  "sideEffects": false,
41
41
  "scripts": {
42
- "build": "tsup",
43
- "dev": "tsup --watch",
42
+ "build": "tsdown",
43
+ "dev": "tsdown --watch",
44
44
  "test": "vitest run",
45
45
  "test:watch": "vitest",
46
46
  "compat:smoke": "node scripts/compat-smoke.mjs",
47
- "bench": "vitest bench",
48
- "lint": "tsc --noEmit",
49
- "prepublishOnly": "pnpm build"
47
+ "bench": "vitest bench --reporter=verbose",
48
+ "lint": "pnpm typecheck && oxlint",
49
+ "prepublishOnly": "pnpm build",
50
+ "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.dts.json",
51
+ "lint:fix": "oxlint --fix"
50
52
  },
51
53
  "keywords": [
52
54
  "npm",
@@ -81,22 +83,26 @@
81
83
  "url": "https://github.com/oleg-kuibar/knarr/issues"
82
84
  },
83
85
  "author": "Oleg Kuibar (https://github.com/oleg-kuibar)",
84
- "packageManager": "pnpm@10.33.2",
86
+ "packageManager": "pnpm@12.18.0",
85
87
  "engines": {
86
- "node": ">=22.12.0"
88
+ "node": ">=22.22.0"
87
89
  },
88
90
  "devDependencies": {
89
- "@types/node": "^26.0.0",
91
+ "@arethetypeswrong/core": "^0.18.5",
92
+ "@types/node": "^26.6.6",
90
93
  "@types/picomatch": "^4.0.3",
91
- "tsup": "^8.5.1",
92
- "typescript": "^6.0.3",
93
- "vite": "^8.0.10",
94
- "vitest": "^4.1.5"
94
+ "oxlint": "^1.92.0",
95
+ "oxlint-tsgolint": "^7.0.2006",
96
+ "publint": "^0.3.25",
97
+ "tsdown": "^0.23.7",
98
+ "typescript": "^7.0.2",
99
+ "vite": "^8.3.6",
100
+ "vitest": "^5.1.0"
95
101
  },
96
102
  "peerDependencies": {
103
+ "@rspack/core": ">=0.5.0",
97
104
  "vite": ">=5.0.0",
98
- "webpack": ">=5.0.0",
99
- "@rspack/core": ">=0.5.0"
105
+ "webpack": ">=5.0.0"
100
106
  },
101
107
  "peerDependenciesMeta": {
102
108
  "vite": {
@@ -110,23 +116,9 @@
110
116
  }
111
117
  },
112
118
  "dependencies": {
113
- "chokidar": "^5.0.0",
119
+ "chokidar": "^6.0.0",
114
120
  "citty": "^0.2.2",
115
- "picocolors": "^1.1.1",
116
- "picomatch": "^4.0.4",
121
+ "picomatch": "^4.0.7",
117
122
  "xxhash-wasm": "^1.1.0"
118
- },
119
- "pnpm": {
120
- "overrides": {
121
- "dompurify": "^3.4.1",
122
- "esbuild": "^0.28.1",
123
- "fast-uri": "^3.1.2",
124
- "picomatch": "^4.0.4",
125
- "postcss": "^8.5.10",
126
- "rollup": "^4.59.0"
127
- },
128
- "onlyBuiltDependencies": [
129
- "esbuild"
130
- ]
131
123
  }
132
124
  }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';import {a}from'./chunk-K6OAYJKS.mjs';import'./chunk-KRX4JX6V.mjs';import'./chunk-QHNHLR6T.mjs';import'./chunk-RIHOZDFW.mjs';import'./chunk-XDWZZBCM.mjs';import'./chunk-WBTSRLB6.mjs';import'./chunk-QEH5VHRO.mjs';import'./chunk-N3B2JO4H.mjs';import'./chunk-WN3DOKIM.mjs';import'./chunk-MN4DV2NO.mjs';import {a as a$1}from'./chunk-HVN6HBWZ.mjs';import'./chunk-CBOYKBSM.mjs';import {b}from'./chunk-U6O35NZ7.mjs';import'./chunk-NGPAGRK4.mjs';import'./chunk-QFHYSC3K.mjs';import'./chunk-W2MMKBWU.mjs';import'./chunk-G7HFTV5Y.mjs';import'./chunk-BH2WXCLS.mjs';import'./chunk-E3HZCU3S.mjs';import'./chunk-SPHWZS5P.mjs';import'./chunk-OQDZJP55.mjs';import'./chunk-L7O2RSTN.mjs';globalThis.require=createRequire(import.meta.url);
3
- var s={meta:{name:"add",description:"Link a package from the Knarr store into this project"},args:{package:{type:"positional",description:"Package name to add",required:true},from:{type:"string",description:"Path to package source (will publish first)"},build:{type:"string",description:"Build command to run before publishing --from"},"skip-build":{type:"boolean",description:"Skip build detection before publishing --from",default:false},yes:{type:"boolean",alias:"y",description:"Auto-accept prompts (install missing deps, etc.)",default:false}},async run({args:e}){b(),await a({packageArg:e.package,from:e.from,build:e.build,skipBuild:e["skip-build"],yes:e.yes,timer:new a$1});}};export{s as default};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';export{a as ringBell}from'./chunk-J6HZHQVL.mjs';import'./chunk-L7O2RSTN.mjs';globalThis.require=createRequire(import.meta.url);
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';import {a as a$1}from'./chunk-IP5ROSRE.mjs';import {b,a as a$2}from'./chunk-U6O35NZ7.mjs';import'./chunk-NGPAGRK4.mjs';import'./chunk-E3HZCU3S.mjs';import'./chunk-SPHWZS5P.mjs';import {a,b as b$1}from'./chunk-OQDZJP55.mjs';import {c}from'./chunk-L7O2RSTN.mjs';import {resolve}from'path';globalThis.require=createRequire(import.meta.url);
3
- var o=c(a(),1);var y={meta:{name:"check",description:"Validate package configuration (exports, types, entry points)"},args:{dir:{type:"positional",description:"Package directory (default: current directory)",required:false}},async run({args:l}){b();let p=resolve(l.dir||"."),s=await a$1(p);if(s.length===0){b$1.success("All pre-flight checks passed"),a$2({issues:[],passed:true});return}let t=s.filter(e=>e.severity==="error"),i=s.filter(e=>e.severity==="warn");b$1.info(`Found ${s.length} issue(s):
4
- `);for(let e of t)b$1.log(` ${o.default.red("ERROR")} ${o.default.dim(`[${e.code}]`)} ${e.message}`);for(let e of i)b$1.log(` ${o.default.yellow("WARN")} ${o.default.dim(`[${e.code}]`)} ${e.message}`);t.length>0?b$1.error(`
5
- ${t.length} error(s), ${i.length} warning(s)`):b$1.warn(`
6
- ${i.length} warning(s)`),a$2({issues:s,passed:t.length===0});}};export{y as default};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';import {a}from'./chunk-L7O2RSTN.mjs';import {EventEmitter}from'events';import {unwatchFile,watchFile,watch,stat as stat$1}from'fs';import {lstat,stat,readdir,realpath,open}from'fs/promises';import*as u from'path';import {resolve,join,relative,sep}from'path';import {Readable}from'stream';import {type}from'os';globalThis.require=createRequire(import.meta.url);
3
- var g={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},k={root:".",fileFilter:a(r=>true,"fileFilter"),directoryFilter:a(r=>true,"directoryFilter"),type:g.FILE_TYPE,lstat:false,depth:2147483648,alwaysStat:false,highWaterMark:4096};Object.freeze(k);var J="READDIRP_RECURSIVE_ERROR",gt=new Set(["ENOENT","EPERM","EACCES","ELOOP",J]),B=[g.DIR_TYPE,g.EVERYTHING_TYPE,g.FILE_DIR_TYPE,g.FILE_TYPE],yt=new Set([g.DIR_TYPE,g.EVERYTHING_TYPE,g.FILE_DIR_TYPE]),Pt=new Set([g.EVERYTHING_TYPE,g.FILE_DIR_TYPE,g.FILE_TYPE]),Rt=a(r=>gt.has(r.code),"isNormalFlowError"),bt=process.platform==="win32",$=a(r=>true,"emptyFn"),q=a(r=>{if(r===void 0)return $;if(typeof r=="function")return r;if(typeof r=="string"){let t=r.trim();return e=>e.basename===t}if(Array.isArray(r)){let t=r.map(e=>e.trim());return e=>t.some(i=>e.basename===i)}return $},"normalizeFilter"),L=class extends Readable{static{a(this,"ReaddirpStream");}parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(t={}){super({objectMode:true,autoDestroy:true,highWaterMark:t.highWaterMark});let e={...k,...t},{root:i,type:s}=e;this._fileFilter=q(e.fileFilter),this._directoryFilter=q(e.directoryFilter);let n=e.lstat?lstat:stat;bt?this._stat=h=>n(h,{bigint:true}):this._stat=n,this._maxDepth=e.depth!=null&&Number.isSafeInteger(e.depth)?e.depth:k.depth,this._wantsDir=s?yt.has(s):false,this._wantsFile=s?Pt.has(s):false,this._wantsEverything=s===g.EVERYTHING_TYPE,this._root=resolve(i),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=false,this.parent=void 0;}async _read(t){if(!this.reading){this.reading=true;try{for(;!this.destroyed&&t>0;){let e=this.parent,i=e&&e.files;if(i&&i.length>0){let{path:s,depth:n}=e,h=i.splice(0,t).map(a=>this._formatEntry(a,s)),o=await Promise.all(h);for(let a of o){if(!a)continue;if(this.destroyed)return;let c=await this._getEntryType(a);c==="directory"&&this._directoryFilter(a)?(n<=this._maxDepth&&this.parents.push(this._exploreDir(a.fullPath,n+1)),this._wantsDir&&(this.push(a),t--)):(c==="file"||this._includeAsFile(a))&&this._fileFilter(a)&&this._wantsFile&&(this.push(a),t--);}}else {let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(e){this.destroy(e);}finally{this.reading=false;}}}async _exploreDir(t,e){let i;try{i=await readdir(t,this._rdOptions);}catch(s){this._onError(s);}return {files:i,depth:e,path:t}}async _formatEntry(t,e){let i,s=this._isDirent?t.name:t;try{let n=resolve(join(e,s));i={path:relative(this._root,n),fullPath:n,basename:s},i[this._statsProp]=this._isDirent?t:await this._stat(n);}catch(n){this._onError(n);return}return i}_onError(t){Rt(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t);}async _getEntryType(t){if(!t&&this._statsProp in t)return "";let e=t[this._statsProp];if(e.isFile())return "file";if(e.isDirectory())return "directory";if(e&&e.isSymbolicLink()){let i=t.fullPath;try{let s=await realpath(i),n=await lstat(s);if(n.isFile())return "file";if(n.isDirectory()){let h=s.length;if(i.startsWith(s)&&i.substr(h,1)===sep){let o=new Error(`Circular symlink detected: "${i}" points to "${s}"`);return o.code=J,this._onError(o)}return "directory"}}catch(s){return this._onError(s),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function Q(r,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=g.FILE_DIR_TYPE),e&&(t.type=e),r){if(typeof r!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!B.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${B.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=r,new L(t)}a(Q,"readdirp");var Ft="data",z="end",et="close",S=a(()=>{},"EMPTY_FN");var A=process.platform,H=A==="win32",St=A==="darwin",At=A==="linux",Wt=A==="freebsd",st=type()==="OS400",m={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},y=m,Nt="watch",kt={lstat:lstat,stat:stat},R="listeners",T="errHandlers",b="rawEmitters",Lt=[R,T,b],Ct=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Ot=a(r=>Ct.has(u.extname(r).slice(1).toLowerCase()),"isBinaryPath"),M=a((r,t)=>{r instanceof Set?r.forEach(t):t(r);},"foreach"),D=a((r,t,e)=>{let i=r[t];i instanceof Set||(r[t]=i=new Set([i])),i.add(e);},"addAndConvert"),Mt=a(r=>t=>{let e=r[t];e instanceof Set?e.clear():delete r[t];},"clearItem"),I=a((r,t,e)=>{let i=r[t];i instanceof Set?i.delete(e):i===e&&delete r[t];},"delFromSet"),it=a(r=>r instanceof Set?r.size===0:!r,"isEmptySet"),v=new Map;function Z(r,t,e,i,s){let n=a((h,o)=>{e(r),s(h,o,{watchedPath:r}),o&&r!==o&&x(u.resolve(r,o),R,u.join(r,o));},"handleEvent");try{return watch(r,{persistent:t.persistent},n)}catch(h){i(h);return}}a(Z,"createFsWatchInstance");var x=a((r,t,e,i,s)=>{let n=v.get(r);n&&M(n[t],h=>{h(e,i,s);});},"fsWatchBroadcast"),zt=a((r,t,e,i)=>{let{listener:s,errHandler:n,rawEmitter:h}=i,o=v.get(t),a;if(!e.persistent)return a=Z(r,e,s,n,h),a?a.close.bind(a):void 0;if(o)D(o,R,s),D(o,T,n),D(o,b,h);else {if(a=Z(r,e,x.bind(null,t,R),n,x.bind(null,t,b)),!a)return;a.on(y.ERROR,async c=>{let d=x.bind(null,t,T);if(o&&(o.watcherUnusable=true),H&&c.code==="EPERM")try{await(await open(r,"r")).close(),d(c);}catch{}else d(c);}),o={listeners:s,errHandlers:n,rawEmitters:h,watcher:a},v.set(t,o);}return ()=>{I(o,R,s),I(o,T,n),I(o,b,h),it(o.listeners)&&(o.watcher.close(),v.delete(t),Lt.forEach(Mt(o)),o.watcher=void 0,Object.freeze(o));}},"setFsWatchListener"),O=new Map,Ht=a((r,t,e,i)=>{let{listener:s,rawEmitter:n}=i,h=O.get(t),o=h&&h.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&(unwatchFile(t),h=void 0),h?(D(h,R,s),D(h,b,n)):(h={listeners:s,rawEmitters:n,options:e,watcher:watchFile(t,e,(a,c)=>{M(h.rawEmitters,_=>{_(y.CHANGE,t,{curr:a,prev:c});});let d=a.mtimeMs;(a.size!==c.size||d>c.mtimeMs||d===0)&&M(h.listeners,_=>_(r,a));})},O.set(t,h)),()=>{I(h,R,s),I(h,b,n),it(h.listeners)&&(O.delete(t),unwatchFile(t),h.options=h.watcher=void 0,Object.freeze(h));}},"setFsWatchFileListener"),F=class{static{a(this,"NodeFsHandler");}fsw;_boundHandleError;constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e);}_watchWithNodeFs(t,e){let i=this.fsw.options,s=u.dirname(t),n=u.basename(t);this.fsw._getWatchedDir(s).add(n);let o=u.resolve(t),a={persistent:i.persistent};e||(e=S);let c;if(i.usePolling){let d=i.interval!==i.binaryInterval;a.interval=d&&Ot(n)?i.binaryInterval:i.interval,c=Ht(t,o,a,{listener:e,rawEmitter:this.fsw._emitRaw});}else c=zt(t,o,a,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return c}_handleFile(t,e,i){if(this.fsw.closed)return;let s=u.dirname(t),n=u.basename(t),h=this.fsw._getWatchedDir(s),o=e;if(h.has(n))return;let a$1=a(async(d,_)=>{if(this.fsw._throttle(Nt,t,5)){if(!_||_.mtimeMs===0)try{let f=await stat(t);if(this.fsw.closed)return;let w=f.atimeMs,E=f.mtimeMs;if((!w||w<=E||E!==o.mtimeMs)&&this.fsw._emit(y.CHANGE,t,f),(St||At||Wt)&&o.ino!==f.ino){this.fsw._closeFile(d),o=f;let P=this._watchWithNodeFs(t,a$1);P&&this.fsw._addPathCloser(d,P);}else o=f;}catch{this.fsw._remove(s,n);}else if(h.has(n)){let f=_.atimeMs,w=_.mtimeMs;(!f||f<=w||w!==o.mtimeMs)&&this.fsw._emit(y.CHANGE,t,_),o=_;}}},"listener"),c=this._watchWithNodeFs(t,a$1);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(y.ADD,t,0))return;this.fsw._emit(y.ADD,t,e);}return c}async _handleSymlink(t,e,i,s){if(this.fsw.closed)return;let n=t.fullPath,h=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await realpath(i);}catch{return this.fsw._emitReady(),true}return this.fsw.closed?void 0:(h.has(s)?this.fsw._symlinkPaths.get(n)!==o&&(this.fsw._symlinkPaths.set(n,o),this.fsw._emit(y.CHANGE,i,t.stats)):(h.add(s),this.fsw._symlinkPaths.set(n,o),this.fsw._emit(y.ADD,i,t.stats)),this.fsw._emitReady(),true)}if(this.fsw._symlinkPaths.has(n))return true;this.fsw._symlinkPaths.set(n,true);}_handleRead(t,e,i,s,n,h,o){t=u.join(t,"");let a$1=s?`${t}:${s}`:t;if(o=this.fsw._throttle("readdir",a$1,1e3),!o)return;let c=this.fsw._getWatchedDir(i.path),d=new Set,_=this.fsw._readdirp(t,{fileFilter:a(f=>i.filterPath(f),"fileFilter"),directoryFilter:a(f=>i.filterDir(f),"directoryFilter")});if(_)return _.on(Ft,async f=>{if(this.fsw.closed){_=void 0;return}let w=f.path,E=u.join(t,w);if(d.add(w),!(f.stats.isSymbolicLink()&&await this._handleSymlink(f,t,E,w))){if(this.fsw.closed){_=void 0;return}(w===s||!s&&!c.has(w))&&(this.fsw._incrReadyCount(),E=u.join(n,u.relative(n,E)),this._addToNodeFs(E,e,i,h+1));}}).on(y.ERROR,this._boundHandleError),new Promise((f,w)=>{if(!_)return w();_.once(z,()=>{if(this.fsw.closed){_=void 0;return}let E=o?o.clear():false;f(void 0),c.getChildren().filter(P=>P!==t&&!d.has(P)).forEach(P=>{this.fsw._remove(t,P);}),_=void 0,E&&this._handleRead(t,false,i,s,n,h,o);});})}async _handleDir(t,e,i,s,n,h,o){let a=this.fsw._getWatchedDir(u.dirname(t)),c=a.has(u.basename(t));!(i&&this.fsw.options.ignoreInitial)&&!n&&!c&&this.fsw._emit(y.ADD_DIR,t,e),a.add(u.basename(t)),this.fsw._getWatchedDir(t);let d,_,f=this.fsw.options.depth;if((f==null||s<=f)&&!this.fsw._symlinkPaths.has(o)){if(!n&&(await this._handleRead(t,i,h,n,t,s,d),this.fsw.closed))return;_=this._watchWithNodeFs(t,(w,E)=>{E&&E.mtimeMs===0||this._handleRead(w,false,h,n,t,s,d);});}return _}async _addToNodeFs(t,e,i,s,n){let h=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return h(),false;let o=this.fsw._getWatchHelpers(t);i&&(o.filterPath=a=>i.filterPath(a),o.filterDir=a=>i.filterDir(a));try{let a=await kt[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,a))return h(),!1;let c=this.fsw.options.followSymlinks,d;if(a.isDirectory()){let _=u.resolve(t),f=c?await realpath(t):t;if(this.fsw.closed||(d=await this._handleDir(o.watchPath,a,e,s,n,o,f),this.fsw.closed))return;_!==f&&f!==void 0&&this.fsw._symlinkPaths.set(_,f);}else if(a.isSymbolicLink()){let _=c?await realpath(t):t;if(this.fsw.closed)return;let f=u.dirname(o.watchPath);if(this.fsw._getWatchedDir(f).add(o.watchPath),this.fsw._emit(y.ADD,o.watchPath,a),d=await this._handleDir(f,a,e,s,t,o,_),this.fsw.closed)return;_!==void 0&&this.fsw._symlinkPaths.set(u.resolve(t),_);}else d=this._handleFile(o.watchPath,a,e);return h(),d&&this.fsw._addPathCloser(t,d),!1}catch(a){if(this.fsw._handleError(a))return h(),t}}};var j="/",Kt="//",ht=".",Vt="..",Bt="string",$t=/\\/g,lt=/\/\//g,qt=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Jt=/^\.[/\\]/;function W(r){return Array.isArray(r)?r:[r]}a(W,"arrify");var Y=a(r=>typeof r=="object"&&r!==null&&!(r instanceof RegExp),"isMatcherObject");function Qt(r){return typeof r=="function"?r:typeof r=="string"?t=>r===t:r instanceof RegExp?t=>r.test(t):typeof r=="object"&&r!==null?t=>{if(r.path===t)return true;if(r.recursive){let e=u.relative(r.path,t);return e?!e.startsWith("..")&&!u.isAbsolute(e):false}return false}:()=>false}a(Qt,"createPattern");function Xt(r){if(typeof r!="string")throw new Error("string expected");r=u.normalize(r),r=r.replace(/\\/g,"/");let t=false;return r.startsWith("//")&&(t=true),r=r.replace(lt,"/"),t&&(r="/"+r),r}a(Xt,"normalizePath");function rt(r,t,e){let i=Xt(t);for(let s=0;s<r.length;s++){let n=r[s];if(n(i,e))return true}return false}a(rt,"matchPatterns");function Zt(r,t){if(r==null)throw new TypeError("anymatch: specify first argument");let i=W(r).map(s=>Qt(s));return t==null?(s,n)=>rt(i,s,n):rt(i,t)}a(Zt,"anymatch");var nt=a(r=>{let t=W(r).flat();if(!t.every(e=>typeof e===Bt))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(ct)},"unifyPaths"),ot=a(r=>{let t=r.replace($t,j),e=false;return t.startsWith(Kt)&&(e=true),t=t.replace(lt,j),e&&(t=j+t),t},"toUnix"),ct=a(r=>ot(u.normalize(ot(r))),"normalizePathToUnix"),at=a((r="")=>t=>typeof t=="string"?ct(u.isAbsolute(t)?t:u.join(r,t)):t,"normalizeIgnored"),te=a((r,t)=>u.isAbsolute(r)?r:u.join(t,r),"getAbsolutePath"),ee=Object.freeze(new Set),U=class{static{a(this,"DirEntry");}path;_removeWatcher;items;constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set;}add(t){let{items:e}=this;e&&t!==ht&&t!==Vt&&e.add(t);}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let i=this.path;try{await readdir(i);}catch{this._removeWatcher&&this._removeWatcher(u.dirname(i),u.basename(i));}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=S,this.items=ee,Object.freeze(this);}},se="stat",ie="lstat",G=class{static{a(this,"WatchHelper");}fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(t,e,i){this.fsw=i;let s=t;this.path=t=t.replace(Jt,""),this.watchPath=s,this.fullWatchPath=u.resolve(s),this.dirParts=[],this.dirParts.forEach(n=>{n.length>1&&n.pop();}),this.followSymlinks=e,this.statMethod=e?se:ie;}entryPath(t){return u.join(this.watchPath,u.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},N=class extends EventEmitter{static{a(this,"FSWatcher");}closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(t={}){super(),this.closed=false,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=false;let e=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},s={persistent:true,ignoreInitial:false,ignorePermissionErrors:false,interval:100,binaryInterval:300,followSymlinks:true,usePolling:false,atomic:true,...t,ignored:t.ignored?W(t.ignored):W([]),awaitWriteFinish:e===true?i:typeof e=="object"?{...i,...e}:false};st&&(s.usePolling=true),s.atomic===void 0&&(s.atomic=!s.usePolling);let n=process.env.CHOKIDAR_USEPOLLING;if(n!==void 0){let a=n.toLowerCase();a==="false"||a==="0"?s.usePolling=false:a==="true"||a==="1"?s.usePolling=true:s.usePolling=!!a;}let h=process.env.CHOKIDAR_INTERVAL;h&&(s.interval=Number.parseInt(h,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=S,this._readyEmitted=true,process.nextTick(()=>this.emit(m.READY)));},this._emitRaw=(...a)=>this.emit(m.RAW,...a),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new F(this),Object.freeze(s);}_addIgnoredPath(t){if(Y(t)){for(let e of this._ignoredPaths)if(Y(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t);}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)Y(e)&&e.path===t&&this._ignoredPaths.delete(e);}add(t,e,i){let{cwd:s}=this.options;this.closed=false,this._closePromise=void 0;let n=nt(t);return s&&(n=n.map(h=>te(h,s))),n.forEach(h=>{this._removeIgnoredPath(h);}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=n.length,Promise.all(n.map(async h=>{let o=await this._nodeFsHandler._addToNodeFs(h,!i,void 0,0,e);return o&&this._emitReady(),o})).then(h=>{this.closed||h.forEach(o=>{o&&this.add(u.dirname(o),u.basename(e||o));});}),this}unwatch(t){if(this.closed)return this;let e=nt(t),{cwd:i}=this.options;return e.forEach(s=>{!u.isAbsolute(s)&&!this._closers.has(s)&&(i&&(s=u.join(i,s)),s=u.resolve(s)),this._closePath(s),this._addIgnoredPath(s),this._watched.has(s)&&this._addIgnoredPath({path:s,recursive:true}),this._userIgnored=void 0;}),this}close(){if(this._closePromise)return this._closePromise;this.closed=true,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(i=>{let s=i();s instanceof Promise&&t.push(s);})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=false,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,i)=>{let n=(this.options.cwd?u.relative(this.options.cwd,i):i)||ht;t[n]=e.getChildren().sort();}),t}emitWithAll(t,e){this.emit(t,...e),t!==m.ERROR&&this.emit(m.ALL,t,...e);}async _emit(t,e,i){if(this.closed)return;let s=this.options;H&&(e=u.normalize(e)),s.cwd&&(e=u.relative(s.cwd,e));let n=[e];i!=null&&n.push(i);let h=s.awaitWriteFinish,o;if(h&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(s.atomic){if(t===m.UNLINK)return this._pendingUnlinks.set(e,[t,...n]),setTimeout(()=>{this._pendingUnlinks.forEach((a,c)=>{this.emit(...a),this.emit(m.ALL,...a),this._pendingUnlinks.delete(c);});},typeof s.atomic=="number"?s.atomic:100),this;t===m.ADD&&this._pendingUnlinks.has(e)&&(t=m.CHANGE,this._pendingUnlinks.delete(e));}if(h&&(t===m.ADD||t===m.CHANGE)&&this._readyEmitted){let a$1=a((c,d)=>{c?(t=m.ERROR,n[0]=c,this.emitWithAll(t,n)):d&&(n.length>1?n[1]=d:n.push(d),this.emitWithAll(t,n));},"awfEmit");return this._awaitWriteFinish(e,h.stabilityThreshold,t,a$1),this}if(t===m.CHANGE&&!this._throttle(m.CHANGE,e,50))return this;if(s.alwaysStat&&i===void 0&&(t===m.ADD||t===m.ADD_DIR||t===m.CHANGE)){let a=s.cwd?u.join(s.cwd,e):e,c;try{c=await stat(a);}catch{}if(!c||this.closed)return;n.push(c);}return this.emitWithAll(t,n),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(m.ERROR,t),t||this.closed}_throttle(t,e,i){this._throttled.has(t)||this._throttled.set(t,new Map);let s=this._throttled.get(t);if(!s)throw new Error("invalid throttle");let n=s.get(e);if(n)return n.count++,false;let h,o=a(()=>{let c=s.get(e),d=c?c.count:0;return s.delete(e),clearTimeout(h),c&&clearTimeout(c.timeoutObject),d},"clear");h=setTimeout(o,i);let a$1={timeoutObject:h,clear:o,count:0};return s.set(e,a$1),a$1}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,i,s){let n=this.options.awaitWriteFinish;if(typeof n!="object")return;let h=n.pollInterval,o,a$1=t;this.options.cwd&&!u.isAbsolute(t)&&(a$1=u.join(this.options.cwd,t));let c=new Date,d=this._pendingWrites;function _(f){stat$1(a$1,(w,E)=>{if(w||!d.has(t)){w&&w.code!=="ENOENT"&&s(w);return}let P=Number(new Date);f&&E.size!==f.size&&(d.get(t).lastChange=P);let dt=d.get(t);P-dt.lastChange>=e?(d.delete(t),s(void 0,E)):o=setTimeout(_,h,E);});}a(_,"awaitWriteFinishFn"),d.has(t)||(d.set(t,{lastChange:c,cancelWait:a(()=>(d.delete(t),clearTimeout(o),i),"cancelWait")}),o=setTimeout(_,h));}_isIgnored(t,e){if(this.options.atomic&&qt.test(t))return true;if(!this._userIgnored){let{cwd:i}=this.options,n=(this.options.ignored||[]).map(at(i)),o=[...[...this._ignoredPaths].map(at(i)),...n];this._userIgnored=Zt(o,void 0);}return this._userIgnored(t,e)}_isntIgnored(t,e){return !this._isIgnored(t,e)}_getWatchHelpers(t){return new G(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=u.resolve(t);return this._watched.has(e)||this._watched.set(e,new U(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?true:!!(Number(t.mode)&256)}_remove(t,e,i){let s=u.join(t,e),n=u.resolve(s);if(i=i??(this._watched.has(s)||this._watched.has(n)),!this._throttle("remove",s,100))return;!i&&this._watched.size===1&&this.add(t,e,true),this._getWatchedDir(s).getChildren().forEach(f=>this._remove(s,f));let a=this._getWatchedDir(t),c=a.has(e);a.remove(e),this._symlinkPaths.has(n)&&this._symlinkPaths.delete(n);let d=s;if(this.options.cwd&&(d=u.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(d)&&this._pendingWrites.get(d).cancelWait()===m.ADD)return;this._watched.delete(s),this._watched.delete(n);let _=i?m.UNLINK_DIR:m.UNLINK;c&&!this._isIgnored(s)&&this._emit(_,s),this._closePath(s);}_closePath(t){this._closeFile(t);let e=u.dirname(t);this._getWatchedDir(e).remove(u.basename(t));}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(i=>i()),this._closers.delete(t));}_addPathCloser(t,e){if(!e)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(e);}_readdirp(t,e){if(this.closed)return;let i={type:m.ALL,alwaysStat:true,lstat:true,...e,depth:0},s=Q(t,i);return this._streams.add(s),s.once(et,()=>{s=void 0;}),s.once(z,()=>{s&&(this._streams.delete(s),s=void 0);}),s}};function re(r,t={}){let e=new N(t);return e.add(r),e}a(re,"watch");var be={watch:re,FSWatcher:N};
4
- export{N as FSWatcher,G as WatchHelper,be as default,re as watch};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';import {G}from'./chunk-BH2WXCLS.mjs';import {d}from'./chunk-SPHWZS5P.mjs';import {a}from'./chunk-L7O2RSTN.mjs';import {readFile}from'fs/promises';import {join}from'path';globalThis.require=createRequire(import.meta.url);
3
- async function l(o){try{let i=await readFile(join(o,"package.json"),"utf-8"),t=JSON.parse(i).knarr;if(!t||typeof t!="object")return {};let r={},n=t;return typeof n.buildCmd=="string"&&(r.buildCmd=n.buildCmd),Array.isArray(n.watchPatterns)&&(r.watchPatterns=n.watchPatterns.filter(u=>typeof u=="string")),typeof n.debounce=="number"&&Number.isFinite(n.debounce)&&(r.debounce=n.debounce),typeof n.cooldown=="number"&&Number.isFinite(n.cooldown)&&(r.cooldown=n.cooldown),typeof n.historyLimit=="number"&&Number.isFinite(n.historyLimit)&&(r.historyLimit=Math.max(0,Math.floor(n.historyLimit))),typeof n.notify=="boolean"&&(r.notify=n.notify),d(`[config] Loaded knarr config from package.json: ${JSON.stringify(r)}`),r}catch{return {}}}a(l,"loadKnarrConfig");async function g(o,i){if(!i)return false;let e=await readFile(o,"utf-8"),t=JSON.parse(e),r=t.knarr;if(r&&typeof r=="object"&&typeof r.buildCmd=="string")return false;t.knarr=r&&typeof r=="object"?r:{},t.knarr.buildCmd=i;let n=e.match(/^(\s+)"/m)?.[1]||" ";return await G(o,JSON.stringify(t,null,n)+`
4
- `),true}a(g,"setKnarrBuildCmdIfMissing");export{l as a,g as b};
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';import {a}from'./chunk-G7HFTV5Y.mjs';import {F,t}from'./chunk-BH2WXCLS.mjs';import {c,a as a$1}from'./chunk-L7O2RSTN.mjs';import {readFile,readdir}from'fs/promises';import {join,dirname,relative,resolve}from'path';globalThis.require=createRequire(import.meta.url);
3
- var w=c(a(),1);async function v(n){let t=n;for(;;){if(await F(join(t,"pnpm-workspace.yaml")))return t;let e=dirname(t);if(e===t)return null;t=e;}}a$1(v,"findWorkspaceRoot");async function K(n){return await v(n)??await b(n)}a$1(K,"findWorkspacePackageRoot");async function T(n){let t={default:{},named:{}},e=join(n,"pnpm-workspace.yaml"),a;try{a=await readFile(e,"utf-8");}catch{return t}let i=a.split(/\r?\n/),s="top",r="";for(let o of i){if(o.trim()===""||o.trim().startsWith("#"))continue;let l=o.length-o.trimStart().length;if(l===0){if(o.startsWith("catalog:")){s="default-catalog";continue}if(o.startsWith("catalogs:")){s="named-catalogs";continue}s="top";continue}if(s==="default-catalog"&&l>=2){let c=S(o);c&&(t.default[c[0]]=c[1]);continue}if(s==="named-catalogs"&&l>=2&&l<4){let c=o.trim();c.endsWith(":")&&(r=c.slice(0,-1),t.named[r]={},s="named-catalog-entries");continue}if(s==="named-catalog-entries"&&l>=4){let c=S(o);c&&r&&(t.named[r][c[0]]=c[1]);continue}if(s==="named-catalog-entries"&&l>=2&&l<4){let c=o.trim();c.endsWith(":")?(r=c.slice(0,-1),t.named[r]={}):s="named-catalogs";continue}}return t}a$1(T,"parseCatalogs");async function N(n){let t=await v(n);if(t){let a=await O(t),i=a.filter(r=>!r.startsWith("!")),s=a.filter(r=>r.startsWith("!")).map(r=>r.slice(1));if(i.length>0)return W(t,i,s)}let e=t??await b(n);if(!e)return [];try{let a=JSON.parse(await readFile(join(e,"package.json"),"utf-8")),i=Array.isArray(a.workspaces)?a.workspaces:a.workspaces?.packages??[];if(i.length===0)return [];let s=i.filter(o=>!o.startsWith("!")),r=i.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return W(e,s,r)}catch{return []}}a$1(N,"findWorkspacePackages");async function O(n){let t=join(n,"pnpm-workspace.yaml"),e;try{e=await readFile(t,"utf-8");}catch{return []}let a=[],i=false;for(let s of e.split(/\r?\n/)){let r=s.trim();if(r===""||r.startsWith("#"))continue;let o=s.length-s.trimStart().length;if(o===0){i=r==="packages:";continue}if(i&&o>=2){let l=r.match(/^-\s+["']?([^"']+)["']?$/);l&&a.push(l[1]);}}return a}a$1(O,"parsePnpmWorkspacePackages");async function b(n){let t=n;for(;;){try{if(JSON.parse(await readFile(join(t,"package.json"),"utf-8")).workspaces)return t}catch{}let e=dirname(t);if(e===t)return null;t=e;}}a$1(b,"findPackageJsonWorkspaceRoot");async function W(n,t$1,e=[]){let a=[];for(let r of t$1)if(r.includes("*")){let o=r.split("/"),l=n,c=[],y=false;for(let g of o)y||g.includes("*")?(y=true,c.push(g)):l=join(l,g);if(c.length===1&&c[0]==="*")try{let g=await readdir(l,{withFileTypes:!0});for(let k of g)if(k.isDirectory()){let u=join(l,k.name);await F(join(u,"package.json"))&&a.push(u);}}catch{}else {let g=(0, w.default)(r),k=await G(n,8);for(let u of k){let M=t(relative(n,u));g(M)&&await F(join(u,"package.json"))&&a.push(u);}}}else {let o=resolve(n,r);await F(join(o,"package.json"))&&a.push(o);}let i=[...new Set(a)];if(e.length===0)return i;let s=(0, w.default)(e);return i.filter(r=>{let o=t(relative(n,r));return !s(o)})}a$1(W,"resolveWorkspaceGlobs");async function G(n,t){if(t<=0)return [];let e=[];try{let a=await readdir(n,{withFileTypes:!0});for(let i of a){if(!i.isDirectory()||i.name==="node_modules"||i.name===".git")continue;let s=join(n,i.name);e.push(s),e.push(...await G(s,t-1));}}catch{}return e}a$1(G,"collectDirs");async function z(n){let t=await N(n),e=[];for(let s of t)try{let r=JSON.parse(await readFile(join(s,"package.json"),"utf-8"));r.name&&r.version&&e.push({name:r.name,version:r.version,dir:s,pkg:r});}catch{}let a=new Set(e.map(s=>s.name)),i=new Map;for(let s of e){let r=new Set;for(let o of ["dependencies","devDependencies"]){let l=s.pkg[o];if(l)for(let c of Object.keys(l))a.has(c)&&r.add(c);}i.set(s.name,r);}return {packages:e,adjacency:i}}a$1(z,"buildWorkspaceGraph");function E(n){let t=n.packages.filter(i=>!i.pkg.private),e=new Set(t.map(i=>i.name)),a=new Map;for(let i of t){let s=n.adjacency.get(i.name)??new Set;a.set(i.name,new Set([...s].filter(r=>e.has(r))));}return {packages:t,adjacency:a}}a$1(E,"filterPublishableWorkspaceGraph");function V(n){let t=new Map;for(let e of n.keys())t.set(e,new Set);for(let[e,a]of n)for(let i of a){let s=t.get(i);s||(s=new Set,t.set(i,s)),s.add(e);}return t}a$1(V,"buildReverseAdjacency");function S(n){let t=n.trim(),e=t.indexOf(":");if(e<=0)return null;let a=t.slice(0,e).trim(),i=q(t.slice(e+1)).trim();if(!a||!i)return null;let s=a.replace(/^["']|["']$/g,""),r=i.replace(/^["']|["']$/g,"");return [s,r]}a$1(S,"parseKeyValue");function q(n){let t=null;for(let e=0;e<n.length;e++){let a=n[e];if((a==='"'||a==="'")&&n[e-1]!=="\\"){t=t===a?null:t??a;continue}if(!t&&a==="#"&&(e===0||/\s/.test(n[e-1])))return n.slice(0,e)}return n}a$1(q,"stripYamlInlineComment");export{v as a,K as b,T as c,N as d,z as e,E as f,V as g};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';import {a as a$1}from'./chunk-E3HZCU3S.mjs';import {d,b as b$1}from'./chunk-SPHWZS5P.mjs';import {b}from'./chunk-OQDZJP55.mjs';import {a}from'./chunk-L7O2RSTN.mjs';import {readFile,stat,mkdir,copyFile,constants,readdir,rm,utimes,rename,cp,writeFile}from'fs/promises';import {join,resolve,relative,isAbsolute,parse,dirname}from'path';import {availableParallelism,homedir}from'os';import {createHash}from'crypto';globalThis.require=createRequire(import.meta.url);
3
- function R(t){let e=0,r=[],n=0,i=a(()=>{n<r.length&&e<t&&(e++,r[n++]()),n>0&&n===r.length&&(r.length=0,n=0);},"next");return a$1=>new Promise((p,w)=>{let g=a(()=>{a$1().then(P=>{e--,p(P),i();},P=>{e--,w(P),i();});},"run");e<t?(e++,g()):r.push(g);})}a(R,"pLimit");var ot=/^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/,it=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,B=/[\x00-\x1F\x7F]/;function $(t){if(!t||t.length>214||B.test(t)||t.includes("\\")||t.includes("//")||t.split("/").some(e=>e==="."||e==="..")||!ot.test(t))throw new Error(`Invalid package name "${t}"`)}a($,"validatePackageName");function st(t){if(!t||B.test(t)||t.includes("/")||t.includes("\\")||t.includes("..")||!it.test(t))throw new Error(`Invalid package version "${t}"`)}a(st,"validatePackageVersion");function X(t,e){$(t),st(e);}a(X,"validatePackageIdentity");function Ft(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.contentHash=="string"&&typeof e.publishedAt=="string"&&typeof e.sourcePath=="string"&&(e.buildId===void 0||typeof e.buildId=="string")&&(e.schemaVersion===void 0||typeof e.schemaVersion=="number")}a(Ft,"isKnarrMeta");function at(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.version=="string"&&typeof e.contentHash=="string"&&typeof e.linkedAt=="string"&&typeof e.sourcePath=="string"&&typeof e.backupExists=="boolean"&&typeof e.packageManager=="string"&&["npm","pnpm","yarn","bun"].includes(e.packageManager)&&(e.buildId===void 0||typeof e.buildId=="string")}a(at,"isLinkEntry");function Ht(t){if(typeof t!="object"||t===null)return false;let e=t;if(e.version!=="1"||typeof e.links!="object"||e.links===null)return false;let r=e.links;for(let n of Object.values(r))if(!at(n))return false;return true}a(Ht,"isConsumerState");async function Nt(t,e,r){try{let n=await readFile(join(t,"package.json"),"utf-8"),i=JSON.parse(n),a=i.dependencies?.[e]??i.devDependencies?.[e]??i.peerDependencies?.[e];if(!a||/^(workspace:|catalog:|\*)/.test(a))return;let p=a.match(/(\d+)\.\d+\.\d+/);if(!p)return;let w=parseInt(p[1],10),g=parseInt(r.split(".")[0],10);w!==g&&b.warn(`Version mismatch: store has ${e}@${r} but your package.json declares "${a}". Consider updating your dependency range.`);}catch{}}a(Nt,"warnVersionMismatch");function Tt(t){if(typeof t!="object"||t===null)return false;let e=t;for(let r of Object.values(e)){if(!Array.isArray(r))return false;for(let n of r)if(typeof n!="string")return false}return true}a(Tt,"isConsumersRegistry");function O(t,e,r){let n=resolve(t),i=resolve(e),a=relative(n,i);if(!(a===""||!a.startsWith("..")&&!isAbsolute(a)))throw new Error(`${r} escapes expected directory: ${e}`)}a(O,"assertInside");function V(){return process.env.KNARR_HOME||join(homedir(),".knarr")}a(V,"getKnarrHome");function pt(){return join(V(),"store")}a(pt,"getStorePath");function Kt(){return join(V(),"consumers.json")}a(Kt,"getConsumersPath");function W(t){return $(t),t.replace(/\//g,"+")}a(W,"encodePackageName");function Vt(t){if(t.startsWith("@")){let e=t.indexOf("+");if(e!==-1)return t.slice(0,e)+"/"+t.slice(e+1)}return t}a(Vt,"decodePackageName");function F(t,e){X(t,e);let r=pt(),n=join(r,`${W(t)}@${e}`);return O(r,n,"Store entry path"),n}a(F,"getStoreEntryPath");function Wt(t,e){return join(F(t,e),"package")}a(Wt,"getStorePackagePath");function Zt(t,e){return join(F(t,e),".knarr-meta.json")}a(Zt,"getStoreMetaPath");function mt(t,e){return join(F(t,e),"history")}a(mt,"getStoreHistoryPath");function Jt(t,e,r){if(!/^[a-f0-9]{8,64}$/i.test(r))throw new Error(`Invalid build id "${r}"`);return join(mt(t,e),r)}a(Jt,"getHistoryEntryPath");function Yt(t){return join(t,".knarr")}a(Yt,"getConsumerKnarrDir");function qt(t){return join(t,".knarr","state.json")}a(qt,"getConsumerStatePath");function Gt(t,e){$(e);let r=join(t,".knarr","backups"),n=join(r,W(e));return O(r,n,"Backup path"),n}a(Gt,"getConsumerBackupPath");function Z(t){return t.replace(/\\/g,"/")}a(Z,"normalizePath");function Ut(t,e){$(e);let r=join(t,"node_modules"),n=join(r,e);return O(r,n,"node_modules package path"),n}a(Ut,"getNodeModulesPackagePath");var S=null;function yt(){return S||(S=import('./xxhash-wasm-I6Q3T2SL.mjs').then(t=>t.default()).catch(t=>{throw S=null,t})),S}a(yt,"getXXHash");var wt=1024*1024,Pt=R(Math.max(availableParallelism(),8)),z=new Map;async function ce(t,e,r=new Map){let n=new Map(t.map(c=>[Z(relative(e,c)),c]));for(let c of r.keys())n.has(c)||n.set(c,join(e,c));let i=[...n.entries()].sort(([c],[d])=>c.localeCompare(d)),a=new Set(n.values()),p=0,w=await Promise.all(i.map(([c,d])=>Pt(async()=>{let s=r.get(c);if(s!==void 0)return {rel:c,content:Buffer.isBuffer(s)?s:Buffer.from(s)};let u=await stat(d),v=z.get(d);if(v&&v.mtimeMs===u.mtimeMs&&v.size===u.size)return p++,{rel:c,content:v.content};let x=await readFile(d);return z.set(d,{mtimeMs:u.mtimeMs,size:u.size,content:x}),{rel:c,content:x}})));for(let c of z.keys())a.has(c)||z.delete(c);d(`[hash] Computing content hash for ${i.length} files (${p} cached)`);let g=createHash("sha256"),P=Buffer.alloc(4);for(let{rel:c,content:d}of w)g.update(c),g.update("\0"),P.writeUInt32LE(d.length),g.update(P),g.update(d);let I="sha256v2:"+g.digest("hex");return d(`[hash] Result: ${I.slice(0,20)}...`),I}a(ce,"computeContentHash");async function H(t,e){let r=e??(await stat(t)).size,n=await yt();if(r>wt)return vt(t,n);let i=await readFile(t);return n.h64Raw(i).toString(16)}a(H,"hashFile");async function vt(t,e){let{createReadStream:r}=await import('fs'),n=e.create64();return new Promise((i,a)=>{let p=r(t);p.on("data",w=>n.update(w)),p.on("end",()=>i(n.digest().toString(16))),p.on("error",a);})}a(vt,"hashFileStream");var G=R(Math.max(availableParallelism(),8));function C(t){return t instanceof Error&&"code"in t}a(C,"isNodeError");var N=new Map;function bt(t){let{root:e}=parse(t);return e||"/"}a(bt,"volumeRoot");async function It(t,e,r){if(b$1()){d(`[dry-run] would copy ${t} \u2192 ${e}`),a$1({type:"copy",path:t,dest:e});return}r?.ensureParent!==false&&await mkdir(dirname(e),{recursive:true});let n=bt(e),i=N.get(n);if(i===false){await copyFile(t,e);return}if(i===true){await copyFile(t,e,constants.COPYFILE_FICLONE);return}try{await copyFile(t,e,constants.COPYFILE_FICLONE_FORCE),N.set(n,!0);}catch{N.set(n,false),d(`[copy] reflink not supported on ${n}, using plain copy`),await copyFile(t,e);}}a(It,"copyWithCoW");async function T(t){return (await readdir(t,{recursive:true,withFileTypes:true})).filter(r=>r.isFile()).map(r=>join(r.parentPath,r.name))}a(T,"collectFiles");async function Mt(t,e){let r=e.split(/[\\/]/).filter(Boolean),n=t;for(let i=0;i<r.length;i++){n=join(n,r[i]);try{let a=await stat(n),p=i===r.length-1;if(a.isDirectory()){p&&(b$1()?a$1({type:"remove",path:n}):await rm(n,{recursive:!0,force:!0}));continue}if(!p)if(b$1()){a$1({type:"remove",path:n});return}else await rm(n,{force:!0});}catch(a){if(C(a)&&a.code==="ENOENT")return;throw a}}}a(Mt,"removeDestinationConflicts");async function Pe(t,e,r={}){let n=T(t),i=T(e).catch(s=>{if(C(s)&&s.code==="ENOENT")return [];throw s}),[a,p]=await Promise.all([n,i]),w=0,g=0,P=0,I=await Promise.all(a.map(s=>G(async()=>{let u=relative(t,s),v=join(e,u),x=true,E=null;if(r.force)d(`[copy] ${u} (forced)`);else try{let[m,M]=await Promise.all([stat(s),stat(v)]);if(E={atime:m.atime,mtime:m.mtime},m.size!==M.size)d(`[copy] ${u} (size differs: ${m.size} vs ${M.size})`);else if(m.mtimeMs===M.mtimeMs)x=!1,d(`[skip] ${u} (size+mtime match)`);else {let[tt,et]=await Promise.all([H(s,m.size),H(v,M.size)]);tt===et?(x=!1,d(`[skip] ${u} (unchanged)`)):d(`[copy] ${u} (hash differs)`);}}catch(m){if(C(m)&&(m.code==="ENOENT"||m.code==="ENOTDIR"))d(`[copy] ${u} (new file)`);else throw m}if(x){if(await Mt(e,u),await It(s,v),b$1())return "copied";if(!E){let m=await stat(s);E={atime:m.atime,mtime:m.mtime};}return await utimes(v,E.atime,E.mtime),"copied"}return "skipped"})));for(let s of I)s==="copied"?w++:P++;let c=new Set(a.map(s=>relative(t,s))),d$1=p.filter(s=>!c.has(relative(e,s)));return await Promise.all(d$1.map(s=>G(async()=>{d(`[remove] ${relative(e,s)} (no longer in source)`),b$1()?a$1({type:"remove",path:s}):await rm(s,{force:true}).catch(u=>{if(!(C(u)&&(u.code==="ENOENT"||u.code==="ENOTDIR"||u.code==="EISDIR"||u.code==="ERR_FS_EISDIR")))throw u});}))),g=d$1.length,{copied:w,removed:g,skipped:P}}a(Pe,"incrementalCopy");async function ve(t,e){if(b$1()){d(`[dry-run] would move ${t} \u2192 ${e}`),a$1({type:"move",path:t,dest:e});return}try{await rename(t,e);}catch(r){if(C(r)&&r.code==="EXDEV")await cp(t,e,{recursive:true}),await rm(t,{recursive:true,force:true});else throw r}}a(ve,"moveDir");async function xe(t){if(b$1()){d(`[dry-run] would remove ${t}`),a$1({type:"remove",path:t});return}await rm(t,{recursive:true,force:true});}a(xe,"removeDir");async function ke(t){if(b$1()){d(`[dry-run] would ensure dir ${t}`),a$1({type:"mkdir",path:t});return}await mkdir(t,{recursive:true});}a(ke,"ensureDir");async function Ee(t){if(b$1()){d(`[dry-run] would ensure private dir ${t}`),a$1({type:"mkdir",path:t});return}await mkdir(t,{recursive:true,mode:448});}a(Ee,"ensurePrivateDir");async function Re(t){try{return await stat(t),!0}catch{return false}}a(Re,"exists");async function $e(t,e){if(b$1()){d(`[dry-run] would write ${t}`),a$1({type:"write",path:t});return}let r=t+`.tmp-${process.pid}-${Date.now()}`;await writeFile(r,e),await rename(r,t);}a($e,"atomicWriteFile");async function Ce(t){try{let e=await T(t);return (await Promise.all(e.map(n=>stat(n).then(i=>i.size).catch(()=>0)))).reduce((n,i)=>n+i,0)}catch{return 0}}a(Ce,"dirSize");async function be(t,e){if(b$1()){d(`[dry-run] would copy directory ${t} \u2192 ${e}`),a$1({type:"copy",path:t,dest:e});return}await cp(t,e,{recursive:true});}a(be,"copyDir");
4
- export{Pe as A,ve as B,xe as C,ke as D,Ee as E,Re as F,$e as G,Ce as H,be as I,$ as a,st as b,X as c,Ft as d,Ht as e,Nt as f,Tt as g,pt as h,Kt as i,W as j,Vt as k,F as l,Wt as m,Zt as n,mt as o,Jt as p,Yt as q,qt as r,Gt as s,Z as t,Ut as u,R as v,ce as w,C as x,It as y,T as z};
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';import {a as a$1}from'./chunk-BH2WXCLS.mjs';import {a as a$2}from'./chunk-E3HZCU3S.mjs';import {b}from'./chunk-SPHWZS5P.mjs';import {a}from'./chunk-L7O2RSTN.mjs';import {spawn}from'child_process';import {platform}from'os';import {readFile,stat}from'fs/promises';import {join,dirname}from'path';globalThis.require=createRequire(import.meta.url);
3
- var B=new Set(["npm","pnpm","yarn","bun"]),T=[["pnpm-lock.yaml","pnpm"],["bun.lockb","bun"],["bun.lock","bun"],["yarn.lock","yarn"],["package-lock.json","npm"],["npm-shrinkwrap.json","npm"]],S=[".pnp.cjs",".pnp.js",".pnp.loader.mjs"],j=[".yarnrc.yml",...S];function $(a){if(typeof a!="string")return null;let n=a.trim().match(/^([^@\s]+)(?:@(.+))?$/);if(!n)return null;let e=n[1];return B.has(e)?{name:e,version:n[2]?.trim()??""}:null}a($,"parsePackageManagerSpec");async function v(a){try{let n=await readFile(join(a,"package.json"),"utf-8"),e=JSON.parse(n);return $(e.packageManager)}catch{return null}}a(v,"readPackageManagerSpec");async function K(a){let n=a;for(;;){let e=await v(n);if(e)return e;let t=dirname(n);if(t===n)return null;n=t;}}a(K,"findPackageManagerSpec");function D(a){let n=a.trim().replace(/^npm:/,"");if(n==="classic")return false;let e=n.match(/^v?(\d+)(?:[.+-]|$)/);return e?Number(e[1])>=2:n.length>0}a(D,"yarnDefaultsToPnp");async function A(a){let n=a;for(;;){let e=await v(n);if(e)return {packageManager:e.name,source:"packageManager",dir:n,file:join(n,"package.json")};let o=(await Promise.all(T.map(async([c,k])=>{try{return await stat(join(n,c)),{lockfile:c,packageManager:k}}catch{return null}}))).find(c=>c!==null);if(o)return {packageManager:o.packageManager,source:"lockfile",dir:n,file:join(n,o.lockfile)};let s=await O(n,j);if(s)return {packageManager:"yarn",source:"yarnArtifact",dir:n,file:join(n,s)};let l=dirname(n);if(l===n)return {packageManager:"npm",source:"default",dir:a};n=l;}}a(A,"detectPackageManagerInfo");async function O(a,n){for(let e of n)try{return await stat(join(a,e)),e}catch{}return null}a(O,"findExistingFile");function G(a,n){for(let e of a.split(`
4
- `)){let t=e.trim();if(t.startsWith("#")||!t.includes(n))continue;let o=t.match(new RegExp(`^${n}:\\s*(.+)$`));if(!o)continue;let s=o[1].trim().replace(/\s+#.*$/,"").trim().replace(/^["']|["']$/g,"");if(s)return s}return null}a(G,"readYarnrcScalar");async function C(a,n){let e=a;for(;;){try{let o=await readFile(join(e,".yarnrc.yml"),"utf-8"),s=G(o,n);if(s)return s}catch{}let t=dirname(e);if(t===e)return null;e=t;}}a(C,"findYarnrcScalar");async function d(a){let n=await C(a,"nodeLinker");return n==="node-modules"||n==="pnpm"||n==="pnp"?n:null}a(d,"detectYarnNodeLinker");async function R(a){return C(a,"pnpmStoreFolder")}a(R,"detectYarnPnpmStoreFolder");async function f(a){let n=a;for(;;)try{return await stat(join(n,".yarnrc.yml")),!0}catch{let e=dirname(n);if(e===n)return false;n=e;}}a(f,"hasYarnrcYml");async function P(a){let n=a;for(;;){if((await Promise.all(S.map(async o=>{try{return await stat(join(n,o)),!0}catch{return false}}))).some(Boolean))return true;let t=dirname(n);if(t===n)return false;n=t;}}a(P,"hasYarnPnpManifest");async function N(a){let n=await d(a);if(n==="pnp")return true;if(n==="node-modules"||n==="pnpm")return false;if(await P(a)||await f(a))return true;let e=await K(a);return e?.name==="yarn"&&D(e.version)}a(N,"isYarnPnpProject");var E={npm:{layout:a(()=>"node-modules","layout"),installArgs:a((a,n)=>["install",...n?["-D"]:[],...a],"installArgs")},pnpm:{layout:a(()=>"pnpm","layout"),installArgs:a((a,n)=>["add",...n?["-D"]:[],...a],"installArgs")},yarn:{layout:a(a=>a==="pnpm"?"yarn-pnpm":"node-modules","layout"),installArgs:a((a,n)=>["add",...n?["-D"]:[],...a],"installArgs")},bun:{layout:a(()=>"bun","layout"),installArgs:a((a,n)=>["add",...n?["-d"]:[],...a],"installArgs")}},V=`Yarn PnP mode is not compatible with Knarr.
5
-
6
- Knarr works by copying files into node_modules/, but PnP eliminates
7
- node_modules/ entirely. To use Knarr with Yarn Berry, add one of these
8
- to .yarnrc.yml:
9
-
10
- nodeLinker: node-modules
11
- nodeLinker: pnpm
12
-
13
- Then run: yarn install`;async function sn(a$1,n={}){let[e,t,o,s,l,c]=await Promise.all([A(a$1),f(a$1),P(a$1),d(a$1),R(a$1),N(a$1)]);return {resolve:a(y=>{let g=n.packageManager??(e.source==="default"&&y?y:e.packageManager),F=E[g],M=o||s==="pnp"||g==="yarn"&&c,b=F.layout(s),w={packageManager:g,layout:b,virtualStoreFolder:b==="yarn-pnpm"?l:null,yarnLinkerDiagnostic:W({packageManager:g,configExists:t,pnpManifestExists:o,nodeLinker:s,isPnp:M}),installCommand(m,_={}){return q(g,m,_.dev===true)},formatCommand:I,run(m){return H(m,a$1)}};return M?{...w,nodeModulesCompatible:false,incompatibilityReason:V}:{...w,nodeModulesCompatible:true,incompatibilityReason:null}},"resolvePackageManager")}}a(sn,"inspectProjectPackageManager");function W(a){let{packageManager:n,configExists:e,pnpManifestExists:t,nodeLinker:o,isPnp:s}=a;return n!=="yarn"&&!e&&!t?null:o==="node-modules"?{status:"pass",message:"Yarn Berry with node-modules linker"}:o==="pnpm"?{status:"pass",message:"Yarn pnpm linker mode (.store virtual store)"}:s?{status:"fail",message:`${o==="pnp"||t?"Yarn PnP is not compatible.":"Yarn Berry defaults to PnP."} Set \`nodeLinker: node-modules\` or \`nodeLinker: pnpm\` in .yarnrc.yml`}:e?{status:"warn",message:"Yarn Berry defaults to PnP. Add `nodeLinker: node-modules` or `nodeLinker: pnpm` to .yarnrc.yml"}:{status:"pass",message:"Yarn Classic, node_modules mode"}}a(W,"getYarnLinkerDiagnostic");function q(a,n,e){if(n.length===0)throw new Error("No dependencies provided");for(let t of n)a$1(t);return {executable:a,args:E[a].installArgs(n,e)}}a(q,"createInstallCommand");function I(a){return [a.executable,...a.args].join(" ")}a(I,"formatCommand");function H(a,n){let e=I(a);return b()?(a$2({type:"command-skip",path:n,detail:e}),Promise.resolve(true)):new Promise(t=>{let o=spawn(a.executable,a.args,{cwd:n,stdio:"inherit",shell:platform()==="win32"});o.on("close",s=>t(s===0)),o.on("error",()=>t(false));})}a(H,"runPackageManagerCommand");export{sn as a};
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import {createRequire}from'node:module';import {c}from'./chunk-SPHWZS5P.mjs';import {b}from'./chunk-OQDZJP55.mjs';import {a}from'./chunk-L7O2RSTN.mjs';globalThis.require=createRequire(import.meta.url);
3
- var n=[],l=false;function m(o){n.push(o);}a(m,"recordMutation");function y(){return [...n]}a(y,"getMutations");function k(){l=true;}a(k,"markDryRunJsonReportPrinted");function g(){if(n.length===0){b.info("[dry-run] No mutations would be performed");return}if(c()){if(l)return;console.log(JSON.stringify({dryRun:true,mutations:n},null,2)),l=true;return}let o=new Map;for(let i of n){let t=o.get(i.type);t||(t=[],o.set(i.type,t)),t.push(i);}b.info(`
4
- [dry-run] ${n.length} mutation(s) would be performed:
5
- `);let a={copy:"Copy",remove:"Remove",move:"Move",mkdir:"Create directory",write:"Write file","bin-link":"Create bin link","bin-unlink":"Remove bin link","cache-invalidate":"Invalidate cache","lock-skip":"Skip lock","lifecycle-skip":"Skip lifecycle hook","command-skip":"Skip command"};for(let[i,t]of o){b.info(` ${a[i]} (${t.length}):`);for(let r of t.slice(0,20)){let p=r.dest?` \u2192 ${r.dest}`:"",c=r.detail?` (${r.detail})`:"";b.info(` ${r.path}${p}${c}`);}t.length>20&&b.info(` ... and ${t.length-20} more`);}}a(g,"printDryRunReport");export{m as a,y as b,k as c,g as d};