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

Prune command doesn't remove child pages (and their parent pages) #710

Closed
colmdoyle opened this issue Dec 12, 2022 · 3 comments · Fixed by #713
Closed

Prune command doesn't remove child pages (and their parent pages) #710

colmdoyle opened this issue Dec 12, 2022 · 3 comments · Fixed by #713
Labels
API Underlying issue is with the ReadMe API and not necessarily the `rdme` client itself bug Something isn't working command:docs Issues pertaining to the `docs`, `changelogs`, or `custompages` commands

Comments

@colmdoyle
Copy link

When pruning docs, the relevant block of code queries getCategoryDocs which returns top level pages, but not the child pages inside that category, meaning the command doesn't cascade out and detect child pages for deletion.

Repro

  1. Create a category with a page, and a child page of that page.
  2. Sync it to Readme
  3. Delete the files from your local filesystem
  4. run rdme docs:prune [path-to-directory-of-markdown]
  5. See that childPage is still on readme, as is the parent doc

(step 5 is kind of expected because you can't have a hanging page like that, but the CLI doesn't even know to delete the child page first)

rdme/src/lib/getDocs.ts

Lines 40 to 46 in d1f6c03

export default async function getDocs(key: string, selectedVersion: string): Promise<Document[]> {
return getCategories(key, selectedVersion)
.then(categories => categories.filter(({ type }: { type: string }) => type === 'guide'))
.then(categories => categories.map(({ slug }: { slug: string }) => getCategoryDocs(key, selectedVersion, slug)))
.then(categoryDocsPromises => Promise.all(categoryDocsPromises))
.then(flatten);
}

@kanadgupta kanadgupta added bug Something isn't working command:docs Issues pertaining to the `docs`, `changelogs`, or `custompages` commands labels Dec 12, 2022
@kanadgupta
Copy link
Member

Thanks for the detailed write-up, @colmdoyle! I briefly investigated and it looks like this is because our GET /categories/{slug}/docs endpoint returns child pages within the children array of the respective parent page and we failed to account for that. Here's what the response looks like for the first category of our docs:

[
  {
    "title": "Intro to ReadMe",
    "slug": "intro-to-readme",
    "order": 0,
    "hidden": false,
    "children": []
  },
  {
    "title": "Best Practices",
    "slug": "best-practices",
    "order": 1,
    "hidden": false,
    "children": []
  },
  {
    "title": "Use Cases Overview",
    "slug": "use-cases-overview",
    "order": 2,
    "hidden": false,
    "children": []
  },
  {
    "title": "Features Overview",
    "slug": "features-overview",
    "order": 3,
    "hidden": false,
    "children": []
  },
  {
    "title": "Navigating Your Hub",
    "slug": "navigating-your-hub",
    "order": 4,
    "hidden": false,
    "children": [
      {
        "title": "Search + Search API",
        "slug": "search",
        "order": 0,
        "hidden": false
      },
      {
        "title": "Quick Nav in the API Reference",
        "slug": "quick-nav-api-reference",
        "order": 1,
        "hidden": false
      }
    ]
  }
]

@kanadgupta kanadgupta added the API Underlying issue is with the ReadMe API and not necessarily the `rdme` client itself label Dec 12, 2022
@colmdoyle
Copy link
Author

Yep, that's the same conclusion I came to as well!

@kanadgupta
Copy link
Member

Just tagged 8.3.1, which should resolve this issue. Thanks for writing in about this @colmdoyle!

https://github.com/readmeio/rdme/releases/tag/8.3.1
https://www.npmjs.com/package/rdme/v/8.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Underlying issue is with the ReadMe API and not necessarily the `rdme` client itself bug Something isn't working command:docs Issues pertaining to the `docs`, `changelogs`, or `custompages` commands
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants