11const { execSync } = require ( "child_process" ) ;
2- const readline = require ( "readline" ) ;
32const fs = require ( "fs" ) ;
43
5- const rl = readline . createInterface ( {
6- input : process . stdin ,
7- output : process . stdout ,
8- } ) ;
4+ // Remove readline and use command line arguments
5+ const args = process . argv . slice ( 2 ) ;
6+
7+ if ( args . length < 2 ) {
8+ console . error ( "Usage: node update-lists.js <Brave Services Key> <target version for brave list (i.e. 1.0.10268)>" ) ;
9+ process . exit ( 1 ) ;
10+ }
11+
12+ const apiKey = args [ 0 ] ;
13+ const version = args [ 1 ] ;
14+
15+ const versionNumber = version . replace ( / \. / g, "_" ) ;
16+ const extensionId = "iodkpdagapdfkphljnddpjlldadblomo" ;
917
1018execSync (
1119 "curl -o data/easylist.to/easylist/easylist.txt https://easylist.to/easylist/easylist.txt"
@@ -17,37 +25,20 @@ execSync(
1725 "curl -o data/easylist.to/easylistgermany/easylistgermany.txt https://easylist.to/easylistgermany/easylistgermany.txt"
1826) ;
1927
20- ( async ( ) => {
21- console . log (
22- "You need to provide Brave Services Key and target version to update brave-main-list.txt"
23- ) ;
24- const apiKey = await new Promise ( ( resolve ) => {
25- rl . question ( "Enter Brave Services Key: " , resolve ) ;
26- } ) ;
27-
28- const version = await new Promise ( ( resolve ) => {
29- rl . question ( "Enter target version (i.e 1.0.10268): " , resolve ) ;
30- } ) ;
31-
32- const versionNumber = version . replace ( / \. / g, "_" ) ;
33- const extensionId = "iodkpdagapdfkphljnddpjlldadblomo" ;
34-
35- execSync (
36- `curl -o extension.zip -H "BraveServiceKey: ${ apiKey } " ` +
37- `https://brave-core-ext.s3.brave.com/release/${ extensionId } /extension_${ versionNumber } .crx`
38- ) ;
39-
40- try {
41- execSync ( "unzip extension.zip list.txt" ) ;
42- } catch ( e ) {
43- if ( ! fs . existsSync ( "list.txt" ) ) {
44- console . error ( "Failed to find list.txt in extension.zip" ) ;
45- process . exit ( 1 ) ;
46- }
28+ execSync (
29+ `curl -o extension.zip -H "BraveServiceKey: ${ apiKey } " ` +
30+ `https://brave-core-ext.s3.brave.com/release/${ extensionId } /extension_${ versionNumber } .crx`
31+ ) ;
32+
33+ try {
34+ execSync ( "unzip extension.zip list.txt" ) ;
35+ } catch ( e ) {
36+ if ( ! fs . existsSync ( "list.txt" ) ) {
37+ console . error ( "Failed to find list.txt in extension.zip" ) ;
38+ process . exit ( 1 ) ;
4739 }
40+ }
4841
49- execSync ( "mv -f list.txt data/brave/brave-main-list.txt" ) ;
42+ execSync ( "mv -f list.txt data/brave/brave-main-list.txt" ) ;
5043
51- fs . unlinkSync ( "extension.zip" ) ;
52- rl . close ( ) ;
53- } ) ( ) ;
44+ fs . unlinkSync ( "extension.zip" ) ;
0 commit comments