mirror of
https://gitlab.com/openlp/web-remote.git
synced 2024-12-21 19:12:48 +00:00
Automatically push up newest source strings to Transifex
This commit is contained in:
parent
fcc1f543d0
commit
08d097dd0a
@ -10,8 +10,8 @@ audit:
|
|||||||
script:
|
script:
|
||||||
- yarn install
|
- yarn install
|
||||||
- yarn audit
|
- yarn audit
|
||||||
except:
|
rules:
|
||||||
- tags
|
- when: always
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@ -19,16 +19,26 @@ lint:
|
|||||||
script:
|
script:
|
||||||
- yarn install
|
- yarn install
|
||||||
- yarn lint
|
- yarn lint
|
||||||
except:
|
rules:
|
||||||
- tags
|
- when: always
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- yarn install
|
- yarn install
|
||||||
- yarn test --no-progress --no-watch --browsers=ChromiumHeadlessCI
|
- yarn test --no-progress --no-watch --browsers=ChromiumHeadlessCI
|
||||||
except:
|
rules:
|
||||||
- tags
|
- when: always
|
||||||
|
|
||||||
|
push-i18n-source:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- apk add npm
|
||||||
|
- npm install @transifex/api
|
||||||
|
- npm run tx push
|
||||||
|
rules:
|
||||||
|
- changes:
|
||||||
|
- src/assets/en.json
|
||||||
|
|
||||||
build-branch:
|
build-branch:
|
||||||
stage: build
|
stage: build
|
||||||
@ -43,8 +53,8 @@ build-branch:
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- dist/
|
- dist/
|
||||||
only:
|
rules:
|
||||||
- branches
|
- if: $CI_COMMIT_BRANCH != "master"
|
||||||
|
|
||||||
build-tag:
|
build-tag:
|
||||||
stage: build
|
stage: build
|
||||||
@ -58,8 +68,8 @@ build-tag:
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- dist/
|
- dist/
|
||||||
only:
|
rules:
|
||||||
- tags
|
- if: $CI_COMMIT_TAG
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
@ -83,5 +93,5 @@ deploy:
|
|||||||
- scp version-$CI_COMMIT_TAG.json openlp@$OPENLP_HOST:/home/openlp/sites/get.openlp.org/www/remote/
|
- scp version-$CI_COMMIT_TAG.json openlp@$OPENLP_HOST:/home/openlp/sites/get.openlp.org/www/remote/
|
||||||
- ssh openlp@$OPENLP_HOST "rm /home/openlp/sites/get.openlp.org/www/remote/version.json"
|
- ssh openlp@$OPENLP_HOST "rm /home/openlp/sites/get.openlp.org/www/remote/version.json"
|
||||||
- scp version-$CI_COMMIT_TAG.json openlp@$OPENLP_HOST:/home/openlp/sites/get.openlp.org/www/remote/version.json
|
- scp version-$CI_COMMIT_TAG.json openlp@$OPENLP_HOST:/home/openlp/sites/get.openlp.org/www/remote/version.json
|
||||||
only:
|
rules:
|
||||||
- tags
|
- if: $CI_COMMIT_TAG
|
||||||
|
@ -5,6 +5,7 @@ const { parseArgs } = require('util');
|
|||||||
const { transifexApi } = require('@transifex/api');
|
const { transifexApi } = require('@transifex/api');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
|
const ACTIONS = ['push', 'upload', 'download'];
|
||||||
|
|
||||||
// Parse the command line arguments
|
// Parse the command line arguments
|
||||||
function parseCliArgs() {
|
function parseCliArgs() {
|
||||||
@ -29,7 +30,7 @@ function parseCliArgs() {
|
|||||||
console.log(`usage: tx [-h|--help] [-v|--verbose] [-t|--token TOKEN] <action>
|
console.log(`usage: tx [-h|--help] [-v|--verbose] [-t|--token TOKEN] <action>
|
||||||
|
|
||||||
positional arguments:
|
positional arguments:
|
||||||
action the action to perform, one of 'upload' or 'download'
|
action the action to perform, one of 'push', 'upload' or 'download'
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
@ -47,8 +48,8 @@ options:
|
|||||||
else if (!values.token && process.env.TX_TOKEN) {
|
else if (!values.token && process.env.TX_TOKEN) {
|
||||||
values.token = process.env.TX_TOKEN;
|
values.token = process.env.TX_TOKEN;
|
||||||
}
|
}
|
||||||
if (positionals.length < 1 || (positionals[0] != 'upload' && positionals[0] != 'download')) {
|
if (positionals.length < 1 || !ACTIONS.includes(positionals[0])) {
|
||||||
console.error("ERROR: Action is not valid, please use either 'upload' or 'download'");
|
console.error("ERROR: Action is not valid, please use one of " + ACTIONS.join(", "));
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
return {token: values.token, action: positionals[0], verbose: values.verbose};
|
return {token: values.token, action: positionals[0], verbose: values.verbose};
|
||||||
@ -60,9 +61,26 @@ function getPercentage(attributes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function pushSource(resource, verbose) {
|
||||||
|
const filename = path.join('src', 'assets', 'en.json');
|
||||||
|
if (!fs.existsSync(filename)) {
|
||||||
|
console.error(`Source file ${filename} does not exist!`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (verbose) {
|
||||||
|
console.log('Reading en.json...');
|
||||||
|
}
|
||||||
|
const content = fs.readFileSync(filename);
|
||||||
|
console.log('Uploading en.json...');
|
||||||
|
await transifexApi.ResourceStringsAsyncUpload.upload({
|
||||||
|
resource: resource,
|
||||||
|
content: content.toString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function uploadFiles(resource, languages, verbose) {
|
async function uploadFiles(resource, languages, verbose) {
|
||||||
for (const lang of languages) {
|
for (const lang of languages) {
|
||||||
const filename = path.join('src', 'assets', 'i18n', `${lang.attributes.code}.json`)
|
const filename = path.join('src', 'assets', 'i18n', `${lang.attributes.code}.json`);
|
||||||
if (!fs.existsSync(filename)) {
|
if (!fs.existsSync(filename)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -129,6 +147,9 @@ async function main() {
|
|||||||
else if (action == 'download') {
|
else if (action == 'download') {
|
||||||
await downloadFiles(org, proj, resource, languages.data, verbose);
|
await downloadFiles(org, proj, resource, languages.data, verbose);
|
||||||
}
|
}
|
||||||
|
else if (action == 'push') {
|
||||||
|
await pushSource(resource, verbose);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
Loading…
Reference in New Issue
Block a user