Skip to content

Commit f9fb886

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

File tree

9 files changed

+121
-137
lines changed

9 files changed

+121
-137
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Setup pnpm CLI"
2+
description: "Install pnpm CLI only"
3+
4+
inputs:
5+
pnpm-version:
6+
description: "pnpm version"
7+
required: false
8+
default: "6.32.12"
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- uses: pnpm/action-setup@v2
14+
with:
15+
version: ${{ inputs.pnpm-version }}
16+
run_install: false

.github/actions/setup-pnpm/action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Setup pnpm with cache"
2+
description: "Setup Node.js, pnpm, and cache dependencies"
3+
4+
inputs:
5+
node-version:
6+
description: "Node.js version"
7+
required: false
8+
default: "16.x"
9+
pnpm-version:
10+
description: "pnpm version"
11+
required: false
12+
default: "6.32.12"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: ${{ inputs.node-version }}
20+
21+
- uses: pnpm/action-setup@v2
22+
with:
23+
version: ${{ inputs.pnpm-version }}
24+
run_install: false
25+
26+
- name: Get pnpm store directory
27+
id: pnpm-cache
28+
shell: bash
29+
run: |
30+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
31+
32+
- uses: actions/cache@v4
33+
with:
34+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
35+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pnpm-store-
38+
39+
- name: Install dependencies
40+
shell: bash
41+
run: pnpm install --frozen-lockfile

.github/workflows/CI.yml

Lines changed: 44 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,49 @@
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:
7-
push:
8-
branches: [master]
9-
pull_request:
10-
branches: [master]
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
118

12-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
139
jobs:
14-
setup:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
19-
20-
- name: Cache yarn.lock
21-
uses: actions/cache@v4
22-
with:
23-
path: package-temp-dir
24-
key: lock-${{ github.sha }}
25-
26-
- name: Create yarn.lock
27-
run: yarn generate-lock-entry
28-
29-
- name: Hack for single file
30-
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
37-
uses: actions/cache@v4
38-
with:
39-
path: node_modules
40-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
41-
42-
- name: Install dependencies
43-
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
44-
run: yarn
45-
46-
prettier:
47-
needs: [setup]
48-
runs-on: ubuntu-latest
49-
steps:
50-
- uses: actions/checkout@v2
51-
52-
- name: Restore cache from yarn.lock
53-
uses: actions/cache@v4
54-
with:
55-
path: package-temp-dir
56-
key: lock-${{ github.sha }}
57-
58-
- name: Restore cache from node_modules
59-
uses: actions/cache@v4
60-
with:
61-
path: node_modules
62-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
63-
64-
- name: Prettier check
65-
run: yarn prettier
66-
67-
eslint:
68-
needs: [setup]
69-
runs-on: ubuntu-latest
70-
steps:
71-
- uses: actions/checkout@v2
72-
73-
- name: Restore cache from yarn.lock
74-
uses: actions/cache@v4
75-
with:
76-
path: package-temp-dir
77-
key: lock-${{ github.sha }}
78-
79-
- name: Restore cache from node_modules
80-
uses: actions/cache@v4
81-
with:
82-
path: node_modules
83-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
84-
85-
- name: Eslint check
86-
run: yarn eslint
87-
88-
test:
89-
needs: [setup]
90-
runs-on: ubuntu-latest
91-
steps:
92-
- uses: actions/checkout@v2
93-
94-
- name: Restore cache from yarn.lock
95-
uses: actions/cache@v4
96-
with:
97-
path: package-temp-dir
98-
key: lock-${{ github.sha }}
99-
100-
- name: Restore cache from node_modules
101-
uses: actions/cache@v4
102-
with:
103-
path: node_modules
104-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
105-
106-
- name: Setup timezone
107-
uses: zcong1993/setup-timezone@master
108-
with:
109-
timezone: Asia/Shanghai
110-
111-
- name: Unit Test
112-
run: yarn test
113-
114-
build:
115-
runs-on: ubuntu-latest
116-
needs: [setup, prettier, eslint, test]
117-
steps:
118-
- uses: actions/checkout@v2
119-
120-
- name: Restore cache from yarn.lock
121-
uses: actions/cache@v4
122-
with:
123-
path: package-temp-dir
124-
key: lock-${{ github.sha }}
125-
126-
- name: Restore cache from node_modules
127-
uses: actions/cache@v4
128-
with:
129-
path: node_modules
130-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
131-
132-
- name: Build test
133-
run: yarn build
10+
setup:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: ./.github/actions/setup-pnpm
15+
16+
prettier:
17+
needs: setup
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: ./.github/actions/setup-pnpm-cli
22+
- run: pnpm prettier
23+
24+
eslint:
25+
needs: setup
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: ./.github/actions/setup-pnpm-cli
30+
- run: pnpm eslint
31+
32+
test:
33+
needs: setup
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: ./.github/actions/setup-pnpm-cli
38+
- uses: zcong1993/setup-timezone@master
39+
with:
40+
timezone: Asia/Shanghai
41+
- run: pnpm test
42+
43+
build:
44+
needs: [setup, prettier, eslint, test]
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: ./.github/actions/setup-pnpm-cli
49+
- 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)