Removed bluebird from misc packages (#15676)

refs: https://github.com/TryGhost/Ghost/issues/14882

- Removed bluebird from members-csv package-json and update-check-service 
- Removing bluebird specific methods in favour of the Ghost sequence method so we can remove the bluebird dependency
This commit is contained in:
Halldor Thorhallsson 2022-10-30 11:16:10 -04:00 committed by GitHub
parent 3f289edc26
commit 5a94cc8039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 29 deletions

View File

@ -1,4 +1,3 @@
const Promise = require('bluebird');
const pump = require('pump');
const papaparse = require('papaparse');
const fs = require('fs-extra');

View File

@ -22,7 +22,6 @@
"sinon": "14.0.1"
},
"dependencies": {
"bluebird": "3.7.2",
"fs-extra": "10.1.0",
"lodash": "4.17.21",
"papaparse": "5.3.2",

View File

@ -107,7 +107,7 @@ module.exports = class MembersCSVImporter {
* @param {string} filePath - the path to a "prepared" CSV file
*/
async perform(filePath) {
const rows = membersCSV.parse(filePath, DEFAULT_CSV_HEADER_MAPPING);
const rows = await membersCSV.parse(filePath, DEFAULT_CSV_HEADER_MAPPING);
const defaultTier = await this._getDefaultTier();
const membersRepository = await this._getMembersRepository();

View File

@ -14,9 +14,6 @@ const join = require('path').join;
const errors = require('@tryghost/errors');
const parse = require('./parse');
// Require bluebird with its own namespace and use it explicitly where we need additional features
const Bluebird = require('bluebird');
const notAPackageRegex = /^\.|_messages|README.md|node_modules|bower_components/i;
const packageJSONPath = 'package.json';
@ -127,28 +124,28 @@ async function readPackage(packagePath, packageName) {
* @returns {Promise<PackageList>}
*/
async function readPackages(packagePath) {
return Bluebird.resolve(fs.readdir(packagePath, {withFileTypes: true}))
.filter(async function (packageFile) {
// Filter out things which are not packages by regex
if (packageFile.name.match(notAPackageRegex)) {
return;
}
const files = await fs.promises.readdir(packagePath, {withFileTypes: true});
const packages = await Promise.all(files.map(async (file) => {
// Filter out things which are not packages by regex
if (file.name.match(notAPackageRegex)) {
return false;
}
if (packageFile.isSymbolicLink()) {
const packageFileOrig = await fs.stat(join(packagePath, packageFile.name));
return packageFileOrig.isDirectory();
}
if (file.isSymbolicLink()) {
const packageFileOrig = await fs.stat(join(packagePath, file.name));
return packageFileOrig.isDirectory();
}
// Check the remaining items to ensure they are a directory
return packageFile.isDirectory();
})
.map(function readPackageJson(packageFile) {
// Check the remaining items to ensure they are a directory
return file.isDirectory();
}))
.then(results => files.filter((_v, index) => results[index]))
.then(packageFiles => Promise.all(packageFiles.map((packageFile) => {
const absolutePath = join(packagePath, packageFile.name);
return processPackage(absolutePath, packageFile.name);
})
.then(function (packages) {
return _.keyBy(packages, 'name');
});
})));
return _.keyBy(packages, 'name');
}
module.exports = {

View File

@ -25,7 +25,6 @@
"dependencies": {
"@tryghost/errors": "1.2.18",
"@tryghost/tpl": "0.1.19",
"bluebird": "3.7.2",
"fs-extra": "10.1.0",
"lodash": "4.17.21"
}

View File

@ -2,8 +2,8 @@ const _ = require('lodash');
const url = require('url');
const crypto = require('crypto');
const moment = require('moment');
const Promise = require('bluebird');
const exec = require('child_process').exec;
const util = require('util');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
@ -112,7 +112,7 @@ class UpdateCheckService {
const theme = (await this.api.settings.read(_.extend({key: 'active_theme'}, internal))).settings[0];
const posts = await this.api.posts.browse();
const users = await this.api.users.browse(internal);
const npm = await Promise.promisify(exec)('npm -v');
const npm = await util.promisify(exec)('npm -v');
const blogUrl = this.config.siteUrl;
const parsedBlogUrl = url.parse(blogUrl);
@ -124,7 +124,7 @@ class UpdateCheckService {
data.post_count = posts && posts.meta && posts.meta.pagination ? posts.meta.pagination.total : 0;
data.user_count = users && users.users && users.users.length ? users.users.length : 0;
data.blog_created_at = users && users.users && users.users[0] && users.users[0].created_at ? moment(users.users[0].created_at).unix() : '';
data.npm_version = npm.trim();
data.npm_version = npm.stdout.trim();
return data;
} catch (err) {

View File

@ -27,7 +27,6 @@
"@tryghost/errors": "1.2.18",
"@tryghost/logging": "2.3.2",
"@tryghost/tpl": "0.1.19",
"bluebird": "3.7.2",
"lodash": "4.17.21",
"moment": "2.24.0"
}