-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugins): add plugin for lost-pixel config (#630)
* feat(plugins): add plugin for lost-pixel config * Fix: add lost-pixel config file to fixtures * Fix: adjust test exectuion assertion * Fix: adjust config file casing * Fix: adjust lost-pixel test * Fix: remove - from the lostpixel config file
- Loading branch information
Showing
7 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/knip/fixtures/plugins/lost-pixel/lostpixel.config.ts
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,33 @@ | ||
import type { CustomProjectConfig } from 'lost-pixel'; | ||
|
||
export const config: CustomProjectConfig = { | ||
apiKey: process.env.LOST_PIXEL_API_KEY, | ||
|
||
ladleShots: { | ||
ladleUrl: 'dist/ladle', | ||
}, | ||
|
||
lostPixelProjectId: process.env.LOST_PIXEL_PROJECT_ID, | ||
|
||
shotConcurrency: 5, | ||
setPendingStatusCheck: true, | ||
|
||
imagePathBaseline: '.lostpixel/baseline', | ||
imagePathCurrent: '.lostpixel/current', | ||
imagePathDifference: '.lostpixel/difference', | ||
|
||
ciBuildId: process.env.BUILD_ID, | ||
ciBuildNumber: process.env.BUILD_NUMBER, | ||
repository: process.env.REPOSITORY_NAME, | ||
commitRefName: process.env.CHANGE_BRANCH ?? process.env.BRANCH_NAME, | ||
commitHash: process.env.GIT_COMMIT, | ||
|
||
configureBrowser: () => ({ | ||
userAgent: | ||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36', | ||
viewport: { | ||
width: 800, | ||
height: 600, | ||
}, | ||
}), | ||
}; |
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,7 @@ | ||
{ | ||
"name": "@fixtures/lost-pixel", | ||
"version": "*", | ||
"devDependencies": { | ||
"lost-pixel": "*" | ||
} | ||
} |
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
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,20 @@ | ||
import type { EnablerPatterns } from '#p/types/config.js'; | ||
import type { IsPluginEnabled, Plugin } from '#p/types/plugins.js'; | ||
import { hasDependency } from '#p/util/plugin.js'; | ||
|
||
// link to lost-pixel docs https://docs.lost-pixel.com/user-docs/api-reference/lost-pixel.config.js-or-ts | ||
|
||
const title = 'Lost Pixel'; | ||
|
||
const enablers: EnablerPatterns = ['lost-pixel']; | ||
|
||
const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers); | ||
|
||
const config = ['lostpixel.config.{js,ts}']; | ||
|
||
export default { | ||
title, | ||
enablers, | ||
isEnabled, | ||
config, | ||
} satisfies Plugin; |
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,21 @@ | ||
import { test } from 'bun:test'; | ||
import assert from 'node:assert/strict'; | ||
import { main } from '../../src/index.js'; | ||
import { resolve } from '../../src/util/path.js'; | ||
import baseArguments from '../helpers/baseArguments.js'; | ||
import baseCounters from '../helpers/baseCounters.js'; | ||
|
||
const cwd = resolve('fixtures/plugins/lost-pixel'); | ||
|
||
test('Find dependencies with the lost-pixel plugin', async () => { | ||
const { counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
}); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
processed: 1, | ||
total: 1, | ||
}); | ||
}); |