Skip to content

Commit 682af97

Browse files
authored
fix: remove require import (#80)
1 parent 2ddf010 commit 682af97

File tree

7 files changed

+38
-18
lines changed

7 files changed

+38
-18
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/checkout@v3
2323
- uses: pnpm/[email protected]
2424
with:
25-
version: 6.32.3
25+
version: 7.0.0
2626
- uses: actions/setup-node@v2
2727
with:
2828
node-version: "16"

.github/workflows/release.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
ref: main
2020
- uses: pnpm/[email protected]
2121
with:
22-
version: 6.32.3
22+
version: 7.0.0
2323
- uses: actions/setup-node@v2
2424
with:
2525
node-version: "16"
@@ -29,6 +29,8 @@ jobs:
2929
- run: pnpm i --frozen-lockfile
3030
- run: |
3131
pnpm build
32+
env:
33+
CI: true
3234
3335
release-github-registry:
3436
runs-on: ubuntu-latest
@@ -44,7 +46,7 @@ jobs:
4446
ref: main
4547
- uses: pnpm/[email protected]
4648
with:
47-
version: 6.32.3
49+
version: 7.0.0
4850
- uses: actions/setup-node@v2
4951
with:
5052
node-version: "16"
@@ -57,6 +59,7 @@ jobs:
5759
pnpm -C ./lib release:github:registry
5860
env:
5961
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
CI: true
6063
6164
release-npm-registry:
6265
runs-on: ubuntu-latest
@@ -66,14 +69,16 @@ jobs:
6669
ref: main
6770
- uses: pnpm/[email protected]
6871
with:
69-
version: 6.32.3
72+
version: 7.0.0
7073
- uses: actions/setup-node@v2
7174
with:
7275
node-version: "16.x"
7376
registry-url: "https://registry.npmjs.org"
7477
cache: "pnpm"
7578
- run: pnpm install
7679
- run: pnpm build
80+
env:
81+
CI: true
7782
- run: pnpm -C ./lib release:npm:registry
7883
env:
7984
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/versionUp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
ref: main
2121
- uses: pnpm/[email protected]
2222
with:
23-
version: 6.32.3
23+
version: 7.0.0
2424
- uses: actions/setup-node@v2
2525
with:
2626
node-version: "16.x"

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
import "./clean";
22

3+
import pkg from "../package.json";
4+
import * as fs from "fs";
5+
import { EOL } from "os";
36
import { cherryPick } from "./tools/cherry-pick";
47
import { copyPackageSet } from "./tools/copyPackageSet";
58
import { generateExportsField } from "./tools/dualPackageSupport";
69
import { shell } from "./tools/shell";
710

11+
const generateVersionTsFile = () => {
12+
const codes: string[] = [`export const Name = "${pkg.name}";`, `export const Version = "${pkg.version}";`];
13+
const tscCode = codes.join(EOL);
14+
if (process.env.CI) {
15+
console.log("`Update src/meta.ts file.");
16+
fs.writeFileSync("src/meta.ts", tscCode, "utf-8");
17+
}
18+
};
19+
820
const main = async () => {
21+
generateVersionTsFile();
22+
923
await Promise.all([
1024
shell("pnpm tsc -p tsconfig.esm.json -d --emitDeclarationOnly --outDir ./lib/\\$types"),
1125
shell("pnpm tsc -p tsconfig.cjs.json"),

src/internal/OpenApiTools/Comment.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import { EOL } from "os";
22

33
import type { OpenApi } from "../../types";
44

5-
// eslint-disable-next-line @typescript-eslint/no-var-requires
6-
const pkg = require("../../../package.json");
5+
import { Version, Name } from "../../meta";
76

87
export const generateLeading = (schema: OpenApi.Document): string => {
98
const messages: string[] = [];
109
messages.push("");
11-
messages.push(`Generated by ${pkg.name} v${pkg.version}`);
10+
messages.push(`Generated by ${Name} v${Version}`);
1211
messages.push("");
1312
messages.push(`OpenApi : ${schema.openapi}`);
1413
messages.push("");

src/meta.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const Name = "dummy-name";
2+
export const Version = "dummy";

0 commit comments

Comments
 (0)