Skip to content

Commit 4c6ec52

Browse files
authored
Merge pull request #7 from sparingsoftware/beta
Release Beta
2 parents 26fe7a1 + 36738e0 commit 4c6ec52

5 files changed

Lines changed: 23 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Create a sparing-open-api.config.js file at the root of the project
1010

1111
```js
1212
/** @type {import('@sparing-software/sparing-open-api').Config} */
13-
module.exports = {
13+
export default {
1414
url: 'https://example.com/schema/'
1515
}
1616
```

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sparing-software/sparing-open-api",
3-
"version": "12.0.0",
3+
"version": "12.1.0-beta.2",
44
"description": "Generate http service based on open api schema",
55
"bin": "./dist/index.js",
66
"main": "./dist/index.js",

src/index.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export type Config = {
5252
typeWhitelist?: string[]
5353
}
5454

55-
function main() {
55+
async function main() {
5656
const CONFIG_PATH = path.resolve(process.cwd(), 'sparing-open-api.config.js')
5757

5858
if (!fs.existsSync(CONFIG_PATH)) {
@@ -72,7 +72,7 @@ function main() {
7272
include = [],
7373
optimizeTypes = true,
7474
typeWhitelist = []
75-
} = require(CONFIG_PATH) as Config
75+
} = (await import(CONFIG_PATH)).default as Config
7676

7777
if (!url) {
7878
console.log(
@@ -144,14 +144,18 @@ function main() {
144144
if (!fs.existsSync(OUTPUT_PATH))
145145
fs.mkdirSync(OUTPUT_PATH, { recursive: true })
146146

147-
const [{ content, name }] = files
148-
const fullPath = `${OUTPUT_PATH}/${name}`
147+
const [firstFile] = files
149148

150-
fs.writeFileSync(fullPath, content)
149+
if (firstFile) {
150+
const { name, content } = firstFile
151+
const fullPath = `${OUTPUT_PATH}/${name}`
151152

152-
if (optimizeTypes) {
153-
console.log('🤏 optimizing types')
154-
await optimizeTypesUtil(fullPath, typeWhitelist)
153+
fs.writeFileSync(fullPath, content)
154+
155+
if (optimizeTypes) {
156+
console.log('🤏 optimizing types')
157+
await optimizeTypesUtil(fullPath, typeWhitelist)
158+
}
155159
}
156160

157161
process.exit(0)

tsconfig.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
"strict": true,
44
"outDir": "dist",
55
"rootDir": "src",
6-
"module": "commonjs",
7-
"target": "es6",
6+
"target": "es2022",
7+
"module": "NodeNext",
8+
"moduleResolution": "NodeNext",
9+
"noUncheckedIndexedAccess": true,
10+
"isolatedModules": true,
811
"esModuleInterop": true,
912
"sourceMap": true,
1013
"declaration": true,
11-
"skipLibCheck": true
14+
"skipLibCheck": true,
15+
"allowJs": true
1216
},
1317
"exclude": ["node_modules", "templates"]
1418
}

0 commit comments

Comments
 (0)