1 | 'use strict'
|
2 | Object.defineProperty(exports, '__esModule', { value: true })
|
3 | exports.getContributeSection = exports.getBackerFile = exports.getBackerSection = void 0
|
4 | const util_js_1 = require('./util.js')
|
5 | const badge_js_1 = require('./badge.js')
|
6 | function getSponsorsText(data) {
|
7 | let result = ''
|
8 | if (data.sponsors.length === 0) {
|
9 |
|
10 | result +=
|
11 | 'No sponsors yet! Will you be the first?\n\n' +
|
12 | badge_js_1.getBadgesInCategory('funding', data)
|
13 | } else {
|
14 | result +=
|
15 | 'These amazing people have contributed finances to this project:\n\n' +
|
16 | util_js_1.getPeopleHTML(data.sponsors) +
|
17 | `\n\nBecome a sponsor!\n\n${badge_js_1.getBadgesInCategory(
|
18 | 'funding',
|
19 | data
|
20 | )}`
|
21 | }
|
22 | return result
|
23 | }
|
24 | function getMaintainersText(data) {
|
25 | let result = ''
|
26 | if (data.maintainers.length === 0) {
|
27 |
|
28 | result += 'No maintainers yet! Will you be the first?'
|
29 | } else {
|
30 | result +=
|
31 | 'These amazing people are maintaining this project:\n\n' +
|
32 | util_js_1.getPeopleHTML(data.maintainers, {
|
33 | displayContributions: true,
|
34 | githubRepoSlug: data.github.slug,
|
35 | })
|
36 | }
|
37 | return result
|
38 | }
|
39 | function getContributeLink(data, optional = false) {
|
40 |
|
41 | const file = data.filenamesForReadmeFiles.contributing
|
42 | if (!file) {
|
43 | if (optional) {
|
44 | return ''
|
45 | } else {
|
46 | throw new Error(
|
47 | 'Contributing section requires a CONTRIBUTING file to exist'
|
48 | )
|
49 | }
|
50 | }
|
51 | const url = util_js_1.getFileUrl(data, file)
|
52 | const text = `Discover how you can contribute by heading on over to the <code>${file}</code> file.`
|
53 |
|
54 | return util_js_1.getLink({ url, text })
|
55 | }
|
56 | function getContributorsText(data) {
|
57 | let result = ''
|
58 | if (data.contributors.length === 0) {
|
59 |
|
60 | result +=
|
61 | 'No contributors yet! Will you be the first?' +
|
62 | `\n\n${getContributeLink(data, true)}`
|
63 | } else {
|
64 | result +=
|
65 | 'These amazing people have contributed code to this project:\n\n' +
|
66 | util_js_1.getPeopleHTML(data.contributors, {
|
67 | displayContributions: true,
|
68 | githubRepoSlug: data.github.slug,
|
69 | }) +
|
70 | `\n\n${getContributeLink(data, true)}`
|
71 | }
|
72 | return result
|
73 | }
|
74 | function getBackerSection(data) {
|
75 |
|
76 | const result = [
|
77 | '<h2>Backers</h2>',
|
78 | '',
|
79 | '<h3>Maintainers</h3>',
|
80 | '',
|
81 | getMaintainersText(data),
|
82 | '',
|
83 | '<h3>Sponsors</h3>',
|
84 | '',
|
85 | getSponsorsText(data),
|
86 | '',
|
87 | '<h3>Contributors</h3>',
|
88 | '',
|
89 | getContributorsText(data),
|
90 | ].join('\n')
|
91 |
|
92 | return result
|
93 | }
|
94 | exports.getBackerSection = getBackerSection
|
95 | function getBackerFile(data) {
|
96 |
|
97 | const result = [
|
98 | '<h1>Backers</h1>',
|
99 | '',
|
100 | '<h2>Maintainers</h2>',
|
101 | '',
|
102 | getMaintainersText(data),
|
103 | '',
|
104 | '<h2>Sponsors</h2>',
|
105 | '',
|
106 | getSponsorsText(data),
|
107 | '',
|
108 | '<h2>Contributors</h2>',
|
109 | '',
|
110 | getContributorsText(data),
|
111 | ].join('\n')
|
112 |
|
113 | return result
|
114 | }
|
115 | exports.getBackerFile = getBackerFile
|
116 | function getContributeSection(data) {
|
117 |
|
118 | const result = ['<h2>Contribute</h2>', '', getContributeLink(data)].join('\n')
|
119 |
|
120 | return result
|
121 | }
|
122 | exports.getContributeSection = getContributeSection
|