fix(cli): fix clean cache description and error messages

This commit is contained in:
Sam Tolmay 2020-10-28 10:53:47 +02:00
parent 2fa577844e
commit a3a9ffccb6
2 changed files with 11 additions and 6 deletions

View File

@ -19,10 +19,13 @@ import decompress from 'decompress';
import decompressTargz from 'decompress-targz';
async function loadBuildScriptToCache(version, cachePath) {
const packageInfo = await axios.get('https://registry.npmjs.org/@lowdefy/build');
const registryUrl = 'https://registry.npmjs.org/@lowdefy/build';
const packageInfo = await axios.get(registryUrl);
if (!packageInfo || !packageInfo.data) {
// TODO: What should this error message be?
throw new Error('Build script could not be found.');
// TODO: Check if user has internet connection.
throw new Error(
`Build package could not be found at ${registryUrl}. Check internet connection.`
);
}
if (!packageInfo.data.versions[version]) {
throw new Error(`Invalid Lowdefy version. Version "${version}" does not exist.`);
@ -31,8 +34,10 @@ async function loadBuildScriptToCache(version, cachePath) {
responseType: 'arraybuffer',
});
if (!tarball || !tarball.data) {
// TODO: What should this error message be?
throw new Error('Build script could not be fetched.');
/// TODO: Check if user has internet connection.
throw new Error(
`Build script could not be fetched from ${packageInfo.data.versions[version].dist.tarball}. Check internet connection.`
);
}
await decompress(tarball.data, cachePath, {
plugins: [decompressTargz()],

View File

@ -36,7 +36,7 @@ program
program
.command('clean-cache')
.description('Build a Lowdefy deployment.')
.description('Clean cached scripts and block meta descriptions.')
.usage(`[options]`)
.option(
'--base-directory <base-directory>',