-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🏗♻️🚮 Disable
@storybook/addon-knobs
(#37681)
Related to #35923 `@storybook/addon-knobs` has been deprecated, and it's officially obsolete. This prevents us from upgrading the Storybook version due to a peer dependency conflict. This change: - Removes `@storybook/addon-knobs` - Disables Storybook files that require Knobs. We use the forbidden term allowlist to find disabled files. - Since `amp-animation` tests do not match the allowlist schema for disabling, we migrate those to Controls instead.
- Loading branch information
1 parent
6e7cb14
commit 1e82a4d
Showing
11 changed files
with
111 additions
and
881 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 was deleted.
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,46 @@ | ||
const globby = require('globby'); | ||
const {yellow} = require('kleur/colors'); | ||
const {logWithoutTimestamp} = require('../../../common/logging'); | ||
|
||
/** | ||
* Remove disabled Storybook files from an evaluated glob pattern. | ||
* This is required since the disabled Stories use the Knobs addon, which is now | ||
* obsolete and prevents us from upgrading the Storybook version. | ||
* @param {string[]} inclusionPattern | ||
* @return {string[]} | ||
*/ | ||
function globExcludeDisabledStorybookFiles(inclusionPattern) { | ||
const { | ||
forbiddenTermsGlobal, | ||
} = require('../../../test-configs/forbidden-terms'); | ||
const forbiddenTerm = `@storybook/${''}addon-knobs`; | ||
const forbiddenTermsEntry = forbiddenTermsGlobal[forbiddenTerm]; | ||
if (!forbiddenTermsEntry?.allowlist?.length) { | ||
throw new Error( | ||
`Forbidden terms entry for "${forbiddenTerm}" not found, or it lacks an allowlist.` + | ||
'\nThis likely means that globExcludeDisabledStorybookFiles() should be removed.' + | ||
'\nIts callsites can be replaced with its argument, like the diff at:' + | ||
'\nhttps://gist.github.com/alanorozco/6e8a64a38cb0d6967c193784624d1011' | ||
); | ||
} | ||
const excluded = new Set(forbiddenTermsEntry.allowlist); | ||
const prefiltered = globby.sync(inclusionPattern); | ||
const filtered = prefiltered.filter((filename) => { | ||
const relativeToRoot = filename.replace(/^([.]{1,2}\/)+/, ''); | ||
return !excluded.has(relativeToRoot); | ||
}); | ||
const excludedTotal = prefiltered.length - filtered.length; | ||
if (excludedTotal > 0) { | ||
logWithoutTimestamp( | ||
yellow( | ||
`WARNING: ${excludedTotal} Storybook files have been disabled due to usage of "${forbiddenTerm}"` + | ||
`\nSee allowlist for "${forbiddenTerm}" in build-system/test-configs/forbidden-terms.js` | ||
) | ||
); | ||
} | ||
return filtered; | ||
} | ||
|
||
module.exports = { | ||
globExcludeDisabledStorybookFiles, | ||
}; |
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
Oops, something went wrong.