@@ -12,14 +12,16 @@ import { CreateBanner } from './banner/index.js'
1212export type BuildOptions = {
1313 Minify : boolean
1414 UseCache : boolean
15- BuildType : 'production' | 'development'
15+ BuildType : 'production' | 'development' ,
16+ SubscriptionUrl : string
1617}
1718
1819export async function Build ( OptionsParam ?: BuildOptions ) : Promise < void > {
1920 const Options = await Zod . strictObject ( {
2021 Minify : Zod . boolean ( ) ,
2122 UseCache : Zod . boolean ( ) ,
22- BuildType : Zod . enum ( [ 'production' , 'development' ] )
23+ BuildType : Zod . enum ( [ 'production' , 'development' ] ) ,
24+ SubscriptionUrl : Zod . string ( ) . transform ( Value => new URL ( Value ) ) . default ( new URL ( 'https://cdn.jsdelivr.net/npm/@filteringdev/tinyshield@latest/dist/tinyShield.user.js' ) )
2325 } ) . parseAsync ( OptionsParam )
2426
2527 let MatchingDomains : Set < string > = new Set < string > ( )
@@ -37,15 +39,20 @@ export async function Build(OptionsParam?: BuildOptions): Promise<void> {
3739 ConvertWildcardSuffixToRegexPattern ( Domain ) . forEach ( GeneratedPattern => MatchingDomains . add ( GeneratedPattern ) )
3840 }
3941 }
42+
43+ let ProjectRoot = Process . cwd ( )
44+ if ( Process . cwd ( ) . endsWith ( '/builder' ) ) {
45+ ProjectRoot = Process . cwd ( ) + '/..'
46+ }
4047
4148 const Banner = CreateBanner ( {
42- Version : ( await PackageJson . load ( Process . cwd ( ) ) ) . content . version ?? '0.0.0' ,
49+ Version : ( await PackageJson . load ( ProjectRoot ) ) . content . version ?? '0.0.0' ,
4350 BuildType : Options . BuildType ?? 'production' ,
4451 Domains : MatchingDomains ,
4552 Name : 'tinyShield' ,
4653 Namespace : 'https://github.com/FilteringDev/tinyShield' ,
47- DownloadURL : new URL ( 'https://cdn.jsdelivr.net/npm/@filteringdev/tinyshield@latest/dist/tinyShield.user.js' ) ,
48- UpdateURL : new URL ( 'https://cdn.jsdelivr.net/npm/@filteringdev/tinyshield@latest/dist/tinyShield.user.js' ) ,
54+ DownloadURL : Options . SubscriptionUrl ,
55+ UpdateURL : Options . SubscriptionUrl ,
4956 HomepageURL : new URL ( 'https://github.com/FilteringDev/tinyShield' ) ,
5057 SupportURL : new URL ( 'https://github.com/FilteringDev/tinyShield/issues' ) ,
5158 License : 'MPL-2.0' ,
@@ -57,10 +64,6 @@ export async function Build(OptionsParam?: BuildOptions): Promise<void> {
5764 }
5865 } )
5966
60- let ProjectRoot = Process . cwd ( )
61- if ( Process . cwd ( ) . endsWith ( '/builder' ) ) {
62- ProjectRoot = Process . cwd ( ) + '/..'
63- }
6467 await ESBuild . build ( {
6568 entryPoints : [ ProjectRoot + '/userscript/source/index.ts' ] ,
6669 bundle : true ,
0 commit comments