build(docs-infra): fail hard if the CLI source is not what we expect (#30901)
Previously we just logged a warning but we should fail to prevent silently allowing the docs to look wrong if something changes on the CLI side of things. PR Close #30901
This commit is contained in:
parent
64488b12ac
commit
297222f892
@ -9,7 +9,7 @@
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
module.exports = function cliCommandFileReader(log) {
|
module.exports = function cliCommandFileReader() {
|
||||||
const json5 = require('json5');
|
const json5 = require('json5');
|
||||||
return {
|
return {
|
||||||
name: 'cliCommandFileReader',
|
name: 'cliCommandFileReader',
|
||||||
@ -38,7 +38,8 @@ module.exports = function cliCommandFileReader(log) {
|
|||||||
}
|
}
|
||||||
return [result];
|
return [result];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.warn(`Failed to read cli command file: "${fileInfo.relativePath}" - ${e.message}`);
|
throw new Error(
|
||||||
|
`Failed to read cli command file: "${fileInfo.relativePath}" - ${e.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -58,12 +59,13 @@ module.exports = function cliCommandFileReader(log) {
|
|||||||
* file, which was passed to the `cliCommandFileReader.getDocs()` method.
|
* file, which was passed to the `cliCommandFileReader.getDocs()` method.
|
||||||
*/
|
*/
|
||||||
function createLongDescriptionDoc(fileInfo) {
|
function createLongDescriptionDoc(fileInfo) {
|
||||||
try {
|
const path = require('canonical-path');
|
||||||
const path = require('canonical-path');
|
const fs = require('fs');
|
||||||
const fs = require('fs');
|
const json5 = require('json5');
|
||||||
const json5 = require('json5');
|
|
||||||
|
|
||||||
const schemaJsonPath = path.resolve(fileInfo.basePath, '../commands', fileInfo.relativePath);
|
const schemaJsonPath = path.resolve(fileInfo.basePath, '../commands', fileInfo.relativePath);
|
||||||
|
|
||||||
|
try {
|
||||||
const schemaJson = fs.readFileSync(schemaJsonPath);
|
const schemaJson = fs.readFileSync(schemaJsonPath);
|
||||||
const schema = json5.parse(schemaJson);
|
const schema = json5.parse(schemaJson);
|
||||||
if (schema.$longDescription) {
|
if (schema.$longDescription) {
|
||||||
@ -77,8 +79,8 @@ module.exports = function cliCommandFileReader(log) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.warn('Unable to read CLI long description file info', e, fileInfo);
|
throw new Error(
|
||||||
return undefined;
|
`Unable to read CLI "$longDescription" info from the schema: "${schemaJsonPath}" - ${e.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user