pnpm-plugin-alex-857 1.0.30 → 1.0.32
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/README.md +2 -2
- package/install-workspace.js +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,13 +41,13 @@ This updates your `pnpm-workspace.yaml` with a `configDependencies` entry and in
|
|
|
41
41
|
|
|
42
42
|
```json
|
|
43
43
|
"scripts": {
|
|
44
|
-
"
|
|
44
|
+
"pnpm:devPreinstall": "pnpm add --config pnpm-plugin-alex-857@latest && node node_modules/.pnpm-config/pnpm-plugin-alex-857/install-workspace.js",
|
|
45
45
|
"postinstall": "pnpm run install:catalog",
|
|
46
46
|
"install:catalog": "node node_modules/.pnpm-config/pnpm-plugin-alex-857/install-catalog.js"
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
- **
|
|
50
|
+
- **pnpm:devPreinstall**: Runs **before** dependency resolution. Installs the plugin and runs install-workspace.js so `pnpm-workspace.yaml` has the catalog and packages **before** `catalog:` is resolved. This avoids `ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC`.
|
|
51
51
|
- **postinstall**: Runs after `pnpm install` and adds all catalog packages to the root (if not already present).
|
|
52
52
|
- **install:catalog**: Manual script to add all catalog packages at once.
|
|
53
53
|
|
package/install-workspace.js
CHANGED
|
@@ -91,3 +91,24 @@ console.log(
|
|
|
91
91
|
"pnpm-workspace.yaml with packages (no duplicates):",
|
|
92
92
|
mergedPackages.join(", ")
|
|
93
93
|
);
|
|
94
|
+
|
|
95
|
+
// Ensure catalog is in pnpm-workspace.yaml before resolution (preinstall runs before install).
|
|
96
|
+
// So dependencies with "catalog:" resolve; otherwise we get ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC.
|
|
97
|
+
const catalogJsonPath = [
|
|
98
|
+
path.join(__dirname, "pnpm-catalog.json"),
|
|
99
|
+
path.join(process.cwd(), "pnpm-catalog.json"),
|
|
100
|
+
].find((p) => fs.existsSync(p));
|
|
101
|
+
if (catalogJsonPath && fs.existsSync(yamlPath)) {
|
|
102
|
+
const yamlNow = fs.readFileSync(yamlPath, "utf8");
|
|
103
|
+
if (!/\ncatalog\s*:/m.test(yamlNow)) {
|
|
104
|
+
const catalogData = JSON.parse(fs.readFileSync(catalogJsonPath, "utf8"));
|
|
105
|
+
const catalogBlock =
|
|
106
|
+
"\ncatalog:\n" +
|
|
107
|
+
Object.entries(catalogData)
|
|
108
|
+
.map(([name, version]) => ` ${name}: ${version}`)
|
|
109
|
+
.join("\n") +
|
|
110
|
+
"\n";
|
|
111
|
+
fs.writeFileSync(yamlPath, yamlNow.trimEnd() + catalogBlock, "utf8");
|
|
112
|
+
console.log("Added catalog to pnpm-workspace.yaml (for catalog: resolution).");
|
|
113
|
+
}
|
|
114
|
+
}
|