Skip to content

Commit

Permalink
Merge pull request #162 from github/changeset-in-details-with-details
Browse files Browse the repository at this point in the history
Changeset in details with details
  • Loading branch information
mattcosta7 authored Aug 5, 2022
2 parents 34b5e51 + 58fc2b0 commit 3ac4188
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 246 deletions.
168 changes: 168 additions & 0 deletions __tests__/__snapshots__/main.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Shows stats when files are added 1`] = `
"**Total**
Files count | Type | Total bundle size | % Changed
----------- | ---- | ----------------- | ---------
2 -> 7 | bundled<br />gzip | 1.29 MB -> 1.34 MB (+53.65 KB)<br />N/A -> 386.44 KB | +4.07%"
`;

exports[`Shows stats when files are added 2`] = `
"**Added**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
296.chunk.js | bundled<br />gzip | 0 B -> 124.57 KB (+124.57 KB)<br />0 B -> 35.05 KB | -
288.chunk.js | bundled<br />gzip | 0 B -> 57.24 KB (+57.24 KB)<br />0 B -> 16.33 KB | -
920.chunk.js | bundled<br />gzip | 0 B -> 54.98 KB (+54.98 KB)<br />0 B -> 17.08 KB | -
912.chunk.js | bundled<br />gzip | 0 B -> 44.37 KB (+44.37 KB)<br />0 B -> 14.31 KB | -
699.chunk.js | bundled<br />gzip | 0 B -> 26.39 KB (+26.39 KB)<br />0 B -> 6.14 KB | -
**Removed**
No assets were removed
**Bigger**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
manifest.json | bundled<br />gzip | 91 B -> 551 B (+460 B)<br />N/A -> 151 B | +505.49%
**Smaller**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
app.bundle.js | bundled<br />gzip | 1.29 MB -> 1.04 MB (-254.35 KB)<br />N/A -> 297.38 KB | -19.29%
**Unchanged**
No assets were unchanged"
`;

exports[`Shows stats when files are removed 1`] = `
"**Total**
Files count | Type | Total bundle size | % Changed
----------- | ---- | ----------------- | ---------
7 -> 2 | bundled<br />gzip | 1.34 MB -> 1.29 MB (-53.65 KB)<br />386.44 KB -> N/A | -3.91%"
`;

exports[`Shows stats when files are removed 2`] = `
"**Added**
No assets were added
**Removed**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
296.chunk.js | bundled<br />gzip | 124.57 KB -> 0 B (-124.57 KB)<br />35.05 KB -> 0 B | -100%
288.chunk.js | bundled<br />gzip | 57.24 KB -> 0 B (-57.24 KB)<br />16.33 KB -> 0 B | -100%
920.chunk.js | bundled<br />gzip | 54.98 KB -> 0 B (-54.98 KB)<br />17.08 KB -> 0 B | -100%
912.chunk.js | bundled<br />gzip | 44.37 KB -> 0 B (-44.37 KB)<br />14.31 KB -> 0 B | -100%
699.chunk.js | bundled<br />gzip | 26.39 KB -> 0 B (-26.39 KB)<br />6.14 KB -> 0 B | -100%
**Bigger**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
app.bundle.js | bundled<br />gzip | 1.04 MB -> 1.29 MB (+254.35 KB)<br />297.38 KB -> N/A | +23.91%
**Smaller**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
manifest.json | bundled<br />gzip | 551 B -> 91 B (-460 B)<br />151 B -> N/A | -83.48%
**Unchanged**
No assets were unchanged"
`;

exports[`Shows stats when files are unchanged 1`] = `
"**Total**
Files count | Type | Total bundle size | % Changed
----------- | ---- | ----------------- | ---------
7 | bundled<br />gzip | 1.34 MB<br />386.44 KB | 0%"
`;

exports[`Shows stats when files are unchanged 2`] = `
"**Added**
No assets were added
**Removed**
No assets were removed
**Bigger**
No assets were bigger
**Smaller**
No assets were smaller
**Unchanged**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
app.bundle.js | bundled<br />gzip | 1.04 MB<br />297.38 KB | 0%
296.chunk.js | bundled<br />gzip | 124.57 KB<br />35.05 KB | 0%
288.chunk.js | bundled<br />gzip | 57.24 KB<br />16.33 KB | 0%
920.chunk.js | bundled<br />gzip | 54.98 KB<br />17.08 KB | 0%
912.chunk.js | bundled<br />gzip | 44.37 KB<br />14.31 KB | 0%
699.chunk.js | bundled<br />gzip | 26.39 KB<br />6.14 KB | 0%
manifest.json | bundled<br />gzip | 551 B<br />151 B | 0%"
`;

exports[`displays module information when files are added/removed/changed 1`] = `
"
<details>
<summary>**Changeset**</summary>
File | Δ
---- | -
\`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 🆕 +2.72 KB
\`src/client/this-file-was-added.ts\` | 🆕 +1.46 KB
\`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 🆕 +1.04 KB
\`src/client/helpers/this-file-is-much-larger.ts\` | 📈 +11.66 KB (+865.77%)
\`src/client/this-file-grew-larger.tsx\` | 📈 +200 B (+35.59%)
\`src/client/helpers/this-file-grew-smaller.ts\` | 📉 -200 B (-7.94%)
\`src/client/this-file-is-much-smaller.tsx\` | 📉 -11.66 KB (-99.92%)
\`src/client/routes.tsx\` | 🔥 -2.72 KB (-100%)
\`src/client/this-file-will-be-deleted.ts\` | 🔥 -1.46 KB (-100%)
\`src/client/render-memex.tsx\` | 🔥 -1.04 KB (-100%)
<details>
<summary>View individual file sizes</summary>
File | Old | New | Δ
---- | --- | --- | -
\`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 0 B | 2.72 KB | 🆕 +2.72 KB
\`src/client/this-file-was-added.ts\` | 0 B | 1.46 KB | 🆕 +1.46 KB
\`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 0 B | 1.04 KB | 🆕 +1.04 KB
\`src/client/helpers/this-file-is-much-larger.ts\` | 1.35 KB | 13.01 KB | 📈 +11.66 KB (+865.77%)
\`src/client/this-file-grew-larger.tsx\` | 562 B | 762 B | 📈 +200 B (+35.59%)
\`src/client/helpers/this-file-grew-smaller.ts\` | 2.46 KB | 2.26 KB | 📉 -200 B (-7.94%)
\`src/client/this-file-is-much-smaller.tsx\` | 11.67 KB | 10 B | 📉 -11.66 KB (-99.92%)
\`src/client/routes.tsx\` | 2.72 KB | 0 B | 🔥 -2.72 KB (-100%)
\`src/client/this-file-will-be-deleted.ts\` | 1.46 KB | 0 B | 🔥 -1.46 KB (-100%)
\`src/client/render-memex.tsx\` | 1.04 KB | 0 B | 🔥 -1.04 KB (-100%)
</details>
</details>
"
`;

exports[`displays no module information when unchanged 1`] = `
"
**Changeset**
No files were changed"
`;

exports[`does not display module information when it does not exist 1`] = `""`;
149 changes: 9 additions & 140 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,8 @@ test('Shows stats when files are removed', () => {
require('./__mocks__/new-stats-assets.json')
)

expect(printTotalAssetTable(statsDiff)).toEqual(`**Total**
Files count | Type | Total bundle size | % Changed
----------- | ---- | ----------------- | ---------
7 -> 2 | bundled<br />gzip | 1.34 MB -> 1.29 MB (-53.65 KB)<br />386.44 KB -> N/A | -3.91%`)
expect(printAssetTablesByGroup(statsDiff)).toEqual(`**Added**
No assets were added
**Removed**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
296.chunk.js | bundled<br />gzip | 124.57 KB -> 0 B (-124.57 KB)<br />35.05 KB -> 0 B | -100%
288.chunk.js | bundled<br />gzip | 57.24 KB -> 0 B (-57.24 KB)<br />16.33 KB -> 0 B | -100%
920.chunk.js | bundled<br />gzip | 54.98 KB -> 0 B (-54.98 KB)<br />17.08 KB -> 0 B | -100%
912.chunk.js | bundled<br />gzip | 44.37 KB -> 0 B (-44.37 KB)<br />14.31 KB -> 0 B | -100%
699.chunk.js | bundled<br />gzip | 26.39 KB -> 0 B (-26.39 KB)<br />6.14 KB -> 0 B | -100%
**Bigger**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
app.bundle.js | bundled<br />gzip | 1.04 MB -> 1.29 MB (+254.35 KB)<br />297.38 KB -> N/A | +23.91%
**Smaller**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
manifest.json | bundled<br />gzip | 551 B -> 91 B (-460 B)<br />151 B -> N/A | -83.48%
**Unchanged**
No assets were unchanged`)
expect(printTotalAssetTable(statsDiff)).toMatchSnapshot()
expect(printAssetTablesByGroup(statsDiff)).toMatchSnapshot()
})

test('Shows stats when files are added', () => {
Expand All @@ -57,40 +25,8 @@ test('Shows stats when files are added', () => {
require('./__mocks__/old-stats-assets.json')
)

expect(printTotalAssetTable(statsDiff)).toEqual(`**Total**
Files count | Type | Total bundle size | % Changed
----------- | ---- | ----------------- | ---------
2 -> 7 | bundled<br />gzip | 1.29 MB -> 1.34 MB (+53.65 KB)<br />N/A -> 386.44 KB | +4.07%`)
expect(printAssetTablesByGroup(statsDiff)).toEqual(`**Added**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
296.chunk.js | bundled<br />gzip | 0 B -> 124.57 KB (+124.57 KB)<br />0 B -> 35.05 KB | -
288.chunk.js | bundled<br />gzip | 0 B -> 57.24 KB (+57.24 KB)<br />0 B -> 16.33 KB | -
920.chunk.js | bundled<br />gzip | 0 B -> 54.98 KB (+54.98 KB)<br />0 B -> 17.08 KB | -
912.chunk.js | bundled<br />gzip | 0 B -> 44.37 KB (+44.37 KB)<br />0 B -> 14.31 KB | -
699.chunk.js | bundled<br />gzip | 0 B -> 26.39 KB (+26.39 KB)<br />0 B -> 6.14 KB | -
**Removed**
No assets were removed
**Bigger**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
manifest.json | bundled<br />gzip | 91 B -> 551 B (+460 B)<br />N/A -> 151 B | +505.49%
**Smaller**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
app.bundle.js | bundled<br />gzip | 1.29 MB -> 1.04 MB (-254.35 KB)<br />N/A -> 297.38 KB | -19.29%
**Unchanged**
No assets were unchanged`)
expect(printTotalAssetTable(statsDiff)).toMatchSnapshot()
expect(printAssetTablesByGroup(statsDiff)).toMatchSnapshot()
})

test('Shows stats when files are unchanged', () => {
Expand All @@ -99,38 +35,8 @@ test('Shows stats when files are unchanged', () => {
require('./__mocks__/old-stats-assets.json')
)

expect(printTotalAssetTable(statsDiff)).toEqual(`**Total**
Files count | Type | Total bundle size | % Changed
----------- | ---- | ----------------- | ---------
7 | bundled<br />gzip | 1.34 MB<br />386.44 KB | 0%`)
expect(printAssetTablesByGroup(statsDiff)).toEqual(`**Added**
No assets were added
**Removed**
No assets were removed
**Bigger**
No assets were bigger
**Smaller**
No assets were smaller
**Unchanged**
Asset | Type | File Size | % Changed
----- | ---- | --------- | ---------
app.bundle.js | bundled<br />gzip | 1.04 MB<br />297.38 KB | 0%
296.chunk.js | bundled<br />gzip | 124.57 KB<br />35.05 KB | 0%
288.chunk.js | bundled<br />gzip | 57.24 KB<br />16.33 KB | 0%
920.chunk.js | bundled<br />gzip | 54.98 KB<br />17.08 KB | 0%
912.chunk.js | bundled<br />gzip | 44.37 KB<br />14.31 KB | 0%
699.chunk.js | bundled<br />gzip | 26.39 KB<br />6.14 KB | 0%
manifest.json | bundled<br />gzip | 551 B<br />151 B | 0%`)
expect(printTotalAssetTable(statsDiff)).toMatchSnapshot()
expect(printAssetTablesByGroup(statsDiff)).toMatchSnapshot()
})

test('computes the correct module diff information', () => {
Expand Down Expand Up @@ -178,42 +84,7 @@ test('displays module information when files are added/removed/changed', () => {
require('./__mocks__/new-stats-with-chunks.json')
)

console.log(printChunkModulesTable(statsDiff))

expect(printChunkModulesTable(statsDiff)).toEqual(`
**Changeset**
File | Δ
---- | -
\`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 🆕 +2.72 KB
\`src/client/this-file-was-added.ts\` | 🆕 +1.46 KB
\`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 🆕 +1.04 KB
\`src/client/helpers/this-file-is-much-larger.ts\` | 📈 +11.66 KB (+865.77%)
\`src/client/this-file-grew-larger.tsx\` | 📈 +200 B (+35.59%)
\`src/client/helpers/this-file-grew-smaller.ts\` | 📉 -200 B (-7.94%)
\`src/client/this-file-is-much-smaller.tsx\` | 📉 -11.66 KB (-99.92%)
\`src/client/routes.tsx\` | 🔥 -2.72 KB (-100%)
\`src/client/this-file-will-be-deleted.ts\` | 🔥 -1.46 KB (-100%)
\`src/client/render-memex.tsx\` | 🔥 -1.04 KB (-100%)
<details>
<summary>View detailed changes</summary>
File | Old | New | Δ
---- | --- | --- | -
\`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 0 B | 2.72 KB | 🆕 +2.72 KB
\`src/client/this-file-was-added.ts\` | 0 B | 1.46 KB | 🆕 +1.46 KB
\`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 0 B | 1.04 KB | 🆕 +1.04 KB
\`src/client/helpers/this-file-is-much-larger.ts\` | 1.35 KB | 13.01 KB | 📈 +11.66 KB (+865.77%)
\`src/client/this-file-grew-larger.tsx\` | 562 B | 762 B | 📈 +200 B (+35.59%)
\`src/client/helpers/this-file-grew-smaller.ts\` | 2.46 KB | 2.26 KB | 📉 -200 B (-7.94%)
\`src/client/this-file-is-much-smaller.tsx\` | 11.67 KB | 10 B | 📉 -11.66 KB (-99.92%)
\`src/client/routes.tsx\` | 2.72 KB | 0 B | 🔥 -2.72 KB (-100%)
\`src/client/this-file-will-be-deleted.ts\` | 1.46 KB | 0 B | 🔥 -1.46 KB (-100%)
\`src/client/render-memex.tsx\` | 1.04 KB | 0 B | 🔥 -1.04 KB (-100%)
</details>
`)
expect(printChunkModulesTable(statsDiff)).toMatchSnapshot()
})

test('displays no module information when unchanged', () => {
Expand All @@ -222,9 +93,7 @@ test('displays no module information when unchanged', () => {
require('./__mocks__/old-stats-with-chunks.json')
)

expect(printChunkModulesTable(statsDiff)).toEqual(
`\n**Changeset**\n\nNo files were changed`
)
expect(printChunkModulesTable(statsDiff)).toMatchSnapshot()
})

test('does not display module information when it does not exist', () => {
Expand All @@ -233,5 +102,5 @@ test('does not display module information when it does not exist', () => {
require('./__mocks__/old-stats-assets.json')
)

expect(printChunkModulesTable(statsDiff)).toEqual('')
expect(printChunkModulesTable(statsDiff)).toMatchSnapshot()
})
7 changes: 5 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 3ac4188

Please sign in to comment.