Add run_install input

This commit is contained in:
khai96_ 2020-05-09 19:13:46 +07:00
parent 4b13327683
commit d44b8c5e53
6 changed files with 66 additions and 0 deletions

View File

@ -20,6 +20,10 @@ Install PNPM package manager.
**Optional** Registry to download PNPM from. **Optional** Registry to download PNPM from.
### `run_install`
**Optional** If specified, run `pnpm install`.
## Outputs ## Outputs
### `dest` ### `dest`

View File

@ -19,6 +19,10 @@ inputs:
description: Registry to download PNPM from description: Registry to download PNPM from
required: false required: false
default: https://registry.npmjs.com default: https://registry.npmjs.com
run_install:
description: If specified, run `pnpm install`
required: false
default: 'null'
runs: runs:
using: node12 using: node12
main: dist/index.js main: dist/index.js

BIN
dist/index.js vendored

Binary file not shown.

View File

@ -8,9 +8,11 @@
"dependencies": { "dependencies": {
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"expand-tilde": "^2.0.2", "expand-tilde": "^2.0.2",
"js-yaml": "^3.13.1",
"@actions/core": "^1.2.4", "@actions/core": "^1.2.4",
"@types/expand-tilde": "^2.0.0", "@types/expand-tilde": "^2.0.0",
"@types/node-fetch": "^2.5.7", "@types/node-fetch": "^2.5.7",
"@types/js-yaml": "^3.12.3",
"@types/node": "^13.13.5" "@types/node": "^13.13.5"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,9 +1,11 @@
dependencies: dependencies:
'@actions/core': 1.2.4 '@actions/core': 1.2.4
'@types/expand-tilde': 2.0.0 '@types/expand-tilde': 2.0.0
'@types/js-yaml': 3.12.3
'@types/node': 13.13.5 '@types/node': 13.13.5
'@types/node-fetch': 2.5.7 '@types/node-fetch': 2.5.7
expand-tilde: 2.0.2 expand-tilde: 2.0.2
js-yaml: 3.13.1
node-fetch: 2.6.0 node-fetch: 2.6.0
devDependencies: devDependencies:
'@zeit/ncc': 0.22.1 '@zeit/ncc': 0.22.1
@ -18,6 +20,10 @@ packages:
dev: false dev: false
resolution: resolution:
integrity: sha512-17h/6MRHoetV2QVUVnUfrmaFCXNIFJ3uDJmXlklX2xDtlEb1W0OXLgP+qwND2Ibg/PtQfQi0vx19KGuPayjLiw== integrity: sha512-17h/6MRHoetV2QVUVnUfrmaFCXNIFJ3uDJmXlklX2xDtlEb1W0OXLgP+qwND2Ibg/PtQfQi0vx19KGuPayjLiw==
/@types/js-yaml/3.12.3:
dev: false
resolution:
integrity: sha512-otRe77JNNWzoVGLKw8TCspKswRoQToys4tuL6XYVBFxjgeM0RUrx7m3jkaTdxILxeGry3zM8mGYkGXMeQ02guA==
/@types/node-fetch/2.5.7: /@types/node-fetch/2.5.7:
dependencies: dependencies:
'@types/node': 13.13.5 '@types/node': 13.13.5
@ -34,6 +40,12 @@ packages:
hasBin: true hasBin: true
resolution: resolution:
integrity: sha512-Qq3bMuonkcnV/96jhy9SQYdh39NXHxNMJ1O31ZFzWG9n52fR2DLtgrNzhj/ahlEjnBziMLGVWDbaS9sf03/fEw== integrity: sha512-Qq3bMuonkcnV/96jhy9SQYdh39NXHxNMJ1O31ZFzWG9n52fR2DLtgrNzhj/ahlEjnBziMLGVWDbaS9sf03/fEw==
/argparse/1.0.10:
dependencies:
sprintf-js: 1.0.3
dev: false
resolution:
integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
/asynckit/0.4.0: /asynckit/0.4.0:
dev: false dev: false
resolution: resolution:
@ -52,6 +64,13 @@ packages:
node: '>=0.4.0' node: '>=0.4.0'
resolution: resolution:
integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk= integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=
/esprima/4.0.1:
dev: false
engines:
node: '>=4'
hasBin: true
resolution:
integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
/expand-tilde/2.0.2: /expand-tilde/2.0.2:
dependencies: dependencies:
homedir-polyfill: 1.0.3 homedir-polyfill: 1.0.3
@ -78,6 +97,14 @@ packages:
node: '>=0.10.0' node: '>=0.10.0'
resolution: resolution:
integrity: sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA== integrity: sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==
/js-yaml/3.13.1:
dependencies:
argparse: 1.0.10
esprima: 4.0.1
dev: false
hasBin: true
resolution:
integrity: sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
/mime-db/1.44.0: /mime-db/1.44.0:
dev: false dev: false
engines: engines:
@ -104,6 +131,10 @@ packages:
node: '>=0.10.0' node: '>=0.10.0'
resolution: resolution:
integrity: sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= integrity: sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=
/sprintf-js/1.0.3:
dev: false
resolution:
integrity: sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
/typescript/3.8.3: /typescript/3.8.3:
dev: true dev: true
engines: engines:
@ -114,9 +145,11 @@ packages:
specifiers: specifiers:
'@actions/core': ^1.2.4 '@actions/core': ^1.2.4
'@types/expand-tilde': ^2.0.0 '@types/expand-tilde': ^2.0.0
'@types/js-yaml': ^3.12.3
'@types/node': ^13.13.5 '@types/node': ^13.13.5
'@types/node-fetch': ^2.5.7 '@types/node-fetch': ^2.5.7
'@zeit/ncc': ^0.22.1 '@zeit/ncc': ^0.22.1
expand-tilde: ^2.0.2 expand-tilde: ^2.0.2
js-yaml: ^3.13.1
node-fetch: ^2.6.0 node-fetch: ^2.6.0
typescript: ^3.8.3 typescript: ^3.8.3

View File

@ -1,11 +1,25 @@
import { getInput, InputOptions } from '@actions/core' import { getInput, InputOptions } from '@actions/core'
import expandTilde from 'expand-tilde' import expandTilde from 'expand-tilde'
import { safeLoad } from 'js-yaml'
interface RunInstall {
readonly recursive?: boolean
readonly cwd?: string
readonly args?: readonly string[]
}
type RunInstallInput =
| null
| boolean
| RunInstall
| RunInstall[]
export interface Inputs { export interface Inputs {
readonly version: string readonly version: string
readonly dest: string readonly dest: string
readonly binDest: string readonly binDest: string
readonly registry: string readonly registry: string
readonly runInstall: RunInstall[]
} }
const options: InputOptions = { const options: InputOptions = {
@ -14,11 +28,20 @@ const options: InputOptions = {
const parseInputPath = (name: string) => expandTilde(getInput(name, options)) const parseInputPath = (name: string) => expandTilde(getInput(name, options))
function parseRunInstall(name: string): RunInstall[] {
const result: RunInstallInput = safeLoad(getInput(name, options))
if (!result) return []
if (result === true) return [{ recursive: true }]
if (Array.isArray(result)) return result
return [result]
}
export const getInputs = (): Inputs => ({ export const getInputs = (): Inputs => ({
version: getInput('version', options), version: getInput('version', options),
dest: parseInputPath('dest'), dest: parseInputPath('dest'),
binDest: parseInputPath('bin_dest'), binDest: parseInputPath('bin_dest'),
registry: getInput('registry', options), registry: getInput('registry', options),
runInstall: parseRunInstall('run_install'),
}) })
export default getInputs export default getInputs