refactor: add tbody to contributors table (#307)

* refactor: add tbody to contributors table

* chore(node): bump version to lts

* fix(html): add correct indentation

* test(url): fix bind error message

Co-authored-by: Pierre Huyghe <phuyghe.externe@bedrockstreaming.com>
This commit is contained in:
Pierre Huyghe 2022-09-07 10:19:41 +02:00 committed by GitHub
parent 5dbb7213b0
commit deb6be93f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 42 deletions

View file

@ -2,7 +2,7 @@ version: 2.1
docker_defaults: &docker_defaults
docker:
- image: circleci/node:12.14.0
- image: cimg/node:16.17.0
commands:
prep_env:

2
.nvmrc
View file

@ -1 +1 @@
12.14.0
16.17.0

View file

@ -11,11 +11,13 @@ These people contributed to the project:
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Divjot Singh is awesome!</td>
<td align=\\"center\\">Jeroen Engels is awesome!</td>
</tr>
<tbody>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Divjot Singh is awesome!</td>
<td align=\\"center\\">Jeroen Engels is awesome!</td>
</tr>
</tobdy>
</table>
<!-- markdownlint-restore -->
@ -37,17 +39,19 @@ These people contributed to the project:
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
</tr>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
</tr>
<tbody>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
</tr>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
</tr>
</tobdy>
</table>
<!-- markdownlint-restore -->

View file

@ -3,7 +3,7 @@ const formatBadge = require('./format-badge')
const formatContributor = require('./format-contributor')
function injectListBetweenTags(newContent) {
return function(previousContent) {
return function (previousContent) {
const tagToLookFor = `<!-- ALL-CONTRIBUTORS-LIST:`
const closingTag = '-->'
const startOfOpeningTagIndex = previousContent.indexOf(
@ -39,7 +39,7 @@ function injectListBetweenTags(newContent) {
function formatLine(contributors) {
return `<td align="center">${contributors.join(
'</td>\n <td align="center">',
'</td>\n <td align="center">',
)}</td>`
}
@ -55,15 +55,15 @@ function generateContributorsList(options, contributors) {
}),
_.chunk(options.contributorsPerLine),
_.map(formatLine),
_.join('\n </tr>\n <tr>\n '),
_.join('\n </tr>\n <tr>\n '),
newContent => {
return `\n<table>\n <tr>\n ${newContent}\n </tr>\n</table>\n\n`
return `\n<table>\n <tbody>\n <tr>\n ${newContent}\n </tr>\n </tobdy>\n</table>\n\n`
},
)(contributors)
}
function replaceBadge(newContent) {
return function(previousContent) {
return function (previousContent) {
const tagToLookFor = `<!-- ALL-CONTRIBUTORS-BADGE:`
const closingTag = '-->'
const startOfOpeningTagIndex = previousContent.indexOf(

View file

@ -1,49 +1,57 @@
import url from '../url';
import url from '../url'
test(`Result of protocol validation should be true`, () => {
expect(url.isHttpProtocol('http:')).toBe(true)
expect(url.isHttpProtocol('https:')).toBe(true)
expect(url.isHttpProtocol('http:')).toBe(true)
expect(url.isHttpProtocol('https:')).toBe(true)
})
test(`Result of protocol validation should be false`, () => {
expect(url.isHttpProtocol('ftp:')).toBe(false)
expect(url.isHttpProtocol('ftp:')).toBe(false)
})
test(`Result of url validation should be true`, () => {
expect(url.isValidHttpUrl('https://api.github.com/users/octocat')).toBe(true)
expect(url.isValidHttpUrl('https://api.github.com/users/octocat')).toBe(true)
})
test(`Result of url validation should be false when url uses wrong protocol`, () => {
expect(url.isValidHttpUrl('git://git@github.com:all-contributors/all-contributors-cli.git')).toBe(false)
expect(
url.isValidHttpUrl(
'git://git@github.com:all-contributors/all-contributors-cli.git',
),
).toBe(false)
})
test(`Result of url validation should be false when input isn't url`, () => {
expect(url.isValidHttpUrl('github-octocat')).toBe(false)
expect(url.isValidHttpUrl('github-octocat')).toBe(false)
})
test(`Result of parsed url should be equal`, () => {
const input = 'https://api.github.com/users/octocat'
const expected = 'https://api.github.com/users/octocat'
expect(url.parseHttpUrl(input)).toBe(expected)
const input = 'https://api.github.com/users/octocat'
const expected = 'https://api.github.com/users/octocat'
expect(url.parseHttpUrl(input)).toBe(expected)
})
test(`Result of parsed url without protocol should be equal`, () => {
const input = 'example.com'
const expected = 'http://example.com/'
expect(url.parseHttpUrl(input)).toBe(expected)
const input = 'example.com'
const expected = 'http://example.com/'
expect(url.parseHttpUrl(input)).toBe(expected)
})
test(`Throw an error when parsed input isn't a string`, () => {
const input = 123
expect(url.parseHttpUrl.bind(null, input)).toThrowError('input must be a string')
const input = 123
expect(url.parseHttpUrl.bind(null, input)).toThrowError(
'input must be a string',
)
})
test(`Throw an error when parsed url has wrong protocol`, () => {
const input = 'ftp://domain.xyz'
expect(url.parseHttpUrl.bind(null, input)).toThrowError('Provided URL has an invalid protocol')
const input = 'ftp://domain.xyz'
expect(url.parseHttpUrl.bind(null, input)).toThrowError(
'Provided URL has an invalid protocol',
)
})
test(`Throw an error when parsed input isn't a URL`, () => {
const input = 'some string'
expect(url.parseHttpUrl.bind(null, input)).toThrowError('Invalid URL: http://some string')
const input = 'some string'
expect(url.parseHttpUrl.bind(null, input)).toThrowError('Invalid URL')
})