diff --git a/.nycrc b/.nycrc index 3767eacced7d..4a69e8c7b863 100644 --- a/.nycrc +++ b/.nycrc @@ -3,9 +3,6 @@ "packages/example-codehub/src/**", "packages/*/dist*/*" ], - "exclude": [ - "packages/core/*/promisify.*" - ], "extension": [ ".js", ".ts" diff --git a/.travis.yml b/.travis.yml index 5ba305c4580c..f1af0851f037 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ sudo: false language: node_js node_js: - - "6" - "8" os: diff --git a/appveyor.yml b/appveyor.yml index fda3f0bec211..6a07fc0d5a8b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,5 @@ environment: matrix: - - nodejs_version: "6" - nodejs_version: "8" install: diff --git a/package.json b/package.json index ce2f2becba6e..bedf37d3cb2d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ }, "version": "4.0.0-alpha.1", "engines": { - "node": ">=6" + "node": ">=8" }, "license": "MIT", "devDependencies": { diff --git a/packages/authentication/package.json b/packages/authentication/package.json index 55f5de213854..4264de849411 100644 --- a/packages/authentication/package.json +++ b/packages/authentication/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.30", "description": "A LoopBack component for authentication support.", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "acceptance": "lb-mocha \"DIST/test/acceptance/**/*.js\"", diff --git a/packages/build/package.json b/packages/build/package.json index 5135f5f317d1..f309d61d4401 100644 --- a/packages/build/package.json +++ b/packages/build/package.json @@ -7,7 +7,7 @@ }, "version": "4.0.0-alpha.12", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "index.js", "copyright.owner": "IBM Corp.", diff --git a/packages/cli/docs.json b/packages/cli/docs.json index 1b37c9ac8301..1211ab7810dc 100644 --- a/packages/cli/docs.json +++ b/packages/cli/docs.json @@ -5,7 +5,6 @@ "lib/base-generator.js", "lib/debug.js", "lib/project-generator.js", - "lib/promisify.js", "lib/utils.js" ], "codeSectionDepth": 4 diff --git a/packages/cli/generators/example/clone-example.js b/packages/cli/generators/example/clone-example.js index 8be103743edf..cf11a9e20b19 100644 --- a/packages/cli/generators/example/clone-example.js +++ b/packages/cli/generators/example/clone-example.js @@ -5,8 +5,6 @@ 'use strict'; -const promisify = require('../../lib/utils').promisify; - const gunzip = require('gunzip-maybe'); const path = require('path'); const request = require('request'); diff --git a/packages/cli/lib/utils.js b/packages/cli/lib/utils.js index 9f0c8de273a9..5f7742858b97 100644 --- a/packages/cli/lib/utils.js +++ b/packages/cli/lib/utils.js @@ -12,7 +12,7 @@ const util = require('util'); const regenerate = require('regenerate'); const _ = require('lodash'); const pascalCase = require('change-case').pascalCase; -const promisify = util.promisify || require('util.promisify/implementation'); +const promisify = require('util').promisify; const camelCase = require('change-case').camelCase; const validate = require('validate-npm-package-name'); const Conflicter = require('yeoman-generator/lib/util/conflicter'); diff --git a/packages/cli/package.json b/packages/cli/package.json index 13fd722d7f9b..3eef3dc5c2d7 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -7,7 +7,7 @@ "name": "IBM" }, "engines": { - "node": ">=6" + "node": ">=8" }, "files": [ "bin", @@ -49,7 +49,6 @@ "request": "^2.83.0", "tar-fs": "^1.16.0", "unicode-10.0.0": "^0.7.4", - "util.promisify": "^1.0.0", "validate-npm-package-name": "^3.0.0", "yeoman-generator": "^2.0.1" }, diff --git a/packages/cli/test/clone-example.test.js b/packages/cli/test/clone-example.test.js index f5dda0a25531..7ad9ff34f920 100644 --- a/packages/cli/test/clone-example.test.js +++ b/packages/cli/test/clone-example.test.js @@ -5,15 +5,13 @@ ('use strict'); -const promisify = require('../lib/utils').promisify; +const promisify = require('util').promisify; const cloneExampleFromGitHub = require('../generators/example/clone-example'); const expect = require('@loopback/testlab').expect; const TestSandbox = require('@loopback/testlab').TestSandbox; -const fs = require('fs'); const glob = promisify(require('glob')); const path = require('path'); -const rimraf = promisify(require('rimraf')); const VALID_EXAMPLE = 'getting-started'; const SANDBOX_PATH = path.resolve(__dirname, 'sandbox'); diff --git a/packages/context/package.json b/packages/context/package.json index 917c9987b530..ebb88fe5dd0b 100644 --- a/packages/context/package.json +++ b/packages/context/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.29", "description": "LoopBack's container for Inversion of Control", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "acceptance": "lb-mocha \"DIST/test/acceptance/**/*.js\"", diff --git a/packages/core/docs.json b/packages/core/docs.json index 2c4e49f7ca88..f4634ab5e5c0 100644 --- a/packages/core/docs.json +++ b/packages/core/docs.json @@ -5,7 +5,6 @@ "src/component.ts", "src/index.ts", "src/keys.ts", - "src/promisify.ts", "src/server.ts" ], "codeSectionDepth": 4 diff --git a/packages/core/package.json b/packages/core/package.json index 01d049054c14..ef162728acf2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.31", "description": "", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "acceptance": "lb-mocha \"DIST/test/acceptance/**/*.js\"", @@ -26,8 +26,7 @@ "dependencies": { "@loopback/context": "^4.0.0-alpha.29", "lodash": "^4.17.4", - "topo": "^3.0.0", - "util.promisify": "^1.0.0" + "topo": "^3.0.0" }, "devDependencies": { "@loopback/build": "^4.0.0-alpha.12", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 450e97adff0b..cf9d5f64358a 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -10,6 +10,5 @@ export {Component, ProviderMap} from './component'; export {inject, Context} from '@loopback/context'; export {Server} from './server'; export * from './application'; -export * from './promisify'; export * from './component'; export * from './keys'; diff --git a/packages/core/src/promisify.ts b/packages/core/src/promisify.ts deleted file mode 100644 index 7e03fe3330c7..000000000000 --- a/packages/core/src/promisify.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/core -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// A temporary polyfill for util.promisify on Node.js 6.x -// Remove it as part of https://github.com/strongloop/loopback-next/issues/611 - -// tslint:disable:no-any - -import * as util from 'util'; -// The @types/util.promisify conflicts with @types/node due to rescoping -// issues, so falling back to legacy import. -const promisifyPolyfill = require('util.promisify/implementation'); - -const nativePromisify = (util as any).promisify; - -export function promisify( - func: (callback: (err: any, result: T) => void) => void, -): () => Promise; -export function promisify( - func: (arg1: A1, callback: (err: any, result: T) => void) => void, -): (arg1: A1) => Promise; -export function promisify( - func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, -): (arg1: A1, arg2: A2) => Promise; - -/** - * Polyfill promisify and use `util.promisify` if available - * @param func A callback-style function - */ -export function promisify( - func: (...args: any[]) => void, -): (...args: any[]) => Promise { - if (nativePromisify) return nativePromisify(func); - - // TODO(kjdelisle): Once Node 6 has been dropped, we can remove this - // compatibility support. - return promisifyPolyfill(func); -} diff --git a/packages/example-hello-world/package.json b/packages/example-hello-world/package.json index 5f88ea1eea31..c460ff518ec5 100644 --- a/packages/example-hello-world/package.json +++ b/packages/example-hello-world/package.json @@ -5,7 +5,7 @@ "private": true, "main": "index.js", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "acceptance": "lb-mocha \"DIST/test/acceptance/**/*.js\"", diff --git a/packages/example-log-extension/package.json b/packages/example-log-extension/package.json index 0782afe2456d..d346360c3b7a 100644 --- a/packages/example-log-extension/package.json +++ b/packages/example-log-extension/package.json @@ -5,7 +5,7 @@ "private": true, "main": "index.js", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "build": "npm run build:dist && npm run build:dist6", diff --git a/packages/example-rpc-server/package.json b/packages/example-rpc-server/package.json index 97e98ed383e8..7334347f8538 100644 --- a/packages/example-rpc-server/package.json +++ b/packages/example-rpc-server/package.json @@ -8,7 +8,7 @@ "loopback" ], "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "build": "npm run build:dist && npm run build:dist6", diff --git a/packages/metadata/package.json b/packages/metadata/package.json index e12c78f4d7a1..0422b0412d65 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.8", "description": "LoopBack's metadata utilities for reflection and decoration", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "acceptance": "lb-mocha \"DIST/test/acceptance/**/*.js\"", diff --git a/packages/openapi-spec-builder/package.json b/packages/openapi-spec-builder/package.json index 7190dda42e88..4ff6bc4f556b 100644 --- a/packages/openapi-spec-builder/package.json +++ b/packages/openapi-spec-builder/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.20", "description": "Make it easy to create OpenAPI (Swagger) specification documents in your tests using the builder pattern.", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "build": "npm run build:dist && npm run build:dist6", diff --git a/packages/openapi-spec/package.json b/packages/openapi-spec/package.json index beedaadbc4c5..2e8fe9afd6e2 100644 --- a/packages/openapi-spec/package.json +++ b/packages/openapi-spec/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.23", "description": "TypeScript type definitions for OpenAPI Spec/Swagger documents.", "engines": { - "node": ">=6" + "node": ">=8" }, "devDependencies": { "@loopback/build": "^4.0.0-alpha.12" diff --git a/packages/repository-json-schema/package.json b/packages/repository-json-schema/package.json index 420f9d64ae26..d657d94f5fcf 100644 --- a/packages/repository-json-schema/package.json +++ b/packages/repository-json-schema/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.5", "description": "Converts TS classes into JSON Schemas using TypeScript's reflection API", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "build": "npm run build:dist && npm run build:dist6", diff --git a/packages/repository/package.json b/packages/repository/package.json index bd37b45801c5..be159d49434b 100644 --- a/packages/repository/package.json +++ b/packages/repository/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.27", "description": "Repository based persistence for LoopBack 4", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "index", "scripts": { diff --git a/packages/rest/package.json b/packages/rest/package.json index a6364b365834..49172708b20d 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.23", "description": "", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "acceptance": "lb-mocha \"DIST/test/acceptance/**/*.js\"", diff --git a/packages/rest/src/parser.ts b/packages/rest/src/parser.ts index da02bc990bbc..8c6696d4d022 100644 --- a/packages/rest/src/parser.ts +++ b/packages/rest/src/parser.ts @@ -6,7 +6,7 @@ import {ServerRequest} from 'http'; import * as HttpErrors from 'http-errors'; import {OperationObject, ParameterObject} from '@loopback/openapi-spec'; -import {promisify} from '@loopback/core'; +import {promisify} from 'util'; import { OperationArgs, ParsedRequest, @@ -15,18 +15,11 @@ import { import {ResolvedRoute} from './router/routing-table'; type HttpError = HttpErrors.HttpError; -type jsonBodyFn = ( - req: ServerRequest, - cb: (err?: Error, body?: {}) => void, -) => void; -const jsonBody: jsonBodyFn = require('body/json'); - -// tslint:disable:no-any +// tslint:disable-next-line:no-any type MaybeBody = any | undefined; -// tslint:enable:no-any const parseJsonBody: (req: ServerRequest) => Promise = promisify( - jsonBody, + require('body/json'), ); /** diff --git a/packages/testlab/package.json b/packages/testlab/package.json index 43ce54dbeca6..7d1dd8216031 100644 --- a/packages/testlab/package.json +++ b/packages/testlab/package.json @@ -3,7 +3,7 @@ "version": "4.0.0-alpha.22", "description": "A collection of test utilities we use to write LoopBack tests.", "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "build": "npm run build:dist && npm run build:dist6",