Skip to content

Commit

Permalink
feat: more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dies committed May 22, 2024
1 parent 100b213 commit 4b96d50
Show file tree
Hide file tree
Showing 10 changed files with 404 additions and 218 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test-data
crowdin-context.csv

# Logs
logs
Expand Down
15 changes: 13 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Command, Option } from 'commander';
import configureCli from './src/configure.js';
import harvest from './src/harvest.js';
import reset from './src/reset.js';
import upload from './src/upload.js';
import chalk from 'chalk';

const program = new Command();
Expand Down Expand Up @@ -43,12 +44,21 @@ program
.addOption(new Option('-l, --localFiles <pattern>', 'local file names pattern (valid glob pattern)').default('**/*.*').makeOptionMandatory())
.addOption(new Option('-i, --localIgnore <pattern>', 'local file names to ignore (valid glob pattern)').default('node_modules/**'))
.addOption(new Option('-c, --crowdinFiles <pattern>', 'Crowdin file names pattern (valid glob pattern)').default(''))
.addOption(new Option('-y, --autoConfirm', 'automatically confirm all extracted contexts, otherwise you will be asked to confirm or edit the extracted context for each key').default(false))
.addOption(new Option('-q, --croql <croql>', 'use CroQL to select a specific subset of strings to extract context for (e.g. strings without AI context, strings modified since specific date, etc.). Cannot be set together with the crowdinFiles argument.').default(''))
.addOption(new Option('-s, --screen <keys | texts>', 'check if the code contains the key or the text of the string before sending it to the AI model (recommended if you have thousands of keys to avoid chunking and improve speed). If the text value is selected, efficiency may be reduced.').default('keys'))
.addOption(new Option('-d, --dryRun', 'do not write extracted context to Crowdin, just show what would be written').default(false))
.addOption(new Option('-w, --output <csv | terminal | crowdin>', 'output destination for extracted context. "terminal" can be considered as a dry run. "crowdin" will save the extracted context to the Crowdin project. "csv" will save the extracted context to a CSV file for review.').default('csv').makeOptionMandatory())
.addOption(new Option('-f, --csvFile <path>', 'path to the CSV file to save extracted context to.'))
.action(harvest);

program
.command('upload')
.description('upload the reviewed context to Crowdin project')
.addOption(new Option('-t, --token <token>', 'Crowdin Personal API token (with Project scope)').makeOptionMandatory().env('CROWDIN_TOKEN'))
.addOption(new Option('-o, --org <organization>', 'Crowdin organization (e.g., acme)').env('CROWDIN_ORG'))
.addOption(new Option('-p, --project <projectId>', 'Crowdin project ID (e.g., 123456)').makeOptionMandatory())
.addOption(new Option('-f, --csvFile <path>', 'path to the CSV file with reviewed context').makeOptionMandatory())
.action(upload);

program
.command('reset')
.description('remove previously written AI context from Crowdin project')
Expand All @@ -58,4 +68,5 @@ program
.addOption(new Option('-c, --crowdinFiles <pattern>', 'Crowdin file names pattern (valid glob pattern)').default('**/*.*'))
.action(reset);


program.parse(process.argv);
3 changes: 3 additions & 0 deletions crowdin-context copy.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,key,text,context,aiContext
2533087,identifier_2,String for translation 2,asdfasdfa," > Used as the application name for a CLI tool.
> Appears as an option description for the '--type' command-line option in a CLI application."
Loading

0 comments on commit 4b96d50

Please sign in to comment.