Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions packages/create-orange/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ async function main() {
validate: (value) => value.length > 0,
});

const branch = process.argv[3] ?? "main";

await command(
{
message: "Cloning template...",
bin: "git",
args: ["clone", "https://github.com/zebp/orange-template.git", name],
args: [
"clone",
"https://github.com/zebp/orange-template.git",
name,
"--depth",
"1",
"--branch",
branch,
],
},
{ clearPromptOnDone: true },
{ clearPromptOnDone: true }
);

const replacements = {
Expand All @@ -36,6 +46,7 @@ async function main() {
rmSync(`${name}/.git`, { recursive: true, force: true });
replace(`${name}/package.json`, replacements);
replace(`${name}/wrangler.jsonc`, replacements);
replace(`${name}/README.md`, replacements);

const doInstallDeps = await confirm({
message: "Do you want to install dependencies?",
Expand All @@ -50,7 +61,7 @@ async function main() {
args: ["install"],
cwd: name,
},
{ clearPromptOnDone: true },
{ clearPromptOnDone: true }
);
}

Expand All @@ -64,7 +75,7 @@ async function main() {
args: ["init"],
cwd: name,
},
{ clearPromptOnDone: true },
{ clearPromptOnDone: true }
);

execSync("git add .", { cwd: name });
Expand All @@ -76,7 +87,7 @@ async function main() {
args: ["commit", "-m", "Initial commit"],
cwd: name,
},
{ clearPromptOnDone: true },
{ clearPromptOnDone: true }
);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/create-orange/src/replace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as fs from "node:fs";

export function replace(path: string, replacements: Record<string, string>) {
if (!fs.existsSync(path)) {
return;
}

let contents = fs.readFileSync(path, "utf-8");

for (const [key, value] of Object.entries(replacements)) {
Expand Down