1
0
mirror of https://github.com/pnpm/action-setup.git synced 2026-06-26 16:43:47 +08:00

Compare commits

...

21 Commits

Author SHA1 Message Date
Oscar Busk
8a1f0929f7 Merge 35353b8037 into 3a0024f066 2025-12-05 16:51:05 +01:00
silverwind
3a0024f066 Remove unused @types/node-fetch dependency (#186) 2025-12-05 16:50:59 +01:00
Roman Usherenko
72f04517b7 Update README.md (#175)
fix the string run_install example
2025-12-05 15:32:46 +01:00
Oscar Busk
35353b8037 Add store_prune to run name 2025-10-28 01:07:44 +01:00
Oscar Busk
4f04570f82 Add store_prune to tests 2025-10-28 00:58:14 +01:00
Oscar Busk
40fbc12c16 Actually check for run_install before store_prune, to match documentation 2025-10-28 00:45:12 +01:00
Oscar Busk
14f23f2699 Add more documentation regarding caching, pruning and the run_install and store_prune options 2025-10-28 00:44:29 +01:00
Oscar Busk
6a5147c614 Update documentation about pnpm store prune 2025-10-28 00:41:07 +01:00
Oscar Busk
82352014bc Add option to disable automatic pruning of store 2025-10-28 00:35:57 +01:00
Oscar Busk
37f0218d62 Make the message when not pruning more helpful
The original message made it sound like it checked the store and decided there was nothing to prune, in reality pruning just did not run if run_install was not set.
2025-10-28 00:31:32 +01:00
Oscar Busk
3cec5320c9 Run pruning as part of main action, not in post
The post action will execute too late to actually improve any caching. By pruning directly after running pnpm install(s), we make sure the store is as clean as possible before continuing. This means any attempt to cache the pnpm store will be caching a pruned store
2025-10-28 00:26:18 +01:00
Adrian Riedel
41ff726559 feat: support installation from custom NPM registry (#179)
copy .npmrc from GitHub workspace if it exists so that PNPM respects custom
registry configurations when self-installing
2025-10-08 10:48:14 +02:00
Matthias
f2b2b233b5 Remove --frozen-lockfile from examples (#171) 2025-07-11 00:08:35 +02:00
Matthias
77504a59bc Fix multiline run_install example in README.md (#167) 2025-06-25 18:10:02 +02:00
Kevin Cui
d648c2dd06 fix: not allow install multiple package manager (#161)
When a project has both npm and pnpm, using pnpm/action-setup will result in an error: `Multiple versions of pnpm specified`.

The previous implementation was only meant to avoid the "ERR_PNPM_BAD_PM_VERSION" error, but it did not take into account the situation of multiple different package managers.

Signed-off-by: Kevin Cui <bh@bugs.cc>
2025-03-28 08:37:14 +08:00
Zoltan Kochan
a7487c7e89 feat: update dist 2025-02-06 22:30:07 +01:00
Zoltan Kochan
fff70888d0 test: update pnpm to v9 2025-02-06 22:24:21 +01:00
Daniel Bayley
6e3017af18 docs: support package.yaml (#157) 2025-02-06 22:13:04 +01:00
Daniel Bayley
0cb0538c33 feat: support package.yaml (#156) 2025-02-06 22:04:41 +01:00
Azat S.
e303250a24 docs: update pnpm version in readme examples (#154) 2025-01-09 00:42:18 +01:00
Karl Horky
ac5bf11548 Update examples to use pnpm v9 (#142) 2024-08-14 16:07:48 +02:00
10 changed files with 172 additions and 173 deletions

View File

@@ -15,7 +15,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
pnpm: pnpm:
- 4.11.1 - 9.15.5
os: os:
- ubuntu-latest - ubuntu-latest
- macos-latest - macos-latest
@@ -27,7 +27,7 @@ jobs:
- name: Run the action - name: Run the action
uses: ./ uses: ./
with: with:
version: 4.11.1 version: 9.15.5
- name: 'Test: which' - name: 'Test: which'
run: which pnpm; which pnpx run: which pnpm; which pnpx
@@ -44,7 +44,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
pnpm: pnpm:
- 4.11.1 - 9.15.5
os: os:
- ubuntu-latest - ubuntu-latest
- macos-latest - macos-latest
@@ -56,7 +56,7 @@ jobs:
- name: Run the action - name: Run the action
uses: ./ uses: ./
with: with:
version: 4.11.1 version: 9.15.5
dest: ~/test/pnpm dest: ~/test/pnpm
- name: 'Test: which' - name: 'Test: which'
@@ -88,7 +88,7 @@ jobs:
- name: Run the action - name: Run the action
uses: ./ uses: ./
with: with:
version: 7.0.0 version: 9.15.0
standalone: ${{ matrix.standalone }} standalone: ${{ matrix.standalone }}
- name: install Node.js - name: install Node.js
@@ -121,7 +121,7 @@ jobs:
fi fi
test_run_install: test_run_install:
name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})' name: 'Test with run_install (${{ matrix.run_install.name }}, prune=${{matrix.store_prune}}, ${{ matrix.os }})'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@@ -129,7 +129,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
pnpm: pnpm:
- 4.11.1 - 9.15.5
os: os:
- ubuntu-latest - ubuntu-latest
- macos-latest - macos-latest
@@ -149,7 +149,6 @@ jobs:
- --global-dir=./pnpm-global - --global-dir=./pnpm-global
- npm - npm
- yarn - yarn
- pnpm
- name: 'array' - name: 'array'
value: | value: |
- {} - {}
@@ -159,7 +158,9 @@ jobs:
- --global-dir=./pnpm-global - --global-dir=./pnpm-global
- npm - npm
- yarn - yarn
- pnpm store_prune:
- 'true'
- 'false'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -167,8 +168,9 @@ jobs:
- name: Run the action - name: Run the action
uses: ./ uses: ./
with: with:
version: 4.11.1 version: 9.15.5
run_install: ${{ matrix.run_install.value }} run_install: ${{ matrix.run_install.value }}
store_prune: ${{ matrix.store_prune }}
- name: 'Test: which' - name: 'Test: which'
run: which pnpm; which pnpx run: which pnpm; which pnpx

View File

@@ -30,6 +30,8 @@ If `run_install` is `true`, pnpm will install dependencies recursively.
If `run_install` is a YAML string representation of either an object or an array, pnpm will execute every install commands. If `run_install` is a YAML string representation of either an object or an array, pnpm will execute every install commands.
If any `run_install` is not falsy, and `store_prune` is not set to `false`, `pnpm store prune` will be executed after all install commands have been executed. This is to ensure the pnpm store is pruned before caching.
#### `run_install.recursive` #### `run_install.recursive`
**Optional** (_type:_ `boolean`, _default:_ `false`) Whether to use `pnpm recursive install`. **Optional** (_type:_ `boolean`, _default:_ `false`) Whether to use `pnpm recursive install`.
@@ -40,11 +42,15 @@ If `run_install` is a YAML string representation of either an object or an array
#### `run_install.args` #### `run_install.args`
**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--frozen-lockfile, --strict-peer-dependencies]`. **Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--ignore-scripts, --strict-peer-dependencies]`.
#### `store_prune`
**Optional** (_type:_ `boolean`, _default:_ `true`) Whether to run `pnpm store prune` after installation. If `run_install` is falsy, this option will be ignored. If you run `pnpm install` on your own, and intend to cache the pnpm store, it's recommended to run `pnpm store prune` yourself to make sure the store that will be cached is pruned.
### `package_json_file` ### `package_json_file`
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json` to read "packageManager" configuration. **Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json`/[`package.yaml`](https://github.com/pnpm/pnpm/pull/1799) to read "packageManager" configuration.
### `standalone` ### `standalone`
@@ -80,7 +86,7 @@ jobs:
steps: steps:
- uses: pnpm/action-setup@v4 - uses: pnpm/action-setup@v4
with: with:
version: 8 version: 10
``` ```
### Install only pnpm with `packageManager` ### Install only pnpm with `packageManager`
@@ -116,10 +122,10 @@ jobs:
- uses: pnpm/action-setup@v4 - uses: pnpm/action-setup@v4
with: with:
version: 8 version: 10
run_install: | run_install: |
- recursive: true - recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies] args: [--strict-peer-dependencies]
- args: [--global, gulp, prettier, typescript] - args: [--global, gulp, prettier, typescript]
``` ```
@@ -141,7 +147,7 @@ jobs:
- uses: pnpm/action-setup@v4 - uses: pnpm/action-setup@v4
name: Install pnpm name: Install pnpm
with: with:
version: 8 version: 10
run_install: false run_install: false
- name: Install Node.js - name: Install Node.js
@@ -152,9 +158,12 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: pnpm install run: pnpm install
- name: Prune pnpm store
run: pnpm store prune
``` ```
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that. **Note:** If you you opt to run install on your own (`run_install: false`), it's recommended to run [`pnpm store prune`](https://pnpm.io/cli/store#prune) after installation to make sure the store that will be cached is pruned.
## Notes ## Notes

View File

@@ -15,6 +15,10 @@ inputs:
description: If specified, run `pnpm install` description: If specified, run `pnpm install`
required: false required: false
default: 'null' default: 'null'
store_prune:
description: Enable store pruning after installation. Set to false to disable.
required: false
default: 'true'
package_json_file: package_json_file:
description: File path to the package.json to read "packageManager" configuration description: File path to the package.json to read "packageManager" configuration
required: false required: false
@@ -31,4 +35,3 @@ outputs:
runs: runs:
using: node20 using: node20
main: dist/index.js main: dist/index.js
post: dist/index.js

6
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -10,7 +10,6 @@
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@types/expand-tilde": "^2.0.2", "@types/expand-tilde": "^2.0.2",
"@types/node": "^20.11.5", "@types/node": "^20.11.5",
"@types/node-fetch": "^2.6.11",
"expand-tilde": "^2.0.2", "expand-tilde": "^2.0.2",
"yaml": "^2.3.4", "yaml": "^2.3.4",
"zod": "^3.22.4" "zod": "^3.22.4"

212
pnpm-lock.yaml generated
View File

@@ -1,180 +1,146 @@
lockfileVersion: '6.0' lockfileVersion: '9.0'
settings: settings:
autoInstallPeers: true autoInstallPeers: true
excludeLinksFromLockfile: false excludeLinksFromLockfile: false
dependencies: importers:
.:
dependencies:
'@actions/core': '@actions/core':
specifier: ^1.10.1 specifier: ^1.10.1
version: 1.10.1 version: 1.11.1
'@types/expand-tilde': '@types/expand-tilde':
specifier: ^2.0.2 specifier: ^2.0.2
version: 2.0.2 version: 2.0.2
'@types/node': '@types/node':
specifier: ^20.11.5 specifier: ^20.11.5
version: 20.11.5 version: 20.17.17
'@types/node-fetch':
specifier: ^2.6.11
version: 2.6.11
expand-tilde: expand-tilde:
specifier: ^2.0.2 specifier: ^2.0.2
version: 2.0.2 version: 2.0.2
yaml: yaml:
specifier: ^2.3.4 specifier: ^2.3.4
version: 2.3.4 version: 2.7.0
zod: zod:
specifier: ^3.22.4 specifier: ^3.22.4
version: 3.22.4 version: 3.24.1
devDependencies:
devDependencies:
'@vercel/ncc': '@vercel/ncc':
specifier: ^0.38.1 specifier: ^0.38.1
version: 0.38.1 version: 0.38.3
pnpm: pnpm:
specifier: ^8.14.3 specifier: ^8.14.3
version: 8.14.3 version: 8.15.9
typescript: typescript:
specifier: ^5.3.3 specifier: ^5.3.3
version: 5.3.3 version: 5.7.3
packages: packages:
/@actions/core@1.10.1: '@actions/core@1.11.1':
resolution: {integrity: sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==} resolution: {integrity: sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==}
dependencies:
'@actions/http-client': 2.2.0
uuid: 8.3.2
dev: false
/@actions/http-client@2.2.0: '@actions/exec@1.1.1':
resolution: {integrity: sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==} resolution: {integrity: sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==}
dependencies:
tunnel: 0.0.6
undici: 5.28.3
dev: false
/@fastify/busboy@2.1.0: '@actions/http-client@2.1.0':
resolution: {integrity: sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==} resolution: {integrity: sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==}
engines: {node: '>=14'}
dev: false
/@types/expand-tilde@2.0.2: '@actions/io@1.1.3':
resolution: {integrity: sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==}
'@types/expand-tilde@2.0.2':
resolution: {integrity: sha512-wlsMYiapmIR4Eq/Z0qysN8xaDMjSkO6AIDNFx9oxgWGeKVA1jU+NzwPRZErBNP5z6/dx6QNkNpKglBGPO9OkTA==} resolution: {integrity: sha512-wlsMYiapmIR4Eq/Z0qysN8xaDMjSkO6AIDNFx9oxgWGeKVA1jU+NzwPRZErBNP5z6/dx6QNkNpKglBGPO9OkTA==}
dev: false
/@types/node-fetch@2.6.11: '@types/node@20.17.17':
resolution: {integrity: sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==} resolution: {integrity: sha512-/WndGO4kIfMicEQLTi/mDANUu/iVUhT7KboZPdEqqHQ4aTS+3qT3U5gIqWDFV+XouorjfgGqvKILJeHhuQgFYg==}
dependencies:
'@types/node': 20.11.5
form-data: 4.0.0
dev: false
/@types/node@20.11.5: '@vercel/ncc@0.38.3':
resolution: {integrity: sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==} resolution: {integrity: sha512-rnK6hJBS6mwc+Bkab+PGPs9OiS0i/3kdTO+CkI8V0/VrW3vmz7O2Pxjw/owOlmo6PKEIxRSeZKv/kuL9itnpYA==}
dependencies:
undici-types: 5.26.5
dev: false
/@vercel/ncc@0.38.1:
resolution: {integrity: sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==}
hasBin: true hasBin: true
dev: true
/asynckit@0.4.0: expand-tilde@2.0.2:
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
dev: false
/combined-stream@1.0.8:
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
engines: {node: '>= 0.8'}
dependencies:
delayed-stream: 1.0.0
dev: false
/delayed-stream@1.0.0:
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
engines: {node: '>=0.4.0'}
dev: false
/expand-tilde@2.0.2:
resolution: {integrity: sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==} resolution: {integrity: sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
dependencies:
homedir-polyfill: 1.0.3
dev: false
/form-data@4.0.0: homedir-polyfill@1.0.3:
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
engines: {node: '>= 6'}
dependencies:
asynckit: 0.4.0
combined-stream: 1.0.8
mime-types: 2.1.35
dev: false
/homedir-polyfill@1.0.3:
resolution: {integrity: sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==} resolution: {integrity: sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
dependencies:
parse-passwd: 1.0.0
dev: false
/mime-db@1.52.0: parse-passwd@1.0.0:
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'}
dev: false
/mime-types@2.1.35:
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
engines: {node: '>= 0.6'}
dependencies:
mime-db: 1.52.0
dev: false
/parse-passwd@1.0.0:
resolution: {integrity: sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==} resolution: {integrity: sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
dev: false
/pnpm@8.14.3: pnpm@8.15.9:
resolution: {integrity: sha512-w+2A61g74+K37zHrlri5z6oFA+XUTscXUUEgtRh7L5M3NukDjFGlojrVgnkLpB1Kt4RhjIn6fiNl9mZWhdYS7g==} resolution: {integrity: sha512-SZQ0ydj90aJ5Tr9FUrOyXApjOrzuW7Fee13pDzL0e1E6ypjNXP0AHDHw20VLw4BO3M1XhQHkyik6aBYWa72fgQ==}
engines: {node: '>=16.14'} engines: {node: '>=16.14'}
hasBin: true hasBin: true
dev: true
/tunnel@0.0.6: tunnel@0.0.6:
resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==} resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==}
engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'} engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'}
dev: false
/typescript@5.3.3: typescript@5.7.3:
resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==}
engines: {node: '>=14.17'} engines: {node: '>=14.17'}
hasBin: true hasBin: true
dev: true
/undici-types@5.26.5: undici-types@6.19.8:
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}
dev: false
/undici@5.28.3: yaml@2.7.0:
resolution: {integrity: sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==} resolution: {integrity: sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==}
engines: {node: '>=14.0'}
dependencies:
'@fastify/busboy': 2.1.0
dev: false
/uuid@8.3.2:
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
hasBin: true
dev: false
/yaml@2.3.4:
resolution: {integrity: sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==}
engines: {node: '>= 14'} engines: {node: '>= 14'}
dev: false hasBin: true
/zod@3.22.4: zod@3.24.1:
resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==}
dev: false
snapshots:
'@actions/core@1.11.1':
dependencies:
'@actions/exec': 1.1.1
'@actions/http-client': 2.1.0
'@actions/exec@1.1.1':
dependencies:
'@actions/io': 1.1.3
'@actions/http-client@2.1.0':
dependencies:
tunnel: 0.0.6
'@actions/io@1.1.3': {}
'@types/expand-tilde@2.0.2': {}
'@types/node@20.17.17':
dependencies:
undici-types: 6.19.8
'@vercel/ncc@0.38.3': {}
expand-tilde@2.0.2:
dependencies:
homedir-polyfill: 1.0.3
homedir-polyfill@1.0.3:
dependencies:
parse-passwd: 1.0.0
parse-passwd@1.0.0: {}
pnpm@8.15.9: {}
tunnel@0.0.6: {}
typescript@5.7.3: {}
undici-types@6.19.8: {}
yaml@2.7.0: {}
zod@3.24.1: {}

View File

@@ -1,4 +1,4 @@
import { setFailed, saveState, getState } from '@actions/core' import { setFailed } from '@actions/core'
import getInputs from './inputs' import getInputs from './inputs'
import installPnpm from './install-pnpm' import installPnpm from './install-pnpm'
import setOutputs from './outputs' import setOutputs from './outputs'
@@ -7,13 +7,11 @@ import pruneStore from './pnpm-store-prune'
async function main() { async function main() {
const inputs = getInputs() const inputs = getInputs()
const isPost = getState('is_post')
if (isPost === 'true') return pruneStore(inputs)
saveState('is_post', 'true')
await installPnpm(inputs) await installPnpm(inputs)
console.log('Installation Completed!') console.log('Installation Completed!')
setOutputs(inputs) setOutputs(inputs)
pnpmInstall(inputs) pnpmInstall(inputs)
pruneStore(inputs)
} }
main().catch(error => { main().catch(error => {

View File

@@ -6,6 +6,7 @@ export interface Inputs {
readonly version?: string readonly version?: string
readonly dest: string readonly dest: string
readonly runInstall: RunInstall[] readonly runInstall: RunInstall[]
readonly storePrune: boolean
readonly packageJsonFile: string readonly packageJsonFile: string
readonly standalone: boolean readonly standalone: boolean
} }
@@ -20,6 +21,7 @@ export const getInputs = (): Inputs => ({
version: getInput('version'), version: getInput('version'),
dest: parseInputPath('dest'), dest: parseInputPath('dest'),
runInstall: parseRunInstall('run_install'), runInstall: parseRunInstall('run_install'),
storePrune: getBooleanInput('store_prune'),
packageJsonFile: parseInputPath('package_json_file'), packageJsonFile: parseInputPath('package_json_file'),
standalone: getBooleanInput('standalone'), standalone: getBooleanInput('standalone'),
}) })

View File

@@ -1,14 +1,16 @@
import { addPath, exportVariable } from '@actions/core' import { addPath, exportVariable } from '@actions/core'
import { spawn } from 'child_process' import { spawn } from 'child_process'
import { rm, writeFile, mkdir } from 'fs/promises' import { rm, writeFile, mkdir, copyFile } from 'fs/promises'
import { readFileSync } from 'fs' import { readFileSync } from 'fs'
import path from 'path' import path from 'path'
import { execPath } from 'process' import { execPath } from 'process'
import util from 'util' import util from 'util'
import { Inputs } from '../inputs' import { Inputs } from '../inputs'
import YAML from 'yaml'
export async function runSelfInstaller(inputs: Inputs): Promise<number> { export async function runSelfInstaller(inputs: Inputs): Promise<number> {
const { version, dest, packageJsonFile, standalone } = inputs const { version, dest, packageJsonFile, standalone } = inputs
const { GITHUB_WORKSPACE } = process.env
// prepare self install // prepare self install
await rm(dest, { recursive: true, force: true }) await rm(dest, { recursive: true, force: true })
@@ -18,6 +20,16 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
// we have ensured the dest directory exists, we can write the file directly // we have ensured the dest directory exists, we can write the file directly
await writeFile(pkgJson, JSON.stringify({ private: true })) await writeFile(pkgJson, JSON.stringify({ private: true }))
// copy .npmrc if it exists to install from custom registry
if (GITHUB_WORKSPACE) {
try {
await copyFile(path.join(GITHUB_WORKSPACE, '.npmrc'), path.join(dest, '.npmrc'))
} catch (error) {
// Swallow error if .npmrc doesn't exist
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
}
}
// prepare target pnpm // prepare target pnpm
const target = await readTarget({ version, packageJsonFile, standalone }) const target = await readTarget({ version, packageJsonFile, standalone })
const cp = spawn(execPath, [path.join(__dirname, 'pnpm.cjs'), 'install', target, '--no-lockfile'], { const cp = spawn(execPath, [path.join(__dirname, 'pnpm.cjs'), 'install', target, '--no-lockfile'], {
@@ -49,7 +61,11 @@ async function readTarget(opts: {
if (GITHUB_WORKSPACE) { if (GITHUB_WORKSPACE) {
try { try {
({ packageManager } = JSON.parse(readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8'))) const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8');
({ packageManager } = packageJsonFile.endsWith(".yaml")
? YAML.parse(content, { merge: true })
: JSON.parse(content)
)
} catch (error: unknown) { } catch (error: unknown) {
// Swallow error if package.json doesn't exist in root // Swallow error if package.json doesn't exist in root
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
@@ -59,6 +75,7 @@ async function readTarget(opts: {
if (version) { if (version) {
if ( if (
typeof packageManager === 'string' && typeof packageManager === 'string' &&
packageManager.startsWith('pnpm@') &&
packageManager.replace('pnpm@', '') !== version packageManager.replace('pnpm@', '') !== version
) { ) {
throw new Error(`Multiple versions of pnpm specified: throw new Error(`Multiple versions of pnpm specified:

View File

@@ -5,7 +5,12 @@ import { patchPnpmEnv } from '../utils'
export function pruneStore(inputs: Inputs) { export function pruneStore(inputs: Inputs) {
if (inputs.runInstall.length === 0) { if (inputs.runInstall.length === 0) {
console.log('Pruning is unnecessary.') console.log('No install commands were run, skipping pnpm store prune, remember to run it after pnpm install if caching the store.')
return
}
if (!inputs.storePrune) {
console.log('Store pruning is disabled, skipping pnpm store prune.')
return return
} }