@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
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { PikkuCLIConfig } from '
|
|
1
|
+
import { PikkuCLIConfig } from '../../pikku-cli-config.js'
|
|
2
2
|
import { InspectorState } from '@pikku/inspector'
|
|
3
3
|
import {
|
|
4
4
|
logCommandInfoAndTime,
|
|
5
5
|
serializeFileImports,
|
|
6
6
|
writeFileInDir,
|
|
7
|
-
} from '
|
|
7
|
+
} from '../../utils.js'
|
|
8
|
+
import { PikkuCommand } from '../../types.js'
|
|
8
9
|
|
|
9
|
-
export const pikkuChannels = async (
|
|
10
|
+
export const pikkuChannels: PikkuCommand = async (
|
|
11
|
+
logger,
|
|
10
12
|
cliConfig: PikkuCLIConfig,
|
|
11
13
|
visitState: InspectorState
|
|
12
14
|
) => {
|
|
13
15
|
return await logCommandInfoAndTime(
|
|
16
|
+
logger,
|
|
14
17
|
'Finding Channels',
|
|
15
18
|
'Found channels',
|
|
16
19
|
[visitState.channels.files.size === 0],
|
|
@@ -18,6 +21,7 @@ export const pikkuChannels = async (
|
|
|
18
21
|
const { channelsFile, channelsMetaFile, packageMappings } = cliConfig
|
|
19
22
|
const { channels } = visitState
|
|
20
23
|
await writeFileInDir(
|
|
24
|
+
logger,
|
|
21
25
|
channelsFile,
|
|
22
26
|
serializeFileImports(
|
|
23
27
|
'addChannel',
|
|
@@ -27,6 +31,7 @@ export const pikkuChannels = async (
|
|
|
27
31
|
)
|
|
28
32
|
)
|
|
29
33
|
await writeFileInDir(
|
|
34
|
+
logger,
|
|
30
35
|
channelsMetaFile,
|
|
31
36
|
`import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`
|
|
32
37
|
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js'
|
|
2
|
+
import { serializeTypedChannelsMap } from './serialize-typed-channel-map.js'
|
|
3
|
+
import { PikkuCommand } from '../../types.js'
|
|
4
|
+
|
|
5
|
+
export const pikkuChannelsMap: PikkuCommand = async (
|
|
6
|
+
logger,
|
|
7
|
+
{ channelsMapDeclarationFile, packageMappings },
|
|
8
|
+
state
|
|
9
|
+
) => {
|
|
10
|
+
return await logCommandInfoAndTime(
|
|
11
|
+
logger,
|
|
12
|
+
'Creating channels map',
|
|
13
|
+
'Created channels map',
|
|
14
|
+
[state.channels.files.size === 0],
|
|
15
|
+
async () => {
|
|
16
|
+
const content = serializeTypedChannelsMap(
|
|
17
|
+
channelsMapDeclarationFile,
|
|
18
|
+
packageMappings,
|
|
19
|
+
state.functions.typesMap,
|
|
20
|
+
state.functions.meta,
|
|
21
|
+
state.channels.meta
|
|
22
|
+
)
|
|
23
|
+
await writeFileInDir(logger, channelsMapDeclarationFile, content)
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logCommandInfoAndTime,
|
|
3
|
+
serializeFileImports,
|
|
4
|
+
writeFileInDir,
|
|
5
|
+
} from '../../utils.js'
|
|
6
|
+
import { PikkuCommand } from '../../types.js'
|
|
7
|
+
|
|
8
|
+
export const pikkuChannels: PikkuCommand = async (
|
|
9
|
+
logger,
|
|
10
|
+
cliConfig,
|
|
11
|
+
visitState
|
|
12
|
+
) => {
|
|
13
|
+
return await logCommandInfoAndTime(
|
|
14
|
+
logger,
|
|
15
|
+
'Finding Channels',
|
|
16
|
+
'Found channels',
|
|
17
|
+
[visitState.channels.files.size === 0],
|
|
18
|
+
async () => {
|
|
19
|
+
const { channelsFile, channelsMetaFile, packageMappings } = cliConfig
|
|
20
|
+
const { channels } = visitState
|
|
21
|
+
await writeFileInDir(
|
|
22
|
+
logger,
|
|
23
|
+
channelsFile,
|
|
24
|
+
serializeFileImports(
|
|
25
|
+
'addChannel',
|
|
26
|
+
channelsFile,
|
|
27
|
+
channels.files,
|
|
28
|
+
packageMappings
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
await writeFileInDir(
|
|
32
|
+
logger,
|
|
33
|
+
channelsMetaFile,
|
|
34
|
+
`import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PikkuCommandWithoutState } from '../../types.js'
|
|
2
|
+
import {
|
|
3
|
+
logCommandInfoAndTime,
|
|
4
|
+
getFileImportRelativePath,
|
|
5
|
+
writeFileInDir,
|
|
6
|
+
} from '../../utils.js'
|
|
7
|
+
import { serializeWebsocketWrapper } from './serialize-websocket-wrapper.js'
|
|
8
|
+
|
|
9
|
+
export const pikkuWebSocketTyped: PikkuCommandWithoutState = async (
|
|
10
|
+
logger,
|
|
11
|
+
{ websocketFile, channelsMapDeclarationFile, packageMappings }
|
|
12
|
+
) => {
|
|
13
|
+
return await logCommandInfoAndTime(
|
|
14
|
+
logger,
|
|
15
|
+
'Generating websocket wrapper',
|
|
16
|
+
'Generated websocket wrapper',
|
|
17
|
+
[
|
|
18
|
+
websocketFile === undefined,
|
|
19
|
+
"websocketFile isn't set in the pikku config",
|
|
20
|
+
],
|
|
21
|
+
async () => {
|
|
22
|
+
if (!websocketFile) {
|
|
23
|
+
throw new Error("fetchFile is isn't set in the pikku config")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const channelsMapDeclarationPath = getFileImportRelativePath(
|
|
27
|
+
websocketFile,
|
|
28
|
+
channelsMapDeclarationFile,
|
|
29
|
+
packageMappings
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const content = [serializeWebsocketWrapper(channelsMapDeclarationPath)]
|
|
33
|
+
await writeFileInDir(logger, websocketFile, content.join('\n'))
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
}
|
package/src/{serialize-typed-channel-map.ts → events/channels/serialize-typed-channel-map.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChannelsMeta } from '@pikku/core/channel'
|
|
2
|
-
import { serializeImportMap } from '
|
|
2
|
+
import { serializeImportMap } from '../../serialize-import-map.js'
|
|
3
3
|
import { TypesMap } from '@pikku/inspector'
|
|
4
|
-
import { generateCustomTypes } from '
|
|
4
|
+
import { generateCustomTypes } from '../../utils.js'
|
|
5
5
|
import { FunctionsMeta } from '@pikku/core'
|
|
6
6
|
|
|
7
7
|
export const serializeTypedChannelsMap = (
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { serializeFetchWrapper } from '../http/serialize-fetch-wrapper.js'
|
|
2
|
+
import {
|
|
3
|
+
getFileImportRelativePath,
|
|
4
|
+
logCommandInfoAndTime,
|
|
5
|
+
writeFileInDir,
|
|
6
|
+
} from '../../utils.js'
|
|
7
|
+
import { PikkuCommandWithoutState } from '../../types.js'
|
|
8
|
+
|
|
9
|
+
export const pikkuFetch: PikkuCommandWithoutState = async (
|
|
10
|
+
logger,
|
|
11
|
+
{ fetchFile, httpRoutesMapDeclarationFile, packageMappings }
|
|
12
|
+
) => {
|
|
13
|
+
return await logCommandInfoAndTime(
|
|
14
|
+
logger,
|
|
15
|
+
'Generating fetch wrapper',
|
|
16
|
+
'Generated fetch wrapper',
|
|
17
|
+
[fetchFile === undefined, "fetchFile isn't set in the pikku config"],
|
|
18
|
+
async () => {
|
|
19
|
+
if (!fetchFile) {
|
|
20
|
+
throw new Error("fetchFile is isn't set in the pikku config")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
24
|
+
fetchFile,
|
|
25
|
+
httpRoutesMapDeclarationFile,
|
|
26
|
+
packageMappings
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const content = [serializeFetchWrapper(routesMapDeclarationPath)]
|
|
30
|
+
await writeFileInDir(logger, fetchFile, content.join('\n'))
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFileImportRelativePath,
|
|
3
|
+
getPikkuFilesAndMethods,
|
|
4
|
+
logCommandInfoAndTime,
|
|
5
|
+
writeFileInDir,
|
|
6
|
+
} from '../../utils.js'
|
|
7
|
+
import { serializePikkuTypes } from '../../serialize-pikku-types.js'
|
|
8
|
+
import { PikkuCommand } from '../../types.js'
|
|
9
|
+
|
|
10
|
+
export const pikkuFunctionTypes: PikkuCommand = async (
|
|
11
|
+
logger,
|
|
12
|
+
{ typesDeclarationFile: typesFile, packageMappings, rpcMapDeclarationFile },
|
|
13
|
+
visitState,
|
|
14
|
+
options = {}
|
|
15
|
+
) => {
|
|
16
|
+
return await logCommandInfoAndTime(
|
|
17
|
+
logger,
|
|
18
|
+
'Creating api types',
|
|
19
|
+
'Created api types',
|
|
20
|
+
[false],
|
|
21
|
+
async () => {
|
|
22
|
+
const { userSessionType, sessionServicesType, singletonServicesType } =
|
|
23
|
+
await getPikkuFilesAndMethods(
|
|
24
|
+
logger,
|
|
25
|
+
visitState,
|
|
26
|
+
packageMappings,
|
|
27
|
+
typesFile,
|
|
28
|
+
options,
|
|
29
|
+
{
|
|
30
|
+
userSessionType: true,
|
|
31
|
+
sessionServiceType: true,
|
|
32
|
+
singletonServicesType: true,
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const content = serializePikkuTypes(
|
|
37
|
+
`import type { ${userSessionType.type} } from '${getFileImportRelativePath(typesFile, userSessionType.typePath, packageMappings)}'`,
|
|
38
|
+
userSessionType.type,
|
|
39
|
+
`import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(typesFile, singletonServicesType.typePath, packageMappings)}'`,
|
|
40
|
+
singletonServicesType.type,
|
|
41
|
+
`import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(typesFile, sessionServicesType.typePath, packageMappings)}'`,
|
|
42
|
+
`import type { TypedPikkuRPC } from '${getFileImportRelativePath(typesFile, rpcMapDeclarationFile, packageMappings)}'`
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
await writeFileInDir(logger, typesFile, content)
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFileImportRelativePath,
|
|
3
|
+
logCommandInfoAndTime,
|
|
4
|
+
writeFileInDir,
|
|
5
|
+
} from '../../utils.js'
|
|
6
|
+
import { PikkuCommand } from '../../types.js'
|
|
7
|
+
|
|
8
|
+
export const serializeFunctionImports = (
|
|
9
|
+
outputPath: string,
|
|
10
|
+
functionsMap: Map<string, { path: string; exportedName: string }>,
|
|
11
|
+
packageMappings: Record<string, string> = {}
|
|
12
|
+
) => {
|
|
13
|
+
const serializedImports: string[] = [
|
|
14
|
+
`/* Import and register RPCs */`,
|
|
15
|
+
`import { addFunction } from '@pikku/core'`,
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
const serializedRegistrations: string[] = []
|
|
19
|
+
|
|
20
|
+
// Sort by function name for consistent output
|
|
21
|
+
const sortedEntries = Array.from(functionsMap.entries()).sort((a, b) =>
|
|
22
|
+
a[0].localeCompare(b[0])
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
for (const [name, { path, exportedName }] of sortedEntries) {
|
|
26
|
+
const filePath = getFileImportRelativePath(
|
|
27
|
+
outputPath,
|
|
28
|
+
path,
|
|
29
|
+
packageMappings
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
// For directly exported functions, we can just import and register them
|
|
33
|
+
if (name === exportedName) {
|
|
34
|
+
serializedImports.push(`import { ${exportedName} } from '${filePath}'`)
|
|
35
|
+
serializedRegistrations.push(
|
|
36
|
+
`addFunction('${name}', { func: ${exportedName} })`
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
// For renamed functions, we need to import and alias them
|
|
40
|
+
else {
|
|
41
|
+
serializedImports.push(
|
|
42
|
+
`import { ${exportedName} as ${name} } from '${filePath}'`
|
|
43
|
+
)
|
|
44
|
+
serializedRegistrations.push(`addFunction('${name}', ${name})`)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Add a blank line between imports and registrations
|
|
49
|
+
if (serializedImports.length > 0 && serializedRegistrations.length > 0) {
|
|
50
|
+
serializedImports.push('')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Combine the imports and registrations
|
|
54
|
+
return [...serializedImports, ...serializedRegistrations].join('\n')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const pikkuFunctions: PikkuCommand = async (
|
|
58
|
+
logger,
|
|
59
|
+
{ functionsMetaFile, functionsFile, packageMappings },
|
|
60
|
+
{ functions }
|
|
61
|
+
) => {
|
|
62
|
+
return await logCommandInfoAndTime(
|
|
63
|
+
logger,
|
|
64
|
+
'Serializing Pikku functions',
|
|
65
|
+
'Serialized Pikku functions',
|
|
66
|
+
[false],
|
|
67
|
+
async () => {
|
|
68
|
+
await writeFileInDir(
|
|
69
|
+
logger,
|
|
70
|
+
functionsFile,
|
|
71
|
+
serializeFunctionImports(
|
|
72
|
+
functionsFile,
|
|
73
|
+
functions.files,
|
|
74
|
+
packageMappings
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
await writeFileInDir(
|
|
78
|
+
logger,
|
|
79
|
+
functionsMetaFile,
|
|
80
|
+
`import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
}
|
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import { PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
2
|
-
import { InspectorState } from '@pikku/inspector'
|
|
3
1
|
import {
|
|
4
2
|
getFileImportRelativePath,
|
|
5
3
|
getPikkuFilesAndMethods,
|
|
6
4
|
logCommandInfoAndTime,
|
|
7
|
-
PikkuCLIOptions,
|
|
8
5
|
writeFileInDir,
|
|
9
|
-
} from '
|
|
10
|
-
import { serializePikkuTypes } from '
|
|
6
|
+
} from '../../utils.js'
|
|
7
|
+
import { serializePikkuTypes } from '../../serialize-pikku-types.js'
|
|
8
|
+
import { PikkuCommand } from '../../types.js'
|
|
11
9
|
|
|
12
|
-
export const pikkuFunctionTypes = async (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}: PikkuCLIConfig,
|
|
18
|
-
options: PikkuCLIOptions,
|
|
19
|
-
visitState: InspectorState
|
|
10
|
+
export const pikkuFunctionTypes: PikkuCommand = async (
|
|
11
|
+
logger,
|
|
12
|
+
{ typesDeclarationFile: typesFile, packageMappings, rpcMapDeclarationFile },
|
|
13
|
+
visitState,
|
|
14
|
+
options = {}
|
|
20
15
|
) => {
|
|
21
|
-
await logCommandInfoAndTime(
|
|
16
|
+
return await logCommandInfoAndTime(
|
|
17
|
+
logger,
|
|
22
18
|
'Creating api types',
|
|
23
19
|
'Created api types',
|
|
24
20
|
[false],
|
|
25
21
|
async () => {
|
|
26
22
|
const { userSessionType, sessionServicesType, singletonServicesType } =
|
|
27
23
|
await getPikkuFilesAndMethods(
|
|
24
|
+
logger,
|
|
28
25
|
visitState,
|
|
29
26
|
packageMappings,
|
|
30
27
|
typesFile,
|
|
@@ -44,7 +41,7 @@ export const pikkuFunctionTypes = async (
|
|
|
44
41
|
`import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(typesFile, sessionServicesType.typePath, packageMappings)}'`,
|
|
45
42
|
`import type { TypedPikkuRPC } from '${getFileImportRelativePath(typesFile, rpcMapDeclarationFile, packageMappings)}'`
|
|
46
43
|
)
|
|
47
|
-
await writeFileInDir(typesFile, content)
|
|
44
|
+
await writeFileInDir(logger, typesFile, content)
|
|
48
45
|
}
|
|
49
46
|
)
|
|
50
47
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
2
|
-
import { InspectorState } from '@pikku/inspector'
|
|
3
1
|
import {
|
|
4
2
|
getFileImportRelativePath,
|
|
5
3
|
logCommandInfoAndTime,
|
|
6
4
|
writeFileInDir,
|
|
7
|
-
} from '
|
|
5
|
+
} from '../../utils.js'
|
|
6
|
+
import { PikkuCommand } from '../../types.js'
|
|
8
7
|
|
|
9
8
|
export const serializeFunctionImports = (
|
|
10
9
|
outputPath: string,
|
|
@@ -55,16 +54,19 @@ export const serializeFunctionImports = (
|
|
|
55
54
|
return [...serializedImports, ...serializedRegistrations].join('\n')
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
export const pikkuFunctions = async (
|
|
59
|
-
|
|
60
|
-
{
|
|
57
|
+
export const pikkuFunctions: PikkuCommand = async (
|
|
58
|
+
logger,
|
|
59
|
+
{ functionsMetaFile, functionsFile, packageMappings },
|
|
60
|
+
{ functions }
|
|
61
61
|
) => {
|
|
62
62
|
return await logCommandInfoAndTime(
|
|
63
|
+
logger,
|
|
63
64
|
'Serializing Pikku functions',
|
|
64
65
|
'Serialized Pikku functions',
|
|
65
66
|
[false],
|
|
66
67
|
async () => {
|
|
67
68
|
await writeFileInDir(
|
|
69
|
+
logger,
|
|
68
70
|
functionsFile,
|
|
69
71
|
serializeFunctionImports(
|
|
70
72
|
functionsFile,
|
|
@@ -73,6 +75,7 @@ export const pikkuFunctions = async (
|
|
|
73
75
|
)
|
|
74
76
|
)
|
|
75
77
|
await writeFileInDir(
|
|
78
|
+
logger,
|
|
76
79
|
functionsMetaFile,
|
|
77
80
|
`import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`
|
|
78
81
|
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js'
|
|
2
|
+
import { serializeTypedRoutesMap } from './serialize-typed-http-map.js'
|
|
3
|
+
import { PikkuCommand } from '../../types.js'
|
|
4
|
+
|
|
5
|
+
export const pikkuHTTPMap: PikkuCommand = async (
|
|
6
|
+
logger,
|
|
7
|
+
{ httpRoutesMapDeclarationFile, packageMappings },
|
|
8
|
+
{ http, functions }
|
|
9
|
+
) => {
|
|
10
|
+
return await logCommandInfoAndTime(
|
|
11
|
+
logger,
|
|
12
|
+
'Creating HTTP map',
|
|
13
|
+
'Created HTTP map',
|
|
14
|
+
[http.files.size === 0],
|
|
15
|
+
async () => {
|
|
16
|
+
const content = serializeTypedRoutesMap(
|
|
17
|
+
httpRoutesMapDeclarationFile,
|
|
18
|
+
packageMappings,
|
|
19
|
+
functions.typesMap,
|
|
20
|
+
functions.meta,
|
|
21
|
+
http.meta,
|
|
22
|
+
http.metaInputTypes
|
|
23
|
+
)
|
|
24
|
+
await writeFileInDir(logger, httpRoutesMapDeclarationFile, content)
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PikkuCLIConfig } from '../../pikku-cli-config.js'
|
|
2
|
+
import { InspectorState } from '@pikku/inspector'
|
|
3
|
+
import {
|
|
4
|
+
logCommandInfoAndTime,
|
|
5
|
+
serializeFileImports,
|
|
6
|
+
writeFileInDir,
|
|
7
|
+
} from '../../utils.js'
|
|
8
|
+
import { PikkuCommand } from '../../types.js'
|
|
9
|
+
|
|
10
|
+
export const pikkuHTTP: PikkuCommand = async (
|
|
11
|
+
logger,
|
|
12
|
+
cliConfig: PikkuCLIConfig,
|
|
13
|
+
visitState: InspectorState
|
|
14
|
+
) => {
|
|
15
|
+
return await logCommandInfoAndTime(
|
|
16
|
+
logger,
|
|
17
|
+
'Finding HTTP routes',
|
|
18
|
+
'Found HTTP routes',
|
|
19
|
+
[visitState.http.files.size === 0],
|
|
20
|
+
async () => {
|
|
21
|
+
const { httpRoutesFile, httpRoutesMetaFile, packageMappings } = cliConfig
|
|
22
|
+
const { http } = visitState
|
|
23
|
+
await writeFileInDir(
|
|
24
|
+
logger,
|
|
25
|
+
httpRoutesFile,
|
|
26
|
+
serializeFileImports(
|
|
27
|
+
'addHTTPRoute',
|
|
28
|
+
httpRoutesFile,
|
|
29
|
+
http.files,
|
|
30
|
+
packageMappings
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
await writeFileInDir(
|
|
34
|
+
logger,
|
|
35
|
+
httpRoutesMetaFile,
|
|
36
|
+
`import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { PikkuCLIConfig } from '../../pikku-cli-config.js'
|
|
2
|
+
import { serializeNextJsBackendWrapper as serializeNextBackendWrapper } from '../../runtimes/nextjs/serialize-nextjs-backend-wrapper.js'
|
|
3
|
+
import { serializeNextJsHTTPWrapper as serializeNextHTTPWrapper } from '../../runtimes/nextjs/serialize-nextjs-http-wrapper.js'
|
|
4
|
+
import {
|
|
5
|
+
getFileImportRelativePath,
|
|
6
|
+
getPikkuFilesAndMethods,
|
|
7
|
+
logCommandInfoAndTime,
|
|
8
|
+
writeFileInDir,
|
|
9
|
+
} from '../../utils.js'
|
|
10
|
+
import { PikkuCommand } from '../../types.js'
|
|
11
|
+
|
|
12
|
+
export const pikkuNext: PikkuCommand = async (
|
|
13
|
+
logger,
|
|
14
|
+
{
|
|
15
|
+
nextBackendFile,
|
|
16
|
+
nextHTTPFile,
|
|
17
|
+
httpRoutesMapDeclarationFile,
|
|
18
|
+
packageMappings,
|
|
19
|
+
fetchFile,
|
|
20
|
+
bootstrapFiles,
|
|
21
|
+
}: PikkuCLIConfig,
|
|
22
|
+
visitState,
|
|
23
|
+
options = {}
|
|
24
|
+
) => {
|
|
25
|
+
return await logCommandInfoAndTime(
|
|
26
|
+
logger,
|
|
27
|
+
'Generating nextjs wrapper',
|
|
28
|
+
'Generated nextjs wrapper',
|
|
29
|
+
[
|
|
30
|
+
nextBackendFile === undefined && nextHTTPFile === undefined,
|
|
31
|
+
'nextjs outfile is not defined',
|
|
32
|
+
],
|
|
33
|
+
async () => {
|
|
34
|
+
if (!nextBackendFile && !nextHTTPFile) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
'nextBackendFile or nextHTTPFile is required in pikku config for nextJS'
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (nextHTTPFile && !fetchFile) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
'fetchFile is required in pikku config in order for nextJS http wrapper to work'
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (nextBackendFile) {
|
|
47
|
+
const {
|
|
48
|
+
pikkuConfigFactory,
|
|
49
|
+
singletonServicesFactory,
|
|
50
|
+
sessionServicesFactory,
|
|
51
|
+
} = await getPikkuFilesAndMethods(
|
|
52
|
+
logger,
|
|
53
|
+
visitState,
|
|
54
|
+
packageMappings,
|
|
55
|
+
nextBackendFile,
|
|
56
|
+
options,
|
|
57
|
+
{
|
|
58
|
+
config: true,
|
|
59
|
+
singletonServicesFactory: true,
|
|
60
|
+
sessionServicesFactory: true,
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
const pikkuConfigImport = `import { ${pikkuConfigFactory.variable} as createConfig } from '${getFileImportRelativePath(nextBackendFile, pikkuConfigFactory.file, packageMappings)}'`
|
|
65
|
+
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`
|
|
66
|
+
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`
|
|
67
|
+
|
|
68
|
+
const httpBootstrapPath = getFileImportRelativePath(
|
|
69
|
+
nextBackendFile,
|
|
70
|
+
bootstrapFiles.http,
|
|
71
|
+
packageMappings
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
75
|
+
nextBackendFile,
|
|
76
|
+
httpRoutesMapDeclarationFile,
|
|
77
|
+
packageMappings
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
const content = serializeNextBackendWrapper(
|
|
81
|
+
httpBootstrapPath,
|
|
82
|
+
routesMapDeclarationPath,
|
|
83
|
+
pikkuConfigImport,
|
|
84
|
+
singletonServicesImport,
|
|
85
|
+
sessionServicesImport
|
|
86
|
+
)
|
|
87
|
+
await writeFileInDir(logger, nextBackendFile, content)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (nextHTTPFile && fetchFile) {
|
|
91
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
92
|
+
nextHTTPFile,
|
|
93
|
+
httpRoutesMapDeclarationFile,
|
|
94
|
+
packageMappings
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
const fetchPath = getFileImportRelativePath(
|
|
98
|
+
nextHTTPFile,
|
|
99
|
+
fetchFile,
|
|
100
|
+
packageMappings
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
const content = serializeNextHTTPWrapper(
|
|
104
|
+
routesMapDeclarationPath,
|
|
105
|
+
fetchPath
|
|
106
|
+
)
|
|
107
|
+
await writeFileInDir(logger, nextHTTPFile, content)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js'
|
|
2
|
+
import { generateSchemas } from '../../schema-generator.js'
|
|
3
|
+
import { generateOpenAPISpec } from './openapi-spec-generator.js'
|
|
4
|
+
import { stringify } from 'yaml'
|
|
5
|
+
import { PikkuCommand } from '../../types.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuOpenAPI: PikkuCommand = async (
|
|
8
|
+
logger,
|
|
9
|
+
{ tsconfig, openAPI },
|
|
10
|
+
{ http, functions }
|
|
11
|
+
) => {
|
|
12
|
+
return await logCommandInfoAndTime(
|
|
13
|
+
logger,
|
|
14
|
+
'Creating OpenAPI spec',
|
|
15
|
+
'Created OpenAPI spec',
|
|
16
|
+
[openAPI?.outputFile === undefined, 'openAPI outfile is not defined'],
|
|
17
|
+
async () => {
|
|
18
|
+
if (!openAPI?.outputFile) {
|
|
19
|
+
throw new Error('openAPI is required')
|
|
20
|
+
}
|
|
21
|
+
const schemas = await generateSchemas(
|
|
22
|
+
logger,
|
|
23
|
+
tsconfig,
|
|
24
|
+
functions.typesMap,
|
|
25
|
+
functions.meta,
|
|
26
|
+
http.meta
|
|
27
|
+
)
|
|
28
|
+
const openAPISpec = await generateOpenAPISpec(
|
|
29
|
+
functions.meta,
|
|
30
|
+
http.meta,
|
|
31
|
+
schemas,
|
|
32
|
+
openAPI.additionalInfo
|
|
33
|
+
)
|
|
34
|
+
if (openAPI.outputFile.endsWith('.json')) {
|
|
35
|
+
await writeFileInDir(
|
|
36
|
+
logger,
|
|
37
|
+
openAPI.outputFile,
|
|
38
|
+
JSON.stringify(openAPISpec, null, 2),
|
|
39
|
+
{ ignoreModifyComment: true }
|
|
40
|
+
)
|
|
41
|
+
} else if (
|
|
42
|
+
openAPI.outputFile.endsWith('.yaml') ||
|
|
43
|
+
openAPI.outputFile.endsWith('.yml')
|
|
44
|
+
) {
|
|
45
|
+
await writeFileInDir(
|
|
46
|
+
logger,
|
|
47
|
+
openAPI.outputFile,
|
|
48
|
+
stringify(openAPISpec),
|
|
49
|
+
{ ignoreModifyComment: true }
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { PikkuCLIConfig } from '
|
|
1
|
+
import { PikkuCLIConfig } from '../../pikku-cli-config.js'
|
|
2
2
|
import { InspectorState } from '@pikku/inspector'
|
|
3
3
|
import {
|
|
4
4
|
logCommandInfoAndTime,
|
|
5
5
|
serializeFileImports,
|
|
6
6
|
writeFileInDir,
|
|
7
|
-
} from '
|
|
7
|
+
} from '../../utils.js'
|
|
8
|
+
import { PikkuCommand } from '../../types.js'
|
|
8
9
|
|
|
9
|
-
export const pikkuHTTP = async (
|
|
10
|
+
export const pikkuHTTP: PikkuCommand = async (
|
|
11
|
+
logger,
|
|
10
12
|
cliConfig: PikkuCLIConfig,
|
|
11
13
|
visitState: InspectorState
|
|
12
14
|
) => {
|
|
13
15
|
return await logCommandInfoAndTime(
|
|
16
|
+
logger,
|
|
14
17
|
'Finding HTTP routes',
|
|
15
18
|
'Found HTTP routes',
|
|
16
19
|
[visitState.http.files.size === 0],
|
|
@@ -18,6 +21,7 @@ export const pikkuHTTP = async (
|
|
|
18
21
|
const { httpRoutesFile, httpRoutesMetaFile, packageMappings } = cliConfig
|
|
19
22
|
const { http } = visitState
|
|
20
23
|
await writeFileInDir(
|
|
24
|
+
logger,
|
|
21
25
|
httpRoutesFile,
|
|
22
26
|
serializeFileImports(
|
|
23
27
|
'addHTTPRoute',
|
|
@@ -27,6 +31,7 @@ export const pikkuHTTP = async (
|
|
|
27
31
|
)
|
|
28
32
|
)
|
|
29
33
|
await writeFileInDir(
|
|
34
|
+
logger,
|
|
30
35
|
httpRoutesMetaFile,
|
|
31
36
|
`import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`
|
|
32
37
|
)
|