nits & better console.log

This commit is contained in:
endiliey 2018-09-06 01:51:33 +08:00
parent a1a26d1c2e
commit 87bd1bea05
2 changed files with 31 additions and 33 deletions

View file

@ -124,11 +124,9 @@ if (feature === 'translations') {
// copy docs examples // copy docs examples
if (fs.existsSync(`${CWD}/../docs-examples-from-docusaurus`)) { if (fs.existsSync(`${CWD}/../docs-examples-from-docusaurus`)) {
console.log( console.log(
`${chalk.yellow( `- ${chalk.green(
'Example docs already exist!' 'docs-examples-from-docusaurus'
)} Rename or remove ${chalk.yellow( )} already exists in ${chalk.blue(outerFolder)}.`
`${outerFolder}/docs-examples-from-docusaurus`
)} to regenerate example docs.\n`
); );
} else { } else {
fs.copySync( fs.copySync(
@ -141,11 +139,9 @@ if (feature === 'translations') {
// copy blog examples // copy blog examples
if (fs.existsSync(`${CWD}/blog-examples-from-docusaurus`)) { if (fs.existsSync(`${CWD}/blog-examples-from-docusaurus`)) {
console.log( console.log(
`${chalk.yellow( `- ${chalk.green(
'Example blog posts already exist!' 'blog-examples-from-docusaurus'
)} Rename or remove ${chalk.yellow( )} already exists in ${chalk.blue(`${outerFolder}/website`)}.`
`${outerFolder}/website/blog-examples-from-docusaurus`
)} to regenerate example blog posts.\n`
); );
} else { } else {
fs.copySync( fs.copySync(
@ -156,33 +152,32 @@ if (feature === 'translations') {
blogCreated = true; blogCreated = true;
} }
const copyFileOutWebsiteFolder = (fileNameFrom, isHide) => { const copyFileToWebsite = (fileNameFrom, fileNameTo) => {
let fileNameTo = isHide ? `.${fileNameFrom}` : fileNameFrom; const copiedFileName = fileNameTo || fileNameFrom;
if (fs.existsSync(`${CWD}/../${fileNameTo}`)) { const src = path.join(folder, fileNameFrom);
fileNameTo = `${fileNameTo}-example-from-docusaurus`; const dest = path.join(CWD, '..', copiedFileName);
if (fs.existsSync(dest)) {
console.log( console.log(
`${chalk.yellow(fileNameTo + ' already exists')} in ${chalk.yellow( `- ${chalk.green(copiedFileName)} already exists in ${chalk.blue(
CWD outerFolder
)}. Creating an example ${fileNameTo} file for you to copy from if desired.\n` )}.`
); );
} else {
fs.copySync(src, dest);
} }
fs.copySync(
path.join(folder, fileNameFrom),
path.join(CWD, `/../${fileNameTo}`)
);
}; };
// copy .gitignore file // copy .gitignore file
copyFileOutWebsiteFolder('gitignore', true); copyFileToWebsite('gitignore', '.gitignore');
// copy Dockerfile file // copy Dockerfile file
copyFileOutWebsiteFolder('Dockerfile', false); copyFileToWebsite('Dockerfile');
// copy docker-compose.yml file // copy docker-compose.yml file
copyFileOutWebsiteFolder('docker-compose.yml', false); copyFileToWebsite('docker-compose.yml');
// copy .dockerignore file // copy .dockerignore file
copyFileOutWebsiteFolder('dockerignore', true); copyFileToWebsite('dockerignore', '.dockerignore');
// copy other files // copy other files
const files = glob.sync(`${folder}/**/*`); const files = glob.sync(`${folder}/**/*`);
@ -210,11 +205,11 @@ if (feature === 'translations') {
exampleSiteCreated = true; exampleSiteCreated = true;
} catch (e) { } catch (e) {
console.log( console.log(
`${chalk.yellow( `- ${chalk.green(
`${path.basename(filePath)} already exists` `${path.basename(filePath)}`
)} in ${chalk.yellow( )} already exists in ${chalk.blue(
`website${filePath.split(path.basename(filePath))[0]}` `${outerFolder}/website${filePath.split(path.basename(filePath))[0]}`
)}. Rename or remove the file to regenerate an example version.\n` )}.`
); );
} }
}); });

View file

@ -176,13 +176,16 @@ function execute() {
// Manually add 'Help Translate' to en.json // Manually add 'Help Translate' to en.json
translations['pages-strings'][ translations['pages-strings'][
'Help Translate|recruit community translators for your project' 'Help Translate|recruit community translators for your project'
] = 'Help Translate'; ] =
'Help Translate';
translations['pages-strings'][ translations['pages-strings'][
'Edit this Doc|recruitment message asking to edit the doc source' 'Edit this Doc|recruitment message asking to edit the doc source'
] = 'Edit'; ] =
'Edit';
translations['pages-strings'][ translations['pages-strings'][
'Translate this Doc|recruitment message asking to translate the docs' 'Translate this Doc|recruitment message asking to translate the docs'
] = 'Translate'; ] =
'Translate';
translations['pages-strings'] = Object.assign( translations['pages-strings'] = Object.assign(
translations['pages-strings'], translations['pages-strings'],
customTranslations['pages-strings'] customTranslations['pages-strings']