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

Don't throw if a doc hasn't been versioned yet #455

Merged
merged 1 commit into from
Feb 17, 2018

Conversation

JoelMarcey
Copy link
Contributor

Instead of throwing, return null because that means we have a
new doc in our versioning sequence

(Also, cleaned up a bit of code as I researched this)

Fixes #450

Motivation

We had a showstopping bug where versioning would not work if you tried to add a new file to the documentation set.

Test Plan

Versioned a set of docs as 1.0.0
Added a new doc to the master set
Ran

npm run version 2.0.0

The new doc was part of version 2.0.0

Related PRs

N/A

Instead of throwing, return `null` because that means we have a
new doc in our versioning sequence

(Also, cleaned up a bit of code as I researched this)

Fixes facebook#450
@@ -96,8 +96,7 @@ files.forEach(file => {
metadata.original_id = metadata.id;
metadata.id = 'version-' + version + '-' + metadata.id;

const targetFile =
CWD + '/versioned_docs/version-' + version + '/' + path.basename(file);
const targetFile = versionFolder + '/' + path.basename(file);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

versionFolder is defined above as:

const versionFolder = CWD + '/versioned_docs/version-' + version;

So might as well not repeat the same full path again.

@iRoachie
Copy link
Contributor

This fix enables the version script to run correctly. However it still throws on build if the newly created document is specified in the sidebar.

Here's the output:
output.txt

Whatever process generates docusaurus/lib/core/metadata.js, it doesn't include the new files added.

@JoelMarcey
Copy link
Contributor Author

@iRoachie and I discussed this on our Discord channel. It looks like the build problem is coming down to how @iRoachie was naming his versions.

[
  "1.0.0-beta2",
  "0.19"
]

So we are bugging out parsing these somehow. We are looking to see what is going on.

@iRoachie
Copy link
Contributor

Video showing the creation process and the resulting bug. https://www.useloom.com/share/5bcc2a1575694d76b034af9ad1b2d116

@JoelMarcey
Copy link
Contributor Author

I have a fix for the other raised issue here. I am going to send that in another PR.

I am going to land this PR to make any revert easier, if needed.

@JoelMarcey JoelMarcey merged commit 1388e13 into facebook:master Feb 17, 2018
JoelMarcey added a commit to JoelMarcey/Docusaurus that referenced this pull request Feb 17, 2018
Right now we were assuming that there would be no `-` in a version.
That was breaking things.

This allows more flexibility for versions like:

1.0.0-beta.2

Ref facebook#455
Fixes facebook#450
JoelMarcey added a commit that referenced this pull request Feb 17, 2018
* Allow multiple `-` in a version string

Right now we were assuming that there would be no `-` in a version.
That was breaking things.

This allows more flexibility for versions like:

1.0.0-beta.2

Ref #455
Fixes #450

* Check more specific strings - need to look for the original_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants