-
Notifications
You must be signed in to change notification settings - Fork 53
feat: new readme #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: new readme #286
Changes from 1 commit
9cbee9f
872235c
bf258d4
970e9bd
e6076f0
6e69883
2f3d287
51039e4
40eb5cd
9c2e4dd
509f5e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import { Command } from "commander"; | ||
| import path from "path"; | ||
| import { promises as fs } from "fs"; | ||
|
|
@@ -54,6 +56,21 @@ async function init(projectName: string, cwd: string, template: string) { | |
| // Rewrite package.json in client directory | ||
| await rewritePackageJson(projectName, clientPath); | ||
|
|
||
| console.log(`Cloning dojo-starter repository...`); | ||
| const gitCloneResult = spawn.sync( | ||
| "git", | ||
| [ | ||
| "clone", | ||
| "https://github.com/dojoengine/dojo-starter.git", | ||
| dojoStarterPath, | ||
| ], | ||
| { stdio: "inherit" } | ||
| ); | ||
|
|
||
| if (gitCloneResult.status !== 0) { | ||
| throw new Error(`Failed to clone dojo-starter repository.`); | ||
| } | ||
|
|
||
|
Comment on lines
+63
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate cloning of The code clones the To resolve this, remove one of the cloning methods. If you prefer using - // Clone dojo-starter
- console.log(`Downloading dojo-starter...`);
- spawn.sync("npx", ["degit", `dojoengine/dojo-starter`, dojoStarterPath], {
- stdio: "inherit",
- });Alternatively, if you prefer using
|
||
| // Clone dojo-starter | ||
| console.log(`Downloading dojo-starter...`); | ||
| spawn.sync("npx", ["degit", `dojoengine/dojo-starter`, dojoStarterPath], { | ||
|
|
@@ -120,14 +137,31 @@ export const start = new Command() | |
| .name("start") | ||
| .description("initialize a new project with a selected template") | ||
| .option("-c, --cwd <cwd>", "the working directory", process.cwd()) | ||
| .option("-t, --template <template>", "specify the template to use") | ||
| .action(async (options) => { | ||
| try { | ||
| const cwd = path.resolve(options.cwd); | ||
|
|
||
| const template = await select({ | ||
| message: "Select a template", | ||
| choices: templates, | ||
| }); | ||
| let template: string; | ||
|
|
||
| if (options.template) { | ||
| const selectedTemplate = templates.find( | ||
| (tpl) => tpl.value === options.template | ||
| ); | ||
| if (!selectedTemplate) { | ||
| console.error( | ||
| `Template "${options.template}" not found. Available templates are: ${templates | ||
| .map((tpl) => tpl.value) | ||
| .join(", ")}` | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| template = selectedTemplate.value; | ||
| } else { | ||
| template = await select({ | ||
| message: "Select a template", | ||
| choices: templates, | ||
| }); | ||
| } | ||
|
|
||
| const projectName = await input({ | ||
| message: "Project name ", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid adding a shebang line in a TypeScript file
Adding a shebang line (
#!/usr/bin/env node) to a TypeScript file is unnecessary and may cause issues during compilation or execution. Since TypeScript files are transpiled to JavaScript before execution, the shebang should be placed in the compiled JavaScript output if needed.To fix this, remove the shebang line from the TypeScript file:
-#!/usr/bin/env node📝 Committable suggestion