Skip to content

Commit 9cbee9f

Browse files
feat: new readme
1 parent 26b77b3 commit 9cbee9f

File tree

6 files changed

+96
-110
lines changed

6 files changed

+96
-110
lines changed

media/dojo-mark-full-dark.svg

+8
Loading

packages/create-dojo/bin/index.d.ts

-1
This file was deleted.

packages/create-dojo/bin/index.js

-83
This file was deleted.

packages/create-dojo/bin/index.js.map

-1
This file was deleted.

packages/create-dojo/src/commands/start.ts

+39-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
import { Command } from "commander";
24
import path from "path";
35
import { promises as fs } from "fs";
@@ -54,6 +56,21 @@ async function init(projectName: string, cwd: string, template: string) {
5456
// Rewrite package.json in client directory
5557
await rewritePackageJson(projectName, clientPath);
5658

59+
console.log(`Cloning dojo-starter repository...`);
60+
const gitCloneResult = spawn.sync(
61+
"git",
62+
[
63+
"clone",
64+
"https://github.com/dojoengine/dojo-starter.git",
65+
dojoStarterPath,
66+
],
67+
{ stdio: "inherit" }
68+
);
69+
70+
if (gitCloneResult.status !== 0) {
71+
throw new Error(`Failed to clone dojo-starter repository.`);
72+
}
73+
5774
// Clone dojo-starter
5875
console.log(`Downloading dojo-starter...`);
5976
spawn.sync("npx", ["degit", `dojoengine/dojo-starter`, dojoStarterPath], {
@@ -120,14 +137,31 @@ export const start = new Command()
120137
.name("start")
121138
.description("initialize a new project with a selected template")
122139
.option("-c, --cwd <cwd>", "the working directory", process.cwd())
140+
.option("-t, --template <template>", "specify the template to use")
123141
.action(async (options) => {
124142
try {
125143
const cwd = path.resolve(options.cwd);
126-
127-
const template = await select({
128-
message: "Select a template",
129-
choices: templates,
130-
});
144+
let template: string;
145+
146+
if (options.template) {
147+
const selectedTemplate = templates.find(
148+
(tpl) => tpl.value === options.template
149+
);
150+
if (!selectedTemplate) {
151+
console.error(
152+
`Template "${options.template}" not found. Available templates are: ${templates
153+
.map((tpl) => tpl.value)
154+
.join(", ")}`
155+
);
156+
process.exit(1);
157+
}
158+
template = selectedTemplate.value;
159+
} else {
160+
template = await select({
161+
message: "Select a template",
162+
choices: templates,
163+
});
164+
}
131165

132166
const projectName = await input({
133167
message: "Project name ",

0 commit comments

Comments
 (0)