From a3cc6d909a22272f7ad1a879493a8a9fde48f3c9 Mon Sep 17 00:00:00 2001 From: guitavano Date: Mon, 23 Sep 2024 07:49:13 -0300 Subject: [PATCH] test --- deco.ts | 1 + my-app | 1 + scripts/new.ts | 42 ++++++++++++++++++------------------------ 3 files changed, 20 insertions(+), 24 deletions(-) create mode 160000 my-app diff --git a/deco.ts b/deco.ts index 25e3653f8..dfd7935f9 100644 --- a/deco.ts +++ b/deco.ts @@ -10,6 +10,7 @@ const compatibilityApps = [{ const config = { apps: [ + app("my-app"), app("posthog"), app("smarthint"), app("ra-trustvox"), diff --git a/my-app b/my-app new file mode 160000 index 000000000..cb7a03753 --- /dev/null +++ b/my-app @@ -0,0 +1 @@ +Subproject commit cb7a0375311b6ec61981384f7c2dcd5c020dbb10 diff --git a/scripts/new.ts b/scripts/new.ts index 43cd8c865..555436982 100644 --- a/scripts/new.ts +++ b/scripts/new.ts @@ -1,34 +1,28 @@ import { join } from "std/path/mod.ts"; const appName = Deno.args[0]; +const repoUrl = "https://github.com/deco-cx/app-template" +const appPath = join(Deno.cwd(), appName); const decoTsPath = join(Deno.cwd(), "deco.ts"); const decoTs = await Deno.readTextFile(decoTsPath); -await Deno.mkdir(join(Deno.cwd(), appName)); -await Deno.writeTextFile( - decoTsPath, - decoTs.replace(` apps: [`, ` apps: [\n app("${appName}"),`), -); +// Criar a pasta do novo app +await Deno.mkdir(appPath); -await Deno.writeTextFile( - join(Deno.cwd(), appName, "mod.ts"), - ` -import type { App, AppContext as AC } from "deco/mod.ts"; -import manifest, { Manifest } from "./manifest.gen.ts"; +// Clonar o repositório para a nova pasta criada +const gitClone = Deno.run({ + cmd: ["git", "clone", repoUrl, appPath], +}); -export interface State { - // you can freely change this to accept new properties when installing this app - exampleProp: string -}; -/** - * @title ${appName} - */ -export default function App( - state: State, -): App { - return { manifest, state }; -} +// Aguarda o comando de clonagem terminar +await gitClone.status(); +gitClone.close(); -export type AppContext = AC>; -`, +// Atualizar o arquivo deco.ts com o novo app +await Deno.writeTextFile( + decoTsPath, + decoTs.replace(` apps: [`, ` apps: [\n app("${appName}"),`) ); + +const denoJsonPath = join(appPath, "deno.json"); +await Deno.remove(denoJsonPath); \ No newline at end of file