Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: manifest commands #483

Merged
merged 1 commit into from
Nov 29, 2023
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
7 changes: 6 additions & 1 deletion src/command/manifest/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { GroupCommand } from 'furious-commander'
import { Add } from './add'
import { Create } from './create'
import { Download } from './download'
import { List } from './list'
import { Merge } from './merge'
import { Remove } from './remove'
import { Sync } from './sync'

export class Manifest implements GroupCommand {
public readonly name = 'manifest'
public readonly description = 'Operate on manifests'

public subCommandClasses = [Download, List]
public subCommandClasses = [Add, Create, Download, List, Merge, Remove, Sync]
}
18 changes: 18 additions & 0 deletions src/command/manifest/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,27 @@ export class Remove extends ManifestCommand implements LeafCommand {
const forks = this.findAllValueForks(node)
for (const fork of forks) {
if (fork.path === address.path || fork.path.startsWith(address.path + '/')) {
const childPaths = this.findAllValueForks(fork.node).map(({ path }) => fork.path + path)

if (childPaths.length > 0) {
const confirmed = await this.promptAdditionalFileDelete(fork.path, childPaths)

if (!confirmed) {
continue
}
}

node.removePath(this.encodePath(fork.path))
}
}
await this.saveAndPrintNode(node, this.stamp)
}

protected promptAdditionalFileDelete(mainPath: string, paths: string[]): Promise<boolean> {
return this.console.confirmAndDelete(
`Deleting the ${mainPath} will result in deletion of the additional resources: \n\t${paths.join(
'\n\t',
)}\nContinue?`,
)
}
}
Loading