Skip to content

Commit

Permalink
build: switch from yarn v1 to pnpm
Browse files Browse the repository at this point in the history
fixes #1693
  • Loading branch information
bd82 committed Jul 3, 2022
1 parent 350e1a8 commit eb1fb3b
Show file tree
Hide file tree
Showing 71 changed files with 9,105 additions and 10,153 deletions.
3 changes: 3 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "cz-conventional-changelog"
}
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ jobs:
- 18.x
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}

- uses: pnpm/[email protected]
with:
version: 7.5.0

- name: Install dependencies
run: yarn
- name: Run CI
run: yarn run ci
run: pnpm install

- name: Build
run: pnpm run ci
18 changes: 12 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: pnpm/[email protected]
with:
version: 7.5.0

- name: Install dependencies
run: yarn
- name: Run CI
run: yarn run ci
run: pnpm install
- name: Build
run: pnpm run ci
- name: npm auth setup
run: |
yarn logout
pnpm logout
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
# avoids lerna validations failing the release due to changes in tracked file.
git update-index --assume-unchanged ".npmrc"
pnpm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to NPM
run: yarn run lerna:publish
run: pnpm run release:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
.baseDir.ts
/bower_components
/npm-debug.log
.pnpm-debug.log
yarn-error.log
.DS_Store

Expand Down Expand Up @@ -35,4 +36,7 @@ yarn-error.log
coverage

# nyc test coverage
.nyc_output
.nyc_output
package-lock.json
yarn.lock
.pnpm-debug.log
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
pnpm commitlint --edit $1
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
pnpm lint-staged
5 changes: 5 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public-hoist-pattern[]=vue
# only one version for the whole project, (oldest nodejs LTS)
public-hoist-pattern[]=@types/node


13 changes: 13 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
hooks: {
readPackage (pkg) {
// this way we do not need to globally disable the peerDeps error in pnpm.
// and only for vuepress related deps
if (/vuepress|sass-loader|@docsearch\/react|@algolia\/autocomplete-preset-algolia/.test(pkg.name)) {
console.warn(`fixing missing peerDeps for vuepress dep: ${pkg.name}`)
delete pkg.peerDependencies
}
return pkg
}
}
}
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# build artifacts
/packages/website/docs/.vuepress/.temp
/packages/website/docs/.vuepress/.cache
/packages/website/docs/.vuepress/dist/
/packages/types/dev
/packages/**/lib
Expand All @@ -18,7 +19,7 @@
/examples/parser/minification/gen/

# prettier ignores
/packages/cst-dts-gen/test/snapshots/**/output.d.ts
/packages/cst-dts-gen-test/test/snapshots/**/output.d.ts

# used to hold "current" master version for relative performance tests.
/packages/chevrotain/benchmark_web/chevrotain.js
Expand Down
45 changes: 11 additions & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Details:

#### Contributing To Chevrotain's Runtime Source code.

This can be more complex as more in-depth knowledge of chevrotain internals may be needed.
This can be more complex as more in-depth knowledge of Chevrotain internals may be needed.

Details:

Expand All @@ -42,63 +42,40 @@ Details:
Chevrotain is developed as a mono-repo with a single (temporary state) productive package
and multiple example packages.

Chevrotain uses **yarn** tasks for the development flows.
Examine the interal [packages/chevrotain/package.json][package] scripts for all the available tasks.
Chevrotain uses **npm** tasks for the development flows.
and pnpm + lerna for the monorepo management.

#### Initial Setup

In the root of this Repo:

- `yarn`
- `yarn build`
- `pnpm`

#### Some basic dev flows to get started

Chevrotain is written using Typescript, so compilation to JavaScript is needed.

- `cd packages/chevrotain`
- `yarn compile`
- `pnpm compile`

Alternatively during development one would want to recompile on file changes.

- `cd packages/chevrotain`
- `yarn compile:watch`
- `pnpm compile:watch`

The compilation result will appear in the **lib** folder.
The compilation result will appear in the **lib** folder in each sub-package.

#### Code Formatting

Chevrotain uses **prettier** to avoid caring about code formatting...
To format your new code use:

`yarn format:fix`

#### Testing

Chevrotain uses several types of tests to promote high quality.

The most basic ones are the **mocha unit tests**, which are also often the most relevant ones.

- `cd packages/chevrotain`
- `yarn coverage`

You can run the whole test suite by running:

- `cd packages/chevrotain`
- `yarn test`

Additionally, **integration tests** are used to test Chevrotain as an end user via the examples packages
tests.

- In this repo's root
- `yarn test`
`pnpm format:fix`

#### Running the central CI flow locally.

This is just another yarn task which performs the whole flow
This is just another npm task which performs the whole flow
including linting / doc generation / d.ts API creation / ...

- `yarn ci`
- `pnpm ci`

#### Committing Changes

Expand All @@ -117,7 +94,7 @@ The release process **requires push permissions to master**.
- Update the [BREAKING_CHANGES.md](./packages/website/docs/changes/BREAKING_CHANGES.md).
- Only for major versions...
- Push the changes related updates to master.
- execute `yarn run lerna:version` and follow the instructions.
- execute `pnpm release:version` and follow the instructions.
- This will update version related files and push a new version **tag** to Github.
- Github Actions will execute a deployment to npmjs.com due to this new tag.
- Additionally, new website contents will be pushed to the gh-pages branch.
Expand Down
2 changes: 1 addition & 1 deletion examples/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# examples should always use latest chevrotain, we don't want to use lock files here.
yarn.lock
pnpm-lock.yaml
1 change: 1 addition & 0 deletions examples/grammars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "chevrotain_examples_grammars",
"version": "10.1.2",
"scripts": {
"ci": "pnpm run test",
"test": "mocha \"!(node_modules)/**/*spec.js\""
},
"dependencies": {
Expand Down
7 changes: 3 additions & 4 deletions examples/implementation_languages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
"name": "chevrotain_examples_implementation_languages",
"version": "10.1.2",
"scripts": {
"build": "npm-run-all build:ts",
"ci": "pnpm run build test",
"build": "pnpm run build:ts",
"build:ts": "tsc && node ./typescript/scripts/gen_dts_signatures.js",
"test": "npm-run-all test:*",
"test": "pnpm run test:*",
"test:cjs": "mocha \"*spec.js\"",
"test:esm": "mocha \"*spec.mjs\""
},
"dependencies": {
"chevrotain": "^10.1.2"
},
"devDependencies": {
"coffee-script": "^1.11.1",
"mocha": "^9.0.0",
"npm-run-all": "^4.1.5",
"typescript": "4.2.3"
},
"private": true
Expand Down
1 change: 1 addition & 0 deletions examples/lexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "chevrotain_examples_lexer",
"version": "10.1.2",
"scripts": {
"ci": "pnpm run test",
"test": "mocha \"!(node_modules)/**/*spec.js\""
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions examples/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "chevrotain_examples_parser",
"version": "10.1.2",
"scripts": {
"ci": "pnpm run test",
"test": "mocha \"!(node_modules)/**/*spec.js\""
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions examples/tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "chevrotain_examples_tutorial",
"version": "10.1.2",
"scripts": {
"ci": "pnpm run test",
"test": "mocha \"step*/*spec.js\""
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"packages": ["packages/*", "examples/*"],
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
"version": {
"allowBranch": "master",
Expand Down
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
"examples/*"
]
},
"engines": {
"pnpm": ">=7"
},
"scripts": {
"lerna:version": "yarn && lerna version --force-publish",
"lerna:publish": "lerna publish from-git --yes --no-verify-access",
"ci": "npm-run-all format:validate lint:validate build test coverage:merge",
"compile": "lerna run clean && tsc --build",
"compile:watch": "lerna run clean && tsc --build --watch",
"build": "lerna run build",
"test": "lerna run test",
"version": "pnpm install && git add pnpm-lock.yaml",
"preinstall": "npx only-allow pnpm",
"release:version": "lerna version --force-publish",
"release:publish": "lerna publish from-git --yes --no-verify-access",
"ci": "pnpm run format:validate lint:validate ci:subpackages coverage:merge",
"compile": "pnpm -r run clean && tsc --build",
"compile:watch": "pnpm -r run clean && tsc --build --watch",
"ci:subpackages": "pnpm -r run ci",
"coverage:merge": "node ./scripts/merge-coverage",
"format:fix": "prettier --write \"**/*.@(ts|js|json|md|yml)\"",
"format:validate": "prettier --check \"**/*.@(ts|js|json|md|yml)\"",
Expand All @@ -35,29 +39,28 @@
"eslint --fix --max-warnings=0 --ignore-pattern=!.*"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"devDependencies": {
"@types/chai": "4.3.1",
"@types/sinon": "^10.0.12",
"@types/sinon-chai": "3.2.8",
"sinon": "14.0.0",
"@types/mocha": "9.1.1",
"@types/node": "14.18.21",
"nyc": "15.1.0",
"chai": "4.3.6",
"sinon-chai": "3.7.0",
"typescript": "4.7.4",
"fs-extra": "10.1.0",
"husky": "8.0.1",
"lerna": "5.1.6",
"lint-staged": "13.0.3",
"lodash": "4.17.21",
"mocha": "10.0.0",
"npm-run-all": "4.1.5",
"prettier": "2.7.1",
"shx": "0.3.4",
"cz-conventional-changelog": "3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/chevrotain/benchmark_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ With the **Next** version (locally built version on current branch).

## Instructions

1. `yarn ci` in the root of this repo.
1. `pnpm ci` in the root of this repo.

- This will generate `chevrotain.js` artifact in the lib directory.

Expand Down
Loading

0 comments on commit eb1fb3b

Please sign in to comment.