From 003359ec15db9a0638c07a10c048a2c668323960 Mon Sep 17 00:00:00 2001 From: Marcos Candeia Date: Fri, 27 Sep 2024 12:32:50 -0300 Subject: [PATCH] Do not upgrade deco if not adminv2 Signed-off-by: Marcos Candeia --- deno.json | 2 +- scripts/codemod.ts | 18 ++++++++++++++++-- scripts/deno.json | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/deno.json b/deno.json index 120157a5..c0df2c00 100644 --- a/deno.json +++ b/deno.json @@ -66,7 +66,7 @@ "$fresh/": "https://denopkg.com/denoland/fresh@1.6.8/", "@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.5", "@core/asyncutil": "jsr:@core/asyncutil@^1.0.2", - "@deco/codemod-toolkit": "jsr:@deco/codemod-toolkit@^0.3.3", + "@deco/codemod-toolkit": "jsr:@deco/codemod-toolkit@^0.3.4", "@deco/deno-ast-wasm": "jsr:@deco/deno-ast-wasm@^0.5.4", "@deco/durable": "jsr:@deco/durable@^0.5.3", "@deco/warp": "jsr:@deco/warp@^0.3.8", diff --git a/scripts/codemod.ts b/scripts/codemod.ts index 86187d44..256da6ad 100644 --- a/scripts/codemod.ts +++ b/scripts/codemod.ts @@ -6,9 +6,13 @@ import { upgradeDeps, } from "@deco/codemod-toolkit"; import { jsrLatest } from "@deco/codemod-toolkit/deno-json"; +import { join } from "@std/path/join"; + +const DECO_PKGS = /(@deco\/.*)|(deco)|(\$live)/; +const PKGS_TO_CHECK = /(apps)|(deco-sites\/.*\/$)|(partytown)|(@deco\/warp)/; + +const upgradeDecoVersion = upgradeDeps(DECO_PKGS, true); -const PKGS_TO_CHECK = - /(@deco\/.*)|(apps)|(deco)|(\$live)|(deco-sites\/.*\/$)|(partytown)/; const EXPORTS = { DECO: "@deco/deco", DECO_WEB: "@deco/deco/web", @@ -664,6 +668,16 @@ export const runCodeMod = async (context?: CodeModContext): Promise => { }, }, upgradeDeps(PKGS_TO_CHECK, true), + { + options: upgradeDecoVersion.options, + apply: async (txt, ctx) => { + const isAdminV2 = await ctx.fs.exists(join(ctx.fs.cwd(), ".deco")); + if (isAdminV2) { + return upgradeDecoVersion.apply(txt, ctx); + } + return txt; + }, + }, { options: { match: [/dev.ts$/], diff --git a/scripts/deno.json b/scripts/deno.json index 5c21f6ca..578b2e9c 100644 --- a/scripts/deno.json +++ b/scripts/deno.json @@ -19,7 +19,7 @@ }, "imports": { "@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.5", - "@deco/codemod-toolkit": "jsr:@deco/codemod-toolkit@^0.3.3", + "@deco/codemod-toolkit": "jsr:@deco/codemod-toolkit@^0.3.4", "@std/flags": "jsr:@std/flags@^0.224.0", "@std/fmt": "jsr:@std/fmt@^1.0.0", "@std/fs": "jsr:@std/fs@^1.0.1",