From bb3322dbf2ef26ec749c00677fa47738543efd9d Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Mon, 13 Mar 2023 14:54:43 -0400 Subject: [PATCH 1/4] build: switch to using mkdir.recursive --- package.json | 2 -- src/generator/download.ts | 4 ++-- src/generator/generator.ts | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 764c1bfbc24..d2f4dec04f4 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "devDependencies": { "@compodoc/compodoc": "^1.1.10", "@types/execa": "^0.9.0", - "@types/mkdirp": "^1.0.0", "@types/mocha": "^9.0.0", "@types/mv": "^2.1.0", "@types/ncp": "^2.0.1", @@ -81,7 +80,6 @@ "gts": "^3.1.0", "js-green-licenses": "^4.0.0", "linkinator": "^4.0.0", - "mkdirp": "^2.0.0", "mocha": "^9.2.2", "mv": "^2.1.1", "ncp": "^2.0.0", diff --git a/src/generator/download.ts b/src/generator/download.ts index b2f3a843360..9fe443179e1 100644 --- a/src/generator/download.ts +++ b/src/generator/download.ts @@ -15,10 +15,10 @@ import * as minimist from 'yargs-parser'; import * as path from 'path'; import * as fs from 'fs'; +import {mkdir} from 'fs/promises'; import Q from 'p-queue'; import {request, Headers} from 'gaxios'; import * as gapi from 'googleapis-common'; -import * as mkdirp from 'mkdirp'; export type Schema = {[index: string]: {}}; export const DISCOVERY_URL = 'https://www.googleapis.com/discovery/v1/apis/'; @@ -41,7 +41,7 @@ export interface DownloadOptions { // exported for mocking purposes export const gfs = { - mkdir: async (dir: string) => mkdirp(dir), + mkdir: async (dir: string) => mkdir(dir, {recursive: true}), writeFile: (path: string, obj: {}) => { fs.writeFileSync(path, JSON.stringify(obj, null, 2)); }, diff --git a/src/generator/generator.ts b/src/generator/generator.ts index 9eb600f9281..8e69e509098 100644 --- a/src/generator/generator.ts +++ b/src/generator/generator.ts @@ -13,8 +13,8 @@ // limitations under the License. import * as fs from 'fs'; +import {mkdir} from 'fs/promises'; import {Schema, Schemas} from 'googleapis-common'; -import * as mkdirp from 'mkdirp'; import * as nunjucks from 'nunjucks'; import * as path from 'path'; import * as util from 'util'; @@ -272,7 +272,7 @@ export class Generator { this.logResult(apiDiscoveryUrl, 'Generating APIs...'); const apiPath = path.join(srcPath, 'apis', schema.name); const exportFilename = path.join(apiPath, schema.version + '.ts'); - await mkdirp(path.dirname(exportFilename)); + await mkdir(path.dirname(exportFilename), {recursive: true}); // populate the `method.fragment` property with samples addFragments(schema); // generate the API (ex: src/apis/youtube/v3.ts) From f7982c8a4749bdcd5c0ad2ddec461578deba2013 Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Mon, 13 Mar 2023 15:31:58 -0400 Subject: [PATCH 2/4] chore: remove mkdirp dep --- src/generator/samplegen.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/generator/samplegen.ts b/src/generator/samplegen.ts index 22fd6879627..6730d1d3d10 100644 --- a/src/generator/samplegen.ts +++ b/src/generator/samplegen.ts @@ -12,7 +12,6 @@ // limitations under the License. import * as path from 'path'; -import * as mkdirp from 'mkdirp'; import * as prettier from 'prettier'; import { Schema, From 26c46909e5478e631bebcff2eb0f89cb40feccf3 Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Mon, 13 Mar 2023 16:03:54 -0400 Subject: [PATCH 3/4] chore: add missing mkdirp --- src/generator/samplegen.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/generator/samplegen.ts b/src/generator/samplegen.ts index 6730d1d3d10..d421f72463e 100644 --- a/src/generator/samplegen.ts +++ b/src/generator/samplegen.ts @@ -24,6 +24,7 @@ import { import * as nunjucks from 'nunjucks'; import * as filters from './filters'; import * as fs from 'fs'; +import {mkdir} from 'fs/promises'; import * as util from 'util'; const writeFile = util.promisify(fs.writeFile); @@ -72,7 +73,7 @@ export async function addFragments(schema: Schema) { */ export async function generateSamples(apiPath: string, schema: Schema) { const samplesPath = path.join(apiPath, 'samples', schema.version); - await mkdirp(samplesPath); + await mkdir(samplesPath, {recursive: true}); const methods = getAllMethods(schema); for (const method of methods) { const sampleData = getSample(schema, method); From 0e3a035e1962d9b7b958991568cd3c05d469c092 Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Mon, 13 Mar 2023 16:30:56 -0400 Subject: [PATCH 4/4] chore: fix build issue --- src/generator/download.ts | 2 +- src/generator/generator.ts | 2 +- src/generator/samplegen.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generator/download.ts b/src/generator/download.ts index 9fe443179e1..7807c1ad1b0 100644 --- a/src/generator/download.ts +++ b/src/generator/download.ts @@ -15,7 +15,7 @@ import * as minimist from 'yargs-parser'; import * as path from 'path'; import * as fs from 'fs'; -import {mkdir} from 'fs/promises'; +const {mkdir} = require('fs').promises; import Q from 'p-queue'; import {request, Headers} from 'gaxios'; import * as gapi from 'googleapis-common'; diff --git a/src/generator/generator.ts b/src/generator/generator.ts index 8e69e509098..ccd3bdfef4e 100644 --- a/src/generator/generator.ts +++ b/src/generator/generator.ts @@ -13,7 +13,7 @@ // limitations under the License. import * as fs from 'fs'; -import {mkdir} from 'fs/promises'; +const {mkdir} = require('fs').promises; import {Schema, Schemas} from 'googleapis-common'; import * as nunjucks from 'nunjucks'; import * as path from 'path'; diff --git a/src/generator/samplegen.ts b/src/generator/samplegen.ts index d421f72463e..118c7f6142f 100644 --- a/src/generator/samplegen.ts +++ b/src/generator/samplegen.ts @@ -24,7 +24,7 @@ import { import * as nunjucks from 'nunjucks'; import * as filters from './filters'; import * as fs from 'fs'; -import {mkdir} from 'fs/promises'; +const {mkdir} = require('fs').promises; import * as util from 'util'; const writeFile = util.promisify(fs.writeFile);