From 302d33d65be4a0b773178cd0a0dd806884b0cba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Wed, 3 Nov 2021 14:51:00 +0100 Subject: [PATCH] chore(engineering)!: set minimum supported Node.JS version to 14 BREAKING CHANGE: this requires using a newer Node.JS version --- .github/workflows/ci.yaml | 2 +- README.md | 2 +- package-lock.json | 86 ++++++++------------------------------- package.json | 8 ++-- src/npm.ts | 4 +- src/package.ts | 42 +++++++++---------- src/publish.ts | 4 +- src/test/package.test.ts | 74 +++++++++++++++++---------------- src/util.ts | 4 +- src/xml.ts | 4 +- 10 files changed, 89 insertions(+), 141 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a16d1f6c..bf9ba2a0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - node-version: [10, 12, 14, 16, 17] + node-version: [14, 16, 17] fail-fast: false runs-on: ${{ matrix.os }} steps: diff --git a/README.md b/README.md index f3bedf4b..3ff3ff3e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## Requirements -- [Node.js](https://nodejs.org/en/) at least `10.x.x` +- [Node.js](https://nodejs.org/en/) at least `14.x.x` Or simply [Docker](#via-docker). diff --git a/package-lock.json b/package-lock.json index f10ac6e7..4fbecf82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,18 @@ { "name": "vsce", - "version": "1.100.2", + "version": "0.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vsce", - "version": "1.100.2", + "version": "0.0.0", "license": "MIT", "dependencies": { "azure-devops-node-api": "^11.0.1", "chalk": "^2.4.2", "cheerio": "^1.0.0-rc.9", "commander": "^6.1.0", - "denodeify": "^1.2.1", "glob": "^7.0.6", "hosted-git-info": "^4.0.2", "keytar": "^7.7.0", @@ -38,7 +37,6 @@ }, "devDependencies": { "@types/cheerio": "^0.22.29", - "@types/denodeify": "^1.2.31", "@types/glob": "^7.1.1", "@types/hosted-git-info": "^3.0.2", "@types/lodash": "^4.14.123", @@ -46,10 +44,10 @@ "@types/mime": "^1", "@types/minimatch": "^3.0.3", "@types/mocha": "^7.0.2", - "@types/node": "^10.17.60", + "@types/node": "^14.17.32", "@types/read": "^0.0.28", "@types/semver": "^6.0.0", - "@types/tmp": "^0.1.0", + "@types/tmp": "^0.2.2", "@types/xml2js": "^0.4.4", "@types/yauzl": "^2.9.2", "husky": "^4.3.0", @@ -63,7 +61,7 @@ "typescript": "^4.3.2" }, "engines": { - "node": ">= 10" + "node": ">= 14" } }, "node_modules/@babel/code-frame": { @@ -582,12 +580,6 @@ "integrity": "sha1-HBJhu+qhCoBVu8XYq4S3sq/IRqA= sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, - "node_modules/@types/denodeify": { - "version": "1.2.31", - "resolved": "https://registry.yarnpkg.com/@types/denodeify/-/denodeify-1.2.31.tgz", - "integrity": "sha1-mnN7BjvxqOOmPMAGy7sN5gHONYQ= sha512-Jgy3dvCyIxhNb5RstVJkubeHZifw8KJXca13ov8OO4IqhDLPRHiJJ6VArJbZZ4HuEMJEB83yCuABodNMlYylzQ==", - "dev": true - }, "node_modules/@types/events": { "version": "3.0.0", "resolved": "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz", @@ -605,12 +597,6 @@ "@types/node": "*" } }, - "node_modules/@types/glob/node_modules/@types/node": { - "version": "10.12.15", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-10.12.15.tgz", - "integrity": "sha1-IOhWUbYv2GZW5Xycm8dxqxVwvFk= sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA==", - "dev": true - }, "node_modules/@types/hosted-git-info": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/hosted-git-info/-/hosted-git-info-3.0.2.tgz", @@ -654,9 +640,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "10.17.60", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", - "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==", + "version": "14.17.32", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.32.tgz", + "integrity": "sha512-JcII3D5/OapPGx+eJ+Ik1SQGyt6WvuqdRfh9jUwL6/iHGjmyOriBDciBUu7lEIBTL2ijxwrR70WUnw5AEDmFvQ==", "dev": true }, "node_modules/@types/normalize-package-data": { @@ -690,9 +676,9 @@ "dev": true }, "node_modules/@types/tmp": { - "version": "0.1.0", - "resolved": "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.1.0.tgz", - "integrity": "sha1-Gc9zp7z2QZZUhRGXJjl6CW8ASb0= sha512-6IwZ9HzWbCq6XoQWhxLpDjuADodH/MKXRUIDFudvgjcVdjFknvmR+DNsoUeer4XPrEnrZs04Jj+kfV9pFsrhmA==", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.2.tgz", + "integrity": "sha512-MhSa0yylXtVMsyT8qFpHA1DLHj4DvQGH5ntxrhHSh8PxUVNi35Wk+P5hVgqbO2qZqOotqr9jaoPRL+iRjWYm/A==", "dev": true }, "node_modules/@types/xml2js": { @@ -704,12 +690,6 @@ "@types/node": "*" } }, - "node_modules/@types/xml2js/node_modules/@types/node": { - "version": "10.12.15", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-10.12.15.tgz", - "integrity": "sha1-IOhWUbYv2GZW5Xycm8dxqxVwvFk= sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA==", - "dev": true - }, "node_modules/@types/yauzl": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz", @@ -1692,11 +1672,6 @@ "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" }, - "node_modules/denodeify": { - "version": "1.2.1", - "resolved": "https://registry.yarnpkg.com/denodeify/-/denodeify-1.2.1.tgz", - "integrity": "sha1-OjYof1A05pnnV3kBBSwubJQlFjE=" - }, "node_modules/deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -9925,12 +9900,6 @@ "integrity": "sha1-HBJhu+qhCoBVu8XYq4S3sq/IRqA= sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, - "@types/denodeify": { - "version": "1.2.31", - "resolved": "https://registry.yarnpkg.com/@types/denodeify/-/denodeify-1.2.31.tgz", - "integrity": "sha1-mnN7BjvxqOOmPMAGy7sN5gHONYQ= sha512-Jgy3dvCyIxhNb5RstVJkubeHZifw8KJXca13ov8OO4IqhDLPRHiJJ6VArJbZZ4HuEMJEB83yCuABodNMlYylzQ==", - "dev": true - }, "@types/events": { "version": "3.0.0", "resolved": "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz", @@ -9946,14 +9915,6 @@ "@types/events": "*", "@types/minimatch": "*", "@types/node": "*" - }, - "dependencies": { - "@types/node": { - "version": "10.12.15", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-10.12.15.tgz", - "integrity": "sha1-IOhWUbYv2GZW5Xycm8dxqxVwvFk= sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA==", - "dev": true - } } }, "@types/hosted-git-info": { @@ -9999,9 +9960,9 @@ "dev": true }, "@types/node": { - "version": "10.17.60", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", - "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==", + "version": "14.17.32", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.32.tgz", + "integrity": "sha512-JcII3D5/OapPGx+eJ+Ik1SQGyt6WvuqdRfh9jUwL6/iHGjmyOriBDciBUu7lEIBTL2ijxwrR70WUnw5AEDmFvQ==", "dev": true }, "@types/normalize-package-data": { @@ -10035,9 +9996,9 @@ "dev": true }, "@types/tmp": { - "version": "0.1.0", - "resolved": "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.1.0.tgz", - "integrity": "sha1-Gc9zp7z2QZZUhRGXJjl6CW8ASb0= sha512-6IwZ9HzWbCq6XoQWhxLpDjuADodH/MKXRUIDFudvgjcVdjFknvmR+DNsoUeer4XPrEnrZs04Jj+kfV9pFsrhmA==", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.2.tgz", + "integrity": "sha512-MhSa0yylXtVMsyT8qFpHA1DLHj4DvQGH5ntxrhHSh8PxUVNi35Wk+P5hVgqbO2qZqOotqr9jaoPRL+iRjWYm/A==", "dev": true }, "@types/xml2js": { @@ -10047,14 +10008,6 @@ "dev": true, "requires": { "@types/node": "*" - }, - "dependencies": { - "@types/node": { - "version": "10.12.15", - "resolved": "https://registry.yarnpkg.com/@types/node/-/node-10.12.15.tgz", - "integrity": "sha1-IOhWUbYv2GZW5Xycm8dxqxVwvFk= sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA==", - "dev": true - } } }, "@types/yauzl": { @@ -10827,11 +10780,6 @@ "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" }, - "denodeify": { - "version": "1.2.1", - "resolved": "https://registry.yarnpkg.com/denodeify/-/denodeify-1.2.1.tgz", - "integrity": "sha1-OjYof1A05pnnV3kBBSwubJQlFjE=" - }, "deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", diff --git a/package.json b/package.json index 33d33a67..676fcc7e 100644 --- a/package.json +++ b/package.json @@ -31,14 +31,13 @@ "watch:test": "npm run test -- --watch" }, "engines": { - "node": ">= 10" + "node": ">= 14" }, "dependencies": { "azure-devops-node-api": "^11.0.1", "chalk": "^2.4.2", "cheerio": "^1.0.0-rc.9", "commander": "^6.1.0", - "denodeify": "^1.2.1", "glob": "^7.0.6", "hosted-git-info": "^4.0.2", "keytar": "^7.7.0", @@ -60,7 +59,6 @@ }, "devDependencies": { "@types/cheerio": "^0.22.29", - "@types/denodeify": "^1.2.31", "@types/glob": "^7.1.1", "@types/hosted-git-info": "^3.0.2", "@types/lodash": "^4.14.123", @@ -68,10 +66,10 @@ "@types/mime": "^1", "@types/minimatch": "^3.0.3", "@types/mocha": "^7.0.2", - "@types/node": "^10.17.60", + "@types/node": "^14.17.32", "@types/read": "^0.0.28", "@types/semver": "^6.0.0", - "@types/tmp": "^0.1.0", + "@types/tmp": "^0.2.2", "@types/xml2js": "^0.4.4", "@types/yauzl": "^2.9.2", "husky": "^4.3.0", diff --git a/src/npm.ts b/src/npm.ts index ae6541aa..a881a287 100644 --- a/src/npm.ts +++ b/src/npm.ts @@ -1,14 +1,12 @@ import * as path from 'path'; import * as fs from 'fs'; -import * as denodeify from 'denodeify'; import * as cp from 'child_process'; import * as parseSemver from 'parse-semver'; import * as _ from 'lodash'; import { CancellationToken, log } from './util'; -const stat = denodeify(fs.stat); const exists = (file: string) => - stat(file).then( + fs.promises.stat(file).then( _ => true, _ => false ); diff --git a/src/package.ts b/src/package.ts index ccc942fb..5fa355db 100644 --- a/src/package.ts +++ b/src/package.ts @@ -1,14 +1,14 @@ import * as fs from 'fs'; import * as path from 'path'; +import { promisify } from 'util'; import * as cp from 'child_process'; import * as _ from 'lodash'; import * as yazl from 'yazl'; import { ExtensionKind, Manifest } from './manifest'; import { ITranslations, patchNLS } from './nls'; import * as util from './util'; -import * as _glob from 'glob'; +import * as glob from 'glob'; import * as minimatch from 'minimatch'; -import * as denodeify from 'denodeify'; import * as markdownit from 'markdown-it'; import * as cheerio from 'cheerio'; import * as url from 'url'; @@ -26,15 +26,6 @@ import { detectYarn, getDependencies } from './npm'; import * as GitHost from 'hosted-git-info'; import * as parseSemver from 'parse-semver'; -const readFile = denodeify(fs.readFile); -const unlink = denodeify(fs.unlink as any); -const stat = denodeify(fs.stat); -const glob = denodeify(_glob); -const exec = denodeify( - cp.exec as any, - (err, stdout, stderr) => [err, { stdout, stderr }] -); - const resourcesPath = path.join(path.dirname(__dirname), 'resources'); const vsixManifestTemplatePath = path.join(resourcesPath, 'extension.vsixmanifest'); const contentTypesTemplatePath = path.join(resourcesPath, '[Content_Types].xml'); @@ -63,7 +54,7 @@ export function read(file: IFile): Promise { if (isInMemoryFile(file)) { return Promise.resolve(file.contents).then(b => (typeof b === 'string' ? b : b.toString('utf8'))); } else { - return readFile(file.localPath, 'utf8'); + return fs.promises.readFile(file.localPath, 'utf8'); } } @@ -325,7 +316,8 @@ export async function versionBump(options: IVersionBumpOptions): Promise { try { // call `npm version` to do our dirty work - const { stdout, stderr } = await exec(command, { cwd }); + cp.exec; + const { stdout, stderr } = await promisify(cp.exec)(command, { cwd }); if (!process.env['VSCE_TESTS']) { process.stdout.write(stdout); @@ -1164,7 +1156,8 @@ export function readManifest(cwd = process.cwd(), nls = true): Promise const manifestPath = path.join(cwd, 'package.json'); const manifestNLSPath = path.join(cwd, 'package.nls.json'); - const manifest = readFile(manifestPath, 'utf8') + const manifest = fs.promises + .readFile(manifestPath, 'utf8') .catch(() => Promise.reject(`Extension manifest not found: ${manifestPath}`)) .then(manifestStr => { try { @@ -1179,7 +1172,8 @@ export function readManifest(cwd = process.cwd(), nls = true): Promise return manifest; } - const manifestNLS = readFile(manifestNLSPath, 'utf8') + const manifestNLS = fs.promises + .readFile(manifestNLSPath, 'utf8') .catch(err => (err.code !== 'ENOENT' ? Promise.reject(err) : Promise.resolve('{}'))) .then(raw => { try { @@ -1195,7 +1189,8 @@ export function readManifest(cwd = process.cwd(), nls = true): Promise } export function toVsixManifest(vsix: any): Promise { - return readFile(vsixManifestTemplatePath, 'utf8') + return fs.promises + .readFile(vsixManifestTemplatePath, 'utf8') .then(vsixManifestTemplateStr => _.template(vsixManifestTemplateStr)) .then(vsixManifestTemplate => vsixManifestTemplate(vsix)); } @@ -1216,7 +1211,8 @@ export function toContentTypes(files: IFile[]): Promise { contentType: allExtensions[extension], })); - return readFile(contentTypesTemplatePath, 'utf8') + return fs.promises + .readFile(contentTypesTemplatePath, 'utf8') .then(contentTypesTemplateStr => _.template(contentTypesTemplateStr)) .then(contentTypesTemplate => contentTypesTemplate({ contentTypes })); } @@ -1264,7 +1260,7 @@ function collectAllFiles( ): Promise { return getDependencies(cwd, dependencies, dependencyEntryPoints).then(deps => { const promises: Promise[] = deps.map(dep => { - return glob('**', { cwd: dep, nodir: true, dot: true, ignore: 'node_modules/**' }).then(files => + return promisify(glob)('**', { cwd: dep, nodir: true, dot: true, ignore: 'node_modules/**' }).then(files => files.map(f => path.relative(cwd, path.join(dep, f))).map(f => f.replace(/\\/g, '/')) ); }); @@ -1283,7 +1279,8 @@ function collectFiles( files = files.filter(f => !/\r$/m.test(f)); return ( - readFile(ignoreFile ? ignoreFile : path.join(cwd, '.vscodeignore'), 'utf8') + fs.promises + .readFile(ignoreFile ? ignoreFile : path.join(cwd, '.vscodeignore'), 'utf8') .catch(err => err.code !== 'ENOENT' ? Promise.reject(err) : ignoreFile ? Promise.reject(err) : Promise.resolve('') ) @@ -1390,7 +1387,8 @@ export function collect(manifest: Manifest, options: IPackageOptions = {}): Prom } function writeVsix(files: IFile[], packagePath: string): Promise { - return unlink(packagePath) + return fs.promises + .unlink(packagePath) .catch(err => (err.code !== 'ENOENT' ? Promise.reject(err) : Promise.resolve(null))) .then( () => @@ -1454,7 +1452,7 @@ async function getPackagePath(cwd: string, manifest: Manifest, options: IPackage } try { - const _stat = await stat(options.packagePath); + const _stat = await fs.promises.stat(options.packagePath); if (_stat.isDirectory()) { return path.join(options.packagePath, getDefaultPackageName(manifest, options)); @@ -1491,7 +1489,7 @@ export async function packageCommand(options: IPackageOptions = {}): Promise(tmp.tmpName); +const tmpName = promisify(tmp.tmpName); export interface IPublishOptions { readonly packagePath?: string[]; diff --git a/src/test/package.test.ts b/src/test/package.test.ts index 8511a1f8..f4a161ae 100644 --- a/src/test/package.test.ts +++ b/src/test/package.test.ts @@ -18,7 +18,6 @@ import * as path from 'path'; import * as fs from 'fs'; import * as assert from 'assert'; import * as tmp from 'tmp'; -import * as denodeify from 'denodeify'; import * as _ from 'lodash'; import { spawnSync } from 'child_process'; import { XMLManifest, parseXmlManifest, parseContentTypes } from '../xml'; @@ -44,7 +43,6 @@ async function throws(fn: () => Promise): Promise { } const fixture = name => path.join(path.dirname(path.dirname(__dirname)), 'src', 'test', 'fixtures', name); -const readFile = denodeify(fs.readFile); function _toVsixManifest(manifest: Manifest, files: IFile[], options: IPackageOptions = {}): Promise { const processors = createDefaultProcessors(manifest, options); @@ -1764,7 +1762,7 @@ describe('toContentTypes', () => { describe('ManifestProcessor', () => { it('should ensure that package.json is writable', async () => { const root = fixture('uuid'); - const manifest = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8')); + const manifest = JSON.parse(await fs.promises.readFile(path.join(root, 'package.json'), 'utf8')); const processor = new ManifestProcessor(manifest); const packageJson = { path: 'extension/package.json', @@ -1778,7 +1776,7 @@ describe('ManifestProcessor', () => { it('should bump package.json version in-memory when using --no-update-package-json', async () => { const root = fixture('uuid'); - let manifest = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8')); + let manifest = JSON.parse(await fs.promises.readFile(path.join(root, 'package.json'), 'utf8')); assert.deepStrictEqual(manifest.version, '1.0.0'); const processor = new ManifestProcessor(manifest, { version: '1.1.1', updatePackageJson: false }); @@ -1791,14 +1789,14 @@ describe('ManifestProcessor', () => { assert.deepStrictEqual(manifest.version, '1.1.1'); assert.deepStrictEqual(processor.vsix.version, '1.1.1'); - manifest = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8')); + manifest = JSON.parse(await fs.promises.readFile(path.join(root, 'package.json'), 'utf8')); assert.deepStrictEqual(manifest.version, '1.0.0'); }); it('should not bump package.json version in-memory when not using --no-update-package-json', async () => { const root = fixture('uuid'); - let manifest = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8')); + let manifest = JSON.parse(await fs.promises.readFile(path.join(root, 'package.json'), 'utf8')); assert.deepStrictEqual(manifest.version, '1.0.0'); const processor = new ManifestProcessor(manifest, { version: '1.1.1' }); @@ -1811,7 +1809,7 @@ describe('ManifestProcessor', () => { assert.deepStrictEqual(manifest.version, '1.0.0'); assert.deepStrictEqual(processor.vsix.version, '1.0.0'); - manifest = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8')); + manifest = JSON.parse(await fs.promises.readFile(path.join(root, 'package.json'), 'utf8')); assert.deepStrictEqual(manifest.version, '1.0.0'); }); }); @@ -1867,7 +1865,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.expected.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.expected.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -1894,7 +1892,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.default.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.default.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -1923,7 +1921,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.branch.main.expected.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.branch.main.expected.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -1954,9 +1952,11 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.branch.override.images.expected.md'), 'utf8').then(expected => { - assert.equal(actual, expected); - }); + return fs.promises + .readFile(path.join(root, 'readme.branch.override.images.expected.md'), 'utf8') + .then(expected => { + assert.equal(actual, expected); + }); }); }); @@ -1984,9 +1984,11 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.branch.override.content.expected.md'), 'utf8').then(expected => { - assert.equal(actual, expected); - }); + return fs.promises + .readFile(path.join(root, 'readme.branch.override.content.expected.md'), 'utf8') + .then(expected => { + assert.equal(actual, expected); + }); }); }); @@ -2011,7 +2013,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.default.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.default.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2038,7 +2040,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.default.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.default.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2065,7 +2067,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.gitlab.default.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.gitlab.default.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2092,7 +2094,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.gitlab.default.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.gitlab.default.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2119,7 +2121,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.gitlab.default.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.gitlab.default.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2148,7 +2150,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.gitlab.branch.main.expected.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.gitlab.branch.main.expected.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2179,9 +2181,11 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.gitlab.branch.override.images.expected.md'), 'utf8').then(expected => { - assert.equal(actual, expected); - }); + return fs.promises + .readFile(path.join(root, 'readme.gitlab.branch.override.images.expected.md'), 'utf8') + .then(expected => { + assert.equal(actual, expected); + }); }); }); @@ -2209,9 +2213,11 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.gitlab.branch.override.content.expected.md'), 'utf8').then(expected => { - assert.equal(actual, expected); - }); + return fs.promises + .readFile(path.join(root, 'readme.gitlab.branch.override.content.expected.md'), 'utf8') + .then(expected => { + assert.equal(actual, expected); + }); }); }); @@ -2240,7 +2246,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.images.expected.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.images.expected.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2267,7 +2273,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.github.expected.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.github.expected.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2294,7 +2300,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.github.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.github.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2321,7 +2327,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.github.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.github.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2348,7 +2354,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.gitlab.expected.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.gitlab.expected.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); @@ -2375,7 +2381,7 @@ describe('MarkdownProcessor', () => { .onFile(readme) .then(file => read(file)) .then(actual => { - return readFile(path.join(root, 'readme.gitlab.md'), 'utf8').then(expected => { + return fs.promises.readFile(path.join(root, 'readme.gitlab.md'), 'utf8').then(expected => { assert.equal(actual, expected); }); }); diff --git a/src/util.ts b/src/util.ts index 4a0f9f4d..7e12af29 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,12 +1,12 @@ +import { promisify } from 'util'; import * as _read from 'read'; import { WebApi, getBasicHandler } from 'azure-devops-node-api/WebApi'; import { IGalleryApi, GalleryApi } from 'azure-devops-node-api/GalleryApi'; -import * as denodeify from 'denodeify'; import chalk from 'chalk'; import { PublicGalleryAPI } from './publicgalleryapi'; import { ISecurityRolesApi } from 'azure-devops-node-api/SecurityRolesApi'; -const __read = denodeify<_read.Options, string>(_read); +const __read = promisify<_read.Options, string>(_read); export function read(prompt: string, options: _read.Options = {}): Promise { if (process.env['VSCE_TESTS'] || !process.stdout.isTTY) { return Promise.resolve('y'); diff --git a/src/xml.ts b/src/xml.ts index 1482ec57..0af4a63a 100644 --- a/src/xml.ts +++ b/src/xml.ts @@ -1,8 +1,8 @@ +import { promisify } from 'util'; import { parseString } from 'xml2js'; -import * as denodeify from 'denodeify'; function createXMLParser(): (raw: string) => Promise { - return denodeify(parseString); + return promisify(parseString); } export type XMLManifest = {