-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2550 from newrelic/mickey/NR-305852-quickstart-ids
feat: NR-305852 Check for missing quickstart IDs
- Loading branch information
Showing
4 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,6 @@ | |
} | ||
}, | ||
"required": [ | ||
"id", | ||
"description", | ||
"summary", | ||
"title", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as glob from 'glob'; | ||
import * as yaml from 'js-yaml'; | ||
|
||
import { QuickstartConfig } from './types/QuickstartConfig'; | ||
|
||
const getQuickstartPaths = () => | ||
glob.sync(path.resolve('..', 'quickstarts', '**', 'config.+(yml|yaml)')); | ||
|
||
const findMissingIds = (quickstartPaths: string[]) => { | ||
const quickstartsMissingIds: string[] = []; | ||
|
||
quickstartPaths.forEach((filePath) => { | ||
const config = yaml.load( | ||
fs.readFileSync(filePath).toString('utf-8') | ||
) as QuickstartConfig; | ||
|
||
if (!config.id) { | ||
quickstartsMissingIds.push(config.title); | ||
} | ||
}); | ||
|
||
return quickstartsMissingIds; | ||
}; | ||
|
||
const main = () => { | ||
const quickstartPaths = getQuickstartPaths(); | ||
const quickstartsMissingIds = findMissingIds(quickstartPaths); | ||
|
||
if (quickstartsMissingIds.length > 0) { | ||
console.log('\nThe following quickstarts are missing IDs:'); | ||
quickstartsMissingIds.forEach((title) => console.log(`\t- ${title}`)); | ||
|
||
process.exit(1); | ||
} | ||
|
||
console.log('[*] All quickstarts have IDs'); | ||
}; | ||
|
||
if (require.main === module) { | ||
main(); | ||
} |