mirror of
https://github.com/pnpm/action-setup.git
synced 2026-06-17 15:53:45 +08:00
Compare commits
1 Commits
2eb3a2bf7e
...
update-pnp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1682287a8f |
@@ -40,11 +40,11 @@ If `run_install` is a YAML string representation of either an object or an array
|
|||||||
|
|
||||||
#### `run_install.args`
|
#### `run_install.args`
|
||||||
|
|
||||||
**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--ignore-scripts, --strict-peer-dependencies]`.
|
**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--frozen-lockfile, --strict-peer-dependencies]`.
|
||||||
|
|
||||||
### `package_json_file`
|
### `package_json_file`
|
||||||
|
|
||||||
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json`/[`package.yaml`](https://github.com/pnpm/pnpm/pull/1799) to read "packageManager" configuration.
|
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json` to read "packageManager" configuration.
|
||||||
|
|
||||||
### `standalone`
|
### `standalone`
|
||||||
|
|
||||||
@@ -117,9 +117,9 @@ jobs:
|
|||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 10
|
version: 10
|
||||||
run_install:
|
run_install: |
|
||||||
- recursive: true
|
- recursive: true
|
||||||
args: [--strict-peer-dependencies]
|
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||||
- args: [--global, gulp, prettier, typescript]
|
- args: [--global, gulp, prettier, typescript]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
6
dist/index.js
vendored
6
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -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'
|
||||||
import YAML from 'yaml'
|
import YAML from 'yaml'
|
||||||
|
|
||||||
@@ -65,7 +64,6 @@ async function readTarget(opts: {
|
|||||||
if (version) {
|
if (version) {
|
||||||
if (
|
if (
|
||||||
typeof packageManager === 'string' &&
|
typeof packageManager === 'string' &&
|
||||||
packageManager.startsWith('pnpm@') &&
|
|
||||||
packageManager.replace('pnpm@', '') !== version
|
packageManager.replace('pnpm@', '') !== version
|
||||||
) {
|
) {
|
||||||
throw new Error(`Multiple versions of pnpm specified:
|
throw new Error(`Multiple versions of pnpm specified:
|
||||||
@@ -85,18 +83,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@')) {
|
||||||
@@ -110,21 +100,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