feat: add update.ts script (#706)
This commit adds an update.ts tool that makes it easy to upgrade existing Fresh projects to the latest version of Fresh. This tool updates dependency versions in the import map, and includes some code mods: 1. update projects from classic JSX to automatic JSX 2. update projects from legacy twind integration to twind plugin Both of these code mods get you about 95% of the way there most of the time. Users might still need to do some manual work to get their projects fully updated.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { join, parse, resolve } from "./src/dev/deps.ts";
|
||||
import { error } from "./src/dev/error.ts";
|
||||
import { collect, ensureMinDenoVersion, generate } from "./src/dev/mod.ts";
|
||||
import { freshImports, twindImports } from "./src/dev/imports.ts";
|
||||
|
||||
ensureMinDenoVersion();
|
||||
|
||||
@@ -76,19 +77,9 @@ if (useVSCode) {
|
||||
await Deno.mkdir(join(resolvedDirectory, ".vscode"), { recursive: true });
|
||||
}
|
||||
|
||||
const importMap = {
|
||||
"imports": {
|
||||
"$fresh/": new URL("./", import.meta.url).href,
|
||||
"preact": "https://esm.sh/preact@10.10.6",
|
||||
"preact/": "https://esm.sh/preact@10.10.6/",
|
||||
"preact-render-to-string":
|
||||
"https://esm.sh/preact-render-to-string@5.2.2?external=preact",
|
||||
} as Record<string, string>,
|
||||
};
|
||||
if (useTwind) {
|
||||
importMap.imports["twind"] = "https://esm.sh/twind@0.16.17";
|
||||
importMap.imports["twind/"] = "https://esm.sh/twind@0.16.17/";
|
||||
}
|
||||
const importMap = { imports: {} as Record<string, string> };
|
||||
freshImports(importMap.imports);
|
||||
if (useTwind) twindImports(importMap.imports);
|
||||
const IMPORT_MAP_JSON = JSON.stringify(importMap, null, 2) + "\n";
|
||||
await Deno.writeTextFile(
|
||||
join(resolvedDirectory, "import_map.json"),
|
||||
|
||||
Reference in New Issue
Block a user