Skip to content

Commit 88e0c93

Browse files
fix: import labels.json in setup (#548)
## PR Checklist - [x] Addresses an existing open issue: fixes #547 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/template-typescript-node-package/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Imports from the local `./labels.json` instead of reading the file as JSON. This is actually a bit simpler as an approach!
1 parent 42a5c54 commit 88e0c93

File tree

7 files changed

+91
-102
lines changed

7 files changed

+91
-102
lines changed

cspell.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"CHANGELOG.md",
77
"lib",
88
"node_modules",
9-
"pnpm-lock.yaml",
10-
"src/setup/*.json"
9+
"pnpm-lock.yaml"
1110
],
1211
"words": [
1312
"Codecov",

src/hydrate/steps/writing/creation/rootFiles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
299299
module: "esnext",
300300
moduleResolution: "node",
301301
outDir: "lib",
302+
resolveJsonModule: true,
302303
skipLibCheck: true,
303304
sourceMap: true,
304305
strict: true,

src/setup/labels.json

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/setup/steps/labels/hydrateRepositoryLabels.test.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@ vi.mock("execa", () => ({
1010
},
1111
}));
1212

13-
const mockReadFileAsJson = vi.fn().mockResolvedValue([
14-
{
15-
color: "000000",
16-
description: "def ghi",
17-
name: "abc",
18-
},
19-
]);
20-
21-
vi.mock("../../../shared/readFileAsJson.js", () => ({
22-
get readFileAsJson() {
23-
return mockReadFileAsJson;
24-
},
13+
vi.mock("./outcomeLabels.js", () => ({
14+
outcomeLabels: [
15+
{
16+
color: "000000",
17+
description: "def ghi",
18+
name: "abc",
19+
},
20+
],
2521
}));
2622

2723
describe("hydrateRepositoryLabels", () => {

src/setup/steps/labels/hydrateRepositoryLabels.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import { $ } from "execa";
22

3-
import { readFileAsJson } from "../../../shared/readFileAsJson.js";
43
import { getExistingEquivalentLabel } from "./getExistingEquivalentLabel.js";
4+
import { outcomeLabels } from "./outcomeLabels.js";
55

66
interface GhLabelData {
77
name: string;
88
}
99

10-
interface FileLabelData {
11-
color: string;
12-
description: string;
13-
name: string;
14-
}
15-
1610
export async function hydrateRepositoryLabels() {
1711
const getLabelName = (label: { name: string }) => label.name;
1812

@@ -22,10 +16,6 @@ export async function hydrateRepositoryLabels() {
2216
) as GhLabelData[]
2317
).map(getLabelName);
2418

25-
const outcomeLabels = (await readFileAsJson(
26-
"./src/setup/labels.json"
27-
)) as FileLabelData[];
28-
2919
for (const outcome of outcomeLabels) {
3020
const existingEquivalent = getExistingEquivalentLabel(
3121
existingLabels,
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* spellchecker: disable */
2+
export const outcomeLabels = [
3+
{
4+
color: "0075ca",
5+
description: "Improvements or additions to docs",
6+
name: "area: documentation",
7+
},
8+
{
9+
color: "6009D7",
10+
description:
11+
"Improving how the repository's tests are run and/or code is tested",
12+
name: "area: testing",
13+
},
14+
{
15+
color: "f9d0c4",
16+
description: "Managing the repository's maintenance",
17+
name: "area: tooling",
18+
},
19+
{
20+
color: "5319E7",
21+
description: "Good for newcomers, please hop on!",
22+
name: "good first issue",
23+
},
24+
{
25+
color: "7a5901",
26+
description: "This doesn't seem right",
27+
name: "invalid",
28+
},
29+
{
30+
color: "0E8A16",
31+
description: "Please, send a pull request to resolve this!",
32+
name: "status: accepting prs",
33+
},
34+
{
35+
color: "#ddcccc",
36+
description: "Waiting for something else to be resolved",
37+
name: "status: blocked",
38+
},
39+
{
40+
color: "cfd3d7",
41+
description: "This issue or pull request already exists",
42+
name: "status: duplicate",
43+
},
44+
{
45+
color: "#05104F",
46+
description: "Not yet ready for implementation or a pull request",
47+
name: "status: in discussion",
48+
},
49+
{
50+
color: "D3F82D",
51+
description: "Further research required...?",
52+
name: "status: needs investigation",
53+
},
54+
{
55+
color: "E4BC82",
56+
description: "Needs an action taken by the original poster",
57+
name: "status: waiting for author",
58+
},
59+
{
60+
color: "ffffff",
61+
description: "This will not be worked on",
62+
name: "status: wontfix",
63+
},
64+
{
65+
color: "d73a4a",
66+
description: "Something isn't working :(",
67+
name: "type: bug",
68+
},
69+
{
70+
color: "a2eeef",
71+
description: "New enhancement or request",
72+
name: "type: feature",
73+
},
74+
{
75+
color: "d876e3",
76+
description: "Further information is requested",
77+
name: "type: question",
78+
},
79+
];

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"module": "esnext",
77
"moduleResolution": "node",
88
"outDir": "lib",
9+
"resolveJsonModule": true,
910
"skipLibCheck": true,
1011
"sourceMap": true,
1112
"strict": true,

0 commit comments

Comments
 (0)