Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce pnpm, fix build tooling #3054

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ module.exports = {
ecmaVersion: 6,
},
settings: {
'import/resolver': {
typescript: true,
node: true,
},
react: {
version: 'detect',
},
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: 7.28.0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install --frozen-lockfile --immutable
node-version: 19
cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- name: Setup NPM credentials
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
Expand All @@ -37,7 +41,7 @@ jobs:
uses: 'kamilkisiela/release-canary@master'
with:
npm-token: ${{ secrets.NPM_TOKEN }}
npm-script: 'yarn release:canary'
npm-script: 'pnpm run release:canary'
changesets: true
- name: Publish a message
if: steps.canary.outputs.released == 'true'
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: License Check
on:
pull_request:
paths:
- 'yarn.lock'
- 'pnpm.lock'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 'pnpm.lock'
- 'pnpm-lock.yaml'


jobs:
check:
Expand All @@ -11,11 +11,16 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 7.28.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 8?

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install --frozen-lockfile --immutable
node-version: 19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use 20 lts

cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- name: License Check
run: yarn license-check
run: pnpm license-check
18 changes: 12 additions & 6 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 7.28.0

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install --frozen-lockfile --immutable
node-version: 19
cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- name: TypeScript Build
run: yarn build
run: pnpm build

- name: ESLint
run: yarn lint
run: pnpm lint

- name: Prettier Check
run: yarn pretty-check
run: pnpm pretty-check
20 changes: 12 additions & 8 deletions .github/workflows/pr-graphql-compat-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 7.28.0

- uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16
cache: 'pnpm'
node-version: 19

- name: Force GraphQL ${{ matrix.release }} solution
run: yarn repo:resolve graphql@${{ matrix.release }}
- run: pnpm install --frozen-lockfile

- run: yarn install --frozen-lockfile --immutable
- name: Force GraphQL ${{ matrix.release }} solution
run: pnpm repo:resolve graphql@${{ matrix.release }}

- name: Typescript Build
run: yarn build
run: pnpm build

- name: Unit Tests
run: yarn test
run: pnpm test

- name: Cypress
run: yarn e2e
run: pnpm e2e
40 changes: 31 additions & 9 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,51 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 7.28.0

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install --frozen-lockfile --immutable
node-version: 19
cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- name: Build
run: yarn build
run: pnpm run build

- name: Run Unit Tests
run: yarn test
run: pnpm test

e2e:
name: Cypress E2E Suite
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 7.28.0

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install --frozen-lockfile --immutable
node-version: 19
cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- name: Cache Cypress binary
# cache cypress binary
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-cypress-${{ hashFiles('**/package.json') }}
restore-keys: |
cypress-${{ runner.os }}-cypress-


- name: Run E2E suite
run: yarn e2e
run: pnpm e2e
16 changes: 11 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions: {}
jobs:
release:
permissions:
contents: write # for changesets/action to git push
contents: write # for changesets/action to git push
environment: deploy
name: Release
runs-on: ubuntu-latest
Expand All @@ -17,18 +17,24 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: pnpm/action-setup@v2
with:
version: 7.28.0

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install --frozen-lockfile --immutable
node-version: 19
cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
publish: pnpm release
env:
# only use GH token here, because GITHUB_TOKEN is no longer allowed to create PRs
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.DS_Store
.secrets
npm-debug.log
yarn-error.log
pnpm-error.log

node_modules/
coverage/
Expand All @@ -23,13 +23,11 @@ lerna-debug.log
**/tsconfig.tsbuildinfo
**/*.tsbuildinfo

.yarnrc
yarn-1.18.0.js
*.orig
.idea/

# Local Netlify folder
.netlify

examples/*/yarn.lock
examples/*/pnpm.lock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
examples/*/pnpm.lock
examples/*/pnpm-lock.yaml

.eslintcache
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
engine-strict=true
access=public
auto-install-peers=true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it’s better install peerdeps explicitly

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"npm.packageManager": "yarn"
"npm.packageManager": "pnpm"
}
3 changes: 0 additions & 3 deletions .yarnrc

This file was deleted.

47 changes: 23 additions & 24 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ If you have not signed the membership agreement (it's free), you will be
prompted by the EasyCLA bot. For more details, please see the
[GraphQL WG repo](https://github.com/graphql/graphql-wg/tree/main/membership).

0. First, you will need the latest `git`, `yarn` 1.16, & `node` 12 or greater.
0. First, you will need the latest `git`, `pnpm` 1.16, & `node` 12 or greater.
macOS, Windows and Linux should all be supported as build environments.

_**Note:** None of the commands below will work with `npm`. Please use `yarn` in
_**Note:** None of the commands below will work with `npm`. Please use `pnpm` in
this repo._

1. Fork this repo by using the "Fork" button in the upper-right
Expand All @@ -23,7 +23,7 @@ this repo._
3. Install or Update all dependencies

```sh
yarn
pnpm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pnpm
pnpm i

```

4. Build all interdependencies so the project you are working on can resolve
Expand All @@ -32,19 +32,19 @@ this repo._
First you'll need —

```sh
yarn run build
pnpm run build
```

— or —

```sh
yarn run build:watch
pnpm run build:watch
```

If you are focused on GraphiQL development, you can run —

```sh
yarn run start-graphiql
pnpm run start-graphiql
```

5. Get coding! If you've added code, add tests. If you've changed APIs, update
Expand All @@ -54,52 +54,51 @@ this repo._
6. Ensure all tests pass, and build everything

```sh
yarn test
pnpm test
```

### Fix CI issues with linting

If you have `prettier` or `eslint --fix`-able issues you see in CI, use —

`yarn format`
`pnpm format`

If you see `typescript` build issues, do a `yarn build` locally, and make sure
If you see `typescript` build issues, do a `pnpm build` locally, and make sure
the whole project references tree builds. Changing interfaces can end up
breaking their implementations.

### Run tests for GraphiQL:

- `yarn test graphiql` will run all tests for graphiql. You can also run tests
- `pnpm test graphiql` will run all tests for graphiql. You can also run tests
from a workspace, but most tooling is at the root.
- `yarn test --watch` will run `jest` with `--watch`
- `yarn e2e` at the root will run the end-to-end suite
- `yarn start-monaco` will launch `webpack` dev server for the `monaco` editor
- `pnpm test --watch` will run `jest` with `--watch`
- `pnpm e2e` at the root will run the end-to-end suite
- `pnpm start-monaco` will launch `webpack` dev server for the `monaco` editor
example with GitHub API from the root. This is the fastest way to test changes
to `graphql-language-service-interface`, parser, etc.

If you want these commands to watch for changes to dependent packages in the
repo, then run `yarn build --watch` alongside either of these.
repo, then run `pnpm build --watch` alongside either of these.

### Developing for GraphiQL

If you want to develop just for graphiql, you won't need to execute commands
from the package subdirectory at `packages/graphiql`.

First, you'll need to `yarn build` all the packages from the root.
First, you'll need to `pnpm build` all the packages from the root.

Then, you can run these commands:

- `yarn start-graphiql` — which will launch `webpack` dev server for graphiql
- `pnpm start-graphiql` — which will launch `webpack` dev server for graphiql
from the root

### Developing Monaco GraphQL

1. First run `yarn`.
1. run `yarn tsc --watch` to watch `monaco-graphql` and
`graphql-language-service` in one screen session/terminal tab/etc
1. in another session, run `yarn start-monaco` from anywhere in the repository
aside from an individual workspace.
1. alternatively to the webpack example, or in addition, you can run monaco or
1. First run `pnpm` outside of workspace.
1. Then, run `pnpm tsc --watch` to watch `monaco-graphql` and
`graphql-language-service` in one session/tab
1. In another session/tab, run `pnpm start-monaco` outside of a workspace
1. Alternatively to the webpack example, or in addition, you can run monaco or
next.js examples, though these examples are simpler. They also require their
own `yarn` or `npm install` as they are excluded from the `workspaces`
resolved on global `yarn install`
own `pnpm` or `npm install` as they are excluded from the `workspaces`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
own `pnpm` or `npm install` as they are excluded from the `workspaces`
own `pnpm i` or `npm install` as they are excluded from the `workspaces`

resolved on global `pnpm install`
1 change: 1 addition & 0 deletions custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ onegraph
openvsx
ovsx
picomatch
pnpm
snyk
stackblitz
strictsoftware
Expand Down
Loading