diff --git a/CHANGELOG.md b/CHANGELOG.md index d0b3fa0..11808f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `--force` flag to `oneblink-release update-dependents` + ## [3.3.1] - 2025-05-06 ### Added diff --git a/src/bin.ts b/src/bin.ts index 0b4c2bc..3a723b7 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -73,10 +73,13 @@ ${chalk.grey('Update all product code bases that depend on an NPM package.')} to the current working directory, defaults to the current working directory. + --force ........ Update all dependencies without prompting the user. + ${chalk.bold('Examples')} oneblink-release update-dependents oneblink-release update-dependents --cwd ../path/to/code + oneblink-release update-dependents --force `, { importMeta: import.meta, @@ -106,6 +109,10 @@ ${chalk.bold('Examples')} type: 'string', default: process.cwd(), }, + force: { + type: 'boolean', + default: false, + }, }, }, ) @@ -148,6 +155,7 @@ async function run(): Promise { case 'update-dependents': { await startUpdateDependents({ cwd, + force: cli.flags.force, }) break } diff --git a/src/startUpdateDependents.ts b/src/startUpdateDependents.ts index cb36234..f7b1efb 100644 --- a/src/startUpdateDependents.ts +++ b/src/startUpdateDependents.ts @@ -5,7 +5,13 @@ import enquirer from 'enquirer' import executeCommand from './executeCommand.js' import boxen from 'boxen' -export default async function startUpdateDependents({ cwd }: { cwd: string }) { +export default async function startUpdateDependents({ + cwd, + force = false, +}: { + cwd: string + force?: boolean +}) { const dependencyRepositoryPlugin = await getRepositoryPlugin({ cwd, }) @@ -95,23 +101,32 @@ export default async function startUpdateDependents({ cwd }: { cwd: string }) { return } - const { isUpdating } = await enquirer.prompt<{ - isUpdating: 'yes' | 'no' - }>({ - type: 'select', - name: 'isUpdating', - message: `Would you like to update "${dependency}" in "${productRepository.repositoryName}" (${currentDependencyVersion} > ${dependencyResult.packageJson.version})?`, - choices: [ - { - message: 'Yes, update dependency!', - name: 'yes', - }, - { - message: `No! "${productRepository.repositoryName}" does not need to be updated.`, - name: 'no', - }, - ], - }) + let isUpdating: 'yes' | 'no' + if (force) { + isUpdating = 'yes' + console.log( + `Auto-updating "${dependency}" in "${productRepository.repositoryName}" (${currentDependencyVersion} > ${dependencyResult.packageJson.version})`, + ) + } else { + const updateResult = await enquirer.prompt<{ + isUpdating: 'yes' | 'no' + }>({ + type: 'select', + name: 'isUpdating', + message: `Would you like to update "${dependency}" in "${productRepository.repositoryName}" (${currentDependencyVersion} > ${dependencyResult.packageJson.version})?`, + choices: [ + { + message: 'Yes, update dependency!', + name: 'yes', + }, + { + message: `No! "${productRepository.repositoryName}" does not need to be updated.`, + name: 'no', + }, + ], + }) + isUpdating = updateResult.isUpdating + } if (isUpdating === 'no') { return }