Skip to content

Commit 304682c

Browse files
committed
Update code generator to ESM
1 parent 0402ed8 commit 304682c

7 files changed

Lines changed: 262 additions & 153 deletions

File tree

code-generator/package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
{
2+
"type": "module",
23
"license": "MIT",
34
"scripts": {
4-
"definitions": "rm -rf ../src/main/java/com/ringcentral/definitions/* && ts-node -r dotenv-override-true/config ./src/definitions.ts",
5-
"paths": "rm -rf ../src/main/java/com/ringcentral/paths/* && ts-node -r dotenv-override-true/config ./src/paths.ts",
6-
"samples": "ts-node -r dotenv-override-true/config ./src/samples.ts",
5+
"definitions": "rm -rf ../src/main/java/com/ringcentral/definitions/* && yarn tsx -r dotenv-override-true/config ./src/definitions.ts",
6+
"paths": "rm -rf ../src/main/java/com/ringcentral/paths/* && yarn tsx -r dotenv-override-true/config ./src/paths.ts",
7+
"samples": "yarn tsx -r dotenv-override-true/config ./src/samples.ts",
78
"generate": "yarn definitions && yarn paths && yarn samples"
89
},
910
"dependencies": {
1011
"change-case": "4.1.2",
11-
"js-yaml": "^4.1.0",
12+
"js-yaml": "^4.1.1",
1213
"lower-case-first": "^3.0.0",
1314
"openapi-types": "^12.1.3",
14-
"ramda": "^0.31.3",
15-
"ringcentral-open-api-parser": "^0.15.9"
15+
"ramda": "^0.32.0",
16+
"ringcentral-open-api-parser": "^0.17.1"
1617
},
1718
"devDependencies": {
1819
"@types/js-yaml": "^4.0.9",
19-
"@types/node": "^24.6.0",
20+
"@types/node": "^25.5.2",
2021
"@types/ramda": "^0.31.1",
2122
"dotenv-override-true": "^6.2.2",
22-
"ts-node": "^10.9.2",
23-
"typescript": "^5.9.2",
23+
"tsx": "^4.21.0",
24+
"typescript": "^6.0.2",
2425
"yarn-upgrade-all": "^0.7.5"
2526
},
2627
"yarn-upgrade-all": {

code-generator/src/definitions.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import fs from "fs";
22
import path from "path";
3-
import { Field } from "ringcentral-open-api-parser/lib/types";
3+
import { fileURLToPath } from "url";
4+
import type { Field } from "ringcentral-open-api-parser/lib/types.js";
45

5-
import { escapeJavaDoc } from "./utils";
6-
import { parsed } from "./parser";
6+
import { escapeJavaDoc } from "./utils.js";
7+
import { parsed } from "./parser.js";
8+
9+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
710

811
const outputDir = path.join(
912
__dirname,

code-generator/src/paths.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import fs from "fs";
22
import path from "path";
33
import { camelCase, capitalCase, pascalCase } from "change-case";
4-
import R from "ramda";
5-
import { Operation } from "ringcentral-open-api-parser/lib/types";
4+
import * as R from "ramda";
5+
import type { Operation } from "ringcentral-open-api-parser/lib/types.js";
66

7-
import { capitalizeFirstLetter, escapeJavaDoc, patchSrcFile } from "./utils";
8-
import { parsed } from "./parser";
7+
import { capitalizeFirstLetter, escapeJavaDoc, patchSrcFile } from "./utils.js";
8+
import { parsed } from "./parser.js";
99

1010
const outputDir = "../src/main/java/com/ringcentral/paths";
1111

code-generator/src/samples.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import fs from "fs";
22
import path from "path";
3-
import R from "ramda";
3+
import { fileURLToPath } from "url";
4+
import * as R from "ramda";
45
import { camelCase } from "change-case";
56

6-
import { capitalizeFirstLetter } from "./utils";
7-
import { parsed } from "./parser";
7+
import { capitalizeFirstLetter } from "./utils.js";
8+
import { parsed } from "./parser.js";
9+
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
811

912
const markdown = ["# RingCentral Java SDK Code Samples"];
1013

code-generator/src/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import path from "path";
22
import fs from "fs";
3+
import { fileURLToPath } from "url";
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
36

47
export const escapeJavaDoc = (str: string | undefined) => {
58
if (typeof str === "string") {

code-generator/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"strict": false,
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"skipLibCheck": true
10+
},
11+
"include": [
12+
"src/**/*.ts"
13+
]
14+
}

0 commit comments

Comments
 (0)