Skip to content

Commit 3169dba

Browse files
committed
chore(utils): improve error message for incompatible ghost zip
refs #681 refs #587 Give the user more information why the installation of the zip file failed. Renders the required and the current installed CLI version and the command to run to solve the issue.
1 parent 981da23 commit 3169dba

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/utils/version-from-zip.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ module.exports = function versionFromZip(zipPath, currentVersion) {
4040
}
4141

4242
if (pkg.engines && pkg.engines.cli && !semver.satisfies(cliPackage.version, pkg.engines.cli)) {
43-
return Promise.reject(new errors.SystemError('Zip file contains a Ghost version incompatible with this version of the CLI.'));
43+
return Promise.reject(new errors.SystemError({
44+
message: 'Zip file contains a Ghost version incompatible with this version of the CLI.',
45+
help: `Required: v${pkg.engines.cli}, current: v${cliPackage.version}`,
46+
suggestion: 'npm install -g ghost-cli@latest'
47+
}));
4448
}
4549

4650
if (currentVersion && semver.lt(pkg.version, currentVersion)) {

test/unit/utils/version-from-zip-spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ describe('Unit: Utils > versionFromZip', function () {
106106
}).catch((error) => {
107107
expect(error).to.be.an.instanceof(errors.SystemError);
108108
expect(error.message).to.equal('Zip file contains a Ghost version incompatible with this version of the CLI.');
109+
expect(error.options.help).to.equal('Required: v^0.0.1, current: v1.7.0');
110+
expect(error.options.suggestion).to.equal('npm install -g ghost-cli@latest');
109111
});
110112
});
111113

0 commit comments

Comments
 (0)