-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use yarn list --pattern to get list of dependencies matching @storybook…
… and get that data to get viewLayer and addons.
- Loading branch information
Showing
5 changed files
with
92 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import execa from 'execa'; | ||
|
||
import { viewLayers } from './viewLayers'; | ||
import { supportedAddons } from './supportedAddons'; | ||
|
||
export const getInstalledStorybookInfo = async () => { | ||
const { all } = await execa.command('yarn list --pattern @storybook/ --json', { | ||
env: {}, | ||
timeout: 10000, | ||
all: true, | ||
shell: true, | ||
}); | ||
|
||
const { data } = JSON.parse(all as any); | ||
const trees: { name: string; version: string }[] = data.trees.map((p) => { | ||
const [, name, version] = p.name.match(/(.+)@(.+)/); | ||
return { name, version }; | ||
}); | ||
|
||
const viewLayer = trees.find(({ name }) => viewLayers[name]); | ||
const addons = trees.filter(({ name }) => supportedAddons[name]); | ||
|
||
const result = { | ||
viewLayer: viewLayers[viewLayer ? viewLayer.name : ''], | ||
version: viewLayer ? viewLayer.version : undefined, | ||
addons: addons.map((a) => supportedAddons[a.name]), | ||
}; | ||
|
||
return result; | ||
}; |
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,28 @@ | ||
export const supportedAddons = { | ||
'@storybook/addon-a11y': 'a11y', | ||
'@storybook/addon-actions': 'actions', | ||
'@storybook/addon-backgrounds': 'backgrounds', | ||
'@storybook/addon-centered': 'centered', | ||
'@storybook/addon-contexts': 'contexts', | ||
'@storybook/addon-cssresources': 'cssresources', | ||
'@storybook/addon-design-assets': 'design-assets', | ||
'@storybook/addon-docs': 'docs', | ||
'@storybook/addon-essentials': 'essentials', | ||
'@storybook/addon-events': 'events', | ||
'@storybook/addon-google-analytics': 'google-analytics', | ||
'@storybook/addon-graphql': 'graphql', | ||
'@storybook/addon-info': 'info', | ||
'@storybook/addon-jest': 'jest', | ||
'@storybook/addon-knobs': 'knobs', | ||
'@storybook/addon-links': 'links', | ||
'@storybook/addon-notes': 'notes', | ||
'@storybook/addon-ondevice-actions': 'ondevice-actions', | ||
'@storybook/addon-ondevice-backgrounds': 'ondevice-backgrounds', | ||
'@storybook/addon-ondevice-knobs': 'ondevice-knobs', | ||
'@storybook/addon-ondevice-notes': 'ondevice-notes', | ||
'@storybook/addon-options': 'options', | ||
'@storybook/addon-queryparams': 'queryparams', | ||
'@storybook/addon-storyshots': 'storyshots', | ||
'@storybook/addon-storysource': 'storysource', | ||
'@storybook/addon-viewport': 'viewport', | ||
} as Record<string, string>; |
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,16 @@ | ||
export const viewLayers = { | ||
'@storybook/react': 'react', | ||
'@storybook/vue': 'vue', | ||
'@storybook/vue3': 'vue3', | ||
'@storybook/angular': 'angular', | ||
'@storybook/html': 'html', | ||
'@storybook/web-components': 'web-components', | ||
'@storybook/polymer': 'polymer', | ||
'@storybook/ember': 'ember', | ||
'@storybook/marko': 'marko', | ||
'@storybook/mithril': 'mithril', | ||
'@storybook/riot': 'riot', | ||
'@storybook/svelte': 'svelte', | ||
'@storybook/preact': 'preact', | ||
'@storybook/rax': 'rax', | ||
} as Record<string, string>; |