-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
5 changed files
with
755 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env ts-node | ||
|
||
/************************************************************************************************** | ||
* | ||
* @file ./mobile-string-parser.ts | ||
* | ||
* Note: must be run from node - will not work if used in the browser. | ||
* | ||
*/ | ||
|
||
/******************************************** IMPORTS *********************************************/ | ||
import { spawnSync } from 'child_process'; | ||
import { readFileSync, unlinkSync } from 'fs'; | ||
import { wasRunAsScript } from 'mad-utils/lib/node'; | ||
|
||
|
||
/******************************************** LOGGING *********************************************/ | ||
import { buildFileTag, nodeLogFactory, colors } from 'mad-logs/lib/node'; | ||
const log = nodeLogFactory(buildFileTag('mobile-string-parser.ts', colors.bgMagenta.white)); | ||
|
||
|
||
/********************************************* EXPORT *********************************************/ | ||
/** | ||
* @export | ||
* | ||
* Get parsed string translations from googledoc. Erases old version, saves new downloaded & parsed | ||
* version as a JSON file, then grabs the file's data, converts it to a JS object & returns it. | ||
* | ||
* TODO try downloading first and save to temp file. Only delete if dwl succeeds. Copy new version | ||
* in temp file to STRING_TRANSLATIONS.json. | ||
* | ||
* @return {Object} Translation strings object, parsed from STRING_TRANSLATIONS.json. | ||
*/ | ||
export const getTranslationsFromWeb = (): Object => { | ||
try { | ||
unlinkSync('./STRING_TRANSLATIONS.json'); | ||
} catch(e) { | ||
log.verbose(`STRING_TRANSLATIONS.json doesn't yet exist - no need to delete.`); | ||
} | ||
|
||
spawnSync('java', ['-jar', 'build/libs/mobile-string-parser-3.0.0.jar'], { env: process.env }); | ||
|
||
const mobileStrings = require('./STRING_TRANSLATIONS.json'); | ||
log.silly('mobileStrings returned from google translations repo:', mobileStrings); | ||
|
||
return mobileStrings; | ||
}; | ||
|
||
|
||
/******************* RUN THE EXPORTED FUNCTION IF THE FILE WAS RUN AS A SCRIPT ********************/ | ||
if (wasRunAsScript(__filename)) getTranslationsFromWeb(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@ottawamhealth/mobile-string-parser", | ||
"version": "0.0.1", | ||
"description": "Grab online CSV, parse it to produce JSON string file (for translations)", | ||
"main": "mobile-string-parser.js", | ||
"typings": "mobile-string-parser", | ||
"files": [ | ||
"./mobile-string-parser.js", | ||
"./mobile-string-parser.d.ts", | ||
"./mobile-string-parser.js.map" | ||
], | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"compile-ts": "tsc", | ||
"ts-compile": "tsc", | ||
"start": "npm run ts-compile; node ./mobile-string-parser.js", | ||
"prepublish": "npm run ts-compile" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jguerinet/mobile-string-parser.git" | ||
}, | ||
"keywords": [ | ||
"java", | ||
"jar", | ||
"strings", | ||
"parsing", | ||
"csv" | ||
], | ||
"author": "", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/jguerinet/mobile-string-parser/issues" | ||
}, | ||
"homepage": "https://github.com/jguerinet/mobile-string-parser#readme", | ||
"private": true, | ||
"dependencies": { | ||
"mad-logs": "^8.3.0", | ||
"mad-utils": "^0.5.7" | ||
}, | ||
"devDependencies": { | ||
"lodash": "^4.17.4", | ||
"chai": "^3.5.0" | ||
}, | ||
"peerDependencies": { | ||
"lodash": "^4.17.4", | ||
"chai": "^3.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"version": "2.3.0", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"removeComments": false, | ||
"preserveConstEnums": true, | ||
"sourceMap": true, | ||
"strictNullChecks": false, | ||
"outDir": "./", | ||
"declaration": true, | ||
"target": "ES5", | ||
"skipLibCheck": true, | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"noImplicitAny": false, | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"jsx": "preserve", | ||
"pretty": true, | ||
"lib": ["ES2015", "DOM"] | ||
}, | ||
"exclude": [ | ||
"*.js", | ||
"*.json" | ||
], | ||
"include": [ | ||
"./mobile-string-parser.ts", | ||
"./src/*.ts" | ||
] | ||
} | ||
|
Oops, something went wrong.