diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 342a7e859f..b1104949d4 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -393,14 +393,31 @@ function updateNextConfig(basePath: string) { writeFileSync(nextConfigPath, nextConfigData) } +// returns new (discovery.config.js) or legacy (faststore.config.js) store config file +function getCurrentUserStoreConfigFile(basePath: string) { + const { userStoreConfigFile, userLegacyStoreConfigFile } = withBasePath(basePath) + + if (existsSync(userStoreConfigFile)) { + return userStoreConfigFile + } + + if (existsSync(userLegacyStoreConfigFile)) { + return userLegacyStoreConfigFile + } + + return null +} + function validateAndInstallMissingDependencies(basePath: string) { - const { userDir, userStoreConfigFile } = withBasePath(basePath) + const { userDir } = withBasePath(basePath) + + const currentUserStoreConfigFile = getCurrentUserStoreConfigFile(basePath) - if (!existsSync(userStoreConfigFile)) { + if (!currentUserStoreConfigFile) { return } - const userStoreConfig = require(userStoreConfigFile) + const userStoreConfig = require(currentUserStoreConfigFile) const userPackageJson = require(path.join(userDir, 'package.json')) const missingDependencies: Array<{