mirror of
https://github.com/pnpm/action-setup.git
synced 2025-08-22 23:29:04 +08:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0b715c7ebb | ||
![]() |
2ed49cbb02 | ||
![]() |
218cb35941 | ||
![]() |
3723f63bb4 | ||
![]() |
849d884800 | ||
![]() |
f92eb0edb6 | ||
![]() |
b27f801bf9 | ||
![]() |
11dd14d0c0 | ||
![]() |
61eb8c655a | ||
![]() |
65db188e28 | ||
![]() |
0609f0983b | ||
![]() |
7208fa2733 | ||
![]() |
1bd00a2972 | ||
![]() |
d5601fb603 | ||
![]() |
bc06aa6030 | ||
![]() |
cd2af74528 | ||
![]() |
c8a150e137 | ||
![]() |
ed0172a253 |
14
.github/FUNDING.yml
vendored
14
.github/FUNDING.yml
vendored
@@ -1,12 +1,2 @@
|
|||||||
# These are supported funding model platforms
|
custom:
|
||||||
|
- 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']
|
|
||||||
|
23
README.md
23
README.md
@@ -38,6 +38,10 @@ 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** File path to the `package.json` to read "packageManager" configutation. If not specified, `package.json` in the project root directory is used.
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
### `dest`
|
### `dest`
|
||||||
@@ -62,9 +66,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: pnpm/action-setup@v2.2.4
|
- uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
version: 6.0.2
|
version: 8
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install pnpm and a few npm packages
|
### Install pnpm and a few npm packages
|
||||||
@@ -79,11 +83,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.2.4
|
- uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
version: 6.0.2
|
version: 8
|
||||||
run_install: |
|
run_install: |
|
||||||
- recursive: true
|
- recursive: true
|
||||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||||
@@ -110,22 +114,21 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 16
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2.0.1
|
- uses: pnpm/action-setup@v2
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
id: pnpm-install
|
|
||||||
with:
|
with:
|
||||||
version: 7
|
version: 7
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
- name: Get pnpm store directory
|
||||||
id: pnpm-cache
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
name: Setup pnpm cache
|
name: Setup pnpm cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
@@ -6,6 +6,7 @@ branding:
|
|||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: Version of pnpm to install
|
description: Version of pnpm to install
|
||||||
|
required: false
|
||||||
dest:
|
dest:
|
||||||
description: Where to store pnpm files
|
description: Where to store pnpm files
|
||||||
required: false
|
required: false
|
||||||
@@ -14,6 +15,10 @@ inputs:
|
|||||||
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" configutation
|
||||||
|
required: false
|
||||||
|
default: 'package.json'
|
||||||
runs:
|
runs:
|
||||||
using: node16
|
using: node16
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -6,6 +6,7 @@ export interface Inputs {
|
|||||||
readonly version?: string
|
readonly version?: string
|
||||||
readonly dest: string
|
readonly dest: string
|
||||||
readonly runInstall: RunInstall[]
|
readonly runInstall: RunInstall[]
|
||||||
|
readonly packageJsonFile: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const options: InputOptions = {
|
const options: InputOptions = {
|
||||||
@@ -18,6 +19,7 @@ export const getInputs = (): Inputs => ({
|
|||||||
version: getInput('version'),
|
version: getInput('version'),
|
||||||
dest: parseInputPath('dest'),
|
dest: parseInputPath('dest'),
|
||||||
runInstall: parseRunInstall('run_install'),
|
runInstall: parseRunInstall('run_install'),
|
||||||
|
packageJsonFile: parseInputPath('package_json_file'),
|
||||||
})
|
})
|
||||||
|
|
||||||
export default getInputs
|
export default getInputs
|
||||||
|
@@ -6,7 +6,7 @@ import { execPath } from 'process'
|
|||||||
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 } = inputs
|
const { version, dest, packageJsonFile } = inputs
|
||||||
|
|
||||||
// prepare self install
|
// prepare self install
|
||||||
await remove(dest)
|
await remove(dest)
|
||||||
@@ -15,7 +15,7 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
|||||||
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
await writeFile(pkgJson, JSON.stringify({ private: true }))
|
||||||
|
|
||||||
// prepare target pnpm
|
// prepare target pnpm
|
||||||
const target = await readTarget(version)
|
const target = await readTarget(packageJsonFile, version)
|
||||||
const cp = spawn(execPath, [path.join(__dirname, 'pnpm.js'), 'install', target, '--no-lockfile'], {
|
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'],
|
||||||
@@ -33,7 +33,7 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
|||||||
return exitCode
|
return exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readTarget(version?: string | undefined) {
|
async function readTarget(packageJsonFile: string, version?: string | undefined) {
|
||||||
if (version) return `pnpm@${version}`
|
if (version) return `pnpm@${version}`
|
||||||
|
|
||||||
const { GITHUB_WORKSPACE } = process.env
|
const { GITHUB_WORKSPACE } = process.env
|
||||||
@@ -44,12 +44,12 @@ please run the actions/checkout before pnpm/action-setup.
|
|||||||
Otherwise, please specify the pnpm version in the action configuration.`)
|
Otherwise, please specify the pnpm version in the action configuration.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { packageManager } = JSON.parse(await readFile(path.join(GITHUB_WORKSPACE, 'package.json'), 'utf8'))
|
const { packageManager } = JSON.parse(await readFile(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8'))
|
||||||
if (typeof packageManager !== 'string') {
|
if (typeof packageManager !== 'string') {
|
||||||
throw new Error(`No pnpm version is specified.
|
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" (See https://nodejs.org/api/corepack.html)`)
|
- in the package.json with the key "packageManager"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!packageManager.startsWith('pnpm@')) {
|
if (!packageManager.startsWith('pnpm@')) {
|
||||||
|
Reference in New Issue
Block a user