mirror of
https://github.com/pnpm/action-setup.git
synced 2025-07-08 01:09:35 +08:00
Compare commits
18 Commits
inspect-is
...
v1.2.1
Author | SHA1 | Date | |
---|---|---|---|
8e1abe543f | |||
af6247d08a | |||
f87c8a916e | |||
d6790970e0 | |||
fa62771e12 | |||
935101478d | |||
4abca36d2a | |||
56013f801f | |||
fb99aeb8e3 | |||
b78eaea668 | |||
83681c63a7 | |||
6eb237a86d | |||
b1febf84ed | |||
2546768411 | |||
8cdddb18c5 | |||
4457a83971 | |||
c8fc1974e1 | |||
291e58ad85 |
57
.github/workflows/test.yaml
vendored
57
.github/workflows/test.yaml
vendored
@ -3,6 +3,7 @@ name: Test Action
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
- workflow_dispatch
|
||||
|
||||
jobs:
|
||||
test_default_inputs:
|
||||
@ -65,3 +66,59 @@ jobs:
|
||||
|
||||
- name: 'Test: install'
|
||||
run: pnpm install
|
||||
|
||||
test_run_install:
|
||||
name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
pnpm:
|
||||
- 4.11.1
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
run_install:
|
||||
- name: 'null'
|
||||
value: 'null'
|
||||
- name: 'empty object'
|
||||
value: '{}'
|
||||
- name: 'recursive'
|
||||
value: |
|
||||
recursive: true
|
||||
- name: 'global'
|
||||
value: |
|
||||
args:
|
||||
- --global
|
||||
- --global-dir=./pnpm-global
|
||||
- npm
|
||||
- yarn
|
||||
- pnpm
|
||||
- name: 'array'
|
||||
value: |
|
||||
- {}
|
||||
- recursive: true
|
||||
- args:
|
||||
- --global
|
||||
- --global-dir=./pnpm-global
|
||||
- npm
|
||||
- yarn
|
||||
- pnpm
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Run the action
|
||||
uses: ./
|
||||
with:
|
||||
version: 4.11.1
|
||||
run_install: ${{ matrix.run_install.value }}
|
||||
|
||||
- name: 'Test: which'
|
||||
run: which pnpm; which pnpx
|
||||
|
||||
- name: 'Test: install'
|
||||
run: pnpm install
|
||||
|
49
README.md
49
README.md
@ -18,11 +18,29 @@ Install PNPM package manager.
|
||||
|
||||
### `registry`
|
||||
|
||||
**Optional** Registry to download PNPM from.
|
||||
**Optional** (_default:_ `https://registry.npmjs.com`) Registry to download PNPM from.
|
||||
|
||||
### `run_install`
|
||||
|
||||
**Optional** If specified, run `pnpm install`.
|
||||
**Optional** (_default:_ `null`) If specified, run `pnpm install`.
|
||||
|
||||
If `run_install` is either `null` or `false`, pnpm will not install any npm package.
|
||||
|
||||
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.
|
||||
|
||||
#### `run_install.recursive`
|
||||
|
||||
**Optional** (_type:_ `boolean`, _default:_ `false`) Whether to use `pnpm recursive install`.
|
||||
|
||||
#### `run_install.cwd`
|
||||
|
||||
**Optional** (_type:_ `string`) Working directory when run `pnpm [recursive] install`.
|
||||
|
||||
#### `run_install.args`
|
||||
|
||||
**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--frozen-lockfile, --strict-peer-dependencies]`.
|
||||
|
||||
## Outputs
|
||||
|
||||
@ -36,6 +54,24 @@ Expanded path of inputs#bin_dest.
|
||||
|
||||
## Usage example
|
||||
|
||||
### Just install PNPM
|
||||
|
||||
```yaml
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: pnpm/action-setup@v1.2.0
|
||||
with:
|
||||
version: 4.11.1
|
||||
```
|
||||
|
||||
### Install PNPM and a few NPM packages
|
||||
|
||||
```yaml
|
||||
on:
|
||||
- push
|
||||
@ -47,12 +83,13 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: pnpm/action-setup@v1.1.0
|
||||
- uses: pnpm/action-setup@v1.2.0
|
||||
with:
|
||||
version: 4.11.1
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
run_install: |
|
||||
- recursive: true
|
||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||
- args: [--global, gulp, prettier, typescript]
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
@ -26,3 +26,4 @@ inputs:
|
||||
runs:
|
||||
using: node12
|
||||
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
16
package.json
16
package.json
@ -7,19 +7,19 @@
|
||||
"start": "pnpm run build && sh ./run.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.6.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"expand-tilde": "^2.0.2",
|
||||
"js-yaml": "^3.13.1",
|
||||
"ajv": "^6.12.0",
|
||||
"@actions/core": "^1.2.4",
|
||||
"js-yaml": "^3.14.0",
|
||||
"ajv": "^6.12.5",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@types/expand-tilde": "^2.0.0",
|
||||
"@types/node-fetch": "^2.5.7",
|
||||
"@types/js-yaml": "^3.12.3",
|
||||
"@types/node": "^13.13.5"
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"@types/node": "^14.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^3.8.3",
|
||||
"typescript": "^4.0.3",
|
||||
"@ts-schema-autogen/cli": "^0.1.2",
|
||||
"@zeit/ncc": "^0.22.1"
|
||||
"@zeit/ncc": "^0.22.3"
|
||||
}
|
||||
}
|
||||
|
80
pnpm-lock.yaml
generated
80
pnpm-lock.yaml
generated
@ -1,23 +1,23 @@
|
||||
dependencies:
|
||||
'@actions/core': 1.2.4
|
||||
'@actions/core': 1.2.6
|
||||
'@types/expand-tilde': 2.0.0
|
||||
'@types/js-yaml': 3.12.3
|
||||
'@types/node': 13.13.5
|
||||
'@types/js-yaml': 3.12.5
|
||||
'@types/node': 14.11.2
|
||||
'@types/node-fetch': 2.5.7
|
||||
ajv: 6.12.0
|
||||
ajv: 6.12.5
|
||||
expand-tilde: 2.0.2
|
||||
js-yaml: 3.13.1
|
||||
node-fetch: 2.6.0
|
||||
js-yaml: 3.14.0
|
||||
node-fetch: 2.6.1
|
||||
devDependencies:
|
||||
'@ts-schema-autogen/cli': 0.1.2
|
||||
'@zeit/ncc': 0.22.1
|
||||
typescript: 3.8.3
|
||||
'@zeit/ncc': 0.22.3
|
||||
typescript: 4.0.3
|
||||
lockfileVersion: 5.1
|
||||
packages:
|
||||
/@actions/core/1.2.4:
|
||||
/@actions/core/1.2.6:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg==
|
||||
integrity: sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
|
||||
/@ts-schema-autogen/cli/0.1.2:
|
||||
dependencies:
|
||||
'@ts-schema-autogen/main': 0.1.1
|
||||
@ -176,8 +176,13 @@ packages:
|
||||
resolution:
|
||||
integrity: sha512-UoOfVEzAUpeSPmjm7h1uk5MH6KZma2z2O7a75onTGjnNvAvMVrPzPL/vBbT65iIGHWj6rokwfmYcmxmlSf2uwg==
|
||||
/@types/js-yaml/3.12.3:
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha512-otRe77JNNWzoVGLKw8TCspKswRoQToys4tuL6XYVBFxjgeM0RUrx7m3jkaTdxILxeGry3zM8mGYkGXMeQ02guA==
|
||||
/@types/js-yaml/3.12.5:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-JCcp6J0GV66Y4ZMDAQCXot4xprYB+Zfd3meK9+INSJeVZwJmHAW30BBEEkPzXswMXuiyReUGOP3GxrADc9wPww==
|
||||
/@types/json-schema/7.0.4:
|
||||
dev: true
|
||||
resolution:
|
||||
@ -192,6 +197,10 @@ packages:
|
||||
/@types/node/13.13.5:
|
||||
resolution:
|
||||
integrity: sha512-3ySmiBYJPqgjiHA7oEaIo2Rzz0HrOZ7yrNO5HWyaE5q0lQ3BppDZ3N53Miz8bw2I7gh1/zir2MGVZBvpb1zq9g==
|
||||
/@types/node/14.11.2:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==
|
||||
/@types/yargs-parser/15.0.0:
|
||||
dev: true
|
||||
resolution:
|
||||
@ -202,19 +211,30 @@ packages:
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==
|
||||
/@zeit/ncc/0.22.1:
|
||||
/@zeit/ncc/0.22.3:
|
||||
deprecated: '@zeit/ncc is no longer maintained. Please use @vercel/ncc instead.'
|
||||
dev: true
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-Qq3bMuonkcnV/96jhy9SQYdh39NXHxNMJ1O31ZFzWG9n52fR2DLtgrNzhj/ahlEjnBziMLGVWDbaS9sf03/fEw==
|
||||
integrity: sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==
|
||||
/ajv/6.12.0:
|
||||
dependencies:
|
||||
fast-deep-equal: 3.1.1
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
json-schema-traverse: 0.4.1
|
||||
uri-js: 4.2.2
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==
|
||||
/ajv/6.12.5:
|
||||
dependencies:
|
||||
fast-deep-equal: 3.1.1
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
json-schema-traverse: 0.4.1
|
||||
uri-js: 4.2.2
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==
|
||||
/ansi-regex/4.1.0:
|
||||
dev: true
|
||||
engines:
|
||||
@ -478,9 +498,18 @@ packages:
|
||||
dependencies:
|
||||
argparse: 1.0.10
|
||||
esprima: 4.0.1
|
||||
dev: true
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
|
||||
/js-yaml/3.14.0:
|
||||
dependencies:
|
||||
argparse: 1.0.10
|
||||
esprima: 4.0.1
|
||||
dev: false
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==
|
||||
/json-schema-traverse/0.4.1:
|
||||
resolution:
|
||||
integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
|
||||
@ -537,12 +566,12 @@ packages:
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
||||
/node-fetch/2.6.0:
|
||||
/node-fetch/2.6.1:
|
||||
dev: false
|
||||
engines:
|
||||
node: 4.x || >=6.0.0
|
||||
resolution:
|
||||
integrity: sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
|
||||
integrity: sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
|
||||
/once/1.4.0:
|
||||
dependencies:
|
||||
wrappy: 1.0.2
|
||||
@ -683,6 +712,13 @@ packages:
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
|
||||
/typescript/4.0.3:
|
||||
dev: true
|
||||
engines:
|
||||
node: '>=4.2.0'
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==
|
||||
/universalify/0.1.2:
|
||||
dev: true
|
||||
engines:
|
||||
@ -783,15 +819,15 @@ packages:
|
||||
resolution:
|
||||
integrity: sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==
|
||||
specifiers:
|
||||
'@actions/core': ^1.2.4
|
||||
'@actions/core': ^1.2.6
|
||||
'@ts-schema-autogen/cli': ^0.1.2
|
||||
'@types/expand-tilde': ^2.0.0
|
||||
'@types/js-yaml': ^3.12.3
|
||||
'@types/node': ^13.13.5
|
||||
'@types/js-yaml': ^3.12.5
|
||||
'@types/node': ^14.11.2
|
||||
'@types/node-fetch': ^2.5.7
|
||||
'@zeit/ncc': ^0.22.1
|
||||
ajv: ^6.12.0
|
||||
'@zeit/ncc': ^0.22.3
|
||||
ajv: ^6.12.5
|
||||
expand-tilde: ^2.0.2
|
||||
js-yaml: ^3.13.1
|
||||
node-fetch: ^2.6.0
|
||||
typescript: ^3.8.3
|
||||
js-yaml: ^3.14.0
|
||||
node-fetch: ^2.6.1
|
||||
typescript: ^4.0.3
|
||||
|
@ -1,11 +1,15 @@
|
||||
import { setFailed } from '@actions/core'
|
||||
import { setFailed, saveState, getState } from '@actions/core'
|
||||
import getInputs from './inputs'
|
||||
import setOutputs from './outputs'
|
||||
import installPnpm from './install-pnpm'
|
||||
import pnpmInstall from './pnpm-install'
|
||||
import pruneStore from './pnpm-store-prune'
|
||||
|
||||
async function main() {
|
||||
const inputs = getInputs()
|
||||
const isPost = getState('is_post')
|
||||
if (isPost === 'true') return pruneStore(inputs)
|
||||
saveState('is_post', 'true')
|
||||
await installPnpm(inputs)
|
||||
console.log('Installation Completed!')
|
||||
setOutputs(inputs)
|
||||
|
@ -21,7 +21,7 @@ const options: InputOptions = {
|
||||
}
|
||||
|
||||
export function parseRunInstall(name: string): RunInstall[] {
|
||||
const result: RunInstallInput = safeLoad(getInput(name, options))
|
||||
const result: RunInstallInput = safeLoad(getInput(name, options)) as any
|
||||
const ajv = new Ajv({
|
||||
allErrors: true,
|
||||
async: false,
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { setFailed } from '@actions/core'
|
||||
import { setFailed, startGroup, endGroup } from '@actions/core'
|
||||
import { Inputs } from '../inputs'
|
||||
import runSelfInstaller from './run'
|
||||
|
||||
export { runSelfInstaller }
|
||||
|
||||
export async function install(inputs: Inputs) {
|
||||
startGroup('Running self-installer...')
|
||||
const status = await runSelfInstaller(inputs)
|
||||
endGroup()
|
||||
if (status) {
|
||||
return setFailed(`Something does wrong, self-installer exits with code ${status}`)
|
||||
}
|
||||
|
@ -1,14 +1,10 @@
|
||||
import process from 'process'
|
||||
import path from 'path'
|
||||
import { spawnSync } from 'child_process'
|
||||
import { setFailed } from '@actions/core'
|
||||
import { setFailed, startGroup, endGroup } from '@actions/core'
|
||||
import { Inputs } from '../inputs'
|
||||
import { patchPnpmEnv } from '../utils'
|
||||
|
||||
export function runPnpmInstall(inputs: Inputs) {
|
||||
const env = {
|
||||
...process.env,
|
||||
PATH: inputs.binDest + path.delimiter + process.env.PATH
|
||||
}
|
||||
const env = patchPnpmEnv(inputs)
|
||||
|
||||
for (const options of inputs.runInstall) {
|
||||
const args = ['install']
|
||||
@ -16,7 +12,7 @@ export function runPnpmInstall(inputs: Inputs) {
|
||||
if (options.args) args.push(...options.args)
|
||||
|
||||
const cmdStr = ['pnpm', ...args].join(' ')
|
||||
console.log('Running', cmdStr)
|
||||
startGroup(`Running ${cmdStr}...`)
|
||||
|
||||
const { error, status } = spawnSync('pnpm', args, {
|
||||
stdio: 'inherit',
|
||||
@ -25,6 +21,8 @@ export function runPnpmInstall(inputs: Inputs) {
|
||||
env,
|
||||
})
|
||||
|
||||
endGroup()
|
||||
|
||||
if (error) {
|
||||
setFailed(error)
|
||||
continue
|
||||
|
31
src/pnpm-store-prune/index.ts
Normal file
31
src/pnpm-store-prune/index.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { spawnSync } from 'child_process'
|
||||
import { warning, startGroup, endGroup } from '@actions/core'
|
||||
import { Inputs } from '../inputs'
|
||||
import { patchPnpmEnv } from '../utils'
|
||||
|
||||
export function pruneStore(inputs: Inputs) {
|
||||
if (inputs.runInstall.length === 0) {
|
||||
console.log('Pruning is unnecessary.')
|
||||
return
|
||||
}
|
||||
|
||||
startGroup('Running pnpm store prune...')
|
||||
const { error, status } = spawnSync('pnpm', ['store', 'prune'], {
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
env: patchPnpmEnv(inputs)
|
||||
})
|
||||
endGroup()
|
||||
|
||||
if (error) {
|
||||
warning(error)
|
||||
return
|
||||
}
|
||||
|
||||
if (status) {
|
||||
warning(`command pnpm store prune exits with code ${status}`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
export default pruneStore
|
8
src/utils/index.ts
Normal file
8
src/utils/index.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import process from 'process'
|
||||
import path from 'path'
|
||||
import { Inputs } from '../inputs'
|
||||
|
||||
export const patchPnpmEnv = (inputs: Inputs): NodeJS.ProcessEnv => ({
|
||||
...process.env,
|
||||
PATH: inputs.binDest + path.delimiter + process.env.PATH
|
||||
})
|
Reference in New Issue
Block a user