mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Fix crowdin's branch selection for non-tty environment, add support for CI-provided branch name [skip ci]
Show crowdin's error at any depth
Show branch name on i18n:push
Unpack git .pack objects to fix automatic branch detect (seems like a workaround for a workaround 🙃)
Detect git branch from CI if available.
Replace git-repo-info with git-rev-sync (maintained)
Fix accidentally removed git installation for Yarn job
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import chalk from 'chalk';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import util from 'util';
|
||||
|
||||
import axios from 'axios';
|
||||
import JSON5 from 'json5';
|
||||
@@ -13,7 +14,7 @@ import ch from 'chalk';
|
||||
import iso639 from 'iso-639-1';
|
||||
import { prompt, DistinctQuestion } from 'inquirer';
|
||||
|
||||
import getRepoInfo from 'git-repo-info';
|
||||
import git from 'git-rev-sync';
|
||||
|
||||
import { crowdin as config } from './../../config';
|
||||
|
||||
@@ -183,8 +184,22 @@ async function ensureDirectory(dirPath: string, branchId?: number): Promise<numb
|
||||
}, Promise.resolve<number>(null));
|
||||
}
|
||||
|
||||
function getGitBranch(): string {
|
||||
if (process.env.CI_COMMIT_BRANCH) {
|
||||
return process.env.CI_COMMIT_BRANCH;
|
||||
}
|
||||
|
||||
const branch = git.branch();
|
||||
|
||||
if (branch.startsWith('Detached')) {
|
||||
throw new Error(`Cannot automatically detect git branch. Received "${branch}"`);
|
||||
}
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
async function pull(): Promise<void> {
|
||||
const { branch: branchName } = getRepoInfo();
|
||||
const branchName = getGitBranch();
|
||||
const isMasterBranch = branchName === 'master';
|
||||
let branchId: number | undefined;
|
||||
|
||||
@@ -299,7 +314,7 @@ async function push(): Promise<void> {
|
||||
},
|
||||
];
|
||||
|
||||
const { branch: branchName } = getRepoInfo();
|
||||
const branchName = getGitBranch();
|
||||
const isMasterBranch = branchName === 'master';
|
||||
|
||||
if (!isMasterBranch) {
|
||||
@@ -307,12 +322,12 @@ async function push(): Promise<void> {
|
||||
name: 'publishInBranch',
|
||||
type: 'confirm',
|
||||
default: true,
|
||||
message: `Should be strings published in its own branch [${chalk.green(getRepoInfo().branch)}]?`,
|
||||
message: `Should be strings published in its own branch [${chalk.green(branchName)}]?`,
|
||||
});
|
||||
}
|
||||
|
||||
let disapproveTranslates = true;
|
||||
let publishInBranch = isMasterBranch;
|
||||
let publishInBranch = !isMasterBranch;
|
||||
try {
|
||||
const answers = await prompt(questions);
|
||||
disapproveTranslates = answers[0]; // eslint-disable-line prefer-destructuring
|
||||
@@ -400,6 +415,7 @@ async function push(): Promise<void> {
|
||||
console.error(`Unknown action ${action}`);
|
||||
}
|
||||
} catch (exception) {
|
||||
console.error(exception);
|
||||
console.error(util.inspect(exception, { depth: null }));
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
|
@@ -14,7 +14,7 @@
|
||||
"@crowdin/crowdin-api-client": "^1.8.0",
|
||||
"axios": "^0.19.2",
|
||||
"chalk": "^4.0.0",
|
||||
"git-repo-info": "^2.1.1",
|
||||
"git-rev-sync": "^2.0.0",
|
||||
"glob": "^7.1.6",
|
||||
"inquirer": "7.0.6",
|
||||
"iso-639-1": "^2.1.3",
|
||||
@@ -22,6 +22,7 @@
|
||||
"progress": "^2.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/git-rev-sync": "^2.0.0",
|
||||
"@types/inquirer": "^6.5.0",
|
||||
"@types/json5": "^0.0.30",
|
||||
"@types/progress": "^2.0.3",
|
||||
|
Reference in New Issue
Block a user