From 2895163d2fdff73cffbc992dde5dbba698816897 Mon Sep 17 00:00:00 2001 From: MarvNC Date: Sat, 23 Dec 2023 01:02:19 -0800 Subject: [PATCH 1/3] Add script to download all from inputs.txt --- inputs.txt | 2 ++ scripts/buildAll.sh | 24 ++++++++++++++++++++++++ {src => scripts}/downloadDump.sh | 0 3 files changed, 26 insertions(+) create mode 100644 inputs.txt create mode 100644 scripts/buildAll.sh rename {src => scripts}/downloadDump.sh (100%) diff --git a/inputs.txt b/inputs.txt new file mode 100644 index 0000000..aa0f7b7 --- /dev/null +++ b/inputs.txt @@ -0,0 +1,2 @@ +ja +2022-12-01 \ No newline at end of file diff --git a/scripts/buildAll.sh b/scripts/buildAll.sh new file mode 100644 index 0000000..40374d9 --- /dev/null +++ b/scripts/buildAll.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Read input from inputs.txt +input_file="inputs.txt" +IFS=',' read -r -a langs < <(sed -n '1p' "$input_file") +date_val=$(sed -n '2p' "$input_file") + +# Format date for file naming +dateFile=$(date -d "$date_val" +"%Y.%m.%d") + +# Output array and dateFile +echo "langs array: ${langs[@]}" +echo "date_val variable: $date_val" +echo "dateFile variable: $dateFile" + +# For each lang, run downloadDump.sh with +for lang in "${langs[@]}" +do + echo "Running downloadDump.sh with $lang and $dateFile" + ./scripts/downloadDump.sh "$lang" "$dateFile" + # Run node src/convertWikipedia.js with + echo "Running convertWikipedia.js with $lang and $date_val" + node src/convertWikipedia.js "$lang" "$date_val" +done \ No newline at end of file diff --git a/src/downloadDump.sh b/scripts/downloadDump.sh similarity index 100% rename from src/downloadDump.sh rename to scripts/downloadDump.sh From 4b03f7a3576ab02563349bfda48e72d9ae5978df Mon Sep 17 00:00:00 2001 From: MarvNC Date: Sat, 23 Dec 2023 01:06:08 -0800 Subject: [PATCH 2/3] Finish buildAll script --- inputs.txt | 2 +- scripts/buildAll.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/inputs.txt b/inputs.txt index aa0f7b7..9547ca7 100644 --- a/inputs.txt +++ b/inputs.txt @@ -1,2 +1,2 @@ -ja +ja,zh 2022-12-01 \ No newline at end of file diff --git a/scripts/buildAll.sh b/scripts/buildAll.sh index 40374d9..f706078 100644 --- a/scripts/buildAll.sh +++ b/scripts/buildAll.sh @@ -18,7 +18,11 @@ for lang in "${langs[@]}" do echo "Running downloadDump.sh with $lang and $dateFile" ./scripts/downloadDump.sh "$lang" "$dateFile" - # Run node src/convertWikipedia.js with +done + +# Run node src/convertWikipedia.js with for each lang +for lang in "${langs[@]}" +do echo "Running convertWikipedia.js with $lang and $date_val" node src/convertWikipedia.js "$lang" "$date_val" done \ No newline at end of file From ed9e60db5fce4e456d13a4be3c3600f7c610a2de Mon Sep 17 00:00:00 2001 From: MarvNC Date: Sat, 23 Dec 2023 01:17:33 -0800 Subject: [PATCH 3/3] Add build dicts automatically --- .github/workflows/build-dicts.yaml | 32 ++++++++++++++++++++++++++++++ src/convertWikipedia.js | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-dicts.yaml diff --git a/.github/workflows/build-dicts.yaml b/.github/workflows/build-dicts.yaml new file mode 100644 index 0000000..28a3cc6 --- /dev/null +++ b/.github/workflows/build-dicts.yaml @@ -0,0 +1,32 @@ +name: Build and Release Dictionaries on Tag + +on: + workflow_dispatch: + push: + tags: + - v* + +jobs: + build-release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up node environment + uses: actions/setup-node@v4 + with: + node-version: '21' + + - name: Install dependencies + run: npm install + + - name: Build + run: ./scripts/buildAll.sh + + - name: Create Release With gh CLI and Upload ./dist/*.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + run: | + gh release create "$tag" ./dist/*.zip --notes-from-tag diff --git a/src/convertWikipedia.js b/src/convertWikipedia.js index c12d164..550f238 100644 --- a/src/convertWikipedia.js +++ b/src/convertWikipedia.js @@ -7,6 +7,8 @@ import { parseLine } from './parseLine.js'; import { languagesAllowed } from './constants.js'; const linkCharacter = '⧉'; +const exportDirectory = './dist'; + /** * * @param {string} lang @@ -64,7 +66,7 @@ div.gloss-sc-div[data-sc-wikipedia=term-specifier] { attribution: `https://${lang.toLowerCase()}.wikipedia.org/`, }); - await dict.export('./'); + await dict.export(exportDirectory); console.log(`Exported to ${outputZipName(lang, date, version)}`); })().catch((e) => { console.error(e);