diff --git a/daemon/workers/denoRun.ts b/daemon/workers/denoRun.ts index bf48d1fc2..ca31b467d 100644 --- a/daemon/workers/denoRun.ts +++ b/daemon/workers/denoRun.ts @@ -21,7 +21,7 @@ const buildPermissionsArgs = ( for (const [key, value] of Object.entries(perm)) { if (value === "inherit") { permCache[key] ??= Deno.permissions.querySync({ - name: key as keyof Deno.PermissionOptionsObject, + name: key as Deno.PermissionDescriptor["name"], }).state; const access = permCache[key]; access === "granted" && args.push(`--allow-${key}`); diff --git a/dev/deno.json b/dev/deno.json index 406e7c2b6..55c9ce2c5 100644 --- a/dev/deno.json +++ b/dev/deno.json @@ -2,10 +2,11 @@ "name": "@deco/dev", "version": "1.107.2", "exports": { + ".": "./mod.ts", "./tailwind": "./tailwind.ts" }, "imports": { - "@deco/deco": "jsr:@deco/deco@^1.101.22-alpha.1", + "@deco/deco": "jsr:@deco/deco@^1.107.2-beta.1", "@std/fmt": "jsr:@std/fmt@^1.0.0", "@std/fs": "jsr:@std/fs@^1.0.4", "@std/path": "jsr:@std/path@^1.0.2" diff --git a/dev/mod.ts b/dev/mod.ts new file mode 100644 index 000000000..c2367ffda --- /dev/null +++ b/dev/mod.ts @@ -0,0 +1,20 @@ +import { newFsFolderProvider } from "@deco/deco/engine"; +import { exists } from "@std/fs/exists"; +import { join } from "@std/path"; +import { build as tailwindBuild } from "./tailwind.ts"; + +const DECO_FOLDER = ".deco"; +export const build = async (): Promise => { + await tailwindBuild(); + const decoFolder = join(Deno.cwd(), DECO_FOLDER); + if ( + Deno.args.includes("build") && await exists(decoFolder) + ) { + const provider = newFsFolderProvider(join(DECO_FOLDER, "blocks")); + const decofile = await provider.state(); + await Deno.writeTextFile( + join(decoFolder, "decofile.json"), + JSON.stringify(decofile, null, 2), + ); + } +}; diff --git a/engine/decofile/provider.ts b/engine/decofile/provider.ts index 9873d7aae..8c91345c6 100644 --- a/engine/decofile/provider.ts +++ b/engine/decofile/provider.ts @@ -88,10 +88,15 @@ const DECOFILE_RELEASE_ENV_VAR = "DECO_RELEASE"; // if decofile does not exists but blocks exists so it should be lazy const BLOCKS_FOLDER = join(Deno.cwd(), ".deco", "blocks"); +const BUILT_DECOFILE_PATH = join(Deno.cwd(), ".deco", "decofile.json"); const blocksFolderExistsPromise = exists(BLOCKS_FOLDER, { isDirectory: true, isReadable: true, }); +const builtDecofileExistsPromise = exists(BUILT_DECOFILE_PATH, { + isFile: true, + isReadable: true, +}); const DECOFILE_PATH_FROM_ENV = Deno.env.get(DECOFILE_RELEASE_ENV_VAR); /** @@ -110,9 +115,13 @@ export const getProvider = async ( return newFsProvider(); } - const endpoint = await blocksFolderExistsPromise - ? `folder://${BLOCKS_FOLDER}` - : DECOFILE_PATH_FROM_ENV; + let endpoint = DECOFILE_PATH_FROM_ENV; + if (await builtDecofileExistsPromise) { + endpoint = `file://${BUILT_DECOFILE_PATH}`; + } else if (await blocksFolderExistsPromise) { + endpoint = `folder://${BLOCKS_FOLDER}`; + } + if (endpoint) { console.info( colors.brightCyan( diff --git a/engine/mod.ts b/engine/mod.ts index 9a3b70e73..d930b5b54 100644 --- a/engine/mod.ts +++ b/engine/mod.ts @@ -1,4 +1,6 @@ +export { newFsFolderProvider } from "./decofile/fsFolder.ts"; export { ImportMapBuilder } from "./importmap/builder.ts"; export type { ImportMapResolver } from "./importmap/builder.ts"; export type { ParsedSource } from "./schema/deps.ts"; export { initLoader, parsePath } from "./schema/parser.ts"; + diff --git a/scripts/codemod.ts b/scripts/codemod.ts index 8551ced82..e234c553a 100644 --- a/scripts/codemod.ts +++ b/scripts/codemod.ts @@ -712,12 +712,30 @@ export const runCodeMod = async (context?: CodeModContext): Promise => { return pinDecoVersion.apply(txt, ctx); }, }, + { + options: { + match: [/.gitignore$/], + }, + apply: (txt) => { + if (txt.content.includes(".deco/decofile.json")) { + return txt; + } + return { + content: `${txt.content}\n.deco/decofile.json\n`, + }; + }, + }, { options: { match: [/dev.ts$/], }, apply: (txt) => { if (txt.content.includes("@deco/dev/tailwind")) { + return { + content: txt.content.replace("@deco/dev/tailwind", "@deco/dev"), + }; + } + if (txt.content.includes("@deco/dev")) { return txt; } return {