mirror of
https://github.com/pnpm/action-setup.git
synced 2026-06-29 17:03:46 +08:00
Compare commits
1 Commits
9b190f2a47
...
remove-v2-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b568c8023 |
10
README.md
10
README.md
@@ -1,7 +1,3 @@
|
|||||||
> ## :warning: Upgrade from v2!
|
|
||||||
>
|
|
||||||
> The v2 version of this action [has stopped working](https://github.com/pnpm/action-setup/issues/135) with newer Node.js versions. Please, upgrade to the latest version to fix any issues.
|
|
||||||
|
|
||||||
# Setup pnpm
|
# Setup pnpm
|
||||||
|
|
||||||
Install pnpm package manager.
|
Install pnpm package manager.
|
||||||
@@ -80,7 +76,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 9
|
version: 8
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install only pnpm with `packageManager`
|
### Install only pnpm with `packageManager`
|
||||||
@@ -116,7 +112,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 9
|
version: 8
|
||||||
run_install: |
|
run_install: |
|
||||||
- recursive: true
|
- recursive: true
|
||||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||||
@@ -141,7 +137,7 @@ jobs:
|
|||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 9
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { readFileSync } from 'fs'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { execPath } from 'process'
|
import { execPath } from 'process'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
import * as yaml from 'yaml'
|
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||||
@@ -79,18 +78,10 @@ Otherwise, please specify the pnpm version in the action configuration.`)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof packageManager !== 'string') {
|
if (typeof packageManager !== 'string') {
|
||||||
if (GITHUB_WORKSPACE) {
|
throw new Error(`No pnpm version is specified.
|
||||||
try {
|
|
||||||
const { lockfileVersion } = yaml.parse(readFileSync(path.join(GITHUB_WORKSPACE, 'pnpm-lock.yaml'), 'utf8'))
|
|
||||||
const version = getPnpmVersionFromLockfile(lockfileVersion);
|
|
||||||
return `${ standalone ? '@pnpm/exe' : 'pnpm' }@${version}`
|
|
||||||
} catch (error: unknown) {
|
|
||||||
throw new Error(`No pnpm version is specified.
|
|
||||||
Please specify it by one of the following ways:
|
Please specify it by one of the following ways:
|
||||||
- in the GitHub Action config with the key "version"
|
- in the GitHub Action config with the key "version"
|
||||||
- in the package.json with the key "packageManager"`)
|
- in the package.json with the key "packageManager"`)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!packageManager.startsWith('pnpm@')) {
|
if (!packageManager.startsWith('pnpm@')) {
|
||||||
@@ -104,21 +95,4 @@ Please specify it by one of the following ways:
|
|||||||
return packageManager
|
return packageManager
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPnpmVersionFromLockfile(
|
|
||||||
lockfileVersion: string | undefined
|
|
||||||
): string | undefined {
|
|
||||||
switch (true) {
|
|
||||||
case lockfileVersion === '5.3':
|
|
||||||
return 'latest-6';
|
|
||||||
case lockfileVersion === '5.4':
|
|
||||||
return 'latest-7';
|
|
||||||
case lockfileVersion === '6.0' || lockfileVersion === '6.1':
|
|
||||||
return 'latest-8';
|
|
||||||
case lockfileVersion === '7.0' || lockfileVersion === '9.0':
|
|
||||||
return 'latest-9';
|
|
||||||
default:
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default runSelfInstaller
|
export default runSelfInstaller
|
||||||
|
|||||||
Reference in New Issue
Block a user