forked from Shopify/react-native-performance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
48 lines (41 loc) · 1.16 KB
/
plopfile.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
41
42
43
44
45
46
47
48
const {readdirSync, existsSync} = require('fs');
const path = require('path');
const jsPackages = getPackages('js');
module.exports = function (plop) {
plop.setGenerator('readme', {
description: "Generates root's README",
prompts: [],
actions: () => {
return [
{
type: 'add',
path: `README.md`,
templateFile: 'templates/README_ROOT.hbs.md',
force: true,
data: {
packages: jsPackages,
},
},
];
},
});
};
function getPackages(type = 'js') {
const packagesPath = path.join(__dirname, type === 'js' ? 'packages' : 'gems');
return readdirSync(packagesPath).reduce((acc, packageName) => {
const packageJSONPath = path.join(packagesPath, packageName, 'package.json');
if (existsSync(packageJSONPath)) {
const packageJSON = require(packageJSONPath);
let {name} = packageJSON;
const {version} = packageJSON;
name = name.replace('@shopify/', '');
const releaseTag = encodeURIComponent(`@shopify/${name}@${version}`);
acc.push({
name,
version,
releaseTag,
});
}
return acc;
}, []);
}