From aaaa6da387b00b41ce16c6bb5ae1c82eaf12f3b5 Mon Sep 17 00:00:00 2001 From: Adam Stolcenburg Date: Fri, 12 Jun 2026 13:58:31 +0200 Subject: [PATCH] Improve error messages when the local package store is not found Ref: #RDKEAPPRT-839 --- bolt/src/PackageStore.cjs | 3 ++- bolt/src/fetch.cjs | 5 +++-- bolt/src/make.cjs | 5 +++-- bolt/src/push.cjs | 14 ++++++++++---- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bolt/src/PackageStore.cjs b/bolt/src/PackageStore.cjs index e821a76..6faef5b 100644 --- a/bolt/src/PackageStore.cjs +++ b/bolt/src/PackageStore.cjs @@ -25,12 +25,13 @@ const PACKAGE_STORE_DIR = 'bolts'; const MAX_DEPTH = 100; class PackageStore { - static find(workDir) { + static find(workDir, searched) { let base = process.env.BUILDDIR ?? process.cwd(); let foundPath; for (let i = 0; i < MAX_DEPTH; ++i) { const path = resolve(base + '/' + PACKAGE_STORE_DIR); + searched?.push(path); if (statSync(path, { throwIfNoEntry: false })?.isDirectory()) { foundPath = path; diff --git a/bolt/src/fetch.cjs b/bolt/src/fetch.cjs index e7556d5..bf55f35 100644 --- a/bolt/src/fetch.cjs +++ b/bolt/src/fetch.cjs @@ -219,9 +219,10 @@ async function fetch(packageName, options) { throw new Error('No package store URL configured. Set "packageStoreURL" in ~/.bolt/config.json'); } - const packageStore = PackageStore.find(process.cwd()); + const searchedStoreDirs = []; + const packageStore = PackageStore.find(process.cwd(), searchedStoreDirs); if (!packageStore) { - throw new Error('Local package store not found'); + throw new Error(`Could not find the local package store. Searched in:\n${searchedStoreDirs.join('\n')}`); } const packageFileName = Package.isPackageFileName(packageName) diff --git a/bolt/src/make.cjs b/bolt/src/make.cjs index 1ae53d4..d9c0bf5 100644 --- a/bolt/src/make.cjs +++ b/bolt/src/make.cjs @@ -146,10 +146,11 @@ async function makeCommand(packageAlias, workDir, options) { const packageConfigBuilder = new PackageConfigBuilder(packageConfig); packageConfigBuilder.resolveAutoValues(packageConfigStore.getPath()); - const packageStore = PackageStore.find(workDir); + const searchedStoreDirs = []; + const packageStore = PackageStore.find(workDir, searchedStoreDirs); if (options.install && !packageStore) { - throw new Error(`Package store not found!`); + throw new Error(`Could not find the local package store. Searched in:\n${searchedStoreDirs.join('\n')}`); } let contentFile; diff --git a/bolt/src/push.cjs b/bolt/src/push.cjs index a7ee7d7..adb6e62 100644 --- a/bolt/src/push.cjs +++ b/bolt/src/push.cjs @@ -36,7 +36,7 @@ function push(remoteName, pkg, options) { } } -function findPackage(pkgParam, workDir, locations) { +function findPackage(pkgParam, workDir, locations, searchedStoreDirs) { let result = Package.fromPath(pkgParam, workDir); if (result) return result; @@ -51,8 +51,9 @@ function findPackage(pkgParam, workDir, locations) { locations.push(fileName); } - const packageStore = PackageStore.find(workDir); + const packageStore = PackageStore.find(workDir, searchedStoreDirs); if (packageStore) { + searchedStoreDirs?.splice(0); result = packageStore.getPackage(pkgParam); if (result) return result; locations.push(packageStore.generatePackagePath(pkgParam)); @@ -64,10 +65,15 @@ function findPackage(pkgParam, workDir, locations) { function pushCommand(remoteName, pkgParam, workDir, options) { const pkgSearchLocations = []; - const pkg = findPackage(pkgParam, workDir, pkgSearchLocations); + const searchedStoreDirs = []; + const pkg = findPackage(pkgParam, workDir, pkgSearchLocations, searchedStoreDirs); if (!pkg) { - throw new Error(`Package ${pkgParam} not found, tried:\n${pkgSearchLocations.join('\n')}`); + let message = `Package ${pkgParam} not found, tried:\n${pkgSearchLocations.join('\n')}`; + if (searchedStoreDirs.length > 0) { + message += `\nNo local package store found. Searched in:\n${searchedStoreDirs.join('\n')}`; + } + throw new Error(message); } const remote = new Remote(remoteName);