mirror of
https://github.com/pnpm/action-setup.git
synced 2026-03-07 08:21:45 +08:00
Merge 35353b8037 into 3a0024f066
This commit is contained in:
commit
8a1f0929f7
6
.github/workflows/test.yaml
vendored
6
.github/workflows/test.yaml
vendored
@ -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 }}
|
||||||
|
|
||||||
@ -158,6 +158,9 @@ jobs:
|
|||||||
- --global-dir=./pnpm-global
|
- --global-dir=./pnpm-global
|
||||||
- npm
|
- npm
|
||||||
- yarn
|
- yarn
|
||||||
|
store_prune:
|
||||||
|
- 'true'
|
||||||
|
- 'false'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -167,6 +170,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: 9.15.5
|
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
|
||||||
|
|||||||
11
README.md
11
README.md
@ -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`.
|
||||||
@ -42,6 +44,10 @@ If `run_install` is a YAML string representation of either an object or an array
|
|||||||
|
|
||||||
**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--ignore-scripts, --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`/[`package.yaml`](https://github.com/pnpm/pnpm/pull/1799) 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.
|
||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -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
|
|
||||||
|
|||||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -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 => {
|
||||||
|
|||||||
@ -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'),
|
||||||
})
|
})
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user