Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsluph committed Nov 12, 2023
1 parent d5f88a0 commit b4fa199
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25520,9 +25520,9 @@ async function extractLanguages(httpClient, api_key) {
const r_lang = await httpClient.getJson(languages_url, {
'X-API-KEY': api_key
});
if (r_lang.statusCode !== 200)
core.debug(JSON.stringify(r_lang.result));
if (r_lang.statusCode !== 200 || !r_lang.result)
throw new Error(`HTTP request failed. Received: ${r_lang.statusCode}`);
// @ts-ignore
const projectLocales = r_lang.result[0];
return projectLocales.map(locale_metadata => ({
tag: locale_metadata.tag,
Expand All @@ -25536,7 +25536,7 @@ async function exportLocaleData(api_key) {
await (0, exec_1.exec)(unzipPath, ['-o', '-d', './src/locales', 'locales.zip']);
await (0, io_util_1.rm)('locales.zip');
}
async function checkoutChanges(commit_message) {
async function commitChanges(commit_message) {
const gitPath = await (0, io_1.which)('git', true);
await (0, exec_1.exec)(gitPath, ['status']);
// await exec(gitPath, ['add', '.'])
Expand All @@ -25546,9 +25546,12 @@ async function main() {
try {
const tolgee_secret = core.getInput('tolgee-secret', { required: true, trimWhitespace: true });
const httpClient = new http_client_1.HttpClient('VueTorrent GitHub Actions workflow');
core.debug('Extracting languages');
core.info(JSON.stringify(await extractLanguages(httpClient, tolgee_secret)));
core.debug('Exporting locale data to ./src/locales');
core.info(JSON.stringify(await exportLocaleData(tolgee_secret)));
await checkoutChanges('chore(localization): Update locales');
core.debug('Committing changes to repo');
await commitChanges('chore(localization): Update locales');
}
catch (error) {
core.setFailed(error.message);
Expand Down
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ async function extractLanguages(httpClient: HttpClient, api_key: string) {
const r_lang = await httpClient.getJson<LanguageResponse>(languages_url, {
'X-API-KEY': api_key
})
core.debug(JSON.stringify(r_lang.result))

if (r_lang.statusCode !== 200) throw new Error(`HTTP request failed. Received: ${ r_lang.statusCode }`)
if (r_lang.statusCode !== 200 || !r_lang.result) throw new Error(`HTTP request failed. Received: ${ r_lang.statusCode }`)

// @ts-ignore
const projectLocales = r_lang.result[0]
return projectLocales.map(locale_metadata => ({
tag: locale_metadata.tag,
Expand All @@ -33,7 +33,7 @@ async function exportLocaleData(api_key: string) {
await rm('locales.zip')
}

async function checkoutChanges(commit_message: string) {
async function commitChanges(commit_message: string) {
const gitPath = await which('git', true)
await exec(gitPath, ['status'])
// await exec(gitPath, ['add', '.'])
Expand All @@ -45,9 +45,12 @@ async function main() {
const tolgee_secret = core.getInput('tolgee-secret', { required: true, trimWhitespace: true })
const httpClient = new HttpClient('VueTorrent GitHub Actions workflow')

core.debug('Extracting languages')
core.info(JSON.stringify(await extractLanguages(httpClient, tolgee_secret)))
core.debug('Exporting locale data to ./src/locales')
core.info(JSON.stringify(await exportLocaleData(tolgee_secret)))
await checkoutChanges('chore(localization): Update locales')
core.debug('Committing changes to repo')
await commitChanges('chore(localization): Update locales')
} catch (error: any) {
core.setFailed(error.message)
}
Expand Down

0 comments on commit b4fa199

Please sign in to comment.