Skip to content

Commit

Permalink
added script for bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus25 committed Nov 8, 2021
1 parent 38dafee commit 0e52f50
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
36 changes: 36 additions & 0 deletions bump-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const path = require('path');
const { spawn } = require('child_process');
const { templates } = require('./utils');


init();


async function init() {

for (let i = 0; i < templates.length; i++) {

const { name, publishable } = templates[i];
const repoPath = path.resolve(name);
if (publishable) {
await new Promise((resolve) => {
const child = spawn(`cd ${repoPath} && yarn version --patch`, {
shell: true
});
child.stdout.on("data", function (data) {
console.log(`${data}`);
});
child.stderr.on("data", data => {
console.log(`stderr: ${data} `);
});
child.on("error", error => {
console.log(`error: ${error.message}`);
});
child.on("close", () => {
console.log('\x1b[32m%s\x1b[0m',);
resolve();
});
})
}
};
}
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');
const version = process.argv[2].trim();

const { templates, updateNBVersionInJsonFile, isUniversalTemplate, bumpVersion, executeShellCommand } = require('./utils');
const { templates, updateNBVersionInJsonFile, isUniversalTemplate, executeShellCommand } = require('./utils');


updateTemplates();
Expand All @@ -18,14 +18,12 @@ function updateTemplates() {
templatePaths.forEach(templatePath => {
const command = `cd ${templatePath} && yarn upgrade native-base@${version}`;
executeShellCommand(command, `${name} nb version changed`);
bumpVersion(repoPath, name);
});
} else {
//updates cra and universal templates
updateNestedTemplates(templatePaths, name, version).then(() => {
if (isUniversalTemplate(name))
executeShellCommand(`cd ${repoPath} && yarn`, `yarn install done in ${name}`)
bumpVersion(repoPath, name);
});
}
});
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"update-nativebase": "node index.js",
"publish-packages": "node publish-package.js"
"publish-packages": "node publish-package.js",
"bump-version": "node bump-version.js"
},
"repository": {
"type": "git",
Expand All @@ -18,4 +19,4 @@
"url": "https://github.com/GeekyAnts/nativebase-templates/issues"
},
"homepage": "https://github.com/GeekyAnts/nativebase-templates#readme"
}
}
4 changes: 0 additions & 4 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ var self = {
console.log('\x1b[32m%s\x1b[0m', msg);
});
},
//bump template version
bumpVersion: function (path, templateName) {
self.executeShellCommand(`cd ${path} && yarn version --patch`, `updated ${templateName} version`);
},
//update native base version in json file by writing the file
updateNBVersionInJsonFile: async function (filePath, templateName, version) {

Expand Down

0 comments on commit 0e52f50

Please sign in to comment.