-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use handlebars, split generate script
- Loading branch information
1 parent
c3f013a
commit 03330a6
Showing
20 changed files
with
629 additions
and
348 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"@actions/core": "npm:@actions/[email protected]", | ||
"@octokit/rest": "npm:@octokit/[email protected]", | ||
"ajv": "npm:[email protected]", | ||
"handlebars": "npm:[email protected]", | ||
"less": "npm:[email protected]", | ||
"usercss-meta": "npm:[email protected]" | ||
}, | ||
|
@@ -14,6 +15,6 @@ | |
"ci:sync-maintainers": "deno run -A ./scripts/sync-maintainers/main.ts", | ||
"lint": "deno run -A ./scripts/lint/main.ts", | ||
"lint:fix": "deno task lint --fix", | ||
"update-types": "deno run -A 'npm:json-schema-to-typescript' ./scripts/userstyles.schema.json ./scripts/types/userstyles.d.ts" | ||
"update-types": "deno run -A ./scripts/update-types.ts" | ||
} | ||
} |
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,50 @@ | ||
import { join } from "std/path/mod.ts"; | ||
|
||
import { REPO_ROOT } from "@/deps.ts"; | ||
import { updateFile } from "@/generate/utils.ts"; | ||
import { UserStylesSchema } from "@/types/mod.d.ts"; | ||
|
||
export const syncIssueLabels = (userstyles: UserStylesSchema.Userstyles) => { | ||
const ISSUE_PREFIX = "lbl:"; | ||
|
||
const issuesLabelerPath = join(REPO_ROOT, ".github/issue-labeler.yml"); | ||
const issuesLabelerContent = Object.entries(userstyles) | ||
.map(([key]) => `${key}: ["(${ISSUE_PREFIX + key})"]`) | ||
.join("\n"); | ||
updateFile(issuesLabelerPath, issuesLabelerContent); | ||
|
||
const userstyleIssuePath = join( | ||
REPO_ROOT, | ||
"scripts/generate/templates/userstyle-issue.yml", | ||
); | ||
const userstyleIssueContent = Deno.readTextFileSync(userstyleIssuePath); | ||
|
||
const replacedUserstyleIssueContent = userstyleIssueContent.replace( | ||
"$PORTS", | ||
`${ | ||
Object.entries(userstyles) | ||
.map(([key]) => `'${ISSUE_PREFIX + key}'`) | ||
.join(", ") | ||
}`, | ||
); | ||
Deno.writeTextFileSync( | ||
join(REPO_ROOT, ".github/ISSUE_TEMPLATE/userstyle.yml"), | ||
replacedUserstyleIssueContent, | ||
); | ||
|
||
const pullRequestLabelerPath = join(REPO_ROOT, ".github/pr-labeler.yml"); | ||
const pullRequestLabelerContent = Object.entries(userstyles) | ||
.map(([key]) => `${key}: styles/${key}/**/*`) | ||
.join("\n"); | ||
updateFile(pullRequestLabelerPath, pullRequestLabelerContent); | ||
|
||
const syncLabels = join(REPO_ROOT, ".github/labels.yml"); | ||
const syncLabelsContent = Object.entries(userstyles) | ||
.map( | ||
([key, style]) => | ||
`- name: ${key} | ||
description: ${style.name} | ||
color: "#8aadf4"`, | ||
).join("\n"); | ||
updateFile(syncLabels, syncLabelsContent); | ||
}; |
Oops, something went wrong.