@rvoh/psychic 0.37.2 → 0.37.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -41,11 +41,17 @@ async function syncTypescriptOpenapiFiles() {
|
|
|
41
41
|
const outpath = path.join((0, psychicPath_js_1.default)('types'), `${jsonPath.replace(/\.json$/, '')}.d.ts`);
|
|
42
42
|
return dream_1.DreamCLI.spawn(`npx openapi-typescript ${jsonPath} -o ${outpath}`).then(async () => {
|
|
43
43
|
const file = (await fs.readFile(outpath)).toString();
|
|
44
|
-
const exportName = (0, dream_1.camelize)(jsonPath
|
|
44
|
+
const exportName = dotToCamelCase((0, dream_1.camelize)(jsonPath
|
|
45
45
|
.split('/')
|
|
46
46
|
.at(-1)
|
|
47
|
-
?.replace(/\.json/, '')) + 'Paths';
|
|
47
|
+
?.replace(/\.json/, ''))) + 'Paths';
|
|
48
48
|
await fs.writeFile(outpath, file.replace(/export interface paths/, `export interface ${exportName}`));
|
|
49
49
|
});
|
|
50
50
|
}));
|
|
51
51
|
}
|
|
52
|
+
function dotToCamelCase(inputString) {
|
|
53
|
+
return inputString
|
|
54
|
+
.split('.')
|
|
55
|
+
.map((word, index) => (index === 0 ? word : (0, dream_1.capitalize)(word)))
|
|
56
|
+
.join('');
|
|
57
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelize, DreamCLI } from '@rvoh/dream';
|
|
1
|
+
import { camelize, capitalize, DreamCLI } from '@rvoh/dream';
|
|
2
2
|
import * as fs from 'node:fs/promises';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import PsychicApp from '../../psychic-app/index.js';
|
|
@@ -12,11 +12,17 @@ export default async function syncTypescriptOpenapiFiles() {
|
|
|
12
12
|
const outpath = path.join(psychicPath('types'), `${jsonPath.replace(/\.json$/, '')}.d.ts`);
|
|
13
13
|
return DreamCLI.spawn(`npx openapi-typescript ${jsonPath} -o ${outpath}`).then(async () => {
|
|
14
14
|
const file = (await fs.readFile(outpath)).toString();
|
|
15
|
-
const exportName = camelize(jsonPath
|
|
15
|
+
const exportName = dotToCamelCase(camelize(jsonPath
|
|
16
16
|
.split('/')
|
|
17
17
|
.at(-1)
|
|
18
|
-
?.replace(/\.json/, '')) + 'Paths';
|
|
18
|
+
?.replace(/\.json/, ''))) + 'Paths';
|
|
19
19
|
await fs.writeFile(outpath, file.replace(/export interface paths/, `export interface ${exportName}`));
|
|
20
20
|
});
|
|
21
21
|
}));
|
|
22
22
|
}
|
|
23
|
+
function dotToCamelCase(inputString) {
|
|
24
|
+
return inputString
|
|
25
|
+
.split('.')
|
|
26
|
+
.map((word, index) => (index === 0 ? word : capitalize(word)))
|
|
27
|
+
.join('');
|
|
28
|
+
}
|