-
Notifications
You must be signed in to change notification settings - Fork 375
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
6 changed files
with
48 additions
and
88 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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { TemplateFramework } from "./types"; | ||
|
||
function renderDevcontainerContent( | ||
templatesDir: string, | ||
framework: TemplateFramework, | ||
frontend: boolean, | ||
) { | ||
const devcontainerJson: any = JSON.parse( | ||
fs.readFileSync(path.join(templatesDir, "devcontainer.json"), "utf8"), | ||
); | ||
|
||
if (frontend) { | ||
devcontainerJson.postCreateCommand = | ||
framework === "fastapi" | ||
? "cd backend && poetry install && cd ../frontend && npm install" | ||
: "cd backend && npm install && cd ../frontend && npm install"; | ||
} else { | ||
devcontainerJson.postCreateCommand = | ||
framework === "fastapi" ? "poetry install" : "npm install"; | ||
} | ||
return JSON.stringify(devcontainerJson, null, 2); | ||
} | ||
|
||
export const writeDevcontainer = async ( | ||
root: string, | ||
templatesDir: string, | ||
framework: TemplateFramework, | ||
frontend: boolean, | ||
) => { | ||
console.log("Adding .devcontainer"); | ||
const devcontainerContent = renderDevcontainerContent( | ||
templatesDir, | ||
framework, | ||
frontend, | ||
); | ||
const devcontainerDir = path.join(root, ".devcontainer"); | ||
fs.mkdirSync(devcontainerDir); | ||
await fs.promises.writeFile( | ||
path.join(devcontainerDir, "devcontainer.json"), | ||
devcontainerContent, | ||
); | ||
}; |
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
20 changes: 0 additions & 20 deletions
20
packages/create-llama/templates/devcontainers/fullstack-node-be/devcontainer.json
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
packages/create-llama/templates/devcontainers/node/devcontainer.json
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
packages/create-llama/templates/devcontainers/python/devcontainer.json
This file was deleted.
Oops, something went wrong.