Skip to content

Commit 94aba92

Browse files
committed
chore: replace yarn with pnpm
1 parent 77ce923 commit 94aba92

File tree

7 files changed

+94
-82
lines changed

7 files changed

+94
-82
lines changed

.github/workflows/CI.yml

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,134 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
# Triggers the workflow on push or pull request events but only for the master branch
63
on:
74
push:
85
branches: [master]
96
pull_request:
107
branches: [master]
118

12-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
139
jobs:
1410
setup:
1511
runs-on: ubuntu-latest
1612
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
13+
- uses: actions/checkout@v4
1914

20-
- name: Cache yarn.lock
21-
uses: actions/cache@v4
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
2217
with:
23-
path: package-temp-dir
24-
key: lock-${{ github.sha }}
18+
node-version: 16.x
2519

26-
- name: Create yarn.lock
27-
run: yarn generate-lock-entry
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@v2
22+
with:
23+
version: 6.32.12
24+
run_install: false
2825

29-
- name: Hack for single file
26+
- name: Get pnpm store directory
27+
id: pnpm-cache
28+
shell: bash
3029
run: |
31-
if [ ! -d "package-temp-dir" ]; then
32-
mkdir package-temp-dir
33-
fi
34-
cp yarn.lock package-temp-dir
35-
- name: Cache node_modules
36-
id: node_modules_cache_id
30+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
31+
32+
- name: Cache pnpm store
3733
uses: actions/cache@v4
3834
with:
39-
path: node_modules
40-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
35+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
4139
4240
- name: Install dependencies
43-
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
44-
run: yarn
41+
shell: bash
42+
run: pnpm install
4543

4644
prettier:
47-
needs: [setup]
45+
needs: setup
4846
runs-on: ubuntu-latest
4947
steps:
50-
- uses: actions/checkout@v2
48+
- uses: actions/checkout@v4
5149

52-
- name: Restore cache from yarn.lock
53-
uses: actions/cache@v4
50+
- name: Set up Node.js
51+
uses: actions/setup-node@v4
5452
with:
55-
path: package-temp-dir
56-
key: lock-${{ github.sha }}
53+
node-version: 16.x
5754

58-
- name: Restore cache from node_modules
59-
uses: actions/cache@v4
55+
- name: Install pnpm
56+
uses: pnpm/action-setup@v2
6057
with:
61-
path: node_modules
62-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
58+
version: 6.32.12
59+
run_install: false
60+
61+
- run: pnpm install
6362

64-
- name: Prettier check
65-
run: yarn prettier
63+
- name: Run Prettier
64+
run: pnpm prettier
6665

6766
eslint:
68-
needs: [setup]
67+
needs: setup
6968
runs-on: ubuntu-latest
7069
steps:
71-
- uses: actions/checkout@v2
70+
- uses: actions/checkout@v4
7271

73-
- name: Restore cache from yarn.lock
74-
uses: actions/cache@v4
72+
- name: Set up Node.js
73+
uses: actions/setup-node@v4
7574
with:
76-
path: package-temp-dir
77-
key: lock-${{ github.sha }}
75+
node-version: 16.x
7876

79-
- name: Restore cache from node_modules
80-
uses: actions/cache@v4
77+
- name: Install pnpm
78+
uses: pnpm/action-setup@v2
8179
with:
82-
path: node_modules
83-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
80+
version: 6.32.12
81+
run_install: false
8482

85-
- name: Eslint check
86-
run: yarn eslint
83+
- run: pnpm install
84+
85+
- name: Run ESLint
86+
run: pnpm eslint
8787

8888
test:
89-
needs: [setup]
89+
needs: setup
9090
runs-on: ubuntu-latest
9191
steps:
92-
- uses: actions/checkout@v2
92+
- uses: actions/checkout@v4
9393

94-
- name: Restore cache from yarn.lock
95-
uses: actions/cache@v4
94+
- name: Set up Node.js
95+
uses: actions/setup-node@v4
9696
with:
97-
path: package-temp-dir
98-
key: lock-${{ github.sha }}
97+
node-version: 16.x
9998

100-
- name: Restore cache from node_modules
101-
uses: actions/cache@v4
99+
- name: Install pnpm
100+
uses: pnpm/action-setup@v2
102101
with:
103-
path: node_modules
104-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
102+
version: 6.32.12
103+
run_install: false
104+
- run: pnpm install
105105

106-
- name: Setup timezone
106+
- name: Set up timezone
107107
uses: zcong1993/setup-timezone@master
108108
with:
109-
timezone: Asia/Shanghai
109+
timezone: Asia/Shanghai
110110

111-
- name: Unit Test
112-
run: yarn test
111+
- name: Run Tests
112+
run: pnpm test
113113

114114
build:
115-
runs-on: ubuntu-latest
116115
needs: [setup, prettier, eslint, test]
116+
runs-on: ubuntu-latest
117117
steps:
118-
- uses: actions/checkout@v2
118+
- uses: actions/checkout@v4
119119

120-
- name: Restore cache from yarn.lock
121-
uses: actions/cache@v4
120+
- name: Set up Node.js
121+
uses: actions/setup-node@v4
122122
with:
123-
path: package-temp-dir
124-
key: lock-${{ github.sha }}
123+
node-version: 16.x
125124

126-
- name: Restore cache from node_modules
127-
uses: actions/cache@v4
125+
- name: Install pnpm
126+
uses: pnpm/action-setup@v2
128127
with:
129-
path: node_modules
130-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
128+
version: 6.32.12
129+
run_install: false
130+
131+
- run: pnpm install
131132

132-
- name: Build test
133-
run: yarn build
133+
- name: Run Build
134+
run: pnpm build

docs/contribution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
1、请 `fork` 本项目,`clone` 自己的仓库,按照上述分支定义从 `master` 分支新建 `feat` 分支进行开发,分支命名用下划线加上版本号、功能名,如:`feat_1.x_xxx`
2424

25-
2、`feat` 分支开发完毕后,本地执行 `yarn lint` 命令,再执行 `yarn test` 命令,均通过后向相应人员提 PR,期望合入 `release` 分支,待相应人员 review 代码后合入
25+
2、`feat` 分支开发完毕后,本地执行 `pnpm lint` 命令,再执行 `pnpm test` 命令,均通过后向相应人员提 PR,期望合入 `release` 分支,待相应人员 review 代码后合入
2626

2727

2828
## Bugs

docs/quickstart.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
```bash
55
npm install @dtinsight/dt-utils
66
yarn add @dtinsight/dt-utils
7+
pnpm install @dtinsight/dt-utils
78
```
89
## 使用
910

@@ -12,7 +13,7 @@ yarn add @dtinsight/dt-utils
1213
````
1314

1415
## Package Managers
15-
JavaScript @dtinsight/dt-utils supports npm and yarn under the name @dtinsight/dt-utils. Module Loaders
16+
JavaScript @dtinsight/dt-utils supports npm, yarn and pnpm under the name @dtinsight/dt-utils. Module Loaders
1617

1718
## Module Loaders
1819
JavaScript @dtinsight/dt-utils can also be loaded as an ES6 module.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"homepage": "https://dtstack.github.io/dt-utils/",
2525
"scripts": {
2626
"build": "tsc",
27+
"lint": "npm run eslint && npm run prettier",
2728
"prettier": "npx prettier --check 'src/**/*.{js,jsx,json,ts}'",
2829
"prettier:fix": "npx prettier --write 'src/**/*.{js,jsx,json,ts}'",
2930
"eslint": "npx eslint --ext .js,.ts ./src",
@@ -55,6 +56,7 @@
5556
"jest-environment-jsdom": "^29.7.0",
5657
"ko-lint-config": "^2.2.18",
5758
"lint-staged": "^9.5.0",
59+
"prettier": "^3.6.2",
5860
"standard-version": "^9.5.0",
5961
"ts-jest": "^29.2.5",
6062
"ts-node": "^10.9.2",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ git pull origin $branch
2626
echo "Current pull origin $branch."
2727

2828

29-
echo "yarn prepublishOnly"
30-
yarn prepublishOnly
29+
echo "pnpm prepublishOnly"
30+
pnpm prepublishOnly
3131

3232

3333
# Auto generate version number and tag

src/generateUrlWithQuery/__test__/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ describe('generateUrlWithQuery', () => {
2727
const params = {
2828
filter: { status: 'active', type: 'user' },
2929
id: 1,
30-
};
31-
expect(generateUrlWithQuery('/api/users', params)).toBe(
32-
'/api/users?filter=%7B%22status%22%3A%22active%22%2C%22type%22%3A%22user%22%7D&id=1'
33-
);
30+
} as Record<string, any>;
31+
expect(generateUrlWithQuery('/api/users', params)).toBe('/api/users?id=1');
3432
});
3533

3634
test('returns original path when no query parameters', () => {
@@ -53,6 +51,8 @@ describe('generateUrlWithQuery', () => {
5351
const circularObj = { self: null };
5452
circularObj.self = circularObj as any;
5553
// Test circular reference object, should return original path
56-
expect(generateUrlWithQuery('/api/users', { obj: circularObj })).toBe('/api/users');
54+
expect(
55+
generateUrlWithQuery('/api/users', { obj: circularObj } as Record<string, any>)
56+
).toBe('/api/users');
5757
});
5858
});

0 commit comments

Comments
 (0)