Skip to content

Commit

Permalink
add legacy peer deps option
Browse files Browse the repository at this point in the history
  • Loading branch information
timonmasberg committed Apr 29, 2023
1 parent de73eea commit 5f91f4a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions src/inputs-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions src/inputs.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export default interface Inputs {
commitMessage: string
prTitle: string
includeMigrationsFile: boolean
legacyPeerDeps: boolean
}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function run(): Promise<void> {
)

core.debug('Starting migrations...')
await migrate(inputs.includeMigrationsFile)
await migrate(inputs.includeMigrationsFile, inputs.legacyPeerDeps)

core.debug('Pushing changes...')
const commitMessage = inputs.commitMessage.replace(
Expand Down
12 changes: 9 additions & 3 deletions src/nx-migrate.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import {exec} from '@actions/exec'
import fs from 'fs'

export async function migrate(keepMigrationsFile: boolean): Promise<void> {
export async function migrate(keepMigrationsFile: boolean, legacyPeerDeps: boolean): Promise<void> {
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)
}
})

Expand Down

0 comments on commit 5f91f4a

Please sign in to comment.