Skip to content

Commit 43218fc

Browse files
committed
ESM
Signed-off-by: Sora Morimoto <[email protected]>
1 parent 8cc7cf4 commit 43218fc

Some content is hidden

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

57 files changed

+3765
-1259
lines changed

cli/constants.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ const skip_command = Symbol("skip");
33

44
const reservedOptions = ["version", "help"];
55

6-
module.exports = {
7-
root_command,
8-
skip_command,
9-
reservedOptions,
10-
};
6+
export { root_command, skip_command, reservedOptions };

cli/execute.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const _ = require("lodash");
2-
const { root_command, skip_command } = require("./constants");
3-
const { parseArgs } = require("./parse-args");
4-
const didYouMean = require("didyoumean");
1+
import didYouMean from "didyoumean";
2+
import _ from "lodash";
3+
import { root_command, skip_command } from "./constants.js";
4+
import { parseArgs } from "./parse-args.js";
55

66
didYouMean.threshold = 0.5;
77

@@ -177,6 +177,4 @@ const processArgs = (commands, args) => {
177177
};
178178
};
179179

180-
module.exports = {
181-
execute,
182-
};
180+
export { execute };

cli/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const _ = require("lodash");
2-
const { reservedOptions, root_command } = require("./constants");
3-
const { processOption } = require("./process-option");
4-
const { execute } = require("./execute");
5-
const { displayHelp } = require("./operations/display-help");
6-
const { displayVersion } = require("./operations/display-version");
1+
import _ from "lodash";
2+
import { reservedOptions, root_command } from "./constants.js";
3+
import { execute } from "./execute.js";
4+
import { displayHelp } from "./operations/display-help.js";
5+
import { displayVersion } from "./operations/display-version.js";
6+
import { processOption } from "./process-option.js";
77

88
const cli = (input) => {
99
const commands = {};
@@ -91,6 +91,4 @@ const cli = (input) => {
9191
return instance;
9292
};
9393

94-
module.exports = {
95-
cli,
96-
};
94+
export { cli };

cli/operations/display-help.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const _ = require("lodash");
2-
const { root_command } = require("../constants");
1+
import _ from "lodash";
2+
import { root_command } from "../constants.js";
33

44
const generateOptionsOutput = (options) =>
55
options.reduce(
@@ -174,6 +174,4 @@ ${command.description}`
174174
${outputTest}`);
175175
};
176176

177-
module.exports = {
178-
displayHelp,
179-
};
177+
export { displayHelp };

cli/operations/display-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ const displayVersion = (instance) => {
22
console.log(instance.input.version);
33
};
44

5-
module.exports = { displayVersion };
5+
export { displayVersion };

cli/parse-args.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ const parseArgs = (args, type) => {
2121
}
2222
};
2323

24-
module.exports = {
25-
parseArgs,
26-
};
24+
export { parseArgs };

cli/process-option.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const _ = require("lodash");
1+
import _ from "lodash";
22

33
const optionFormatters = {
44
number: (str) => +str,
@@ -72,6 +72,4 @@ const processOption = (option) => {
7272
};
7373
};
7474

75-
module.exports = {
76-
processOption,
77-
};
75+
export { processOption };

index.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
#!/usr/bin/env node
22

3-
// Copyright (c) 2019-present acacode
4-
// Node module: swagger-typescript-api
5-
// This file is licensed under the MIT License.
6-
// License text available at https://opensource.org/licenses/MIT
7-
// Repository https://github.com/acacode/swagger-typescript-api
8-
9-
const { version, name } = require("./package.json");
10-
const { cli } = require("./cli");
11-
const { generateApi, generateTemplates } = require("./src");
12-
const { HTTP_CLIENT } = require("./src/constants");
13-
const { resolve } = require("node:path");
14-
const { CodeGenConfig } = require("./src/configuration");
15-
const {
16-
TemplatesGenConfig,
17-
} = require("./src/commands/generate-templates/configuration");
3+
import { resolve } from "node:path";
4+
import { cli } from "./cli/index.js";
5+
import { name, version } from "./package.json";
6+
import { TemplatesGenConfig } from "./src/commands/generate-templates/configuration.js";
7+
import { CodeGenConfig } from "./src/configuration.js";
8+
import { HTTP_CLIENT } from "./src/constants.js";
9+
import { generateApi, generateTemplates } from "./src/index.js";
1810

1911
const codeGenBaseConfig = new CodeGenConfig({});
2012
const templateGenBaseConfig = new TemplatesGenConfig({});

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"contributors": [
1111
"Sora Morimoto <[email protected]>"
1212
],
13+
"type": "module",
1314
"main": "./src/index.js",
1415
"types": "./index.d.ts",
1516
"bin": {
@@ -49,13 +50,16 @@
4950
"typescript": "~5.4.5"
5051
},
5152
"devDependencies": {
53+
"5to6-codemod": "1.8.0",
5254
"@biomejs/biome": "1.8.2",
5355
"@types/didyoumean": "1.2.2",
5456
"@types/js-yaml": "4.0.9",
57+
"@types/jscodeshift": "^0",
5558
"@types/lodash": "4.17.5",
5659
"@types/node": "20.14.6",
5760
"@types/swagger2openapi": "7.0.4",
5861
"axios": "1.7.2",
62+
"jscodeshift": "0.16.0",
5963
"shx": "0.3.4",
6064
"vitest": "1.6.0"
6165
},

src/code-formatter.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const _ = require("lodash");
2-
const ts = require("typescript");
3-
const prettier = require("prettier");
1+
import _ from "lodash";
2+
import prettier from "prettier";
3+
import ts from "typescript";
44

55
class CodeFormatter {
66
/**
@@ -111,6 +111,4 @@ class TsLanguageServiceHost {
111111
}
112112
}
113113

114-
module.exports = {
115-
CodeFormatter,
116-
};
114+
export { CodeFormatter };

0 commit comments

Comments
 (0)