mirror of
https://github.com/pnpm/action-setup.git
synced 2025-07-08 04:40:50 +08:00
Compare commits
5 Commits
feat/18
...
add-to-pat
Author | SHA1 | Date | |
---|---|---|---|
0e9c99a89a | |||
9087a16275 | |||
9c583927b0 | |||
43a416008e | |||
eb99e9e4c7 |
18
.github/workflows/test.yaml
vendored
18
.github/workflows/test.yaml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
pnpm:
|
pnpm:
|
||||||
- 6.17.1
|
- 4.11.1
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
- macos-latest
|
||||||
@ -27,10 +27,10 @@ jobs:
|
|||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 6.17.1
|
version: 4.11.1
|
||||||
|
|
||||||
- name: 'Test: which'
|
- name: 'Test: which'
|
||||||
run: which pnpm
|
run: which pnpm; which pnpx
|
||||||
|
|
||||||
- name: 'Test: install'
|
- name: 'Test: install'
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
@ -44,7 +44,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
pnpm:
|
pnpm:
|
||||||
- 6.17.1
|
- 4.11.1
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
- macos-latest
|
||||||
@ -56,11 +56,11 @@ jobs:
|
|||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 6.17.1
|
version: 4.11.1
|
||||||
dest: ~/test/pnpm
|
dest: ~/test/pnpm
|
||||||
|
|
||||||
- name: 'Test: which'
|
- name: 'Test: which'
|
||||||
run: which pnpm
|
run: which pnpm && which pnpx
|
||||||
|
|
||||||
- name: 'Test: install'
|
- name: 'Test: install'
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
@ -74,7 +74,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
pnpm:
|
pnpm:
|
||||||
- 6.17.1
|
- 4.11.1
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
- macos-latest
|
||||||
@ -112,11 +112,11 @@ jobs:
|
|||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 6.17.1
|
version: 4.11.1
|
||||||
run_install: ${{ matrix.run_install.value }}
|
run_install: ${{ matrix.run_install.value }}
|
||||||
|
|
||||||
- name: 'Test: which'
|
- name: 'Test: which'
|
||||||
run: which pnpm
|
run: which pnpm; which pnpx
|
||||||
|
|
||||||
- name: 'Test: install'
|
- name: 'Test: install'
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
63
README.md
63
README.md
@ -54,13 +54,12 @@ on:
|
|||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
install:
|
runs-on: ubuntu-latest
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
- uses: pnpm/action-setup@v2.0.1
|
||||||
with:
|
with:
|
||||||
version: 6.0.2
|
version: 6.0.2
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install pnpm and a few npm packages
|
### Install pnpm and a few npm packages
|
||||||
@ -71,19 +70,18 @@ on:
|
|||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
install:
|
runs-on: ubuntu-latest
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
- uses: pnpm/action-setup@v2.0.1
|
||||||
with:
|
with:
|
||||||
version: 6.0.2
|
version: 6.0.2
|
||||||
run_install: |
|
run_install: |
|
||||||
- recursive: true
|
- recursive: true
|
||||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||||
- args: [--global, gulp, prettier, typescript]
|
- args: [--global, gulp, prettier, typescript]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use cache to reduce installation time
|
### Use cache to reduce installation time
|
||||||
@ -94,25 +92,24 @@ on:
|
|||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cache-and-install:
|
runs-on: ubuntu-latest
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
build:
|
build:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Cache pnpm modules
|
- name: Cache pnpm modules
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: ~/.pnpm-store
|
path: ~/.pnpm-store
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-
|
${{ runner.os }}-
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.1.0
|
- uses: pnpm/action-setup@v2.0.1
|
||||||
with:
|
with:
|
||||||
version: 6.0.2
|
version: 6.0.2
|
||||||
run_install: true
|
run_install: true
|
||||||
```
|
```
|
||||||
|
|
||||||
**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.
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -1,15 +1,15 @@
|
|||||||
import { addPath, exportVariable } from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import { execPath } from 'process'
|
import { execPath } from 'process'
|
||||||
import path from 'path'
|
import { join } from 'path'
|
||||||
import { remove, ensureFile, writeFile } from 'fs-extra'
|
import { remove, ensureFile, writeFile } from 'fs-extra'
|
||||||
import fetch from 'node-fetch'
|
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/exe@${version}` : '@pnpm/exe'
|
const target = version ? `pnpm@${version}` : 'pnpm'
|
||||||
const pkgJson = path.join(dest, 'package.json')
|
const pkgJson = join(dest, 'package.json')
|
||||||
|
|
||||||
await remove(dest)
|
await remove(dest)
|
||||||
await ensureFile(pkgJson)
|
await ensureFile(pkgJson)
|
||||||
@ -20,19 +20,19 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
|||||||
stdio: ['pipe', 'inherit', 'inherit'],
|
stdio: ['pipe', 'inherit', 'inherit'],
|
||||||
})
|
})
|
||||||
|
|
||||||
const response = await fetch('https://get.pnpm.io/v6.16.js')
|
const response = await fetch('https://pnpm.js.org/pnpm.js')
|
||||||
response.body.pipe(cp.stdin)
|
response.body.pipe(cp.stdin)
|
||||||
|
|
||||||
const exitCode = await new Promise<number>((resolve, reject) => {
|
const result = await new Promise<number>((resolve, reject) => {
|
||||||
cp.on('error', reject)
|
cp.on('error', reject)
|
||||||
cp.on('close', resolve)
|
cp.on('close', resolve)
|
||||||
})
|
})
|
||||||
if (exitCode === 0) {
|
if (result === 0) {
|
||||||
const pnpmHome = path.join(dest, 'node_modules/.bin')
|
const pnpmHome = join(dest, 'node_modules/.bin')
|
||||||
addPath(pnpmHome)
|
core.addPath(pnpmHome)
|
||||||
exportVariable('PNPM_HOME', pnpmHome)
|
core.exportVariable('PNPM_HOME_PATH', pnpmHome)
|
||||||
}
|
}
|
||||||
return exitCode
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export default runSelfInstaller
|
export default runSelfInstaller
|
||||||
|
Reference in New Issue
Block a user