From 682af97f886d6fdc1ac46678cece4498549e5c82 Mon Sep 17 00:00:00 2001 From: "K.Himeno" Date: Fri, 6 May 2022 20:02:03 +0900 Subject: [PATCH] fix: remove require import (#80) --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 11 ++++++++--- .github/workflows/versionUp.yml | 2 +- pnpm-lock.yaml | 20 ++++++++++---------- scripts/build.ts | 14 ++++++++++++++ src/internal/OpenApiTools/Comment.ts | 5 ++--- src/meta.ts | 2 ++ 7 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 src/meta.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a619f3d..6a24cd05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v3 - uses: pnpm/action-setup@v2.1.0 with: - version: 6.32.3 + version: 7.0.0 - uses: actions/setup-node@v2 with: node-version: "16" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fbd7ea6..c1c54f8e 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: ref: main - uses: pnpm/action-setup@v2.1.0 with: - version: 6.32.3 + version: 7.0.0 - uses: actions/setup-node@v2 with: node-version: "16" @@ -29,6 +29,8 @@ jobs: - run: pnpm i --frozen-lockfile - run: | pnpm build + env: + CI: true release-github-registry: runs-on: ubuntu-latest @@ -44,7 +46,7 @@ jobs: ref: main - uses: pnpm/action-setup@v2.1.0 with: - version: 6.32.3 + version: 7.0.0 - uses: actions/setup-node@v2 with: node-version: "16" @@ -57,6 +59,7 @@ jobs: pnpm -C ./lib release:github:registry env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CI: true release-npm-registry: runs-on: ubuntu-latest @@ -66,7 +69,7 @@ jobs: ref: main - uses: pnpm/action-setup@v2.1.0 with: - version: 6.32.3 + version: 7.0.0 - uses: actions/setup-node@v2 with: node-version: "16.x" @@ -74,6 +77,8 @@ jobs: cache: "pnpm" - run: pnpm install - run: pnpm build + env: + CI: true - run: pnpm -C ./lib release:npm:registry env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/versionUp.yml b/.github/workflows/versionUp.yml index d8883382..69833fce 100644 --- a/.github/workflows/versionUp.yml +++ b/.github/workflows/versionUp.yml @@ -20,7 +20,7 @@ jobs: ref: main - uses: pnpm/action-setup@v2.1.0 with: - version: 6.32.3 + version: 7.0.0 - uses: actions/setup-node@v2 with: node-version: "16.x" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1274798a..2d630a2e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: 5.3 +lockfileVersion: 5.4 overrides: kind-of: 6.0.3 @@ -67,8 +67,8 @@ devDependencies: "@types/js-yaml": 4.0.0 "@types/node": 14.14.37 "@types/rimraf": 3.0.0 - "@typescript-eslint/eslint-plugin": 4.20.0_7448dc1756632cc6400f187319207d38 - "@typescript-eslint/parser": 4.20.0_eslint@7.23.0+typescript@4.2.3 + "@typescript-eslint/eslint-plugin": 4.20.0_orenyf2wmmwmmqapdbzrsid5ha + "@typescript-eslint/parser": 4.20.0_fiokpmyopzkfqgcyzlsuljpi3y chokidar: 3.5.1 conventional-changelog-angular-all: 1.7.0 cpy: 8.1.2 @@ -91,7 +91,7 @@ devDependencies: rimraf: 3.0.2 simple-git-hooks: 2.7.0 sort-package-json: 1.49.0 - ts-jest: 26.5.4_jest@26.6.3+typescript@4.2.3 + ts-jest: 26.5.4_bteoty65ydbkof7g24r4dam4im ts-node: 9.1.1_typescript@4.2.3 typescript: 4.2.3 yarn-deduplicate: 3.1.0 @@ -2018,7 +2018,7 @@ packages: "@types/yargs-parser": 21.0.0 dev: true - /@typescript-eslint/eslint-plugin/4.20.0_7448dc1756632cc6400f187319207d38: + /@typescript-eslint/eslint-plugin/4.20.0_orenyf2wmmwmmqapdbzrsid5ha: resolution: { integrity: sha512-sw+3HO5aehYqn5w177z2D82ZQlqHCwcKSMboueo7oE4KU9QiC0SAgfS/D4z9xXvpTc8Bt41Raa9fBR8T2tIhoQ== } engines: { node: ^10.12.0 || >=12.0.0 } peerDependencies: @@ -2029,8 +2029,8 @@ packages: typescript: optional: true dependencies: - "@typescript-eslint/experimental-utils": 4.20.0_eslint@7.23.0+typescript@4.2.3 - "@typescript-eslint/parser": 4.20.0_eslint@7.23.0+typescript@4.2.3 + "@typescript-eslint/experimental-utils": 4.20.0_fiokpmyopzkfqgcyzlsuljpi3y + "@typescript-eslint/parser": 4.20.0_fiokpmyopzkfqgcyzlsuljpi3y "@typescript-eslint/scope-manager": 4.20.0 debug: 4.3.4 eslint: 7.23.0 @@ -2044,7 +2044,7 @@ packages: - supports-color dev: true - /@typescript-eslint/experimental-utils/4.20.0_eslint@7.23.0+typescript@4.2.3: + /@typescript-eslint/experimental-utils/4.20.0_fiokpmyopzkfqgcyzlsuljpi3y: resolution: { integrity: sha512-sQNlf6rjLq2yB5lELl3gOE7OuoA/6IVXJUJ+Vs7emrQMva14CkOwyQwD7CW+TkmOJ4Q/YGmoDLmbfFrpGmbKng== } engines: { node: ^10.12.0 || >=12.0.0 } peerDependencies: @@ -2062,7 +2062,7 @@ packages: - typescript dev: true - /@typescript-eslint/parser/4.20.0_eslint@7.23.0+typescript@4.2.3: + /@typescript-eslint/parser/4.20.0_fiokpmyopzkfqgcyzlsuljpi3y: resolution: { integrity: sha512-m6vDtgL9EABdjMtKVw5rr6DdeMCH3OA1vFb0dAyuZSa3e5yw1YRzlwFnm9knma9Lz6b2GPvoNSa8vOXrqsaglA== } engines: { node: ^10.12.0 || >=12.0.0 } peerDependencies: @@ -8321,7 +8321,7 @@ packages: engines: { node: ">=8" } dev: true - /ts-jest/26.5.4_jest@26.6.3+typescript@4.2.3: + /ts-jest/26.5.4_bteoty65ydbkof7g24r4dam4im: resolution: { integrity: sha512-I5Qsddo+VTm94SukBJ4cPimOoFZsYTeElR2xy6H2TOVs+NsvgYglW8KuQgKoApOKuaU/Ix/vrF9ebFZlb5D2Pg== } engines: { node: ">= 10" } hasBin: true diff --git a/scripts/build.ts b/scripts/build.ts index 12d2302f..29120f39 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -1,11 +1,25 @@ import "./clean"; +import pkg from "../package.json"; +import * as fs from "fs"; +import { EOL } from "os"; import { cherryPick } from "./tools/cherry-pick"; import { copyPackageSet } from "./tools/copyPackageSet"; import { generateExportsField } from "./tools/dualPackageSupport"; import { shell } from "./tools/shell"; +const generateVersionTsFile = () => { + const codes: string[] = [`export const Name = "${pkg.name}";`, `export const Version = "${pkg.version}";`]; + const tscCode = codes.join(EOL); + if (process.env.CI) { + console.log("`Update src/meta.ts file."); + fs.writeFileSync("src/meta.ts", tscCode, "utf-8"); + } +}; + const main = async () => { + generateVersionTsFile(); + await Promise.all([ shell("pnpm tsc -p tsconfig.esm.json -d --emitDeclarationOnly --outDir ./lib/\\$types"), shell("pnpm tsc -p tsconfig.cjs.json"), diff --git a/src/internal/OpenApiTools/Comment.ts b/src/internal/OpenApiTools/Comment.ts index 1ca44d81..5645f6c7 100644 --- a/src/internal/OpenApiTools/Comment.ts +++ b/src/internal/OpenApiTools/Comment.ts @@ -2,13 +2,12 @@ import { EOL } from "os"; import type { OpenApi } from "../../types"; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const pkg = require("../../../package.json"); +import { Version, Name } from "../../meta"; export const generateLeading = (schema: OpenApi.Document): string => { const messages: string[] = []; messages.push(""); - messages.push(`Generated by ${pkg.name} v${pkg.version}`); + messages.push(`Generated by ${Name} v${Version}`); messages.push(""); messages.push(`OpenApi : ${schema.openapi}`); messages.push(""); diff --git a/src/meta.ts b/src/meta.ts new file mode 100644 index 00000000..741339bf --- /dev/null +++ b/src/meta.ts @@ -0,0 +1,2 @@ +export const Name = "dummy-name"; +export const Version = "dummy";