diff --git a/automation/build-bin.ts b/automation/build-bin.ts index 2ba3c479..f0c03f6f 100644 --- a/automation/build-bin.ts +++ b/automation/build-bin.ts @@ -19,7 +19,6 @@ import type { JsonVersions } from '../src/commands/version/index'; import { run as oclifRun } from '@oclif/core'; import * as archiver from 'archiver'; -import * as Bluebird from 'bluebird'; import { exec, execFile } from 'child_process'; import * as filehound from 'filehound'; import type { Stats } from 'fs'; @@ -42,6 +41,7 @@ import { const execFileAsync = promisify(execFile); const execAsync = promisify(exec); +const rimrafAsync = promisify(rimraf); export const packageJSON = loadPackageJson(); export const version = 'v' + packageJSON.version; @@ -517,7 +517,7 @@ export async function buildOclifInstaller() { } for (const dir of dirs) { console.log(`rimraf(${dir})`); - await Bluebird.fromCallback((cb) => rimraf(dir, cb)); + await rimrafAsync(dir); } console.log('======================================================='); console.log(`oclif ${packCmd} ${packOpts.join(' ')}`); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d0c48fc2..d17f0b86 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -26,7 +26,6 @@ "balena-semver": "^2.3.0", "balena-settings-client": "^5.0.2", "balena-settings-storage": "^8.1.0", - "bluebird": "^3.7.2", "body-parser": "^1.19.1", "bonjour-service": "^1.2.1", "chalk": "^3.0.0", diff --git a/package.json b/package.json index 59cb08c1..4bbad610 100644 --- a/package.json +++ b/package.json @@ -207,7 +207,6 @@ "balena-semver": "^2.3.0", "balena-settings-client": "^5.0.2", "balena-settings-storage": "^8.1.0", - "bluebird": "^3.7.2", "body-parser": "^1.19.1", "bonjour-service": "^1.2.1", "chalk": "^3.0.0", diff --git a/src/utils/device/deploy.ts b/src/utils/device/deploy.ts index 018467e8..9ead627a 100644 --- a/src/utils/device/deploy.ts +++ b/src/utils/device/deploy.ts @@ -309,7 +309,6 @@ function connectToDocker(host: string, port: number): Docker { return new Docker({ host, port, - Promise: require('bluebird'), }); } diff --git a/tests/auth/utils.spec.ts b/tests/auth/utils.spec.ts index 7db48171..dd5a733c 100644 --- a/tests/auth/utils.spec.ts +++ b/tests/auth/utils.spec.ts @@ -1,4 +1,3 @@ -import * as Bluebird from 'bluebird'; import { expect } from 'chai'; import * as sinon from 'sinon'; import * as url from 'url'; @@ -19,28 +18,28 @@ describe('Utils:', async function () { )); it('should eventually contain an https protocol', () => - Bluebird.props({ - dashboardUrl: balena.settings.get('dashboardUrl'), - loginUrl: utils.getDashboardLoginURL('https://127.0.0.1:3000/callback'), - }).then(function ({ dashboardUrl, loginUrl }) { + Promise.all([ + balena.settings.get('dashboardUrl'), + utils.getDashboardLoginURL('https://127.0.0.1:3000/callback'), + ]).then(function ([dashboardUrl, loginUrl]) { const { protocol } = url.parse(loginUrl); return expect(protocol).to.equal(url.parse(dashboardUrl).protocol); })); it('should correctly escape a callback url without a path', () => - Bluebird.props({ - dashboardUrl: balena.settings.get('dashboardUrl'), - loginUrl: utils.getDashboardLoginURL('http://127.0.0.1:3000'), - }).then(function ({ dashboardUrl, loginUrl }) { + Promise.all([ + balena.settings.get('dashboardUrl'), + utils.getDashboardLoginURL('http://127.0.0.1:3000'), + ]).then(function ([dashboardUrl, loginUrl]) { const expectedUrl = `${dashboardUrl}/login/cli/http%253A%252F%252F127.0.0.1%253A3000`; return expect(loginUrl).to.equal(expectedUrl); })); return it('should correctly escape a callback url with a path', () => - Bluebird.props({ - dashboardUrl: balena.settings.get('dashboardUrl'), - loginUrl: utils.getDashboardLoginURL('http://127.0.0.1:3000/callback'), - }).then(function ({ dashboardUrl, loginUrl }) { + Promise.all([ + balena.settings.get('dashboardUrl'), + utils.getDashboardLoginURL('http://127.0.0.1:3000/callback'), + ]).then(function ([dashboardUrl, loginUrl]) { const expectedUrl = `${dashboardUrl}/login/cli/http%253A%252F%252F127.0.0.1%253A3000%252Fcallback`; return expect(loginUrl).to.equal(expectedUrl); })); diff --git a/tests/nock/builder-mock.ts b/tests/nock/builder-mock.ts index b0f69d79..ef1cc55d 100644 --- a/tests/nock/builder-mock.ts +++ b/tests/nock/builder-mock.ts @@ -15,11 +15,13 @@ * limitations under the License. */ -import * as Bluebird from 'bluebird'; import * as path from 'path'; import * as zlib from 'zlib'; import { NockMock } from './nock-mock'; +import { promisify } from 'util'; + +const gunzipAsync = promisify(zlib.gunzip); export const builderResponsePath = path.normalize( path.join(__dirname, '..', 'test-data', 'builder-response'), @@ -45,9 +47,7 @@ export class BuilderMock extends NockMock { await opts.checkURI(uri); if (typeof requestBody === 'string') { const gzipped = Buffer.from(requestBody, 'hex'); - const gunzipped = await Bluebird.fromCallback((cb) => { - zlib.gunzip(gzipped, cb); - }); + const gunzipped = await gunzipAsync(gzipped); await opts.checkBuildRequestBody(gunzipped); } else { throw new Error( diff --git a/typings/balena-device-init/index.d.ts b/typings/balena-device-init/index.d.ts index c2bfc1d6..3dce4d69 100644 --- a/typings/balena-device-init/index.d.ts +++ b/typings/balena-device-init/index.d.ts @@ -17,7 +17,6 @@ declare module 'balena-device-init' { import { DeviceTypeJson } from 'balena-sdk'; - import type * as Bluebird from 'bluebird'; interface OperationState { operation: @@ -78,25 +77,29 @@ declare module 'balena-device-init' { on(event: 'error', callback: (error: Error) => void): void; } + // As of writing this, these are Bluebird promises, but we are typing then + // as normal Promises so that we do not rely on Bluebird specific methods, + // so that the CLI will not require any change once the package drops Bluebird. + export function configure( image: string, manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType, config: object, options?: object, - ): Bluebird; + ): Promise; export function initialize( image: string, manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType, config: object, - ): Bluebird; + ): Promise; export function getImageOsVersion( image: string, manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType, - ): Bluebird; + ): Promise; export function getImageManifest( image: string, - ): Bluebird; + ): Promise; } diff --git a/typings/resin-cli-form/index.d.ts b/typings/resin-cli-form/index.d.ts index 625e4cb8..2830888a 100644 --- a/typings/resin-cli-form/index.d.ts +++ b/typings/resin-cli-form/index.d.ts @@ -16,8 +16,6 @@ */ declare module 'resin-cli-form' { - import Bluebird = require('bluebird'); - export type TypeOrPromiseLike = T | PromiseLike; export type Validate = ( @@ -43,9 +41,13 @@ declare module 'resin-cli-form' { validate?: Validate; } - export const ask: (options: AskOptions) => Bluebird; + // As of writing this, these are Bluebird promises, but we are typing then + // as normal Promises so that we do not rely on Bluebird specific methods, + // so that the CLI will not require any change once the package drops Bluebird. + + export const ask: (options: AskOptions) => Promise; export const run: ( questions?: RunQuestion[], extraOptions?: { override?: object }, - ) => Bluebird; + ) => Promise; }