From 1dfc6f33c11994e409828efb10a735609bd05f45 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Mon, 30 Jan 2023 17:46:49 -0600 Subject: [PATCH 1/3] chore: fix spacing after trash bin emoji --- __tests__/cmds/docs/prune.test.ts | 6 +++--- src/lib/deleteDoc.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__tests__/cmds/docs/prune.test.ts b/__tests__/cmds/docs/prune.test.ts index 8b71ca2db..5db19c3a7 100644 --- a/__tests__/cmds/docs/prune.test.ts +++ b/__tests__/cmds/docs/prune.test.ts @@ -88,7 +88,7 @@ describe('rdme docs:prune', () => { confirm: true, version, }) - ).resolves.toBe('šŸ—‘ļø successfully deleted `this-doc-should-be-missing-in-folder`.'); + ).resolves.toBe('šŸ—‘ļø successfully deleted `this-doc-should-be-missing-in-folder`.'); apiMocks.done(); versionMock.done(); @@ -116,7 +116,7 @@ describe('rdme docs:prune', () => { key, version, }) - ).resolves.toBe('šŸ—‘ļø successfully deleted `this-doc-should-be-missing-in-folder`.'); + ).resolves.toBe('šŸ—‘ļø successfully deleted `this-doc-should-be-missing-in-folder`.'); apiMocks.done(); versionMock.done(); @@ -151,7 +151,7 @@ describe('rdme docs:prune', () => { version, }) ).resolves.toBe( - 'šŸ—‘ļø successfully deleted `this-doc-should-be-missing-in-folder`.\nšŸ—‘ļø successfully deleted `this-child-is-also-missing`.' + 'šŸ—‘ļø successfully deleted `this-doc-should-be-missing-in-folder`.\nšŸ—‘ļø successfully deleted `this-child-is-also-missing`.' ); apiMocks.done(); diff --git a/src/lib/deleteDoc.ts b/src/lib/deleteDoc.ts index 974a89f1e..9d3d4ce81 100644 --- a/src/lib/deleteDoc.ts +++ b/src/lib/deleteDoc.ts @@ -36,5 +36,5 @@ export default async function deleteDoc( ), }) .then(handleRes) - .then(() => `šŸ—‘ļø successfully deleted \`${slug}\`.`); + .then(() => `šŸ—‘ļø successfully deleted \`${slug}\`.`); } From 66001a69b9abd7dffc5414114fca7cf804204f5d Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Mon, 30 Jan 2023 18:23:38 -0600 Subject: [PATCH 2/3] fix: move parent pages to the end of the deletion queue --- src/lib/getDocs.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/getDocs.ts b/src/lib/getDocs.ts index 91d5cfd46..fa76403ce 100644 --- a/src/lib/getDocs.ts +++ b/src/lib/getDocs.ts @@ -24,6 +24,11 @@ function flatten(data: Document[][]): Document[] { }); } }); + + // Docs with children cannot be deleted unless the children are deleted first, + // so move those parent docs to the back of the list + allDocs.sort(a => (a.children?.length ? 1 : -1)); + return allDocs; } From e0c407d7f0c66fc0900102e24bc522ba8865dcdf Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Mon, 30 Jan 2023 18:32:45 -0600 Subject: [PATCH 3/3] test: fix --- __tests__/cmds/docs/prune.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/cmds/docs/prune.test.ts b/__tests__/cmds/docs/prune.test.ts index 5db19c3a7..05c840b41 100644 --- a/__tests__/cmds/docs/prune.test.ts +++ b/__tests__/cmds/docs/prune.test.ts @@ -151,7 +151,7 @@ describe('rdme docs:prune', () => { version, }) ).resolves.toBe( - 'šŸ—‘ļø successfully deleted `this-doc-should-be-missing-in-folder`.\nšŸ—‘ļø successfully deleted `this-child-is-also-missing`.' + 'šŸ—‘ļø successfully deleted `this-child-is-also-missing`.\nšŸ—‘ļø successfully deleted `this-doc-should-be-missing-in-folder`.' ); apiMocks.done();