@pikku/cli 0.7.7 → 0.8.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/CHANGELOG.md +43 -0
- package/bin/pikku-all.ts +188 -91
- package/bin/pikku-fetch.ts +10 -38
- package/bin/pikku-nextjs.ts +12 -113
- package/bin/pikku-openapi.ts +9 -54
- package/bin/pikku-queue-service.ts +28 -0
- package/bin/pikku-schemas.ts +6 -32
- package/bin/pikku-websocket.ts +11 -41
- package/bin/pikku.ts +2 -0
- package/cli.schema.json +113 -10
- package/dist/bin/pikku-all.d.ts +1 -1
- package/dist/bin/pikku-all.js +105 -84
- package/dist/bin/pikku-fetch.d.ts +1 -3
- package/dist/bin/pikku-fetch.js +9 -15
- package/dist/bin/pikku-nextjs.d.ts +1 -4
- package/dist/bin/pikku-nextjs.js +10 -40
- package/dist/bin/pikku-openapi.d.ts +0 -3
- package/dist/bin/pikku-openapi.js +8 -24
- package/dist/bin/pikku-queue-service.d.ts +4 -0
- package/dist/bin/pikku-queue-service.js +19 -0
- package/dist/bin/pikku-schemas.d.ts +0 -3
- package/dist/bin/pikku-schemas.js +5 -11
- package/dist/bin/pikku-websocket.d.ts +1 -3
- package/dist/bin/pikku-websocket.js +9 -18
- package/dist/bin/pikku.js +2 -0
- package/dist/src/events/channels/pikku-channels.d.ts +2 -0
- package/dist/src/events/channels/pikku-channels.js +9 -0
- package/dist/src/events/channels/pikku-command-channels-map.d.ts +2 -0
- package/dist/src/events/channels/pikku-command-channels-map.js +8 -0
- package/dist/src/events/channels/pikku-command-channels.d.ts +2 -0
- package/dist/src/events/channels/pikku-command-channels.js +9 -0
- package/dist/src/events/channels/pikku-command-websocket-typed.d.ts +2 -0
- package/dist/src/events/channels/pikku-command-websocket-typed.js +15 -0
- package/dist/src/{serialize-typed-channel-map.js → events/channels/serialize-typed-channel-map.js} +2 -2
- package/dist/src/events/fetch/index.d.ts +2 -0
- package/dist/src/events/fetch/index.js +12 -0
- package/dist/src/events/functions/pikku-command-function-types.d.ts +2 -0
- package/dist/src/events/functions/pikku-command-function-types.js +13 -0
- package/dist/src/events/functions/pikku-command-functions.d.ts +6 -0
- package/dist/src/events/functions/pikku-command-functions.js +35 -0
- package/dist/src/events/functions/pikku-command-services.d.ts +3 -0
- package/dist/src/events/functions/pikku-command-services.js +73 -0
- package/dist/src/events/functions/pikku-function-types.d.ts +2 -0
- package/dist/{bin → src/events/functions}/pikku-function-types.js +6 -6
- package/dist/src/events/functions/pikku-functions.d.ts +6 -0
- package/dist/{bin → src/events/functions}/pikku-functions.js +5 -5
- package/dist/src/events/http/pikku-command-http-map.d.ts +2 -0
- package/dist/src/events/http/pikku-command-http-map.js +8 -0
- package/dist/src/events/http/pikku-command-http-routes.d.ts +2 -0
- package/dist/src/events/http/pikku-command-http-routes.js +9 -0
- package/dist/src/events/http/pikku-command-openapi.d.ts +2 -0
- package/dist/src/events/http/pikku-command-openapi.js +20 -0
- package/dist/src/events/http/pikku-http-routes.d.ts +2 -0
- package/dist/src/events/http/pikku-http-routes.js +9 -0
- package/dist/src/{serialize-typed-http-map.d.ts → events/http/serialize-typed-http-map.d.ts} +0 -1
- package/dist/src/{serialize-typed-http-map.js → events/http/serialize-typed-http-map.js} +2 -15
- package/dist/src/events/mcp/pikku-command-mcp-json.d.ts +2 -0
- package/dist/src/events/mcp/pikku-command-mcp-json.js +13 -0
- package/dist/src/events/mcp/pikku-command-mcp.d.ts +2 -0
- package/dist/src/events/mcp/pikku-command-mcp.js +54 -0
- package/dist/src/events/mcp/serialize-mcp-json.d.ts +5 -0
- package/dist/src/events/mcp/serialize-mcp-json.js +101 -0
- package/dist/src/events/queue/pikku-command-queue-map.d.ts +2 -0
- package/dist/src/events/queue/pikku-command-queue-map.js +8 -0
- package/dist/src/events/queue/pikku-command-queue-service.d.ts +2 -0
- package/dist/src/events/queue/pikku-command-queue-service.js +12 -0
- package/dist/src/events/queue/pikku-command-queue.d.ts +2 -0
- package/dist/src/events/queue/pikku-command-queue.js +10 -0
- package/dist/src/events/queue/pikku-queue-map.d.ts +2 -0
- package/dist/src/events/queue/pikku-queue-map.js +8 -0
- package/dist/src/events/queue/pikku-queue.d.ts +2 -0
- package/dist/src/events/queue/pikku-queue.js +10 -0
- package/dist/src/events/queue/serialize-queue-map.d.ts +4 -0
- package/dist/src/events/queue/serialize-queue-map.js +77 -0
- package/dist/src/events/queue/serialize-queue-meta.d.ts +2 -0
- package/dist/src/events/queue/serialize-queue-meta.js +6 -0
- package/dist/src/events/queue/serialize-queue-wrapper.d.ts +1 -0
- package/dist/src/events/queue/serialize-queue-wrapper.js +35 -0
- package/dist/src/events/rpc/pikku-command-rpc-client.d.ts +2 -0
- package/dist/src/events/rpc/pikku-command-rpc-client.js +12 -0
- package/dist/src/events/rpc/pikku-command-rpc-map.d.ts +2 -0
- package/dist/src/events/rpc/pikku-command-rpc-map.js +8 -0
- package/dist/src/events/rpc/pikku-command-rpc.d.ts +2 -0
- package/dist/src/events/rpc/pikku-command-rpc.js +6 -0
- package/dist/src/events/rpc/pikku-rpc.d.ts +2 -0
- package/dist/src/events/rpc/pikku-rpc.js +6 -0
- package/dist/src/events/rpc/serialize-rpc-wrapper.d.ts +1 -0
- package/dist/src/events/rpc/serialize-rpc-wrapper.js +29 -0
- package/dist/src/{serialize-typed-rpc-map.d.ts → events/rpc/serialize-typed-rpc-map.d.ts} +1 -1
- package/dist/src/{serialize-typed-rpc-map.js → events/rpc/serialize-typed-rpc-map.js} +3 -3
- package/dist/src/events/scheduler/pikku-command-scheduler.d.ts +2 -0
- package/dist/src/events/scheduler/pikku-command-scheduler.js +10 -0
- package/dist/src/inspector-glob.d.ts +1 -1
- package/dist/src/inspector-glob.js +4 -4
- package/dist/src/pikku-cli-config.d.ts +12 -2
- package/dist/src/pikku-cli-config.js +79 -30
- package/dist/src/pikku-command-schemas.d.ts +2 -0
- package/dist/src/pikku-command-schemas.js +8 -0
- package/dist/src/runtimes/nextjs/pikku-command-nextjs.d.ts +2 -0
- package/dist/src/runtimes/nextjs/pikku-command-nextjs.js +36 -0
- package/dist/src/schema-generator.d.ts +3 -2
- package/dist/src/schema-generator.js +9 -9
- package/dist/src/schemas.d.ts +2 -0
- package/dist/src/schemas.js +8 -0
- package/dist/src/{utils/serialize-import-map.js → serialize-import-map.js} +3 -0
- package/dist/src/serialize-pikku-types.js +378 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/src/types.js +1 -0
- package/dist/src/{utils/utils.d.ts → utils.d.ts} +20 -7
- package/dist/src/{utils/utils.js → utils.js} +56 -32
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/{bin → src/events/channels}/pikku-channels.ts +8 -3
- package/src/events/channels/pikku-command-channels-map.ts +26 -0
- package/src/events/channels/pikku-command-channels.ts +38 -0
- package/src/events/channels/pikku-command-websocket-typed.ts +36 -0
- package/src/{serialize-typed-channel-map.ts → events/channels/serialize-typed-channel-map.ts} +2 -2
- package/src/events/fetch/index.ts +33 -0
- package/src/events/functions/pikku-command-function-types.ts +48 -0
- package/src/events/functions/pikku-command-functions.ts +84 -0
- package/src/events/functions/pikku-command-services.ts +125 -0
- package/{bin → src/events/functions}/pikku-function-types.ts +12 -15
- package/{bin → src/events/functions}/pikku-functions.ts +9 -6
- package/src/events/http/pikku-command-http-map.ts +27 -0
- package/src/events/http/pikku-command-http-routes.ts +40 -0
- package/src/events/http/pikku-command-openapi.ts +54 -0
- package/{bin → src/events/http}/pikku-http-routes.ts +8 -3
- package/src/{serialize-typed-http-map.ts → events/http/serialize-typed-http-map.ts} +2 -19
- package/src/events/mcp/pikku-command-mcp-json.ts +33 -0
- package/src/events/mcp/pikku-command-mcp.ts +110 -0
- package/src/events/mcp/serialize-mcp-json.ts +159 -0
- package/src/events/queue/pikku-command-queue-map.ts +26 -0
- package/src/events/queue/pikku-command-queue-service.ts +33 -0
- package/src/events/queue/pikku-command-queue.ts +42 -0
- package/src/events/queue/pikku-queue-map.ts +26 -0
- package/src/events/queue/pikku-queue.ts +40 -0
- package/src/events/queue/serialize-queue-map.ts +119 -0
- package/src/events/queue/serialize-queue-meta.ts +10 -0
- package/src/events/queue/serialize-queue-wrapper.ts +35 -0
- package/src/events/rpc/pikku-command-rpc-client.ts +33 -0
- package/src/events/rpc/pikku-command-rpc-map.ts +26 -0
- package/src/events/rpc/pikku-command-rpc.ts +22 -0
- package/{bin → src/events/rpc}/pikku-rpc.ts +8 -6
- package/src/events/rpc/serialize-rpc-wrapper.ts +29 -0
- package/src/{serialize-typed-rpc-map.ts → events/rpc/serialize-typed-rpc-map.ts} +5 -4
- package/{bin/pikku-scheduler.ts → src/events/scheduler/pikku-command-scheduler.ts} +11 -8
- package/src/inspector-glob.ts +4 -2
- package/src/pikku-cli-config.ts +119 -42
- package/src/pikku-command-schemas.ts +33 -0
- package/src/runtimes/nextjs/pikku-command-nextjs.ts +110 -0
- package/src/schema-generator.ts +10 -5
- package/src/schemas.ts +33 -0
- package/src/{utils/serialize-import-map.ts → serialize-import-map.ts} +5 -0
- package/src/serialize-pikku-types.ts +378 -1
- package/src/types.ts +16 -0
- package/src/{utils/utils.ts → utils.ts} +68 -34
- package/tsconfig.json +1 -1
- package/bin/pikku-channels-map.ts +0 -25
- package/bin/pikku-http-map.ts +0 -26
- package/bin/pikku-nextjs.test.ts +0 -279
- package/bin/pikku-rpc-map.ts +0 -25
- package/dist/bin/pikku-channels-map.d.ts +0 -3
- package/dist/bin/pikku-channels-map.js +0 -8
- package/dist/bin/pikku-channels.d.ts +0 -3
- package/dist/bin/pikku-channels.js +0 -9
- package/dist/bin/pikku-function-types.d.ts +0 -4
- package/dist/bin/pikku-functions.d.ts +0 -7
- package/dist/bin/pikku-http-map.d.ts +0 -3
- package/dist/bin/pikku-http-map.js +0 -8
- package/dist/bin/pikku-http-routes.d.ts +0 -3
- package/dist/bin/pikku-http-routes.js +0 -9
- package/dist/bin/pikku-rpc-map.d.ts +0 -3
- package/dist/bin/pikku-rpc-map.js +0 -8
- package/dist/bin/pikku-rpc.d.ts +0 -3
- package/dist/bin/pikku-rpc.js +0 -6
- package/dist/bin/pikku-scheduler.d.ts +0 -3
- package/dist/bin/pikku-scheduler.js +0 -10
- /package/dist/src/{serialize-typed-channel-map.d.ts → events/channels/serialize-typed-channel-map.d.ts} +0 -0
- /package/dist/src/{serialize-websocket-wrapper.d.ts → events/channels/serialize-websocket-wrapper.d.ts} +0 -0
- /package/dist/src/{serialize-websocket-wrapper.js → events/channels/serialize-websocket-wrapper.js} +0 -0
- /package/dist/src/{openapi-spec-generator.d.ts → events/http/openapi-spec-generator.d.ts} +0 -0
- /package/dist/src/{openapi-spec-generator.js → events/http/openapi-spec-generator.js} +0 -0
- /package/dist/src/{serialize-fetch-wrapper.d.ts → events/http/serialize-fetch-wrapper.d.ts} +0 -0
- /package/dist/src/{serialize-fetch-wrapper.js → events/http/serialize-fetch-wrapper.js} +0 -0
- /package/dist/src/{serialize-scheduler-meta.d.ts → events/scheduler/serialize-scheduler-meta.d.ts} +0 -0
- /package/dist/src/{serialize-scheduler-meta.js → events/scheduler/serialize-scheduler-meta.js} +0 -0
- /package/dist/src/{serialize-nextjs-backend-wrapper.d.ts → runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts} +0 -0
- /package/dist/src/{serialize-nextjs-backend-wrapper.js → runtimes/nextjs/serialize-nextjs-backend-wrapper.js} +0 -0
- /package/dist/src/{serialize-nextjs-http-wrapper.d.ts → runtimes/nextjs/serialize-nextjs-http-wrapper.d.ts} +0 -0
- /package/dist/src/{serialize-nextjs-http-wrapper.js → runtimes/nextjs/serialize-nextjs-http-wrapper.js} +0 -0
- /package/dist/src/{utils/serialize-import-map.d.ts → serialize-import-map.d.ts} +0 -0
- /package/src/{serialize-websocket-wrapper.ts → events/channels/serialize-websocket-wrapper.ts} +0 -0
- /package/src/{openapi-spec-generator.ts → events/http/openapi-spec-generator.ts} +0 -0
- /package/src/{serialize-fetch-wrapper.ts → events/http/serialize-fetch-wrapper.ts} +0 -0
- /package/src/{serialize-scheduler-meta.ts → events/scheduler/serialize-scheduler-meta.ts} +0 -0
- /package/src/{serialize-nextjs-backend-wrapper.ts → runtimes/nextjs/serialize-nextjs-backend-wrapper.ts} +0 -0
- /package/src/{serialize-nextjs-http-wrapper.ts → runtimes/nextjs/serialize-nextjs-http-wrapper.ts} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { generateSchemas, saveSchemas } from './schema-generator.js'
|
|
2
|
+
import { logCommandInfoAndTime } from './utils.js'
|
|
3
|
+
import { PikkuCommand } from './types.js'
|
|
4
|
+
|
|
5
|
+
export const pikkuSchemas: PikkuCommand = async (
|
|
6
|
+
logger,
|
|
7
|
+
{ tsconfig, schemaDirectory, supportsImportAttributes },
|
|
8
|
+
{ functions, http }
|
|
9
|
+
) => {
|
|
10
|
+
return await logCommandInfoAndTime(
|
|
11
|
+
logger,
|
|
12
|
+
'Creating schemas',
|
|
13
|
+
'Created schemas',
|
|
14
|
+
[false],
|
|
15
|
+
async () => {
|
|
16
|
+
const schemas = await generateSchemas(
|
|
17
|
+
logger,
|
|
18
|
+
tsconfig,
|
|
19
|
+
functions.typesMap,
|
|
20
|
+
functions.meta,
|
|
21
|
+
http.meta
|
|
22
|
+
)
|
|
23
|
+
await saveSchemas(
|
|
24
|
+
logger,
|
|
25
|
+
schemaDirectory,
|
|
26
|
+
schemas,
|
|
27
|
+
functions.typesMap,
|
|
28
|
+
functions.meta,
|
|
29
|
+
supportsImportAttributes
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logCommandInfoAndTime,
|
|
3
|
+
getPikkuFilesAndMethods,
|
|
4
|
+
getFileImportRelativePath,
|
|
5
|
+
writeFileInDir,
|
|
6
|
+
} from '../../utils.js'
|
|
7
|
+
import { serializeNextJsBackendWrapper as serializeNextBackendWrapper } from './serialize-nextjs-backend-wrapper.js'
|
|
8
|
+
import { serializeNextJsHTTPWrapper as serializeNextHTTPWrapper } from './serialize-nextjs-http-wrapper.js'
|
|
9
|
+
import { PikkuCommand } from '../../types.js'
|
|
10
|
+
|
|
11
|
+
export const pikkuNext: PikkuCommand = async (
|
|
12
|
+
logger,
|
|
13
|
+
{
|
|
14
|
+
nextBackendFile,
|
|
15
|
+
nextHTTPFile,
|
|
16
|
+
httpRoutesMapDeclarationFile,
|
|
17
|
+
packageMappings,
|
|
18
|
+
fetchFile,
|
|
19
|
+
bootstrapFiles,
|
|
20
|
+
},
|
|
21
|
+
visitState,
|
|
22
|
+
options = {}
|
|
23
|
+
) => {
|
|
24
|
+
return await logCommandInfoAndTime(
|
|
25
|
+
logger,
|
|
26
|
+
'Generating nextjs wrapper',
|
|
27
|
+
'Generated nextjs wrapper',
|
|
28
|
+
[
|
|
29
|
+
nextBackendFile === undefined && nextHTTPFile === undefined,
|
|
30
|
+
'nextjs outfile is not defined',
|
|
31
|
+
],
|
|
32
|
+
async () => {
|
|
33
|
+
if (!nextBackendFile && !nextHTTPFile) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
'nextBackendFile or nextHTTPFile is required in pikku config for nextJS'
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (nextHTTPFile && !fetchFile) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'fetchFile is required in pikku config in order for nextJS http wrapper to work'
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (nextBackendFile) {
|
|
46
|
+
const {
|
|
47
|
+
pikkuConfigFactory,
|
|
48
|
+
singletonServicesFactory,
|
|
49
|
+
sessionServicesFactory,
|
|
50
|
+
} = await getPikkuFilesAndMethods(
|
|
51
|
+
logger,
|
|
52
|
+
visitState,
|
|
53
|
+
packageMappings,
|
|
54
|
+
nextBackendFile,
|
|
55
|
+
options,
|
|
56
|
+
{
|
|
57
|
+
config: true,
|
|
58
|
+
singletonServicesFactory: true,
|
|
59
|
+
sessionServicesFactory: true,
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
const pikkuConfigImport = `import { ${pikkuConfigFactory.variable} as createConfig } from '${getFileImportRelativePath(nextBackendFile, pikkuConfigFactory.file, packageMappings)}'`
|
|
64
|
+
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`
|
|
65
|
+
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`
|
|
66
|
+
|
|
67
|
+
const httpBootstrapPath = getFileImportRelativePath(
|
|
68
|
+
nextBackendFile,
|
|
69
|
+
bootstrapFiles.http,
|
|
70
|
+
packageMappings
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
74
|
+
nextBackendFile,
|
|
75
|
+
httpRoutesMapDeclarationFile,
|
|
76
|
+
packageMappings
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
const content = serializeNextBackendWrapper(
|
|
80
|
+
httpBootstrapPath,
|
|
81
|
+
routesMapDeclarationPath,
|
|
82
|
+
pikkuConfigImport,
|
|
83
|
+
singletonServicesImport,
|
|
84
|
+
sessionServicesImport
|
|
85
|
+
)
|
|
86
|
+
await writeFileInDir(logger, nextBackendFile, content)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (nextHTTPFile && fetchFile) {
|
|
90
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
91
|
+
nextHTTPFile,
|
|
92
|
+
httpRoutesMapDeclarationFile,
|
|
93
|
+
packageMappings
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const fetchPath = getFileImportRelativePath(
|
|
97
|
+
nextHTTPFile,
|
|
98
|
+
fetchFile,
|
|
99
|
+
packageMappings
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
const content = serializeNextHTTPWrapper(
|
|
103
|
+
routesMapDeclarationPath,
|
|
104
|
+
fetchPath
|
|
105
|
+
)
|
|
106
|
+
await writeFileInDir(logger, nextHTTPFile, content)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
package/src/schema-generator.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createGenerator, RootlessError } from 'ts-json-schema-generator'
|
|
2
|
-
import {
|
|
2
|
+
import { CLILogger, writeFileInDir } from './utils.js'
|
|
3
3
|
import { mkdir, writeFile } from 'fs/promises'
|
|
4
4
|
import { FunctionsMeta, JSONValue } from '@pikku/core'
|
|
5
5
|
import { HTTPRoutesMeta } from '@pikku/core/http'
|
|
6
6
|
import { TypesMap } from '@pikku/inspector'
|
|
7
7
|
|
|
8
8
|
export async function generateSchemas(
|
|
9
|
+
logger: CLILogger,
|
|
9
10
|
tsconfig: string,
|
|
10
11
|
typesMap: TypesMap,
|
|
11
12
|
functionMeta: FunctionsMeta,
|
|
@@ -52,10 +53,10 @@ export async function generateSchemas(
|
|
|
52
53
|
} catch (e) {
|
|
53
54
|
// Ignore rootless errors
|
|
54
55
|
if (e instanceof RootlessError) {
|
|
55
|
-
|
|
56
|
+
logger.error(`Error generating schema since it has no root: ${schema}`)
|
|
56
57
|
return
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
logger.error(`Error generating schema: ${schema}`)
|
|
59
60
|
}
|
|
60
61
|
})
|
|
61
62
|
|
|
@@ -63,6 +64,7 @@ export async function generateSchemas(
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
export async function saveSchemas(
|
|
67
|
+
logger: CLILogger,
|
|
66
68
|
schemaParentDir: string,
|
|
67
69
|
schemas: Record<string, JSONValue>,
|
|
68
70
|
typesMap: TypesMap,
|
|
@@ -70,6 +72,7 @@ export async function saveSchemas(
|
|
|
70
72
|
supportsImportAttributes: boolean
|
|
71
73
|
) {
|
|
72
74
|
await writeFileInDir(
|
|
75
|
+
logger,
|
|
73
76
|
`${schemaParentDir}/register.gen.ts`,
|
|
74
77
|
'export const empty = null;'
|
|
75
78
|
)
|
|
@@ -90,7 +93,7 @@ export async function saveSchemas(
|
|
|
90
93
|
])
|
|
91
94
|
|
|
92
95
|
if (desiredSchemas.size === 0) {
|
|
93
|
-
|
|
96
|
+
logger.info(`• Skipping schemas since none found.\x1b[0m`)
|
|
94
97
|
return
|
|
95
98
|
}
|
|
96
99
|
|
|
@@ -117,8 +120,10 @@ addSchema('${schema}', ${schema})
|
|
|
117
120
|
.join('\n')
|
|
118
121
|
|
|
119
122
|
await writeFileInDir(
|
|
123
|
+
logger,
|
|
120
124
|
`${schemaParentDir}/register.gen.ts`,
|
|
121
125
|
`import { addSchema } from '@pikku/core/schema'
|
|
122
|
-
${schemaImports}
|
|
126
|
+
${schemaImports}`,
|
|
127
|
+
{ logWrite: true }
|
|
123
128
|
)
|
|
124
129
|
}
|
package/src/schemas.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { saveSchemas, generateSchemas } from './schema-generator.js'
|
|
2
|
+
import { logCommandInfoAndTime } from './utils.js'
|
|
3
|
+
import { PikkuCommand } from './types.js'
|
|
4
|
+
|
|
5
|
+
export const pikkuSchemas: PikkuCommand = async (
|
|
6
|
+
logger,
|
|
7
|
+
{ tsconfig, schemaDirectory, supportsImportAttributes },
|
|
8
|
+
{ functions, http }
|
|
9
|
+
) => {
|
|
10
|
+
return await logCommandInfoAndTime(
|
|
11
|
+
logger,
|
|
12
|
+
'Creating schemas',
|
|
13
|
+
'Created schemas',
|
|
14
|
+
[false],
|
|
15
|
+
async () => {
|
|
16
|
+
const schemas = await generateSchemas(
|
|
17
|
+
logger,
|
|
18
|
+
tsconfig,
|
|
19
|
+
functions.typesMap,
|
|
20
|
+
functions.meta,
|
|
21
|
+
http.meta
|
|
22
|
+
)
|
|
23
|
+
await saveSchemas(
|
|
24
|
+
logger,
|
|
25
|
+
schemaDirectory,
|
|
26
|
+
schemas,
|
|
27
|
+
functions.typesMap,
|
|
28
|
+
functions.meta,
|
|
29
|
+
supportsImportAttributes
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
}
|