Skip to content
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

hathora init throws an error #261

Open
vyder opened this issue May 8, 2022 · 7 comments
Open

hathora init throws an error #261

vyder opened this issue May 8, 2022 · 7 comments

Comments

@vyder
Copy link

vyder commented May 8, 2022

Was about to try making a project from scratch, and discovered that hathora init fails with this error:

<path>/node_modules/hathora/cli.js:28
        throw new Error("Doesn't appear to be inside a hathora project");
        ^

Error: Doesn't appear to be inside a hathora project
    at getProjectRoot (<path>/node_modules/hathora/cli.js:28:15)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at Object.<anonymous> (<path>/node_modules/hathora/cli.js:132:17)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)

Looks like the issue is that cli.ts (line 140) calls getProjectRoot at the top level of the file, but in the init scenario hathora.yml doesn't exist yet - and so it throws.

Additionally, running hathora --help throws the same error - which makes it hard to understand what is expected as a new user - since it's unclear what a 'hathora project' is yet.

@vyder
Copy link
Author

vyder commented May 8, 2022

Reading through the other issues - probably best to fix this along with a CLI restructure referenced in #157

@vyder
Copy link
Author

vyder commented May 8, 2022

Ok my bad - I thought this generated a hathora project from scratch, but as I work through the uno tutorial, I see that the expected workflow is:

  1. Create hathora.yml by hand
  2. Run hathora init to generate project from that

@hpx7
Copy link
Member

hpx7 commented May 9, 2022

Probably a couple things that should be improved here:

  1. cli shouldn't call getProjectRoot() at the top level
  2. there should potentially be a separate hathora create command

@vyder
Copy link
Author

vyder commented May 9, 2022

What do you think about having hathora init create the hathora.yml from a template - similar to npm init or bundle init conventions - and then hathora generate does the generation?

Actually I haven't checked what the difference is between init and generate, but I have been running generate as I tweak the yaml definition during development.

@hpx7
Copy link
Member

hpx7 commented May 9, 2022

Right now, hathora init is responsible for project bootstrapping, i.e. creating the initial directory structure for your application (independent of what you put in your hathora.yml. hathora generate runs the codegen based on your hathora.yml.

I like the idea of being able to create something from a template so you don't have to create your hathora.yml from scratch when starting your project. Not sure whether it should be a separate hathora create --template <templateName> command or just folded into the existing hathora init command.

@vyder
Copy link
Author

vyder commented May 9, 2022

I didn't explain myself well - what I meant was that I think many package managers follow the npm/bundle convention where the init command either interactively or statically creates that pkg manager's respective manifest - package.json or Gemfile - and then they have other commands to do the subsequent generation.

Actually come to think of it rails uses new.

Ok maybe there is no fixed convention - and it's the wild west. Something to think about for the CLI UX.

@francislavoie
Copy link
Contributor

To add onto this, I had to create .env by hand as well. Would be nice if it prompted me to enter my app ID/secret if .env doesn't exist, and create a hathora.yml by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants