fix(update): Update tasks + lock in deno.json (#2987)
Noticed that we don't update these.
This commit is contained in:
@@ -9,6 +9,8 @@ export const PREACT_VERSION = "10.26.6";
|
||||
export const PREACT_SIGNALS_VERSION = "2.0.4";
|
||||
|
||||
export interface DenoJson {
|
||||
lock?: boolean;
|
||||
tasks?: Record<string, string>;
|
||||
name?: string;
|
||||
version?: string;
|
||||
imports?: Record<string, string>;
|
||||
@@ -90,6 +92,39 @@ export async function updateProject(dir: string) {
|
||||
delete config.imports["$fresh/"];
|
||||
delete config.imports["@preact/signals-core"];
|
||||
delete config.imports["preact-render-to-string"];
|
||||
|
||||
// We should always use a lockfile going forwards
|
||||
if ("lock" in config) {
|
||||
delete config.lock;
|
||||
}
|
||||
|
||||
// Update Fresh 1.x tasks
|
||||
const tasks = config.tasks;
|
||||
if (tasks !== undefined) {
|
||||
if (tasks.manifest === "deno task cli manifest $(pwd)") {
|
||||
delete tasks.manifest;
|
||||
}
|
||||
|
||||
if (
|
||||
tasks.cli ===
|
||||
"echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -" ||
|
||||
tasks.cli ===
|
||||
"echo \"import '$fresh/src/dev/cli.ts'\" | deno run --unstable -A -"
|
||||
) {
|
||||
delete tasks.cli;
|
||||
}
|
||||
|
||||
if (tasks.update === "deno run -A -r https://fresh.deno.dev/update .") {
|
||||
tasks.update = "deno run -A -r jsr:@fresh/update .";
|
||||
}
|
||||
|
||||
if (
|
||||
tasks.check ===
|
||||
"deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx"
|
||||
) {
|
||||
tasks.check = "deno fmt --check && deno lint && deno check";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Update routes folder
|
||||
|
||||
@@ -105,6 +105,38 @@ Deno.test("update - 1.x project deno.json with imports", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
Deno.test("update - 1.x project deno.json tasks + lock", async () => {
|
||||
await using tmp = await withTmpDir();
|
||||
await writeFiles(tmp.dir, {
|
||||
"/deno.json": `{
|
||||
"lock": false,
|
||||
"tasks": {
|
||||
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
|
||||
"cli": "echo \\"import '$fresh/src/dev/cli.ts'\\" | deno run --unstable -A -",
|
||||
"manifest": "deno task cli manifest $(pwd)",
|
||||
"start": "deno run -A --allow-scripts --watch=static/,routes/ dev.ts",
|
||||
"build": "deno run -A dev.ts build",
|
||||
"preview": "deno run -A main.ts",
|
||||
"update": "deno run -A -r https://fresh.deno.dev/update ."
|
||||
}
|
||||
}`,
|
||||
});
|
||||
|
||||
await updateProject(tmp.dir);
|
||||
const files = await readFiles(tmp.dir);
|
||||
|
||||
const updated = JSON.parse(files["/deno.json"]);
|
||||
expect(updated.lock).toEqual(undefined);
|
||||
expect(updated.tasks)
|
||||
.toEqual({
|
||||
build: "deno run -A dev.ts build",
|
||||
check: "deno fmt --check && deno lint && deno check",
|
||||
preview: "deno run -A main.ts",
|
||||
start: "deno run -A --allow-scripts --watch=static/,routes/ dev.ts",
|
||||
update: "deno run -A -r jsr:@fresh/update .",
|
||||
});
|
||||
});
|
||||
|
||||
Deno.test("update - 1.x project middlewares", async () => {
|
||||
await using _tmp = await withTmpDir();
|
||||
const dir = _tmp.dir;
|
||||
|
||||
Reference in New Issue
Block a user