From 55ebe5b594b39391d077f1a51a793d2c25a355f6 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Tue, 31 Jan 2023 10:35:29 +0100 Subject: [PATCH] CLI: replace glob with glob-promise --- code/lib/core-common/package.json | 4 ++-- .../src/utils/validate-configuration-files.ts | 11 +++++++++-- code/yarn.lock | 11 +++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/code/lib/core-common/package.json b/code/lib/core-common/package.json index b215cf3e1b3d..0ff1ac9090fe 100644 --- a/code/lib/core-common/package.json +++ b/code/lib/core-common/package.json @@ -58,7 +58,7 @@ "file-system-cache": "^2.0.0", "find-up": "^5.0.0", "fs-extra": "^11.1.0", - "glob": "^7.1.6", + "glob-promise": "^4.2.0", "handlebars": "^4.7.7", "lazy-universal-dotenv": "^4.0.0", "picomatch": "^2.3.0", @@ -85,4 +85,4 @@ "platform": "node" }, "gitHead": "91302a6818a7794e1e8bbff01c68513b8516cb53" -} \ No newline at end of file +} diff --git a/code/lib/core-common/src/utils/validate-configuration-files.ts b/code/lib/core-common/src/utils/validate-configuration-files.ts index 6c7c64e416d4..b66d9af3955a 100644 --- a/code/lib/core-common/src/utils/validate-configuration-files.ts +++ b/code/lib/core-common/src/utils/validate-configuration-files.ts @@ -1,5 +1,5 @@ import { dedent } from 'ts-dedent'; -import glob from 'glob'; +import { promise as glob } from 'glob-promise'; import path from 'path'; import { readConfig } from '@storybook/csf-tools'; import { once } from '@storybook/node-logger'; @@ -8,10 +8,17 @@ import { boost } from './interpret-files'; export async function validateConfigurationFiles(configDir: string) { const extensionsPattern = `{${Array.from(boost).join(',')}}`; - const mainConfigMatches = glob.sync(path.resolve(configDir, `main${extensionsPattern}`)); + const mainConfigMatches = await glob(path.resolve(configDir, `main${extensionsPattern}`)); const [mainConfigPath] = mainConfigMatches; + if (mainConfigMatches.length > 1) { + once.warn(dedent` + Multiple main files found in your configDir (${path.resolve(configDir)}). + Storybook will use the first one found and ignore the others. Please remove the extra files. + `); + } + if (!mainConfigPath) { throw new Error(dedent` No configuration files have been found in your configDir (${path.resolve(configDir)}). diff --git a/code/yarn.lock b/code/yarn.lock index a85d8dd19885..30ab5c441f63 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -1,3 +1,6 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + __metadata: version: 6 cacheKey: 8c0 @@ -6059,9 +6062,9 @@ __metadata: resolution: "@storybook/core-common@workspace:lib/core-common" dependencies: "@babel/core": ^7.20.2 - "@storybook/csf-tools": 7.0.0-beta.36 - "@storybook/node-logger": 7.0.0-beta.36 - "@storybook/types": 7.0.0-beta.36 + "@storybook/csf-tools": 7.0.0-beta.38 + "@storybook/node-logger": 7.0.0-beta.38 + "@storybook/types": 7.0.0-beta.38 "@types/babel__core": ^7.1.20 "@types/express": ^4.7.0 "@types/mock-fs": ^4.13.1 @@ -6075,7 +6078,7 @@ __metadata: file-system-cache: ^2.0.0 find-up: ^5.0.0 fs-extra: ^11.1.0 - glob: ^7.1.6 + glob-promise: ^4.2.0 handlebars: ^4.7.7 lazy-universal-dotenv: ^4.0.0 mock-fs: ^5.2.0