@pikku/cli 0.7.7 → 0.8.0
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 +14 -0
- package/bin/pikku-all.ts +87 -48
- package/bin/pikku-fetch.ts +5 -37
- package/bin/pikku-nextjs.ts +7 -112
- package/bin/pikku-openapi.ts +6 -53
- package/bin/pikku-queue-service.ts +24 -0
- package/bin/pikku-schemas.ts +6 -32
- package/bin/pikku-websocket.ts +6 -40
- package/bin/pikku.ts +2 -0
- package/dist/bin/pikku-all.d.ts +1 -1
- package/dist/bin/pikku-all.js +68 -48
- package/dist/bin/pikku-fetch.d.ts +1 -3
- package/dist/bin/pikku-fetch.js +4 -14
- package/dist/bin/pikku-nextjs.d.ts +1 -4
- package/dist/bin/pikku-nextjs.js +5 -39
- package/dist/bin/pikku-openapi.d.ts +0 -3
- package/dist/bin/pikku-openapi.js +5 -23
- package/dist/bin/pikku-queue-service.d.ts +4 -0
- package/dist/bin/pikku-queue-service.js +15 -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 +4 -17
- 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-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-nextjs.d.ts +2 -0
- package/dist/src/events/http/pikku-command-nextjs.js +36 -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.js → events/http/serialize-typed-http-map.js} +1 -1
- 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-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/{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} +2 -2
- 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 +3 -3
- package/dist/src/pikku-cli-config.d.ts +8 -1
- package/dist/src/pikku-cli-config.js +59 -22
- 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 +7 -7
- 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} +17 -7
- package/dist/src/{utils/utils.js → utils.js} +47 -29
- 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/{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-nextjs.ts +111 -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} +1 -1
- 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-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/{serialize-typed-rpc-map.ts → events/rpc/serialize-typed-rpc-map.ts} +4 -3
- package/{bin/pikku-scheduler.ts → src/events/scheduler/pikku-command-scheduler.ts} +11 -8
- package/src/inspector-glob.ts +3 -1
- package/src/pikku-cli-config.ts +93 -32
- package/src/pikku-command-schemas.ts +33 -0
- package/src/runtimes/nextjs/pikku-command-nextjs.ts +110 -0
- package/src/schema-generator.ts +8 -3
- 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} +55 -31
- 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-typed-http-map.d.ts → events/http/serialize-typed-http-map.d.ts} +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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @pikku/cli
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Major Features
|
|
6
|
+
|
|
7
|
+
- **Model Context Protocol (MCP) Support**: Complete MCP implementation with automatic generation of MCP JSON specifications, resources, tools, and prompts
|
|
8
|
+
- **Queue System**: Added queue support
|
|
9
|
+
- **RPC (Remote Procedure Calls)**: Added typed RPC call generation with local and remote procedure support
|
|
10
|
+
- **Multiple Bootstrap Files**: Added support for generating different transport-specific bootstrap files
|
|
11
|
+
- **Service Destructuring Analysis**: Added service destructuring analysis for better code generation
|
|
12
|
+
- **Bootstrap Files**: Added support for generating transport-specific bootstrap files
|
|
13
|
+
- **Service Destructuring**: Added service destructuring analysis for better code organization
|
|
14
|
+
- **Error Handling**: Improved error handling for complex type generation
|
|
15
|
+
- **Performance**: Optimized code generation for large projects with multiple event types
|
|
16
|
+
|
|
3
17
|
## 0.7.7
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/bin/pikku-all.ts
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
2
|
import {
|
|
3
|
+
CLILogger,
|
|
3
4
|
getFileImportRelativePath,
|
|
4
|
-
logInfo,
|
|
5
|
-
logPikkuLogo,
|
|
6
5
|
PikkuCLIOptions,
|
|
7
6
|
writeFileInDir,
|
|
8
|
-
} from '../src/utils
|
|
7
|
+
} from '../src/utils.js'
|
|
9
8
|
import { getPikkuCLIConfig, PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
10
|
-
import { pikkuHTTP } from '
|
|
11
|
-
import { pikkuFunctionTypes } from '
|
|
12
|
-
import { pikkuHTTPMap } from '
|
|
9
|
+
import { pikkuHTTP } from '../src/events/http/pikku-command-http-routes.js'
|
|
10
|
+
import { pikkuFunctionTypes } from '../src/events/functions/pikku-command-function-types.js'
|
|
11
|
+
import { pikkuHTTPMap } from '../src/events/http/pikku-command-http-map.js'
|
|
13
12
|
import { existsSync } from 'fs'
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { pikkuChannels } from './pikku-channels.js'
|
|
17
|
-
import { pikkuNext } from './pikku-nextjs.js'
|
|
18
|
-
import { pikkuOpenAPI } from './pikku-openapi.js'
|
|
19
|
-
import { pikkuScheduler } from './pikku-scheduler.js'
|
|
20
|
-
import { pikkuSchemas } from './pikku-schemas.js'
|
|
21
|
-
import { pikkuWebSocket } from './pikku-websocket.js'
|
|
13
|
+
import { pikkuChannelsMap } from '../src/events/channels/pikku-command-channels-map.js'
|
|
14
|
+
import { pikkuChannels } from '../src/events/channels/pikku-command-channels.js'
|
|
22
15
|
import { inspectorGlob } from '../src/inspector-glob.js'
|
|
23
16
|
import chokidar from 'chokidar'
|
|
24
|
-
import { pikkuFunctions } from '
|
|
25
|
-
import { pikkuRPC } from '
|
|
26
|
-
import { pikkuRPCMap } from '
|
|
17
|
+
import { pikkuFunctions } from '../src/events/functions/pikku-command-functions.js'
|
|
18
|
+
import { pikkuRPC } from '../src/events/rpc/pikku-command-rpc.js'
|
|
19
|
+
import { pikkuRPCMap } from '../src/events/rpc/pikku-command-rpc-map.js'
|
|
27
20
|
import { PikkuEventTypes } from '@pikku/core'
|
|
21
|
+
import { pikkuQueue } from '../src/events/queue/pikku-command-queue.js'
|
|
22
|
+
import { pikkuQueueMap } from '../src/events/queue/pikku-command-queue-map.js'
|
|
23
|
+
import { pikkuFetch } from '../src/events/fetch/index.js'
|
|
24
|
+
import { pikkuWebSocketTyped } from '../src/events/channels/pikku-command-websocket-typed.js'
|
|
25
|
+
import { pikkuNext } from '../src/events/http/pikku-command-nextjs.js'
|
|
26
|
+
import { pikkuOpenAPI } from '../src/events/http/pikku-command-openapi.js'
|
|
27
|
+
import { pikkuMCP } from '../src/events/mcp/pikku-command-mcp.js'
|
|
28
|
+
import { pikkuQueueService } from '../src/events/queue/pikku-command-queue-service.js'
|
|
29
|
+
import { pikkuScheduler } from '../src/events/scheduler/pikku-command-scheduler.js'
|
|
30
|
+
import { pikkuSchemas } from '../src/schemas.js'
|
|
31
|
+
import { pikkuMCPJSON } from '../src/events/mcp/pikku-command-mcp-json.js'
|
|
28
32
|
|
|
29
|
-
const runAll = async (
|
|
33
|
+
const runAll = async (
|
|
34
|
+
logger: CLILogger,
|
|
35
|
+
cliConfig: PikkuCLIConfig,
|
|
36
|
+
options: PikkuCLIOptions
|
|
37
|
+
) => {
|
|
30
38
|
const boostrapImports: Partial<
|
|
31
39
|
Record<PikkuEventTypes, { meta: string[]; events: string[] }>
|
|
32
40
|
> & { all: { meta: string[]; events: string[] } } = {
|
|
@@ -38,11 +46,10 @@ const runAll = async (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
38
46
|
type: 'meta' | 'events' | 'other',
|
|
39
47
|
addTo?: PikkuEventTypes[]
|
|
40
48
|
) => {
|
|
41
|
-
const statement = `import '${getFileImportRelativePath(cliConfig.bootstrapFile, from, cliConfig.packageMappings)}'`
|
|
42
49
|
if (type === 'meta') {
|
|
43
|
-
boostrapImports.all.meta.push(
|
|
50
|
+
boostrapImports.all.meta.push(from)
|
|
44
51
|
} else {
|
|
45
|
-
boostrapImports.all.events.push(
|
|
52
|
+
boostrapImports.all.events.push(from)
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
for (const transport of Object.keys(PikkuEventTypes)) {
|
|
@@ -52,9 +59,9 @@ const runAll = async (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
52
59
|
events: [],
|
|
53
60
|
}
|
|
54
61
|
if (type === 'meta') {
|
|
55
|
-
boostrapImports[transport].meta.push(
|
|
62
|
+
boostrapImports[transport].meta.push(from)
|
|
56
63
|
} else {
|
|
57
|
-
boostrapImports[transport].events.push(
|
|
64
|
+
boostrapImports[transport].events.push(from)
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
}
|
|
@@ -62,6 +69,7 @@ const runAll = async (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
62
69
|
|
|
63
70
|
let typesDeclarationFileExists = true
|
|
64
71
|
let visitState = await inspectorGlob(
|
|
72
|
+
logger,
|
|
65
73
|
cliConfig.rootDir,
|
|
66
74
|
cliConfig.srcDirectories,
|
|
67
75
|
cliConfig.filters
|
|
@@ -70,80 +78,111 @@ const runAll = async (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
70
78
|
if (!existsSync(cliConfig.typesDeclarationFile)) {
|
|
71
79
|
typesDeclarationFileExists = false
|
|
72
80
|
}
|
|
73
|
-
await pikkuFunctionTypes(cliConfig,
|
|
81
|
+
await pikkuFunctionTypes(logger, cliConfig, visitState, options)
|
|
74
82
|
|
|
75
83
|
// This is needed since the addHTTPRoute function will add the routes to the visitState
|
|
76
84
|
if (!typesDeclarationFileExists) {
|
|
77
|
-
|
|
85
|
+
logger.info(`• Type file first created, inspecting again...\x1b[0m`)
|
|
78
86
|
visitState = await inspectorGlob(
|
|
87
|
+
logger,
|
|
79
88
|
cliConfig.rootDir,
|
|
80
89
|
cliConfig.srcDirectories,
|
|
81
90
|
cliConfig.filters
|
|
82
91
|
)
|
|
83
92
|
}
|
|
84
93
|
|
|
85
|
-
const functions = pikkuFunctions(cliConfig, visitState)
|
|
94
|
+
const functions = pikkuFunctions(logger, cliConfig, visitState)
|
|
86
95
|
if (!functions) {
|
|
87
|
-
|
|
96
|
+
logger.info(`• No functions found, skipping remaining steps...\x1b[0m`)
|
|
88
97
|
process.exit(1)
|
|
89
98
|
}
|
|
90
99
|
addImport(cliConfig.functionsMetaFile, 'meta')
|
|
91
100
|
addImport(cliConfig.functionsFile, 'events')
|
|
92
101
|
|
|
93
|
-
await pikkuRPC(cliConfig, visitState)
|
|
94
|
-
await pikkuRPCMap(cliConfig, visitState)
|
|
102
|
+
await pikkuRPC(logger, cliConfig, visitState)
|
|
103
|
+
await pikkuRPCMap(logger, cliConfig, visitState)
|
|
95
104
|
addImport(cliConfig.rpcMetaFile, 'meta', [PikkuEventTypes.rpc])
|
|
96
105
|
|
|
97
|
-
const schemas = await pikkuSchemas(cliConfig, visitState)
|
|
106
|
+
const schemas = await pikkuSchemas(logger, cliConfig, visitState)
|
|
98
107
|
if (schemas) {
|
|
99
108
|
addImport(`${cliConfig.schemaDirectory}/register.gen.ts`, 'other')
|
|
100
109
|
}
|
|
101
110
|
|
|
102
|
-
const http = await pikkuHTTP(cliConfig, visitState)
|
|
111
|
+
const http = await pikkuHTTP(logger, cliConfig, visitState)
|
|
103
112
|
if (http) {
|
|
104
|
-
await pikkuHTTPMap(cliConfig, visitState)
|
|
105
|
-
await pikkuFetch(cliConfig)
|
|
113
|
+
await pikkuHTTPMap(logger, cliConfig, visitState)
|
|
114
|
+
await pikkuFetch(logger, cliConfig)
|
|
106
115
|
addImport(cliConfig.httpRoutesMetaFile, 'meta', [PikkuEventTypes.http])
|
|
107
116
|
addImport(cliConfig.httpRoutesFile, 'events', [PikkuEventTypes.http])
|
|
108
117
|
}
|
|
109
118
|
|
|
110
|
-
const scheduled = await pikkuScheduler(cliConfig, visitState)
|
|
119
|
+
const scheduled = await pikkuScheduler(logger, cliConfig, visitState)
|
|
111
120
|
if (scheduled) {
|
|
112
121
|
addImport(cliConfig.schedulersMetaFile, 'meta', [PikkuEventTypes.scheduled])
|
|
113
122
|
addImport(cliConfig.schedulersFile, 'events', [PikkuEventTypes.scheduled])
|
|
114
123
|
}
|
|
115
124
|
|
|
116
|
-
const
|
|
125
|
+
const queues = await pikkuQueue(logger, cliConfig, visitState)
|
|
126
|
+
if (queues) {
|
|
127
|
+
await pikkuQueueMap(logger, cliConfig, visitState)
|
|
128
|
+
await pikkuQueueService(logger, cliConfig)
|
|
129
|
+
addImport(cliConfig.queueWorkersMetaFile, 'meta', [PikkuEventTypes.queue])
|
|
130
|
+
addImport(cliConfig.queueWorkersFile, 'events', [PikkuEventTypes.queue])
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const channels = await pikkuChannels(logger, cliConfig, visitState)
|
|
117
134
|
if (channels) {
|
|
118
|
-
await pikkuChannelsMap(cliConfig, visitState)
|
|
119
|
-
await
|
|
135
|
+
await pikkuChannelsMap(logger, cliConfig, visitState)
|
|
136
|
+
await pikkuWebSocketTyped(logger, cliConfig)
|
|
120
137
|
addImport(cliConfig.channelsMetaFile, 'meta', [PikkuEventTypes.channel])
|
|
121
138
|
addImport(cliConfig.channelsFile, 'events', [PikkuEventTypes.channel])
|
|
122
139
|
}
|
|
123
140
|
|
|
141
|
+
const mcp = await pikkuMCP(logger, cliConfig, visitState)
|
|
142
|
+
if (mcp) {
|
|
143
|
+
await pikkuMCPJSON(logger, cliConfig, visitState)
|
|
144
|
+
addImport(cliConfig.mcpEndpointsMetaFile, 'meta', [PikkuEventTypes.mcp])
|
|
145
|
+
addImport(cliConfig.mcpEndpointsFile, 'events', [PikkuEventTypes.mcp])
|
|
146
|
+
}
|
|
147
|
+
|
|
124
148
|
if (cliConfig.nextBackendFile || cliConfig.nextHTTPFile) {
|
|
125
|
-
await pikkuNext(cliConfig, visitState, options)
|
|
149
|
+
await pikkuNext(logger, cliConfig, visitState, options)
|
|
126
150
|
}
|
|
127
151
|
|
|
128
152
|
if (cliConfig.openAPI) {
|
|
129
|
-
|
|
153
|
+
logger.info(
|
|
154
|
+
`• OpenAPI requires a reinspection to pickup new generated types..`
|
|
155
|
+
)
|
|
130
156
|
visitState = await inspectorGlob(
|
|
157
|
+
logger,
|
|
131
158
|
cliConfig.rootDir,
|
|
132
159
|
cliConfig.srcDirectories,
|
|
133
160
|
cliConfig.filters
|
|
134
161
|
)
|
|
135
|
-
await pikkuOpenAPI(cliConfig, visitState)
|
|
162
|
+
await pikkuOpenAPI(logger, cliConfig, visitState)
|
|
136
163
|
}
|
|
137
164
|
|
|
138
165
|
for (const [type, { meta, events }] of Object.entries(boostrapImports)) {
|
|
166
|
+
const bootstrapFile =
|
|
167
|
+
type === 'all' ? cliConfig.bootstrapFile : cliConfig.bootstrapFiles[type]
|
|
139
168
|
await writeFileInDir(
|
|
140
|
-
|
|
141
|
-
|
|
169
|
+
logger,
|
|
170
|
+
bootstrapFile,
|
|
171
|
+
[...meta, ...events]
|
|
172
|
+
.map(
|
|
173
|
+
(to) =>
|
|
174
|
+
`import '${getFileImportRelativePath(bootstrapFile, to, cliConfig.packageMappings)}'`
|
|
175
|
+
)
|
|
176
|
+
.join('\n')
|
|
142
177
|
)
|
|
143
178
|
}
|
|
144
179
|
}
|
|
145
180
|
|
|
146
|
-
const watch = (
|
|
181
|
+
const watch = (
|
|
182
|
+
logger: CLILogger,
|
|
183
|
+
cliConfig: PikkuCLIConfig,
|
|
184
|
+
options: PikkuCLIOptions
|
|
185
|
+
) => {
|
|
147
186
|
const configWatcher = chokidar.watch(cliConfig.srcDirectories, {
|
|
148
187
|
ignoreInitial: true,
|
|
149
188
|
ignored: /.*\.gen\.tsx?/,
|
|
@@ -154,7 +193,7 @@ const watch = (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
154
193
|
const generatorWatcher = () => {
|
|
155
194
|
watcher.close()
|
|
156
195
|
|
|
157
|
-
|
|
196
|
+
logger.info(
|
|
158
197
|
`• Watching directories: \n - ${cliConfig.srcDirectories.join('\n - ')}`
|
|
159
198
|
)
|
|
160
199
|
watcher = chokidar.watch(cliConfig.srcDirectories, {
|
|
@@ -165,7 +204,7 @@ const watch = (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
165
204
|
watcher.on('ready', async () => {
|
|
166
205
|
const handle = async () => {
|
|
167
206
|
try {
|
|
168
|
-
await runAll(cliConfig, options)
|
|
207
|
+
await runAll(logger, cliConfig, options)
|
|
169
208
|
} catch (err) {
|
|
170
209
|
console.error(err)
|
|
171
210
|
console.info()
|
|
@@ -194,7 +233,7 @@ const watch = (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
194
233
|
}
|
|
195
234
|
|
|
196
235
|
export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
197
|
-
|
|
236
|
+
const logger = new CLILogger({ logLogo: true })
|
|
198
237
|
|
|
199
238
|
const cliConfig = await getPikkuCLIConfig(
|
|
200
239
|
options.config,
|
|
@@ -204,9 +243,9 @@ export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
|
204
243
|
)
|
|
205
244
|
|
|
206
245
|
if (options.watch) {
|
|
207
|
-
watch(cliConfig, options)
|
|
246
|
+
watch(logger, cliConfig, options)
|
|
208
247
|
} else {
|
|
209
|
-
await runAll(cliConfig, options)
|
|
248
|
+
await runAll(logger, cliConfig, options)
|
|
210
249
|
}
|
|
211
250
|
}
|
|
212
251
|
|
package/bin/pikku-fetch.ts
CHANGED
|
@@ -1,49 +1,17 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
|
-
import { getPikkuCLIConfig
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
getFileImportRelativePath,
|
|
6
|
-
logCommandInfoAndTime,
|
|
7
|
-
logPikkuLogo,
|
|
8
|
-
PikkuCLIOptions,
|
|
9
|
-
writeFileInDir,
|
|
10
|
-
} from '../src/utils/utils.js'
|
|
11
|
-
|
|
12
|
-
export const pikkuFetch = async ({
|
|
13
|
-
fetchFile,
|
|
14
|
-
httpRoutesMapDeclarationFile,
|
|
15
|
-
packageMappings,
|
|
16
|
-
}: PikkuCLIConfig) => {
|
|
17
|
-
await logCommandInfoAndTime(
|
|
18
|
-
'Generating fetch wrapper',
|
|
19
|
-
'Generated fetch wrapper',
|
|
20
|
-
[fetchFile === undefined, "fetchFile isn't set in the pikku config"],
|
|
21
|
-
async () => {
|
|
22
|
-
if (!fetchFile) {
|
|
23
|
-
throw new Error("fetchFile is isn't set in the pikku config")
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
27
|
-
fetchFile,
|
|
28
|
-
httpRoutesMapDeclarationFile,
|
|
29
|
-
packageMappings
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const content = [serializeFetchWrapper(routesMapDeclarationPath)]
|
|
33
|
-
await writeFileInDir(fetchFile, content.join('\n'))
|
|
34
|
-
}
|
|
35
|
-
)
|
|
36
|
-
}
|
|
2
|
+
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
3
|
+
import { pikkuFetch } from '../src/events/fetch/index.js'
|
|
4
|
+
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
37
5
|
|
|
38
6
|
export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
39
|
-
|
|
7
|
+
const logger = new CLILogger({ logLogo: true })
|
|
40
8
|
const cliConfig = await getPikkuCLIConfig(
|
|
41
9
|
options.config,
|
|
42
10
|
['rootDir', 'schemaDirectory', 'configDir', 'fetchFile'],
|
|
43
11
|
options.tags,
|
|
44
12
|
true
|
|
45
13
|
)
|
|
46
|
-
await pikkuFetch(cliConfig)
|
|
14
|
+
await pikkuFetch(logger, cliConfig)
|
|
47
15
|
}
|
|
48
16
|
|
|
49
17
|
export const fetch = (program: Command): void => {
|
package/bin/pikku-nextjs.ts
CHANGED
|
@@ -1,118 +1,12 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
getFileImportRelativePath,
|
|
6
|
-
getPikkuFilesAndMethods,
|
|
7
|
-
logCommandInfoAndTime,
|
|
8
|
-
logPikkuLogo,
|
|
9
|
-
PikkuCLIOptions,
|
|
10
|
-
writeFileInDir,
|
|
11
|
-
} from '../src/utils/utils.js'
|
|
12
|
-
import { getPikkuCLIConfig, PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
13
|
-
import { InspectorState } from '@pikku/inspector'
|
|
2
|
+
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
3
|
+
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
14
4
|
import { inspectorGlob } from '../src/inspector-glob.js'
|
|
15
|
-
|
|
16
|
-
export const pikkuNext = async (
|
|
17
|
-
{
|
|
18
|
-
nextBackendFile,
|
|
19
|
-
nextHTTPFile,
|
|
20
|
-
httpRoutesMapDeclarationFile,
|
|
21
|
-
packageMappings,
|
|
22
|
-
fetchFile,
|
|
23
|
-
bootstrapFiles,
|
|
24
|
-
}: PikkuCLIConfig,
|
|
25
|
-
visitState: InspectorState,
|
|
26
|
-
options: PikkuCLIOptions
|
|
27
|
-
) => {
|
|
28
|
-
return await logCommandInfoAndTime(
|
|
29
|
-
'Generating nextjs wrapper',
|
|
30
|
-
'Generated nextjs wrapper',
|
|
31
|
-
[
|
|
32
|
-
nextBackendFile === undefined && nextHTTPFile === undefined,
|
|
33
|
-
'nextjs outfile is not defined',
|
|
34
|
-
],
|
|
35
|
-
async () => {
|
|
36
|
-
if (!nextBackendFile && !nextHTTPFile) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
'nextBackendFile or nextHTTPFile is required in pikku config for nextJS'
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (nextHTTPFile && !fetchFile) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
'fetchFile is required in pikku config in order for nextJS http wrapper to work'
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (nextBackendFile) {
|
|
49
|
-
const {
|
|
50
|
-
pikkuConfigFactory,
|
|
51
|
-
singletonServicesFactory,
|
|
52
|
-
sessionServicesFactory,
|
|
53
|
-
} = await getPikkuFilesAndMethods(
|
|
54
|
-
visitState,
|
|
55
|
-
packageMappings,
|
|
56
|
-
nextBackendFile,
|
|
57
|
-
options,
|
|
58
|
-
{
|
|
59
|
-
config: true,
|
|
60
|
-
singletonServicesFactory: true,
|
|
61
|
-
sessionServicesFactory: true,
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
const pikkuConfigImport = `import { ${pikkuConfigFactory.variable} as createConfig } from '${getFileImportRelativePath(nextBackendFile, pikkuConfigFactory.file, packageMappings)}'`
|
|
66
|
-
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`
|
|
67
|
-
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`
|
|
68
|
-
|
|
69
|
-
const httpBootstrapPath = getFileImportRelativePath(
|
|
70
|
-
nextBackendFile,
|
|
71
|
-
bootstrapFiles.http,
|
|
72
|
-
packageMappings
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
76
|
-
nextBackendFile,
|
|
77
|
-
httpRoutesMapDeclarationFile,
|
|
78
|
-
packageMappings
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
const content = serializeNextBackendWrapper(
|
|
82
|
-
httpBootstrapPath,
|
|
83
|
-
routesMapDeclarationPath,
|
|
84
|
-
pikkuConfigImport,
|
|
85
|
-
singletonServicesImport,
|
|
86
|
-
sessionServicesImport
|
|
87
|
-
)
|
|
88
|
-
await writeFileInDir(nextBackendFile, content)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (nextHTTPFile && fetchFile) {
|
|
92
|
-
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
93
|
-
nextHTTPFile,
|
|
94
|
-
httpRoutesMapDeclarationFile,
|
|
95
|
-
packageMappings
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
const fetchPath = getFileImportRelativePath(
|
|
99
|
-
nextHTTPFile,
|
|
100
|
-
fetchFile,
|
|
101
|
-
packageMappings
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
const content = serializeNextHTTPWrapper(
|
|
105
|
-
routesMapDeclarationPath,
|
|
106
|
-
fetchPath
|
|
107
|
-
)
|
|
108
|
-
await writeFileInDir(nextHTTPFile, content)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
)
|
|
112
|
-
}
|
|
5
|
+
import { pikkuNext } from '../src/events/http/pikku-command-nextjs.js'
|
|
113
6
|
|
|
114
7
|
export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
115
|
-
|
|
8
|
+
const logger = new CLILogger({ logLogo: true })
|
|
9
|
+
|
|
116
10
|
const cliConfig = await getPikkuCLIConfig(
|
|
117
11
|
options.config,
|
|
118
12
|
['rootDir', 'schemaDirectory', 'configDir'],
|
|
@@ -120,11 +14,12 @@ export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
|
120
14
|
true
|
|
121
15
|
)
|
|
122
16
|
const visitState = await inspectorGlob(
|
|
17
|
+
logger,
|
|
123
18
|
cliConfig.rootDir,
|
|
124
19
|
cliConfig.srcDirectories,
|
|
125
20
|
cliConfig.filters
|
|
126
21
|
)
|
|
127
|
-
await pikkuNext(cliConfig, visitState, options)
|
|
22
|
+
await pikkuNext(logger, cliConfig, visitState, options)
|
|
128
23
|
}
|
|
129
24
|
|
|
130
25
|
export const nextjs = (program: Command): void => {
|
package/bin/pikku-openapi.ts
CHANGED
|
@@ -1,70 +1,23 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
logPikkuLogo,
|
|
5
|
-
PikkuCLIOptions,
|
|
6
|
-
writeFileInDir,
|
|
7
|
-
} from '../src/utils/utils.js'
|
|
8
|
-
import { generateSchemas } from '../src/schema-generator.js'
|
|
9
|
-
import { generateOpenAPISpec } from '../src/openapi-spec-generator.js'
|
|
10
|
-
import { getPikkuCLIConfig, PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
11
|
-
import { InspectorState } from '@pikku/inspector'
|
|
12
|
-
import { stringify } from 'yaml'
|
|
2
|
+
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
3
|
+
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
13
4
|
import { inspectorGlob } from '../src/inspector-glob.js'
|
|
14
|
-
|
|
15
|
-
export const pikkuOpenAPI = async (
|
|
16
|
-
{ tsconfig, openAPI }: PikkuCLIConfig,
|
|
17
|
-
{ http, functions }: InspectorState
|
|
18
|
-
) => {
|
|
19
|
-
await logCommandInfoAndTime(
|
|
20
|
-
'Creating OpenAPI spec',
|
|
21
|
-
'Created OpenAPI spec',
|
|
22
|
-
[openAPI?.outputFile === undefined, 'openAPI outfile is not defined'],
|
|
23
|
-
async () => {
|
|
24
|
-
if (!openAPI?.outputFile) {
|
|
25
|
-
throw new Error('openAPI is required')
|
|
26
|
-
}
|
|
27
|
-
const schemas = await generateSchemas(
|
|
28
|
-
tsconfig,
|
|
29
|
-
functions.typesMap,
|
|
30
|
-
functions.meta,
|
|
31
|
-
http.meta
|
|
32
|
-
)
|
|
33
|
-
const openAPISpec = await generateOpenAPISpec(
|
|
34
|
-
functions.meta,
|
|
35
|
-
http.meta,
|
|
36
|
-
schemas,
|
|
37
|
-
openAPI.additionalInfo
|
|
38
|
-
)
|
|
39
|
-
if (openAPI.outputFile.endsWith('.json')) {
|
|
40
|
-
await writeFileInDir(
|
|
41
|
-
openAPI.outputFile,
|
|
42
|
-
JSON.stringify(openAPISpec, null, 2),
|
|
43
|
-
true
|
|
44
|
-
)
|
|
45
|
-
} else if (
|
|
46
|
-
openAPI.outputFile.endsWith('.yaml') ||
|
|
47
|
-
openAPI.outputFile.endsWith('.yml')
|
|
48
|
-
) {
|
|
49
|
-
await writeFileInDir(openAPI.outputFile, stringify(openAPISpec), true)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
}
|
|
5
|
+
import { pikkuOpenAPI } from '../src/events/http/pikku-command-openapi.js'
|
|
54
6
|
|
|
55
7
|
async function action({ config, tags }: PikkuCLIOptions): Promise<void> {
|
|
56
|
-
|
|
8
|
+
const logger = new CLILogger({ logLogo: true })
|
|
57
9
|
const cliConfig = await getPikkuCLIConfig(
|
|
58
10
|
config,
|
|
59
11
|
['rootDir', 'httpRoutesFile', 'openAPI', 'schemaDirectory', 'tsconfig'],
|
|
60
12
|
tags
|
|
61
13
|
)
|
|
62
14
|
const visitState = await inspectorGlob(
|
|
15
|
+
logger,
|
|
63
16
|
cliConfig.rootDir,
|
|
64
17
|
cliConfig.srcDirectories,
|
|
65
18
|
cliConfig.filters
|
|
66
19
|
)
|
|
67
|
-
await pikkuOpenAPI(cliConfig, visitState)
|
|
20
|
+
await pikkuOpenAPI(logger, cliConfig, visitState)
|
|
68
21
|
}
|
|
69
22
|
|
|
70
23
|
export const openapi = (program: Command): void => {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
3
|
+
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
4
|
+
import { pikkuQueueService } from '../src/events/queue/pikku-command-queue-service.js'
|
|
5
|
+
|
|
6
|
+
export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
7
|
+
const logger = new CLILogger({ logLogo: true })
|
|
8
|
+
|
|
9
|
+
const cliConfig = await getPikkuCLIConfig(
|
|
10
|
+
options.config,
|
|
11
|
+
['rootDir', 'schemaDirectory', 'configDir', 'queueFile'],
|
|
12
|
+
options.tags,
|
|
13
|
+
true
|
|
14
|
+
)
|
|
15
|
+
await pikkuQueueService(logger, cliConfig)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const queue = (program: Command): void => {
|
|
19
|
+
program
|
|
20
|
+
.command('queue')
|
|
21
|
+
.description('generate queue service wrapper')
|
|
22
|
+
.option('-c | --config <string>', 'The path to pikku cli config file')
|
|
23
|
+
.action(action)
|
|
24
|
+
}
|
package/bin/pikku-schemas.ts
CHANGED
|
@@ -1,39 +1,12 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
|
-
import { saveSchemas, generateSchemas } from '../src/schema-generator.js'
|
|
3
2
|
|
|
4
|
-
import { getPikkuCLIConfig
|
|
5
|
-
import { InspectorState } from '@pikku/inspector'
|
|
6
|
-
import { logCommandInfoAndTime, logPikkuLogo } from '../src/utils/utils.js'
|
|
3
|
+
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
7
4
|
import { inspectorGlob } from '../src/inspector-glob.js'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{ tsconfig, schemaDirectory, supportsImportAttributes }: PikkuCLIConfig,
|
|
11
|
-
{ functions, http }: InspectorState
|
|
12
|
-
) => {
|
|
13
|
-
return await logCommandInfoAndTime(
|
|
14
|
-
'Creating schemas',
|
|
15
|
-
'Created schemas',
|
|
16
|
-
[false],
|
|
17
|
-
async () => {
|
|
18
|
-
const schemas = await generateSchemas(
|
|
19
|
-
tsconfig,
|
|
20
|
-
functions.typesMap,
|
|
21
|
-
functions.meta,
|
|
22
|
-
http.meta
|
|
23
|
-
)
|
|
24
|
-
await saveSchemas(
|
|
25
|
-
schemaDirectory,
|
|
26
|
-
schemas,
|
|
27
|
-
functions.typesMap,
|
|
28
|
-
functions.meta,
|
|
29
|
-
supportsImportAttributes
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
}
|
|
5
|
+
import { pikkuSchemas } from '../src/schemas.js'
|
|
6
|
+
import { CLILogger } from '../src/utils.js'
|
|
34
7
|
|
|
35
8
|
async function action({ config }: { config?: string }): Promise<void> {
|
|
36
|
-
|
|
9
|
+
const logger = new CLILogger({ logLogo: true })
|
|
37
10
|
|
|
38
11
|
const cliConfig = await getPikkuCLIConfig(config, [
|
|
39
12
|
'srcDirectories',
|
|
@@ -41,11 +14,12 @@ async function action({ config }: { config?: string }): Promise<void> {
|
|
|
41
14
|
'tsconfig',
|
|
42
15
|
])
|
|
43
16
|
const visitState = await inspectorGlob(
|
|
17
|
+
logger,
|
|
44
18
|
cliConfig.rootDir,
|
|
45
19
|
cliConfig.srcDirectories,
|
|
46
20
|
cliConfig.filters
|
|
47
21
|
)
|
|
48
|
-
await pikkuSchemas(cliConfig, visitState)
|
|
22
|
+
await pikkuSchemas(logger, cliConfig, visitState)
|
|
49
23
|
}
|
|
50
24
|
|
|
51
25
|
export const schemas = (program: Command): void => {
|