Skip to content

Commit

Permalink
feat(scripts): Sort issue labels (#9423)
Browse files Browse the repository at this point in the history
feat(scripts): sort issue labels

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Jiralite and kodiakhq[bot] authored Apr 19, 2023
1 parent ecd1b5d commit a2ab2b8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/scripts/src/createPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ interface LabelerData {
name: string;
}

function sortYAMLObject(yaml: Record<string, string[]>) {
const sortedYAML: typeof yaml = {};
for (const key of Object.keys(yaml).sort((a, b) => a.localeCompare(b))) sortedYAML[key] = yaml[key]!;
return sortedYAML;
}

export async function createPackage(packageName: string, packageDescription?: string) {
const packageDir = join('packages', packageName);

Expand Down Expand Up @@ -75,19 +81,14 @@ export async function createPackage(packageName: string, packageDescription?: st
const labelerYAML = parseYAML(await readFile('labeler.yml', 'utf8')) as Record<string, string[]>;
labelerYAML[`packages:${packageName}`] = [`packages/${packageName}/*`, `packages/${packageName}/**/*`];

const sortedLabelerYAML: Record<string, string[]> = {};
for (const key of Object.keys(labelerYAML).sort((a, b) => a.localeCompare(b))) {
sortedLabelerYAML[key] = labelerYAML[key]!;
}

await writeFile('labeler.yml', stringifyYAML(sortedLabelerYAML));
await writeFile('labeler.yml', stringifyYAML(sortYAMLObject(labelerYAML)));

const issueLabelerYAML = parseYAML(await readFile('issue-labeler.yml', 'utf8')) as Record<string, string[]>;
issueLabelerYAML[`packages:${packageName}`] = [
`### Which package is this (bug report|feature request) for\\?\\n\\n${packageName}`,
];

await writeFile('issue-labeler.yml', stringifyYAML(issueLabelerYAML));
await writeFile('issue-labeler.yml', stringifyYAML(sortYAMLObject(issueLabelerYAML)));

// Move back to root
chdir('..');
Expand Down

0 comments on commit a2ab2b8

Please sign in to comment.