Skip to content

Commit

Permalink
perf(automation): automate branch and version string replacement #36
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Aug 24, 2023
1 parent 6ef9fa6 commit f7fee80
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/utils/auroLibraryUtils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export default class AuroLibraryUtils {
} else {
try {
fs.copyFileSync(sourceFilePath, destFilePath);

fs.readFile(destFilePath, 'utf8', (err, data) => {
this.formatFileContents(data, destFilePath);
});

this.auroLogger(`Copied file: ${file}`, 'success');
} catch (err) {
this.auroLogger(`Error copying file ${file}: ${err}`, 'error');
Expand Down Expand Up @@ -118,7 +123,7 @@ export default class AuroLibraryUtils {
}

/**
* Extracts NPM, NAMESPACE, NAME, NPM VERSION and BRANCH NAME from package.json.
* Extracts NPM VERSION, BRANCH NAME, NPM, NAMESPACE, and NAME from package.json.
* @returns {Object} result - Object containing data from package.json.
*/
nameExtraction() {
Expand All @@ -135,6 +140,8 @@ export default class AuroLibraryUtils {
let nameStart = pName.indexOf('-');

let result = {
'abstractNodeVersion': JSON.parse(packageJson).engines.node.substring(2),
'branchName': JSON.parse(packageJson).release.branch,
'npm': pName.substring(npmStart, namespaceStart),
'namespace': pName.substring(namespaceStart + 1, nameStart),
'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
Expand All @@ -155,6 +162,8 @@ export default class AuroLibraryUtils {
/**
* Replace placeholder strings
*/
result = result.replace(/\[abstractNodeVersion]/g, nameExtractionData.abstractNodeVersion);
result = result.replace(/\[branchName]/g, nameExtractionData.branchName);
result = result.replace(/\[npm]/g, nameExtractionData.npm);
result = result.replace(/\[name](?!\()/g, nameExtractionData.name);
result = result.replace(/\[Name](?!\()/g, nameExtractionData.nameCap);
Expand Down

0 comments on commit f7fee80

Please sign in to comment.