1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const fs = require('fs-extra')
|
13 | const Readme = require('@oclif/dev-cli/lib/commands/readme').default
|
14 |
|
15 | function genRow (pkName) {
|
16 | return `| [@${pkName}](https://github.com/${pkName}) ` +
|
17 | `| [![Version](https://img.shields.io/npm/v/@${pkName}.svg)](https://npmjs.org/package/@${pkName})` +
|
18 | `| [![Downloads/week](https://img.shields.io/npm/dw/@${pkName}.svg)](https://npmjs.org/package/@${pkName})` +
|
19 | `| [![Build Status](https://travis-ci.com/${pkName}.svg?branch=master)](https://travis-ci.com/${pkName})` +
|
20 | `| [![Codecov Coverage](https://img.shields.io/codecov/c/github/${pkName}/master.svg?style=flat-square)](https://codecov.io/gh/${pkName}/)` +
|
21 | `| [![Github Issues](https://img.shields.io/github/issues/${pkName}.svg)](https://github.com/${pkName}/issues)` +
|
22 | `| [![Github Pull Requests](https://img.shields.io/github/issues-pr/${pkName}.svg)](https://github.com/${pkName}/pulls)|`
|
23 | }
|
24 |
|
25 | function replaceTag (readme, tag, body) {
|
26 | const oclDev = new Readme()
|
27 | return oclDev.replaceTag(readme, tag, body)
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | }
|
38 |
|
39 |
|
40 |
|
41 | const pkjson = fs.readJSONSync('package.json')
|
42 | const adobeDeps = pkjson.oclif.plugins
|
43 | .filter(item => item.indexOf('@adobe/aio-cli-plugin') === 0)
|
44 | .concat([
|
45 | '@adobe/generator-aio-app'
|
46 | ])
|
47 | .map(item => item.substring(1))
|
48 |
|
49 |
|
50 | adobeDeps.unshift(pkjson.name.substring(1))
|
51 |
|
52 |
|
53 | const tableData = ['| Module | Version | Downloads | Build Status | Coverage | Issues | Pull Requests |',
|
54 | '|---|---|---|---|---|---|---|']
|
55 |
|
56 |
|
57 | adobeDeps.forEach(item => { tableData.push(genRow(item)) })
|
58 |
|
59 |
|
60 | const readme = fs.readFileSync('README.md', 'utf8')
|
61 | fs.writeFileSync('README.md', replaceTag(readme, 'health', tableData.join('\n')))
|