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
|
||||
required: false
|
||||
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:
|
||||
description: If specified, run `pnpm install`
|
||||
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",
|
||||
"js-yaml": "^4.0.0",
|
||||
"ajv": "^6.12.5",
|
||||
"fs-extra": "^9.1.0",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@types/expand-tilde": "^2.0.0",
|
||||
"@types/node-fetch": "^2.5.8",
|
||||
"@types/js-yaml": "^4.0.0",
|
||||
"@types/fs-extra": "^9.0.8",
|
||||
"@types/node": "^14.14.35"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,11 +1,13 @@
|
||||
dependencies:
|
||||
'@actions/core': 1.2.6
|
||||
'@types/expand-tilde': 2.0.0
|
||||
'@types/fs-extra': 9.0.8
|
||||
'@types/js-yaml': 4.0.0
|
||||
'@types/node': 14.14.35
|
||||
'@types/node-fetch': 2.5.8
|
||||
ajv: 6.12.6
|
||||
expand-tilde: 2.0.2
|
||||
fs-extra: 9.1.0
|
||||
js-yaml: 4.0.0
|
||||
node-fetch: 2.6.1
|
||||
devDependencies:
|
||||
@ -175,6 +177,12 @@ packages:
|
||||
dev: true
|
||||
resolution:
|
||||
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:
|
||||
dev: true
|
||||
resolution:
|
||||
@ -278,6 +286,12 @@ packages:
|
||||
dev: false
|
||||
resolution:
|
||||
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:
|
||||
dev: true
|
||||
resolution:
|
||||
@ -444,6 +458,17 @@ packages:
|
||||
node: '>=6 <7 || >=8'
|
||||
resolution:
|
||||
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:
|
||||
dev: true
|
||||
resolution:
|
||||
@ -466,7 +491,6 @@ packages:
|
||||
resolution:
|
||||
integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
|
||||
/graceful-fs/4.2.3:
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
|
||||
/homedir-polyfill/1.0.3:
|
||||
@ -530,6 +554,14 @@ packages:
|
||||
graceful-fs: 4.2.3
|
||||
resolution:
|
||||
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:
|
||||
dev: true
|
||||
resolution:
|
||||
@ -731,6 +763,12 @@ packages:
|
||||
node: '>= 4.0.0'
|
||||
resolution:
|
||||
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:
|
||||
dependencies:
|
||||
punycode: 2.1.1
|
||||
@ -828,12 +866,14 @@ specifiers:
|
||||
'@actions/core': ^1.2.6
|
||||
'@ts-schema-autogen/cli': ^0.1.2
|
||||
'@types/expand-tilde': ^2.0.0
|
||||
'@types/fs-extra': ^9.0.8
|
||||
'@types/js-yaml': ^4.0.0
|
||||
'@types/node': ^14.14.35
|
||||
'@types/node-fetch': ^2.5.8
|
||||
'@vercel/ncc': ^0.27.0
|
||||
ajv: ^6.12.5
|
||||
expand-tilde: ^2.0.2
|
||||
fs-extra: ^9.1.0
|
||||
js-yaml: ^4.0.0
|
||||
node-fetch: ^2.6.1
|
||||
typescript: ^4.2.3
|
||||
|
2
run.sh
2
run.sh
@ -3,7 +3,5 @@
|
||||
export HOME="$(pwd)"
|
||||
export INPUT_VERSION=4.11.1
|
||||
export INPUT_DEST='~/pnpm.temp'
|
||||
export INPUT_BIN_DEST='~/pnpm.temp/.bin'
|
||||
export INPUT_REGISTRY=https://registry.npmjs.com
|
||||
export INPUT_RUN_INSTALL=null
|
||||
exec node dist/index.js
|
||||
|
@ -5,8 +5,6 @@ import { RunInstall, parseRunInstall } from './run-install'
|
||||
export interface Inputs {
|
||||
readonly version: string
|
||||
readonly dest: string
|
||||
readonly binDest: string
|
||||
readonly registry: string
|
||||
readonly runInstall: RunInstall[]
|
||||
}
|
||||
|
||||
@ -19,8 +17,6 @@ const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
||||
export const getInputs = (): Inputs => ({
|
||||
version: getInput('version', options),
|
||||
dest: parseInputPath('dest'),
|
||||
binDest: parseInputPath('bin_dest'),
|
||||
registry: getInput('registry', options),
|
||||
runInstall: parseRunInstall('run_install'),
|
||||
})
|
||||
|
||||
|
@ -1,20 +1,24 @@
|
||||
import { spawn } from 'child_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'
|
||||
|
||||
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||
const cp = spawn(execPath, {
|
||||
env: {
|
||||
PNPM_VERSION: inputs.version,
|
||||
PNPM_DEST: inputs.dest,
|
||||
PNPM_BIN_DEST: inputs.binDest,
|
||||
PNPM_REGISTRY: inputs.registry,
|
||||
},
|
||||
const { version, dest } = inputs
|
||||
const target = version ? `pnpm@${version}` : 'pnpm'
|
||||
const pkgJson = join(dest, 'package.json')
|
||||
|
||||
await remove(dest)
|
||||
await ensureFile(pkgJson)
|
||||
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
||||
|
||||
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
|
||||
stdio: ['pipe', 'inherit', 'inherit'],
|
||||
})
|
||||
|
||||
const response = await downloadSelfInstaller()
|
||||
const response = await fetch('https://pnpm.js.org/pnpm.js')
|
||||
response.body.pipe(cp.stdin)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { setOutput, addPath } from '@actions/core'
|
||||
import { Inputs } from '../inputs'
|
||||
import { getBinDest } from '../utils'
|
||||
|
||||
export function setOutputs(inputs: Inputs) {
|
||||
addPath(inputs.binDest)
|
||||
const binDest = getBinDest(inputs)
|
||||
addPath(binDest)
|
||||
setOutput('dest', inputs.dest)
|
||||
setOutput('bin_dest', inputs.binDest)
|
||||
setOutput('bin_dest', binDest)
|
||||
}
|
||||
|
||||
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 { Inputs } from '../inputs'
|
||||
|
||||
export const getBinDest = (inputs: Inputs): string => path.join(inputs.dest, 'node_modules', '.bin')
|
||||
|
||||
export const patchPnpmEnv = (inputs: Inputs): NodeJS.ProcessEnv => ({
|
||||
...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