From 26d534068f91bfd01d303ff6729c7a7a3728226c Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 14 Nov 2022 07:04:36 -0800 Subject: [PATCH] build: provide moduleVersion to docs-parser directly (#36329) --- package.json | 6 +++--- script/create-api-json.js | 17 +++++++++++++++++ yarn.lock | 16 ++++++++-------- 3 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 script/create-api-json.js diff --git a/package.json b/package.json index 8a49c3ba23a56..75cc526e1f2c7 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "devDependencies": { "@azure/storage-blob": "^12.9.0", "@electron/asar": "^3.2.1", - "@electron/docs-parser": "^0.12.4", - "@electron/typescript-definitions": "^8.9.5", + "@electron/docs-parser": "^1.0.0", + "@electron/typescript-definitions": "^8.10.0", "@octokit/auth-app": "^2.10.0", "@octokit/rest": "^18.0.3", "@primer/octicons": "^10.0.0", @@ -89,7 +89,7 @@ "lint:docs-relative-links": "python3 ./script/check-relative-doc-links.py", "lint:markdownlint": "markdownlint \"*.md\" \"docs/**/*.md\"", "lint:js-in-markdown": "standard-markdown docs", - "create-api-json": "electron-docs-parser --dir=./", + "create-api-json": "node script/create-api-json.js", "create-typescript-definitions": "npm run create-api-json && electron-typescript-definitions --api=electron-api.json && node spec/ts-smoke/runner.js", "gn-typescript-definitions": "npm run create-typescript-definitions && shx cp electron.d.ts", "pre-flight": "pre-flight", diff --git a/script/create-api-json.js b/script/create-api-json.js new file mode 100644 index 0000000000000..00a70355c3f8d --- /dev/null +++ b/script/create-api-json.js @@ -0,0 +1,17 @@ +const { parseDocs } = require('@electron/docs-parser'); +const fs = require('fs'); +const path = require('path'); + +const { getElectronVersion } = require('./lib/get-version'); + +parseDocs({ + baseDirectory: path.resolve(__dirname, '..'), + packageMode: 'single', + useReadme: false, + moduleVersion: getElectronVersion() +}).then((api) => { + return fs.promises.writeFile(path.resolve(__dirname, '..', 'electron-api.json'), JSON.stringify(api, null, 2)); +}).catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/yarn.lock b/yarn.lock index 0a371e2c7e6ec..5e051cbd213f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -118,10 +118,10 @@ optionalDependencies: "@types/glob" "^7.1.1" -"@electron/docs-parser@^0.12.4": - version "0.12.4" - resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-0.12.4.tgz#cca403c8c2200181339c3115cdd25f3fbfc7dea3" - integrity sha512-vdkjcvkI7zTd2v1A8qsl5+HY+9AQCrW5Eh60I9rhPtUPoxo2V1pQwogTW6kzc3XZ54crTa7R3KxwkZpSbcGCug== +"@electron/docs-parser@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-1.0.0.tgz#1844ed2e18528ea56aaef0ace1cfa0633a6fa1b1" + integrity sha512-nIqEO8Ga6LavdaY2aJMPfq2vSOPVlgOvNv7jpiyaoqsAz5vYnWNUnxeCyaalCaDyFiKhVeHbKwP8Kt2TENwneg== dependencies: "@types/markdown-it" "^10.0.0" chai "^4.2.0" @@ -133,10 +133,10 @@ ora "^4.0.3" pretty-ms "^5.1.0" -"@electron/typescript-definitions@^8.9.5": - version "8.9.5" - resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.9.5.tgz#e6cb08e0e7c9656e178b892eab50866a8a80bf7a" - integrity sha512-xDLFl6joGpA8c9cGSPWC3DFHyIGf9+OWZmDrPbGJW1URt6C1ukdQWKSmjb1Rttb94QQxBrGuUlSyz27IQgLFsw== +"@electron/typescript-definitions@^8.10.0": + version "8.10.0" + resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.10.0.tgz#e9cf2b329ec4b0b76947ef751725383a6cf8994d" + integrity sha512-FVc2y0GUfxFZDoma0scYiMxkoalle19Fq332fNFGWoCJ9rCj5OUvriewSjPtGBsRuHv2xaMS5MhBuy2/pRuFuQ== dependencies: "@types/node" "^11.13.7" chalk "^2.4.2"