Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions media/dojo-mark-full-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion packages/create-dojo/bin/index.d.ts

This file was deleted.

83 changes: 0 additions & 83 deletions packages/create-dojo/bin/index.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/create-dojo/bin/index.js.map

This file was deleted.

44 changes: 39 additions & 5 deletions packages/create-dojo/src/commands/start.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/usr/bin/env node


import { Command } from "commander";
import path from "path";
import { promises as fs } from "fs";
Expand Down Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Duplicate cloning of dojo-starter repository

The code clones the dojo-starter repository twice: once using git clone and again using degit. This duplication may cause unnecessary processing and potential conflicts.

To resolve this, remove one of the cloning methods. If you prefer using git clone, remove the existing degit cloning code. Here's how you can remove the redundant degit cloning:

-    // Clone dojo-starter
-    console.log(`Downloading dojo-starter...`);
-    spawn.sync("npx", ["degit", `dojoengine/dojo-starter`, dojoStarterPath], {
-        stdio: "inherit",
-    });

Alternatively, if you prefer using degit, remove the newly added git clone code in lines 59-73.

Committable suggestion was skipped due to low confidence.

// Clone dojo-starter
console.log(`Downloading dojo-starter...`);
spawn.sync("npx", ["degit", `dojoengine/dojo-starter`, dojoStarterPath], {
Expand Down Expand Up @@ -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 ",
Expand Down
Loading
Loading