Skip to content

Commit 8c1154c

Browse files
authored
feat: support ES Modules (#119)
BREAKING CHANGE: Support ES Modules & Require TypeScript >= 5
1 parent cbcccde commit 8c1154c

92 files changed

Lines changed: 4842 additions & 4563 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
},
4343
overrides: [
4444
{
45-
files: ["example/**"],
45+
files: ["examples/**"],
4646
rules: {
4747
"@typescript-eslint/no-unused-vars": "off",
4848
"@typescript-eslint/no-empty-interface": "off",

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [16]
12+
node-version: [20.x]
1313
os: [windows-latest, ubuntu-latest]
1414

1515
steps:
@@ -22,10 +22,10 @@ jobs:
2222
- uses: actions/checkout@v3
2323
- uses: pnpm/action-setup@v2.1.0
2424
with:
25-
version: 7.0.0
25+
version: 8.15.1
2626
- uses: actions/setup-node@v2
2727
with:
28-
node-version: "16"
28+
node-version: "20.x"
2929
cache: "pnpm"
3030
- run: pnpm i --frozen-lockfile
3131
- name: Use Node.js ${{ matrix.node-version }}

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
ref: main
2020
- uses: pnpm/action-setup@v2.1.0
2121
with:
22-
version: 7.0.0
22+
version: 8.15.1
2323
- uses: actions/setup-node@v2
2424
with:
25-
node-version: "16"
25+
node-version: "20.x"
2626
registry-url: https://npm.pkg.github.com
2727
scope: "@Himenon"
2828
cache: "pnpm"
@@ -46,10 +46,10 @@ jobs:
4646
ref: main
4747
- uses: pnpm/action-setup@v2.1.0
4848
with:
49-
version: 7.0.0
49+
version: 8.15.1
5050
- uses: actions/setup-node@v2
5151
with:
52-
node-version: "16"
52+
node-version: "20.x"
5353
registry-url: https://npm.pkg.github.com
5454
scope: "@Himenon"
5555
cache: "pnpm"
@@ -69,10 +69,10 @@ jobs:
6969
ref: main
7070
- uses: pnpm/action-setup@v2.1.0
7171
with:
72-
version: 7.0.0
72+
version: 8.15.1
7373
- uses: actions/setup-node@v2
7474
with:
75-
node-version: "16.x"
75+
node-version: "20.x"
7676
registry-url: "https://registry.npmjs.org"
7777
cache: "pnpm"
7878
- run: pnpm install

.github/workflows/versionUp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
ref: main
2121
- uses: pnpm/action-setup@v2.1.0
2222
with:
23-
version: 7.0.0
23+
version: 8.15.1
2424
- uses: actions/setup-node@v2
2525
with:
26-
node-version: "16.x"
26+
node-version: "20.x"
2727
cache: "pnpm"
2828
- run: pnpm i --frozen-lockfile
2929
- name: Auto version update

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ debug
1111
test/kubernetes
1212
test/argo-rollout
1313
CHANGELOG.md
14+
esm/
15+
dist/
16+
output/

.yarnrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ main();
5252
import * as fs from "fs";
5353

5454
import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
55-
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
56-
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
55+
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
56+
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";
5757

5858
const main = () => {
5959
const codeGenerator = new CodeGenerator("your/openapi/spec.yml");
@@ -79,7 +79,7 @@ main();
7979
This library provides three types of templates
8080

8181
```ts
82-
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
82+
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
8383

8484
Templates.ClassApiClient.generator;
8585
Templates.FunctionalApiClient.generator;
@@ -106,7 +106,10 @@ export interface ApiClient<RequestOption> {
106106

107107
export class Client<RequestOption> {
108108
private baseUrl: string;
109-
constructor(private apiClient: ApiClient<RequestOption>, baseUrl: string) {
109+
constructor(
110+
private apiClient: ApiClient<RequestOption>,
111+
baseUrl: string,
112+
) {
110113
this.baseUrl = baseUrl.replace(/\/$/, "");
111114
}
112115

@@ -270,8 +273,8 @@ export const createPublisherV2 =
270273
import * as fs from "fs";
271274

272275
import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
273-
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
274-
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
276+
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
277+
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";
275278

276279
const main = () => {
277280
const codeGenerator = new CodeGenerator("your/openapi/spec.yml");
@@ -307,7 +310,7 @@ The examples in this section can be used in the following ways
307310
import * as fs from "fs";
308311

309312
import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
310-
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
313+
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";
311314

312315
/** Write the definition of the Code Template here. */
313316
const customGenerator: Types.CodeGenerator.CustomGenerator<{}> = {
@@ -440,7 +443,7 @@ You can directly use the API of TypeScript AST or use the wrapper API of TypeScr
440443

441444
```ts
442445
import * as Types from "@himenon/openapi-typescript-code-generator/types";
443-
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
446+
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api";
444447

445448
interface Option {}
446449

@@ -501,7 +504,7 @@ This is a type definition file for `Templates.FunctionalApiClient`. The reason i
501504
### TsGenerator
502505

503506
```ts
504-
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
507+
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api";
505508
```
506509

507510
This is a wrapper API for the TypeScript AST used internally.
@@ -510,7 +513,7 @@ It is subject to change without notice.
510513
### OpenApiTools
511514

512515
```ts
513-
import { OpenApiTools } from "@himenon/openapi-typescript-code-generator/api";
516+
import { OpenApiTools } from "@himenon/openapi-typescript-code-generator/dist/api";
514517
```
515518

516519
#### Parser

docs/ja/README-ja.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ main();
4646
import * as fs from "fs";
4747

4848
import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
49-
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
50-
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
49+
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
50+
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";
5151

5252
const main = () => {
5353
const codeGenerator = new CodeGenerator("your/openapi/spec.yml");
@@ -73,7 +73,7 @@ main();
7373
本ライブラリからは 3 種類提供しています。
7474

7575
```ts
76-
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
76+
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
7777

7878
Templates.ClassApiClient.generator;
7979
Templates.FunctionalApiClient.generator;
@@ -100,7 +100,10 @@ export interface ApiClient<RequestOption> {
100100

101101
export class Client<RequestOption> {
102102
private baseUrl: string;
103-
constructor(private apiClient: ApiClient<RequestOption>, baseUrl: string) {
103+
constructor(
104+
private apiClient: ApiClient<RequestOption>,
105+
baseUrl: string,
106+
) {
104107
this.baseUrl = baseUrl.replace(/\/$/, "");
105108
}
106109

@@ -266,8 +269,8 @@ export const createPublisherV2 =
266269
import * as fs from "fs";
267270

268271
import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
269-
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
270-
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
272+
import * as Templates from "@himenon/openapi-typescript-code-generator/dist/templates";
273+
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";
271274

272275
const main = () => {
273276
const codeGenerator = new CodeGenerator("your/openapi/spec.yml");
@@ -303,7 +306,7 @@ main();
303306
import * as fs from "fs";
304307

305308
import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
306-
import type * as Types from "@himenon/openapi-typescript-code-generator/types";
309+
import type * as Types from "@himenon/openapi-typescript-code-generator/dist/types";
307310

308311
/** ここにCode Templateの定義を記述してください */
309312
const customGenerator: Types.CodeGenerator.CustomGenerator<{}> = {
@@ -436,7 +439,7 @@ TypeScript AST の API を利用したコードの拡張が可能です。
436439

437440
```ts
438441
import * as Types from "@himenon/openapi-typescript-code-generator/types";
439-
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
442+
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api";
440443

441444
interface Option {}
442445

@@ -497,7 +500,7 @@ OpenAPI Schema から抽出したパラメーターを取得できます。
497500
### TsGenerator
498501

499502
```ts
500-
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
503+
import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api";
501504
```
502505

503506
内部で利用している TypeScript AST のラッパー API です。
@@ -506,7 +509,7 @@ import { TsGenerator } from "@himenon/openapi-typescript-code-generator/api";
506509
### OpenApiTools
507510

508511
```ts
509-
import { OpenApiTools } from "@himenon/openapi-typescript-code-generator/api";
512+
import { OpenApiTools } from "@himenon/openapi-typescript-code-generator/dist/api";
510513
```
511514

512515
#### Parser
File renamed without changes.

0 commit comments

Comments
 (0)