Skip to content

Commit 0e52f50

Browse files
committed
added script for bump version
1 parent 38dafee commit 0e52f50

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

bump-version.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const path = require('path');
2+
const { spawn } = require('child_process');
3+
const { templates } = require('./utils');
4+
5+
6+
init();
7+
8+
9+
async function init() {
10+
11+
for (let i = 0; i < templates.length; i++) {
12+
13+
const { name, publishable } = templates[i];
14+
const repoPath = path.resolve(name);
15+
if (publishable) {
16+
await new Promise((resolve) => {
17+
const child = spawn(`cd ${repoPath} && yarn version --patch`, {
18+
shell: true
19+
});
20+
child.stdout.on("data", function (data) {
21+
console.log(`${data}`);
22+
});
23+
child.stderr.on("data", data => {
24+
console.log(`stderr: ${data} `);
25+
});
26+
child.on("error", error => {
27+
console.log(`error: ${error.message}`);
28+
});
29+
child.on("close", () => {
30+
console.log('\x1b[32m%s\x1b[0m',);
31+
resolve();
32+
});
33+
})
34+
}
35+
};
36+
}

index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
22
const version = process.argv[2].trim();
33

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

66

77
updateTemplates();
@@ -18,14 +18,12 @@ function updateTemplates() {
1818
templatePaths.forEach(templatePath => {
1919
const command = `cd ${templatePath} && yarn upgrade native-base@${version}`;
2020
executeShellCommand(command, `${name} nb version changed`);
21-
bumpVersion(repoPath, name);
2221
});
2322
} else {
2423
//updates cra and universal templates
2524
updateNestedTemplates(templatePaths, name, version).then(() => {
2625
if (isUniversalTemplate(name))
2726
executeShellCommand(`cd ${repoPath} && yarn`, `yarn install done in ${name}`)
28-
bumpVersion(repoPath, name);
2927
});
3028
}
3129
});

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"update-nativebase": "node index.js",
9-
"publish-packages": "node publish-package.js"
9+
"publish-packages": "node publish-package.js",
10+
"bump-version": "node bump-version.js"
1011
},
1112
"repository": {
1213
"type": "git",
@@ -18,4 +19,4 @@
1819
"url": "https://github.com/GeekyAnts/nativebase-templates/issues"
1920
},
2021
"homepage": "https://github.com/GeekyAnts/nativebase-templates#readme"
21-
}
22+
}

utils.js

-4
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ var self = {
110110
console.log('\x1b[32m%s\x1b[0m', msg);
111111
});
112112
},
113-
//bump template version
114-
bumpVersion: function (path, templateName) {
115-
self.executeShellCommand(`cd ${path} && yarn version --patch`, `updated ${templateName} version`);
116-
},
117113
//update native base version in json file by writing the file
118114
updateNBVersionInJsonFile: async function (filePath, templateName, version) {
119115

0 commit comments

Comments
 (0)