diff --git a/ghost/members-csv/lib/parse.js b/ghost/members-csv/lib/parse.js index a2a4df5ccf..9723109ef1 100644 --- a/ghost/members-csv/lib/parse.js +++ b/ghost/members-csv/lib/parse.js @@ -1,4 +1,3 @@ -const Promise = require('bluebird'); const pump = require('pump'); const papaparse = require('papaparse'); const fs = require('fs-extra'); diff --git a/ghost/members-csv/package.json b/ghost/members-csv/package.json index eeafbddcbd..13177821ef 100644 --- a/ghost/members-csv/package.json +++ b/ghost/members-csv/package.json @@ -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", diff --git a/ghost/members-importer/lib/importer.js b/ghost/members-importer/lib/importer.js index f2ad24f50a..01ed454b03 100644 --- a/ghost/members-importer/lib/importer.js +++ b/ghost/members-importer/lib/importer.js @@ -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(); diff --git a/ghost/package-json/lib/package-json.js b/ghost/package-json/lib/package-json.js index 162da61839..95b13c2f19 100644 --- a/ghost/package-json/lib/package-json.js +++ b/ghost/package-json/lib/package-json.js @@ -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} */ 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 = { diff --git a/ghost/package-json/package.json b/ghost/package-json/package.json index fa06da5da1..22f68f167a 100644 --- a/ghost/package-json/package.json +++ b/ghost/package-json/package.json @@ -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" } diff --git a/ghost/update-check-service/lib/update-check-service.js b/ghost/update-check-service/lib/update-check-service.js index 83cb9eae0e..8ec3fe07d4 100644 --- a/ghost/update-check-service/lib/update-check-service.js +++ b/ghost/update-check-service/lib/update-check-service.js @@ -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) { diff --git a/ghost/update-check-service/package.json b/ghost/update-check-service/package.json index 445e8821c8..80ef703fc7 100644 --- a/ghost/update-check-service/package.json +++ b/ghost/update-check-service/package.json @@ -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" }