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

Migrate to pnpm #1123

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ coverage
**/*.template
**/package.json
**/*.md
docs/assets/main.js
docs/
packages/eslint-plugin-khan/demo
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
},
overrides: [
{
files: ["utils/*.js"],
files: ["utils/*.js", "typedoc.config.js"],
rules: {
"import/no-commonjs": "off",
},
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn.lock linguist-generated
pnpm-lock.yaml linguist-generated
2 changes: 1 addition & 1 deletion .github/workflows/node-ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Run tests with coverage
run: yarn coverage
run: pnpm run coverage
- name: Upload Coverage
uses: codecov/codecov-action@v4
with:
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,30 @@ jobs:
name: Files that would trigger a full eslint run
with:
changed-files: ${{ steps.changed.outputs.files }}
files: '.eslintrc.js,yarn.lock,.eslintignore'
files: '.eslintrc.js,pnpm-lock.yaml,pnpm-workspace.yaml,.eslintignore'

- name: Build so that inter-package references are resolved
run: yarn build
run: pnpm run build

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

# Linting / type checking
- name: Eslint
uses: Khan/actions@full-or-limited-v0
with:
full-trigger: ${{ steps.eslint-reset.outputs.filtered }}
full: yarn lint:ci .
full: pnpm run lint:ci .
limited-trigger: ${{ steps.js-ts-files.outputs.filtered }}
limited: yarn lint:ci {}
limited: pnpm run lint:ci {}

- name: Typecheck
if: steps.js-ts-files.outputs.filtered != '[]'
run: yarn typecheck
run: pnpm run typecheck

# Collect and record coverage
- name: Run Jest with coverage
run: yarn coverage
run: pnpm run coverage
- name: Upload Coverage
# We don't bother collecting a record of coverage for dependabot changes
if: ${{ github.actor != 'dependabot[bot]' }}
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
id: changed

- name: Build so that inter-package references are resolved
run: yarn build
run: pnpm run build

- id: jest-reset
uses: Khan/actions@filter-files-v1
Expand All @@ -165,7 +165,8 @@ jobs:
changed-files: ${{ steps.changed.outputs.files }}
files: |
jest.config.js
yarn.lock
pnpm-lock.yaml
pnpm-workspace.yaml
test.config.js
test.transform.js

Expand All @@ -180,6 +181,6 @@ jobs:
uses: Khan/actions@full-or-limited-v0
with:
full-trigger: ${{ steps.jest-reset.outputs.filtered }}
full: yarn test
full: pnpm run test
limited-trigger: ${{ steps.js-ts-files.outputs.filtered }}
limited: yarn test --findRelatedTests --passWithNoTests {}
limited: pnpm run test --findRelatedTests --passWithNoTests {}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: Build Typedoc
# Generate nice docs inside "docs/" folder
run: yarn build:docs
run: pnpm run build:docs

- name: Deploy to GitHub pages
uses: JamesIves/github-pages-deploy-action@v4
Expand All @@ -57,7 +57,7 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
publish: yarn publish:ci
publish: pnpm run publish:ci
env:
# We use a Personal Access Token here rather than the GITHUB_TOKEN
# so that it will trigger our other actions. The token has to be on
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ docs
!packages/eslint-plugin-khan/docs
!.vscode
.DS_Store
yarn-error.log
*.tsbuildinfo
utils/**/*.d.ts
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ To work in the `wonder-stuff` repository, follow these steps:

1. Clone the repository
`git clone git@github.com:Khan/wonder-stuff.git`
2. Install `yarn` (see [🔗yarnpkg.com](https://yarnpkg.com))
3. Run `yarn install` to install the dependencies
2. Install `pnpm` (see [🔗pnpm](https://pnpm.io))
3. Run `pnpm install` to install the dependencies

You can now work on `wonder-stuff`. We prefer [🔗Visual Studio Code](https://code.visualstudio.com/) as our development environment (it's cross-platform and awesome), but please use what you feel comfortable with (we'll even forgive you for using vim).

Expand All @@ -46,17 +46,17 @@ We love code reviews. If there are open pull requests, please feel free to revie

To ensure code quality, we use prettier, TypeScript, eslint, and jest. These are all executed automatically on commit, so don't worry if you forget to run them before you commit. They are also executed when you submit, edit, or push to a pull request to ensure the contribution meets our code quality standard.

To execute these operations outside of a pull request or commit operation, you can use `yarn`.
To execute these operations outside of a pull request or commit operation, you can use `pnpm`.

- `yarn typecheck`
- `yarn lint`
- `yarn test`
- `pnpm typecheck`
- `pnpm lint`
- `pnpm test`

💭**REMEMBER** If you would like to contribute code changes to the project, first make sure there's a corresponding issue for the change you wish to make.

## 📦 Build And Publish

Anyone can create a local build of the distributed code by running `yarn build`.
Anyone can create a local build of the distributed code by running `pnpm build`.

### Publishing

Expand Down
4 changes: 3 additions & 1 deletion build-settings/check-type-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* files instead. Since we don't want to ship source code in every package,
* we want to guard against this.
*
* This script should be run after `yarn build:types`. It will scan the type
* This script should be run after `pnpm build:types`. It will scan the type
* definitions of each package for any types that are being incorrectly
* imported from other the source code of other packages, and flag them,
* exiting with a non-zero status code if any are found.
Expand All @@ -24,6 +24,8 @@ const packagesDir = path.join(rootDir, "packages");
const typeDefinitionFiles = fglob.sync("**/*.d.ts", {
cwd: packagesDir,
onlyFiles: true,
globstar: true,
ignore: ["**/node_modules/**"],
});

let foundErrors = false;
Expand Down
49 changes: 28 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
"author": "Jeff Yates <jeff@khanacademy.org>",
"license": "MIT",
"private": true,
"workspaces": [
"packages/*",
"build-settings"
],
"engines": {
"node": ">=16"
},
Expand All @@ -24,6 +20,7 @@
"@google-cloud/logging-winston": "^4.2.4",
"@google-cloud/profiler": "^4.2.0",
"@google-cloud/trace-agent": "^5.1.6",
"@jest/globals": "^29.7.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.3",
Expand All @@ -39,6 +36,7 @@
"@types/winston": "^2.4.4",
"@typescript-eslint/eslint-plugin": "8.17.0",
"@typescript-eslint/parser": "8.17.0",
"@typescript-eslint/rule-tester": "^8.17.0",
"babel-jest": "^29.7.0",
"babel-watch": "^7.8.1",
"eslint": "^8.55.0",
Expand Down Expand Up @@ -74,28 +72,37 @@
"typescript": "5.7.3",
"winston": "^3.10.0"
},
"resolutions": {
"//": "we need to pin wide-align/string-width because v5 & up are ESM only",
"wide-align/string-width": "^4.2.0",
"node-gyp": "^10.0.0"
"pnpm": {
"overrides": {
"a": "we need to pin wide-align/string-width because v5 & up are ESM only",
"wide-align>string-width": "^4.2.0",
"node-gyp": "^10.0.0"
},
"onlyBuiltDependencies": [
"@swc/core",
"pprof",
"protobufjs"
]
},
"scripts": {
"preinstall": "npx -y only-allow pnpm",
"rollup": "rollup -c build-settings/rollup.config.mjs",
"build": "yarn rollup",
"build:prodsizecheck": "yarn rollup --configPlatforms='browser' --configFormats='esm' --configEnvironment='production'",
"build:types": "yarn tsc --build --verbose tsconfig-build.json && ./build-settings/check-type-definitions.ts",
"build": "pnpm run rollup",
"build:prodsizecheck": "pnpm run rollup --configPlatforms='browser' --configFormats='esm' --configEnvironment='production'",
"build:types": "pnpm tsc --build --verbose tsconfig-build.json && ./build-settings/check-type-definitions.ts",
"build:docs": "typedoc",
"watch": "yarn rollup --watch",
"clean": "rm -rf packages/wonder-stuff-*/dist && rm -rf packages/wonder-stuff-*/node_modules && rm -f packages/*/*.tsbuildinfo",
"coverage": "yarn run jest --coverage",
"watch": "pnpm run rollup --watch",
"clean": "rm -rf packages/wonder-stuff-*/dist && rm -rf packages/wonder-stuff-*/node_modules && rm -rf node_modules && rm -f packages/*/*.tsbuildinfo",
"coverage": "pnpm jest --coverage",
"format": "prettier --write .",
"lint": "yarn lint:ci .",
"lint": "pnpm run lint:ci .",
"lint:ci": "eslint --ext .ts --ext .js",
"lint:pkg-json": "yarn npmPkgJsonLint ./packages/wonder-stuff-*",
"publish:ci": "yarn run lint:pkg-json && node utils/pre-publish-check-ci.js && git diff --stat --exit-code HEAD && yarn build && yarn build:types && changeset publish",
"test": "yarn jest",
"lint:pkg-json": "pnpm npmPkgJsonLint ./packages/wonder-stuff-*",
"publish:ci": "pnpm run lint:pkg-json && node utils/pre-publish-check-ci.js && git diff --stat --exit-code HEAD && pnpm run build && pnpm run build:types && changeset publish",
"test": "pnpm jest",
"typecheck": "tsc",
"nochangeset": "yarn changeset add --empty",
"add:devdepbysha": "bash -c 'yarn add -W --dev \"git+https://git@github.com/Khan/$0.git#$1\"'"
}
"nochangeset": "pnpm changeset add --empty",
"add:devdepbysha": "bash -c 'pnpm add --workspace-root --save-dev \"git+https://git@github.com/Khan/$0.git#$1\"'"
},
"packageManager": "pnpm@10.0.0+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b"
}
2 changes: 1 addition & 1 deletion packages/eslint-config-khan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Shared Khan Academy eslint configuration.

## Quick Start

- `yarn add @khanacademy/eslint-config`
- `(yarn|pnpm) add --save-dev @khanacademy/eslint-config`
- Update your .eslintrc.js file to:
- extend `"@khanacademy"`
- include settings for `"import/resolver"`
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-khan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"author": "Kevin Barabash <kevinb@khanacademy.org>",
"license": "MIT",
"peerDependencies": {
"@khanacademy/eslint-plugin": "^3.1.1",
"@khanacademy/eslint-plugin": "workspace:*",
"@typescript-eslint/eslint-plugin": "8.17.0",
"@typescript-eslint/parser": "8.17.0",
"eslint": "^8.55.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/eslint-plugin-khan/demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ the custom eslint rules this plugin provides.

After making a change to the plugin source code, you'll need to take following steps to
update the demo:
- run `yarn build` from the root directory of the repository
- run `pnpm install` and `pnpm build` from the root directory of the repository
- `cd packages/eslint-plugin-khan/demo`
- `rm node_modules`
- `yarn install`
- `yarn eslint .`
- `pnpm eslint .`

Your editor/IDE should report eslint errors that accurately reflect the changes you made
to the plugin.
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-khan/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "eslint --ext .ts --ext .js --ext .tsx --ext .jsx ."
},
"devDependencies": {
"@khanacademy/eslint-plugin": "^3.1.1",
"@khanacademy/eslint-plugin": "workspace:*",
"eslint": "^8.55.0",
"typescript": "^5.0.4"
},
Expand Down
Loading
Loading