@talend/i18n-scripts
Advanced tools
Comparing version 2.0.6 to 2.1.0
# Deploy | ||
This step will push downloaded i18n files to github. Files will be generated to create a npm or maven module. For now, no module is deployed on npm/mvn repositories. | ||
This step will push downloaded i18n files to github. Files will be generated to create a npm or maven module. | ||
@@ -5,0 +5,0 @@ You need to pass github credentials as environment variables. |
{ | ||
"name": "@talend/i18n-scripts", | ||
"description": "Set of scripts to ease i18n workflow", | ||
"version": "2.0.6", | ||
"version": "2.1.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -10,35 +10,9 @@ const fs = require('fs'); | ||
const { getVersion } = require('../common/version'); | ||
const { setDoubleQuote } = require('../common/fixQuote'); | ||
// find odd number of following quote and capture them | ||
const REGEX_SINGLE_QUOTE = /([^']|^)'('')*(?!')/g; | ||
function replaceOddQuote(fileName) { | ||
const content = fs.readFileSync(fileName, 'utf-8'); | ||
const newValue = content.replace(REGEX_SINGLE_QUOTE, "$&'"); | ||
fs.writeFileSync(fileName, newValue); | ||
} | ||
function findPropertiesFiles(currentPath) { | ||
const propsFiles = []; | ||
if (!fs.existsSync(currentPath)) { | ||
return propsFiles; | ||
} | ||
fs.readdirSync(currentPath).forEach(file => { | ||
const filename = path.join(currentPath, file); | ||
if (fs.lstatSync(filename).isDirectory()) { | ||
propsFiles.push(...findPropertiesFiles(filename)); | ||
} else if (filename.endsWith('.properties')) { | ||
propsFiles.push(filename); | ||
} | ||
}); | ||
return propsFiles; | ||
} | ||
function fixOddQuote(data) { | ||
const { targetPath, fixQuote } = data; | ||
if (fixQuote) { | ||
fs.readdirSync(targetPath) | ||
.map(currentFolder => path.join(targetPath, currentFolder)) | ||
.flatMap(findPropertiesFiles) | ||
.forEach(replaceOddQuote); | ||
setDoubleQuote(targetPath); | ||
} | ||
@@ -52,4 +26,4 @@ return data; | ||
fs.readdirSync(targetPath) | ||
.filter(fileName => fileName.endsWith('.zip')) | ||
.forEach(fileName => { | ||
.filter((fileName) => fileName.endsWith('.zip')) | ||
.forEach((fileName) => { | ||
const filePath = path.join(targetPath, fileName); | ||
@@ -65,5 +39,5 @@ const zip = new Zip(filePath); | ||
const { targetPath } = data; | ||
fs.readdirSync(targetPath).forEach(language => { | ||
fs.readdirSync(targetPath).forEach((language) => { | ||
const languagePath = path.join(targetPath, language); | ||
fs.readdirSync(languagePath).forEach(version => { | ||
fs.readdirSync(languagePath).forEach((version) => { | ||
const languageVersionPath = path.join(targetPath, language, version); | ||
@@ -75,3 +49,3 @@ const versionLanguagePath = path.join(targetPath, version, language); | ||
fs.readdirSync(languageVersionPath).forEach(fileName => { | ||
fs.readdirSync(languageVersionPath).forEach((fileName) => { | ||
fs.renameSync( | ||
@@ -114,3 +88,3 @@ path.join(languageVersionPath, fileName), | ||
.then(reshapeFolders) | ||
.catch(e => { | ||
.catch((e) => { | ||
error(e.message); | ||
@@ -117,0 +91,0 @@ }); |
@@ -13,2 +13,3 @@ const fs = require('fs'); | ||
const { getXmlAsJson } = require('../common/files'); | ||
const { setSingleQuote } = require('../common/fixQuote'); | ||
@@ -22,3 +23,3 @@ /** | ||
return new Promise((resolve) => { | ||
find.file(path, resolve) | ||
find.file(path, resolve); | ||
}); | ||
@@ -34,3 +35,3 @@ } | ||
return new Promise((resolve) => { | ||
find.dir(path, resolve) | ||
find.dir(path, resolve); | ||
}); | ||
@@ -82,3 +83,3 @@ } | ||
const extractionFolder = path.join(process.cwd(), target); | ||
files.forEach(srcPath => { | ||
files.forEach((srcPath) => { | ||
const filename = path.basename(srcPath); | ||
@@ -143,3 +144,3 @@ const srcFolder = path.dirname(srcPath); | ||
const searchFolders = [].concat( | ||
rootPath === 'mvnModules' ? getMvnChildModulesFolders(options) : rootPath | ||
rootPath === 'mvnModules' ? getMvnChildModulesFolders(options) : rootPath, | ||
); | ||
@@ -163,6 +164,3 @@ | ||
const files = child.stdout | ||
.toString() | ||
.split('\n') | ||
.filter(Boolean); | ||
const files = child.stdout.toString().split('\n').filter(Boolean); | ||
if (!files.length) { | ||
@@ -178,24 +176,20 @@ error(`No file matches the expression "${expression}" from ${rootPath}`); | ||
files | ||
.forEach(filePath => { | ||
const fileName = path.basename(filePath); | ||
fs.renameSync(filePath, path.join(target, fileName)); | ||
}); | ||
files.forEach((filePath) => { | ||
const fileName = path.basename(filePath); | ||
fs.renameSync(filePath, path.join(target, fileName)); | ||
}); | ||
const directoriesChild = await listDirs(target); | ||
directoriesChild | ||
.filter(folderPath => folderPath && folderPath !== target) | ||
.forEach(folderPath => rimraf.sync(folderPath)); | ||
} else if(transform === 'rename-to-properties') { | ||
.filter((folderPath) => folderPath && folderPath !== target) | ||
.forEach((folderPath) => rimraf.sync(folderPath)); | ||
} else if (transform === 'rename-to-properties') { | ||
const files = await listFiles(target); | ||
files | ||
.forEach(filePath => { | ||
const { dir, ext, name } = path.parse(filePath); | ||
if (ext === 'properties') { | ||
return; | ||
} | ||
fs.renameSync(filePath, path.join(dir, `${name}.properties`)); | ||
}); | ||
files.forEach((filePath) => { | ||
const { dir, ext, name } = path.parse(filePath); | ||
if (ext === 'properties') { | ||
return; | ||
} | ||
fs.renameSync(filePath, path.join(dir, `${name}.properties`)); | ||
}); | ||
} | ||
@@ -211,3 +205,3 @@ } | ||
mkdirp.sync(versionFolderPath); | ||
i18nContent.forEach(fileName => { | ||
i18nContent.forEach((fileName) => { | ||
const originalPath = path.join(target, fileName); | ||
@@ -221,3 +215,3 @@ const newPath = path.join(versionFolderPath, fileName); | ||
async function runExtract({ extract }) { | ||
async function runExtract({ extract, load }) { | ||
const { method, target } = extract; | ||
@@ -246,2 +240,5 @@ rimraf.sync(target); | ||
await runTransform(extract); | ||
if (load.fixQuote) { | ||
setSingleQuote(target); | ||
} | ||
wrapWithVersion(extract); | ||
@@ -248,0 +245,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113065
26
1458
27