add back getInstalledStorybookInfo via yarn
MODIFY
bin-src/lib/getStorybookInfo.ts
bin-src/lib/getStorybookInfo.ts
@@ -2,12 +2,44 @@ import fs from 'fs-extra';
import meow from 'meow';
import { parseArgsStringToArgv } from 'string-argv';
import semver from 'semver';
+import execa from 'execa';
+
import noViewLayerPackage from '../ui/messages/errors/noViewLayerPackage';
import { viewLayers } from './viewLayers';
import { supportedAddons } from './supportedAddons';
import { timeout, raceFulfilled } from './promises';
import { Context } from '../types';
+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: any) => {
+ 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) => ({
+ packageVersion: a.version,
+ packageName: a.name,
+ name: supportedAddons[a.name],
+ })),
+ };
+
+ return result;
+};
+
const resolvePackageJson = (pkg: string) => {
try {
// we bundle this app for node, meaning all require calls are replaced by webpack.
@@ -134,6 +166,10 @@ export default async function getStorybookInfo(
const info = await Promise.all([findAddons(ctx), findConfigFlags(ctx), findViewlayer(ctx)]);
return info.reduce((acc, obj) => Object.assign(acc, obj), {});
} catch (e) {
+ const result = await getInstalledStorybookInfo();
+ if (result.viewLayer) {
+ return result;
+ }
return { viewLayer: null, version: null, addons: [] };
}
}

add back getInstalledStorybookInfo via yarn