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

build(docs-infra): fail hard if the CLI source is not what we expect #30901

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions aio/tools/transforms/cli-docs-package/readers/cli-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* }
* ```
*/
module.exports = function cliCommandFileReader(log) {
module.exports = function cliCommandFileReader() {
const json5 = require('json5');
return {
name: 'cliCommandFileReader',
Expand Down Expand Up @@ -38,7 +38,8 @@ module.exports = function cliCommandFileReader(log) {
}
return [result];
} 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}`);
}
}
};
Expand All @@ -58,12 +59,13 @@ module.exports = function cliCommandFileReader(log) {
* file, which was passed to the `cliCommandFileReader.getDocs()` method.
*/
function createLongDescriptionDoc(fileInfo) {
try {
const path = require('canonical-path');
const fs = require('fs');
const json5 = require('json5');
const path = require('canonical-path');
const fs = require('fs');
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 schema = json5.parse(schemaJson);
if (schema.$longDescription) {
Expand All @@ -77,8 +79,8 @@ module.exports = function cliCommandFileReader(log) {
};
}
} catch (e) {
log.warn('Unable to read CLI long description file info', e, fileInfo);
return undefined;
throw new Error(
`Unable to read CLI "$longDescription" info from the schema: "${schemaJsonPath}" - ${e.message}`);
}
}
};