From d367820ebed5d74180356e090c93685588176ce3 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Mon, 30 Nov 2020 14:12:22 -0800 Subject: [PATCH] feat: Add `"octokit": { "openapi-version": "1.0.1" }` to package.json (#11) --- .github/workflows/release-notification.yml | 1 - package.json | 16 ++++++---------- scripts/update-package.js | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 scripts/update-package.js diff --git a/.github/workflows/release-notification.yml b/.github/workflows/release-notification.yml index 22f0642af..ba9a962f8 100644 --- a/.github/workflows/release-notification.yml +++ b/.github/workflows/release-notification.yml @@ -12,4 +12,3 @@ jobs: with: app_id: ${{ secrets.RELEASE_NOTIFIER_APP_ID }} private_key: ${{ secrets.RELEASE_NOTIFIER_APP_PRIVATE_KEY }} - dispatch_event_type: "octokit/openapi-types.ts release" diff --git a/package.json b/package.json index af8041013..5140196fe 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,6 @@ { "name": "@octokit/openapi-types", - "publishConfig": { - "access": "public" - }, + "publishConfig": { "access": "public" }, "version": "1.0.0", "description": "Generated TypeScript definitions based on GitHub's OpenAPI spec", "main": "generated/types.ts", @@ -12,12 +10,10 @@ "license": "MIT", "scripts": { "download": "node scripts/download", - "generate-types": "npx openapi-typescript cache/openapi-schema.json -o generated/types.ts" - }, - "devDependencies": { - "openapi-typescript": "^2.4.2" + "generate-types": "npx openapi-typescript cache/openapi-schema.json -o generated/types.ts", + "postgenerate-types": "node scripts/update-package" }, - "release": { - "branches": "main" - } + "devDependencies": { "openapi-typescript": "^2.4.2", "prettier": "^2.2.1" }, + "release": { "branches": "main" }, + "octokit": { "openapi-version": "1.0.1" } } diff --git a/scripts/update-package.js b/scripts/update-package.js new file mode 100644 index 000000000..b72c5f8fd --- /dev/null +++ b/scripts/update-package.js @@ -0,0 +1,19 @@ +const { writeFileSync } = require("fs"); +const prettier = require("prettier"); + +if (!process.env.VERSION) { + throw new Error("VERSION is not set"); +} + +const pkg = require("../package.json"); + +if (!pkg.octokit) { + pkg.octokit = {}; +} + +pkg.octokit["openapi-version"] = process.env.VERSION; + +writeFileSync( + "package.json", + prettier.format(JSON.stringify(pkg), { parser: "json" }) +);