mirror of
https://github.com/directus/directus.git
synced 2026-01-24 09:18:06 -05:00
feat: global installation and update check (#6795)
* Add global installation option * Add update check for global install
This commit is contained in:
@@ -10,6 +10,7 @@ const ora = require('ora');
|
||||
|
||||
const pkg = require('../package.json');
|
||||
const checkRequirements = require('./check-requirements');
|
||||
const checkForUpdate = require('update-check');
|
||||
|
||||
const program = new commander.Command(pkg.name);
|
||||
|
||||
@@ -94,5 +95,25 @@ async function create(directory) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let update;
|
||||
|
||||
try {
|
||||
update = await checkForUpdate(pkg);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Error: ${err.stderr}`);
|
||||
}
|
||||
|
||||
if (update) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log();
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(chalk.yellow.bold(`A new version of \`${pkg.name}\` is available!`));
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('You can update by running: ' + chalk.cyan(`npm i -g ${pkg.name}@latest`));
|
||||
// eslint-disable-next-line no-console
|
||||
console.log();
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
"version": "9.0.0-rc.84",
|
||||
"description": "A small installer util that will create a directory, add boilerplate folders, and install Directus through npm.",
|
||||
"main": "lib/index.js",
|
||||
"bin": "./lib/index.js",
|
||||
"bin": {
|
||||
"create-directus-project": "./lib/index.js",
|
||||
"cdp": "./lib/index.js"
|
||||
},
|
||||
"keywords": [
|
||||
"directus",
|
||||
"installer"
|
||||
@@ -15,7 +18,8 @@
|
||||
"commander": "^8.0.0",
|
||||
"execa": "^5.1.1",
|
||||
"fs-extra": "^10.0.0",
|
||||
"ora": "^5.4.0"
|
||||
"ora": "^5.4.0",
|
||||
"update-check": "^1.5.4"
|
||||
},
|
||||
"gitHead": "24621f3934dc77eb23441331040ed13c676ceffd"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user