Support npm@5 and yarn (#6010)

* Support npm@5 and yarn

Use package.default.json
Partial #6008

- Overwrite package.json with package.default.json values
- `dependencies` field is merged with package.default.json version taking precidence
- `./nodebb upgrade` automatically does those things and runs `git pull`
- use `./nodebb upgrade --dev` to avoid the `git pull`

* added logic to preserve extraneous plugins installed in node_modules/

* Don't automatically git pull

* Simplify package-install, run it on upgrade just in case
This commit is contained in:
Peter Jaszkowiak
2017-11-02 12:12:05 -06:00
committed by Julian Lam
parent e609e497b3
commit dfad76120d
7 changed files with 98 additions and 6 deletions

18
nodebb
View File

@@ -6,18 +6,20 @@ var fs = require('fs');
var path = require('path');
var cproc = require('child_process');
var packageInstall = require('./src/meta/package-install');
// check to make sure dependencies are installed
try {
fs.readFileSync(path.join(__dirname, './package.json'));
fs.readFileSync(path.join(__dirname, 'node_modules/async/package.json'));
} catch (e) {
if (e.code === 'ENOENT') {
process.stdout.write('Dependencies not yet installed.\n');
process.stdout.write('Installing them now...\n\n');
cproc.execSync('npm i --production', {
cwd: __dirname,
stdio: [0, 1, 2],
});
packageInstall.updatePackageFile();
packageInstall.preserveExtraneousPlugins();
packageInstall.npmInstallProduction();
} else {
throw e;
}
@@ -458,9 +460,15 @@ var commands = {
}
async.series([
function (next) {
packageInstall.updatePackageFile();
packageInstall.preserveExtraneousPlugins();
next();
},
function (next) {
process.stdout.write('1. '.bold + 'Bringing base dependencies up to date... '.yellow);
cproc.exec('npm i --production', { cwd: __dirname, stdio: 'ignore' }, next);
packageInstall.npmInstallProduction();
next();
},
function (next) {
process.stdout.write('OK\n'.green);