From 5f91f4af42ceca3157ed2b269aa1c01fd06dd21d Mon Sep 17 00:00:00 2001 From: Timon Date: Sat, 29 Apr 2023 09:30:54 +0000 Subject: [PATCH] add legacy peer deps option --- action.yml | 4 ++++ src/inputs-helper.ts | 4 ++++ src/inputs.model.ts | 1 + src/main.ts | 2 +- src/nx-migrate.ts | 12 +++++++++--- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index bd355a1..3bb24cb 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,10 @@ inputs: required: false description: 'Title of the PR where $VERSION is the new version of NX.' default: 'Migrate NX to $VERSION' + legacyPeerDeps: + required: false + description: 'Value of the legacy-peer-deps flag for npm install.' + default: 'false' outputs: prId: description: 'Issue ID of the created PR' diff --git a/src/inputs-helper.ts b/src/inputs-helper.ts index 5d6f083..63afc8a 100644 --- a/src/inputs-helper.ts +++ b/src/inputs-helper.ts @@ -7,12 +7,16 @@ export function getInputs(): Inputs { const includeMigrationsFile = core.getInput('includeMigrationsFile', { required: false }) + const legacyPeerDeps = core.getInput('legacyPeerDeps', { + required: false + }) const prTitle = core.getInput('prTitle', {required: false}) return { repoToken, commitMessage, includeMigrationsFile: Boolean(includeMigrationsFile), + legacyPeerDeps: Boolean(legacyPeerDeps), prTitle } } diff --git a/src/inputs.model.ts b/src/inputs.model.ts index 26cbaf7..ffd6024 100644 --- a/src/inputs.model.ts +++ b/src/inputs.model.ts @@ -3,4 +3,5 @@ export default interface Inputs { commitMessage: string prTitle: string includeMigrationsFile: boolean + legacyPeerDeps: boolean } diff --git a/src/main.ts b/src/main.ts index 92b254e..264895d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,7 +52,7 @@ async function run(): Promise { ) core.debug('Starting migrations...') - await migrate(inputs.includeMigrationsFile) + await migrate(inputs.includeMigrationsFile, inputs.legacyPeerDeps) core.debug('Pushing changes...') const commitMessage = inputs.commitMessage.replace( diff --git a/src/nx-migrate.ts b/src/nx-migrate.ts index e58b982..e001e6a 100644 --- a/src/nx-migrate.ts +++ b/src/nx-migrate.ts @@ -1,18 +1,24 @@ import {exec} from '@actions/exec' import fs from 'fs' -export async function migrate(keepMigrationsFile: boolean): Promise { +export async function migrate(keepMigrationsFile: boolean, legacyPeerDeps: boolean): Promise { await exec('npx nx migrate latest', [], { env: { ...process.env, npm_config_yes: 'true' } }) - await exec('npm i') + await exec('npm i', [], { + env: { + ...process.env, + 'npm_config_legacy_peer_deps': String(legacyPeerDeps) + } + }) await exec('npx nx migrate --run-migrations=migrations.json', [], { env: { ...process.env, - npm_config_yes: 'true' + npm_config_yes: 'true', + 'npm_config_legacy_peer_deps': String(legacyPeerDeps) } })