feat: support installation from custom NPM registry (#179)
Some checks are pending
Test Action / Test with default inputs (push) Waiting to run
Test Action / Test with default inputs-1 (push) Waiting to run
Test Action / Test with default inputs-2 (push) Waiting to run
Test Action / Test with dest (push) Waiting to run
Test Action / Test with dest-1 (push) Waiting to run
Test Action / Test with dest-2 (push) Waiting to run
Test Action / Test with standalone (push) Waiting to run
Test Action / Test with standalone-1 (push) Waiting to run
Test Action / Test with standalone-2 (push) Waiting to run
Test Action / Test with standalone-3 (push) Waiting to run
Test Action / Test with standalone-4 (push) Waiting to run
Test Action / Test with standalone-5 (push) Waiting to run
Test Action / Test with run_install (array, macos-latest) (push) Waiting to run
Test Action / Test with run_install (empty object, macos-latest) (push) Waiting to run
Test Action / Test with run_install (global, macos-latest) (push) Waiting to run
Test Action / Test with run_install (null, macos-latest) (push) Waiting to run
Test Action / Test with run_install (recursive, macos-latest) (push) Waiting to run
Test Action / Test with run_install (array, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (empty object, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (global, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (null, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (recursive, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (array, windows-latest) (push) Waiting to run
Test Action / Test with run_install (empty object, windows-latest) (push) Waiting to run
Test Action / Test with run_install (global, windows-latest) (push) Waiting to run
Test Action / Test with run_install (null, windows-latest) (push) Waiting to run
Test Action / Test with run_install (recursive, windows-latest) (push) Waiting to run
Some checks are pending
Test Action / Test with default inputs (push) Waiting to run
Test Action / Test with default inputs-1 (push) Waiting to run
Test Action / Test with default inputs-2 (push) Waiting to run
Test Action / Test with dest (push) Waiting to run
Test Action / Test with dest-1 (push) Waiting to run
Test Action / Test with dest-2 (push) Waiting to run
Test Action / Test with standalone (push) Waiting to run
Test Action / Test with standalone-1 (push) Waiting to run
Test Action / Test with standalone-2 (push) Waiting to run
Test Action / Test with standalone-3 (push) Waiting to run
Test Action / Test with standalone-4 (push) Waiting to run
Test Action / Test with standalone-5 (push) Waiting to run
Test Action / Test with run_install (array, macos-latest) (push) Waiting to run
Test Action / Test with run_install (empty object, macos-latest) (push) Waiting to run
Test Action / Test with run_install (global, macos-latest) (push) Waiting to run
Test Action / Test with run_install (null, macos-latest) (push) Waiting to run
Test Action / Test with run_install (recursive, macos-latest) (push) Waiting to run
Test Action / Test with run_install (array, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (empty object, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (global, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (null, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (recursive, ubuntu-latest) (push) Waiting to run
Test Action / Test with run_install (array, windows-latest) (push) Waiting to run
Test Action / Test with run_install (empty object, windows-latest) (push) Waiting to run
Test Action / Test with run_install (global, windows-latest) (push) Waiting to run
Test Action / Test with run_install (null, windows-latest) (push) Waiting to run
Test Action / Test with run_install (recursive, windows-latest) (push) Waiting to run
copy .npmrc from GitHub workspace if it exists so that PNPM respects custom registry configurations when self-installing
This commit is contained in:
parent
f2b2b233b5
commit
41ff726559
2 changed files with 12 additions and 1 deletions
BIN
dist/index.js
vendored
BIN
dist/index.js
vendored
Binary file not shown.
|
|
@ -1,6 +1,6 @@
|
|||
import { addPath, exportVariable } from '@actions/core'
|
||||
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 path from 'path'
|
||||
import { execPath } from 'process'
|
||||
|
|
@ -10,6 +10,7 @@ import YAML from 'yaml'
|
|||
|
||||
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||
const { version, dest, packageJsonFile, standalone } = inputs
|
||||
const { GITHUB_WORKSPACE } = process.env
|
||||
|
||||
// prepare self install
|
||||
await rm(dest, { recursive: true, force: true })
|
||||
|
|
@ -19,6 +20,16 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
|||
// we have ensured the dest directory exists, we can write the file directly
|
||||
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
|
||||
const target = await readTarget({ version, packageJsonFile, standalone })
|
||||
const cp = spawn(execPath, [path.join(__dirname, 'pnpm.cjs'), 'install', target, '--no-lockfile'], {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue