Dough Git

commit

Use JPCL for the config files

commit
5cc1a52f2dd9c76207fe8ab770e925eb7691a845
author
Clove Twilight <[email protected]>
date
2026-11-18 05:51
Move config/messages.json and config/unsupportedCnames.json to .jp
files parsed with jpcl-lang. The CNAME list now sits under a hosts key.
Fallback wording is read once from the committed messages.jp, because
Vite cannot bundle a .jp import.

Co-Authored-By: Sandrone <[email protected]>

diff --git a/.env.example b/.env.example
index 8faa947..7ce5134 100644
--- a/.env.example
+++ b/.env.example
@@ -29,7 +29,7 @@ ORIGIN=http://localhost:3101
 POLL_INTERVAL_SECONDS=120
 SCANNER_ENABLED=true
 DATABASE_PATH=data/tracker.sqlite
-MESSAGES_PATH=config/messages.json
-UNSUPPORTED_CNAMES_PATH=config/unsupportedCnames.json
+MESSAGES_PATH=config/messages.jp
+UNSUPPORTED_CNAMES_PATH=config/unsupportedCnames.jp
 NS_MIN_MERGED_PRS=1
 MAX_FILES_PER_PR=25
diff --git a/README.md b/README.md
index 2785c00..01e5975 100644
--- a/README.md
+++ b/README.md
@@ -52,15 +52,15 @@ done, and nothing is sent to GitHub.
 
 ## Wording
 
-Edit `config/messages.json`. Changes apply on the next action, with no restart.
+Edit `config/messages.jp` ([JPCL](https://www.npmjs.com/package/jpcl-lang)). Changes apply on the next action, with no restart.
 
 Once a contributor fixes a change request, the next scan dismisses that review with the rule's
 `reviewDismissal` wording and marks the finding resolved.
 
 ## Unsupported CNAME targets
 
-List hosts in `config/unsupportedCnames.json` as a JSON array, for example
-`["vercel.app", "example.com"]`. A CNAME matches an entry or any subdomain of it.
+List hosts in `config/unsupportedCnames.jp` under `hosts`, for example
+`hosts: ["vercel.app", "example.com"]`. A CNAME matches an entry or any subdomain of it.
 Changes apply on the next scan. An empty list turns the rule off.
 
 ## Avatar
@@ -95,7 +95,7 @@ the other open violations on the same PR.
 1. Add a module in `src/lib/server/rules/` that exports a `Rule`.
 2. Register it in `src/lib/server/rules/index.ts`.
 3. Give it a `severity` from 1 (low) to 3 (high).
-4. A `requestChanges` rule needs a `findLine` and wording in `config/messages.json`
+4. A `requestChanges` rule needs a `findLine` and wording in `config/messages.jp`
    (`reviewComment`, `reviewSummary` and `reviewDismissal`).
 5. If it needs a new kind of action, add an executor in `src/lib/server/moderation/executors.ts`.
 
diff --git a/config/messages.jp b/config/messages.jp
new file mode 100644
index 0000000..c388fad
--- /dev/null
+++ b/config/messages.jp
@@ -0,0 +1,14 @@
+# config/messages.jp
+
+[nsRecords]
+closeComment: "Thanks for your interest in is-a.dev!\n\nThis pull request requests `NS` records. We do not grant nameserver records to first-time contributors, so I am closing this pull request.\n\nYou are welcome to open a new pull request using other record types, such as `A`, `AAAA`, `CNAME`, `MX` or `TXT`. Once you have an accepted registration, you can request `NS` records with a clear justification for why they are needed.\n\nPlease see the [Docs](https://docs.is-a.dev/faq/#who-can-use-ns-records) for more information.\n<sub>This comment was sent with an [automated tool](https://doughmination.gay/automated), and approved by a human. I do not see replies.</sub>"
+
+[unsupportedCname]
+reviewComment: "Your `CNAME` record points at a host that we do not support. Please point it at a supported host, or use another record type such as `A` or `AAAA`.\n\nIf you have requested a CloudFlare Worker, please use a legacy CloudFlare Pages project."
+reviewDismissal: "Thanks, the `CNAME` record is fixed. Dismissing the requested changes."
+reviewSummary: "Please see the inline comment on `CNAME`.\n<sub>This comment was sent with an [automated tool](https://doughmination.gay/automated), and approved by a human. I do not see replies.</sub>"
+
+[noReplyEmail]
+reviewComment: "Your `owner.email` value is a GitHub no-reply email address. We do not allow these on our service. Please update it to a personal email address or remove the `owner.email` field entirely, as it is optional."
+reviewDismissal: "Thanks, `owner.email` is fixed. Dismissing the requested changes."
+reviewSummary: "Please see the inline comment on `owner.email`.\n<sub>This comment was sent with an [automated tool](https://doughmination.gay/automated), and approved by a human. I do not see replies.</sub>"
diff --git a/config/messages.json b/config/messages.json
deleted file mode 100644
index 0666215..0000000
--- a/config/messages.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-	"nsRecords": {
-		"closeComment": "Thanks for your interest in is-a.dev!\n\nThis pull request requests `NS` records. We do not grant nameserver records to first-time contributors, so I am closing this pull request.\n\nYou are welcome to open a new pull request using other record types, such as `A`, `AAAA`, `CNAME`, `MX` or `TXT`. Once you have an accepted registration, you can request `NS` records with a clear justification for why they are needed.\n\nPlease see the [Docs](https://docs.is-a.dev/faq/#who-can-use-ns-records) for more information.\n<sub>This comment was sent with an [automated tool](https://doughmination.gay/automated), and approved by a human. I do not see replies.</sub>"
-	},
-	"unsupportedCname": {
-		"reviewComment": "Your `CNAME` record points at a host that we do not support. Please point it at a supported host, or use another record type such as `A` or `AAAA`.\n\nIf you have requested a CloudFlare Worker, please use a legacy CloudFlare Pages project.",
-		"reviewDismissal": "Thanks, the `CNAME` record is fixed. Dismissing the requested changes.",
-		"reviewSummary": "Please see the inline comment on `CNAME`.\n<sub>This comment was sent with an [automated tool](https://doughmination.gay/automated), and approved by a human. I do not see replies.</sub>"
-	},
-	"noReplyEmail": {
-		"reviewComment": "Your `owner.email` value is a GitHub no-reply email address. We do not allow these on our service. Please update it to a personal email address or remove the `owner.email` field entirely, as it is optional.",
-		"reviewDismissal": "Thanks, `owner.email` is fixed. Dismissing the requested changes.",
-		"reviewSummary": "Please see the inline comment on `owner.email`.\n<sub>This comment was sent with an [automated tool](https://doughmination.gay/automated), and approved by a human. I do not see replies.</sub>"
-	}
-}
diff --git a/config/unsupportedCnames.jp b/config/unsupportedCnames.jp
new file mode 100644
index 0000000..4b739b2
--- /dev/null
+++ b/config/unsupportedCnames.jp
@@ -0,0 +1,21 @@
+# config/unsupportedCnames.jp
+# A CNAME matches an entry or any subdomain of it
+
+hosts: [
+  ".adult",
+  ".blob.core.windows.net",
+  ".cf",
+  ".cfargotunnel.com",
+  ".ga",
+  ".gq",
+  ".ml",
+  ".porn",
+  ".r2.dev",
+  ".sex",
+  ".sexy",
+  ".trycloudflare.com",
+  ".tk",
+  ".workers.dev",
+  ".xxx",
+  ".ts.net"
+]
diff --git a/config/unsupportedCnames.json b/config/unsupportedCnames.json
deleted file mode 100644
index f771dcf..0000000
--- a/config/unsupportedCnames.json
+++ /dev/null
@@ -1,18 +0,0 @@
-[
-	".adult",
-	".blob.core.windows.net",
-	".cf",
-	".cfargotunnel.com",
-	".ga",
-	".gq",
-	".ml",
-	".porn",
-	".r2.dev",
-	".sex",
-	".sexy",
-	".trycloudflare.com",
-	".tk",
-	".workers.dev",
-	".xxx",
-	".ts.net"
-]
diff --git a/deno.lock b/deno.lock
index b8358b4..05ac268 100644
--- a/deno.lock
+++ b/deno.lock
@@ -11,6 +11,7 @@
     "npm:eslint-plugin-svelte@^3.19.0": "[email protected][email protected]",
     "npm:eslint@^10.4.1": "10.14.0",
     "npm:globals@^17.6.0": "17.14.0",
+    "npm:jpcl-lang@^1.1.1": "1.1.1",
     "npm:prettier-plugin-svelte@^4.1.0": "[email protected][email protected]",
     "npm:prettier@^3.8.3": "3.10.0",
     "npm:svelte-check@^4.6.0": "[email protected][email protected]",
@@ -851,6 +852,10 @@
     "[email protected]": {
       "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
     },
+    "[email protected]": {
+      "integrity": "sha512-WyED4bjuNuWr+oKi0+3iIY2EinGk/VsZj4AP4XY8PrvPhzCL3aSBJSZcZ5pDz2Myf+JW8AN5omEIjSyjGMupIQ==",
+      "bin": true
+    },
     "[email protected]": {
       "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
     },
@@ -1067,8 +1072,7 @@
       "integrity": "sha512-Khh/tERVBn0I1499dvBSHY0pWJloMJWUxDsOBM0CCDPAcVZ10Jl2L1qy1f19uEX22spa8Mv7DCdEQJc0cGwBhQ==",
       "dependencies": [
         "util-deprecate"
-      ],
-      "deprecated": true
+      ]
     },
     "[email protected]": {
       "integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==",
@@ -1331,6 +1335,7 @@
         "npm:eslint-plugin-svelte@^3.19.0",
         "npm:eslint@^10.4.1",
         "npm:globals@^17.6.0",
+        "npm:jpcl-lang@^1.1.1",
         "npm:prettier-plugin-svelte@^4.1.0",
         "npm:prettier@^3.8.3",
         "npm:svelte-check@^4.6.0",
diff --git a/package.json b/package.json
index e5afab3..b356d78 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,8 @@
 		"format": "prettier --write ."
 	},
 	"dependencies": {
-		"discord.js": "^14.28.1"
+		"discord.js": "^14.28.1",
+		"jpcl-lang": "^1.1.1"
 	},
 	"devDependencies": {
 		"@eslint/js": "^10.0.1",
diff --git a/src/lib/server/config.ts b/src/lib/server/config.ts
index 9b98731..20b1bc4 100644
--- a/src/lib/server/config.ts
+++ b/src/lib/server/config.ts
@@ -55,8 +55,8 @@ export function getConfig(): AppConfig {
 		discordUserId: readText('DISCORD_USER_ID'),
 		discordChannelId: readText('DISCORD_CHANNEL_ID'),
 		databasePath: readText('DATABASE_PATH', 'data/tracker.sqlite'),
-		messagesPath: readText('MESSAGES_PATH', 'config/messages.json'),
-		unsupportedCnamesPath: readText('UNSUPPORTED_CNAMES_PATH', 'config/unsupportedCnames.json'),
+		messagesPath: readText('MESSAGES_PATH', 'config/messages.jp'),
+		unsupportedCnamesPath: readText('UNSUPPORTED_CNAMES_PATH', 'config/unsupportedCnames.jp'),
 		avatarPath: readText('AVATAR_PATH', 'config/avatar.png'),
 		pollIntervalSeconds: Math.max(30, readNumber('POLL_INTERVAL_SECONDS', 120)),
 		scannerEnabled: readFlag('SCANNER_ENABLED', true),
diff --git a/src/lib/server/messages.ts b/src/lib/server/messages.ts
index 10ba04c..2dde0bb 100644
--- a/src/lib/server/messages.ts
+++ b/src/lib/server/messages.ts
@@ -3,19 +3,44 @@
  */
 
 import { readFileSync } from 'node:fs';
+import { loads } from 'jpcl-lang';
 
-import defaultMessages from '../../../config/messages.json' with { type: 'json' };
 import { getConfig } from './config.ts';
 import { createLogger } from './logger.ts';
 
 const logger = createLogger('messages');
 
-export type ModerationMessages = typeof defaultMessages;
+export type ModerationMessages = {
+	nsRecords: {
+		closeComment: string;
+	};
+	unsupportedCname: {
+		reviewComment: string;
+		reviewDismissal: string;
+		reviewSummary: string;
+	};
+	noReplyEmail: {
+		reviewComment: string;
+		reviewDismissal: string;
+		reviewSummary: string;
+	};
+};
+
+// The committed file, read once, so a later bad edit still has wording to fall back on
+let defaultMessages: ModerationMessages | null = null;
+
+function getDefaultMessages(): ModerationMessages {
+	defaultMessages ??= loads(readFileSync('config/messages.jp', 'utf8')) as ModerationMessages;
+
+	return defaultMessages;
+}
 
 // Read on every use, so wording edits apply without a restart
 export function getMessages(): ModerationMessages {
+	const defaultMessages = getDefaultMessages();
+
 	try {
-		const overrides = JSON.parse(
+		const overrides = loads(
 			readFileSync(getConfig().messagesPath, 'utf8')
 		) as Partial<ModerationMessages>;
 
diff --git a/src/lib/server/rules/unsupportedCname.ts b/src/lib/server/rules/unsupportedCname.ts
index 11317b1..e462340 100644
--- a/src/lib/server/rules/unsupportedCname.ts
+++ b/src/lib/server/rules/unsupportedCname.ts
@@ -3,6 +3,7 @@
  */
 
 import { readFileSync } from 'node:fs';
+import { loads } from 'jpcl-lang';
 
 import { getConfig } from '../config.ts';
 import { createLogger } from '../logger.ts';
@@ -23,10 +24,11 @@ function normaliseHost(host: string): string {
 // Read on every scan, so list edits apply without a restart
 export function getUnsupportedCnames(): string[] {
 	try {
-		const list: unknown = JSON.parse(readFileSync(getConfig().unsupportedCnamesPath, 'utf8'));
+		const file = loads(readFileSync(getConfig().unsupportedCnamesPath, 'utf8'));
+		const list: unknown = file.hosts;
 
 		if (!Array.isArray(list)) {
-			throw new Error('expected a JSON array of hostnames');
+			throw new Error('expected a "hosts" array of hostnames');
 		}
 
 		return list.filter(