pnpm-plugin-alex-857 1.0.28 → 1.0.30

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.
@@ -21,8 +21,25 @@ if (specifiers.length === 0) {
21
21
  process.exit(0);
22
22
  }
23
23
 
24
- const isWorkspaceRoot =
25
- fs.existsSync(path.join(process.cwd(), "pnpm-workspace.yaml"));
24
+ // Ensure pnpm-workspace.yaml has a catalog section so catalog: resolution works.
25
+ const workspaceYamlPath = path.join(process.cwd(), "pnpm-workspace.yaml");
26
+ if (fs.existsSync(workspaceYamlPath)) {
27
+ let yaml = fs.readFileSync(workspaceYamlPath, "utf8");
28
+ const hasCatalog = /\ncatalog\s*:/m.test(yaml);
29
+ if (!hasCatalog) {
30
+ const catalogBlock =
31
+ "\ncatalog:\n" +
32
+ Object.entries(catalog)
33
+ .map(([name, version]) => ` ${name}: ${version}`)
34
+ .join("\n") +
35
+ "\n";
36
+ yaml = yaml.trimEnd() + catalogBlock;
37
+ fs.writeFileSync(workspaceYamlPath, yaml, "utf8");
38
+ console.log("Added catalog to pnpm-workspace.yaml");
39
+ }
40
+ }
41
+
42
+ const isWorkspaceRoot = fs.existsSync(workspaceYamlPath);
26
43
  const addCmd = `pnpm add ${isWorkspaceRoot ? "-w " : ""}${specifiers.join(" ")}`;
27
44
 
28
45
  console.log("Adding from catalog:", specifiers.join(", "));
@@ -67,13 +67,17 @@ const packagesBlock =
67
67
 
68
68
  let output;
69
69
  if (raw && /^packages\s*:/m.test(raw)) {
70
- // Replace only the packages section: from "packages:" to next top-level key (catalog/configDependencies) or end of file.
71
- // Do not use $ with /m (it matches end of line) or we stop at a blank line and leave duplicates.
70
+ // Replace only the packages list: "packages:\n" + list lines. Never replace to end of file
71
+ // so we never wipe catalog / configDependencies (which would break install-catalog).
72
72
  const nextKeyRegex = /^packages\s*:\s*\n[\s\S]*?(?=\n(?:catalog|configDependencies)\s*:)/m;
73
73
  output = raw.replace(nextKeyRegex, () => packagesBlock);
74
74
  if (output === raw) {
75
- // No catalog/configDependencies after packages; replace to end of string
76
- output = raw.replace(/^packages\s*:\s*\n[\s\S]*/m, packagesBlock);
75
+ // No catalog/configDependencies after packages: replace only the list lines ( - '...')
76
+ // so any trailing content (catalog, configDependencies, blank lines) is preserved.
77
+ output = raw.replace(
78
+ /^(packages\s*:\s*\n)((?:\s+-\s+['"][^'"]+['"]\s*\n)*)/m,
79
+ () => packagesBlock
80
+ );
77
81
  }
78
82
  } else if (raw) {
79
83
  output = raw.trimEnd() + "\n\n" + packagesBlock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pnpm-plugin-alex-857",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "A plugin for pnpm to use alex as a linter",
5
5
  "bin": {
6
6
  "install-catalog": "./install-catalog.js",