-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Jest, switch to
semver
for compare, fix downgrade issue (#39)
* add Jest, fix downgrade issue * fix main workflow, add test workflow * switch to `semver`, improve sorting, add more complex test
- Loading branch information
Showing
18 changed files
with
24,417 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Run Tests | ||
on: [pull_request] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
- run: yarn | ||
- run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [['@babel/preset-env', { targets: { node: 'current' } }]] | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
transformIgnorePatterns: ['<rootDir>/node_modules/*'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const { markdownTable } = require('markdown-table'); | ||
|
||
const { STATUS, countStatuses } = require('./utils'); | ||
|
||
const ASSETS_URL = { | ||
ADDED: 'https://git.io/J38HP', | ||
DOWNGRADED: 'https://git.io/J38ds', | ||
REMOVED: 'https://git.io/J38dt', | ||
UPDATED: 'https://git.io/J38dY' | ||
}; | ||
|
||
const getStatusLabel = status => | ||
`[<sub><img alt="${status}" src="${ASSETS_URL[status]}" height="16" /></sub>](#)`; | ||
|
||
export const createTable = (lockChanges, plainStatuses = false) => | ||
markdownTable( | ||
[ | ||
['Name', 'Status', 'Previous', 'Current'], | ||
...Object.entries(lockChanges) | ||
.map(([key, { status, previous, current }]) => [ | ||
'`' + key + '`', | ||
plainStatuses ? status : getStatusLabel(status), | ||
previous, | ||
current | ||
]) | ||
.sort((a, b) => a[0].localeCompare(b[0])) | ||
], | ||
{ align: ['l', 'c', 'c', 'c'], alignDelimiters: false } | ||
); | ||
|
||
const createSummaryRow = (lockChanges, status) => { | ||
const statusCount = countStatuses(lockChanges, status); | ||
return statusCount ? [getStatusLabel(status), statusCount] : undefined; | ||
}; | ||
|
||
export const createSummary = lockChanges => | ||
markdownTable( | ||
[ | ||
['Status', 'Count'], | ||
createSummaryRow(lockChanges, STATUS.ADDED), | ||
createSummaryRow(lockChanges, STATUS.UPDATED), | ||
createSummaryRow(lockChanges, STATUS.DOWNGRADED), | ||
createSummaryRow(lockChanges, STATUS.REMOVED) | ||
].filter(Boolean), | ||
{ align: ['l', 'c'], alignDelimiters: false } | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.