From d77c711ddaf2e4abfb3e00cd913833dde9f706d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladan=20Tomi=C4=87?= Date: Tue, 28 Nov 2023 15:05:32 +0100 Subject: [PATCH] fix: manifest commands --- src/command/manifest/index.ts | 7 ++++++- src/command/manifest/remove.ts | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/command/manifest/index.ts b/src/command/manifest/index.ts index 6d940ae6..9fe617a5 100644 --- a/src/command/manifest/index.ts +++ b/src/command/manifest/index.ts @@ -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] } diff --git a/src/command/manifest/remove.ts b/src/command/manifest/remove.ts index 4ccae03a..302bc1a2 100644 --- a/src/command/manifest/remove.ts +++ b/src/command/manifest/remove.ts @@ -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 { + return this.console.confirmAndDelete( + `Deleting the ${mainPath} will result in deletion of the additional resources: \n\t${paths.join( + '\n\t', + )}\nContinue?`, + ) + } }