Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typings/

# test output for diffs
test_data/test_output.json
output.txt

# package-lock is dumb and not at all worth it here
package-lock.json
4 changes: 4 additions & 0 deletions bash_scripts/hashed_data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
12345deadbeef|It's a message, for testing
8badf00d|Also a message for testing
bada55|It's a message, for testing
feedface9876|Also a message for testing
7 changes: 3 additions & 4 deletions bash_scripts/put_comments.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
curl -L -w "\n" --user $SECRET_USER:$SECRET_PWD -X PUT -H "Content-Type: application/json" --data "{\"comment\": \"It's a message, for testing\"}" $112345deadbeef
curl -L -w "\n" --user $SECRET_USER:$SECRET_PWD -X PUT -H "Content-Type: application/json" --data "{\"comment\": \"Also a message for testing\"}" $18badf00d
curl -L -w "\n" --user $SECRET_USER:$SECRET_PWD -X PUT -H "Content-Type: application/json" --data "{\"comment\": \"It's a message, for testing\"}" $1bada55
curl -L -w "\n" --user $SECRET_USER:$SECRET_PWD -X PUT -H "Content-Type: application/json" --data "{\"comment\": \"Also a message for testing\"}" $1feedface9876
while IFS='|' read -r string_hash string_comment; do
curl -L -w "\n" --user $SECRET_USER:$SECRET_PWD -X PUT -H "Content-Type: application/json" --data "{\"comment\": \"$string_comment\"}" $1$string_hash
done < bash_scripts/hashed_data.txt
10 changes: 3 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ inData.forEach((message) => {
if (process.argv[3] === "--comments") {
process.stdout.write("generating bash scripts...\n");
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 {
process.stdout.write("string " + message.id + " does not yet exist on transifex!\n");
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "reactifex",
"version": "1.0.1",
"version": "1.0.2",
"description": "A helper for moving react-intl messages to transifex and back",
"bin": "./main.js",
"scripts": {
"lint": "eslint .",
"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"
},
"repository": {
"type": "git",
Expand Down
5 changes: 0 additions & 5 deletions test_data/expected_output/put_comments.sh

This file was deleted.

4 changes: 4 additions & 0 deletions test_data/expected_output/test_curl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+ curl -L -w '\n' --user uname:password -X PUT -H 'Content-Type: application/json' --data '{"comment": "It'\''s a message, for testing"}' http://totally_real.notfake.com/api/12345deadbeef
+ curl -L -w '\n' --user uname:password -X PUT -H 'Content-Type: application/json' --data '{"comment": "Also a message for testing"}' http://totally_real.notfake.com/api/8badf00d
+ curl -L -w '\n' --user uname:password -X PUT -H 'Content-Type: application/json' --data '{"comment": "It'\''s a message, for testing"}' http://totally_real.notfake.com/api/bada55
+ curl -L -w '\n' --user uname:password -X PUT -H 'Content-Type: application/json' --data '{"comment": "Also a message for testing"}' http://totally_real.notfake.com/api/feedface9876