-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.js
77 lines (72 loc) · 2 KB
/
bootstrap.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const { existsSync, writeFileSync, readdirSync } = require('fs');
const { join } = require('path');
const { yParser } = require('@umijs/utils');
const getPackages = require('./utils/getPackages');
(async () => {
const args = yParser(process.argv);
const version = require('../lerna.json').version;
const pkgs = getPackages();
pkgs.forEach((shortName) => {
const name = shortName === 'umi' ? shortName : `@umijs/${shortName}`;
const pkgJSONPath = join(
__dirname,
'..',
'packages',
shortName,
'package.json',
);
const pkgJSONExists = existsSync(pkgJSONPath);
if (args.force || !pkgJSONExists) {
const json = {
name,
version,
description: name,
main: 'lib/index.js',
types: 'lib/index.d.ts',
files: ['lib', 'src'],
repository: {
type: 'git',
url: 'https://github.com/umijs/umi',
},
keywords: ['umi'],
authors: ['chencheng <[email protected]> (https://github.com/sorrycc)'],
license: 'MIT',
bugs: 'http://github.com/umijs/umi/issues',
homepage: `https://github.com/umijs/umi/tree/master/packages/${shortName}#readme`,
publishConfig: {
access: 'public',
},
};
if (pkgJSONExists) {
const pkg = require(pkgJSONPath);
[
'dependencies',
'devDependencies',
'peerDependencies',
'bin',
'files',
'authors',
'types',
'sideEffects',
'main',
'module',
].forEach((key) => {
if (pkg[key]) json[key] = pkg[key];
});
}
writeFileSync(pkgJSONPath, `${JSON.stringify(json, null, 2)}\n`);
}
if (shortName !== 'umi') {
const readmePath = join(
__dirname,
'..',
'packages',
shortName,
'README.md',
);
if (args.force || !existsSync(readmePath)) {
writeFileSync(readmePath, `# ${name}\n`);
}
}
});
})();