-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Check quickstart IDs in PR from release to main
- Loading branch information
Mickey Ryan
committed
Sep 11, 2024
1 parent
4cbbd1d
commit 5683e90
Showing
2 changed files
with
57 additions
and
1 deletion.
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
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(); | ||
} |