@pikku/cli 0.6.17 → 0.6.19
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 +17 -0
- package/bin/pikku-all.ts +5 -1
- package/bin/pikku-nextjs.ts +56 -41
- package/bin/pikku-schemas.ts +1 -0
- package/dist/bin/pikku-all.js +6 -1
- package/dist/bin/pikku-nextjs.js +21 -17
- package/dist/bin/pikku-schemas.js +1 -0
- package/dist/src/nextjs/serialize-nextjs-http-wrapper.js +2 -2
- package/dist/src/schema/schema-generator.js +0 -3
- package/package.json +4 -3
- package/src/nextjs/serialize-nextjs-http-wrapper.ts +2 -2
- package/src/schema/schema-generator.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @pikku/cli
|
|
2
2
|
|
|
3
|
+
## 0.6.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1c8c470: removing a console
|
|
8
|
+
- Updated dependencies [1c8c470]
|
|
9
|
+
- @pikku/core@0.6.23
|
|
10
|
+
|
|
11
|
+
## 0.6.18
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 60b2265: refactor: supporting request and response objects
|
|
16
|
+
- Updated dependencies [60b2265]
|
|
17
|
+
- @pikku/inspector@0.6.4
|
|
18
|
+
- @pikku/core@0.6.22
|
|
19
|
+
|
|
3
20
|
## 0.6.17
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/bin/pikku-all.ts
CHANGED
|
@@ -76,7 +76,9 @@ const runAll = async (cliConfig: PikkuCLIConfig, options: PikkuCLIOptions) => {
|
|
|
76
76
|
addImport(`${cliConfig.schemaDirectory}/register.gen.ts`)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
if (cliConfig.nextBackendFile || cliConfig.nextHTTPFile) {
|
|
80
|
+
await pikkuNext(cliConfig, visitState, options)
|
|
81
|
+
}
|
|
80
82
|
|
|
81
83
|
if (cliConfig.openAPI) {
|
|
82
84
|
logInfo(`• OpenAPI requires a reinspection to pickup new generated types..`)
|
|
@@ -153,6 +155,8 @@ export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
|
153
155
|
|
|
154
156
|
if (options.watch) {
|
|
155
157
|
watch(cliConfig, options)
|
|
158
|
+
} else {
|
|
159
|
+
await runAll(cliConfig, options)
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
162
|
|
package/bin/pikku-nextjs.ts
CHANGED
|
@@ -29,11 +29,14 @@ export const pikkuNext = async (
|
|
|
29
29
|
return await logCommandInfoAndTime(
|
|
30
30
|
'Generating nextjs wrapper',
|
|
31
31
|
'Generated nextjs wrapper',
|
|
32
|
-
[
|
|
32
|
+
[
|
|
33
|
+
nextBackendFile === undefined && nextHTTPFile === undefined,
|
|
34
|
+
'nextjs outfile is not defined',
|
|
35
|
+
],
|
|
33
36
|
async () => {
|
|
34
|
-
if (!nextBackendFile
|
|
37
|
+
if (!nextBackendFile && !nextHTTPFile) {
|
|
35
38
|
throw new Error(
|
|
36
|
-
'nextBackendFile or nextHTTPFile is required in pikku config'
|
|
39
|
+
'nextBackendFile or nextHTTPFile is required in pikku config for nextJS'
|
|
37
40
|
)
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -43,43 +46,44 @@ export const pikkuNext = async (
|
|
|
43
46
|
)
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
if (nextBackendFile) {
|
|
50
|
+
const {
|
|
51
|
+
pikkuConfigFactory,
|
|
52
|
+
singletonServicesFactory,
|
|
53
|
+
sessionServicesFactory,
|
|
54
|
+
} = await getPikkuFilesAndMethods(
|
|
55
|
+
visitState,
|
|
56
|
+
packageMappings,
|
|
57
|
+
nextBackendFile,
|
|
58
|
+
options,
|
|
59
|
+
{
|
|
60
|
+
config: true,
|
|
61
|
+
singletonServicesFactory: true,
|
|
62
|
+
sessionServicesFactory: true,
|
|
63
|
+
}
|
|
64
|
+
)
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
const pikkuConfigImport = `import { ${pikkuConfigFactory.variable} as createConfig } from '${getFileImportRelativePath(nextBackendFile, pikkuConfigFactory.file, packageMappings)}'`
|
|
67
|
+
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`
|
|
68
|
+
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
const routesPath = getFileImportRelativePath(
|
|
71
|
+
nextBackendFile,
|
|
72
|
+
routesFile,
|
|
73
|
+
packageMappings
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
77
|
+
nextBackendFile,
|
|
78
|
+
routesMapDeclarationFile,
|
|
79
|
+
packageMappings
|
|
80
|
+
)
|
|
81
|
+
const schemasPath = getFileImportRelativePath(
|
|
82
|
+
nextBackendFile,
|
|
83
|
+
`${schemaDirectory}/register.gen.ts`,
|
|
84
|
+
packageMappings
|
|
85
|
+
)
|
|
81
86
|
|
|
82
|
-
if (nextBackendFile) {
|
|
83
87
|
const content = serializeNextBackendWrapper(
|
|
84
88
|
routesPath,
|
|
85
89
|
routesMapDeclarationPath,
|
|
@@ -92,10 +96,21 @@ export const pikkuNext = async (
|
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
if (nextHTTPFile) {
|
|
95
|
-
const
|
|
99
|
+
const routesPath = getFileImportRelativePath(
|
|
100
|
+
nextHTTPFile,
|
|
101
|
+
routesFile,
|
|
102
|
+
packageMappings
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
106
|
+
nextHTTPFile,
|
|
107
|
+
routesMapDeclarationFile,
|
|
108
|
+
packageMappings
|
|
109
|
+
)
|
|
110
|
+
|
|
96
111
|
const content = serializeNextHTTPWrapper(
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
routesPath,
|
|
113
|
+
routesMapDeclarationPath
|
|
99
114
|
)
|
|
100
115
|
await writeFileInDir(nextHTTPFile, content)
|
|
101
116
|
}
|
|
@@ -107,7 +122,7 @@ export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
|
107
122
|
logPikkuLogo()
|
|
108
123
|
const cliConfig = await getPikkuCLIConfig(
|
|
109
124
|
options.config,
|
|
110
|
-
['rootDir', 'schemaDirectory', 'configDir'
|
|
125
|
+
['rootDir', 'schemaDirectory', 'configDir'],
|
|
111
126
|
options.tags,
|
|
112
127
|
true
|
|
113
128
|
)
|
package/bin/pikku-schemas.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const pikkuSchemas = async (
|
|
|
10
10
|
{ tsconfig, schemaDirectory, supportsImportAttributes }: PikkuCLIConfig,
|
|
11
11
|
{ http }: InspectorState
|
|
12
12
|
) => {
|
|
13
|
+
console.log('Generating schemas...')
|
|
13
14
|
return await logCommandInfoAndTime(
|
|
14
15
|
'Creating schemas',
|
|
15
16
|
'Created schemas',
|
package/dist/bin/pikku-all.js
CHANGED
|
@@ -50,7 +50,9 @@ const runAll = async (cliConfig, options) => {
|
|
|
50
50
|
if (schemas) {
|
|
51
51
|
addImport(`${cliConfig.schemaDirectory}/register.gen.ts`);
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
if (cliConfig.nextBackendFile || cliConfig.nextHTTPFile) {
|
|
54
|
+
await pikkuNext(cliConfig, visitState, options);
|
|
55
|
+
}
|
|
54
56
|
if (cliConfig.openAPI) {
|
|
55
57
|
logInfo(`• OpenAPI requires a reinspection to pickup new generated types..`);
|
|
56
58
|
visitState = await inspectorGlob(cliConfig.rootDir, cliConfig.routeDirectories, cliConfig.filters);
|
|
@@ -103,6 +105,9 @@ export const action = async (options) => {
|
|
|
103
105
|
if (options.watch) {
|
|
104
106
|
watch(cliConfig, options);
|
|
105
107
|
}
|
|
108
|
+
else {
|
|
109
|
+
await runAll(cliConfig, options);
|
|
110
|
+
}
|
|
106
111
|
};
|
|
107
112
|
export const all = (program) => {
|
|
108
113
|
program
|
package/dist/bin/pikku-nextjs.js
CHANGED
|
@@ -4,38 +4,42 @@ import { getFileImportRelativePath, getPikkuFilesAndMethods, logCommandInfoAndTi
|
|
|
4
4
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
5
5
|
import { inspectorGlob } from '../src/inspector-glob.js';
|
|
6
6
|
export const pikkuNext = async ({ nextBackendFile, nextHTTPFile, routesFile, routesMapDeclarationFile, schemaDirectory, packageMappings, fetchFile, }, visitState, options) => {
|
|
7
|
-
return await logCommandInfoAndTime('Generating nextjs wrapper', 'Generated nextjs wrapper', [
|
|
8
|
-
|
|
9
|
-
|
|
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');
|
|
10
13
|
}
|
|
11
14
|
if (nextHTTPFile && !fetchFile) {
|
|
12
15
|
throw new Error('fetchFile is required in pikku config in order for nextJS http wrapper to work');
|
|
13
16
|
}
|
|
14
|
-
const { pikkuConfigFactory, singletonServicesFactory, sessionServicesFactory, } = await getPikkuFilesAndMethods(visitState, packageMappings, nextBackendFile, options, {
|
|
15
|
-
config: true,
|
|
16
|
-
singletonServicesFactory: true,
|
|
17
|
-
sessionServicesFactory: true,
|
|
18
|
-
});
|
|
19
|
-
const pikkuConfigImport = `import { ${pikkuConfigFactory.variable} as createConfig } from '${getFileImportRelativePath(nextBackendFile, pikkuConfigFactory.file, packageMappings)}'`;
|
|
20
|
-
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`;
|
|
21
|
-
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`;
|
|
22
|
-
const routesPath = getFileImportRelativePath(nextBackendFile, routesFile, packageMappings);
|
|
23
|
-
const routesMapDeclarationPath = getFileImportRelativePath(nextBackendFile, routesMapDeclarationFile, packageMappings);
|
|
24
|
-
const schemasPath = getFileImportRelativePath(nextBackendFile, `${schemaDirectory}/register.gen.ts`, packageMappings);
|
|
25
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 routesPath = getFileImportRelativePath(nextBackendFile, routesFile, packageMappings);
|
|
27
|
+
const routesMapDeclarationPath = getFileImportRelativePath(nextBackendFile, routesMapDeclarationFile, packageMappings);
|
|
28
|
+
const schemasPath = getFileImportRelativePath(nextBackendFile, `${schemaDirectory}/register.gen.ts`, packageMappings);
|
|
26
29
|
const content = serializeNextBackendWrapper(routesPath, routesMapDeclarationPath, schemasPath, pikkuConfigImport, singletonServicesImport, sessionServicesImport);
|
|
27
30
|
await writeFileInDir(nextBackendFile, content);
|
|
28
31
|
}
|
|
29
32
|
if (nextHTTPFile) {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
33
|
+
const routesPath = getFileImportRelativePath(nextHTTPFile, routesFile, packageMappings);
|
|
34
|
+
const routesMapDeclarationPath = getFileImportRelativePath(nextHTTPFile, routesMapDeclarationFile, packageMappings);
|
|
35
|
+
const content = serializeNextHTTPWrapper(routesPath, routesMapDeclarationPath);
|
|
32
36
|
await writeFileInDir(nextHTTPFile, content);
|
|
33
37
|
}
|
|
34
38
|
});
|
|
35
39
|
};
|
|
36
40
|
export const action = async (options) => {
|
|
37
41
|
logPikkuLogo();
|
|
38
|
-
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir'
|
|
42
|
+
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir'], options.tags, true);
|
|
39
43
|
const visitState = await inspectorGlob(cliConfig.rootDir, cliConfig.routeDirectories, cliConfig.filters);
|
|
40
44
|
await pikkuNext(cliConfig, visitState, options);
|
|
41
45
|
};
|
|
@@ -3,6 +3,7 @@ import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
|
3
3
|
import { logCommandInfoAndTime, logPikkuLogo } from '../src/utils.js';
|
|
4
4
|
import { inspectorGlob } from '../src/inspector-glob.js';
|
|
5
5
|
export const pikkuSchemas = async ({ tsconfig, schemaDirectory, supportsImportAttributes }, { http }) => {
|
|
6
|
+
console.log('Generating schemas...');
|
|
6
7
|
return await logCommandInfoAndTime('Creating schemas', 'Created schemas', [false], async () => {
|
|
7
8
|
const schemas = await generateSchemas(tsconfig, http.typesMap, http.meta);
|
|
8
9
|
await saveSchemas(schemaDirectory, schemas, http.typesMap, http.meta, supportsImportAttributes);
|
|
@@ -30,7 +30,7 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
30
30
|
method: Method,
|
|
31
31
|
data: RouteHandlerOf<Route, Method>['input'] = null
|
|
32
32
|
): Promise<RouteHandlerOf<Route, Method>['output']> => {
|
|
33
|
-
return (_pikku! as any)[method](route, data as any)
|
|
33
|
+
return (_pikku! as any)[(method as string).toLowerCase()](route, data as any)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -52,7 +52,7 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
52
52
|
method: Method,
|
|
53
53
|
data: RouteHandlerOf<Route, Method>['input'] = null
|
|
54
54
|
): Promise<RouteHandlerOf<Route, Method>['output']> => {
|
|
55
|
-
return (_pikku! as any)[method](route, data as any)
|
|
55
|
+
return (_pikku! as any)[(method as string).toLowerCase()](route, data as any)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -69,11 +69,8 @@ export async function saveSchemas(schemaParentDir, schemas, typesMap, routesMeta
|
|
|
69
69
|
.map((schema) => `
|
|
70
70
|
import * as ${schema} from './schemas/${schema}.schema.json' ${supportsImportAttributes ? `with { type: 'json' }` : ''}
|
|
71
71
|
addSchema('${schema}', ${schema})
|
|
72
|
-
// addSchema('${schema}', require('./schemas/${schema}.schema.json'))
|
|
73
72
|
`)
|
|
74
73
|
.join('\n');
|
|
75
74
|
await writeFileInDir(`${schemaParentDir}/register.gen.ts`, `import { addSchema } from '@pikku/core/schema'
|
|
76
|
-
// import { createRequire } from "module"
|
|
77
|
-
// const require = createRequire(import.meta.url)
|
|
78
75
|
${schemaImports}`);
|
|
79
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@openapi-contrib/json-schema-to-openapi-schema": "^3.0.2",
|
|
25
|
-
"@pikku/core": "^0.6.
|
|
26
|
-
"@pikku/inspector": "^0.6.
|
|
25
|
+
"@pikku/core": "^0.6.23",
|
|
26
|
+
"@pikku/inspector": "^0.6.4",
|
|
27
27
|
"@types/cookie": "^0.6.0",
|
|
28
28
|
"@types/uuid": "^10.0.0",
|
|
29
29
|
"chalk": "^5.4.1",
|
|
30
|
+
"chokidar": "^4.0.3",
|
|
30
31
|
"commander": "^12",
|
|
31
32
|
"path-to-regexp": "^8.2.0",
|
|
32
33
|
"tinyglobby": "^0.2.12",
|
|
@@ -33,7 +33,7 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
33
33
|
method: Method,
|
|
34
34
|
data: RouteHandlerOf<Route, Method>['input'] = null
|
|
35
35
|
): Promise<RouteHandlerOf<Route, Method>['output']> => {
|
|
36
|
-
return (_pikku! as any)[method](route, data as any)
|
|
36
|
+
return (_pikku! as any)[(method as string).toLowerCase()](route, data as any)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -55,7 +55,7 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
55
55
|
method: Method,
|
|
56
56
|
data: RouteHandlerOf<Route, Method>['input'] = null
|
|
57
57
|
): Promise<RouteHandlerOf<Route, Method>['output']> => {
|
|
58
|
-
return (_pikku! as any)[method](route, data as any)
|
|
58
|
+
return (_pikku! as any)[(method as string).toLowerCase()](route, data as any)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -102,7 +102,6 @@ export async function saveSchemas(
|
|
|
102
102
|
(schema) => `
|
|
103
103
|
import * as ${schema} from './schemas/${schema}.schema.json' ${supportsImportAttributes ? `with { type: 'json' }` : ''}
|
|
104
104
|
addSchema('${schema}', ${schema})
|
|
105
|
-
// addSchema('${schema}', require('./schemas/${schema}.schema.json'))
|
|
106
105
|
`
|
|
107
106
|
)
|
|
108
107
|
.join('\n')
|
|
@@ -110,8 +109,6 @@ addSchema('${schema}', ${schema})
|
|
|
110
109
|
await writeFileInDir(
|
|
111
110
|
`${schemaParentDir}/register.gen.ts`,
|
|
112
111
|
`import { addSchema } from '@pikku/core/schema'
|
|
113
|
-
// import { createRequire } from "module"
|
|
114
|
-
// const require = createRequire(import.meta.url)
|
|
115
112
|
${schemaImports}`
|
|
116
113
|
)
|
|
117
114
|
}
|