mirror of
https://github.com/pnpm/action-setup.git
synced 2025-07-08 22:59:22 +08:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
10693b3829 | |||
99ecd24520 | |||
958500fcab | |||
57b9359b4c | |||
ec1a8b444c | |||
73e15250cb | |||
10b4b0b462 | |||
5fa8980bf4 | |||
ae78e9abbe | |||
35ab4267a1 | |||
11ba3424e0 | |||
847a737d63 | |||
225f3bb4b0 | |||
777a50d72e | |||
e7c10c6fc5 | |||
a576a70bc6 | |||
1d51e20937 | |||
ad2b35ae0c | |||
d8ea532ac4 |
3
.github/dependabot.yml
vendored
3
.github/dependabot.yml
vendored
@ -5,6 +5,3 @@ updates:
|
|||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
labels:
|
|
||||||
- dependabot
|
|
||||||
- github-actions
|
|
||||||
|
6
.github/workflows/test.yaml
vendored
6
.github/workflows/test.yaml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
- windows-latest
|
- windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -51,7 +51,7 @@ jobs:
|
|||||||
- windows-latest
|
- windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -107,7 +107,7 @@ jobs:
|
|||||||
- pnpm
|
- pnpm
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ node_modules
|
|||||||
*.log
|
*.log
|
||||||
/dist/*
|
/dist/*
|
||||||
!/dist/index.js
|
!/dist/index.js
|
||||||
|
!/dist/pnpm.js
|
||||||
tmp
|
tmp
|
||||||
temp
|
temp
|
||||||
*.tmp
|
*.tmp
|
||||||
|
51
README.md
51
README.md
@ -6,7 +6,11 @@ Install pnpm package manager.
|
|||||||
|
|
||||||
### `version`
|
### `version`
|
||||||
|
|
||||||
**Required** Version of pnpm to install. It supports npm versioning scheme, it could be an exact version (such as `6.24.1`), or a version range (such as `6`, `6.x.x`, `6.24.x`, `^6.24.1`, `*`, etc.), or `latest`.
|
Version of pnpm to install.
|
||||||
|
|
||||||
|
**Optional** when there is a [`packageManager` field in the `package.json`](https://nodejs.org/api/corepack.html).
|
||||||
|
|
||||||
|
otherwise, this field is **required** It supports npm versioning scheme, it could be an exact version (such as `6.24.1`), or a version range (such as `6`, `6.x.x`, `6.24.x`, `^6.24.1`, `*`, etc.), or `latest`.
|
||||||
|
|
||||||
### `dest`
|
### `dest`
|
||||||
|
|
||||||
@ -58,7 +62,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
- uses: pnpm/action-setup@v2.2.2
|
||||||
with:
|
with:
|
||||||
version: 6.0.2
|
version: 6.0.2
|
||||||
```
|
```
|
||||||
@ -77,7 +81,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
- uses: pnpm/action-setup@v2.2.2
|
||||||
with:
|
with:
|
||||||
version: 6.0.2
|
version: 6.0.2
|
||||||
run_install: |
|
run_install: |
|
||||||
@ -98,21 +102,36 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
build:
|
- name: Checkout
|
||||||
- uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cache pnpm modules
|
- name: Install Node.js
|
||||||
uses: actions/cache@v2
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.pnpm-store
|
node-version: 16
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
- uses: pnpm/action-setup@v2.0.1
|
||||||
with:
|
name: Install pnpm
|
||||||
version: 6.0.2
|
id: pnpm-install
|
||||||
run_install: true
|
with:
|
||||||
|
version: 7
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Get pnpm store directory
|
||||||
|
id: pnpm-cache
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
name: Setup pnpm cache
|
||||||
|
with:
|
||||||
|
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
||||||
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.
|
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
name: Setup PNPM
|
name: Setup pnpm
|
||||||
description: Install PNPM package manager
|
description: Install pnpm package manager
|
||||||
branding:
|
branding:
|
||||||
icon: package
|
icon: package
|
||||||
color: orange
|
color: orange
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: Version of PNPM to install
|
description: Version of pnpm to install
|
||||||
required: true
|
|
||||||
dest:
|
dest:
|
||||||
description: Where to store PNPM files
|
description: Where to store pnpm files
|
||||||
required: false
|
required: false
|
||||||
default: ~/setup-pnpm
|
default: ~/setup-pnpm
|
||||||
run_install:
|
run_install:
|
||||||
|
11
dist/index.js
vendored
11
dist/index.js
vendored
File diff suppressed because one or more lines are too long
134031
dist/pnpm.js
vendored
Normal file
134031
dist/pnpm.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11
package.json
11
package.json
@ -3,7 +3,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build:schemas": "ts-schema-autogen generate",
|
"build:schemas": "ts-schema-autogen generate",
|
||||||
"build:ncc": "ncc build --minify --no-source-map-register --no-cache dist/tsc/index.js --out dist/",
|
"build:ncc": "ncc build --minify --no-source-map-register --no-cache dist/tsc/index.js --out dist/",
|
||||||
"build": "pnpm run build:schemas && tsc && pnpm run build:ncc",
|
"build": "pnpm run build:schemas && tsc && pnpm run build:ncc && cp src/install-pnpm/pnpm.js dist/pnpm.js",
|
||||||
"start": "pnpm run build && sh ./run.sh"
|
"start": "pnpm run build && sh ./run.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -12,16 +12,15 @@
|
|||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^4.0.5",
|
||||||
"@types/node": "^14.18.10",
|
"@types/node": "^14.18.10",
|
||||||
"@types/node-fetch": "^2.5.12",
|
"@types/node-fetch": "^2.6.1",
|
||||||
"ajv": "^6.12.6",
|
"ajv": "^6.12.6",
|
||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^10.0.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0"
|
||||||
"node-fetch": "^2.6.7"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ts-schema-autogen/cli": "^0.1.2",
|
"@ts-schema-autogen/cli": "^0.1.2",
|
||||||
"@vercel/ncc": "^0.27.0",
|
"@vercel/ncc": "^0.33.3",
|
||||||
"typescript": "^4.5.5"
|
"typescript": "^4.5.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
75
pnpm-lock.yaml
generated
75
pnpm-lock.yaml
generated
@ -1,4 +1,4 @@
|
|||||||
lockfileVersion: 5.3
|
lockfileVersion: 5.4
|
||||||
|
|
||||||
specifiers:
|
specifiers:
|
||||||
'@actions/core': ^1.6.0
|
'@actions/core': ^1.6.0
|
||||||
@ -7,13 +7,12 @@ specifiers:
|
|||||||
'@types/fs-extra': ^9.0.13
|
'@types/fs-extra': ^9.0.13
|
||||||
'@types/js-yaml': ^4.0.5
|
'@types/js-yaml': ^4.0.5
|
||||||
'@types/node': ^14.18.10
|
'@types/node': ^14.18.10
|
||||||
'@types/node-fetch': ^2.5.12
|
'@types/node-fetch': ^2.6.1
|
||||||
'@vercel/ncc': ^0.27.0
|
'@vercel/ncc': ^0.33.3
|
||||||
ajv: ^6.12.6
|
ajv: ^6.12.6
|
||||||
expand-tilde: ^2.0.2
|
expand-tilde: ^2.0.2
|
||||||
fs-extra: ^9.1.0
|
fs-extra: ^10.0.0
|
||||||
js-yaml: ^4.1.0
|
js-yaml: ^4.1.0
|
||||||
node-fetch: ^2.6.7
|
|
||||||
typescript: ^4.5.5
|
typescript: ^4.5.5
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -22,16 +21,15 @@ dependencies:
|
|||||||
'@types/fs-extra': 9.0.13
|
'@types/fs-extra': 9.0.13
|
||||||
'@types/js-yaml': 4.0.5
|
'@types/js-yaml': 4.0.5
|
||||||
'@types/node': 14.18.10
|
'@types/node': 14.18.10
|
||||||
'@types/node-fetch': 2.5.12
|
'@types/node-fetch': 2.6.1
|
||||||
ajv: 6.12.6
|
ajv: 6.12.6
|
||||||
expand-tilde: 2.0.2
|
expand-tilde: 2.0.2
|
||||||
fs-extra: 9.1.0
|
fs-extra: 10.0.0
|
||||||
js-yaml: 4.1.0
|
js-yaml: 4.1.0
|
||||||
node-fetch: 2.6.7
|
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@ts-schema-autogen/cli': 0.1.2
|
'@ts-schema-autogen/cli': 0.1.2
|
||||||
'@vercel/ncc': 0.27.0
|
'@vercel/ncc': 0.33.3
|
||||||
typescript: 4.5.5
|
typescript: 4.5.5
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
@ -216,8 +214,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==}
|
resolution: {integrity: sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/node-fetch/2.5.12:
|
/@types/node-fetch/2.6.1:
|
||||||
resolution: {integrity: sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==}
|
resolution: {integrity: sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 14.18.10
|
'@types/node': 14.18.10
|
||||||
form-data: 3.0.1
|
form-data: 3.0.1
|
||||||
@ -240,8 +238,8 @@ packages:
|
|||||||
'@types/yargs-parser': 20.2.1
|
'@types/yargs-parser': 20.2.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@vercel/ncc/0.27.0:
|
/@vercel/ncc/0.33.3:
|
||||||
resolution: {integrity: sha512-DllIJQapnU2YwewIhh/4dYesmMQw3h2cFtabECc/zSJHqUbNa0eJuEkRa6DXbZvh1YPWBtYQoPV17NlDpBw1Vw==}
|
resolution: {integrity: sha512-JGZ11QV+/ZcfudW2Cz2JVp54/pJNXbsuWRgSh2ZmmZdQBKXqBtIGrwI1Wyx8nlbzAiEFe7FHi4K1zX4//jxTnQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
@ -291,11 +289,6 @@ packages:
|
|||||||
resolution: {integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=}
|
resolution: {integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/at-least-node/1.0.0:
|
|
||||||
resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==}
|
|
||||||
engines: {node: '>= 4.0.0'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/balanced-match/1.0.2:
|
/balanced-match/1.0.2:
|
||||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||||
dev: true
|
dev: true
|
||||||
@ -442,6 +435,15 @@ packages:
|
|||||||
mime-types: 2.1.34
|
mime-types: 2.1.34
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/fs-extra/10.0.0:
|
||||||
|
resolution: {integrity: sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dependencies:
|
||||||
|
graceful-fs: 4.2.9
|
||||||
|
jsonfile: 6.1.0
|
||||||
|
universalify: 2.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/fs-extra/8.1.0:
|
/fs-extra/8.1.0:
|
||||||
resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==}
|
resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==}
|
||||||
engines: {node: '>=6 <7 || >=8'}
|
engines: {node: '>=6 <7 || >=8'}
|
||||||
@ -451,16 +453,6 @@ packages:
|
|||||||
universalify: 0.1.2
|
universalify: 0.1.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/fs-extra/9.1.0:
|
|
||||||
resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
dependencies:
|
|
||||||
at-least-node: 1.0.0
|
|
||||||
graceful-fs: 4.2.9
|
|
||||||
jsonfile: 6.1.0
|
|
||||||
universalify: 2.0.0
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/fs.realpath/1.0.0:
|
/fs.realpath/1.0.0:
|
||||||
resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=}
|
resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=}
|
||||||
dev: true
|
dev: true
|
||||||
@ -587,18 +579,6 @@ packages:
|
|||||||
brace-expansion: 1.1.11
|
brace-expansion: 1.1.11
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/node-fetch/2.6.7:
|
|
||||||
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
|
|
||||||
engines: {node: 4.x || >=6.0.0}
|
|
||||||
peerDependencies:
|
|
||||||
encoding: ^0.1.0
|
|
||||||
peerDependenciesMeta:
|
|
||||||
encoding:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
|
||||||
whatwg-url: 5.0.0
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/once/1.4.0:
|
/once/1.4.0:
|
||||||
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
|
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -704,10 +684,6 @@ packages:
|
|||||||
ansi-regex: 5.0.1
|
ansi-regex: 5.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/tr46/0.0.3:
|
|
||||||
resolution: {integrity: sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/tslib/1.14.1:
|
/tslib/1.14.1:
|
||||||
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
|
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
|
||||||
dev: true
|
dev: true
|
||||||
@ -764,17 +740,6 @@ packages:
|
|||||||
engines: {node: '>= 4'}
|
engines: {node: '>= 4'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/webidl-conversions/3.0.1:
|
|
||||||
resolution: {integrity: sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/whatwg-url/5.0.0:
|
|
||||||
resolution: {integrity: sha1-lmRU6HZUYuN2RNNib2dCzotwll0=}
|
|
||||||
dependencies:
|
|
||||||
tr46: 0.0.3
|
|
||||||
webidl-conversions: 3.0.1
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/which-module/2.0.0:
|
/which-module/2.0.0:
|
||||||
resolution: {integrity: sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=}
|
resolution: {integrity: sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { setFailed, saveState, getState } from '@actions/core'
|
import { setFailed, saveState, getState } from '@actions/core'
|
||||||
import getInputs from './inputs'
|
import getInputs from './inputs'
|
||||||
import setOutputs from './outputs'
|
|
||||||
import installPnpm from './install-pnpm'
|
import installPnpm from './install-pnpm'
|
||||||
|
import setOutputs from './outputs'
|
||||||
import pnpmInstall from './pnpm-install'
|
import pnpmInstall from './pnpm-install'
|
||||||
import pruneStore from './pnpm-store-prune'
|
import pruneStore from './pnpm-store-prune'
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import expandTilde from 'expand-tilde'
|
|||||||
import { RunInstall, parseRunInstall } from './run-install'
|
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 runInstall: RunInstall[]
|
readonly runInstall: RunInstall[]
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ const options: InputOptions = {
|
|||||||
const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
||||||
|
|
||||||
export const getInputs = (): Inputs => ({
|
export const getInputs = (): Inputs => ({
|
||||||
version: getInput('version', options),
|
version: getInput('version'),
|
||||||
dest: parseInputPath('dest'),
|
dest: parseInputPath('dest'),
|
||||||
runInstall: parseRunInstall('run_install'),
|
runInstall: parseRunInstall('run_install'),
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import process from 'process'
|
|
||||||
import { load } from 'js-yaml'
|
|
||||||
import Ajv from 'ajv'
|
|
||||||
import { getInput, error, InputOptions } from '@actions/core'
|
import { getInput, error, InputOptions } from '@actions/core'
|
||||||
|
import Ajv from 'ajv'
|
||||||
|
import { load } from 'js-yaml'
|
||||||
|
import process from 'process'
|
||||||
import runInstallSchema from './run-install-input.schema.json'
|
import runInstallSchema from './run-install-input.schema.json'
|
||||||
|
|
||||||
export interface RunInstall {
|
export interface RunInstall {
|
||||||
|
134031
src/install-pnpm/pnpm.js
Normal file
134031
src/install-pnpm/pnpm.js
Normal file
File diff suppressed because one or more lines are too long
@ -1,28 +1,26 @@
|
|||||||
import { addPath, exportVariable } from '@actions/core'
|
import { addPath, exportVariable } from '@actions/core'
|
||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import { execPath } from 'process'
|
import { remove, ensureFile, writeFile, readFile } from 'fs-extra'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { remove, ensureFile, writeFile } from 'fs-extra'
|
import { execPath } from 'process'
|
||||||
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 { version, dest } = inputs
|
const { version, dest } = inputs
|
||||||
const target = version ? `pnpm@${version}` : 'pnpm'
|
|
||||||
const pkgJson = path.join(dest, 'package.json')
|
|
||||||
|
|
||||||
|
// prepare self install
|
||||||
await remove(dest)
|
await remove(dest)
|
||||||
|
const pkgJson = path.join(dest, 'package.json')
|
||||||
await ensureFile(pkgJson)
|
await ensureFile(pkgJson)
|
||||||
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
||||||
|
|
||||||
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
|
// prepare target pnpm
|
||||||
|
const target = await readTarget(version)
|
||||||
|
const cp = spawn(execPath, [path.join(__dirname, 'pnpm.js'), 'install', target, '--no-lockfile'], {
|
||||||
cwd: dest,
|
cwd: dest,
|
||||||
stdio: ['pipe', 'inherit', 'inherit'],
|
stdio: ['pipe', 'inherit', 'inherit'],
|
||||||
})
|
})
|
||||||
|
|
||||||
const response = await fetch('https://pnpm.io/pnpm.js')
|
|
||||||
response.body.pipe(cp.stdin)
|
|
||||||
|
|
||||||
const exitCode = await new Promise<number>((resolve, reject) => {
|
const exitCode = await new Promise<number>((resolve, reject) => {
|
||||||
cp.on('error', reject)
|
cp.on('error', reject)
|
||||||
cp.on('close', resolve)
|
cp.on('close', resolve)
|
||||||
@ -35,4 +33,29 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
|||||||
return exitCode
|
return exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function readTarget(version?: string | undefined) {
|
||||||
|
if (version) return `pnpm@${version}`
|
||||||
|
|
||||||
|
const { GITHUB_WORKSPACE } = process.env
|
||||||
|
if (!GITHUB_WORKSPACE) {
|
||||||
|
throw new Error(`No workspace is found.
|
||||||
|
If you're intended to let pnpm/action-setup read preferred pnpm version from the "packageManager" field in the package.json file,
|
||||||
|
please run the actions/checkout before pnpm/action-setup.
|
||||||
|
Otherwise, please specify the pnpm version in the action configuration.`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const { packageManager } = JSON.parse(await readFile(path.join(GITHUB_WORKSPACE, 'package.json'), 'utf8'))
|
||||||
|
if (typeof packageManager !== 'string') {
|
||||||
|
throw new Error(`No pnpm version is specified.
|
||||||
|
Please specify it by one of the following ways:
|
||||||
|
- in the GitHub Action config with the key "version"
|
||||||
|
- in the package.json with the key "packageManager" (See https://nodejs.org/api/corepack.html)`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!packageManager.startsWith('pnpm@')) {
|
||||||
|
throw new Error('Invalid packageManager field in package.json')
|
||||||
|
}
|
||||||
|
return packageManager
|
||||||
|
}
|
||||||
|
|
||||||
export default runSelfInstaller
|
export default runSelfInstaller
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { spawnSync } from 'child_process'
|
|
||||||
import { setFailed, startGroup, endGroup } from '@actions/core'
|
import { setFailed, startGroup, endGroup } from '@actions/core'
|
||||||
|
import { spawnSync } from 'child_process'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
import { patchPnpmEnv } from '../utils'
|
import { patchPnpmEnv } from '../utils'
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { spawnSync } from 'child_process'
|
|
||||||
import { warning, startGroup, endGroup } from '@actions/core'
|
import { warning, startGroup, endGroup } from '@actions/core'
|
||||||
|
import { spawnSync } from 'child_process'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
import { patchPnpmEnv } from '../utils'
|
import { patchPnpmEnv } from '../utils'
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ export function pruneStore(inputs: Inputs) {
|
|||||||
const { error, status } = spawnSync('pnpm', ['store', 'prune'], {
|
const { error, status } = spawnSync('pnpm', ['store', 'prune'], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
shell: true,
|
shell: true,
|
||||||
env: patchPnpmEnv(inputs)
|
env: patchPnpmEnv(inputs),
|
||||||
})
|
})
|
||||||
endGroup()
|
endGroup()
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import process from 'process'
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import process from 'process'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
export const getBinDest = (inputs: Inputs): string => path.join(inputs.dest, 'node_modules', '.bin')
|
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: getBinDest(inputs) + path.delimiter + process.env.PATH
|
PATH: getBinDest(inputs) + path.delimiter + process.env.PATH,
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user