mirror of
https://github.com/pnpm/action-setup.git
synced 2024-11-10 09:39:11 +08:00
Use pnpm.js to install pnpm
This commit is contained in:
parent
b7b9d6344b
commit
aefcd1e623
@ -11,14 +11,6 @@ inputs:
|
|||||||
description: Where to store PNPM files
|
description: Where to store PNPM files
|
||||||
required: false
|
required: false
|
||||||
default: ~/setup-pnpm
|
default: ~/setup-pnpm
|
||||||
bin_dest:
|
|
||||||
description: Where to store executables (pnpm and pnpx commands)
|
|
||||||
required: false
|
|
||||||
default: ~/setup-pnpm/.bin
|
|
||||||
registry:
|
|
||||||
description: Registry to download PNPM from
|
|
||||||
required: false
|
|
||||||
default: https://registry.npmjs.com
|
|
||||||
run_install:
|
run_install:
|
||||||
description: If specified, run `pnpm install`
|
description: If specified, run `pnpm install`
|
||||||
required: false
|
required: false
|
||||||
|
BIN
dist/index.js
vendored
BIN
dist/index.js
vendored
Binary file not shown.
@ -11,10 +11,12 @@
|
|||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
"js-yaml": "^4.0.0",
|
"js-yaml": "^4.0.0",
|
||||||
"ajv": "^6.12.5",
|
"ajv": "^6.12.5",
|
||||||
|
"fs-extra": "^9.1.0",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@types/expand-tilde": "^2.0.0",
|
"@types/expand-tilde": "^2.0.0",
|
||||||
"@types/node-fetch": "^2.5.8",
|
"@types/node-fetch": "^2.5.8",
|
||||||
"@types/js-yaml": "^4.0.0",
|
"@types/js-yaml": "^4.0.0",
|
||||||
|
"@types/fs-extra": "^9.0.8",
|
||||||
"@types/node": "^14.14.35"
|
"@types/node": "^14.14.35"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@actions/core': 1.2.6
|
'@actions/core': 1.2.6
|
||||||
'@types/expand-tilde': 2.0.0
|
'@types/expand-tilde': 2.0.0
|
||||||
|
'@types/fs-extra': 9.0.8
|
||||||
'@types/js-yaml': 4.0.0
|
'@types/js-yaml': 4.0.0
|
||||||
'@types/node': 14.14.35
|
'@types/node': 14.14.35
|
||||||
'@types/node-fetch': 2.5.8
|
'@types/node-fetch': 2.5.8
|
||||||
ajv: 6.12.6
|
ajv: 6.12.6
|
||||||
expand-tilde: 2.0.2
|
expand-tilde: 2.0.2
|
||||||
|
fs-extra: 9.1.0
|
||||||
js-yaml: 4.0.0
|
js-yaml: 4.0.0
|
||||||
node-fetch: 2.6.1
|
node-fetch: 2.6.1
|
||||||
devDependencies:
|
devDependencies:
|
||||||
@ -175,6 +177,12 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-UoOfVEzAUpeSPmjm7h1uk5MH6KZma2z2O7a75onTGjnNvAvMVrPzPL/vBbT65iIGHWj6rokwfmYcmxmlSf2uwg==
|
integrity: sha512-UoOfVEzAUpeSPmjm7h1uk5MH6KZma2z2O7a75onTGjnNvAvMVrPzPL/vBbT65iIGHWj6rokwfmYcmxmlSf2uwg==
|
||||||
|
/@types/fs-extra/9.0.8:
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 14.14.35
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-bnlTVTwq03Na7DpWxFJ1dvnORob+Otb8xHyUqUWhqvz/Ksg8+JXPlR52oeMSZ37YEOa5PyccbgUNutiQdi13TA==
|
||||||
/@types/js-yaml/3.12.3:
|
/@types/js-yaml/3.12.3:
|
||||||
dev: true
|
dev: true
|
||||||
resolution:
|
resolution:
|
||||||
@ -278,6 +286,12 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=
|
integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=
|
||||||
|
/at-least-node/1.0.0:
|
||||||
|
dev: false
|
||||||
|
engines:
|
||||||
|
node: '>= 4.0.0'
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
|
||||||
/balanced-match/1.0.0:
|
/balanced-match/1.0.0:
|
||||||
dev: true
|
dev: true
|
||||||
resolution:
|
resolution:
|
||||||
@ -444,6 +458,17 @@ packages:
|
|||||||
node: '>=6 <7 || >=8'
|
node: '>=6 <7 || >=8'
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
|
integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
|
||||||
|
/fs-extra/9.1.0:
|
||||||
|
dependencies:
|
||||||
|
at-least-node: 1.0.0
|
||||||
|
graceful-fs: 4.2.3
|
||||||
|
jsonfile: 6.1.0
|
||||||
|
universalify: 2.0.0
|
||||||
|
dev: false
|
||||||
|
engines:
|
||||||
|
node: '>=10'
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
|
||||||
/fs.realpath/1.0.0:
|
/fs.realpath/1.0.0:
|
||||||
dev: true
|
dev: true
|
||||||
resolution:
|
resolution:
|
||||||
@ -466,7 +491,6 @@ packages:
|
|||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
|
integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
|
||||||
/graceful-fs/4.2.3:
|
/graceful-fs/4.2.3:
|
||||||
dev: true
|
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
|
integrity: sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
|
||||||
/homedir-polyfill/1.0.3:
|
/homedir-polyfill/1.0.3:
|
||||||
@ -530,6 +554,14 @@ packages:
|
|||||||
graceful-fs: 4.2.3
|
graceful-fs: 4.2.3
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
|
integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
|
||||||
|
/jsonfile/6.1.0:
|
||||||
|
dependencies:
|
||||||
|
universalify: 2.0.0
|
||||||
|
dev: false
|
||||||
|
optionalDependencies:
|
||||||
|
graceful-fs: 4.2.3
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
|
||||||
/jsonify/0.0.0:
|
/jsonify/0.0.0:
|
||||||
dev: true
|
dev: true
|
||||||
resolution:
|
resolution:
|
||||||
@ -731,6 +763,12 @@ packages:
|
|||||||
node: '>= 4.0.0'
|
node: '>= 4.0.0'
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||||
|
/universalify/2.0.0:
|
||||||
|
dev: false
|
||||||
|
engines:
|
||||||
|
node: '>= 10.0.0'
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
|
||||||
/uri-js/4.2.2:
|
/uri-js/4.2.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
punycode: 2.1.1
|
punycode: 2.1.1
|
||||||
@ -828,12 +866,14 @@ specifiers:
|
|||||||
'@actions/core': ^1.2.6
|
'@actions/core': ^1.2.6
|
||||||
'@ts-schema-autogen/cli': ^0.1.2
|
'@ts-schema-autogen/cli': ^0.1.2
|
||||||
'@types/expand-tilde': ^2.0.0
|
'@types/expand-tilde': ^2.0.0
|
||||||
|
'@types/fs-extra': ^9.0.8
|
||||||
'@types/js-yaml': ^4.0.0
|
'@types/js-yaml': ^4.0.0
|
||||||
'@types/node': ^14.14.35
|
'@types/node': ^14.14.35
|
||||||
'@types/node-fetch': ^2.5.8
|
'@types/node-fetch': ^2.5.8
|
||||||
'@vercel/ncc': ^0.27.0
|
'@vercel/ncc': ^0.27.0
|
||||||
ajv: ^6.12.5
|
ajv: ^6.12.5
|
||||||
expand-tilde: ^2.0.2
|
expand-tilde: ^2.0.2
|
||||||
|
fs-extra: ^9.1.0
|
||||||
js-yaml: ^4.0.0
|
js-yaml: ^4.0.0
|
||||||
node-fetch: ^2.6.1
|
node-fetch: ^2.6.1
|
||||||
typescript: ^4.2.3
|
typescript: ^4.2.3
|
||||||
|
2
run.sh
2
run.sh
@ -3,7 +3,5 @@
|
|||||||
export HOME="$(pwd)"
|
export HOME="$(pwd)"
|
||||||
export INPUT_VERSION=4.11.1
|
export INPUT_VERSION=4.11.1
|
||||||
export INPUT_DEST='~/pnpm.temp'
|
export INPUT_DEST='~/pnpm.temp'
|
||||||
export INPUT_BIN_DEST='~/pnpm.temp/.bin'
|
|
||||||
export INPUT_REGISTRY=https://registry.npmjs.com
|
|
||||||
export INPUT_RUN_INSTALL=null
|
export INPUT_RUN_INSTALL=null
|
||||||
exec node dist/index.js
|
exec node dist/index.js
|
||||||
|
@ -5,8 +5,6 @@ import { RunInstall, parseRunInstall } from './run-install'
|
|||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
readonly version: string
|
readonly version: string
|
||||||
readonly dest: string
|
readonly dest: string
|
||||||
readonly binDest: string
|
|
||||||
readonly registry: string
|
|
||||||
readonly runInstall: RunInstall[]
|
readonly runInstall: RunInstall[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,8 +17,6 @@ const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
|||||||
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'),
|
|
||||||
registry: getInput('registry', options),
|
|
||||||
runInstall: parseRunInstall('run_install'),
|
runInstall: parseRunInstall('run_install'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,20 +1,24 @@
|
|||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import { execPath } from 'process'
|
import { execPath } from 'process'
|
||||||
import { downloadSelfInstaller } from '../self-installer'
|
import { join } from 'path'
|
||||||
|
import { remove, ensureFile, writeFile } from 'fs-extra'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||||
const cp = spawn(execPath, {
|
const { version, dest } = inputs
|
||||||
env: {
|
const target = version ? `pnpm@${version}` : 'pnpm'
|
||||||
PNPM_VERSION: inputs.version,
|
const pkgJson = join(dest, 'package.json')
|
||||||
PNPM_DEST: inputs.dest,
|
|
||||||
PNPM_BIN_DEST: inputs.binDest,
|
await remove(dest)
|
||||||
PNPM_REGISTRY: inputs.registry,
|
await ensureFile(pkgJson)
|
||||||
},
|
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
||||||
|
|
||||||
|
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
|
||||||
stdio: ['pipe', 'inherit', 'inherit'],
|
stdio: ['pipe', 'inherit', 'inherit'],
|
||||||
})
|
})
|
||||||
|
|
||||||
const response = await downloadSelfInstaller()
|
const response = await fetch('https://pnpm.js.org/pnpm.js')
|
||||||
response.body.pipe(cp.stdin)
|
response.body.pipe(cp.stdin)
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { setOutput, addPath } from '@actions/core'
|
import { setOutput, addPath } from '@actions/core'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
import { getBinDest } from '../utils'
|
||||||
|
|
||||||
export function setOutputs(inputs: Inputs) {
|
export function setOutputs(inputs: Inputs) {
|
||||||
addPath(inputs.binDest)
|
const binDest = getBinDest(inputs)
|
||||||
|
addPath(binDest)
|
||||||
setOutput('dest', inputs.dest)
|
setOutput('dest', inputs.dest)
|
||||||
setOutput('bin_dest', inputs.binDest)
|
setOutput('bin_dest', binDest)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default setOutputs
|
export default setOutputs
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
import fetch from 'node-fetch'
|
|
||||||
import url from './url'
|
|
||||||
export const downloadSelfInstaller = () => fetch(url)
|
|
||||||
export default downloadSelfInstaller
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from './url'
|
|
||||||
export * from './download'
|
|
@ -1,3 +0,0 @@
|
|||||||
export const ref = '301414cec74a2b6b63c95b42f2ad1790ccb980ed'
|
|
||||||
export const url = `https://raw.githubusercontent.com/pnpm/self-installer/${ref}/install.js`
|
|
||||||
export default url
|
|
@ -2,7 +2,9 @@ import process from 'process'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
|
export const getBinDest = (inputs: Inputs): string => path.join(inputs.dest, 'node_modules', '.bin')
|
||||||
|
|
||||||
export const patchPnpmEnv = (inputs: Inputs): NodeJS.ProcessEnv => ({
|
export const patchPnpmEnv = (inputs: Inputs): NodeJS.ProcessEnv => ({
|
||||||
...process.env,
|
...process.env,
|
||||||
PATH: inputs.binDest + path.delimiter + process.env.PATH
|
PATH: getBinDest(inputs) + path.delimiter + process.env.PATH
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user