-
Notifications
You must be signed in to change notification settings - Fork 48
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
fix: create-dojo project broken unless name is worlds
#333
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA new directory named Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
packages/create-dojo/src/commands/start.ts (3)
69-79
: Enhance error handling and robustness of the cloning operation.While the switch to
npx degit
is a good improvement, consider these enhancements:
- Add a check for
npx
availability- Provide more detailed error messages to help users troubleshoot
Consider this implementation:
// Clone dojo-starter console.log(`Downloading dojo-starter...`); + // Check if npx is available + const npxCheck = spawn.sync('npx', ['--version'], { stdio: 'ignore' }); + if (npxCheck.status !== 0) { + throw new Error('npx is required but not found. Please install [email protected] or later.'); + } + const starterCloneResult = spawn.sync( "npx", ["degit", `dojoengine/dojo-starter`, dojoStarterPath], { stdio: "inherit" } ); if (starterCloneResult.status !== 0) { - throw new Error(`Failed to clone dojo-starter repository.`); + throw new Error( + `Failed to clone dojo-starter repository. ` + + `Please ensure you have internet connectivity and the repository exists at ` + + `https://github.com/dojoengine/dojo-starter` + ); }
Line range hint
39-46
: Review directory structure for path compatibility.The current implementation creates
dojo-starter
inside the project directory, but the PR mentions issues with relative paths in examples referring to../../worlds/dojo-starter
. This structure might still cause issues with example configurations.Consider these options:
- Update all example configurations to use relative paths based on the new structure
- Create a symlink from
../../worlds/dojo-starter
to the localdojo-starter
directory- Document the expected directory structure in the README
Would you like me to help implement any of these solutions?
Line range hint
1-8
: Enhance template validation and error handling.The template validation could be improved to:
- Validate template existence before starting the initialization
- Handle network issues when fetching templates
- Provide better error messages for template-related issues
Consider enhancing the template validation:
.action(async (options) => { try { const cwd = path.resolve(options.cwd); let template: string; + + // Validate template repository existence + const validateTemplate = async (templateName: string) => { + const url = `https://api.github.com/repos/dojoengine/dojo.js/contents/examples/${templateName}`; + try { + const response = await fetch(url); + return response.status === 200; + } catch (error) { + return false; + } + }; 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 + `Template "${options.template}" not found.\n\nAvailable templates:\n${templates + .map((tpl) => `- ${tpl.value}: ${tpl.description}`) + .join("\n")}` - .map((tpl) => tpl.value) - .join(", ")}` ); process.exit(1); } + if (!(await validateTemplate(selectedTemplate.value))) { + throw new Error( + `Template "${selectedTemplate.value}" exists in the list but ` + + `could not be accessed. Please check your internet connection ` + + `or report this issue.` + ); + } template = selectedTemplate.value; }Also applies to: 144-167
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (12)
examples/dojo-starter
(1 hunks)examples/example-nodejs-bot/dojoConfig.ts
(1 hunks)examples/example-vanillajs-phaser-recs/dojoConfig.ts
(1 hunks)examples/example-vite-kitchen-sink/dojoConfig.ts
(1 hunks)examples/example-vite-react-app-recs/dojoConfig.ts
(1 hunks)examples/example-vite-react-phaser-recs/dojoConfig.ts
(1 hunks)examples/example-vite-react-pwa-recs/dojoConfig.ts
(1 hunks)examples/example-vite-react-sdk/dojoConfig.ts
(1 hunks)examples/example-vite-react-threejs-recs/dojoConfig.ts
(1 hunks)examples/example-vite-svelte-recs/dojoConfig.ts
(1 hunks)examples/example-vue-app-recs/dojoConfig.ts
(1 hunks)packages/create-dojo/src/commands/start.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (11)
- examples/dojo-starter
- examples/example-nodejs-bot/dojoConfig.ts
- examples/example-vanillajs-phaser-recs/dojoConfig.ts
- examples/example-vite-kitchen-sink/dojoConfig.ts
- examples/example-vite-react-app-recs/dojoConfig.ts
- examples/example-vite-react-phaser-recs/dojoConfig.ts
- examples/example-vite-react-pwa-recs/dojoConfig.ts
- examples/example-vite-react-sdk/dojoConfig.ts
- examples/example-vite-react-threejs-recs/dojoConfig.ts
- examples/example-vite-svelte-recs/dojoConfig.ts
- examples/example-vue-app-recs/dojoConfig.ts
🔇 Additional comments (1)
packages/create-dojo/src/commands/start.ts (1)
Line range hint 39-46
: Verify directory structure and symlink creation.
According to the PR objectives, a symlink should be created to ensure compatibility with newly created projects. However, I don't see the symlink creation in the code.
Let's verify the directory structure and symlink requirements:
Currently the
create-dojo
command is broken in 2 ways:dojo-starter
repository twice. The second attempt always fails, but the project creation process is not interrupted thanks to the command result not being checked. Nonetheless it's bad DX.dojo-starter
folder by../../worlds/dojo-starter
, which means newly created projects must be named exactlyworlds
to work. This is the bigger issue.Introduced changes
dojo-starter
folder compatible with a newly created project by adding a symlinkdojo-starter
.Summary by CodeRabbit
New Features
dojo-starter
for future content organization.dojo-starter
repository to usenpx degit
for improved efficiency.Bug Fixes
Documentation
dojoConfig.ts
files for clarity and simplicity.