@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/bin/pikku-websocket.ts
CHANGED
|
@@ -1,52 +1,18 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
logPikkuLogo,
|
|
6
|
-
PikkuCLIOptions,
|
|
7
|
-
writeFileInDir,
|
|
8
|
-
} from '../src/utils/utils.js'
|
|
9
|
-
import { getPikkuCLIConfig, PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
10
|
-
import { serializeWebsocketWrapper } from '../src/serialize-websocket-wrapper.js'
|
|
11
|
-
|
|
12
|
-
export const pikkuWebSocket = async ({
|
|
13
|
-
websocketFile,
|
|
14
|
-
channelsMapDeclarationFile,
|
|
15
|
-
packageMappings,
|
|
16
|
-
}: PikkuCLIConfig) => {
|
|
17
|
-
await logCommandInfoAndTime(
|
|
18
|
-
'Generating websocket wrapper',
|
|
19
|
-
'Generated websocket wrapper',
|
|
20
|
-
[
|
|
21
|
-
websocketFile === undefined,
|
|
22
|
-
"websocketFile isn't set in the pikku config",
|
|
23
|
-
],
|
|
24
|
-
async () => {
|
|
25
|
-
if (!websocketFile) {
|
|
26
|
-
throw new Error("fetchFile is isn't set in the pikku config")
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const channelsMapDeclarationPath = getFileImportRelativePath(
|
|
30
|
-
websocketFile,
|
|
31
|
-
channelsMapDeclarationFile,
|
|
32
|
-
packageMappings
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
const content = [serializeWebsocketWrapper(channelsMapDeclarationPath)]
|
|
36
|
-
await writeFileInDir(websocketFile, content.join('\n'))
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
}
|
|
2
|
+
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
3
|
+
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
4
|
+
import { pikkuWebSocketTyped } from '../src/events/channels/pikku-command-websocket-typed.js'
|
|
40
5
|
|
|
41
6
|
export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
42
|
-
|
|
7
|
+
const logger = new CLILogger({ logLogo: true })
|
|
8
|
+
|
|
43
9
|
const cliConfig = await getPikkuCLIConfig(
|
|
44
10
|
options.config,
|
|
45
11
|
['rootDir', 'schemaDirectory', 'configDir', 'fetchFile'],
|
|
46
12
|
options.tags,
|
|
47
13
|
true
|
|
48
14
|
)
|
|
49
|
-
await
|
|
15
|
+
await pikkuWebSocketTyped(logger, cliConfig)
|
|
50
16
|
}
|
|
51
17
|
|
|
52
18
|
export const websocket = (program: Command): void => {
|
package/bin/pikku.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { schemas } from './pikku-schemas.js'
|
|
|
4
4
|
import { nextjs } from './pikku-nextjs.js'
|
|
5
5
|
import { all } from './pikku-all.js'
|
|
6
6
|
import { fetch } from './pikku-fetch.js'
|
|
7
|
+
import { queue } from './pikku-queue-service.js'
|
|
7
8
|
|
|
8
9
|
const program = new Command('pikku')
|
|
9
10
|
program.usage('[command]')
|
|
@@ -12,5 +13,6 @@ all(program)
|
|
|
12
13
|
schemas(program)
|
|
13
14
|
nextjs(program)
|
|
14
15
|
fetch(program)
|
|
16
|
+
queue(program)
|
|
15
17
|
|
|
16
18
|
program.parse(process.argv)
|
package/dist/bin/pikku-all.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { PikkuCLIOptions } from '../src/utils
|
|
2
|
+
import { PikkuCLIOptions } from '../src/utils.js';
|
|
3
3
|
export declare const action: (options: PikkuCLIOptions) => Promise<void>;
|
|
4
4
|
export declare const all: (program: Command) => void;
|
package/dist/bin/pikku-all.js
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CLILogger, getFileImportRelativePath, writeFileInDir, } from '../src/utils.js';
|
|
2
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
3
|
-
import { pikkuHTTP } from '
|
|
4
|
-
import { pikkuFunctionTypes } from '
|
|
5
|
-
import { pikkuHTTPMap } from '
|
|
3
|
+
import { pikkuHTTP } from '../src/events/http/pikku-command-http-routes.js';
|
|
4
|
+
import { pikkuFunctionTypes } from '../src/events/functions/pikku-command-function-types.js';
|
|
5
|
+
import { pikkuHTTPMap } from '../src/events/http/pikku-command-http-map.js';
|
|
6
6
|
import { existsSync } from 'fs';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { pikkuChannels } from './pikku-channels.js';
|
|
10
|
-
import { pikkuNext } from './pikku-nextjs.js';
|
|
11
|
-
import { pikkuOpenAPI } from './pikku-openapi.js';
|
|
12
|
-
import { pikkuScheduler } from './pikku-scheduler.js';
|
|
13
|
-
import { pikkuSchemas } from './pikku-schemas.js';
|
|
14
|
-
import { pikkuWebSocket } from './pikku-websocket.js';
|
|
7
|
+
import { pikkuChannelsMap } from '../src/events/channels/pikku-command-channels-map.js';
|
|
8
|
+
import { pikkuChannels } from '../src/events/channels/pikku-command-channels.js';
|
|
15
9
|
import { inspectorGlob } from '../src/inspector-glob.js';
|
|
16
10
|
import chokidar from 'chokidar';
|
|
17
|
-
import { pikkuFunctions } from '
|
|
18
|
-
import { pikkuRPC } from '
|
|
19
|
-
import { pikkuRPCMap } from '
|
|
11
|
+
import { pikkuFunctions } from '../src/events/functions/pikku-command-functions.js';
|
|
12
|
+
import { pikkuRPC } from '../src/events/rpc/pikku-command-rpc.js';
|
|
13
|
+
import { pikkuRPCMap } from '../src/events/rpc/pikku-command-rpc-map.js';
|
|
20
14
|
import { PikkuEventTypes } from '@pikku/core';
|
|
21
|
-
|
|
15
|
+
import { pikkuQueue } from '../src/events/queue/pikku-command-queue.js';
|
|
16
|
+
import { pikkuQueueMap } from '../src/events/queue/pikku-command-queue-map.js';
|
|
17
|
+
import { pikkuFetch } from '../src/events/fetch/index.js';
|
|
18
|
+
import { pikkuWebSocketTyped } from '../src/events/channels/pikku-command-websocket-typed.js';
|
|
19
|
+
import { pikkuNext } from '../src/events/http/pikku-command-nextjs.js';
|
|
20
|
+
import { pikkuOpenAPI } from '../src/events/http/pikku-command-openapi.js';
|
|
21
|
+
import { pikkuMCP } from '../src/events/mcp/pikku-command-mcp.js';
|
|
22
|
+
import { pikkuQueueService } from '../src/events/queue/pikku-command-queue-service.js';
|
|
23
|
+
import { pikkuScheduler } from '../src/events/scheduler/pikku-command-scheduler.js';
|
|
24
|
+
import { pikkuSchemas } from '../src/schemas.js';
|
|
25
|
+
import { pikkuMCPJSON } from '../src/events/mcp/pikku-command-mcp-json.js';
|
|
26
|
+
const runAll = async (logger, cliConfig, options) => {
|
|
22
27
|
const boostrapImports = {
|
|
23
28
|
all: { meta: [], events: [] },
|
|
24
29
|
};
|
|
25
30
|
const addImport = (from, type, addTo) => {
|
|
26
|
-
const statement = `import '${getFileImportRelativePath(cliConfig.bootstrapFile, from, cliConfig.packageMappings)}'`;
|
|
27
31
|
if (type === 'meta') {
|
|
28
|
-
boostrapImports.all.meta.push(
|
|
32
|
+
boostrapImports.all.meta.push(from);
|
|
29
33
|
}
|
|
30
34
|
else {
|
|
31
|
-
boostrapImports.all.events.push(
|
|
35
|
+
boostrapImports.all.events.push(from);
|
|
32
36
|
}
|
|
33
37
|
for (const transport of Object.keys(PikkuEventTypes)) {
|
|
34
38
|
if (!addTo || addTo?.includes(transport)) {
|
|
@@ -37,71 +41,87 @@ const runAll = async (cliConfig, options) => {
|
|
|
37
41
|
events: [],
|
|
38
42
|
};
|
|
39
43
|
if (type === 'meta') {
|
|
40
|
-
boostrapImports[transport].meta.push(
|
|
44
|
+
boostrapImports[transport].meta.push(from);
|
|
41
45
|
}
|
|
42
46
|
else {
|
|
43
|
-
boostrapImports[transport].events.push(
|
|
47
|
+
boostrapImports[transport].events.push(from);
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
};
|
|
48
52
|
let typesDeclarationFileExists = true;
|
|
49
|
-
let visitState = await inspectorGlob(cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
53
|
+
let visitState = await inspectorGlob(logger, cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
50
54
|
if (!existsSync(cliConfig.typesDeclarationFile)) {
|
|
51
55
|
typesDeclarationFileExists = false;
|
|
52
56
|
}
|
|
53
|
-
await pikkuFunctionTypes(cliConfig,
|
|
57
|
+
await pikkuFunctionTypes(logger, cliConfig, visitState, options);
|
|
54
58
|
// This is needed since the addHTTPRoute function will add the routes to the visitState
|
|
55
59
|
if (!typesDeclarationFileExists) {
|
|
56
|
-
|
|
57
|
-
visitState = await inspectorGlob(cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
60
|
+
logger.info(`• Type file first created, inspecting again...\x1b[0m`);
|
|
61
|
+
visitState = await inspectorGlob(logger, cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
58
62
|
}
|
|
59
|
-
const functions = pikkuFunctions(cliConfig, visitState);
|
|
63
|
+
const functions = pikkuFunctions(logger, cliConfig, visitState);
|
|
60
64
|
if (!functions) {
|
|
61
|
-
|
|
65
|
+
logger.info(`• No functions found, skipping remaining steps...\x1b[0m`);
|
|
62
66
|
process.exit(1);
|
|
63
67
|
}
|
|
64
68
|
addImport(cliConfig.functionsMetaFile, 'meta');
|
|
65
69
|
addImport(cliConfig.functionsFile, 'events');
|
|
66
|
-
await pikkuRPC(cliConfig, visitState);
|
|
67
|
-
await pikkuRPCMap(cliConfig, visitState);
|
|
70
|
+
await pikkuRPC(logger, cliConfig, visitState);
|
|
71
|
+
await pikkuRPCMap(logger, cliConfig, visitState);
|
|
68
72
|
addImport(cliConfig.rpcMetaFile, 'meta', [PikkuEventTypes.rpc]);
|
|
69
|
-
const schemas = await pikkuSchemas(cliConfig, visitState);
|
|
73
|
+
const schemas = await pikkuSchemas(logger, cliConfig, visitState);
|
|
70
74
|
if (schemas) {
|
|
71
75
|
addImport(`${cliConfig.schemaDirectory}/register.gen.ts`, 'other');
|
|
72
76
|
}
|
|
73
|
-
const http = await pikkuHTTP(cliConfig, visitState);
|
|
77
|
+
const http = await pikkuHTTP(logger, cliConfig, visitState);
|
|
74
78
|
if (http) {
|
|
75
|
-
await pikkuHTTPMap(cliConfig, visitState);
|
|
76
|
-
await pikkuFetch(cliConfig);
|
|
79
|
+
await pikkuHTTPMap(logger, cliConfig, visitState);
|
|
80
|
+
await pikkuFetch(logger, cliConfig);
|
|
77
81
|
addImport(cliConfig.httpRoutesMetaFile, 'meta', [PikkuEventTypes.http]);
|
|
78
82
|
addImport(cliConfig.httpRoutesFile, 'events', [PikkuEventTypes.http]);
|
|
79
83
|
}
|
|
80
|
-
const scheduled = await pikkuScheduler(cliConfig, visitState);
|
|
84
|
+
const scheduled = await pikkuScheduler(logger, cliConfig, visitState);
|
|
81
85
|
if (scheduled) {
|
|
82
86
|
addImport(cliConfig.schedulersMetaFile, 'meta', [PikkuEventTypes.scheduled]);
|
|
83
87
|
addImport(cliConfig.schedulersFile, 'events', [PikkuEventTypes.scheduled]);
|
|
84
88
|
}
|
|
85
|
-
const
|
|
89
|
+
const queues = await pikkuQueue(logger, cliConfig, visitState);
|
|
90
|
+
if (queues) {
|
|
91
|
+
await pikkuQueueMap(logger, cliConfig, visitState);
|
|
92
|
+
await pikkuQueueService(logger, cliConfig);
|
|
93
|
+
addImport(cliConfig.queueWorkersMetaFile, 'meta', [PikkuEventTypes.queue]);
|
|
94
|
+
addImport(cliConfig.queueWorkersFile, 'events', [PikkuEventTypes.queue]);
|
|
95
|
+
}
|
|
96
|
+
const channels = await pikkuChannels(logger, cliConfig, visitState);
|
|
86
97
|
if (channels) {
|
|
87
|
-
await pikkuChannelsMap(cliConfig, visitState);
|
|
88
|
-
await
|
|
98
|
+
await pikkuChannelsMap(logger, cliConfig, visitState);
|
|
99
|
+
await pikkuWebSocketTyped(logger, cliConfig);
|
|
89
100
|
addImport(cliConfig.channelsMetaFile, 'meta', [PikkuEventTypes.channel]);
|
|
90
101
|
addImport(cliConfig.channelsFile, 'events', [PikkuEventTypes.channel]);
|
|
91
102
|
}
|
|
103
|
+
const mcp = await pikkuMCP(logger, cliConfig, visitState);
|
|
104
|
+
if (mcp) {
|
|
105
|
+
await pikkuMCPJSON(logger, cliConfig, visitState);
|
|
106
|
+
addImport(cliConfig.mcpEndpointsMetaFile, 'meta', [PikkuEventTypes.mcp]);
|
|
107
|
+
addImport(cliConfig.mcpEndpointsFile, 'events', [PikkuEventTypes.mcp]);
|
|
108
|
+
}
|
|
92
109
|
if (cliConfig.nextBackendFile || cliConfig.nextHTTPFile) {
|
|
93
|
-
await pikkuNext(cliConfig, visitState, options);
|
|
110
|
+
await pikkuNext(logger, cliConfig, visitState, options);
|
|
94
111
|
}
|
|
95
112
|
if (cliConfig.openAPI) {
|
|
96
|
-
|
|
97
|
-
visitState = await inspectorGlob(cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
98
|
-
await pikkuOpenAPI(cliConfig, visitState);
|
|
113
|
+
logger.info(`• OpenAPI requires a reinspection to pickup new generated types..`);
|
|
114
|
+
visitState = await inspectorGlob(logger, cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
115
|
+
await pikkuOpenAPI(logger, cliConfig, visitState);
|
|
99
116
|
}
|
|
100
117
|
for (const [type, { meta, events }] of Object.entries(boostrapImports)) {
|
|
101
|
-
|
|
118
|
+
const bootstrapFile = type === 'all' ? cliConfig.bootstrapFile : cliConfig.bootstrapFiles[type];
|
|
119
|
+
await writeFileInDir(logger, bootstrapFile, [...meta, ...events]
|
|
120
|
+
.map((to) => `import '${getFileImportRelativePath(bootstrapFile, to, cliConfig.packageMappings)}'`)
|
|
121
|
+
.join('\n'));
|
|
102
122
|
}
|
|
103
123
|
};
|
|
104
|
-
const watch = (cliConfig, options) => {
|
|
124
|
+
const watch = (logger, cliConfig, options) => {
|
|
105
125
|
const configWatcher = chokidar.watch(cliConfig.srcDirectories, {
|
|
106
126
|
ignoreInitial: true,
|
|
107
127
|
ignored: /.*\.gen\.tsx?/,
|
|
@@ -109,7 +129,7 @@ const watch = (cliConfig, options) => {
|
|
|
109
129
|
let watcher = new chokidar.FSWatcher({});
|
|
110
130
|
const generatorWatcher = () => {
|
|
111
131
|
watcher.close();
|
|
112
|
-
|
|
132
|
+
logger.info(`• Watching directories: \n - ${cliConfig.srcDirectories.join('\n - ')}`);
|
|
113
133
|
watcher = chokidar.watch(cliConfig.srcDirectories, {
|
|
114
134
|
ignoreInitial: true,
|
|
115
135
|
ignored: /.*\.gen\.ts/,
|
|
@@ -117,7 +137,7 @@ const watch = (cliConfig, options) => {
|
|
|
117
137
|
watcher.on('ready', async () => {
|
|
118
138
|
const handle = async () => {
|
|
119
139
|
try {
|
|
120
|
-
await runAll(cliConfig, options);
|
|
140
|
+
await runAll(logger, cliConfig, options);
|
|
121
141
|
}
|
|
122
142
|
catch (err) {
|
|
123
143
|
console.error(err);
|
|
@@ -141,13 +161,13 @@ const watch = (cliConfig, options) => {
|
|
|
141
161
|
configWatcher.on('change', generatorWatcher);
|
|
142
162
|
};
|
|
143
163
|
export const action = async (options) => {
|
|
144
|
-
|
|
164
|
+
const logger = new CLILogger({ logLogo: true });
|
|
145
165
|
const cliConfig = await getPikkuCLIConfig(options.config, [], options.tags, true);
|
|
146
166
|
if (options.watch) {
|
|
147
|
-
watch(cliConfig, options);
|
|
167
|
+
watch(logger, cliConfig, options);
|
|
148
168
|
}
|
|
149
169
|
else {
|
|
150
|
-
await runAll(cliConfig, options);
|
|
170
|
+
await runAll(logger, cliConfig, options);
|
|
151
171
|
}
|
|
152
172
|
};
|
|
153
173
|
export const all = (program) => {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
3
|
-
import { PikkuCLIOptions } from '../src/utils/utils.js';
|
|
4
|
-
export declare const pikkuFetch: ({ fetchFile, httpRoutesMapDeclarationFile, packageMappings, }: PikkuCLIConfig) => Promise<void>;
|
|
2
|
+
import { PikkuCLIOptions } from '../src/utils.js';
|
|
5
3
|
export declare const action: (options: PikkuCLIOptions) => Promise<void>;
|
|
6
4
|
export declare const fetch: (program: Command) => void;
|
package/dist/bin/pikku-fetch.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export const pikkuFetch = async ({ fetchFile, httpRoutesMapDeclarationFile, packageMappings, }) => {
|
|
5
|
-
await logCommandInfoAndTime('Generating fetch wrapper', 'Generated fetch wrapper', [fetchFile === undefined, "fetchFile isn't set in the pikku config"], async () => {
|
|
6
|
-
if (!fetchFile) {
|
|
7
|
-
throw new Error("fetchFile is isn't set in the pikku config");
|
|
8
|
-
}
|
|
9
|
-
const routesMapDeclarationPath = getFileImportRelativePath(fetchFile, httpRoutesMapDeclarationFile, packageMappings);
|
|
10
|
-
const content = [serializeFetchWrapper(routesMapDeclarationPath)];
|
|
11
|
-
await writeFileInDir(fetchFile, content.join('\n'));
|
|
12
|
-
});
|
|
13
|
-
};
|
|
2
|
+
import { pikkuFetch } from '../src/events/fetch/index.js';
|
|
3
|
+
import { CLILogger } from '../src/utils.js';
|
|
14
4
|
export const action = async (options) => {
|
|
15
|
-
|
|
5
|
+
const logger = new CLILogger({ logLogo: true });
|
|
16
6
|
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir', 'fetchFile'], options.tags, true);
|
|
17
|
-
await pikkuFetch(cliConfig);
|
|
7
|
+
await pikkuFetch(logger, cliConfig);
|
|
18
8
|
};
|
|
19
9
|
export const fetch = (program) => {
|
|
20
10
|
program
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { PikkuCLIOptions } from '../src/utils
|
|
3
|
-
import { PikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
4
|
-
import { InspectorState } from '@pikku/inspector';
|
|
5
|
-
export declare const pikkuNext: ({ nextBackendFile, nextHTTPFile, httpRoutesMapDeclarationFile, packageMappings, fetchFile, bootstrapFiles, }: PikkuCLIConfig, visitState: InspectorState, options: PikkuCLIOptions) => Promise<boolean>;
|
|
2
|
+
import { PikkuCLIOptions } from '../src/utils.js';
|
|
6
3
|
export declare const action: (options: PikkuCLIOptions) => Promise<void>;
|
|
7
4
|
export declare const nextjs: (program: Command) => void;
|
package/dist/bin/pikku-nextjs.js
CHANGED
|
@@ -1,46 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { serializeNextJsHTTPWrapper as serializeNextHTTPWrapper } from '../src/serialize-nextjs-http-wrapper.js';
|
|
3
|
-
import { getFileImportRelativePath, getPikkuFilesAndMethods, logCommandInfoAndTime, logPikkuLogo, writeFileInDir, } from '../src/utils/utils.js';
|
|
1
|
+
import { CLILogger } from '../src/utils.js';
|
|
4
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
5
3
|
import { inspectorGlob } from '../src/inspector-glob.js';
|
|
6
|
-
|
|
7
|
-
return await logCommandInfoAndTime('Generating nextjs wrapper', 'Generated nextjs wrapper', [
|
|
8
|
-
nextBackendFile === undefined && nextHTTPFile === undefined,
|
|
9
|
-
'nextjs outfile is not defined',
|
|
10
|
-
], async () => {
|
|
11
|
-
if (!nextBackendFile && !nextHTTPFile) {
|
|
12
|
-
throw new Error('nextBackendFile or nextHTTPFile is required in pikku config for nextJS');
|
|
13
|
-
}
|
|
14
|
-
if (nextHTTPFile && !fetchFile) {
|
|
15
|
-
throw new Error('fetchFile is required in pikku config in order for nextJS http wrapper to work');
|
|
16
|
-
}
|
|
17
|
-
if (nextBackendFile) {
|
|
18
|
-
const { pikkuConfigFactory, singletonServicesFactory, sessionServicesFactory, } = await getPikkuFilesAndMethods(visitState, packageMappings, nextBackendFile, options, {
|
|
19
|
-
config: true,
|
|
20
|
-
singletonServicesFactory: true,
|
|
21
|
-
sessionServicesFactory: true,
|
|
22
|
-
});
|
|
23
|
-
const pikkuConfigImport = `import { ${pikkuConfigFactory.variable} as createConfig } from '${getFileImportRelativePath(nextBackendFile, pikkuConfigFactory.file, packageMappings)}'`;
|
|
24
|
-
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`;
|
|
25
|
-
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`;
|
|
26
|
-
const httpBootstrapPath = getFileImportRelativePath(nextBackendFile, bootstrapFiles.http, packageMappings);
|
|
27
|
-
const routesMapDeclarationPath = getFileImportRelativePath(nextBackendFile, httpRoutesMapDeclarationFile, packageMappings);
|
|
28
|
-
const content = serializeNextBackendWrapper(httpBootstrapPath, routesMapDeclarationPath, pikkuConfigImport, singletonServicesImport, sessionServicesImport);
|
|
29
|
-
await writeFileInDir(nextBackendFile, content);
|
|
30
|
-
}
|
|
31
|
-
if (nextHTTPFile && fetchFile) {
|
|
32
|
-
const routesMapDeclarationPath = getFileImportRelativePath(nextHTTPFile, httpRoutesMapDeclarationFile, packageMappings);
|
|
33
|
-
const fetchPath = getFileImportRelativePath(nextHTTPFile, fetchFile, packageMappings);
|
|
34
|
-
const content = serializeNextHTTPWrapper(routesMapDeclarationPath, fetchPath);
|
|
35
|
-
await writeFileInDir(nextHTTPFile, content);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
};
|
|
4
|
+
import { pikkuNext } from '../src/events/http/pikku-command-nextjs.js';
|
|
39
5
|
export const action = async (options) => {
|
|
40
|
-
|
|
6
|
+
const logger = new CLILogger({ logLogo: true });
|
|
41
7
|
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir'], options.tags, true);
|
|
42
|
-
const visitState = await inspectorGlob(cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
43
|
-
await pikkuNext(cliConfig, visitState, options);
|
|
8
|
+
const visitState = await inspectorGlob(logger, cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
9
|
+
await pikkuNext(logger, cliConfig, visitState, options);
|
|
44
10
|
};
|
|
45
11
|
export const nextjs = (program) => {
|
|
46
12
|
program
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { PikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
3
|
-
import { InspectorState } from '@pikku/inspector';
|
|
4
|
-
export declare const pikkuOpenAPI: ({ tsconfig, openAPI }: PikkuCLIConfig, { http, functions }: InspectorState) => Promise<void>;
|
|
5
2
|
export declare const openapi: (program: Command) => void;
|
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { generateSchemas } from '../src/schema-generator.js';
|
|
3
|
-
import { generateOpenAPISpec } from '../src/openapi-spec-generator.js';
|
|
1
|
+
import { CLILogger } from '../src/utils.js';
|
|
4
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
5
|
-
import { stringify } from 'yaml';
|
|
6
3
|
import { inspectorGlob } from '../src/inspector-glob.js';
|
|
7
|
-
|
|
8
|
-
await logCommandInfoAndTime('Creating OpenAPI spec', 'Created OpenAPI spec', [openAPI?.outputFile === undefined, 'openAPI outfile is not defined'], async () => {
|
|
9
|
-
if (!openAPI?.outputFile) {
|
|
10
|
-
throw new Error('openAPI is required');
|
|
11
|
-
}
|
|
12
|
-
const schemas = await generateSchemas(tsconfig, functions.typesMap, functions.meta, http.meta);
|
|
13
|
-
const openAPISpec = await generateOpenAPISpec(functions.meta, http.meta, schemas, openAPI.additionalInfo);
|
|
14
|
-
if (openAPI.outputFile.endsWith('.json')) {
|
|
15
|
-
await writeFileInDir(openAPI.outputFile, JSON.stringify(openAPISpec, null, 2), true);
|
|
16
|
-
}
|
|
17
|
-
else if (openAPI.outputFile.endsWith('.yaml') ||
|
|
18
|
-
openAPI.outputFile.endsWith('.yml')) {
|
|
19
|
-
await writeFileInDir(openAPI.outputFile, stringify(openAPISpec), true);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
4
|
+
import { pikkuOpenAPI } from '../src/events/http/pikku-command-openapi.js';
|
|
23
5
|
async function action({ config, tags }) {
|
|
24
|
-
|
|
6
|
+
const logger = new CLILogger({ logLogo: true });
|
|
25
7
|
const cliConfig = await getPikkuCLIConfig(config, ['rootDir', 'httpRoutesFile', 'openAPI', 'schemaDirectory', 'tsconfig'], tags);
|
|
26
|
-
const visitState = await inspectorGlob(cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
27
|
-
await pikkuOpenAPI(cliConfig, visitState);
|
|
8
|
+
const visitState = await inspectorGlob(logger, cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
9
|
+
await pikkuOpenAPI(logger, cliConfig, visitState);
|
|
28
10
|
}
|
|
29
11
|
export const openapi = (program) => {
|
|
30
12
|
program
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
2
|
+
import { CLILogger } from '../src/utils.js';
|
|
3
|
+
import { pikkuQueueService } from '../src/events/queue/pikku-command-queue-service.js';
|
|
4
|
+
export const action = async (options) => {
|
|
5
|
+
const logger = new CLILogger({ logLogo: true });
|
|
6
|
+
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir', 'queueFile'], options.tags, true);
|
|
7
|
+
await pikkuQueueService(logger, cliConfig);
|
|
8
|
+
};
|
|
9
|
+
export const queue = (program) => {
|
|
10
|
+
program
|
|
11
|
+
.command('queue')
|
|
12
|
+
.description('generate queue service wrapper')
|
|
13
|
+
.option('-c | --config <string>', 'The path to pikku cli config file')
|
|
14
|
+
.action(action);
|
|
15
|
+
};
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { PikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
3
|
-
import { InspectorState } from '@pikku/inspector';
|
|
4
|
-
export declare const pikkuSchemas: ({ tsconfig, schemaDirectory, supportsImportAttributes }: PikkuCLIConfig, { functions, http }: InspectorState) => Promise<boolean>;
|
|
5
2
|
export declare const schemas: (program: Command) => void;
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import { saveSchemas, generateSchemas } from '../src/schema-generator.js';
|
|
2
1
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
3
|
-
import { logCommandInfoAndTime, logPikkuLogo } from '../src/utils/utils.js';
|
|
4
2
|
import { inspectorGlob } from '../src/inspector-glob.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const schemas = await generateSchemas(tsconfig, functions.typesMap, functions.meta, http.meta);
|
|
8
|
-
await saveSchemas(schemaDirectory, schemas, functions.typesMap, functions.meta, supportsImportAttributes);
|
|
9
|
-
});
|
|
10
|
-
};
|
|
3
|
+
import { pikkuSchemas } from '../src/schemas.js';
|
|
4
|
+
import { CLILogger } from '../src/utils.js';
|
|
11
5
|
async function action({ config }) {
|
|
12
|
-
|
|
6
|
+
const logger = new CLILogger({ logLogo: true });
|
|
13
7
|
const cliConfig = await getPikkuCLIConfig(config, [
|
|
14
8
|
'srcDirectories',
|
|
15
9
|
'schemaDirectory',
|
|
16
10
|
'tsconfig',
|
|
17
11
|
]);
|
|
18
|
-
const visitState = await inspectorGlob(cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
19
|
-
await pikkuSchemas(cliConfig, visitState);
|
|
12
|
+
const visitState = await inspectorGlob(logger, cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
13
|
+
await pikkuSchemas(logger, cliConfig, visitState);
|
|
20
14
|
}
|
|
21
15
|
export const schemas = (program) => {
|
|
22
16
|
program
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { PikkuCLIOptions } from '../src/utils
|
|
3
|
-
import { PikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
4
|
-
export declare const pikkuWebSocket: ({ websocketFile, channelsMapDeclarationFile, packageMappings, }: PikkuCLIConfig) => Promise<void>;
|
|
2
|
+
import { PikkuCLIOptions } from '../src/utils.js';
|
|
5
3
|
export declare const action: (options: PikkuCLIOptions) => Promise<void>;
|
|
6
4
|
export declare const websocket: (program: Command) => void;
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CLILogger } from '../src/utils.js';
|
|
2
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
3
|
-
import {
|
|
4
|
-
export const pikkuWebSocket = async ({ websocketFile, channelsMapDeclarationFile, packageMappings, }) => {
|
|
5
|
-
await logCommandInfoAndTime('Generating websocket wrapper', 'Generated websocket wrapper', [
|
|
6
|
-
websocketFile === undefined,
|
|
7
|
-
"websocketFile isn't set in the pikku config",
|
|
8
|
-
], async () => {
|
|
9
|
-
if (!websocketFile) {
|
|
10
|
-
throw new Error("fetchFile is isn't set in the pikku config");
|
|
11
|
-
}
|
|
12
|
-
const channelsMapDeclarationPath = getFileImportRelativePath(websocketFile, channelsMapDeclarationFile, packageMappings);
|
|
13
|
-
const content = [serializeWebsocketWrapper(channelsMapDeclarationPath)];
|
|
14
|
-
await writeFileInDir(websocketFile, content.join('\n'));
|
|
15
|
-
});
|
|
16
|
-
};
|
|
3
|
+
import { pikkuWebSocketTyped } from '../src/events/channels/pikku-command-websocket-typed.js';
|
|
17
4
|
export const action = async (options) => {
|
|
18
|
-
|
|
5
|
+
const logger = new CLILogger({ logLogo: true });
|
|
19
6
|
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir', 'fetchFile'], options.tags, true);
|
|
20
|
-
await
|
|
7
|
+
await pikkuWebSocketTyped(logger, cliConfig);
|
|
21
8
|
};
|
|
22
9
|
export const websocket = (program) => {
|
|
23
10
|
program
|
package/dist/bin/pikku.js
CHANGED
|
@@ -4,10 +4,12 @@ import { schemas } from './pikku-schemas.js';
|
|
|
4
4
|
import { nextjs } from './pikku-nextjs.js';
|
|
5
5
|
import { all } from './pikku-all.js';
|
|
6
6
|
import { fetch } from './pikku-fetch.js';
|
|
7
|
+
import { queue } from './pikku-queue-service.js';
|
|
7
8
|
const program = new Command('pikku');
|
|
8
9
|
program.usage('[command]');
|
|
9
10
|
all(program);
|
|
10
11
|
schemas(program);
|
|
11
12
|
nextjs(program);
|
|
12
13
|
fetch(program);
|
|
14
|
+
queue(program);
|
|
13
15
|
program.parse(process.argv);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
+
export const pikkuChannels = async (logger, cliConfig, visitState) => {
|
|
3
|
+
return await logCommandInfoAndTime(logger, 'Finding Channels', 'Found channels', [visitState.channels.files.size === 0], async () => {
|
|
4
|
+
const { channelsFile, channelsMetaFile, packageMappings } = cliConfig;
|
|
5
|
+
const { channels } = visitState;
|
|
6
|
+
await writeFileInDir(logger, channelsFile, serializeFileImports('addChannel', channelsFile, channels.files, packageMappings));
|
|
7
|
+
await writeFileInDir(logger, channelsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
+
import { serializeTypedChannelsMap } from './serialize-typed-channel-map.js';
|
|
3
|
+
export const pikkuChannelsMap = async (logger, { channelsMapDeclarationFile, packageMappings }, state) => {
|
|
4
|
+
return await logCommandInfoAndTime(logger, 'Creating channels map', 'Created channels map', [state.channels.files.size === 0], async () => {
|
|
5
|
+
const content = serializeTypedChannelsMap(channelsMapDeclarationFile, packageMappings, state.functions.typesMap, state.functions.meta, state.channels.meta);
|
|
6
|
+
await writeFileInDir(logger, channelsMapDeclarationFile, content);
|
|
7
|
+
});
|
|
8
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
+
export const pikkuChannels = async (logger, cliConfig, visitState) => {
|
|
3
|
+
return await logCommandInfoAndTime(logger, 'Finding Channels', 'Found channels', [visitState.channels.files.size === 0], async () => {
|
|
4
|
+
const { channelsFile, channelsMetaFile, packageMappings } = cliConfig;
|
|
5
|
+
const { channels } = visitState;
|
|
6
|
+
await writeFileInDir(logger, channelsFile, serializeFileImports('addChannel', channelsFile, channels.files, packageMappings));
|
|
7
|
+
await writeFileInDir(logger, channelsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { logCommandInfoAndTime, getFileImportRelativePath, writeFileInDir, } from '../../utils.js';
|
|
2
|
+
import { serializeWebsocketWrapper } from './serialize-websocket-wrapper.js';
|
|
3
|
+
export const pikkuWebSocketTyped = async (logger, { websocketFile, channelsMapDeclarationFile, packageMappings }) => {
|
|
4
|
+
return await logCommandInfoAndTime(logger, 'Generating websocket wrapper', 'Generated websocket wrapper', [
|
|
5
|
+
websocketFile === undefined,
|
|
6
|
+
"websocketFile isn't set in the pikku config",
|
|
7
|
+
], async () => {
|
|
8
|
+
if (!websocketFile) {
|
|
9
|
+
throw new Error("fetchFile is isn't set in the pikku config");
|
|
10
|
+
}
|
|
11
|
+
const channelsMapDeclarationPath = getFileImportRelativePath(websocketFile, channelsMapDeclarationFile, packageMappings);
|
|
12
|
+
const content = [serializeWebsocketWrapper(channelsMapDeclarationPath)];
|
|
13
|
+
await writeFileInDir(logger, websocketFile, content.join('\n'));
|
|
14
|
+
});
|
|
15
|
+
};
|
package/dist/src/{serialize-typed-channel-map.js → events/channels/serialize-typed-channel-map.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { serializeImportMap } from '
|
|
2
|
-
import { generateCustomTypes } from '
|
|
1
|
+
import { serializeImportMap } from '../../serialize-import-map.js';
|
|
2
|
+
import { generateCustomTypes } from '../../utils.js';
|
|
3
3
|
export const serializeTypedChannelsMap = (relativeToPath, packageMappings, typesMap, functionsMeta, channelsMeta) => {
|
|
4
4
|
const { channels, requiredTypes } = generateChannels(functionsMeta, channelsMeta);
|
|
5
5
|
typesMap.customTypes.forEach(({ references }) => {
|