fix: normalize generated VS Code configuration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/cli",
|
||||
"version": "0.2.19",
|
||||
"version": "0.2.20",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
+26
-15
@@ -72,6 +72,20 @@ interface Migration {
|
||||
apply: (ctx: MigrationCtx) => void;
|
||||
}
|
||||
|
||||
const VSCODE_EXTENSIONS = `{
|
||||
"recommendations": ["wrnexus.wrnexus", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
|
||||
}
|
||||
`;
|
||||
|
||||
const LEGACY_VSCODE_EXTENSIONS =
|
||||
JSON.stringify(
|
||||
{
|
||||
recommendations: ["wrnexus.wrnexus", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n";
|
||||
|
||||
/**
|
||||
* Versioned, idempotent upgrade steps. Each MUST be safe to re-run and MUST NOT
|
||||
* overwrite user code. Append new entries with the version that ships them.
|
||||
@@ -202,21 +216,7 @@ const MIGRATIONS: Migration[] = [
|
||||
) + "\n",
|
||||
".vscode/settings.json",
|
||||
],
|
||||
[
|
||||
extensions,
|
||||
JSON.stringify(
|
||||
{
|
||||
recommendations: [
|
||||
"wrnexus.wrnexus",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
".vscode/extensions.json",
|
||||
],
|
||||
[extensions, VSCODE_EXTENSIONS, ".vscode/extensions.json"],
|
||||
];
|
||||
|
||||
for (const [file, contents, label] of files) {
|
||||
@@ -253,6 +253,17 @@ const MIGRATIONS: Migration[] = [
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
version: "0.2.20",
|
||||
id: "normalize-vscode-extensions",
|
||||
description: "Normalize the framework-generated VS Code recommendations file",
|
||||
apply(ctx) {
|
||||
const file = join(ctx.appRoot, ".vscode", "extensions.json");
|
||||
if (!existsSync(file) || readFileSync(file, "utf8") !== LEGACY_VSCODE_EXTENSIONS) return;
|
||||
ctx.log("~ .vscode/extensions.json formatting normalized");
|
||||
if (!ctx.dryRun) writeFileSync(file, VSCODE_EXTENSIONS, "utf8");
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
/** Release tooling uses this to require an explicit migration entry per version. */
|
||||
|
||||
@@ -84,6 +84,9 @@ test("0.2.19 migration adds VS Code formatting defaults without overwriting sett
|
||||
expect(readFileSync(join(root, ".vscode", "extensions.json"), "utf8")).toContain(
|
||||
"wrnexus.wrnexus",
|
||||
);
|
||||
expect(readFileSync(join(root, ".vscode", "extensions.json"), "utf8")).toBe(
|
||||
'{\n "recommendations": ["wrnexus.wrnexus", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]\n}\n',
|
||||
);
|
||||
expect(readFileSync(join(root, ".prettierignore"), "utf8")).toBe("node_modules/\nCLAUDE.md\n");
|
||||
const gitignore = readFileSync(join(root, ".gitignore"), "utf8");
|
||||
expect(gitignore).not.toContain(".vscode/\n");
|
||||
@@ -93,3 +96,32 @@ test("0.2.19 migration adds VS Code formatting defaults without overwriting sett
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("0.2.20 migration repairs only the legacy generated recommendations layout", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "wrnexus-update-"));
|
||||
mkdirSync(join(root, "app", "pages"), { recursive: true });
|
||||
mkdirSync(join(root, ".vscode"), { recursive: true });
|
||||
writeFileSync(
|
||||
join(root, "package.json"),
|
||||
JSON.stringify({ name: "editor-app", wrnexus: { version: "0.2.19" } }),
|
||||
);
|
||||
writeFileSync(
|
||||
join(root, ".vscode", "extensions.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
recommendations: ["wrnexus.wrnexus", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
);
|
||||
|
||||
try {
|
||||
updateApp(root, "0.2.20", false);
|
||||
expect(readFileSync(join(root, ".vscode", "extensions.json"), "utf8")).toBe(
|
||||
'{\n "recommendations": ["wrnexus.wrnexus", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]\n}\n',
|
||||
);
|
||||
} finally {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user