Skip to content

Commit b6142ea

Browse files
author
Jérémie Parker
committed
feat(hooks): implement SYNC with the new HOOKS mechanism
1 parent d374483 commit b6142ea

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ Add a `.gitporc` with the followings:
1919
"HOOKS": {
2020
"<projectId>": {
2121
"IMPORT": "<webhook_url>",
22+
"SYNC": "<webhook_url>",
2223
"EXPORT": {
2324
"fr": "<webhook_url>",
2425
"en": "<webhook_url>"
25-
},
26-
"SYNC": {
27-
// Not impleted currently
2826
}
2927
}
3028
}
3129
}
3230
```
3331

32+
The `HOOKS` need to be defined on POEditor, this is due to a change on POEditor's side which prevent us from building the hooks url or creating them automatically through API calls.
33+
Check [POEditor WebHooks guide](https://poeditor.com/help/how_to_use_the_github_webhook) for more information.
34+
3435
## Usage
3536

3637
### CLI Usage

config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
module.exports = require('rc')('gitpo', {
2-
API_TOKEN: '',
2+
API_TOKEN: '<your POEditor API key>',
3+
HOOKS: {
4+
'<projectId>': {
5+
IMPORT: '<webhook_url>', // only one language needed as we import TERMS only
6+
SYNC: '<webhook_url>', // only one language needed as we import TERMS only
7+
EXPORT: {
8+
fr: '<webhook_url>',
9+
en: '<webhook_url>',
10+
},
11+
},
12+
},
313
})

lib/webhooks/synchronizeTerms.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
const rp = require('request-promise')
22

3-
module.exports = ({ API_TOKEN }) => (projectId) => {
4-
console.log('Sorry this doesnt work at the moment as POEditor has updated its webhooks API...')
5-
// rp({
6-
// method: 'GET',
7-
// url: `https://poeditor.com/api/webhooks/github?api_token=${API_TOKEN}&id_project=${projectId}&language=en&operation=sync_terms_and_translations`,
8-
// })
9-
}
3+
module.exports = ({ HOOKS }) => async (projectId) => rp({ method: 'GET', url: HOOKS[projectId]['SYNC'] })

0 commit comments

Comments
 (0)