mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
Update messages for versioning
This commit is contained in:
parent
cdea25eceb
commit
88359ea845
3 changed files with 16 additions and 7 deletions
|
@ -56,7 +56,9 @@ function readCategories(sidebar) {
|
|||
if (metadata.next) {
|
||||
if (!articles[metadata.next]) {
|
||||
throw new Error(
|
||||
"Improper sidebars.json file. Make sure that documents with the ids specified in sidebars.json exist and that no ids are repeated."
|
||||
metadata.version
|
||||
? `Improper sidebars file for version ${metadata.version}. Make sure that all documents with ids specified in this version's sidebar file exist and that no ids are repeated.`
|
||||
: `Improper sidebars.json file. Make sure that documents with the ids specified in sidebars.json exist and that no ids are repeated.`
|
||||
);
|
||||
}
|
||||
previous[articles[metadata.next].id] = metadata.id;
|
||||
|
|
|
@ -20,7 +20,7 @@ const ENABLE_TRANSLATION = fs.existsSync(CWD + "/languages.js");
|
|||
|
||||
let versions;
|
||||
if (fs.existsSync(CWD + "/versions.json")) {
|
||||
versions = require(CWD + "/versions.json");
|
||||
versions = require(CWD + "/versions.json");
|
||||
} else {
|
||||
versions = [];
|
||||
}
|
||||
|
@ -124,7 +124,9 @@ function docVersion(id, req_version) {
|
|||
return versions[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
throw new Error(
|
||||
`No document available to use for version ${req_version} of document with id ${id}. Verify that all version files are correct.`
|
||||
);
|
||||
}
|
||||
|
||||
// returns whether a given file has content that differ from the
|
||||
|
@ -226,7 +228,7 @@ function docData() {
|
|||
// return the version of the sidebar to use given a requested version
|
||||
function sidebarVersion(req_version) {
|
||||
// iterate through versions until a version less than or equal to the requested
|
||||
// is found, then check if that verison has an available file to use
|
||||
// is found, then check if that version has an available file to use
|
||||
let requestedFound = false;
|
||||
for (let i = 0; i < versions.length; i++) {
|
||||
if (versions[i] === req_version) {
|
||||
|
@ -243,7 +245,9 @@ function sidebarVersion(req_version) {
|
|||
return versions[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
throw new Error(
|
||||
`No sidebar file available to use for version ${req_version}. Verify that all version files are correct.`
|
||||
);
|
||||
}
|
||||
|
||||
// return whether or not the current sidebars.json file differs from the
|
||||
|
|
|
@ -13,6 +13,7 @@ const glob = require("glob");
|
|||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const mkdirp = require("mkdirp");
|
||||
const chalk = require("chalk");
|
||||
const readMetadata = require("./server/readMetadata.js");
|
||||
const versionFallback = require("./server/versionFallback.js");
|
||||
|
||||
|
@ -36,14 +37,14 @@ program
|
|||
|
||||
if (typeof version === "undefined") {
|
||||
console.error(
|
||||
"No version number specified!\nPass the version you wish to create as an argument.\nEx: 1.0.0"
|
||||
`${chalk.yellow("No version number specified!")}\nPass the version you wish to create as an argument.\nEx: 1.0.0`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (versions.includes(version)) {
|
||||
console.error(
|
||||
"This verison already exists!\nSpecify a new version to create that does not already exist."
|
||||
`${chalk.yellow("This version already exists!")}\nSpecify a new version to create that does not already exist.`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
@ -120,3 +121,5 @@ if (versionFallback.diffLatestSidebar()) {
|
|||
// update versions.json file
|
||||
versions.unshift(version);
|
||||
fs.writeFileSync(CWD + "/versions.json", JSON.stringify(versions, null, 2));
|
||||
|
||||
console.log(`${chalk.green("Version " + version + " created!\n")}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue