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

feat(gatsby-cli): remove feature flag for new interactive gatsby new experience #28125

Merged
merged 1 commit into from Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 51 additions & 16 deletions docs/docs/gatsby-cli.md
Expand Up @@ -27,11 +27,60 @@ You can also use the `package.json` script variant of these commands, typically

### `new`

#### Usage
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need updating in Contentful too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think these docs live in Contentful 🤔 Either way we should ship this for now and (worst-case scenario) update Contentful afterwards 👍

cc @meganesu


```shell
gatsby new
```

The CLI will run an interactive shell asking for these options before creating a Gatsby site for you:

```shell
gatsby new

What would you like to name the folder where your site will be created?
my-gatsby-site

Will you be using a CMS? (single choice)
No (or I'll add it later)
WordPress
Contentful
Sanity
DatoCMS
Shopify

Would you like to install a styling system? (single choice)
No (or I'll add it later)
CSS Modules/PostCSS
styled-components
Emotion
Sass
Theme UI

Would you like to install additional features with other plugins? (multiple choice)
◯ Add the Google Analytics tracking script
◯ Add responsive images
◯ Add page meta tags with React Helmet
◯ Add an automatic sitemap
◯ Enable offline functionality
◯ Generate a manifest file
◯ Add Markdown support (without MDX)
◯ Add Markdown and MDX support
```

#### Creating a site from a starter

To create a site from a starter instead, run the command while immediately specifying your site name and starter URL:

```shell
gatsby new [<site-name> [<starter-url>]]
```

#### Arguments
Note that this will not prompt you to create a custom setup, but only clone the starter from the URL you specified.

##### Arguments

| Argument | Description |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -40,7 +89,7 @@ gatsby new [<site-name> [<starter-url>]]

> Note: The `site-name` should only consist of letters and numbers. If you specify a `.`, `./` or a `<space>` in the name, `gatsby new` will throw an error.

#### Examples
##### Examples

- Create a Gatsby site named `my-awesome-site` using the default starter:

Expand All @@ -54,20 +103,6 @@ gatsby new my-awesome-site
gatsby new my-awesome-blog-site https://github.com/gatsbyjs/gatsby-starter-blog
```

- If you leave out both of the arguments, the CLI will run an interactive shell asking for these inputs:

```shell
gatsby new
? What is your project called? › my-gatsby-project
? What starter would you like to use? › - Use arrow-keys. Return to submit.
❯ gatsby-starter-default
gatsby-starter-hello-world
gatsby-starter-blog
(Use a different starter)
```

_Note: you can try out the experimental interactive experience from the `create-gatsby` package with the `GATSBY_EXPERIMENTAL_GATSBY_NEW_FLOW=true` flag, which will prompt you with questions about the kind of site you're building, and install the plugins you'll need automatically._

See the [Gatsby starters docs](/docs/gatsby-starters/) for more details.

### `develop`
Expand Down
9 changes: 1 addition & 8 deletions integration-tests/gatsby-cli/__tests__/new.js
Expand Up @@ -79,14 +79,7 @@ describe(`gatsby new`, () => {
expect(code).toBe(1)
})

it(`runs the prompted starter selection process when no arguments are passed`, () => {
const [_, logs] = GatsbyCLI.from(cwd).invoke([`new`])

logs.should.contain(`What is your project called?`)
})

it(`runs create-gatsby when no arguments are provided to gatsby new with the GATSBY_EXPERIMENTAL_GATSBY_NEW_FLOW flag set`, () => {
process.env.GATSBY_EXPERIMENTAL_GATSBY_NEW_FLOW = true // when this flag is removed we can remove this line
it(`runs create-gatsby when no arguments are provided to gatsby new`, () => {
const [_, logs] = GatsbyCLI.from(cwd).invoke([`new`])

logs.should.contain(`Welcome to Gatsby!`)
Expand Down
6 changes: 1 addition & 5 deletions packages/gatsby-cli/src/create-cli.ts
Expand Up @@ -504,11 +504,7 @@ export const createCli = (argv: Array<string>): yargs.Arguments => {
const rootPathStr = rootPath ? String(rootPath) : undefined

// We only run the interactive CLI when there are no arguments passed in
if (
process.env.GATSBY_EXPERIMENTAL_GATSBY_NEW_FLOW &&
!starterStr &&
!rootPathStr
) {
if (!starterStr && !rootPathStr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should eventually handle root path too, skipping the first question

await runCreateGatsby()
} else {
await initStarter(starterStr, rootPathStr)
Expand Down