forked from GeekyAnts/nativebase-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (30 loc) · 1.36 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const path = require('path');
const version = process.argv[2].trim();
const { templates, updateNBVersionInJsonFile, isUniversalTemplate, executeShellCommand } = require('./utils');
updateTemplates();
function updateTemplates() {
templates.forEach(template => {
const { name, paths: templatePaths, nested } = template;
const repoPath = path.resolve(name);
if (!nested) {
//updates expo, next and react-native templates
templatePaths.forEach(templatePath => {
const command = `cd ${templatePath} && yarn upgrade native-base@${version}`;
executeShellCommand(command, `${name} nb version changed`);
});
} else {
//updates cra and universal templates
updateNestedTemplates(templatePaths, name, version).then(() => {
if (isUniversalTemplate(name))
executeShellCommand(`cd ${repoPath} && yarn`, `yarn install done in ${name}`)
});
}
});
}
async function updateNestedTemplates(templatePaths, name, version) {
for (let i = 0; i < templatePaths.length; i++) {
const templatePath = templatePaths[i];
const jsonFileName = isUniversalTemplate(name) ? "package.json" : "template.json";
await updateNBVersionInJsonFile(`${templatePath}/${jsonFileName}`, name, version);
}
}