-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
20 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule my-app
added at
cb7a03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |