Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c147d3f3ca | ||
|
|
9a52a9ef25 | ||
|
|
aeb1c1fbbe | ||
|
|
1e1c8eafbd | ||
|
|
b9e1dbc72f | ||
|
|
61bc82c7df | ||
|
|
e94b270858 | ||
|
|
ee7b8711bd | ||
|
|
3a0024f066 | ||
|
|
72f04517b7 | ||
|
|
41ff726559 | ||
|
|
f2b2b233b5 | ||
|
|
77504a59bc | ||
|
|
d648c2dd06 | ||
|
|
a7487c7e89 | ||
|
|
fff70888d0 | ||
|
|
6e3017af18 | ||
|
|
0cb0538c33 | ||
|
|
e303250a24 | ||
|
|
ac5bf11548 |
+13
-15
@@ -15,19 +15,19 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
pnpm:
|
pnpm:
|
||||||
- 4.11.1
|
- 9.15.5
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
- macos-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 4.11.1
|
version: 9.15.5
|
||||||
|
|
||||||
- name: 'Test: which'
|
- name: 'Test: which'
|
||||||
run: which pnpm; which pnpx
|
run: which pnpm; which pnpx
|
||||||
@@ -44,19 +44,19 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
pnpm:
|
pnpm:
|
||||||
- 4.11.1
|
- 9.15.5
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
- macos-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 4.11.1
|
version: 9.15.5
|
||||||
dest: ~/test/pnpm
|
dest: ~/test/pnpm
|
||||||
|
|
||||||
- name: 'Test: which'
|
- name: 'Test: which'
|
||||||
@@ -74,8 +74,8 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
|
# macos is excluded from this test because node 12 is no longer available on this platform
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
|
||||||
- windows-latest
|
- windows-latest
|
||||||
|
|
||||||
standalone:
|
standalone:
|
||||||
@@ -83,16 +83,16 @@ jobs:
|
|||||||
- false
|
- false
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 7.0.0
|
version: 9.15.0
|
||||||
standalone: ${{ matrix.standalone }}
|
standalone: ${{ matrix.standalone }}
|
||||||
|
|
||||||
- name: install Node.js
|
- name: install Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
# [email protected] is not compatible with Node.js 12
|
# [email protected] is not compatible with Node.js 12
|
||||||
node-version: 12.22.12
|
node-version: 12.22.12
|
||||||
@@ -129,7 +129,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
pnpm:
|
pnpm:
|
||||||
- 4.11.1
|
- 9.15.5
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-latest
|
- macos-latest
|
||||||
@@ -149,7 +149,6 @@ jobs:
|
|||||||
- --global-dir=./pnpm-global
|
- --global-dir=./pnpm-global
|
||||||
- npm
|
- npm
|
||||||
- yarn
|
- yarn
|
||||||
- pnpm
|
|
||||||
- name: 'array'
|
- name: 'array'
|
||||||
value: |
|
value: |
|
||||||
- {}
|
- {}
|
||||||
@@ -159,15 +158,14 @@ jobs:
|
|||||||
- --global-dir=./pnpm-global
|
- --global-dir=./pnpm-global
|
||||||
- npm
|
- npm
|
||||||
- yarn
|
- yarn
|
||||||
- pnpm
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 4.11.1
|
version: 9.15.5
|
||||||
run_install: ${{ matrix.run_install.value }}
|
run_install: ${{ matrix.run_install.value }}
|
||||||
|
|
||||||
- name: 'Test: which'
|
- name: 'Test: which'
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
> ## :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.
|
||||||
@@ -36,11 +40,19 @@ 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. `[--frozen-lockfile, --strict-peer-dependencies]`.
|
**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--ignore-scripts, --strict-peer-dependencies]`.
|
||||||
|
|
||||||
|
### `cache`
|
||||||
|
|
||||||
|
**Optional** (_type:_ `boolean`, _default:_ `false`) Whether to cache the pnpm store directory.
|
||||||
|
|
||||||
|
### `cache_dependency_path`
|
||||||
|
|
||||||
|
**Optional** (_type:_ `string|string[]`, _default:_ `pnpm-lock.yaml`) File path to the pnpm lockfile, which contents hash will be used as a cache key.
|
||||||
|
|
||||||
### `package_json_file`
|
### `package_json_file`
|
||||||
|
|
||||||
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json` to read "packageManager" configuration.
|
**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.
|
||||||
|
|
||||||
### `standalone`
|
### `standalone`
|
||||||
|
|
||||||
@@ -76,7 +88,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: 10
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install only pnpm with `packageManager`
|
### Install only pnpm with `packageManager`
|
||||||
@@ -112,10 +124,10 @@ jobs:
|
|||||||
|
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: 10
|
||||||
run_install: |
|
run_install: |
|
||||||
- recursive: true
|
- recursive: true
|
||||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
args: [--strict-peer-dependencies]
|
||||||
- args: [--global, gulp, prettier, typescript]
|
- args: [--global, gulp, prettier, typescript]
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -137,14 +149,8 @@ jobs:
|
|||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: 10
|
||||||
run_install: false
|
cache: true
|
||||||
|
|
||||||
- name: Install Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
cache: 'pnpm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|||||||
+10
-2
@@ -15,8 +15,16 @@ inputs:
|
|||||||
description: If specified, run `pnpm install`
|
description: If specified, run `pnpm install`
|
||||||
required: false
|
required: false
|
||||||
default: 'null'
|
default: 'null'
|
||||||
|
cache:
|
||||||
|
description: Whether to cache the pnpm store directory
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
cache_dependency_path:
|
||||||
|
description: File path to the pnpm lockfile, which contents hash will be used as a cache key
|
||||||
|
required: false
|
||||||
|
default: 'pnpm-lock.yaml'
|
||||||
package_json_file:
|
package_json_file:
|
||||||
description: File path to the package.json to read "packageManager" configuration
|
description: File path to the package.json to read "packageManager" configuration. This path must be relative to the repository root (GITHUB_WORKSPACE).
|
||||||
required: false
|
required: false
|
||||||
default: 'package.json'
|
default: 'package.json'
|
||||||
standalone:
|
standalone:
|
||||||
@@ -29,6 +37,6 @@ outputs:
|
|||||||
bin_dest:
|
bin_dest:
|
||||||
description: Location of `pnpm` and `pnpx` command
|
description: Location of `pnpm` and `pnpx` command
|
||||||
runs:
|
runs:
|
||||||
using: node20
|
using: node24
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
post: dist/index.js
|
post: dist/index.js
|
||||||
|
|||||||
Vendored
+4
-4
File diff suppressed because one or more lines are too long
+4
-2
@@ -7,10 +7,12 @@
|
|||||||
"update-pnpm-dist": "pnpm install && cp ./node_modules/pnpm/dist/pnpm.cjs ./dist/pnpm.cjs && cp ./node_modules/pnpm/dist/worker.js ./dist/worker.js"
|
"update-pnpm-dist": "pnpm install && cp ./node_modules/pnpm/dist/pnpm.cjs ./dist/pnpm.cjs && cp ./node_modules/pnpm/dist/worker.js ./dist/worker.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@actions/cache": "^4.1.0",
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
|
"@actions/exec": "^1.1.1",
|
||||||
|
"@actions/glob": "^0.5.0",
|
||||||
"@types/expand-tilde": "^2.0.2",
|
"@types/expand-tilde": "^2.0.2",
|
||||||
"@types/node": "^20.11.5",
|
"@types/node": "^22.0.0",
|
||||||
"@types/node-fetch": "^2.6.11",
|
|
||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
"yaml": "^2.3.4",
|
"yaml": "^2.3.4",
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
|
|||||||
Generated
+696
-132
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
|||||||
|
import { isFeatureAvailable } from '@actions/cache'
|
||||||
|
import { endGroup, startGroup, warning } from '@actions/core'
|
||||||
|
import { Inputs } from '../inputs'
|
||||||
|
import { runRestoreCache } from './run'
|
||||||
|
|
||||||
|
export async function restoreCache(inputs: Inputs) {
|
||||||
|
if (!inputs.cache) return
|
||||||
|
|
||||||
|
if (!isFeatureAvailable()) {
|
||||||
|
warning('Cache is not available, skipping cache restoration')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
startGroup('Restoring cache...')
|
||||||
|
await runRestoreCache(inputs)
|
||||||
|
endGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
export default restoreCache
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { restoreCache } from '@actions/cache'
|
||||||
|
import { debug, info, saveState, setOutput } from '@actions/core'
|
||||||
|
import { getExecOutput } from '@actions/exec'
|
||||||
|
import { hashFiles } from '@actions/glob'
|
||||||
|
import os from 'os'
|
||||||
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
|
export async function runRestoreCache(inputs: Inputs) {
|
||||||
|
const cachePath = await getCacheDirectory()
|
||||||
|
saveState('cache_path', cachePath)
|
||||||
|
|
||||||
|
const fileHash = await hashFiles(inputs.cacheDependencyPath)
|
||||||
|
if (!fileHash) {
|
||||||
|
throw new Error('Some specified paths were not resolved, unable to cache dependencies.')
|
||||||
|
}
|
||||||
|
|
||||||
|
const primaryKey = `pnpm-cache-${process.env.RUNNER_OS}-${os.arch()}-${fileHash}`
|
||||||
|
debug(`Primary key is ${primaryKey}`)
|
||||||
|
saveState('cache_primary_key', primaryKey)
|
||||||
|
|
||||||
|
let cacheKey = await restoreCache([cachePath], primaryKey)
|
||||||
|
|
||||||
|
setOutput('cache-hit', Boolean(cacheKey))
|
||||||
|
|
||||||
|
if (!cacheKey) {
|
||||||
|
info(`Cache is not found`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
saveState('cache_restored_key', cacheKey)
|
||||||
|
info(`Cache restored from key: ${cacheKey}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getCacheDirectory() {
|
||||||
|
const { stdout } = await getExecOutput('pnpm store path --silent')
|
||||||
|
const cacheFolderPath = stdout.trim()
|
||||||
|
debug(`Cache folder is set to "${cacheFolderPath}"`)
|
||||||
|
return cacheFolderPath
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { setFailed } from '@actions/core'
|
||||||
|
import { Inputs } from '../inputs'
|
||||||
|
import { runSaveCache } from './run'
|
||||||
|
|
||||||
|
export async function saveCache(inputs: Inputs) {
|
||||||
|
if (!inputs.cache) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
await runSaveCache()
|
||||||
|
} catch (error) {
|
||||||
|
setFailed((error as Error).message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default saveCache
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { saveCache } from '@actions/cache'
|
||||||
|
import { getState, info } from '@actions/core'
|
||||||
|
|
||||||
|
export async function runSaveCache() {
|
||||||
|
const state = getState('cache_restored_key')
|
||||||
|
const primaryKey = getState('cache_primary_key')
|
||||||
|
const cachePath = getState('cache_path')
|
||||||
|
|
||||||
|
if (primaryKey === state) {
|
||||||
|
info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacheId = await saveCache([cachePath], primaryKey)
|
||||||
|
if (cacheId == -1) return
|
||||||
|
|
||||||
|
info(`Cache saved with the key: ${primaryKey}`)
|
||||||
|
}
|
||||||
+21
-3
@@ -1,5 +1,7 @@
|
|||||||
import { setFailed, saveState, getState } from '@actions/core'
|
import { setFailed, saveState, getState } from '@actions/core'
|
||||||
import getInputs from './inputs'
|
import restoreCache from './cache-restore'
|
||||||
|
import saveCache from './cache-save'
|
||||||
|
import getInputs, { Inputs } from './inputs'
|
||||||
import installPnpm from './install-pnpm'
|
import installPnpm from './install-pnpm'
|
||||||
import setOutputs from './outputs'
|
import setOutputs from './outputs'
|
||||||
import pnpmInstall from './pnpm-install'
|
import pnpmInstall from './pnpm-install'
|
||||||
@@ -7,15 +9,31 @@ import pruneStore from './pnpm-store-prune'
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
const isPost = getState('is_post')
|
|
||||||
if (isPost === 'true') return pruneStore(inputs)
|
if (getState('is_post') === 'true') {
|
||||||
|
await runPost(inputs)
|
||||||
|
} else {
|
||||||
|
await runMain(inputs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runMain(inputs: Inputs) {
|
||||||
saveState('is_post', 'true')
|
saveState('is_post', 'true')
|
||||||
|
|
||||||
await installPnpm(inputs)
|
await installPnpm(inputs)
|
||||||
console.log('Installation Completed!')
|
console.log('Installation Completed!')
|
||||||
setOutputs(inputs)
|
setOutputs(inputs)
|
||||||
|
|
||||||
|
await restoreCache(inputs)
|
||||||
|
|
||||||
pnpmInstall(inputs)
|
pnpmInstall(inputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function runPost(inputs: Inputs) {
|
||||||
|
pruneStore(inputs)
|
||||||
|
await saveCache(inputs)
|
||||||
|
}
|
||||||
|
|
||||||
main().catch(error => {
|
main().catch(error => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
setFailed(error)
|
setFailed(error)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ 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 cache: boolean
|
||||||
|
readonly cacheDependencyPath: string
|
||||||
readonly runInstall: RunInstall[]
|
readonly runInstall: RunInstall[]
|
||||||
readonly packageJsonFile: string
|
readonly packageJsonFile: string
|
||||||
readonly standalone: boolean
|
readonly standalone: boolean
|
||||||
@@ -19,6 +21,8 @@ const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
|||||||
export const getInputs = (): Inputs => ({
|
export const getInputs = (): Inputs => ({
|
||||||
version: getInput('version'),
|
version: getInput('version'),
|
||||||
dest: parseInputPath('dest'),
|
dest: parseInputPath('dest'),
|
||||||
|
cache: getBooleanInput('cache'),
|
||||||
|
cacheDependencyPath: parseInputPath('cache_dependency_path'),
|
||||||
runInstall: parseRunInstall('run_install'),
|
runInstall: parseRunInstall('run_install'),
|
||||||
packageJsonFile: parseInputPath('package_json_file'),
|
packageJsonFile: parseInputPath('package_json_file'),
|
||||||
standalone: getBooleanInput('standalone'),
|
standalone: getBooleanInput('standalone'),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getInput, error } from '@actions/core'
|
import { getInput, error } from '@actions/core'
|
||||||
import * as yaml from 'yaml'
|
import { parse as parseYaml } from 'yaml'
|
||||||
import { z, ZodError } from 'zod'
|
import { z, ZodError } from 'zod'
|
||||||
|
|
||||||
const RunInstallSchema = z.object({
|
const RunInstallSchema = z.object({
|
||||||
@@ -20,7 +20,7 @@ export type RunInstall = z.infer<typeof RunInstallSchema>
|
|||||||
|
|
||||||
export function parseRunInstall(inputName: string): RunInstall[] {
|
export function parseRunInstall(inputName: string): RunInstall[] {
|
||||||
const input = getInput(inputName, { required: true })
|
const input = getInput(inputName, { required: true })
|
||||||
const parsedInput: unknown = yaml.parse(input)
|
const parsedInput: unknown = parseYaml(input)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result: RunInstallInput = RunInstallInputSchema.parse(parsedInput)
|
const result: RunInstallInput = RunInstallInputSchema.parse(parsedInput)
|
||||||
|
|||||||
+19
-2
@@ -1,14 +1,16 @@
|
|||||||
import { addPath, exportVariable } from '@actions/core'
|
import { addPath, exportVariable } from '@actions/core'
|
||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import { rm, writeFile, mkdir } from 'fs/promises'
|
import { rm, writeFile, mkdir, copyFile } from 'fs/promises'
|
||||||
import { readFileSync } from 'fs'
|
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 { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
import { parse as parseYaml } from 'yaml'
|
||||||
|
|
||||||
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||||
const { version, dest, packageJsonFile, standalone } = inputs
|
const { version, dest, packageJsonFile, standalone } = inputs
|
||||||
|
const { GITHUB_WORKSPACE } = process.env
|
||||||
|
|
||||||
// prepare self install
|
// prepare self install
|
||||||
await rm(dest, { recursive: true, force: true })
|
await rm(dest, { recursive: true, force: true })
|
||||||
@@ -18,6 +20,16 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
|||||||
// we have ensured the dest directory exists, we can write the file directly
|
// we have ensured the dest directory exists, we can write the file directly
|
||||||
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
||||||
|
|
||||||
|
// copy .npmrc if it exists to install from custom registry
|
||||||
|
if (GITHUB_WORKSPACE) {
|
||||||
|
try {
|
||||||
|
await copyFile(path.join(GITHUB_WORKSPACE, '.npmrc'), path.join(dest, '.npmrc'))
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow error if .npmrc doesn't exist
|
||||||
|
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// prepare target pnpm
|
// prepare target pnpm
|
||||||
const target = await readTarget({ version, packageJsonFile, standalone })
|
const target = await readTarget({ version, packageJsonFile, standalone })
|
||||||
const cp = spawn(execPath, [path.join(__dirname, 'pnpm.cjs'), 'install', target, '--no-lockfile'], {
|
const cp = spawn(execPath, [path.join(__dirname, 'pnpm.cjs'), 'install', target, '--no-lockfile'], {
|
||||||
@@ -49,7 +61,11 @@ async function readTarget(opts: {
|
|||||||
|
|
||||||
if (GITHUB_WORKSPACE) {
|
if (GITHUB_WORKSPACE) {
|
||||||
try {
|
try {
|
||||||
({ packageManager } = JSON.parse(readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8')))
|
const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8');
|
||||||
|
({ packageManager } = packageJsonFile.endsWith(".yaml")
|
||||||
|
? parseYaml(content, { merge: true })
|
||||||
|
: JSON.parse(content)
|
||||||
|
)
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
// Swallow error if package.json doesn't exist in root
|
// Swallow error if package.json doesn't exist in root
|
||||||
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
|
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
|
||||||
@@ -59,6 +75,7 @@ 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:
|
||||||
|
|||||||
Reference in New Issue
Block a user