citeclaw 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/botcite.js +30 -0
package/package.json
CHANGED
package/scripts/botcite.js
CHANGED
|
@@ -112,6 +112,7 @@ function usage() {
|
|
|
112
112
|
console.error( ' citeclaw cite-pdf [--headers] [--debug-pdf] <pdf-path>' );
|
|
113
113
|
console.error( ' citeclaw fetch-pdf [--base <openurl-base>] [--out <file.pdf>] <doi|arxiv|url>' );
|
|
114
114
|
console.error( ' citeclaw openurl-resolve [--base <openurl-base>] <doi|arxiv|url>' );
|
|
115
|
+
console.error( ' citeclaw translators sync' );
|
|
115
116
|
console.error( ' citeclaw zotero <login|logout|whoami|query|dump|cite|add|delete|update|note|sync-cite|dedup|enrich|export|watch|templates|safe-mode> [...]' );
|
|
116
117
|
console.error( ' citeclaw batch --op <cite|cite-style|fetch-pdf|openurl-resolve> --in <file>' );
|
|
117
118
|
console.error( ' citeclaw styles sync [--repo <git-url>]' );
|
|
@@ -138,6 +139,7 @@ function usage() {
|
|
|
138
139
|
console.error( " citeclaw zotero query 'transformer'" );
|
|
139
140
|
console.error( ' citeclaw zotero cite AB12CD34' );
|
|
140
141
|
console.error( ' citeclaw batch --op cite --format bibtex --in ./ids.txt --out-jsonl ./result.jsonl' );
|
|
142
|
+
console.error( ' citeclaw translators sync' );
|
|
141
143
|
console.error( 'options:' );
|
|
142
144
|
console.error( ' --concurrency <n> batch worker count (default: 4)' );
|
|
143
145
|
console.error( ' --user-id <id> Zotero user id (or set ZOTERO_USER_ID)' );
|
|
@@ -562,6 +564,18 @@ function syncMergedTranslators() {
|
|
|
562
564
|
writeTranslatorStamp();
|
|
563
565
|
}
|
|
564
566
|
|
|
567
|
+
function syncTranslators() {
|
|
568
|
+
ensureDirs();
|
|
569
|
+
const sources = ensureDefaultTranslatorSources();
|
|
570
|
+
syncMergedTranslators();
|
|
571
|
+
const mergedCount = fs.readdirSync( mergedTranslatorsDir )
|
|
572
|
+
.filter( ( name ) => name.endsWith( '.js' ) )
|
|
573
|
+
.length;
|
|
574
|
+
process.stdout.write(
|
|
575
|
+
`translators synced to ${ mergedTranslatorsDir } from ${ sources.officialDir }, ${ sources.cnDir } and ${ path.join( zoteroDir, 'modules', 'translators' ) } (${ mergedCount } files)\n`
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
|
|
565
579
|
function ensureDefaultTranslatorSources() {
|
|
566
580
|
const existingOfficial = fileExists( officialTranslatorsDir ) ? officialTranslatorsDir : null;
|
|
567
581
|
const existingCn = fileExists( cnTranslatorsDir ) ? cnTranslatorsDir : null;
|
|
@@ -4950,6 +4964,22 @@ function main() {
|
|
|
4950
4964
|
return;
|
|
4951
4965
|
}
|
|
4952
4966
|
|
|
4967
|
+
if ( action === 'translators' ) {
|
|
4968
|
+
const parsed = parseOptions( process.argv.slice( 3 ) );
|
|
4969
|
+
const subAction = parsed.args[ 0 ];
|
|
4970
|
+
if ( subAction !== 'sync' ) {
|
|
4971
|
+
usage();
|
|
4972
|
+
process.exit( 1 );
|
|
4973
|
+
}
|
|
4974
|
+
try {
|
|
4975
|
+
syncTranslators();
|
|
4976
|
+
process.exit( 0 );
|
|
4977
|
+
} catch ( error ) {
|
|
4978
|
+
handleCommandError( error, parsed, 'translators', 'sync' );
|
|
4979
|
+
}
|
|
4980
|
+
return;
|
|
4981
|
+
}
|
|
4982
|
+
|
|
4953
4983
|
if ( action === 'api' ) {
|
|
4954
4984
|
const parsed = parseOptions( process.argv.slice( 3 ) );
|
|
4955
4985
|
const requestPath = parsed.args.join( ' ' ).trim();
|