Compare commits
No commits in common. "master" and "pnpm-v7-test" have entirely different histories.
master
...
pnpm-v7-te
14
.github/FUNDING.yml
vendored
14
.github/FUNDING.yml
vendored
@ -1,2 +1,12 @@
|
|||||||
custom:
|
# These are supported funding model platforms
|
||||||
- https://opencollective.com/pnpm
|
|
||||||
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: khai96_
|
||||||
|
open_collective: # Collective unavailable
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # disabled
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
|
3
.github/dependabot.yml
vendored
3
.github/dependabot.yml
vendored
@ -5,3 +5,6 @@ updates:
|
|||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
|
labels:
|
||||||
|
- dependabot
|
||||||
|
- github-actions
|
||||||
|
65
.github/workflows/test.yaml
vendored
65
.github/workflows/test.yaml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
- windows-latest
|
- windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -35,8 +35,8 @@ jobs:
|
|||||||
- name: 'Test: install'
|
- name: 'Test: install'
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|
||||||
test_dest:
|
test_explicit_inputs:
|
||||||
name: Test with dest
|
name: Test with explicit inputs
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ jobs:
|
|||||||
- windows-latest
|
- windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -65,61 +65,6 @@ jobs:
|
|||||||
- name: 'Test: install'
|
- name: 'Test: install'
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|
||||||
test_standalone:
|
|
||||||
name: Test with standalone
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- ubuntu-latest
|
|
||||||
- macos-latest
|
|
||||||
- windows-latest
|
|
||||||
|
|
||||||
standalone:
|
|
||||||
- true
|
|
||||||
- false
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Run the action
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
version: 7.0.0
|
|
||||||
standalone: ${{ matrix.standalone }}
|
|
||||||
|
|
||||||
- name: install Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
# pnpm@7.0.0 is not compatible with Node.js 12
|
|
||||||
node-version: 12.22.12
|
|
||||||
|
|
||||||
- name: 'Test: which (pnpm)'
|
|
||||||
run: which pnpm
|
|
||||||
|
|
||||||
- name: 'Test: which (pnpx)'
|
|
||||||
if: matrix.standalone == false
|
|
||||||
run: which pnpx
|
|
||||||
|
|
||||||
- name: 'Test: install when standalone is true'
|
|
||||||
if: matrix.standalone
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: 'Test: install when standalone is false'
|
|
||||||
if: matrix.standalone == false
|
|
||||||
# Since the default shell on windows runner is pwsh, we specify bash explicitly
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
if pnpm install; then
|
|
||||||
echo "pnpm install should fail"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "pnpm install failed as expected"
|
|
||||||
fi
|
|
||||||
|
|
||||||
test_run_install:
|
test_run_install:
|
||||||
name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'
|
name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'
|
||||||
|
|
||||||
@ -162,7 +107,7 @@ jobs:
|
|||||||
- pnpm
|
- pnpm
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run the action
|
- name: Run the action
|
||||||
uses: ./
|
uses: ./
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,7 +2,6 @@ node_modules
|
|||||||
*.log
|
*.log
|
||||||
/dist/*
|
/dist/*
|
||||||
!/dist/index.js
|
!/dist/index.js
|
||||||
!/dist/pnpm.js
|
|
||||||
tmp
|
tmp
|
||||||
temp
|
temp
|
||||||
*.tmp
|
*.tmp
|
||||||
|
65
README.md
65
README.md
@ -6,11 +6,7 @@ Install pnpm package manager.
|
|||||||
|
|
||||||
### `version`
|
### `version`
|
||||||
|
|
||||||
Version of pnpm to install.
|
**Required** Version of pnpm to install. It supports npm versioning scheme, it could be an exact version (such as `6.24.1`), or a version range (such as `6`, `6.x.x`, `6.24.x`, `^6.24.1`, `*`, etc.), or `latest`.
|
||||||
|
|
||||||
**Optional** when there is a [`packageManager` field in the `package.json`](https://nodejs.org/api/corepack.html).
|
|
||||||
|
|
||||||
otherwise, this field is **required** It supports npm versioning scheme, it could be an exact version (such as `6.24.1`), or a version range (such as `6`, `6.x.x`, `6.24.x`, `^6.24.1`, `*`, etc.), or `latest`.
|
|
||||||
|
|
||||||
### `dest`
|
### `dest`
|
||||||
|
|
||||||
@ -38,16 +34,6 @@ If `run_install` is a YAML string representation of either an object or an array
|
|||||||
|
|
||||||
**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. `[--frozen-lockfile, --strict-peer-dependencies]`.
|
||||||
|
|
||||||
### `package_json_file`
|
|
||||||
|
|
||||||
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json` to read "packageManager" configuration.
|
|
||||||
|
|
||||||
### `standalone`
|
|
||||||
|
|
||||||
**Optional** (_type:_ `boolean`, _default:_ `false`) When set to true, [@pnpm/exe](https://www.npmjs.com/package/@pnpm/exe), which is a Node.js bundled package, will be installed, enabling using `pnpm` without Node.js.
|
|
||||||
|
|
||||||
This is useful when you want to use a incompatible pair of Node.js and pnpm.
|
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
### `dest`
|
### `dest`
|
||||||
@ -68,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
|
- uses: pnpm/action-setup@v2.0.1
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: 6.0.2
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install pnpm and a few npm packages
|
### Install pnpm and a few npm packages
|
||||||
@ -85,15 +70,14 @@ on:
|
|||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
install:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2.0.1
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: 6.0.2
|
||||||
run_install: |
|
run_install: |
|
||||||
- recursive: true
|
- recursive: true
|
||||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||||
@ -108,39 +92,24 @@ on:
|
|||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cache-and-install:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
build:
|
||||||
uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Cache pnpm modules
|
||||||
uses: actions/setup-node@v3
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
path: ~/.pnpm-store
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
- uses: pnpm/action-setup@v2
|
|
||||||
name: Install pnpm
|
|
||||||
with:
|
|
||||||
version: 8
|
|
||||||
run_install: false
|
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
name: Setup pnpm cache
|
|
||||||
with:
|
|
||||||
path: ${{ env.STORE_PATH }}
|
|
||||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-
|
||||||
|
|
||||||
- name: Install dependencies
|
- uses: pnpm/action-setup@v2.0.1
|
||||||
run: pnpm install
|
with:
|
||||||
|
version: 6.0.2
|
||||||
|
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.
|
||||||
|
20
action.yml
20
action.yml
@ -1,29 +1,21 @@
|
|||||||
name: Setup pnpm
|
name: Setup PNPM
|
||||||
description: Install pnpm package manager
|
description: Install PNPM package manager
|
||||||
branding:
|
branding:
|
||||||
icon: package
|
icon: package
|
||||||
color: orange
|
color: orange
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: Version of pnpm to install
|
description: Version of PNPM to install
|
||||||
required: false
|
required: true
|
||||||
dest:
|
dest:
|
||||||
description: Where to store pnpm files
|
description: Where to store PNPM files
|
||||||
required: false
|
required: false
|
||||||
default: ~/setup-pnpm
|
default: ~/setup-pnpm
|
||||||
run_install:
|
run_install:
|
||||||
description: If specified, run `pnpm install`
|
description: If specified, run `pnpm install`
|
||||||
required: false
|
required: false
|
||||||
default: 'null'
|
default: 'null'
|
||||||
package_json_file:
|
|
||||||
description: File path to the package.json to read "packageManager" configuration
|
|
||||||
required: false
|
|
||||||
default: 'package.json'
|
|
||||||
standalone:
|
|
||||||
description: When set to true, @pnpm/exe, which is a Node.js bundled package, will be installed, enabling using pnpm without Node.js.
|
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
runs:
|
runs:
|
||||||
using: node16
|
using: node12
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
post: dist/index.js
|
post: dist/index.js
|
||||||
|
BIN
dist/index.js
vendored
BIN
dist/index.js
vendored
Binary file not shown.
134031
dist/pnpm.js
vendored
134031
dist/pnpm.js
vendored
File diff suppressed because one or more lines are too long
17
package.json
17
package.json
@ -3,24 +3,25 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build:schemas": "ts-schema-autogen generate",
|
"build:schemas": "ts-schema-autogen generate",
|
||||||
"build:ncc": "ncc build --minify --no-source-map-register --no-cache dist/tsc/index.js --out dist/",
|
"build:ncc": "ncc build --minify --no-source-map-register --no-cache dist/tsc/index.js --out dist/",
|
||||||
"build": "pnpm run build:schemas && tsc && pnpm run build:ncc && cp src/install-pnpm/pnpm.js dist/pnpm.js",
|
"build": "pnpm run build:schemas && tsc && pnpm run build:ncc",
|
||||||
"start": "pnpm run build && sh ./run.sh"
|
"start": "pnpm run build && sh ./run.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.6.0",
|
||||||
"@types/expand-tilde": "^2.0.0",
|
"@types/expand-tilde": "^2.0.0",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^4.0.5",
|
||||||
"@types/node": "^14.18.54",
|
"@types/node": "^14.18.10",
|
||||||
"@types/node-fetch": "^2.6.4",
|
"@types/node-fetch": "^2.5.12",
|
||||||
"ajv": "^6.12.6",
|
"ajv": "^6.12.6",
|
||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"js-yaml": "^4.1.0"
|
"js-yaml": "^4.1.0",
|
||||||
|
"node-fetch": "^2.6.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ts-schema-autogen/cli": "^0.1.2",
|
"@ts-schema-autogen/cli": "^0.1.2",
|
||||||
"@vercel/ncc": "^0.33.4",
|
"@vercel/ncc": "^0.27.0",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.5.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
486
pnpm-lock.yaml
486
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
1
run.sh
1
run.sh
@ -4,5 +4,4 @@ export HOME="$(pwd)"
|
|||||||
export INPUT_VERSION=4.11.1
|
export INPUT_VERSION=4.11.1
|
||||||
export INPUT_DEST='~/pnpm.temp'
|
export INPUT_DEST='~/pnpm.temp'
|
||||||
export INPUT_RUN_INSTALL=null
|
export INPUT_RUN_INSTALL=null
|
||||||
export INPUT_standalone=false
|
|
||||||
exec node dist/index.js
|
exec node dist/index.js
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { setFailed, saveState, getState } from '@actions/core'
|
import { setFailed, saveState, getState } from '@actions/core'
|
||||||
import getInputs from './inputs'
|
import getInputs from './inputs'
|
||||||
import installPnpm from './install-pnpm'
|
|
||||||
import setOutputs from './outputs'
|
import setOutputs from './outputs'
|
||||||
|
import installPnpm from './install-pnpm'
|
||||||
import pnpmInstall from './pnpm-install'
|
import pnpmInstall from './pnpm-install'
|
||||||
import pruneStore from './pnpm-store-prune'
|
import pruneStore from './pnpm-store-prune'
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import { getBooleanInput, getInput, InputOptions } from '@actions/core'
|
import { getInput, InputOptions } from '@actions/core'
|
||||||
import expandTilde from 'expand-tilde'
|
import expandTilde from 'expand-tilde'
|
||||||
import { RunInstall, parseRunInstall } from './run-install'
|
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 runInstall: RunInstall[]
|
readonly runInstall: RunInstall[]
|
||||||
readonly packageJsonFile: string
|
|
||||||
readonly standalone: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const options: InputOptions = {
|
const options: InputOptions = {
|
||||||
@ -17,11 +15,9 @@ const options: InputOptions = {
|
|||||||
const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
||||||
|
|
||||||
export const getInputs = (): Inputs => ({
|
export const getInputs = (): Inputs => ({
|
||||||
version: getInput('version'),
|
version: getInput('version', options),
|
||||||
dest: parseInputPath('dest'),
|
dest: parseInputPath('dest'),
|
||||||
runInstall: parseRunInstall('run_install'),
|
runInstall: parseRunInstall('run_install'),
|
||||||
packageJsonFile: parseInputPath('package_json_file'),
|
|
||||||
standalone: getBooleanInput('standalone'),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default getInputs
|
export default getInputs
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { getInput, error, InputOptions } from '@actions/core'
|
|
||||||
import Ajv from 'ajv'
|
|
||||||
import { load } from 'js-yaml'
|
|
||||||
import process from 'process'
|
import process from 'process'
|
||||||
|
import { load } from 'js-yaml'
|
||||||
|
import Ajv from 'ajv'
|
||||||
|
import { getInput, error, InputOptions } from '@actions/core'
|
||||||
import runInstallSchema from './run-install-input.schema.json'
|
import runInstallSchema from './run-install-input.schema.json'
|
||||||
|
|
||||||
export interface RunInstall {
|
export interface RunInstall {
|
||||||
|
134031
src/install-pnpm/pnpm.js
134031
src/install-pnpm/pnpm.js
File diff suppressed because one or more lines are too long
@ -1,72 +1,38 @@
|
|||||||
import { addPath, exportVariable } from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import { remove, ensureFile, writeFile, readFile } from 'fs-extra'
|
|
||||||
import path from 'path'
|
|
||||||
import { execPath } from 'process'
|
import { execPath } from 'process'
|
||||||
|
import { join } from 'path'
|
||||||
|
import { remove, ensureFile, writeFile } from 'fs-extra'
|
||||||
|
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, packageJsonFile, standalone } = inputs
|
const { version, dest } = inputs
|
||||||
|
const target = version ? `pnpm@${version}` : 'pnpm'
|
||||||
|
const pkgJson = join(dest, 'package.json')
|
||||||
|
|
||||||
// prepare self install
|
|
||||||
await remove(dest)
|
await remove(dest)
|
||||||
const pkgJson = path.join(dest, 'package.json')
|
|
||||||
await ensureFile(pkgJson)
|
await ensureFile(pkgJson)
|
||||||
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
||||||
|
|
||||||
// prepare target pnpm
|
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
|
||||||
const target = await readTarget({ version, packageJsonFile, standalone })
|
|
||||||
const cp = spawn(execPath, [path.join(__dirname, 'pnpm.js'), 'install', target, '--no-lockfile'], {
|
|
||||||
cwd: dest,
|
cwd: dest,
|
||||||
stdio: ['pipe', 'inherit', 'inherit'],
|
stdio: ['pipe', 'inherit', 'inherit'],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const response = await fetch('https://pnpm.js.org/pnpm.js')
|
||||||
|
response.body.pipe(cp.stdin)
|
||||||
|
|
||||||
const exitCode = await new Promise<number>((resolve, reject) => {
|
const exitCode = 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 (exitCode === 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', pnpmHome)
|
||||||
}
|
}
|
||||||
return exitCode
|
return exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readTarget(opts: {
|
|
||||||
readonly version?: string | undefined
|
|
||||||
readonly packageJsonFile: string
|
|
||||||
readonly standalone: boolean
|
|
||||||
}) {
|
|
||||||
const { version, packageJsonFile, standalone } = opts
|
|
||||||
|
|
||||||
if (version) return `${ standalone ? '@pnpm/exe' : 'pnpm' }@${version}`
|
|
||||||
|
|
||||||
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, packageJsonFile), 'utf8'))
|
|
||||||
if (typeof packageManager !== 'string') {
|
|
||||||
throw new Error(`No pnpm version is specified.
|
|
||||||
Please specify it by one of the following ways:
|
|
||||||
- in the GitHub Action config with the key "version"
|
|
||||||
- in the package.json with the key "packageManager"`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!packageManager.startsWith('pnpm@')) {
|
|
||||||
throw new Error('Invalid packageManager field in package.json')
|
|
||||||
}
|
|
||||||
|
|
||||||
if(standalone){
|
|
||||||
return packageManager.replace('pnpm@', '@pnpm/exe@')
|
|
||||||
}
|
|
||||||
|
|
||||||
return packageManager
|
|
||||||
}
|
|
||||||
|
|
||||||
export default runSelfInstaller
|
export default runSelfInstaller
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { setFailed, startGroup, endGroup } from '@actions/core'
|
|
||||||
import { spawnSync } from 'child_process'
|
import { spawnSync } from 'child_process'
|
||||||
|
import { setFailed, startGroup, endGroup } from '@actions/core'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
import { patchPnpmEnv } from '../utils'
|
import { patchPnpmEnv } from '../utils'
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { warning, startGroup, endGroup } from '@actions/core'
|
|
||||||
import { spawnSync } from 'child_process'
|
import { spawnSync } from 'child_process'
|
||||||
|
import { warning, startGroup, endGroup } from '@actions/core'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
import { patchPnpmEnv } from '../utils'
|
import { patchPnpmEnv } from '../utils'
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ export function pruneStore(inputs: Inputs) {
|
|||||||
const { error, status } = spawnSync('pnpm', ['store', 'prune'], {
|
const { error, status } = spawnSync('pnpm', ['store', 'prune'], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
shell: true,
|
shell: true,
|
||||||
env: patchPnpmEnv(inputs),
|
env: patchPnpmEnv(inputs)
|
||||||
})
|
})
|
||||||
endGroup()
|
endGroup()
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import path from 'path'
|
|
||||||
import process from 'process'
|
import process from 'process'
|
||||||
|
import path from 'path'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
export const getBinDest = (inputs: Inputs): string => path.join(inputs.dest, 'node_modules', '.bin')
|
export const getBinDest = (inputs: Inputs): string => path.join(inputs.dest, 'node_modules', '.bin')
|
||||||
|
|
||||||
export const patchPnpmEnv = (inputs: Inputs): NodeJS.ProcessEnv => ({
|
export const patchPnpmEnv = (inputs: Inputs): NodeJS.ProcessEnv => ({
|
||||||
...process.env,
|
...process.env,
|
||||||
PATH: getBinDest(inputs) + path.delimiter + process.env.PATH,
|
PATH: getBinDest(inputs) + path.delimiter + process.env.PATH
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user