Skip to content

Commit 6816ffe

Browse files
aliggsawyerh
andauthored
Move from Yarn to NPM (#13)
Ticket: #11 - yarn to npm - add adr Co-authored-by: Sawyer Hollenshead <[email protected]>
1 parent 56cae06 commit 6816ffe

File tree

12 files changed

+53642
-13380
lines changed

12 files changed

+53642
-13380
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
version: 2
77
updates:
8-
# Maintain dependencies for yarn (uses `npm`)
8+
# Maintain dependencies
99
- package-ecosystem: "npm"
1010
directory: "/app"
1111
schedule:

.github/workflows/ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ jobs:
2020
- uses: actions/setup-node@v1
2121
with:
2222
node-version: 16
23-
- run: npm install --location=global yarn
24-
- run: yarn install --frozen-lockfile
25-
- run: yarn build
26-
- run: yarn lint
27-
- run: yarn format-check
28-
- run: yarn test
23+
- run: npm ci
24+
- run: npm run build
25+
- run: npm run lint
26+
- run: npm run format-check
27+
- run: npm run test
2928

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ This template includes setup for:
1717

1818
You can run the Next.js app without docker as follows:
1919

20-
1. `yarn install`
21-
2. `yarn dev`
20+
1. `npm install`
21+
2. `npm run dev`
2222
3. Navigate to `localhost:3000` in your browser to view the application
2323

2424
You can run storybook without docker by running:
2525

26-
1. `yarn storybook`
26+
1. `npm run storybook`
2727
2. Navigate to `localhost:6006` in your browser to view storybook
2828

2929
### With Docker
@@ -36,13 +36,13 @@ A `docker-compose.yml` has been included to support local development and deploy
3636
2. Make sure you have [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed & running.
3737
3. Run `docker-compose up -d --build` to build the image and start the container.
3838
4. Navigate to `localhost:3000` in your browser to view the application. Note that it takes a few minutes for the initial sass compiling to complete and load.
39-
5. Run `docker-compose exec nextjs yarn storybook` to build and run storybook. Note that the initial sass compiling for storybook also takes a few minutes to complete and load
39+
5. Run `docker-compose exec nextjs npm run storybook` to build and run storybook. Note that the initial sass compiling for storybook also takes a few minutes to complete and load
4040
5. Navigate to `localhost:6006` in your browser to view storybook.
4141
6. Run `docker-compose down` when you are done to delete the container.
4242

43-
To support local development, the `docker-compose.yml` runs the `nextjs` container in development mode (i.e. `yarn dev`) instead of production mode (i.e. `yarn start`). This allows Next.js to do things like hot reload.
43+
To support local development, the `docker-compose.yml` runs the `nextjs` container in development mode (i.e. `npm run dev`) instead of production mode (i.e. `npm run start`). This allows Next.js to do things like hot reload.
4444

45-
The docker-compose file bind mounts `app` on the host machine to `/srv` in the guest machine. However, to ensure that the container uses the correct packages in `node_modules`, we use a named docker volume for the `node_modules` dir. The named volume will take precedence over the bind mount, so that the `node_modules` dir in the guest machine will not be overwritten with the host machine's `node_modules` dir. This also means that if you run `yarn add <package>` on the host machine in development (which will update `yarn.lock`), you'll also need to run `docker-compose exec nextjs yarn install --frozen-lockfile` to update `node_modules` in the guest machine.
45+
The docker-compose file bind mounts `app` on the host machine to `/srv` in the guest machine. However, to ensure that the container uses the correct packages in `node_modules`, we use a named docker volume for the `node_modules` dir. The named volume will take precedence over the bind mount, so that the `node_modules` dir in the guest machine will not be overwritten with the host machine's `node_modules` dir. This also means that if you run `npm install <package>` on the host machine in development (which will update `package-lock.lock`), you'll also need to run `docker-compose exec nextjs npm ci` to update `node_modules` in the guest machine.
4646

4747
## Getting started
4848

app/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
# debug
2323
npm-debug.log*
24-
yarn-debug.log*
25-
yarn-error.log*
2624
.pnpm-debug.log*
2725

2826
# local env files

app/.storybook/main.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* @file Storybook's main configuration file that controls the generation of Storybook.
3+
* Handles things like config for location of story files and managing presets (which configure webpack and babel).
4+
* @see https://storybook.js.org/docs/configurations/default-config/
5+
*/
6+
17
const nextConfig = require('../next.config')
28

39
module.exports = {
@@ -18,7 +24,7 @@ module.exports = {
1824
test: /\.scss$/,
1925
use: [
2026
'style-loader',
21-
'css-loader',
27+
{ loader: 'css-loader', options: { url: false } }, // this mirrors next.js behavior
2228
{
2329
/**
2430
* Next.js sets this automatically for us, but we need to manually set it here for Storybook.

app/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ FROM node:16-alpine
55
# -U runs both apk update and apk upgrade.
66
RUN apk -U upgrade
77
# Copy just the package data to the working directory.
8-
COPY yarn.lock /srv
8+
COPY package-lock.json /srv
99
COPY package.json /srv
1010
WORKDIR /srv
1111
# Install application dependencies.
12-
RUN yarn install --frozen-lockfile
12+
RUN npm ci
1313
# Copy all the remaining application files (ignoring files in .dockerignore) to the working directory.
1414
COPY . /srv
1515
# Build the application.
16-
RUN yarn build
16+
RUN npm run build
1717
# Run the application.
18-
CMD yarn start
18+
CMD npm run start

app/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next
22

33
## Getting Started
44

5-
First, install dependencies:
5+
First, install dependencies from the app directory:
66

77
```bash
8-
yarn
8+
npm install
99
```
1010

1111
Second, run the development server:
1212

1313
```bash
14-
yarn dev
14+
npm run dev
1515
```
1616

1717
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
@@ -103,7 +103,7 @@ We did not follow their [install directions](https://designsystem.digital.gov/do
103103

104104
Compiling the USWDS sass is slow, so the initial build step and subsequent sass re-compiles are slow, but after the design system is set up, we shouldn't need to be regularly re-compiling sass.
105105

106-
Copying the USWDS static assets into the project is handled by a [yarn postinstall](https://classic.yarnpkg.com/lang/en/docs/package-json/#toc-scripts) script in `package.json`.
106+
Copying the USWDS static assets into the project is handled by a [`postinstall`](https://docs.npmjs.com/cli/v8/using-npm/scripts) script in `package.json`.
107107

108108
## Internationalization (i18n)
109109

0 commit comments

Comments
 (0)