-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
| 🚥 Resolves RM-11796, RM-11797 | | :------------------- | ## 🧰 Changes ### 🚧 outstanding work - [x] core command + helper logic - [x] tests - [x] loading states - [x] complete error messages - [x] docs - [x] migration guide (see #1161) - [x] callouts in `documentation/rdme.md` (see #1163) ### 🔜 to be addressed in follow-up PRs - [ ] safeguards for users that use bidirectional syncing (ticketed in RM-11883 and RM-11901) - [ ] updating the v9 migration guide + deprecation warnings (ticketed in RM-11902) ### things to call out - on a high level, we're mostly matching the functionality of v9's `rdme docs` in that we're just taking markdown files and sending its contents as a body payload to the ReadMe API. inferring page hierarchy from directory/file structure is out of scope for this work. - one big change from `rdme@9` is that we now validate page front matter against the schemas from our OAS before making any API requests and prompt the user to migrate any frontmatter that we recognize as legacy APIv1 attributes. i'm open to reevaluating this paradigm, but i think it'll be helpful for folks migrating. as an interim escape hatch, this command has a hidden `--skip-validation` flag, just in case. - our API expects category and parent page URIs to be a full URI (e.g., `/versions/stable/categories/guides/some-uri`), but that's a bit arduous for `rdme` users since most of the URI can be inferred from the `rdme` command context. as a result, `rdme` will automatically expand any category/parent URIs that don't match that pattern (i.e., a category URI front matter value of `some-uri` will be changed to `/versions/stable/categories/guides/some-uri` before we make the `POST`/`PATCH` request) - the vast majority of this diff is tests + fixtures + our OAS. the three files of note are: - `src/lib/syncPagePath.ts` - `src/lib/frontmatter.ts` - `src/commands/docs/upload.ts` - i've tried to build this in a testable and robust way where we can easily add support for reference pages, custom pages, etc. in the future - `PATCH` requests to our API (i.e., for making updates to guide pages) that include `slug` in the body payload will always rename the page. so if you have a slug called `some-page` and your body payload contains `some-page`, the API will change your slug to `some-page-1`. this is most likely unexpected behavior for users of `rdme`, so i'm **always** removing the slug from the body payload in favor of using the URL instead. the trade-off is that page renaming isn't really a thing via `rdme`, but that's why we support bidirectional syncing, right? ## 🧬 QA & Testing we're at nearly 100% test coverage with this work 📈 to QA it yourself, check out this branch and run the following: ```sh # install + set up npm ci npm run build ``` ```sh # grab an API key from a readme-refactored-enabled project and pop it at the end of this command: bin/run.js docs upload __tests__/__fixtures__/docs/mixed-docs --key <key> ```
- Loading branch information
1 parent
47988b7
commit 69f9c7e
Showing
32 changed files
with
7,953 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
__tests__/__fixtures__/docs/existing-docs/subdir/another-doc.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
--- | ||
title: This is another document title | ||
category: | ||
uri: /versions/stable/categories/guides/category-slug | ||
--- | ||
|
||
Another body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
category: | ||
uri: some-category-uri | ||
is-this-a-valid-property: nope | ||
title: This is the document title | ||
--- | ||
|
||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: 5ae122e10fdf4e39bb34db6f | ||
title: This is the document title | ||
--- | ||
|
||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
category: | ||
uri: some-category-uri | ||
title: This is the document title | ||
slug: some-slug | ||
--- | ||
|
||
Body |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: This is the document title | ||
--- | ||
|
||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
title: Child | ||
parentDocSlug: parent | ||
parent: | ||
uri: parent | ||
--- | ||
|
||
# Child Body | ||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
title: Friend | ||
--- | ||
|
||
# Friend Body | ||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
title: Grandparent | ||
--- | ||
|
||
# Grandparent Body | ||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
title: Parent | ||
parentDocSlug: grandparent | ||
parent: | ||
uri: grandparent | ||
--- | ||
|
||
# Parent Body | ||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
category: 5ae122e10fdf4e39bb34db6f | ||
category: | ||
uri: category-slug | ||
title: This is the document title | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
--- | ||
category: CATEGORY_ID | ||
category: | ||
uri: some-category-uri | ||
title: This is the document title | ||
slug: marc-actually-wrote-a-test | ||
slug: some-slug | ||
--- | ||
|
||
Body |
Oops, something went wrong.