From 40d62f9ae13b86687cf3ab0a5bb78715985c6490 Mon Sep 17 00:00:00 2001 From: Raman Sinclair Date: Tue, 7 Jul 2026 18:15:20 +0200 Subject: [PATCH] chore: disallow using @include in the TS script metadata in favor of @match - nothing is currently using it --- src/build/build.ts | 47 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/build/build.ts b/src/build/build.ts index cf18fc7..54872fe 100644 --- a/src/build/build.ts +++ b/src/build/build.ts @@ -31,26 +31,21 @@ const BABEL_OPTIONS = { ], } satisfies RollupBabelInputPluginOptions; -const MetadataSchema = z - .strictObject({ - name: z.string(), - description: z.string(), - version: z.string(), - author: z.string(), - namespace: z.string(), - downloadURL: z.string(), - updateURL: z.string(), - match: z.array(z.string()).optional(), - include: z.array(z.string()).optional(), - require: z.array(z.string()).optional(), - grant: z.array(z.string()).optional(), - runAt: z.string().optional(), - icon: z.string().optional(), - }) - .refine(data => (data.match && !data.include) || (!data.match && data.include), { - message: 'Either `match` or `include` must be provided, not both.', - path: ['match', 'include'], - }); +const MetadataSchema = z.strictObject({ + name: z.string(), + description: z.string(), + version: z.string(), + author: z.string(), + namespace: z.string(), + downloadURL: z.string(), + updateURL: z.string(), + match: z.array(z.string()), + require: z.array(z.string()).optional(), + grant: z.array(z.string()).optional(), + runAt: z.string().optional(), + icon: z.string().optional(), +}); + type UserscriptMetadata = z.infer; async function buildUserscript(userscriptName: string): Promise { @@ -119,15 +114,9 @@ function generateUserscriptHeader(metadata: UserscriptMetadata): string { lines.push(`@downloadURL ${metadata.downloadURL}`); lines.push(`@updateURL ${metadata.updateURL}`); - if (metadata.match) { - metadata.match.forEach(pattern => { - lines.push(`@match ${pattern}`); - }); - } else if (metadata.include) { - metadata.include.forEach(pattern => { - lines.push(`@include ${pattern}`); - }); - } + metadata.match.forEach(pattern => { + lines.push(`@match ${pattern}`); + }); if (metadata.require) { metadata.require.forEach(url => {