pnpm-plugin-alex-857 1.0.19 → 1.0.21
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/install-workspace.js +55 -0
- package/package.json +8 -4
- package/pnpm-workspace.json +3 -0
- package/pnpmfile.cjs +0 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
// Resolve pnpm-workspace.json: plugin dir first, then cwd
|
|
6
|
+
const possiblePaths = [
|
|
7
|
+
path.join(__dirname, "pnpm-workspace.json"),
|
|
8
|
+
path.join(process.cwd(), "pnpm-workspace.json"),
|
|
9
|
+
];
|
|
10
|
+
const workspaceJsonPath = possiblePaths.find((p) => fs.existsSync(p));
|
|
11
|
+
if (!workspaceJsonPath) {
|
|
12
|
+
console.error("No pnpm-workspace.json found in plugin or current directory.");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const workspaceJson = JSON.parse(fs.readFileSync(workspaceJsonPath, "utf8"));
|
|
17
|
+
const packagesFromJson = workspaceJson.packages;
|
|
18
|
+
if (!Array.isArray(packagesFromJson) || packagesFromJson.length === 0) {
|
|
19
|
+
console.log("No packages array in pnpm-workspace.json.");
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const yamlPath = path.join(process.cwd(), "pnpm-workspace.yaml");
|
|
24
|
+
let existingPackages = [];
|
|
25
|
+
let raw = "";
|
|
26
|
+
|
|
27
|
+
if (fs.existsSync(yamlPath)) {
|
|
28
|
+
raw = fs.readFileSync(yamlPath, "utf8");
|
|
29
|
+
const match = raw.match(/^packages\s*:\s*\n((?:\s+-\s+[^\n]+\n?)*)/m);
|
|
30
|
+
if (match) {
|
|
31
|
+
const items = match[1].matchAll(/^\s+-\s+['"]?([^'"]+)['"]?/gm);
|
|
32
|
+
for (const m of items) existingPackages.push(m[1]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const mergedPackages = [...new Set([...existingPackages, ...packagesFromJson])];
|
|
37
|
+
const packagesBlock = "packages:\n" + mergedPackages.map((p) => ` - '${p}'`).join("\n") + "\n";
|
|
38
|
+
|
|
39
|
+
let output;
|
|
40
|
+
if (raw) {
|
|
41
|
+
if (/^packages\s*:/m.test(raw)) {
|
|
42
|
+
output = raw.replace(/^packages\s*:\s*\n(?:\s+-\s+[^\n]+\n?)*/m, packagesBlock);
|
|
43
|
+
} else {
|
|
44
|
+
output = raw.trimEnd() + "\n\n" + packagesBlock;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
output = packagesBlock;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fs.writeFileSync(yamlPath, output, "utf8");
|
|
51
|
+
console.log(
|
|
52
|
+
raw ? "Updated" : "Created",
|
|
53
|
+
"pnpm-workspace.yaml with packages:",
|
|
54
|
+
mergedPackages.join(", ")
|
|
55
|
+
);
|
package/package.json
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pnpm-plugin-alex-857",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "A plugin for pnpm to use alex as a linter",
|
|
5
5
|
"bin": {
|
|
6
|
-
"install-catalog": "./install-catalog.js"
|
|
6
|
+
"install-catalog": "./install-catalog.js",
|
|
7
|
+
"install-workspace": "./install-workspace.js"
|
|
7
8
|
},
|
|
8
9
|
"files": [
|
|
9
10
|
"pnpmfile.cjs",
|
|
10
11
|
"pnpm-catalog.json",
|
|
11
|
-
"
|
|
12
|
+
"pnpm-workspace.json",
|
|
13
|
+
"install-catalog.js",
|
|
14
|
+
"install-workspace.js"
|
|
12
15
|
],
|
|
13
16
|
"keywords": ["pnpm", "plugin"],
|
|
14
17
|
"author": "aboungnaseng857",
|
|
15
18
|
"license": "ISC",
|
|
16
19
|
"scripts": {
|
|
17
|
-
"install:catalog": "node install-catalog.js"
|
|
20
|
+
"install:catalog": "node install-catalog.js",
|
|
21
|
+
"install:workspace": "node install-workspace.js"
|
|
18
22
|
}
|
|
19
23
|
}
|
package/pnpmfile.cjs
CHANGED
|
@@ -8,9 +8,6 @@ module.exports = {
|
|
|
8
8
|
for (const [name, version] of Object.entries(catalog)) {
|
|
9
9
|
config.catalogs.default[name] = version;
|
|
10
10
|
}
|
|
11
|
-
console.log("[pnpmfile] strictPeerDependencies = true");
|
|
12
|
-
console.log("[pnpmfile] hoist = false");
|
|
13
|
-
console.log("[pnpmfile] hoistWorkspacePackages = true");
|
|
14
11
|
return {
|
|
15
12
|
...config,
|
|
16
13
|
strictPeerDependencies: true,
|