-
Notifications
You must be signed in to change notification settings - Fork 44
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(docs/upload): add safeguard if projects have bidi enabled #1175
base: next
Are you sure you want to change the base?
fix(docs/upload): add safeguard if projects have bidi enabled #1175
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few small outstanding things but this looks great on the whole!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😮💨 do you think we could make it so we split out the openapi changes into their own PR? and this PR is branched off of that PR?
const biDiConnection = projectMetadata.data.git?.connection; | ||
if (biDiConnection && !skipValidation) { | ||
throw new Error( | ||
"Bi-directional syncing is enabled for this project. Uploading these docs will overwrite what's currently synced from Git. To proceed with uploading via `rdme`, please use the `--skip-validation` flag.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Bi-directional syncing is enabled for this project. Uploading these docs will overwrite what's currently synced from Git. To proceed with uploading via `rdme`, please use the `--skip-validation` flag.", | |
"Bi-directional syncing is enabled for this project. Uploading these docs will overwrite what's currently synced from Git. To proceed with the upload, re-run this command with the `--skip-validation` flag.", |
"Bi-directional syncing is enabled for this project. Uploading these docs will overwrite what's currently synced from Git. To proceed with uploading via `rdme`, please use the `--skip-validation` flag.", | ||
); | ||
} | ||
|
||
if (skipValidation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on making it so this warning is only shown if bidi is not enabled? or maybe we have a separate warning for those users?
if (skipValidation) { | |
if (skipValidation && !bidiConnection) { |
return this.handleAPIRes(res); | ||
}); | ||
|
||
const biDiConnection = projectMetadata.data.git?.connection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just to be extra cautious:
const biDiConnection = projectMetadata.data.git?.connection; | |
const biDiConnection = projectMetadata?.data?.git?.connection; |
@@ -24,6 +24,9 @@ describe('rdme docs upload', () => { | |||
categories: {}, | |||
parentPages: {}, | |||
}); | |||
getAPIv2Mock({ authorization }).get('/projects/me').reply(200, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests are great, ty! could you also add a test case for if this initial /projects/me
request fails? i'll DM you an example error response that you can pull from shortly
## 🧰 Changes this PR updates our APIv2 openapi description as part of @emilyskuo's work in #1175 and chunks out the OAS into its own dedicated file since it's absolutely massive. you can check out the diff of the file changes [here](next...1346b8b). i tried messing around with JSON module imports so we can eventually automate these updates more easily, but we lose out on a lot of good strict typing that we currently have with `as const satisfies OASDocument`. annoying! ## 🧬 QA & Testing no functional changes. do tests still pass?
🧰 Changes
Adding in a safe guard for ReadMe projects with bidirectional sync enabled, since the docs frontmatter format is different for bidi. By default,
rdme docs upload
may try to "fix" things and modify the markdown files, which could result in corrupted data and/or syncing errors.Once https://github.com/readmeio/readme/pull/13869 is merged, we'll be exposing info on the project's bidi connection if it exists via the get project metadata (
/projects/me
) endpoint. This PR will introduce a check to see if a bidi connection exists, and throw an error if it does. If users want to continue uploading viardme
, they can use the--skip-validation
flag to do so without potential issues fromrdme
's validation & fixing steps.🧬 QA & Testing
Tested this against https://github.com/readmeio/readme/pull/13869 locally. Added some tests for
docs upload
as well.