Commit graph

49 commits

Author SHA1 Message Date
Ivan Torres
bebc63fce0
Update devdependecy commander (#66771)
Upgrade devdependecy commander to latest versio.

Now in command, the optional argument is with [] and the required
argument is with <>.

---------

Co-authored-by: torresgol10.itd <torresgol10.itd@gmail.com>
Co-authored-by: Sam Ko <sam@vercel.com>
2024-06-12 11:25:09 -07:00
Loren ☺️
a0911afbe0
Clarify create-next-app question wording (#66157)
### Why?

The current wording leaves room for questions/misinterpretations like:

- What does "use `src/`" mean? Does this affect my build, like compile
`src/*.ts` to `lib/*.js`?
- Oh, I can customize import aliases to use @ for project root instead
of doing relative everywhere? I'll choose Yes!

I think the proposed wording clarifies ^

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-24 16:11:30 -07:00
Arindam Majumder
60ad8affd7
feat: Add option to enable Turbopack with create-next-app (#65926)
This PR addresses an issue where the `dev` script in `package.json` was
not correctly updated to use the `--turbo` option when specified. The
changes ensure that the `dev` script is set to `next dev --turbo` if the
`turbo` option is enabled.

### Changes:
1. **Function Modification**:
- Updated the `modifyPackageJson` function to include a check for the
`turbo` parameter.
- If `turbo` is true, the `dev` script in `package.json` is set to `next
dev --turbo`.
   - If `turbo` is false, the `dev` script remains `next dev`.

2. **Integration in App Creation**:
- Integrated the `modifyPackageJson` function into the app creation
process to ensure the `dev` script is correctly set based on the `turbo`
parameter.

### Testing:
- Verified that the `dev` script in `package.json` is correctly updated
to `next dev --turbo` when the `turbo` option is enabled.
- Ensured that the `dev` script remains `next dev` when the `turbo`
option is not enabled.

### Related Issues:
- Fixes #65924

### Notes:
- This change ensures that developers opting to use Turbopack for
development will have the correct script set up automatically.

---------

Signed-off-by: Arindam Majumder <arindammajumder2020@gmail.com>
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: devjiwonchoi <devjiwonchoi@gmail.com>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-20 20:34:24 +00:00
Sam Ko
c07497eb9c
chore(create-next-app): add --empty flag (#65532)
## Why?

Adding an `--empty` flag so we can easily create an empty Create Next
App template.

Closes NEXT-3367

---------

Co-authored-by: Ahmed Abdelbaset <A7med3bdulBaset@gmail.com>
2024-05-09 17:18:20 +00:00
hrmny
64b718c661
chore: update prettier to 3.2.5 (#65092) 2024-05-08 21:47:14 +02:00
Vladimir Kryachko
2d341c7b89
Add --skip-install flag to create-next-app (#64691)
This change allows disabling automatic `npm install`(or other supported
package managers).

Installing NextJS dependencies takes a long time and results in 0.5GB on
disk inside `node_modules`, it's not always what you want as sometimes
it's useful to delay dependency installation to a later time.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-23 22:04:54 +00:00
Fellipe Utaka
3e449b235d
fix(create-next-app): validate --import-alias value (#63855)
Fixes #63854

Previously, there was no check when a path was passed with the
--import-alias flag. Furthermore, the regex used before did not check
for possible invalid paths.

The current regex checks the following conditions:
- It must follow the pattern `<prefix>/*`
- The prefix cannot contain invalid characters for folders, such as:
(whitespaces, /, <, >, :, ", /, \, |, ? and *)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-02 13:10:14 -07:00
Kuzey Kose
09c0065c3d
fix(create-next-app): add --no-import-alias for non-interactive (#62035)
### What?

The [create-next-app
documentation](https://nextjs.org/docs/app/api-reference/create-next-app#non-interactive)
under API reference says that;

> Further, you can negate default options by prefixing them with --no-
(e.g., --no-eslint).

When I tried to use --no-import-alias, I thought that it would
automatically use the default alias (@/*), but it does not.

### Why?

Each option has --no prefix control but import-alias has no --no prefix
control to give default value to program.

In an [Interactive](https://nextjs.org/#interactive) approach, the user
can select a prompt; `Would you like to customize the default import
alias (@/*)? No / Yes.` If the user selects no, then the default alias
is applied with @/*.

### How?

Implementing a condition solve the problem for general purpose. If
arguments includes `--no-import-alias` then the importAlias section
automatically apply the default value.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2024-02-20 10:23:04 -05:00
Sukka
b8b104506d
refactor(cna): make create-next-app even smaller and faster (#58030)
The PR further reduces the `create-next-app` installation size by
another 80 KiB:

- Replace the callback version of Node.js built-in `dns` API usage with
`dns/promise` + async/await
- Replace `got` w/ `fetch` since Next.js and `create-next-app` now
target Node.js 18.17.0+
- Download and extract the tar.gz file in the memory (without creating
temporary files). This improves the performance.
- Some other minor refinements.

Following these changes, the size of `dist/index.js` is now 536 KiB.
2024-01-11 09:40:29 -05:00
Anthony Shew
5a10d2566b
Getting rid of a few TypeScript anys. (#60017)
Had some spare time and was trying to get more familiar with the
codebase.

Added a few types to `create-next-app` here. Nothing fancy!

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-01-03 16:22:29 -05:00
Vũ Văn Dũng
cf3d73a46b
Add the default import alias to create-next-app prompt for clarity (#55896)
### Why?

Whenever I run `create-next-app` and reach this question

```
Would you like to customize the default import alias? No / Yes
```

I always have to select "No", because I don't remember what this default import alias here is. [It _is_ documented to be `@/*`](https://nextjs.org/docs/app/api-reference/create-next-app#non-interactive), but the documentation is relatively hidden and not many people know about it – it's also easy to forget.

Even more confusingly, the next question ("What import alias would you like configured?") doesn't have this `@/*` as the default answer, but the user's last choice as the default answer instead (which could be different from `@/*` – making people wonder if Next.js changed their defaults overnight).

I suppose it would be better to just make it clear in the prompt itself, so people with skill issues who happen to forget that default value (like me) can still confidently select "Yes" if they want `@/*`, without having to do "No" and manually type `@/*` again.

### How

```diff
- Would you like to customize the default import alias?
+ Would you like to customize the default import alias (@/*)?
```
2023-09-26 22:58:46 +00:00
Steven
7ec76eb7e4
fix(create-next-app): fix CI defaults (default to typescript) (#53686)
Since the default for `create-next-app` has been TypeScript for some time, we should make sure this is also the case for CI.

This PR also makes sure that CI will use the same value as if the question was asked. Therefore changing defaults in the future will automatically change the behavior of CI defaults.

- Related https://github.com/vercel/next.js/issues/42592
2023-08-07 17:24:45 +00:00
Colin McDonnell
57ce466502
Add --use-bun to create-next-app (#53467)
This adds support for `--use-bun` to `create-next-app` to use `bun
install` when bootstrapping a new project.

```
npx create-next-app --use-bun
```

As with Yarn and pnpm, it reads from `npm_config_user_agent` to
determine if the user ran `bunx create-next-app`. If so, it defaults to
using Bun.

```sh
bunx create-next-app
```

## For Contributors

### Improving Documentation

- [x] Run `pnpm prettier-fix`
- [x] `pnpm build && pnpm lint` 
- [x] Added test to
`test/integration/create-next-app/package-manager.test.ts`

---------
2023-08-03 18:00:38 -07:00
Sukka
66ffc3cd39
refactor(cna): replace chalk with picocolors, glob with fast-glob@2.2.7 (#53146)
Follows #53115

- Replace `chalk` with `picocolors`
  - Note that `chalk.hex('#007acc')` has been replaced with `picocolors.blue`
- Replace `glob` with `fast-glob@2.2.7`
  - Not only does `fast-glob` is a faster drop-in replacement of `glob` with first-party `Promise`-based API support, but also `fast-glob` is already a dependency of `cpy`:
 
  <img width="812" alt="image" src="https://github.com/vercel/next.js/assets/40715044/8efa24c4-5312-4b1c-bf8d-68255ca30b60">


Together the PR removes about `50 KiB` from the `create-next-app/dist/index.js`:

<img width="570" alt="image" src="https://github.com/vercel/next.js/assets/40715044/db2f3723-14cc-48ce-9cb2-8aa1fb1d5e95">


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-07-26 18:16:13 +00:00
Steven
97461f0bba
fix(create-next-app): consolidate messages to "Would you like to use" (#52011)
This PR ensure that `create-next-app` questions are all formatted the
same way:

```
Would you like to use <feature>?
```

fix NEXT-1333
2023-06-30 18:11:23 +02:00
Anders Kjær Damgaard
428342dbdf
Add --use-yarn flag to create-next-app (#49407)
# Add `--use-yarn` flag to `create-next-app`

fixes #49405

- [x] Implement `--use-yarn` flag
- [x] Update docs
- [x] Add tests

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-05-10 14:51:12 +02:00
Tim Neutkens
3cb15a064b
Update create-next-app App Router question (#49111)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-02 17:28:31 -07:00
JJ Kasper
26f69d5ef3
Simplify CNA prompts a bit (#49063)
This updates the default CNA prompts a bit to be more straightforward.

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1681919151818769)
x-ref: [slack thread](https://vercel.slack.com/archives/C04K237UHCP/p1682959312307409)
2023-05-02 17:01:36 +00:00
Balázs Orbán
2a8961b36b
fix(cli): unify styles/content of templates (#47294)
### What?

- fixes some typos
  - [x] getting started by editing "filename"
  - [x] match app/pages content
  - [x] fix utm params 
- [x] Reverted different text coloring in the CLI as they were hard to
read on a dark background
- [x] removes 13 ([Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1679151687968809?thread_ts=1679123593.519319&cid=C03KAR5DCKC))


### Why?

Unifying the styles across all templates

### How?

Used
https://github.com/vercel/next.js/tree/canary/packages/create-next-app/templates/default/js
as the base and made sure that all other templates match its content and
styling.

Related: #46927. This PR was extracted from #47238 to make reviewing
easier.

fix NEXT-851 ([link](https://linear.app/vercel/issue/NEXT-851))

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-20 15:33:44 -07:00
Balázs Orbán
8c98a207f2
feat(cli): introduce --tailwind flag (#46927)
### What?

This PR introduces a new `--tailwind` flag to the `create-next-app` CLI,
to make it easier to bootstrap a Next.js app with Tailwind CSS
pre-configured. This is going to be the **default**. To opt-out of
Tailwind CSS, you can use the `--no-tailwind` flag.

### Why?

Tailwind CSS is one of the most popular styling solutions right now, and
we would like to make it easier to get started.

Currently, the closest you can come to this is by running `pnpm create
next-app -e with-tailwindcss` which will clone the
https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss
example. But that example is not configured for the App Router. This PR
will let you add Tailwind CSS to both `app/`, `pages/`, and start out
with TypeScript or JavaScript via the CLI prompts.

(Some community feedback
https://twitter.com/dev_jonaskaas/status/1632367991827443713,
https://twitter.com/samselikoff/status/1634662473331617794)

### How?

We are adding 4 new templates to the CLI bundle.

> Note: The styling is not pixel-perfect compared to the current
templates (using CSS modules) to require fewer overrides, but I tried to
match it as close as possible. Here are a few screenshots:

<details>
<summary><b>Current, light</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733372-9dba86fe-9191-471d-ad9f-ab904c47f544.png"/>
</details>

<details>
<summary><b>Tailwind (new), light</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733610-038d9d0f-634d-4b69-b5c2-a5056b56760c.png"/>
</details>

<details>
<summary><b>Current, dark, responsive</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733790-9b4d730c-0336-4dbe-bc10-1cae1d7fd145.png"/>
</details>

<details>
<summary><b>Tailwind (new), dark, responsive</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224734375-28384bbc-2c3a-4125-8f29-c102f3b7aa1d.png"/>
</details>

#### For reviewers

This introduces 4 new templates, with a very similar code base to the
original ones. To keep the PR focused, I decided to copy over duplicate
code, but we could potentially create a shared folder for files that are
the same across templates to somewhat reduce the CLI size. Not sure if
it's worth it, let me know. Probably fine for now, but something to
consider if we are adding more permutations in the future.

---

~Work remaining:~

- [x] app+ts
	- [x] layout
	- [x] dark mode
	- [x] media queries
	- [x] animations
- [x] app+js
- [x] pages+ts
- [x] pages+js
- [x] prompt/config
- [x] deprecate Tailwind CSS example in favor of CLI
- [x] update docs
- [x] add test
- [x] add [Prettier
plugin](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
 
Closes NEXT-772
Related #45814, #44286
2023-03-16 16:06:27 +01:00
Julius Marminge
00cbc5abf4
refactor(create-next-app): simplify import alias validation logic (#45241) 2023-01-24 16:36:16 -08:00
JJ Kasper
c0ad169e17
Ensure ctrl + c handling works with CNA prompts correctly (#45205) 2023-01-23 19:30:38 -08:00
Max Leiter
a3b89a5230
create-next-app: warn if project dir isn't empty before prompts (#45195) 2023-01-23 12:10:45 -08:00
JJ Kasper
189008c6a9
Re-prompt on invalid import alias (#45194) 2023-01-23 12:00:02 -08:00
GJunior
196957fd68
Next/Script documentation beforeInteractive inconsistency (#44898)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Closes https://github.com/vercel/next.js/issues/43566
2023-01-15 17:08:11 -08:00
JJ Kasper
a72a9f2225
Prompt for custom import alias and store preferences in CNA (#44872) 2023-01-13 16:51:25 -08:00
JJ Kasper
893328905f
Update prompts for CNA and add default @/* alias (#44672)
This adds prompts for using a `src/` directory and experimental `app/`
directory with create-next-app. Also adds `jsconfig` and `tsconfig`
options to alias `@/*` by default.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1672856097701429)


## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2023-01-09 15:41:12 -08:00
JJ Kasper
22b449ba56
Fix default value handling for CNA in CI (#42596)
Fixes: https://github.com/vercel/next.js/issues/42592

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
2022-11-07 14:02:34 -08:00
JJ Kasper
5da108bc19
Update default eslint choice for CNA setup (#42371)
This ensures we continue to default to ESLint be configured for new
projects so that our lint checks are enabled for new projects.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-02 20:17:37 -07:00
JJ Kasper
b7ea0a5abe
Add prompt for ESLint to CNA (#42218)
Following up https://github.com/vercel/next.js/pull/42012 this adds an
additional prompt for include ESLint config/dependencies or not. As
discussed, this also removes the slow down from doing separate
`dependencies` and `devDependencies` installs since this separation is
no longer required now that we have `output: 'standalone'` which ensures
only actual necessary dependency files are used for production builds.

<details>

<summary>Before</summary>


https://user-images.githubusercontent.com/22380829/198953290-116b422d-4359-4aa9-9d82-b3265fde7b3f.mp4


</details>

<details>

<summary>After</summary>




https://user-images.githubusercontent.com/22380829/198953347-20dbf897-92b3-45ea-a9d2-cfb61622251d.mp4



</details>

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-10-31 08:51:50 -07:00
C. Lewis
389c77f205
feat(create-next-app): JS/TS prompt (with appDir support); enhanced testing (#42012)
Resubmitting this PR following this comment from Tim. This work has been done already and we can build off of it to get this in faster. 

> Just to be clear we're planning to rework create-next-app to give you the option to choose between JavaScript or TypeScript so it'll solve this request. For `app` right now it'll stay TypeScript till that is implemented.
> 
> _Originally posted by @timneutkens in https://github.com/vercel/next.js/discussions/41745#discussioncomment-3985833_

---

I added the `--ts, --typescript` flag to `create-next-app` in https://github.com/vercel/next.js/pull/24655, and since then I have seen it used very frequently, including in recent issues (such as https://github.com/vercel/next.js/issues/33314) and most Next.js tutorials on YouTube. I noticed the template logic added in this PR was also used to add the `appDir` configuration as well.

We discussed a while ago adding the following user flow:

- `create-next-app --js, --javascript` creates a JS project
- `create-next-app --ts, --typescript` creates a TS project
- `create-next-app [name]` (no `--js, --ts`) prompts the user to choose either JS or TS, with TS selected by default.

### Review

Adding support for appDir and refactoring the templates brought the pain-of-review up a bit, but it's not so bad when broken into increments.

The original 8-file diff is here:
1f47d9b0bf

And the PR that brought the diff up to 59 files (mostly owed to `app` template dirs and file structure refactors):
bd3ae4afd3 ([PR link](https://github.com/ctjlewis/next.js/pull/3/files))

### Demo

https://user-images.githubusercontent.com/1657236/198586216-4691ff4c-48d4-4c6c-b7c1-705c38dd0194.mov


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-10-31 05:43:39 +00:00
Balázs Orbán
e0b04f22e3
feat(cna): add template (#41660)
Adds a new template for `app/` via `--experimental-app` flag.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-10-22 14:18:39 -07:00
Néstor
5cd31e41ca
Add npm to create-next-app environment package manager parser (#41279)
Gracefully parse the environment package manager when calling
`create-next-app` instead of passing extra arguments.

Reference: #41090

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-10-13 14:34:55 -07:00
Exortions
ef69aca4df
Merge multiple log statements (#35310)
* Merge multiple log statements

It is inefficient to use multiple console.log satements, and if something is logged to the console in the middle of execution, it will be in the center of the text, making it hard to read.
This pull request merges multiple console.logs into one.

In addition, it reduces the bundle size.

* ensure formatting matches

* update test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-05-22 13:50:08 -05:00
JJ Kasper
3a313a4ca6
Fix create-next-app failing without yarn installed (#35608)
This fixes our package manager detection which was changed slightly in https://github.com/vercel/next.js/pull/34947 for `pnpm` support to ensure the default case still attempts detecting the available package manager if no preference is specified in the command args. This also adds a test case to ensure the install succeeds when we fail to detect a valid `yarn` binary and no preference is set via the `npm_config_user_agent` env variable. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/35607
Fixes: https://github.com/vercel/next.js/issues/35599
2022-03-26 08:29:52 +00:00
Balázs Orbán
62c33c1eb7
feat: support pnpm with create-next-app (#34947)
* feat: support `pnpm` with `create-next-app`

* test: add `--use-pnpm` tests

* docs: mention `--use-pnpm` flag in docs

* test: remove `only`

* Update test/integration/create-next-app/index.test.ts

Co-authored-by: Steven <steven@ceriously.com>

* chore: add pnpm action setup to tests

* chore: use latest pnpm

* chore: debug

* chore: debug

* fix: fall back to `yarn` instead of `npm`

* test: run all tests

Co-authored-by: Steven <steven@ceriously.com>
2022-03-04 00:49:24 +01:00
C. Lewis
9c77cda6c5
feat(create-next-app): add --ts, --typescript support (#24655)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2021-05-07 10:08:16 +02:00
James George
bd70e8fced
chore(create-next-app): update help information (#24251)
Add description for `--use-npm` flag that shows up as part of the help information.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes
2021-04-20 13:12:10 +00:00
James Mosier
d51fef5fc9
chore(create-next-app): remove example picker (#13977)
If a user does not specify `--example` when using create-next-app then just spin up the default template and only prompt them for the name of their project.

if a user does specify `--example` (with no string after it) then show them the example picker. 

Closes #13960
2020-06-10 03:14:24 +00:00
Tim Neutkens
b124ed2e14
Added no-shadow rule to eslint (#13645)
Was going through _document and noticed some variable shadowing going on. Added a rule for it to our eslint configuration and went through all warnings with @Timer.
2020-06-01 21:00:22 +00:00
Joe Haddad
bee8c31b87
Lint for invalid imports (#13482)
This adds a lint rule to ensure we don't import dev dependencies by accident.
2020-05-28 08:23:10 +00:00
Marco Moretti
b3e45fab5e
feat(cli): use default template when GH is offline (#12194)
fix #12136 

I add a prompt if there is an error when trying to download example files.
Maybe could be better to add an error class and in create-app.ts on every "console.error" trow a new Exception and manage it in catch. What you think ? 👯
2020-05-26 16:39:18 +00:00
James Mosier
846ec74013
Special case default template in CNA (#12109)
This addresses #11910 in which `-e default` was not working because there was no example with the name `default`. This PR checks if a user inputted `default` as the example argument for `create-next-app` and if so it will use the local `default` template in the create-next-app directory.

Closes #11910
2020-05-23 22:50:31 +00:00
Joe Haddad
86160a5190
Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
Maxi Gimenez
ce830af202
chore(create-next-app): add missing types (#12691) 2020-05-10 17:51:47 -04:00
Dylan Brookes
bc7d18367b
Confirm if user wants example when creating app (#10543)
* Confirm if user wants example when creating app

* Only ask user to choose example if they provide --example flag

* Simplify the search

* Added test

* Use a select to pick the template

* Updated test

* check for lowercase and updated no example message

* Add message if no template is selected

* Updated tests

* Handle error if fetching the examples fails

* Fixed tests

* Updated test timeout

* Update examples.ts

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
Co-authored-by: Luis Alvarez <luis@zeit.co>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-07 13:11:29 -04:00
Luis Alvarez D
75559f1431
Add --example=<github-url> to create-next-app (#10226)
* Initial support for URLs

* Added folder support

* Added --example-path

* Bug fix

* Also install deps

* Updated error message

* Bug fix and replace the file path

* Added tests

Co-authored-by: Shu Uesugi <shu@chibicode.com>
2020-02-27 16:32:32 +01:00
Afzal Sayed
58b2d9e208 Use optional chaining syntax (#9975)
* Use optional chaining syntax

* Changes as per review

* Bug fix
2020-01-08 11:30:53 -05:00
Joe Haddad
104d18c607
Rewrite Create Next App (#8030)
* Completely rewrite Create Next App

* Sort imports

* Show what package manager is being used

* Fix project name suggestion

* Update tests for new implementation

* Use normal prepublish command for on-install

* Upgrade Node version

* Switch to 8.16

* Disable v8 cache

* Swap out update check package and fix CLI boot
2019-07-19 15:55:30 -04:00