pnpm-plugin-alex-857 1.0.18 → 1.0.20
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 +38 -0
- package/package.json +11 -4
- package/pnpm-workspace.json +3 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const yaml = require("js-yaml");
|
|
5
|
+
|
|
6
|
+
// Resolve pnpm-workspace.json: plugin dir first, then cwd
|
|
7
|
+
const possiblePaths = [
|
|
8
|
+
path.join(__dirname, "pnpm-workspace.json"),
|
|
9
|
+
path.join(process.cwd(), "pnpm-workspace.json"),
|
|
10
|
+
];
|
|
11
|
+
const workspaceJsonPath = possiblePaths.find((p) => fs.existsSync(p));
|
|
12
|
+
if (!workspaceJsonPath) {
|
|
13
|
+
console.error("No pnpm-workspace.json found in plugin or current directory.");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const workspaceJson = JSON.parse(fs.readFileSync(workspaceJsonPath, "utf8"));
|
|
18
|
+
const packagesFromJson = workspaceJson.packages;
|
|
19
|
+
if (!Array.isArray(packagesFromJson) || packagesFromJson.length === 0) {
|
|
20
|
+
console.log("No packages array in pnpm-workspace.json.");
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const yamlPath = path.join(process.cwd(), "pnpm-workspace.yaml");
|
|
25
|
+
let yamlContent = {};
|
|
26
|
+
let exists = false;
|
|
27
|
+
|
|
28
|
+
if (fs.existsSync(yamlPath)) {
|
|
29
|
+
exists = true;
|
|
30
|
+
yamlContent = yaml.load(fs.readFileSync(yamlPath, "utf8")) || {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const existingPackages = Array.isArray(yamlContent.packages) ? yamlContent.packages : [];
|
|
34
|
+
const mergedPackages = [...new Set([...existingPackages, ...packagesFromJson])];
|
|
35
|
+
yamlContent.packages = mergedPackages;
|
|
36
|
+
|
|
37
|
+
fs.writeFileSync(yamlPath, yaml.dump(yamlContent), "utf8");
|
|
38
|
+
console.log(exists ? "Updated" : "Created", "pnpm-workspace.yaml with packages:", mergedPackages.join(", "));
|
package/package.json
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pnpm-plugin-alex-857",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
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"],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"js-yaml": "^4.1.0"
|
|
19
|
+
},
|
|
14
20
|
"author": "aboungnaseng857",
|
|
15
21
|
"license": "ISC",
|
|
16
22
|
"scripts": {
|
|
17
|
-
"install:catalog": "node install-catalog.js"
|
|
23
|
+
"install:catalog": "node install-catalog.js",
|
|
24
|
+
"install:workspace": "node install-workspace.js"
|
|
18
25
|
}
|
|
19
26
|
}
|