feat: restore gateway HMR and add WRN formatting
This commit is contained in:
@@ -172,6 +172,87 @@ const MIGRATIONS: Migration[] = [
|
||||
if (!ctx.dryRun) writeFileSync(file, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
||||
},
|
||||
},
|
||||
{
|
||||
version: "0.2.19",
|
||||
id: "vscode-formatting",
|
||||
description: "Add safe VS Code format-on-save defaults and extension recommendations",
|
||||
apply(ctx) {
|
||||
const vscode = join(ctx.appRoot, ".vscode");
|
||||
const settings = join(vscode, "settings.json");
|
||||
const extensions = join(vscode, "extensions.json");
|
||||
const prettierIgnore = join(ctx.appRoot, ".prettierignore");
|
||||
const gitignore = join(ctx.appRoot, ".gitignore");
|
||||
|
||||
const files: Array<[string, string, string]> = [
|
||||
[
|
||||
settings,
|
||||
JSON.stringify(
|
||||
{
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
|
||||
"prettier.requireConfig": true,
|
||||
"[wrn]": {
|
||||
"editor.defaultFormatter": "wrnexus.wrnexus",
|
||||
"editor.formatOnSave": true,
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
".vscode/settings.json",
|
||||
],
|
||||
[
|
||||
extensions,
|
||||
JSON.stringify(
|
||||
{
|
||||
recommendations: [
|
||||
"wrnexus.wrnexus",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
".vscode/extensions.json",
|
||||
],
|
||||
];
|
||||
|
||||
for (const [file, contents, label] of files) {
|
||||
if (existsSync(file)) continue;
|
||||
ctx.log(`+ ${label}`);
|
||||
if (!ctx.dryRun) {
|
||||
mkdirSync(vscode, { recursive: true });
|
||||
writeFileSync(file, contents, "utf8");
|
||||
}
|
||||
}
|
||||
|
||||
const prettier = existsSync(prettierIgnore) ? readFileSync(prettierIgnore, "utf8") : "";
|
||||
if (!new Set(prettier.split(/\r?\n/).map((line) => line.trim())).has("CLAUDE.md")) {
|
||||
ctx.log("+ .prettierignore: CLAUDE.md");
|
||||
if (!ctx.dryRun) {
|
||||
writeFileSync(prettierIgnore, `${prettier.replace(/\s*$/, "")}\nCLAUDE.md\n`, "utf8");
|
||||
}
|
||||
}
|
||||
|
||||
if (existsSync(gitignore)) {
|
||||
const current = readFileSync(gitignore, "utf8");
|
||||
const lines = current.split(/\r?\n/);
|
||||
const vscodeIgnore = lines.findIndex((line) => line.trim() === ".vscode/");
|
||||
const needed = [".vscode/*", "!.vscode/settings.json", "!.vscode/extensions.json"];
|
||||
if (vscodeIgnore >= 0 || needed.some((entry) => !lines.includes(entry))) {
|
||||
ctx.log("~ .gitignore: track shared VS Code configuration");
|
||||
if (!ctx.dryRun) {
|
||||
const filtered = lines.filter((line) => line.trim() !== ".vscode/");
|
||||
const have = new Set(filtered.map((line) => line.trim()));
|
||||
for (const entry of needed) if (!have.has(entry)) filtered.push(entry);
|
||||
writeFileSync(gitignore, filtered.join("\n").replace(/\n*$/, "\n"), "utf8");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
/** Release tooling uses this to require an explicit migration entry per version. */
|
||||
@@ -246,6 +327,9 @@ function backupProjectFiles(appRoot: string, from: string, target: string): stri
|
||||
"wrnexus.config.mjs",
|
||||
"tsconfig.json",
|
||||
".gitignore",
|
||||
".prettierignore",
|
||||
".vscode/settings.json",
|
||||
".vscode/extensions.json",
|
||||
"CLAUDE.md",
|
||||
"public/llms.txt",
|
||||
]) {
|
||||
|
||||
Reference in New Issue
Block a user