Skip to content

Commit 610fb7c

Browse files
committed
feat: add pnpm support
1 parent 7128de7 commit 610fb7c

29 files changed

Lines changed: 24283 additions & 93 deletions

File tree

.github/actions/prepare-workspace/action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ runs:
55
using: composite
66
steps:
77
- uses: actions/checkout@v4
8+
- uses: pnpm/action-setup@v4
9+
with:
10+
version: 10
11+
cache: true
812
- uses: actions/setup-node@v4
913
with:
1014
node-version-file: '.nvmrc'
1115
registry-url: 'https://registry.npmjs.org'
12-
cache: 'npm'
16+
cache: 'pnpm'
1317

1418
- name: Install Dependencies
1519
shell: bash
16-
run: npm ci
20+
run: pnpm install --frozen-lockfile

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ jobs:
2121
- uses: ./.github/actions/prepare-workspace
2222

2323
- name: Run Lint
24-
run: npm run lint
24+
run: pnpm run lint
2525

2626
- name: Run Stylelint
27-
run: npm run stylelint
27+
run: pnpm run stylelint
2828

2929
- name: Run Tests
30-
run: npm run test:all
30+
run: pnpm run test:all
3131

3232
- name: Run Bundle Size Test
33-
run: npm run test:size
33+
run: pnpm run test:size
3434

3535
- name: Run Create IMA App Test
36-
run: npm run test:create-ima-app
36+
run: pnpm run test:create-ima-app
3737

3838
release:
3939
if: github.ref_name == 'master' || github.ref_name == 'next'
@@ -50,7 +50,7 @@ jobs:
5050
- name: Release new versions
5151
env:
5252
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
53-
run: npm run release:publish
53+
run: pnpm run release:publish
5454

5555
- name: Create GitHub Releases
5656
uses: seznam/changeset-create-release@main

.github/workflows/pages-deploy.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16+
- uses: pnpm/action-setup@v2
17+
with:
18+
version: 10
1619
- uses: actions/setup-node@v3
1720
with:
1821
node-version: 24
19-
cache: npm
22+
cache: pnpm
2023

2124
- name: Install dependencies
22-
run: npm ci
25+
run: pnpm install --frozen-lockfile
2326
- name: Build website
24-
run: npm run build:doc --workspaces --if-present
27+
run: pnpm run -r --if-present build:doc
2528

2629
# Popular action to deploy to GitHub Pages:
2730
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npx --no-install lint-staged
1+
lint-staged

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
registry = "https://registry.npmjs.org/"
2+
shamefully-hoist = true

package.json

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,24 @@
2828
],
2929
"scripts": {
3030
"dev": "node ./utils/scripts/dev.js",
31-
"build": "npm run build --workspaces --if-present",
32-
"commit": "echo 'This command has been replaced with \"npm run changeset\"'",
31+
"build": "pnpm run --recursive --if-present build",
32+
"commit": "echo 'This command has been replaced with \"pnpm run changeset\"'",
3333
"changeset": "changeset add",
34-
"postinstall": "npm run build",
3534
"lint": "eslint --cache --cache-location=node_modules/.cache/ './**/*.{js,jsx,ts,tsx,mjs}'",
3635
"prepare": "husky",
37-
"release": "npm run release:prepare && npm run release:push",
38-
"release:prepare": "npm run check:uncommited:changes && changeset version && npm i --package-lock-only --ignore-scripts",
39-
"release:push": "git add .changeset package-lock.json packages/*/CHANGELOG.md packages/*/package.json && git commit -m 'Publish' && changeset tag && git push --follow-tags",
40-
"release:devtools": "npm run publish-webstore --prefix ./packages/devtools",
41-
"release:graduate": "npm run check:uncommited:changes && changeset pre exit && node utils/changesets/config-base-branch-replace.js master && changeset version && npm i --package-lock-only --ignore-scripts && npm run release:push",
36+
"release": "pnpm run release:prepare && pnpm run release:push",
37+
"release:prepare": "pnpm run check:uncommited:changes && changeset version && pnpm i --lockfile-only --ignore-scripts",
38+
"release:push": "git add .changeset pnpm-lock.yaml packages/*/CHANGELOG.md packages/*/package.json && git commit -m 'Publish' && changeset tag && git push --follow-tags",
39+
"release:devtools": "pnpm run --filter ./packages/devtools publish-webstore",
40+
"release:graduate": "pnpm run check:uncommited:changes && changeset pre exit && node utils/changesets/config-base-branch-replace.js master && changeset version && pnpm i --lockfile-only --ignore-scripts && pnpm run release:push",
4241
"release:next:init": "changeset pre enter rc && node utils/changesets/config-base-branch-replace.js next",
4342
"release:publish": "changeset publish --no-git-tag",
4443
"stylelint": "stylelint --cache --cache-location=node_modules/.cache/ './**/*.{css,less}'",
4544
"test": "jest --changedSince `test -f '.changeset/pre.json' && echo 'next' || echo 'master'`",
4645
"test:all": "jest --colors",
4746
"test:create-ima-app": "utils/tests/testRunner.sh",
48-
"test:size": "npm run test:size --workspaces --if-present",
49-
"version": "npm run doc && node utils/version/create-ima-app-versions.js && git add docs packages/create-ima-app/template/common/package.json",
47+
"test:size": "pnpm run --recursive --if-present test:size",
48+
"version": "pnpm run doc && node utils/version/create-ima-app-versions.js && git add docs packages/create-ima-app/template/common/package.json",
5049
"check:uncommited:changes": "test \"`git status . --porcelain`\" && echo 'There are uncommitted changes. Aborting release.' && exit 1 || exit 0"
5150
},
5251
"lint-staged": {
@@ -88,7 +87,7 @@
8887
"eslint-import-resolver-typescript": "^4.4.4",
8988
"eslint-plugin-import": "^2.32.0",
9089
"eslint-plugin-jest": "^29.1.0",
91-
"eslint-plugin-prettier": "^5.5.4",
90+
"eslint-plugin-prettier": "5.5.4",
9291
"eslint-plugin-react": "^7.37.5",
9392
"fork-ts-checker-webpack-plugin": "^9.1.0",
9493
"fs-extra": "^11.3.2",
@@ -107,7 +106,7 @@
107106
"postcss-less": "6.0.0",
108107
"postcss-loader": "^8.2.0",
109108
"postcss-preset-env": "^10.4.0",
110-
"prettier": "^3.6.2",
109+
"prettier": "3.6.2",
111110
"react": "^18.3.1",
112111
"react-dom": "^18.3.1",
113112
"rollup": "^4.53.2",
@@ -126,8 +125,8 @@
126125
"webpack-cli": "^6.0.1",
127126
"yargs": "^18.0.0"
128127
},
129-
"overrides": {
130-
"enzyme": {
128+
"pnpm": {
129+
"overrides": {
131130
"cheerio": "1.0.0-rc.12"
132131
}
133132
}

packages/cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"dev": "tsc -w --preserveWatchOutput",
2929
"lint": "eslint './**/*.{js,jsx,ts,tsx}'",
3030
"test": "jest -c jest.config.js",
31-
"test:watch": "npm run test -- --watch"
31+
"test:watch": "pnpm run test --watch",
32+
"prepare": "pnpm run build"
3233
},
3334
"dependencies": {
3435
"@babel/generator": "^7.28.5",

packages/core/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@
5454
"build": "node ../plugin-cli/dist/bin/ima-plugin.js build",
5555
"link": "node ../plugin-cli/dist/bin/ima-plugin.js link",
5656
"lint": "eslint './**/*.{js,jsx,ts,tsx}'",
57-
"test": "npm run test:jest && npm run test:size",
57+
"test": "pnpm run test:jest && pnpm run test:size",
5858
"test:jest": "jest -c jest.config.js",
5959
"test:size": "size-limit",
60-
"preversion": "npm test"
60+
"preversion": "pnpm run test",
61+
"prepare": "pnpm run build"
6162
},
6263
"dependencies": {
6364
"@esmj/task": "^0.5.2",

packages/create-ima-app/bin/create-ima-app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ if (nodeMajorVersion > MAX_NODE_VERSION) {
5555
// Run create script
5656
create(
5757
process.argv[2],
58-
process.argv.includes('--typescript') || process.argv.includes('-ts')
58+
process.argv.includes('--typescript') || process.argv.includes('-ts'),
59+
process.argv.includes('--pnpm')
5960
);

packages/create-ima-app/scripts/create.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import fsExtra from 'fs-extra/esm';
1010

1111
import { info, error, mergePkgJson } from './utils.js';
1212

13-
export async function create(projDir, useTS) {
13+
export async function create(projDir, useTS, usePNPM) {
1414
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1515

1616
info(
@@ -74,16 +74,19 @@ export async function create(projDir, useTS) {
7474
pkgJson.name = projName;
7575
await fs.promises.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
7676

77-
// Run npm install
77+
// Determine package manager
78+
const pkgManager = usePNPM ? 'pnpm' : 'npm';
79+
80+
// Run package manager install
7881
info(
7982
`Running ${chalk.magenta(
80-
'npm install'
83+
`${pkgManager} install`
8184
)} inside app directory, this might take a while...`
8285
);
8386

8487
console.log(chalk.dim(' Press CTRL+C to cancel.\n'));
8588

86-
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
89+
const npm = process.platform === 'win32' ? `${pkgManager}.cmd` : pkgManager;
8790
spawnSync(npm, ['install'], {
8891
stdio: 'inherit',
8992
cwd: appRoot,
@@ -97,24 +100,24 @@ export async function create(projDir, useTS) {
97100
98101
From there you can run several commands:
99102
100-
${chalk.blue('npm run test')}
103+
${chalk.blue(`${pkgManager} run test`)}
101104
To run test runners.
102105
103-
${chalk.blue('npm run lint')}
106+
${chalk.blue(`${pkgManager} run lint`)}
104107
To run eslint on your application source files.
105108
106-
${chalk.blue('npm run dev')}
109+
${chalk.blue(`${pkgManager} run dev`)}
107110
To start development server.
108111
109-
${chalk.blue('npm run build')}
112+
${chalk.blue(`${pkgManager} run build`)}
110113
To build the application.
111114
112-
${chalk.blue('npm run start')}
115+
${chalk.blue(`${pkgManager} run start`)}
113116
To start IMA.js application server.
114117
115118
We suggest that you start with:
116119
117120
${chalk.blue('cd')} ${projDir}
118-
${chalk.blue('npm run dev')}
121+
${chalk.blue(`${pkgManager} run dev`)}
119122
`);
120123
}

0 commit comments

Comments
 (0)