Compare commits
7 Commits
v2.2.0
..
57b9359b4c
| Author | SHA1 | Date | |
|---|---|---|---|
| 57b9359b4c | |||
| ec1a8b444c | |||
| 73e15250cb | |||
| 10b4b0b462 | |||
| 5fa8980bf4 | |||
| ae78e9abbe | |||
| 35ab4267a1 |
@@ -5,6 +5,3 @@ updates:
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 10
|
||||
labels:
|
||||
- dependabot
|
||||
- github-actions
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
- windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Run the action
|
||||
uses: ./
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
- windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Run the action
|
||||
uses: ./
|
||||
@@ -107,7 +107,7 @@ jobs:
|
||||
- pnpm
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Run the action
|
||||
uses: ./
|
||||
|
||||
@@ -102,21 +102,36 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
build:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Cache pnpm modules
|
||||
uses: actions/cache@v2
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
node-version: 16
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
name: Install pnpm
|
||||
id: pnpm-install
|
||||
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 }}-
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- uses: pnpm/action-setup@v2.1.0
|
||||
with:
|
||||
version: 6.0.2
|
||||
run_install: true
|
||||
- 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.
|
||||
|
||||
@@ -6,7 +6,6 @@ branding:
|
||||
inputs:
|
||||
version:
|
||||
description: Version of PNPM to install
|
||||
required: true
|
||||
dest:
|
||||
description: Where to store PNPM files
|
||||
required: false
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+14
-4
@@ -8,13 +8,15 @@ import { Inputs } from '../inputs'
|
||||
|
||||
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||
const { version, dest } = inputs
|
||||
const pkgJson = path.join(dest, 'package.json')
|
||||
const target = await readTarget(pkgJson, version)
|
||||
|
||||
// prepare self install
|
||||
await remove(dest)
|
||||
const pkgJson = path.join(dest, 'package.json')
|
||||
await ensureFile(pkgJson)
|
||||
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
||||
|
||||
// prepare target pnpm
|
||||
const target = await readTarget(version)
|
||||
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
|
||||
cwd: dest,
|
||||
stdio: ['pipe', 'inherit', 'inherit'],
|
||||
@@ -36,10 +38,18 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||
return exitCode
|
||||
}
|
||||
|
||||
async function readTarget(packageJsonPath: string, version?: string | undefined) {
|
||||
async function readTarget(version?: string | undefined) {
|
||||
if (version) return `pnpm@${version}`
|
||||
|
||||
const { packageManager } = JSON.parse(await readFile(packageJsonPath, 'utf8'))
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user