mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-20 06:22:50 +01:00
Squashed commit of the following: commitf9ce878b26Author: Julian Lam <julian@nodebb.org> Date: Tue Aug 13 14:30:46 2019 -0400 fix(style): updated code to follow new eslint recommendations commit80dd370e41Author: Julian Lam <julian@nodebb.org> Date: Tue Aug 13 14:14:58 2019 -0400 fix(deps): update dependency sitemap to v4 Squashed commit of the following: commitf4dd9cabb2Author: Julian Lam <julian@nodebb.org> Date: Tue Aug 13 11:33:05 2019 -0400 fix: resolved breaking changes from sitemap v4 upgrade commit9043415ee1Merge:e3352b27272590b346Author: Julian Lam <julian@nodebb.org> Date: Tue Aug 13 11:09:55 2019 -0400 Merge branch 'master' into renovate/sitemap-4.x commite3352b272eAuthor: Renovate Bot <bot@renovateapp.com> Date: Mon Aug 12 07:59:05 2019 +0000 fix(deps): update dependency sitemap to v4 commit8e3c0cdcaeAuthor: Renovate Bot <bot@renovateapp.com> Date: Fri Aug 9 00:49:51 2019 +0000 fix(deps): update dependency commander to v3 commit2104449d38Author: Renovate Bot <bot@renovateapp.com> Date: Tue Aug 13 15:00:27 2019 +0000 fix(deps): update dependency mongodb to v3.3.0 commitd2937f446aAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Tue Aug 13 10:36:48 2019 -0400 feat: async/await admin/controllers commit1b97e8b199Author: Misty (Bot) <deploy@nodebb.org> Date: Tue Aug 13 09:28:39 2019 +0000 Latest translations and fallbacks commit69a48957a2Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Aug 12 21:56:09 2019 -0400 feat: async/await commitb9b2a7e593Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Aug 12 20:58:29 2019 -0400 feat: async/await refactor controllers/accounts commita8d43a1759Author: Baris Usakli <barisusakli@gmail.com> Date: Mon Aug 12 14:49:40 2019 -0400 feat: async/await controllers/accounts commit2f25aae57bAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Aug 11 23:09:50 2019 -0400 fix: #7831, fix pagination convert to async/await commitc9e83f2374Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Aug 11 00:14:35 2019 -0400 fix: remove empty line commit30be91b26cAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Aug 11 00:13:41 2019 -0400 fix: remove useless catchs and empty line commit2e4a71c0b6Author: Renovate Bot <bot@renovateapp.com> Date: Sat Aug 10 06:51:50 2019 +0000 chore(deps): update dependency eslint-config-airbnb-base to v14
93 lines
2.8 KiB
JavaScript
93 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
var cproc = require('child_process');
|
|
|
|
var packageFilePath = path.join(__dirname, '../../package.json');
|
|
var packageDefaultFilePath = path.join(__dirname, '../../install/package.json');
|
|
var modulesPath = path.join(__dirname, '../../node_modules');
|
|
|
|
function updatePackageFile() {
|
|
var oldPackageContents = {};
|
|
|
|
try {
|
|
oldPackageContents = JSON.parse(fs.readFileSync(packageFilePath, 'utf8'));
|
|
} catch (e) {
|
|
if (e.code !== 'ENOENT') {
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
var defaultPackageContents = JSON.parse(fs.readFileSync(packageDefaultFilePath, 'utf8'));
|
|
var packageContents = { ...oldPackageContents, ...defaultPackageContents, dependencies: { ...oldPackageContents.dependencies, ...defaultPackageContents.dependencies } };
|
|
|
|
fs.writeFileSync(packageFilePath, JSON.stringify(packageContents, null, 2));
|
|
}
|
|
|
|
exports.updatePackageFile = updatePackageFile;
|
|
|
|
function installAll() {
|
|
var prod = global.env !== 'development';
|
|
var command = 'npm install';
|
|
try {
|
|
fs.accessSync(path.join(modulesPath, 'nconf/package.json'), fs.constants.R_OK);
|
|
var packageManager = require('nconf').get('package_manager');
|
|
if (packageManager === 'yarn') {
|
|
command = 'yarn';
|
|
}
|
|
} catch (e) {
|
|
// ignore
|
|
}
|
|
try {
|
|
cproc.execSync(command + (prod ? ' --production' : ''), {
|
|
cwd: path.join(__dirname, '../../'),
|
|
stdio: [0, 1, 2],
|
|
});
|
|
} catch (e) {
|
|
console.log('Error installing dependencies!');
|
|
console.log('message: ' + e.message);
|
|
console.log('stdout: ' + e.stdout);
|
|
console.log('stderr: ' + e.stderr);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
exports.installAll = installAll;
|
|
|
|
function preserveExtraneousPlugins() {
|
|
// Skip if `node_modules/` is not found or inaccessible
|
|
try {
|
|
fs.accessSync(modulesPath, fs.constants.R_OK);
|
|
} catch (e) {
|
|
return;
|
|
}
|
|
|
|
var isPackage = /^nodebb-(plugin|theme|widget|reward)-\w+/;
|
|
var packages = fs.readdirSync(modulesPath).filter(function (pkgName) {
|
|
return isPackage.test(pkgName);
|
|
});
|
|
var packageContents = JSON.parse(fs.readFileSync(packageFilePath, 'utf8'));
|
|
|
|
var extraneous = packages
|
|
// only extraneous plugins (ones not in package.json) which are not links
|
|
.filter(function (pkgName) {
|
|
const extraneous = !packageContents.dependencies.hasOwnProperty(pkgName);
|
|
const isLink = fs.lstatSync(path.join(modulesPath, pkgName)).isSymbolicLink();
|
|
|
|
return extraneous && !isLink;
|
|
})
|
|
// reduce to a map of package names to package versions
|
|
.reduce(function (map, pkgName) {
|
|
var pkgConfig = JSON.parse(fs.readFileSync(path.join(modulesPath, pkgName, 'package.json'), 'utf8'));
|
|
map[pkgName] = pkgConfig.version;
|
|
return map;
|
|
}, {});
|
|
|
|
// Add those packages to package.json
|
|
Object.assign(packageContents.dependencies, extraneous);
|
|
fs.writeFileSync(packageFilePath, JSON.stringify(packageContents, null, 2));
|
|
}
|
|
|
|
exports.preserveExtraneousPlugins = preserveExtraneousPlugins;
|