Skip to content

Commit

Permalink
Do not upgrade deco if not adminv2
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <marrcooos@gmail.com>
  • Loading branch information
mcandeia committed Sep 27, 2024
1 parent d5cc344 commit 003359e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 16 additions & 2 deletions scripts/codemod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -664,6 +668,16 @@ export const runCodeMod = async (context?: CodeModContext): Promise<void> => {
},
},
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$/],
Expand Down
2 changes: 1 addition & 1 deletion scripts/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 003359e

Please sign in to comment.