Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -106,6 +109,10 @@ ${chalk.bold('Examples')}
type: 'string',
default: process.cwd(),
},
force: {
type: 'boolean',
default: false,
},
},
},
)
Expand Down Expand Up @@ -148,6 +155,7 @@ async function run(): Promise<void> {
case 'update-dependents': {
await startUpdateDependents({
cwd,
force: cli.flags.force,
})
break
}
Expand Down
51 changes: 33 additions & 18 deletions src/startUpdateDependents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down Expand Up @@ -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
}
Expand Down