@signal24/vue-foundation 4.0.0 → 4.1.1
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.
- package/dist/src/vite-plugins/vite-openapi-plugin.cli.d.ts +2 -0
- package/dist/src/vite-plugins/vite-openapi-plugin.cli.js +10 -0
- package/dist/src/vite-plugins/vite-openapi-plugin.d.ts +3 -0
- package/dist/src/vite-plugins/vite-openapi-plugin.js +10 -6
- package/package.json +5 -2
- package/src/vite-plugins/vite-openapi-plugin.cli.ts +15 -0
- package/src/vite-plugins/vite-openapi-plugin.ts +11 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { generateOpenapiClient } from './vite-openapi-plugin.js';
|
|
4
|
+
if (!process.argv[2]) {
|
|
5
|
+
throw new Error('Usage: vf-generate-openapi-client <openapi-yaml-path>');
|
|
6
|
+
}
|
|
7
|
+
if (!existsSync(process.argv[2])) {
|
|
8
|
+
throw new Error(`OpenAPI YAML file not found: ${process.argv[2]}`);
|
|
9
|
+
}
|
|
10
|
+
await generateOpenapiClient(process.argv[2]);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { existsSync, readFileSync, watch } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { rm } from 'node:fs/promises';
|
|
4
4
|
import * as OpenAPI from 'openapi-typescript-codegen';
|
|
5
5
|
let generatedHash = null;
|
|
6
6
|
export function openapiClientGeneratorPlugin(openapiYamlPath) {
|
|
7
|
-
|
|
7
|
+
let generator = null;
|
|
8
8
|
return {
|
|
9
9
|
name: 'openapi-types-generator',
|
|
10
|
+
apply: 'serve',
|
|
11
|
+
buildStart() {
|
|
12
|
+
generator = getGenerator(openapiYamlPath);
|
|
13
|
+
},
|
|
10
14
|
closeBundle() {
|
|
11
15
|
generator?.close();
|
|
12
16
|
}
|
|
@@ -20,16 +24,16 @@ function getGenerator(openapiYamlPath) {
|
|
|
20
24
|
const watcher = watch(openapiYamlPath);
|
|
21
25
|
watcher.on('change', () => {
|
|
22
26
|
// give the writes a moment to settle
|
|
23
|
-
setTimeout(() =>
|
|
27
|
+
setTimeout(() => generateOpenapiClient(openapiYamlPath), 100);
|
|
24
28
|
});
|
|
25
|
-
|
|
29
|
+
generateOpenapiClient(openapiYamlPath);
|
|
26
30
|
return {
|
|
27
31
|
close() {
|
|
28
32
|
watcher.close();
|
|
29
33
|
}
|
|
30
34
|
};
|
|
31
35
|
}
|
|
32
|
-
async function
|
|
36
|
+
export async function generateOpenapiClient(openapiYamlPath) {
|
|
33
37
|
const yaml = readFileSync(openapiYamlPath, 'utf8');
|
|
34
38
|
const hash = createHash('sha256').update(yaml).digest('hex');
|
|
35
39
|
if (hash === generatedHash) {
|
|
@@ -38,7 +42,7 @@ async function generateClient(openapiYamlPath) {
|
|
|
38
42
|
generatedHash = hash;
|
|
39
43
|
try {
|
|
40
44
|
try {
|
|
41
|
-
await
|
|
45
|
+
await rm('./src/openapi-client-generated', { recursive: true });
|
|
42
46
|
}
|
|
43
47
|
catch (e) {
|
|
44
48
|
// ignore
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signal24/vue-foundation",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.1",
|
|
5
5
|
"description": "Common components, directives, and helpers for Vue 3 apps",
|
|
6
6
|
"module": "./dist/vue-foundation.es.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"vf-generate-openapi-client": "./dist/src/vite-plugins/vite-openapi-plugin.cli.js"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"import": "./dist/vue-foundation.es.js"
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
"typings": "./dist/src/index.d.ts",
|
|
21
24
|
"scripts": {
|
|
22
25
|
"dev": "vite",
|
|
23
|
-
"build": "rm -rf dist && vite build && vue-tsc --declaration --emitDeclarationOnly -p tsconfig.app.json && tsc -p tsconfig.vite-plugins.json && find dist -name '*.tsbuildinfo' -delete",
|
|
26
|
+
"build": "rm -rf dist && vite build && vue-tsc --declaration --emitDeclarationOnly -p tsconfig.app.json && tsc -p tsconfig.vite-plugins.json && find dist -name '*.tsbuildinfo' -delete && chmod +x dist/src/vite-plugins/vite-openapi-plugin.cli.js",
|
|
24
27
|
"preview": "vite preview",
|
|
25
28
|
"test:types": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
|
|
26
29
|
"test:unit": "vitest",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
|
|
5
|
+
import { generateOpenapiClient } from './vite-openapi-plugin.js';
|
|
6
|
+
|
|
7
|
+
if (!process.argv[2]) {
|
|
8
|
+
throw new Error('Usage: vf-generate-openapi-client <openapi-yaml-path>');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (!existsSync(process.argv[2])) {
|
|
12
|
+
throw new Error(`OpenAPI YAML file not found: ${process.argv[2]}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
await generateOpenapiClient(process.argv[2]);
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { existsSync, readFileSync, watch } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { rm } from 'node:fs/promises';
|
|
4
4
|
|
|
5
5
|
import * as OpenAPI from 'openapi-typescript-codegen';
|
|
6
6
|
|
|
7
7
|
let generatedHash: string | null = null;
|
|
8
8
|
|
|
9
9
|
export function openapiClientGeneratorPlugin(openapiYamlPath: string) {
|
|
10
|
-
|
|
10
|
+
let generator: ReturnType<typeof getGenerator> = null;
|
|
11
11
|
|
|
12
12
|
return {
|
|
13
13
|
name: 'openapi-types-generator',
|
|
14
|
+
apply: 'serve',
|
|
15
|
+
|
|
16
|
+
buildStart() {
|
|
17
|
+
generator = getGenerator(openapiYamlPath);
|
|
18
|
+
},
|
|
14
19
|
|
|
15
20
|
closeBundle() {
|
|
16
21
|
generator?.close();
|
|
@@ -27,10 +32,10 @@ function getGenerator(openapiYamlPath: string) {
|
|
|
27
32
|
const watcher = watch(openapiYamlPath);
|
|
28
33
|
watcher.on('change', () => {
|
|
29
34
|
// give the writes a moment to settle
|
|
30
|
-
setTimeout(() =>
|
|
35
|
+
setTimeout(() => generateOpenapiClient(openapiYamlPath), 100);
|
|
31
36
|
});
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
generateOpenapiClient(openapiYamlPath);
|
|
34
39
|
|
|
35
40
|
return {
|
|
36
41
|
close() {
|
|
@@ -39,7 +44,7 @@ function getGenerator(openapiYamlPath: string) {
|
|
|
39
44
|
};
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
async function
|
|
47
|
+
export async function generateOpenapiClient(openapiYamlPath: string) {
|
|
43
48
|
const yaml = readFileSync(openapiYamlPath, 'utf8');
|
|
44
49
|
const hash = createHash('sha256').update(yaml).digest('hex');
|
|
45
50
|
|
|
@@ -51,7 +56,7 @@ async function generateClient(openapiYamlPath: string) {
|
|
|
51
56
|
|
|
52
57
|
try {
|
|
53
58
|
try {
|
|
54
|
-
await
|
|
59
|
+
await rm('./src/openapi-client-generated', { recursive: true });
|
|
55
60
|
} catch (e) {
|
|
56
61
|
// ignore
|
|
57
62
|
}
|