@pikku/cli 0.7.3 → 0.7.5
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 +16 -0
- package/bin/pikku-all.ts +0 -1
- package/bin/pikku-functions.ts +67 -8
- package/bin/pikku-rpc-map.ts +1 -1
- package/bin/pikku-rpc.ts +3 -60
- package/dist/bin/pikku-all.js +0 -1
- package/dist/bin/pikku-functions.d.ts +5 -1
- package/dist/bin/pikku-functions.js +32 -5
- package/dist/bin/pikku-rpc-map.js +1 -1
- package/dist/bin/pikku-rpc.d.ts +1 -5
- package/dist/bin/pikku-rpc.js +3 -32
- package/dist/src/pikku-cli-config.d.ts +0 -1
- package/dist/src/pikku-cli-config.js +0 -3
- package/package.json +3 -3
- package/src/pikku-cli-config.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @pikku/cli
|
|
2
2
|
|
|
3
|
+
## 0.7.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- faa1369: refactor: moving function imports into pikku-fun.gen file
|
|
8
|
+
- Updated dependencies [faa1369]
|
|
9
|
+
- @pikku/inspector@0.7.6
|
|
10
|
+
|
|
11
|
+
## 0.7.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 6af8a19: fix: always write functions meta data
|
|
16
|
+
- Updated dependencies [6af8a19]
|
|
17
|
+
- @pikku/core@0.7.7
|
|
18
|
+
|
|
3
19
|
## 0.7.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/bin/pikku-all.ts
CHANGED
|
@@ -70,7 +70,6 @@ const runAll = async (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
70
70
|
await pikkuRPC(cliConfig, visitState)
|
|
71
71
|
await pikkuRPCMap(cliConfig, visitState)
|
|
72
72
|
addImport(cliConfig.rpcMetaFile, 'meta')
|
|
73
|
-
addImport(cliConfig.rpcFile, 'events')
|
|
74
73
|
|
|
75
74
|
const routes = await pikkuHTTP(cliConfig, visitState)
|
|
76
75
|
if (routes) {
|
package/bin/pikku-functions.ts
CHANGED
|
@@ -1,18 +1,77 @@
|
|
|
1
1
|
import { PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
2
2
|
import { InspectorState } from '@pikku/inspector'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getFileImportRelativePath,
|
|
5
|
+
logCommandInfoAndTime,
|
|
6
|
+
writeFileInDir,
|
|
7
|
+
} from '../src/utils/utils.js'
|
|
8
|
+
|
|
9
|
+
export const serializeFunctionImports = (
|
|
10
|
+
outputPath: string,
|
|
11
|
+
functionsMap: Map<string, { path: string; exportedName: string }>,
|
|
12
|
+
packageMappings: Record<string, string> = {}
|
|
13
|
+
) => {
|
|
14
|
+
const serializedImports: string[] = [
|
|
15
|
+
`/* Import and register RPCs */`,
|
|
16
|
+
`import { addFunction } from '@pikku/core'`,
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
const serializedRegistrations: string[] = []
|
|
20
|
+
|
|
21
|
+
// Sort by function name for consistent output
|
|
22
|
+
const sortedEntries = Array.from(functionsMap.entries()).sort((a, b) =>
|
|
23
|
+
a[0].localeCompare(b[0])
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
for (const [name, { path, exportedName }] of sortedEntries) {
|
|
27
|
+
const filePath = getFileImportRelativePath(
|
|
28
|
+
outputPath,
|
|
29
|
+
path,
|
|
30
|
+
packageMappings
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// For directly exported functions, we can just import and register them
|
|
34
|
+
if (name === exportedName) {
|
|
35
|
+
serializedImports.push(`import { ${exportedName} } from '${filePath}'`)
|
|
36
|
+
serializedRegistrations.push(
|
|
37
|
+
`addFunction('${name}', { func: ${exportedName} })`
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
// For renamed functions, we need to import and alias them
|
|
41
|
+
else {
|
|
42
|
+
serializedImports.push(
|
|
43
|
+
`import { ${exportedName} as ${name} } from '${filePath}'`
|
|
44
|
+
)
|
|
45
|
+
serializedRegistrations.push(`addFunction('${name}', ${name})`)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Add a blank line between imports and registrations
|
|
50
|
+
if (serializedImports.length > 0 && serializedRegistrations.length > 0) {
|
|
51
|
+
serializedImports.push('')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Combine the imports and registrations
|
|
55
|
+
return [...serializedImports, ...serializedRegistrations].join('\n')
|
|
56
|
+
}
|
|
4
57
|
|
|
5
58
|
export const pikkuFunctions = async (
|
|
6
|
-
|
|
7
|
-
|
|
59
|
+
{ functionsMetaFile, functionsFile, packageMappings }: PikkuCLIConfig,
|
|
60
|
+
{ functions }: InspectorState
|
|
8
61
|
) => {
|
|
9
62
|
return await logCommandInfoAndTime(
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
[
|
|
63
|
+
'Serializing Pikku functions',
|
|
64
|
+
'Serialized Pikku functions',
|
|
65
|
+
[false],
|
|
13
66
|
async () => {
|
|
14
|
-
|
|
15
|
-
|
|
67
|
+
await writeFileInDir(
|
|
68
|
+
functionsFile,
|
|
69
|
+
serializeFunctionImports(
|
|
70
|
+
functionsFile,
|
|
71
|
+
functions.files,
|
|
72
|
+
packageMappings
|
|
73
|
+
)
|
|
74
|
+
)
|
|
16
75
|
await writeFileInDir(
|
|
17
76
|
functionsMetaFile,
|
|
18
77
|
`import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`
|
package/bin/pikku-rpc-map.ts
CHANGED
package/bin/pikku-rpc.ts
CHANGED
|
@@ -1,73 +1,16 @@
|
|
|
1
1
|
import { PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
2
2
|
import { InspectorState } from '@pikku/inspector'
|
|
3
|
-
import {
|
|
4
|
-
getFileImportRelativePath,
|
|
5
|
-
logCommandInfoAndTime,
|
|
6
|
-
writeFileInDir,
|
|
7
|
-
} from '../src/utils/utils.js'
|
|
8
|
-
|
|
9
|
-
export const serializeRPCImports = (
|
|
10
|
-
outputPath: string,
|
|
11
|
-
functionsMap: Map<string, { path: string; exportedName: string }>,
|
|
12
|
-
packageMappings: Record<string, string> = {}
|
|
13
|
-
) => {
|
|
14
|
-
const serializedImports: string[] = [
|
|
15
|
-
`/* Import and register RPCs */`,
|
|
16
|
-
`import { addFunction } from '@pikku/core'`,
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
const serializedRegistrations: string[] = []
|
|
20
|
-
|
|
21
|
-
// Sort by function name for consistent output
|
|
22
|
-
const sortedEntries = Array.from(functionsMap.entries()).sort((a, b) =>
|
|
23
|
-
a[0].localeCompare(b[0])
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
for (const [name, { path, exportedName }] of sortedEntries) {
|
|
27
|
-
const filePath = getFileImportRelativePath(
|
|
28
|
-
outputPath,
|
|
29
|
-
path,
|
|
30
|
-
packageMappings
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
// For directly exported functions, we can just import and register them
|
|
34
|
-
if (name === exportedName) {
|
|
35
|
-
serializedImports.push(`import { ${exportedName} } from '${filePath}'`)
|
|
36
|
-
serializedRegistrations.push(
|
|
37
|
-
`addFunction('${name}', { func: ${exportedName} })`
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
// For renamed functions, we need to import and alias them
|
|
41
|
-
else {
|
|
42
|
-
serializedImports.push(
|
|
43
|
-
`import { ${exportedName} as ${name} } from '${filePath}'`
|
|
44
|
-
)
|
|
45
|
-
serializedRegistrations.push(`addFunction('${name}', ${name})`)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Add a blank line between imports and registrations
|
|
50
|
-
if (serializedImports.length > 0 && serializedRegistrations.length > 0) {
|
|
51
|
-
serializedImports.push('')
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Combine the imports and registrations
|
|
55
|
-
return [...serializedImports, ...serializedRegistrations].join('\n')
|
|
56
|
-
}
|
|
3
|
+
import { logCommandInfoAndTime, writeFileInDir } from '../src/utils/utils.js'
|
|
57
4
|
|
|
58
5
|
export const pikkuRPC = async (
|
|
59
|
-
{
|
|
6
|
+
{ rpcMetaFile }: PikkuCLIConfig,
|
|
60
7
|
{ rpc }: InspectorState
|
|
61
8
|
) => {
|
|
62
9
|
return await logCommandInfoAndTime(
|
|
63
10
|
'Finding RPCs tasks',
|
|
64
11
|
'Found RPCs',
|
|
65
|
-
[
|
|
12
|
+
[false],
|
|
66
13
|
async () => {
|
|
67
|
-
await writeFileInDir(
|
|
68
|
-
rpcFile,
|
|
69
|
-
serializeRPCImports(rpcFile, rpc.files, packageMappings)
|
|
70
|
-
)
|
|
71
14
|
await writeFileInDir(
|
|
72
15
|
rpcMetaFile,
|
|
73
16
|
`import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.meta, null, 2)})`
|
package/dist/bin/pikku-all.js
CHANGED
|
@@ -50,7 +50,6 @@ const runAll = async (cliConfig, options) => {
|
|
|
50
50
|
await pikkuRPC(cliConfig, visitState);
|
|
51
51
|
await pikkuRPCMap(cliConfig, visitState);
|
|
52
52
|
addImport(cliConfig.rpcMetaFile, 'meta');
|
|
53
|
-
addImport(cliConfig.rpcFile, 'events');
|
|
54
53
|
const routes = await pikkuHTTP(cliConfig, visitState);
|
|
55
54
|
if (routes) {
|
|
56
55
|
await pikkuHTTPMap(cliConfig, visitState);
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { PikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
2
2
|
import { InspectorState } from '@pikku/inspector';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const serializeFunctionImports: (outputPath: string, functionsMap: Map<string, {
|
|
4
|
+
path: string;
|
|
5
|
+
exportedName: string;
|
|
6
|
+
}>, packageMappings?: Record<string, string>) => string;
|
|
7
|
+
export declare const pikkuFunctions: ({ functionsMetaFile, functionsFile, packageMappings }: PikkuCLIConfig, { functions }: InspectorState) => Promise<boolean>;
|
|
@@ -1,8 +1,35 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../src/utils/utils.js';
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../src/utils/utils.js';
|
|
2
|
+
export const serializeFunctionImports = (outputPath, functionsMap, packageMappings = {}) => {
|
|
3
|
+
const serializedImports = [
|
|
4
|
+
`/* Import and register RPCs */`,
|
|
5
|
+
`import { addFunction } from '@pikku/core'`,
|
|
6
|
+
];
|
|
7
|
+
const serializedRegistrations = [];
|
|
8
|
+
// Sort by function name for consistent output
|
|
9
|
+
const sortedEntries = Array.from(functionsMap.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
10
|
+
for (const [name, { path, exportedName }] of sortedEntries) {
|
|
11
|
+
const filePath = getFileImportRelativePath(outputPath, path, packageMappings);
|
|
12
|
+
// For directly exported functions, we can just import and register them
|
|
13
|
+
if (name === exportedName) {
|
|
14
|
+
serializedImports.push(`import { ${exportedName} } from '${filePath}'`);
|
|
15
|
+
serializedRegistrations.push(`addFunction('${name}', { func: ${exportedName} })`);
|
|
16
|
+
}
|
|
17
|
+
// For renamed functions, we need to import and alias them
|
|
18
|
+
else {
|
|
19
|
+
serializedImports.push(`import { ${exportedName} as ${name} } from '${filePath}'`);
|
|
20
|
+
serializedRegistrations.push(`addFunction('${name}', ${name})`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Add a blank line between imports and registrations
|
|
24
|
+
if (serializedImports.length > 0 && serializedRegistrations.length > 0) {
|
|
25
|
+
serializedImports.push('');
|
|
26
|
+
}
|
|
27
|
+
// Combine the imports and registrations
|
|
28
|
+
return [...serializedImports, ...serializedRegistrations].join('\n');
|
|
29
|
+
};
|
|
30
|
+
export const pikkuFunctions = async ({ functionsMetaFile, functionsFile, packageMappings }, { functions }) => {
|
|
31
|
+
return await logCommandInfoAndTime('Serializing Pikku functions', 'Serialized Pikku functions', [false], async () => {
|
|
32
|
+
await writeFileInDir(functionsFile, serializeFunctionImports(functionsFile, functions.files, packageMappings));
|
|
6
33
|
await writeFileInDir(functionsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`);
|
|
7
34
|
});
|
|
8
35
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logCommandInfoAndTime, writeFileInDir } from '../src/utils/utils.js';
|
|
2
2
|
import { serializeTypedRPCMap } from '../src/serialize-typed-rpc-map.js';
|
|
3
3
|
export const pikkuRPCMap = async ({ rpcMapDeclarationFile, packageMappings }, { functions, rpc }) => {
|
|
4
|
-
return await logCommandInfoAndTime('Creating RPC map', 'Created RPC map', [
|
|
4
|
+
return await logCommandInfoAndTime('Creating RPC map', 'Created RPC map', [false], async () => {
|
|
5
5
|
const content = serializeTypedRPCMap(rpcMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, rpc.meta);
|
|
6
6
|
await writeFileInDir(rpcMapDeclarationFile, content);
|
|
7
7
|
});
|
package/dist/bin/pikku-rpc.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { PikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
2
2
|
import { InspectorState } from '@pikku/inspector';
|
|
3
|
-
export declare const
|
|
4
|
-
path: string;
|
|
5
|
-
exportedName: string;
|
|
6
|
-
}>, packageMappings?: Record<string, string>) => string;
|
|
7
|
-
export declare const pikkuRPC: ({ rpcFile, rpcMetaFile, packageMappings }: PikkuCLIConfig, { rpc }: InspectorState) => Promise<boolean>;
|
|
3
|
+
export declare const pikkuRPC: ({ rpcMetaFile }: PikkuCLIConfig, { rpc }: InspectorState) => Promise<boolean>;
|
package/dist/bin/pikku-rpc.js
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
`/* Import and register RPCs */`,
|
|
5
|
-
`import { addFunction } from '@pikku/core'`,
|
|
6
|
-
];
|
|
7
|
-
const serializedRegistrations = [];
|
|
8
|
-
// Sort by function name for consistent output
|
|
9
|
-
const sortedEntries = Array.from(functionsMap.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
10
|
-
for (const [name, { path, exportedName }] of sortedEntries) {
|
|
11
|
-
const filePath = getFileImportRelativePath(outputPath, path, packageMappings);
|
|
12
|
-
// For directly exported functions, we can just import and register them
|
|
13
|
-
if (name === exportedName) {
|
|
14
|
-
serializedImports.push(`import { ${exportedName} } from '${filePath}'`);
|
|
15
|
-
serializedRegistrations.push(`addFunction('${name}', { func: ${exportedName} })`);
|
|
16
|
-
}
|
|
17
|
-
// For renamed functions, we need to import and alias them
|
|
18
|
-
else {
|
|
19
|
-
serializedImports.push(`import { ${exportedName} as ${name} } from '${filePath}'`);
|
|
20
|
-
serializedRegistrations.push(`addFunction('${name}', ${name})`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
// Add a blank line between imports and registrations
|
|
24
|
-
if (serializedImports.length > 0 && serializedRegistrations.length > 0) {
|
|
25
|
-
serializedImports.push('');
|
|
26
|
-
}
|
|
27
|
-
// Combine the imports and registrations
|
|
28
|
-
return [...serializedImports, ...serializedRegistrations].join('\n');
|
|
29
|
-
};
|
|
30
|
-
export const pikkuRPC = async ({ rpcFile, rpcMetaFile, packageMappings }, { rpc }) => {
|
|
31
|
-
return await logCommandInfoAndTime('Finding RPCs tasks', 'Found RPCs', [rpc.files.size === 0], async () => {
|
|
32
|
-
await writeFileInDir(rpcFile, serializeRPCImports(rpcFile, rpc.files, packageMappings));
|
|
1
|
+
import { logCommandInfoAndTime, writeFileInDir } from '../src/utils/utils.js';
|
|
2
|
+
export const pikkuRPC = async ({ rpcMetaFile }, { rpc }) => {
|
|
3
|
+
return await logCommandInfoAndTime('Finding RPCs tasks', 'Found RPCs', [false], async () => {
|
|
33
4
|
await writeFileInDir(rpcMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.meta, null, 2)})`);
|
|
34
5
|
});
|
|
35
6
|
};
|
|
@@ -62,9 +62,6 @@ const _getPikkuCLIConfig = async (configFile = undefined, requiredFields, tags =
|
|
|
62
62
|
if (!result.functionsMetaFile) {
|
|
63
63
|
result.functionsMetaFile = join(result.outDir, 'pikku-functions-meta.gen.ts');
|
|
64
64
|
}
|
|
65
|
-
if (!result.rpcFile) {
|
|
66
|
-
result.rpcFile = join(result.outDir, 'pikku-rpc.gen.ts');
|
|
67
|
-
}
|
|
68
65
|
if (!result.rpcMetaFile) {
|
|
69
66
|
result.rpcMetaFile = join(result.outDir, 'pikku-rpc-meta.gen.ts');
|
|
70
67
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@openapi-contrib/json-schema-to-openapi-schema": "^3.0.2",
|
|
25
|
-
"@pikku/core": "^0.7.
|
|
26
|
-
"@pikku/inspector": "^0.7.
|
|
25
|
+
"@pikku/core": "^0.7.7",
|
|
26
|
+
"@pikku/inspector": "^0.7.6",
|
|
27
27
|
"@types/cookie": "^0.6.0",
|
|
28
28
|
"@types/uuid": "^10.0.0",
|
|
29
29
|
"chalk": "^5.4.1",
|
package/src/pikku-cli-config.ts
CHANGED
|
@@ -26,7 +26,6 @@ export interface PikkuCLICoreOutputFiles {
|
|
|
26
26
|
channelsMapDeclarationFile: string
|
|
27
27
|
|
|
28
28
|
// RPC
|
|
29
|
-
rpcFile: string
|
|
30
29
|
rpcMetaFile: string
|
|
31
30
|
rpcMapDeclarationFile: string
|
|
32
31
|
|
|
@@ -153,9 +152,6 @@ const _getPikkuCLIConfig = async (
|
|
|
153
152
|
'pikku-functions-meta.gen.ts'
|
|
154
153
|
)
|
|
155
154
|
}
|
|
156
|
-
if (!result.rpcFile) {
|
|
157
|
-
result.rpcFile = join(result.outDir, 'pikku-rpc.gen.ts')
|
|
158
|
-
}
|
|
159
155
|
if (!result.rpcMetaFile) {
|
|
160
156
|
result.rpcMetaFile = join(result.outDir, 'pikku-rpc-meta.gen.ts')
|
|
161
157
|
}
|