Skip to content

Commit

Permalink
build: switch from yarn to npm
Browse files Browse the repository at this point in the history
migration steps for future ref:
- replace yarn install with npm install
  - (npm ci == yarn install --frozen-lockfile)
- replace yarn <script> with npm run <script>
- use `--` when passing args to scripts called with npm run
- replace yarn.lock references with package-lock.json
- remove node_modules and yarn.lock, run npm i
- optionally prevent using yarn with package.json "engines" trick

resolves virtualcommons#926
  • Loading branch information
sgfost committed Dec 22, 2023
1 parent 097eb0c commit da36603
Show file tree
Hide file tree
Showing 29 changed files with 17,307 additions and 10,146 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
with:
node-version: 18
- name: Clean install
run: yarn install --frozen-lockfile
run: npm ci
- name: Lint
run: yarn lint
run: npm run lint
- name: Check formatting
# run regardless of whether linting caught errors
if: ${{ success() || failure() }}
run: yarn style
run: npm run style

server:
runs-on: ubuntu-latest
Expand All @@ -39,10 +39,10 @@ jobs:
with:
node-version: 18
- name: Clean install
run: yarn install --frozen-lockfile
run: npm ci
- name: Lint
run: yarn lint
run: npm run lint
- name: Check formatting
# run regardless of whether linting caught errors
if: ${{ success() || failure() }}
run: yarn style
run: npm run style
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ settings: $(SENTRY_DSN_PATH) $(SECRET_KEY_PATH) | keys


initialize: build
docker compose run --rm server yarn initdb
docker compose run --rm server npm run initdb

docker-compose.yml: base.yml $(ENVIR).yml config.mk $(DB_DATA_PATH) $(DATA_DUMP_PATH) $(LOG_DATA_PATH) $(REDIS_SETTINGS_PATH) $(ORMCONFIG_PATH) $(NUXT_ORMCONFIG_PATH) $(PGPASS_PATH) $(SERVER_ENV) settings
case "$(ENVIR)" in \
Expand All @@ -119,25 +119,25 @@ docker-compose.yml: base.yml $(ENVIR).yml config.mk $(DB_DATA_PATH) $(DATA_DUMP_

.PHONY: test-setup
test-setup: docker-compose.yml
docker compose run --rm server bash -c "dropdb --if-exists -h db -U ${DB_USER} ${TEST_DB_NAME} && createdb -h db -U ${DB_USER} ${TEST_DB_NAME} && yarn typeorm schema:sync -c test && yarn load-fixtures ./fixtures/sologame -cn test"
docker compose run --rm server bash -c "dropdb --if-exists -h db -U ${DB_USER} ${TEST_DB_NAME} && createdb -h db -U ${DB_USER} ${TEST_DB_NAME} && npm run typeorm -- schema:sync -c test && npm run load-fixtures -- ./fixtures/sologame -cn test"

.PHONY: test
test: test-setup
docker compose run --rm client yarn test:unit
docker compose run --rm server yarn test
docker compose run --rm client npm run test:unit
docker compose run --rm server npm run test

.PHONY: test-server
test-server: test-setup
docker compose run --rm server yarn test $(tests)
docker compose run --rm server npm run test $(tests)

.PHONY: deploy
deploy: build
docker compose up -d

.PHONY: buildprod
buildprod: docker-compose.yml
docker compose run --rm client yarn build
docker compose run --rm server yarn build
docker compose run --rm client npm run build
docker compose run --rm server npm run build

.PHONY: docker-clean
docker-clean:
Expand Down
11 changes: 6 additions & 5 deletions client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ EXPOSE 3000

WORKDIR /code/client

COPY ./client/package.json ./client/yarn.lock /code/client/
RUN yarn install
COPY ./client/package.json ./client/package-lock.json /code/client/
RUN npm install
RUN ls /code/client/node_modules

COPY ./shared/package.json ./shared/yarn.lock /code/shared/
RUN cd /code/shared && yarn install
COPY ./shared/package.json ./shared/package-lock.json /code/shared/
RUN cd /code/shared && npm install

COPY . /code/client

ENV NODE_ENV=development

CMD ["yarn", "serve"]
CMD ["npm", "run", "serve"]
14 changes: 7 additions & 7 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@

## Project setup
```
yarn install
npm install
```

### Compiles and hot-reloads for development
```
yarn run serve
npm run run serve
```

### Compiles and minifies for production
```
yarn run build
npm run run build
```

### Run your tests
```
yarn run test
npm run run test
```

### Lints and fixes files
```
yarn run lint
npm run run lint
```

### Run your end-to-end tests
```
yarn run test:e2e
npm run run test:e2e
```

### Run your unit tests
```
docker compose exec client bash
yarn run test:unit
npm run run test:unit
```

### Customize configuration
Expand Down
4 changes: 2 additions & 2 deletions client/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

set -o errexit

yarn install
exec yarn serve
npm install
exec npm run serve

Loading

0 comments on commit da36603

Please sign in to comment.