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

refactor: split out fixtures, test cleanup #542

Merged
merged 3 commits into from
Jul 25, 2022
Merged

Conversation

kanadgupta
Copy link
Member

🧰 Changes

Just some refactoring as part of the upcoming Changelog + Custom Pages functionality.

  • Refactoring our generic pushDoc function to support more routes and check for generic 404s as opposed to DOC_NOTFOUND errors
  • Some minor grammar + camelcasing changes (i.e. filePath instead of filepath)
  • Moving all the fixtures for the docs command into its own folder

🧬 QA & Testing

Do tests pass?

... so we can reuse it for Changelog! 🚀

No functional changes were made, docs tests should still pass.
@kanadgupta kanadgupta added refactor Issues about tackling technical debt command:docs Issues pertaining to the `docs`, `changelogs`, or `custompages` commands labels Jul 25, 2022
@kanadgupta kanadgupta requested a review from erunion July 25, 2022 23:35
@@ -8,12 +8,12 @@ const pushDoc = require('../../lib/pushDoc');
module.exports = class SingleDocCommand {
constructor() {
this.command = 'docs:single';
this.usage = 'docs:single <filepath> [options]';
this.usage = 'docs:single <file> [options]';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't <file> need to match the arg that we're going to be using (filePath in this case)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is just the string used for the usage example

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been so long since I've looked at this part of the code but how does it know to give you the first arg as filePath?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear I thought it was parsing the usage string to determine if things were required or not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this guy:

{
name: 'filePath',
type: String,
defaultOption: true,
},

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah there it is. Ignore me today!

@@ -62,7 +62,7 @@ module.exports = class SingleDocCommand {

debug(`selectedVersion: ${selectedVersion}`);

const createdDoc = await pushDoc(key, selectedVersion, dryRun, filepath);
const createdDoc = await pushDoc(key, selectedVersion, dryRun, filePath, this.category);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's this.category being set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We pass that into the pushDoc function so we can use it for dynamic routing:

return fetch(`${config.get('host')}/api/v1/${type}`, {

The idea is we can use a single handler for docs, changelogs, and custompages routes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH right, this.category is the category that it shows up in the help screen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol misread your question so my response didn't actually answer your question but yes, it's for the categories in the help screen

@kanadgupta kanadgupta merged commit da0f370 into main Jul 25, 2022
@kanadgupta kanadgupta deleted the split-out-fixtures branch July 25, 2022 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command:docs Issues pertaining to the `docs`, `changelogs`, or `custompages` commands refactor Issues about tackling technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants