Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
guitavano committed Sep 23, 2024
1 parent 4538883 commit a3cc6d9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
1 change: 1 addition & 0 deletions deco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const compatibilityApps = [{

const config = {
apps: [
app("my-app"),
app("posthog"),
app("smarthint"),
app("ra-trustvox"),
Expand Down
1 change: 1 addition & 0 deletions my-app
Submodule my-app added at cb7a03
42 changes: 18 additions & 24 deletions scripts/new.ts
Original file line number Diff line number Diff line change
@@ -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<Manifest, State> {
return { manifest, state };
}
// Aguarda o comando de clonagem terminar
await gitClone.status();
gitClone.close();

export type AppContext = AC<ReturnType<typeof App>>;
`,
// 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);

0 comments on commit a3cc6d9

Please sign in to comment.