@pikku/cli 0.9.16-next.0 → 0.10.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/.pikku/channel/pikku-channel-types.gen.ts +28 -29
- package/.pikku/channel/pikku-channels-map.gen.d.ts +44 -0
- package/.pikku/channel/pikku-channels-meta.gen.ts +5 -0
- package/.pikku/channel/pikku-channels.gen.ts +4 -0
- package/.pikku/cli/pikku-cli-channel.gen.ts +34 -0
- package/.pikku/cli/pikku-cli-client.gen.ts +43 -0
- package/.pikku/cli/pikku-cli-types.gen.ts +14 -15
- package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +142 -2
- package/.pikku/cli/pikku-cli-wirings.gen.ts +4 -2
- package/.pikku/cli/pikku-cli.gen.ts +41 -0
- package/.pikku/function/pikku-function-types.gen.ts +167 -19
- package/.pikku/function/pikku-functions-meta.gen.ts +220 -192
- package/.pikku/function/pikku-functions-meta.min.gen.ts +61 -56
- package/.pikku/function/pikku-functions.gen.ts +3 -1
- package/.pikku/http/pikku-http-types.gen.ts +28 -3
- package/.pikku/http/pikku-http-wirings-map.gen.d.ts +43 -0
- package/.pikku/http/pikku-http-wirings-meta.gen.ts +13 -0
- package/.pikku/http/pikku-http-wirings.gen.ts +4 -0
- package/.pikku/mcp/pikku-mcp-types.gen.ts +15 -13
- package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +7 -0
- package/.pikku/mcp/pikku-mcp-wirings.gen.ts +4 -0
- package/.pikku/mcp/pikku-mcp.gen.json +5 -0
- package/.pikku/pikku-bootstrap.gen.ts +11 -1
- package/.pikku/pikku-services.gen.ts +1 -5
- package/.pikku/pikku-types.gen.ts +1 -2
- package/.pikku/pikku-websocket.gen.ts +76 -0
- package/.pikku/queue/pikku-queue-types.gen.ts +1 -2
- package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +57 -0
- package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +5 -0
- package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +4 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +5 -4
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +19 -17
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +15 -14
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +1 -2
- package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +5 -0
- package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +4 -0
- package/.pikku/schemas/register.gen.ts +15 -11
- package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
- package/CHANGELOG.md +6 -0
- package/bin/pikku.ts +63 -11
- package/build.sh +1 -1
- package/cli.schema.json +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +11 -20
- package/dist/.pikku/channel/pikku-channel-types.gen.js +9 -11
- package/dist/.pikku/channel/pikku-channels-meta.gen.d.ts +1 -0
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +5 -0
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +4 -0
- package/dist/.pikku/channel/pikku-channels.gen.js +5 -0
- package/dist/.pikku/cli/pikku-cli-channel.gen.d.ts +1 -0
- package/dist/.pikku/cli/pikku-cli-channel.gen.js +33 -0
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +10 -0
- package/dist/.pikku/cli/pikku-cli-client.gen.js +34 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +9 -12
- package/dist/.pikku/cli/pikku-cli-types.gen.js +5 -4
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +142 -2
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +3 -2
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +4 -3
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +10 -0
- package/dist/.pikku/cli/pikku-cli.gen.js +38 -0
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +141 -20
- package/dist/.pikku/function/pikku-function-types.gen.js +108 -12
- package/dist/.pikku/function/pikku-functions-meta.gen.js +220 -192
- package/dist/.pikku/function/pikku-functions-meta.min.gen.js +61 -56
- package/dist/.pikku/function/pikku-functions.gen.js +3 -1
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +21 -2
- package/dist/.pikku/http/pikku-http-types.gen.js +24 -3
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +13 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +4 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.js +5 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +11 -8
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +6 -6
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +7 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +4 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +5 -0
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +11 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +11 -1
- package/dist/.pikku/pikku-services.gen.d.ts +1 -4
- package/dist/.pikku/pikku-services.gen.js +0 -6
- package/dist/.pikku/pikku-types.gen.d.ts +1 -2
- package/dist/.pikku/pikku-types.gen.js +1 -2
- package/dist/.pikku/pikku-websocket.gen.d.ts +31 -0
- package/dist/.pikku/pikku-websocket.gen.js +49 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -2
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -2
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +5 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +5 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +15 -14
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -2
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -2
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +5 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +5 -0
- package/dist/.pikku/schemas/register.gen.js +9 -7
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
- package/dist/bin/pikku.d.ts +1 -1
- package/dist/bin/pikku.js +37 -6
- package/dist/src/cli.wiring.js +99 -75
- package/dist/src/functions/commands/all.js +10 -0
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +10 -8
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +2 -2
- package/dist/src/functions/wirings/channels/pikku-channels.js +0 -5
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +0 -2
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.js +0 -5
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +0 -5
- package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.js +6 -3
- package/dist/src/functions/wirings/channels/serialize-channel-types.js +27 -28
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +4 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +31 -8
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +0 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +0 -2
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +6 -2
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +88 -11
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +1 -18
- package/dist/src/functions/wirings/cli/serialize-cli-types.js +13 -14
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +19 -14
- package/dist/src/functions/wirings/fetch/index.js +6 -3
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +6 -5
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +0 -2
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +0 -2
- package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-services.js +11 -21
- package/dist/src/functions/wirings/functions/pikku-function-types.js +0 -2
- package/dist/src/functions/wirings/functions/schemas.js +0 -2
- package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-function-types.js +167 -19
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +0 -1
- package/dist/src/functions/wirings/http/openapi-spec-generator.d.ts +2 -1
- package/dist/src/functions/wirings/http/pikku-command-http-map.js +0 -5
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +0 -5
- package/dist/src/functions/wirings/http/pikku-command-http-types.js +0 -2
- package/dist/src/functions/wirings/http/pikku-command-openapi.js +7 -4
- package/dist/src/functions/wirings/http/pikku-http-routes.js +0 -5
- package/dist/src/functions/wirings/http/serialize-http-types.js +27 -2
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +0 -5
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.js +0 -2
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +0 -5
- package/dist/src/functions/wirings/mcp/serialize-mcp-json.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +14 -12
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +0 -2
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +1 -7
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.d.ts +1 -0
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.js +28 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.d.ts +2 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.js +43 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +0 -5
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +6 -3
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.js +0 -2
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +0 -5
- package/dist/src/functions/wirings/queue/pikku-queue-map.js +0 -5
- package/dist/src/functions/wirings/queue/pikku-queue.js +1 -5
- package/dist/src/functions/wirings/queue/serialize-queue-meta.d.ts +1 -1
- package/dist/src/functions/wirings/queue/serialize-queue-types.js +0 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +5 -3
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +0 -4
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +0 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.js +0 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +0 -5
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +0 -1
- package/dist/src/middleware/log-command-info-and-time.d.ts +2 -8
- package/dist/src/middleware/log-command-info-and-time.js +2 -14
- package/dist/src/services/cli-logger-forwarder.service.d.ts +6 -2
- package/dist/src/services/cli-logger-forwarder.service.js +9 -0
- package/dist/src/services/cli-logger.service.d.ts +4 -0
- package/dist/src/services/cli-logger.service.js +11 -0
- package/dist/src/services.d.ts +5 -0
- package/dist/src/services.js +111 -13
- package/dist/src/utils/custom-types-generator.js +8 -2
- package/dist/src/utils/file-writer.d.ts +4 -1
- package/dist/src/utils/file-writer.js +13 -3
- package/dist/src/utils/get-cli-version.d.ts +5 -0
- package/dist/src/utils/get-cli-version.js +27 -0
- package/dist/src/utils/pikku-cli-config.d.ts +1 -2
- package/dist/src/utils/pikku-cli-config.js +9 -28
- package/dist/src/utils/schema-generator.js +3 -2
- package/dist/src/utils/serialize-import-map.js +0 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -8
- package/pikku.config.json +4 -2
- package/src/cli.wiring.ts +101 -74
- package/src/functions/commands/all.ts +12 -0
- package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +12 -12
- package/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +2 -2
- package/src/functions/wirings/channels/pikku-channels.ts +0 -5
- package/src/functions/wirings/channels/pikku-command-channel-types.ts +0 -2
- package/src/functions/wirings/channels/pikku-command-channels-map.ts +0 -5
- package/src/functions/wirings/channels/pikku-command-channels.ts +0 -5
- package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +7 -3
- package/src/functions/wirings/channels/serialize-channel-types.ts +27 -28
- package/src/functions/wirings/channels/serialize-typed-channel-map.ts +4 -1
- package/src/functions/wirings/cli/pikku-command-cli-entry.ts +52 -9
- package/src/functions/wirings/cli/pikku-command-cli-types.ts +0 -2
- package/src/functions/wirings/cli/pikku-command-cli.ts +0 -2
- package/src/functions/wirings/cli/serialize-channel-cli-client.ts +111 -12
- package/src/functions/wirings/cli/serialize-channel-cli.ts +2 -23
- package/src/functions/wirings/cli/serialize-cli-types.ts +13 -14
- package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +19 -14
- package/src/functions/wirings/fetch/index.ts +7 -3
- package/src/functions/wirings/functions/pikku-command-function-types-split.ts +14 -5
- package/src/functions/wirings/functions/pikku-command-function-types.ts +0 -2
- package/src/functions/wirings/functions/pikku-command-functions.ts +0 -2
- package/src/functions/wirings/functions/pikku-command-services.ts +13 -24
- package/src/functions/wirings/functions/pikku-function-types.ts +0 -2
- package/src/functions/wirings/functions/schemas.ts +0 -2
- package/src/functions/wirings/functions/serialize-function-types.ts +169 -19
- package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +0 -1
- package/src/functions/wirings/http/openapi-spec-generator.ts +2 -1
- package/src/functions/wirings/http/pikku-command-http-map.ts +0 -5
- package/src/functions/wirings/http/pikku-command-http-routes.ts +0 -5
- package/src/functions/wirings/http/pikku-command-http-types.ts +0 -2
- package/src/functions/wirings/http/pikku-command-openapi.ts +9 -4
- package/src/functions/wirings/http/pikku-http-routes.ts +0 -5
- package/src/functions/wirings/http/serialize-http-types.ts +27 -2
- package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +0 -5
- package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +0 -2
- package/src/functions/wirings/mcp/pikku-command-mcp.ts +0 -5
- package/src/functions/wirings/mcp/serialize-mcp-json.ts +1 -1
- package/src/functions/wirings/mcp/serialize-mcp-types.ts +14 -12
- package/src/functions/wirings/middleware/pikku-command-middleware.ts +0 -2
- package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +1 -7
- package/src/functions/wirings/permissions/pikku-command-permissions.ts +49 -0
- package/src/functions/wirings/permissions/serialize-permissions-imports.test.ts +274 -0
- package/src/functions/wirings/permissions/serialize-permissions-imports.ts +78 -0
- package/src/functions/wirings/queue/pikku-command-queue-map.ts +0 -5
- package/src/functions/wirings/queue/pikku-command-queue-service.ts +7 -3
- package/src/functions/wirings/queue/pikku-command-queue-types.ts +0 -2
- package/src/functions/wirings/queue/pikku-command-queue.ts +0 -5
- package/src/functions/wirings/queue/pikku-queue-map.ts +0 -5
- package/src/functions/wirings/queue/pikku-queue.ts +3 -6
- package/src/functions/wirings/queue/serialize-queue-meta.ts +1 -1
- package/src/functions/wirings/queue/serialize-queue-types.ts +0 -1
- package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +6 -3
- package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +0 -4
- package/src/functions/wirings/rpc/pikku-command-rpc.ts +0 -2
- package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +0 -2
- package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +0 -5
- package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +0 -1
- package/src/middleware/log-command-info-and-time.ts +2 -28
- package/src/services/cli-logger-forwarder.service.ts +15 -2
- package/src/services/cli-logger.service.ts +15 -0
- package/src/services.ts +148 -19
- package/src/utils/custom-types-generator.ts +8 -2
- package/src/utils/file-writer.ts +19 -3
- package/src/utils/get-cli-version.ts +28 -0
- package/src/utils/pikku-cli-config.ts +6 -35
- package/src/utils/schema-generator.ts +7 -3
- package/src/utils/serialize-import-map.ts +0 -4
- package/types/application-types.d.ts +4 -1
- package/types/config.d.ts +15 -3
- package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.d.ts +0 -6
- package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.js +0 -6
- package/dist/src/serialize-pikku-types.d.ts +0 -4
- package/dist/src/serialize-pikku-types.js +0 -605
- package/src/serialize-pikku-types.ts +0 -613
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { dirname } from 'path';
|
|
2
|
-
import { mkdir, readFile, writeFile } from 'fs/promises';
|
|
3
|
-
|
|
2
|
+
import { mkdir, readFile, writeFile, rm } from 'fs/promises';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
import { getCLIVersion } from './get-cli-version.js';
|
|
4
5
|
export const DO_NOT_MODIFY_COMMENT = `/**
|
|
5
|
-
* This file was generated by
|
|
6
|
+
* This file was generated by @pikku/cli@${getCLIVersion()}
|
|
6
7
|
*/
|
|
7
8
|
`;
|
|
8
9
|
export const writeFileInDir = async (logger, path, content, { ignoreModifyComment = false, logWrite = true, } = {}) => {
|
|
@@ -38,3 +39,12 @@ export const writeFileInDir = async (logger, path, content, { ignoreModifyCommen
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
};
|
|
42
|
+
export const removeFileInDir = async (logger, path, { logRemove = true } = {}) => {
|
|
43
|
+
// Check if file exists before attempting removal
|
|
44
|
+
if (existsSync(path)) {
|
|
45
|
+
await rm(path, { force: true });
|
|
46
|
+
if (logRemove) {
|
|
47
|
+
logger.info({ message: `✓ File removed at ${path}`, type: 'success' });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { dirname, join } from 'path';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
// Get package version for generated file comments
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
let version = 'unknown';
|
|
7
|
+
try {
|
|
8
|
+
// Try from src/ first (development), then from dist/src/ (built)
|
|
9
|
+
const pkgPath = join(__dirname, '..', '..', 'package.json');
|
|
10
|
+
const pkgJson = JSON.parse(await readFile(pkgPath, 'utf-8'));
|
|
11
|
+
version = pkgJson.version;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
try {
|
|
15
|
+
const pkgPath = join(__dirname, '..', '..', '..', 'package.json');
|
|
16
|
+
const pkgJson = JSON.parse(await readFile(pkgPath, 'utf-8'));
|
|
17
|
+
version = pkgJson.version;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Fallback to unknown if package.json can't be found
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the CLI version string
|
|
25
|
+
* Works from both src/ and dist/src/ locations
|
|
26
|
+
*/
|
|
27
|
+
export const getCLIVersion = () => version;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PikkuCLIConfig } from '../../types/config.js';
|
|
2
|
-
import { InspectorFilters } from '@pikku/inspector';
|
|
3
2
|
import { CLILogger } from '../services/cli-logger.service.js';
|
|
4
|
-
export declare const getPikkuCLIConfig: (logger: CLILogger, configFile: string | undefined, requiredFields: Array<keyof PikkuCLIConfig>,
|
|
3
|
+
export declare const getPikkuCLIConfig: (logger: CLILogger, configFile: string | undefined, requiredFields: Array<keyof PikkuCLIConfig>, exitProcess?: boolean) => Promise<PikkuCLIConfig>;
|
|
5
4
|
export declare const validateCLIConfig: (cliConfig: PikkuCLIConfig, required: Array<keyof PikkuCLIConfig>) => void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { join, dirname, resolve, isAbsolute } from 'path';
|
|
2
2
|
import { readdir, readFile } from 'fs/promises';
|
|
3
|
-
import { PikkuWiringTypes } from '@pikku/core';
|
|
4
3
|
const CONFIG_DIR_FILES = [
|
|
5
4
|
'nextBackendFile',
|
|
6
5
|
'nextHTTPFile',
|
|
@@ -10,11 +9,11 @@ const CONFIG_DIR_FILES = [
|
|
|
10
9
|
'queueWiringsFile',
|
|
11
10
|
'mcpJsonFile',
|
|
12
11
|
];
|
|
13
|
-
export const getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields,
|
|
14
|
-
const config = await _getPikkuCLIConfig(logger, configFile, requiredFields,
|
|
12
|
+
export const getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields, exitProcess = false) => {
|
|
13
|
+
const config = await _getPikkuCLIConfig(logger, configFile, requiredFields, exitProcess);
|
|
15
14
|
return config;
|
|
16
15
|
};
|
|
17
|
-
const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields,
|
|
16
|
+
const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields, exitProcess = false) => {
|
|
18
17
|
if (!configFile) {
|
|
19
18
|
let execDirectory = process.cwd();
|
|
20
19
|
const files = await readdir(execDirectory);
|
|
@@ -30,7 +29,7 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
30
29
|
const configDir = dirname(configFile);
|
|
31
30
|
const config = JSON.parse(file);
|
|
32
31
|
if (config.extends) {
|
|
33
|
-
const extendedConfig = await getPikkuCLIConfig(logger, resolve(configDir, config.extends), [],
|
|
32
|
+
const extendedConfig = await getPikkuCLIConfig(logger, resolve(configDir, config.extends), [], exitProcess);
|
|
34
33
|
result = {
|
|
35
34
|
...extendedConfig,
|
|
36
35
|
...config,
|
|
@@ -151,6 +150,11 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
151
150
|
if (!result.middlewareGroupsMetaFile) {
|
|
152
151
|
result.middlewareGroupsMetaFile = join(middlewareDir, 'pikku-middleware-groups-meta.gen.ts');
|
|
153
152
|
}
|
|
153
|
+
// Permissions
|
|
154
|
+
const permissionsDir = join(result.outDir, 'permissions');
|
|
155
|
+
if (!result.permissionsFile) {
|
|
156
|
+
result.permissionsFile = join(permissionsDir, 'pikku-permissions.gen.ts');
|
|
157
|
+
}
|
|
154
158
|
// Bootstrap files
|
|
155
159
|
if (!result.bootstrapFile) {
|
|
156
160
|
result.bootstrapFile = join(result.outDir, 'pikku-bootstrap.gen.ts');
|
|
@@ -181,11 +185,6 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
181
185
|
if (!result.cliTypesFile) {
|
|
182
186
|
result.cliTypesFile = join(cliDir, 'pikku-cli-types.gen.ts');
|
|
183
187
|
}
|
|
184
|
-
result.bootstrapFiles = result.bootstrapFiles || {};
|
|
185
|
-
for (const key of Object.keys(PikkuWiringTypes)) {
|
|
186
|
-
const eventDir = join(result.outDir, key.toLowerCase());
|
|
187
|
-
result.bootstrapFiles[key] = join(eventDir, `pikku-bootstrap-${key}.gen.ts`);
|
|
188
|
-
}
|
|
189
188
|
if (requiredFields.length > 0) {
|
|
190
189
|
validateCLIConfig(result, requiredFields);
|
|
191
190
|
}
|
|
@@ -202,24 +201,6 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
202
201
|
}
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
|
-
// Separately normalize bootstrapFiles (Record<string, string>)
|
|
206
|
-
if (result.bootstrapFiles && typeof result.bootstrapFiles === 'object') {
|
|
207
|
-
for (const [key, value] of Object.entries(result.bootstrapFiles)) {
|
|
208
|
-
if (typeof value === 'string' && !isAbsolute(value)) {
|
|
209
|
-
result.bootstrapFiles[key] = join(result.rootDir, value);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
result.filters = result.filters || {};
|
|
214
|
-
if (filters.tags && filters.tags.length > 0) {
|
|
215
|
-
result.filters.tags = filters.tags;
|
|
216
|
-
}
|
|
217
|
-
if (filters.types && filters.types.length > 0) {
|
|
218
|
-
result.filters.types = filters.types;
|
|
219
|
-
}
|
|
220
|
-
if (filters.directories && filters.directories.length > 0) {
|
|
221
|
-
result.filters.directories = filters.directories;
|
|
222
|
-
}
|
|
223
204
|
if (!isAbsolute(result.tsconfig)) {
|
|
224
205
|
result.tsconfig = join(result.rootDir, result.tsconfig);
|
|
225
206
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createGenerator, RootlessError } from 'ts-json-schema-generator';
|
|
2
2
|
import { writeFileInDir } from './file-writer.js';
|
|
3
3
|
import { mkdir, writeFile } from 'fs/promises';
|
|
4
|
+
import { ErrorCode } from '@pikku/inspector';
|
|
4
5
|
export async function generateSchemas(logger, tsconfig, typesMap, functionMeta, httpWiringsMeta, additionalTypes) {
|
|
5
6
|
const schemasSet = new Set(typesMap.customTypes.keys());
|
|
6
7
|
for (const { inputs, outputs } of Object.values(functionMeta)) {
|
|
@@ -51,10 +52,10 @@ export async function generateSchemas(logger, tsconfig, typesMap, functionMeta,
|
|
|
51
52
|
catch (e) {
|
|
52
53
|
// Ignore rootless errors
|
|
53
54
|
if (e instanceof RootlessError) {
|
|
54
|
-
logger.error(`Error generating schema since it has no root: ${schema}`);
|
|
55
|
+
logger.error(`[${ErrorCode.SCHEMA_NO_ROOT}] Error generating schema since it has no root: ${schema}`);
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
|
-
logger.error(`Error generating schema: ${schema}`);
|
|
58
|
+
logger.error(`[${ErrorCode.SCHEMA_GENERATION_ERROR}] Error generating schema: ${schema}. Message: ${e.message}`);
|
|
58
59
|
}
|
|
59
60
|
});
|
|
60
61
|
return schemas;
|
|
@@ -69,9 +69,6 @@ export const serializeImportMap = (relativeToPath, packageMappings, typesMap, re
|
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
const variables = paths.get(path) || [];
|
|
72
|
-
if (uniqueName === '__object') {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
72
|
const importName = originalName === uniqueName
|
|
76
73
|
? originalName
|
|
77
74
|
: `${originalName} as ${uniqueName}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../bin/pikku.ts","../src/cli.wiring.ts","../src/
|
|
1
|
+
{"root":["../bin/pikku.ts","../src/cli.wiring.ts","../src/services.ts","../src/functions/commands/all.ts","../src/functions/commands/watch.ts","../src/functions/runtimes/nextjs/pikku-command-nextjs.ts","../src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts","../src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts","../src/functions/wirings/channels/pikku-channels.ts","../src/functions/wirings/channels/pikku-command-channel-types.ts","../src/functions/wirings/channels/pikku-command-channels-map.ts","../src/functions/wirings/channels/pikku-command-channels.ts","../src/functions/wirings/channels/pikku-command-websocket-typed.ts","../src/functions/wirings/channels/serialize-channel-types.ts","../src/functions/wirings/channels/serialize-typed-channel-map.ts","../src/functions/wirings/channels/serialize-websocket-wrapper.ts","../src/functions/wirings/cli/pikku-command-cli-entry.ts","../src/functions/wirings/cli/pikku-command-cli-types.ts","../src/functions/wirings/cli/pikku-command-cli.ts","../src/functions/wirings/cli/serialize-channel-cli-client.ts","../src/functions/wirings/cli/serialize-channel-cli.ts","../src/functions/wirings/cli/serialize-cli-types.ts","../src/functions/wirings/cli/serialize-local-cli-bootstrap.ts","../src/functions/wirings/fetch/index.ts","../src/functions/wirings/functions/pikku-command-function-types-split.ts","../src/functions/wirings/functions/pikku-command-function-types.ts","../src/functions/wirings/functions/pikku-command-functions.ts","../src/functions/wirings/functions/pikku-command-services.ts","../src/functions/wirings/functions/pikku-function-types.ts","../src/functions/wirings/functions/schemas.ts","../src/functions/wirings/functions/serialize-function-imports.ts","../src/functions/wirings/functions/serialize-function-types.ts","../src/functions/wirings/functions/serialize-pikku-types-hub.ts","../src/functions/wirings/http/openapi-spec-generator.ts","../src/functions/wirings/http/pikku-command-http-map.ts","../src/functions/wirings/http/pikku-command-http-routes.ts","../src/functions/wirings/http/pikku-command-http-types.ts","../src/functions/wirings/http/pikku-command-openapi.ts","../src/functions/wirings/http/pikku-http-routes.ts","../src/functions/wirings/http/serialize-fetch-wrapper.ts","../src/functions/wirings/http/serialize-http-types.ts","../src/functions/wirings/http/serialize-typed-http-map.ts","../src/functions/wirings/mcp/pikku-command-mcp-json.ts","../src/functions/wirings/mcp/pikku-command-mcp-types.ts","../src/functions/wirings/mcp/pikku-command-mcp.ts","../src/functions/wirings/mcp/serialize-mcp-json.ts","../src/functions/wirings/mcp/serialize-mcp-types.ts","../src/functions/wirings/middleware/pikku-command-middleware.ts","../src/functions/wirings/middleware/serialize-middleware-groups-meta.ts","../src/functions/wirings/middleware/serialize-middleware-imports.ts","../src/functions/wirings/permissions/pikku-command-permissions.ts","../src/functions/wirings/permissions/serialize-permissions-imports.ts","../src/functions/wirings/queue/pikku-command-queue-map.ts","../src/functions/wirings/queue/pikku-command-queue-service.ts","../src/functions/wirings/queue/pikku-command-queue-types.ts","../src/functions/wirings/queue/pikku-command-queue.ts","../src/functions/wirings/queue/pikku-queue-map.ts","../src/functions/wirings/queue/pikku-queue.ts","../src/functions/wirings/queue/serialize-queue-map.ts","../src/functions/wirings/queue/serialize-queue-meta.ts","../src/functions/wirings/queue/serialize-queue-types.ts","../src/functions/wirings/queue/serialize-queue-wrapper.ts","../src/functions/wirings/rpc/pikku-command-rpc-client.ts","../src/functions/wirings/rpc/pikku-command-rpc-map.ts","../src/functions/wirings/rpc/pikku-command-rpc.ts","../src/functions/wirings/rpc/serialize-rpc-wrapper.ts","../src/functions/wirings/rpc/serialize-typed-rpc-map.ts","../src/functions/wirings/scheduler/pikku-command-scheduler-types.ts","../src/functions/wirings/scheduler/pikku-command-scheduler.ts","../src/functions/wirings/scheduler/serialize-scheduler-meta.ts","../src/functions/wirings/scheduler/serialize-scheduler-types.ts","../src/middleware/log-command-info-and-time.ts","../src/services/cli-logger-forwarder.service.ts","../src/services/cli-logger.service.ts","../src/utils/check-required-types.ts","../src/utils/custom-types-generator.ts","../src/utils/file-import-path.ts","../src/utils/file-imports-serializer.ts","../src/utils/file-writer.ts","../src/utils/generate-bootstrap-file.ts","../src/utils/get-cli-version.ts","../src/utils/pikku-cli-config.ts","../src/utils/pikku-files-and-methods.ts","../src/utils/schema-generator.ts","../src/utils/serialize-import-map.ts","../.pikku/pikku-bootstrap.gen.ts","../.pikku/pikku-services.gen.ts","../.pikku/pikku-types.gen.ts","../.pikku/pikku-websocket.gen.ts","../.pikku/channel/pikku-channel-types.gen.ts","../.pikku/channel/pikku-channels-map.gen.d.ts","../.pikku/channel/pikku-channels-meta.gen.ts","../.pikku/channel/pikku-channels.gen.ts","../.pikku/cli/pikku-cli-channel.gen.ts","../.pikku/cli/pikku-cli-client.gen.ts","../.pikku/cli/pikku-cli-types.gen.ts","../.pikku/cli/pikku-cli-wirings-meta.gen.ts","../.pikku/cli/pikku-cli-wirings.gen.ts","../.pikku/cli/pikku-cli.gen.ts","../.pikku/function/pikku-function-types.gen.ts","../.pikku/function/pikku-functions-meta.gen.ts","../.pikku/function/pikku-functions-meta.min.gen.ts","../.pikku/function/pikku-functions.gen.ts","../.pikku/http/pikku-http-types.gen.ts","../.pikku/http/pikku-http-wirings-map.gen.d.ts","../.pikku/http/pikku-http-wirings-meta.gen.ts","../.pikku/http/pikku-http-wirings.gen.ts","../.pikku/mcp/pikku-mcp-types.gen.ts","../.pikku/mcp/pikku-mcp-wirings-meta.gen.ts","../.pikku/mcp/pikku-mcp-wirings.gen.ts","../.pikku/queue/pikku-queue-types.gen.ts","../.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts","../.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts","../.pikku/queue/pikku-queue-workers-wirings.gen.ts","../.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts","../.pikku/scheduler/pikku-scheduler-types.gen.ts","../.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts","../.pikku/scheduler/pikku-schedulers-wirings.gen.ts","../.pikku/schemas/register.gen.ts","../types/application-types.d.ts","../types/config.d.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -21,22 +21,24 @@
|
|
|
21
21
|
"test:coverage": "bash run-tests.sh --coverage"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@openapi-contrib/json-schema-to-openapi-schema": "^4.0
|
|
25
|
-
"@pikku/core": "^0.
|
|
26
|
-
"@pikku/inspector": "^0.
|
|
24
|
+
"@openapi-contrib/json-schema-to-openapi-schema": "^4.2.0",
|
|
25
|
+
"@pikku/core": "^0.10.0",
|
|
26
|
+
"@pikku/inspector": "^0.10.0",
|
|
27
27
|
"@types/cookie": "^1.0.0",
|
|
28
|
-
"@types/
|
|
29
|
-
"
|
|
28
|
+
"@types/json-schema": "^7.0.15",
|
|
29
|
+
"@types/uuid": "^11.0.0",
|
|
30
|
+
"chalk": "^5.6.2",
|
|
30
31
|
"chokidar": "^4.0.3",
|
|
31
32
|
"commander": "^14",
|
|
32
|
-
"
|
|
33
|
+
"openapi-types": "^12.1.3",
|
|
34
|
+
"path-to-regexp": "^8.3.0",
|
|
33
35
|
"tinyglobby": "^0.2.12",
|
|
34
36
|
"ts-json-schema-generator": "^2.4.0",
|
|
35
37
|
"typescript": "^5.9",
|
|
36
38
|
"yaml": "^2.8.1"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^24.
|
|
41
|
+
"@types/node": "^24.9.1"
|
|
40
42
|
},
|
|
41
43
|
"engines": {
|
|
42
44
|
"node": ">=18"
|
package/pikku.config.json
CHANGED
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
".pikku/cli/pikku-cli.gen.ts",
|
|
16
16
|
{
|
|
17
17
|
"type": "channel",
|
|
18
|
-
"wirePath": ".pikku/cli/pikku-channel.
|
|
19
|
-
"path": ".pikku/cli/pikku-
|
|
18
|
+
"wirePath": ".pikku/cli/pikku-cli-channel.gen.ts",
|
|
19
|
+
"path": ".pikku/cli/pikku-cli-client.gen.ts",
|
|
20
|
+
"name": "pikku-cli",
|
|
21
|
+
"route": "/cli/pikku"
|
|
20
22
|
}
|
|
21
23
|
]
|
|
22
24
|
}
|
package/src/cli.wiring.ts
CHANGED
|
@@ -1,75 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { pikkuSchemas } from './functions/wirings/functions/schemas.js'
|
|
2
|
+
import { pikkuFetch } from './functions/wirings/fetch/index.js'
|
|
3
|
+
import { pikkuWebSocketTyped } from './functions/wirings/channels/pikku-command-websocket-typed.js'
|
|
4
|
+
import { pikkuRPCClient } from './functions/wirings/rpc/pikku-command-rpc-client.js'
|
|
5
|
+
import { pikkuQueueService } from './functions/wirings/queue/pikku-command-queue-service.js'
|
|
6
|
+
import { pikkuOpenAPI } from './functions/wirings/http/pikku-command-openapi.js'
|
|
7
|
+
import { pikkuNext } from './functions/runtimes/nextjs/pikku-command-nextjs.js'
|
|
8
|
+
import { pikkuCLICommand, wireCLI } from '../.pikku/cli/pikku-cli-types.gen.js'
|
|
9
|
+
import { all } from './functions/commands/all.js'
|
|
10
|
+
import { clientCLIRenderer } from './services.js'
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
12
|
+
wireCLI({
|
|
13
|
+
program: 'pikku',
|
|
14
|
+
description:
|
|
15
|
+
'Pikku CLI - Code generation tool for type-safe backend development',
|
|
16
|
+
render: clientCLIRenderer,
|
|
17
|
+
options: {
|
|
18
|
+
config: {
|
|
19
|
+
description: 'Path to pikku.config.json file',
|
|
20
|
+
short: 'c',
|
|
21
|
+
},
|
|
22
|
+
logLevel: {
|
|
23
|
+
description: 'Set log level',
|
|
24
|
+
default: 'info' as const,
|
|
25
|
+
short: 'l',
|
|
26
|
+
},
|
|
27
|
+
userSessionType: {
|
|
28
|
+
description:
|
|
29
|
+
'Specify which UserSession type to use (when multiple exist)',
|
|
30
|
+
},
|
|
31
|
+
singletonServicesFactoryType: {
|
|
32
|
+
description: 'Specify which singleton services factory to use',
|
|
33
|
+
},
|
|
34
|
+
sessionServicesFactoryType: {
|
|
35
|
+
description: 'Specify which session services factory to use',
|
|
36
|
+
},
|
|
37
|
+
stateOutput: {
|
|
38
|
+
description: 'Save inspector state to JSON file for reuse',
|
|
39
|
+
},
|
|
40
|
+
stateInput: {
|
|
41
|
+
description: 'Load inspector state from JSON file (skips inspection)',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
commands: {
|
|
45
|
+
all: pikkuCLICommand({
|
|
46
|
+
func: all,
|
|
47
|
+
description: 'Generate all Pikku files (types, schemas, wirings, etc.)',
|
|
48
|
+
isDefault: true,
|
|
49
|
+
options: {
|
|
50
|
+
tags: {
|
|
51
|
+
description: 'Filter functions by tags (comma-separated)',
|
|
52
|
+
short: 't',
|
|
53
|
+
},
|
|
54
|
+
types: {
|
|
55
|
+
description: 'Filter functions by types (comma-separated)',
|
|
56
|
+
},
|
|
57
|
+
directories: {
|
|
58
|
+
description: 'Filter functions by directories (comma-separated)',
|
|
59
|
+
short: 'd',
|
|
60
|
+
},
|
|
61
|
+
httpMethods: {
|
|
62
|
+
description: 'Filter HTTP routes by methods (comma-separated)',
|
|
63
|
+
},
|
|
64
|
+
httpRoutes: {
|
|
65
|
+
description: 'Filter HTTP routes by route patterns (comma-separated)',
|
|
66
|
+
},
|
|
67
|
+
names: {
|
|
68
|
+
description: 'Filter functions by name patterns (supports wildcards)',
|
|
69
|
+
short: 'n',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
schemas: pikkuCLICommand({
|
|
74
|
+
func: pikkuSchemas,
|
|
75
|
+
description: 'Generate JSON schemas for function input/output types',
|
|
76
|
+
}),
|
|
77
|
+
fetch: pikkuCLICommand({
|
|
78
|
+
func: pikkuFetch,
|
|
79
|
+
description: 'Generate type-safe HTTP fetch client',
|
|
80
|
+
}),
|
|
81
|
+
websocket: pikkuCLICommand({
|
|
82
|
+
func: pikkuWebSocketTyped,
|
|
83
|
+
description: 'Generate type-safe WebSocket client',
|
|
84
|
+
}),
|
|
85
|
+
rpc: pikkuCLICommand({
|
|
86
|
+
func: pikkuRPCClient,
|
|
87
|
+
description: 'Generate RPC client wrappers',
|
|
88
|
+
}),
|
|
89
|
+
'queue-service': pikkuCLICommand({
|
|
90
|
+
func: pikkuQueueService,
|
|
91
|
+
description: 'Generate queue service wrapper',
|
|
92
|
+
}),
|
|
93
|
+
openapi: pikkuCLICommand({
|
|
94
|
+
func: pikkuOpenAPI,
|
|
95
|
+
description: 'Generate OpenAPI specification from HTTP routes',
|
|
96
|
+
}),
|
|
97
|
+
nextjs: pikkuCLICommand({
|
|
98
|
+
func: pikkuNext,
|
|
99
|
+
description: 'Generate Next.js backend and HTTP wrappers',
|
|
100
|
+
}),
|
|
101
|
+
},
|
|
102
|
+
})
|
|
@@ -38,6 +38,13 @@ export const all: any = pikkuVoidFunc({
|
|
|
38
38
|
allImports.push(config.middlewareFile)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// Generate and register permissions
|
|
42
|
+
const permissions = await rpc.invoke('pikkuPermissions', null)
|
|
43
|
+
// Permissions must be imported before functions meta to ensure registration happens first
|
|
44
|
+
if (permissions) {
|
|
45
|
+
allImports.push(config.permissionsFile)
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
// Always import functions meta (needed for all function metadata)
|
|
42
49
|
allImports.push(config.functionsMetaFile)
|
|
43
50
|
|
|
@@ -137,5 +144,10 @@ export const all: any = pikkuVoidFunc({
|
|
|
137
144
|
.sort((to) => (to.includes('meta') ? -1 : 1)) // Ensure meta files are at the top
|
|
138
145
|
.join('\n')
|
|
139
146
|
)
|
|
147
|
+
|
|
148
|
+
// Check for critical errors and exit if any were logged
|
|
149
|
+
if (logger.hasCriticalErrors()) {
|
|
150
|
+
process.exit(1)
|
|
151
|
+
}
|
|
140
152
|
},
|
|
141
153
|
})
|
|
@@ -14,16 +14,20 @@ export const pikkuNext: any = pikkuSessionlessFunc<void, void>({
|
|
|
14
14
|
httpMapDeclarationFile,
|
|
15
15
|
packageMappings,
|
|
16
16
|
fetchFile,
|
|
17
|
-
bootstrapFiles,
|
|
18
17
|
} = config
|
|
19
|
-
const visitState = await getInspectorState()
|
|
20
18
|
|
|
19
|
+
// If both files are undefined, clean up any existing files and return
|
|
21
20
|
if (!nextBackendFile && !nextHTTPFile) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
logger.info({
|
|
22
|
+
message:
|
|
23
|
+
'Skipping generating nextjs wrapper since nextjs outfile is not defined.',
|
|
24
|
+
type: 'skip',
|
|
25
|
+
})
|
|
26
|
+
return
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
const visitState = await getInspectorState()
|
|
30
|
+
|
|
27
31
|
if (nextHTTPFile && !fetchFile) {
|
|
28
32
|
throw new Error(
|
|
29
33
|
'fetchFile is required in pikku config in order for nextJS http wrapper to work'
|
|
@@ -56,9 +60,9 @@ export const pikkuNext: any = pikkuSessionlessFunc<void, void>({
|
|
|
56
60
|
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`
|
|
57
61
|
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`
|
|
58
62
|
|
|
59
|
-
const
|
|
63
|
+
const bootstrapPath = getFileImportRelativePath(
|
|
60
64
|
nextBackendFile,
|
|
61
|
-
|
|
65
|
+
config.bootstrapFile,
|
|
62
66
|
packageMappings
|
|
63
67
|
)
|
|
64
68
|
|
|
@@ -69,7 +73,7 @@ export const pikkuNext: any = pikkuSessionlessFunc<void, void>({
|
|
|
69
73
|
)
|
|
70
74
|
|
|
71
75
|
const content = serializeNextBackendWrapper(
|
|
72
|
-
|
|
76
|
+
bootstrapPath,
|
|
73
77
|
routesMapDeclarationPath,
|
|
74
78
|
pikkuConfigImport,
|
|
75
79
|
singletonServicesImport,
|
|
@@ -102,10 +106,6 @@ export const pikkuNext: any = pikkuSessionlessFunc<void, void>({
|
|
|
102
106
|
logCommandInfoAndTime({
|
|
103
107
|
commandStart: 'Generating nextjs wrapper',
|
|
104
108
|
commandEnd: 'Generated nextjs wrapper',
|
|
105
|
-
skipCondition: ({ config }) =>
|
|
106
|
-
config.nextBackendFile === undefined &&
|
|
107
|
-
config.nextHTTPFile === undefined,
|
|
108
|
-
skipMessage: 'nextjs outfile is not defined',
|
|
109
109
|
}),
|
|
110
110
|
],
|
|
111
111
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const serializeNextJsBackendWrapper = (
|
|
2
|
-
|
|
2
|
+
bootstrapPath: string,
|
|
3
3
|
routesMapPath: string,
|
|
4
4
|
configImport: string,
|
|
5
5
|
singleServicesFactoryImport: string,
|
|
@@ -18,7 +18,7 @@ ${configImport}
|
|
|
18
18
|
${singleServicesFactoryImport}
|
|
19
19
|
${sessionServicesImport}
|
|
20
20
|
|
|
21
|
-
import '${
|
|
21
|
+
import '${bootstrapPath}'
|
|
22
22
|
|
|
23
23
|
let _pikku: PikkuNextJS | undefined
|
|
24
24
|
|
|
@@ -30,11 +30,6 @@ export const pikkuChannels: any = pikkuVoidFunc({
|
|
|
30
30
|
logCommandInfoAndTime({
|
|
31
31
|
commandStart: 'Finding Channels',
|
|
32
32
|
commandEnd: 'Found channels',
|
|
33
|
-
skipCondition: async ({ getInspectorState }: any) => {
|
|
34
|
-
const visitState = await getInspectorState()
|
|
35
|
-
return visitState.channels.files.size === 0
|
|
36
|
-
},
|
|
37
|
-
skipMessage: 'none found',
|
|
38
33
|
}),
|
|
39
34
|
],
|
|
40
35
|
})
|
|
@@ -21,11 +21,6 @@ export const pikkuChannelsMap: any = pikkuSessionlessFunc<void, void>({
|
|
|
21
21
|
logCommandInfoAndTime({
|
|
22
22
|
commandStart: 'Creating channels map',
|
|
23
23
|
commandEnd: 'Created channels map',
|
|
24
|
-
skipCondition: async ({ getInspectorState }) => {
|
|
25
|
-
const state = await getInspectorState()
|
|
26
|
-
return state.channels.files.size === 0
|
|
27
|
-
},
|
|
28
|
-
skipMessage: 'none found',
|
|
29
24
|
}),
|
|
30
25
|
],
|
|
31
26
|
})
|
|
@@ -35,11 +35,6 @@ export const pikkuChannels: any = pikkuSessionlessFunc<
|
|
|
35
35
|
logCommandInfoAndTime({
|
|
36
36
|
commandStart: 'Finding Channels',
|
|
37
37
|
commandEnd: 'Found channels',
|
|
38
|
-
skipCondition: async ({ getInspectorState }) => {
|
|
39
|
-
const visitState = await getInspectorState()
|
|
40
|
-
return visitState.channels.files.size === 0
|
|
41
|
-
},
|
|
42
|
-
skipMessage: 'none found',
|
|
43
38
|
}),
|
|
44
39
|
],
|
|
45
40
|
})
|
|
@@ -9,8 +9,14 @@ export const pikkuWebSocketTyped: any = pikkuSessionlessFunc<void, void>({
|
|
|
9
9
|
const { websocketFile, channelsMapDeclarationFile, packageMappings } =
|
|
10
10
|
config
|
|
11
11
|
|
|
12
|
+
// If websocketFile is not set, clean up any existing file and return
|
|
12
13
|
if (!websocketFile) {
|
|
13
|
-
|
|
14
|
+
logger.info({
|
|
15
|
+
message:
|
|
16
|
+
"Skipping generating websocket wrapper since websocketFile isn't set in the pikku config.",
|
|
17
|
+
type: 'skip',
|
|
18
|
+
})
|
|
19
|
+
return
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
const channelsMapDeclarationPath = getFileImportRelativePath(
|
|
@@ -26,8 +32,6 @@ export const pikkuWebSocketTyped: any = pikkuSessionlessFunc<void, void>({
|
|
|
26
32
|
logCommandInfoAndTime({
|
|
27
33
|
commandStart: 'Generating websocket wrapper',
|
|
28
34
|
commandEnd: 'Generated websocket wrapper',
|
|
29
|
-
skipCondition: ({ config }) => config.websocketFile === undefined,
|
|
30
|
-
skipMessage: "websocketFile isn't set in the pikku config",
|
|
31
35
|
}),
|
|
32
36
|
],
|
|
33
37
|
})
|