@pikku/cli 0.9.2 → 0.9.3

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/bin/pikku-all.ts +10 -3
  3. package/cli.schema.json +4 -0
  4. package/dist/bin/pikku-all.js +7 -3
  5. package/dist/src/pikku-cli-config.d.ts +3 -0
  6. package/dist/src/pikku-cli-config.js +15 -4
  7. package/dist/src/serialize-import-map.js +62 -1
  8. package/dist/src/serialize-pikku-types.js +2 -2
  9. package/dist/src/utils.js +24 -2
  10. package/dist/src/wirings/functions/pikku-command-function-types.js +2 -2
  11. package/dist/src/wirings/functions/pikku-command-functions.d.ts +0 -4
  12. package/dist/src/wirings/functions/pikku-command-functions.js +10 -31
  13. package/dist/src/wirings/functions/pikku-command-services.js +1 -1
  14. package/dist/src/wirings/functions/pikku-function-types.js +2 -2
  15. package/dist/src/wirings/functions/serialize-function-imports.d.ts +6 -0
  16. package/dist/src/wirings/functions/serialize-function-imports.js +59 -0
  17. package/dist/src/wirings/rpc/pikku-command-rpc-client.js +2 -2
  18. package/dist/src/wirings/rpc/pikku-command-rpc-map.d.ts +2 -1
  19. package/dist/src/wirings/rpc/pikku-command-rpc-map.js +9 -3
  20. package/dist/src/wirings/rpc/pikku-command-rpc.js +7 -2
  21. package/dist/src/wirings/rpc/serialize-typed-rpc-map.d.ts +1 -2
  22. package/dist/src/wirings/rpc/serialize-typed-rpc-map.js +2 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +3 -3
  25. package/src/pikku-cli-config.ts +35 -5
  26. package/src/serialize-import-map.ts +67 -2
  27. package/src/serialize-pikku-types.ts +2 -2
  28. package/src/utils.ts +31 -2
  29. package/src/wirings/functions/pikku-command-function-types.ts +6 -2
  30. package/src/wirings/functions/pikku-command-functions.ts +28 -64
  31. package/src/wirings/functions/pikku-command-services.ts +1 -1
  32. package/src/wirings/functions/pikku-function-types.ts +6 -2
  33. package/src/wirings/functions/serialize-function-imports.ts +97 -0
  34. package/src/wirings/rpc/pikku-command-rpc-client.ts +8 -4
  35. package/src/wirings/rpc/pikku-command-rpc-map.ts +27 -4
  36. package/src/wirings/rpc/pikku-command-rpc.ts +16 -6
  37. package/src/wirings/rpc/serialize-typed-rpc-map.ts +4 -5
  38. package/dist/src/wirings/functions/pikku-functions.d.ts +0 -6
  39. package/dist/src/wirings/functions/pikku-functions.js +0 -35
  40. package/dist/src/wirings/rpc/pikku-rpc.d.ts +0 -2
  41. package/dist/src/wirings/rpc/pikku-rpc.js +0 -6
  42. package/src/wirings/functions/pikku-functions.ts +0 -84
  43. package/src/wirings/rpc/pikku-rpc.ts +0 -22
@@ -1,2 +0,0 @@
1
- import { PikkuCommand } from '../../types.js';
2
- export declare const pikkuRPC: PikkuCommand;
@@ -1,6 +0,0 @@
1
- import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
2
- export const pikkuRPC = async (logger, { rpcWiringMetaFile }, { rpc }) => {
3
- return await logCommandInfoAndTime(logger, 'Finding RPCs tasks', 'Found RPCs', [false], async () => {
4
- await writeFileInDir(logger, rpcWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.meta, null, 2)})`);
5
- });
6
- };
@@ -1,84 +0,0 @@
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,22 +0,0 @@
1
- import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js'
2
- import { PikkuCommand } from '../../types.js'
3
-
4
- export const pikkuRPC: PikkuCommand = async (
5
- logger,
6
- { rpcWiringMetaFile },
7
- { rpc }
8
- ) => {
9
- return await logCommandInfoAndTime(
10
- logger,
11
- 'Finding RPCs tasks',
12
- 'Found RPCs',
13
- [false],
14
- async () => {
15
- await writeFileInDir(
16
- logger,
17
- rpcWiringMetaFile,
18
- `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.meta, null, 2)})`
19
- )
20
- }
21
- )
22
- }