Comparing version 1.0.1 to 1.0.2
10
main.js
@@ -26,12 +26,8 @@ #!/usr/bin/env node | ||
var messageInfo = JSON.parse(fs.readFileSync(__dirname + "/bash_scripts/hashmap.json")); | ||
var scriptPath = __dirname + "/bash_scripts/put_comments.sh"; | ||
fs.writeFileSync(scriptPath, "#!/bin/bash\n"); | ||
var dataPath = __dirname + "/bash_scripts/hashed_data.txt"; | ||
fs.writeFileSync(dataPath, ""); | ||
inData.forEach((message) => { | ||
var info = messageInfo.find(mi => mi.key == message.id); | ||
if (info) { | ||
var header = " -H \"Content-Type: application/json\""; | ||
var escapedDescription = message.description.replace(/(["])/g, "\\\\\\$1"); | ||
var data = " --data \"{\\\"comment\\\": \\\"" + escapedDescription + "\\\"}\""; | ||
var url = " $1" + info.string_hash; | ||
fs.appendFileSync(scriptPath, "curl -L -w \"\\n\" --user $SECRET_USER:$SECRET_PWD -X PUT" + header + data + url + "\n"); | ||
fs.appendFileSync(dataPath, info.string_hash + "|" + message.description + "\n"); | ||
} else { | ||
@@ -38,0 +34,0 @@ process.stdout.write("string " + message.id + " does not yet exist on transifex!\n"); |
{ | ||
"name": "reactifex", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A helper for moving react-intl messages to transifex and back", | ||
@@ -9,3 +9,3 @@ "bin": "./main.js", | ||
"test_compile": "node main.js test_data/input/ test_data/test_output.json && diff test_data/test_output.json test_data/expected_output/messages.json", | ||
"test_comments": "node main.js test_data/input/ --comments && diff bash_scripts/put_comments.sh test_data/expected_output/put_comments.sh" | ||
"test_comments": "node main.js test_data/input/ --comments && SECRET_USER=uname SECRET_PWD=password bash -x ./bash_scripts/put_comments.sh http://totally_real.notfake.com/api/ 2>&1 | grep PUT > output.txt && diff -w output.txt test_data/expected_output/test_curl.txt" | ||
}, | ||
@@ -12,0 +12,0 @@ "repository": { |
@@ -41,4 +41,4 @@ # reactifex | ||
- Next, the main reactifex script (node js) runs with an additional `--comments` flag, and no output file. This has the effect of gathering up all your `babel-plugin-react-intl` extracted messages *with* their comments attached. From there, it's simple enough to match up each message with its `string_hash`, and makes it possible to generate `bash_scripts/put_comments.sh` (a series of curl requests, one per message) | ||
- Next, the main reactifex script (node js) runs with an additional `--comments` flag, and no output file. This has the effect of gathering up all your `babel-plugin-react-intl` extracted messages *with* their comments attached. From there, it's simple enough to match up each message with its `string_hash`, and save these pairs in a '|'-delimited list, for later consumption. | ||
- Finally, `bash_scripts/put_comments.sh` is run with the base PUT url as an argument (we generated the specific `string_hash` portion in the previous step), updating translator comments for each message on Transifex via their API. | ||
- Finally, `bash_scripts/put_comments.sh` is run with the base PUT url as an argument (also reads the data file we created in the previous step), updating translator comments for each message on Transifex via their API. |
Sorry, the diff of this file is not supported yet
14
9845
103