Skip to content

Commit

Permalink
feat: move to pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
vanpho93 committed Sep 15, 2022
1 parent b8d56fb commit 8cafa12
Show file tree
Hide file tree
Showing 23 changed files with 14,719 additions and 124 deletions.
68 changes: 38 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,88 @@ defaults: &defaults
docker:
- image: circleci/node:14.18.1-stretch


install_pnpm: &install_pnpm
- run:
name: Install pnpm package manager
command: sudo npm i -g pnpm@7
- run:
name: Check pnpm version
command: pnpm -v

jobs:
install-dependencies:
<<: *defaults
steps:
- checkout
- <<: *install_pnpm
- restore_cache:
keys:
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "pnpm-lock.yaml" }}
- reaction-v6-node-modules-{{ .Branch }}
- run:
name: Install npm version 8
command: sudo npm i -g [email protected]
- run:
name: Check npm version
command: npm -v
- run:
name: Install NPM dependencies
command: npm ci
name: Install PNPM dependencies
command: pnpm install -r
- save_cache:
key: reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
key: reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "pnpm-lock.yaml" }}
paths:
- node_modules
- packages
- save_cache:
key: reaction-v6-node-modules-{{ .Branch }}
paths:
- node_modules
- packages

dockerfile-lint:
<<: *defaults
steps:
- checkout
- <<: *install_pnpm
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Lint Dockerfiles
command: ${CI_SCRIPTS} lint-dockerfiles

eslint:
<<: *defaults
steps:
- checkout
- <<: *install_pnpm
- restore_cache:
keys:
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "pnpm-lock.yaml" }}
- reaction-v6-node-modules-{{ .Branch }}
- run:
name: Lint JavaScript
command: |
npm run build:packages
npm run lint
command: pnpm run lint

graphql-lint:
<<: *defaults
steps:
- checkout
- <<: *install_pnpm
- restore_cache:
keys:
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "pnpm-lock.yaml" }}
- reaction-v6-node-modules-{{ .Branch }}
- run:
name: Lint GraphQL schemas
command: npm run lint:gql
command: pnpm -r run lint:gql

test-unit:
<<: *defaults
steps:
- checkout
- <<: *install_pnpm
- restore_cache:
keys:
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "pnpm-lock.yaml" }}
- reaction-v6-node-modules-{{ .Branch }}
- run: pnpm install -r
- run:
name: Test Unit
command: |
npm run build:packages
npm run test
command: pnpm test

test-integration-query:
<<: *defaults
Expand All @@ -100,10 +106,12 @@ jobs:
- "27017:27017"
steps:
- checkout
- <<: *install_pnpm
- restore_cache:
keys:
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "pnpm-lock.yaml" }}
- reaction-v6-node-modules-{{ .Branch }}
- run: pnpm install -r
- run:
name: Run Integration Query Tests
environment:
Expand All @@ -112,8 +120,7 @@ jobs:
command: |
sudo apt-get install -y mongodb
mongo --eval "rs.initiate()"
npm run build:packages
npm run test:integration:query -w=apps/reaction
pnpm run test:integration:query
test-integration-mutation:
<<: *defaults
Expand All @@ -126,10 +133,12 @@ jobs:
- "27017:27017"
steps:
- checkout
- <<: *install_pnpm
- restore_cache:
keys:
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "pnpm-lock.yaml" }}
- reaction-v6-node-modules-{{ .Branch }}
- run: pnpm install -r
- run:
name: Run Integration Mutation Tests
environment:
Expand All @@ -138,24 +147,23 @@ jobs:
command: |
sudo apt-get install -y mongodb
mongo --eval "rs.initiate()"
npm run build:packages
npm run test:integration:mutation -w=apps/reaction
pnpm run test:integration:mutation
release:
<<: *defaults
steps:
- checkout
- <<: *install_pnpm
- restore_cache:
keys:
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- reaction-v6-node-modules-{{ checksum "package.json" }}-{{ checksum "pnpm-lock.yaml" }}
- reaction-v6-node-modules-{{ .Branch }}
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
- run:
name: Push the latest version to npm
command: |
npm run release
command: pnpm publish -r

docker-build-push:
<<: *defaults
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
root: true,
extends: "@reactioncommerce",
parser: "@babel/eslint-parser",
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release
on:
workflow_dispatch:
branches:
- main
- trunk
jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -12,21 +12,30 @@ jobs:
with:
# This makes action fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
key: reaction-v6-node-modules-${{ hashFiles('package.json') }}-${{ hashFiles('pnpm-lock.yaml') }}
path: '**/node_modules'

- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 14

- name: Install npm 8.1.0
run: npm i -g [email protected]
- name: Install pnpm
run: npm i -g pnpm@latest

- name: Install Dependencies
run: npm ci --ignore-scripts
run: pnpm install --ignore-scripts

- name: Create Release Pull Request or Publish to npm
uses: changesets/action@v1
with:
publish: npm run release
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # Ensure to have this set up under GitHub secrets
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
engine-strict=true
legacy-peer-deps=true
auto-install-peers=true
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Go to the complete [installation instructions](https://mailchimp.com/developer/o
## What you need
* NPM >= 7 (support workspaces)
* Docker & docker-compose
* MongoDB

## Clone and Start the source
```bash
Expand All @@ -74,13 +73,13 @@ cd reaction
npm install
cp apps/reaction/.env.example apps/reaction/.env
```
Start dev server with mongo on local:
Start dev-server with mongo on local:
```bash
## you must change MONGO_URL in the .env to mongodb://localhost:27017/reaction before start
npm run start:dev
```

Start dev server with mongodb on docker
Start dev-server with mongodb on docker
```bash
docker-compose up -d
npm run start:dev
Expand Down
38 changes: 6 additions & 32 deletions apps/reaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@reactioncommerce/api-plugin-shipments": "^1.0.1",
"@reactioncommerce/api-plugin-shipments-flat-rate": "^1.0.4",
"@reactioncommerce/api-plugin-shops": "^1.2.1",
"@reactioncommerce/api-plugin-simple-schema": "^1.0.1",
"@reactioncommerce/api-plugin-simple-schema": "^1.0.3",
"@reactioncommerce/api-plugin-sitemap-generator": "^1.2.2",
"@reactioncommerce/api-plugin-surcharges": "^1.1.2",
"@reactioncommerce/api-plugin-system-information": "^1.1.3",
Expand All @@ -63,49 +63,23 @@
"@reactioncommerce/file-collections": "^0.9.3",
"@reactioncommerce/file-collections-sa-gridfs": "^0.1.5",
"@reactioncommerce/logger": "^1.1.3",
"@reactioncommerce/nodemailer": "^5.0.5",
"@reactioncommerce/random": "^1.0.2",
"@snyk/protect": "latest",
"graphql": "~14.7.0",
"semver": "~6.3.0",
"sharp": "^0.29.3"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@reactioncommerce/babel-remove-es-create-require": "~1.0.0",
"@reactioncommerce/data-factory": "~1.0.1",
"@reactioncommerce/eslint-config": "~2.2.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"apollo-link-http": "~1.5.16",
"apollo-server-testing": "~2.9.6",
"babel-eslint": "~10.0.3",
"babel-jest": "~25.1.0",
"babel-plugin-rewire-exports": "~2.0.0",
"babel-plugin-transform-es2015-modules-commonjs": "~6.26.2",
"babel-plugin-transform-import-meta": "~1.0.0",
"eslint": "~6.8.0",
"eslint-plugin-import": "~2.18.2",
"eslint-plugin-jest": "~22.17.0",
"eslint-plugin-jsx-a11y": "~6.2.3",
"eslint-plugin-node": "~10.0.0",
"eslint-plugin-promise": "~4.2.1",
"eslint-plugin-react": "~7.14.3",
"eslint-plugin-react-hooks": "~2.0.1",
"faker": "~4.1.0",
"graphql-tools": "~4.0.5",
"husky": "^5.0.8",
"is-ci": "^2.0.0",
"is-docker": "^2.1.1",
"jest": "~25.1.0",
"nock": "~11.4.0",
"node-fetch": "~2.6.0",
"nodemon": "~1.19.2",
"pinst": "^2.1.4",
"semantic-release": "^17.4.3",
"wait-for-expect": "~3.0.0"
},
"scripts": {
Expand All @@ -120,12 +94,11 @@
"test:integration:watch": "node --max_old_space_size=10000 node_modules/jest/bin/jest --runInBand --watch --testPathIgnorePatterns '<rootDir>/src/'",
"test:integration:file": "jest --runInBand",
"test:integration:file:watch": "jest --runInBand --watch",
"test:integration:query": "node --max_old_space_size=4000 --expose-gc ../../node_modules/.bin/jest --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns '<rootDir>/src/' '<rootDir>/tests/integration/api/mutations/'",
"test:integration:mutation": "node --max_old_space_size=4000 --expose-gc ../../node_modules/.bin/jest --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns '<rootDir>/src/' '<rootDir>/tests/integration/api/queries/'",
"test:integration:query": "node --max_old_space_size=4000 --expose-gc ../../node_modules/jest/bin/jest.js --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns '<rootDir>/src/' '<rootDir>/tests/integration/api/mutations/'",
"test:integration:mutation": "node --max_old_space_size=4000 --expose-gc ../../node_modules/jest/bin/jest.js --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns '<rootDir>/src/' '<rootDir>/tests/integration/api/queries/'",
"lint": "eslint .",
"lint:gql": "graphql-schema-linter ./src/**/*.graphql",
"version": "echo $npm_package_version",
"postinstall": "is-ci || is-docker || cd ../.. husky install apps/reaction/.husky",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable",
"prepare": "npm run snyk-protect",
Expand All @@ -139,7 +112,8 @@
"ext": "js,cjs,mjs,json,graphql",
"legacyWatch": true,
"watch": [
"src"
"src",
"../../packages"
]
},
"graphql-schema-linter": {
Expand Down
4 changes: 2 additions & 2 deletions apps/reaction/src/mockTypes.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ input MoneyInput {
}

"Fake"
input AddressInput {
type AddressInput {
"Fake"
fake: String
}
Expand Down Expand Up @@ -450,7 +450,7 @@ input ShopSettingsUpdates {
A fake type to satisfy linting
type lives in `api-plugin-tags`
"""
input TagSortByField {
type TagSortByField {
"A fake field to satisfy linting"
fakeField: String
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ beforeAll(async () => {
await publishProducts({ productIds: [opaqueProductId] });
});

// eslint-disable-next-line require-jsdoc
export default function getCommonData() {
return {
addCartItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let updateTag;
let mockTagsAccount;
let tagInput;

// eslint-disable-next-line require-jsdoc
function createMockTag() {
return Factory.Tag.makeOne({
_id: "123",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const addressValidationRulesQuery = importAsString("./addressValidationRules.gra

jest.setTimeout(300000);

// eslint-disable-next-line require-jsdoc
function mongoToGql(rules) {
return rules.map((rule) => ({
...rule,
Expand Down
Loading

0 comments on commit 8cafa12

Please sign in to comment.