teambit / bit

A build system for development of composable software.

Home Page:https://bit.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`nextjs` workspace starter fails if `--empty` flag is used

coreyaus opened this issue Β· comments

Describe the bug

Following the instructions here to create a new Bit workspace using Next.js without pre-built components by applying the --empty flag throws an error:

bit new nextjs workspace-name --default-scope my-org.my-scope --aspect frontend.nextjs/nextjs-env --empty

The error message says:

unable to import the following component(s): my-org.my-scope/apps/my-nextjs-app.
the remote scope "my-org.my-scope" was not found

Or if the org and scope you supply do exist then the error says this:

error: a component "my-org.my-scope/apps/my-nextjs-app" was not found
your workspace.jsonc has this component-id set. you might want to remove/change it.

The underlying issue appears to be this line in the nextjs-workspace-starter.ts, where it adds the app to the workspace.jsonc file even if the --empty flag is used: https://bit.cloud/frontend/nextjs/templates/starters/~code/nextjs-workspace/nextjs-workspace-starter.ts#l50

Steps to Reproduce

  1. Read the official instructions in the section titled "Start without pre-built components" here: https://bit.cloud/frontend/nextjs/docs/intro

  2. Run the following command:

    bit new nextjs bit-hello-world --env frontend.nextjs/nextjs-env --empty

image

Steps to fix

This line should not be inserted in the workspace.jsonc if the --empty flag is passed: https://bit.cloud/frontend/nextjs/templates/starters/~code/nextjs-workspace/nextjs-workspace-starter.ts#l50. There may be other changes needed. What's the best way to handle this, or put another way, how do other starters observe and apply that --empty flag?

@leimonio over to you :)
(just add a check for empty before adding that line)

Thank you for reporting @coreyaus πŸ‘‹ Your solution was indeed really close to the fix. πŸ‘
The issue is now resolved, feel free to try again with the latest version. πŸš€

Thanks Kostas - I can confirm that's now working as expected πŸ‘Œ Happy new year!