@geekmidas/cli 0.28.0 → 0.29.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/dist/index.cjs +82 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +82 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/init/generators/web.ts +86 -37
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ const node_module = require_chunk.__toESM(require("node:module"));
|
|
|
27
27
|
|
|
28
28
|
//#region package.json
|
|
29
29
|
var name = "@geekmidas/cli";
|
|
30
|
-
var version = "0.
|
|
30
|
+
var version = "0.29.0";
|
|
31
31
|
var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
|
|
32
32
|
var private$1 = false;
|
|
33
33
|
var type = "module";
|
|
@@ -6299,6 +6299,8 @@ function generateWebAppFiles(options) {
|
|
|
6299
6299
|
},
|
|
6300
6300
|
dependencies: {
|
|
6301
6301
|
[modelsPackage]: "workspace:*",
|
|
6302
|
+
"@geekmidas/client": GEEKMIDAS_VERSIONS["@geekmidas/client"],
|
|
6303
|
+
"@tanstack/react-query": "~5.80.0",
|
|
6302
6304
|
next: "~16.1.0",
|
|
6303
6305
|
react: "~19.2.0",
|
|
6304
6306
|
"react-dom": "~19.2.0"
|
|
@@ -6355,7 +6357,68 @@ export default nextConfig;
|
|
|
6355
6357
|
],
|
|
6356
6358
|
exclude: ["node_modules"]
|
|
6357
6359
|
};
|
|
6360
|
+
const providersTsx = `'use client';
|
|
6361
|
+
|
|
6362
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
6363
|
+
import { useState } from 'react';
|
|
6364
|
+
|
|
6365
|
+
export function Providers({ children }: { children: React.ReactNode }) {
|
|
6366
|
+
const [queryClient] = useState(
|
|
6367
|
+
() =>
|
|
6368
|
+
new QueryClient({
|
|
6369
|
+
defaultOptions: {
|
|
6370
|
+
queries: {
|
|
6371
|
+
staleTime: 60 * 1000,
|
|
6372
|
+
},
|
|
6373
|
+
},
|
|
6374
|
+
}),
|
|
6375
|
+
);
|
|
6376
|
+
|
|
6377
|
+
return (
|
|
6378
|
+
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
6379
|
+
);
|
|
6380
|
+
}
|
|
6381
|
+
`;
|
|
6382
|
+
const apiIndexTs = `import { TypedFetcher } from '@geekmidas/client/fetcher';
|
|
6383
|
+
import { createEndpointHooks } from '@geekmidas/client/endpoint-hooks';
|
|
6384
|
+
|
|
6385
|
+
// TODO: Run 'gkm openapi' to generate typed paths from your API
|
|
6386
|
+
// This is a placeholder that will be replaced by the generated openapi.ts
|
|
6387
|
+
interface paths {
|
|
6388
|
+
'/health': {
|
|
6389
|
+
get: {
|
|
6390
|
+
responses: {
|
|
6391
|
+
200: {
|
|
6392
|
+
content: {
|
|
6393
|
+
'application/json': { status: string; timestamp: string };
|
|
6394
|
+
};
|
|
6395
|
+
};
|
|
6396
|
+
};
|
|
6397
|
+
};
|
|
6398
|
+
};
|
|
6399
|
+
'/users': {
|
|
6400
|
+
get: {
|
|
6401
|
+
responses: {
|
|
6402
|
+
200: {
|
|
6403
|
+
content: {
|
|
6404
|
+
'application/json': { users: Array<{ id: string; name: string }> };
|
|
6405
|
+
};
|
|
6406
|
+
};
|
|
6407
|
+
};
|
|
6408
|
+
};
|
|
6409
|
+
};
|
|
6410
|
+
}
|
|
6411
|
+
|
|
6412
|
+
const baseURL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000';
|
|
6413
|
+
|
|
6414
|
+
const fetcher = new TypedFetcher<paths>({ baseURL });
|
|
6415
|
+
|
|
6416
|
+
const hooks = createEndpointHooks<paths>(fetcher.request.bind(fetcher));
|
|
6417
|
+
|
|
6418
|
+
export const api = Object.assign(fetcher.request.bind(fetcher), hooks);
|
|
6419
|
+
`;
|
|
6358
6420
|
const layoutTsx = `import type { Metadata } from 'next';
|
|
6421
|
+
import { Providers } from './providers';
|
|
6359
6422
|
|
|
6360
6423
|
export const metadata: Metadata = {
|
|
6361
6424
|
title: '${options.name}',
|
|
@@ -6369,35 +6432,18 @@ export default function RootLayout({
|
|
|
6369
6432
|
}) {
|
|
6370
6433
|
return (
|
|
6371
6434
|
<html lang="en">
|
|
6372
|
-
<body>
|
|
6435
|
+
<body>
|
|
6436
|
+
<Providers>{children}</Providers>
|
|
6437
|
+
</body>
|
|
6373
6438
|
</html>
|
|
6374
6439
|
);
|
|
6375
6440
|
}
|
|
6376
6441
|
`;
|
|
6377
|
-
const pageTsx = `import
|
|
6442
|
+
const pageTsx = `import { api } from '@/api';
|
|
6378
6443
|
|
|
6379
6444
|
export default async function Home() {
|
|
6380
|
-
//
|
|
6381
|
-
const
|
|
6382
|
-
let health = null;
|
|
6383
|
-
|
|
6384
|
-
try {
|
|
6385
|
-
const response = await fetch(\`\${apiUrl}/health\`, {
|
|
6386
|
-
cache: 'no-store',
|
|
6387
|
-
});
|
|
6388
|
-
health = await response.json();
|
|
6389
|
-
} catch (error) {
|
|
6390
|
-
console.error('Failed to fetch health:', error);
|
|
6391
|
-
}
|
|
6392
|
-
|
|
6393
|
-
// Example: Type-safe model usage
|
|
6394
|
-
const exampleUser: User = {
|
|
6395
|
-
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
6396
|
-
email: 'user@example.com',
|
|
6397
|
-
name: 'Example User',
|
|
6398
|
-
createdAt: new Date(),
|
|
6399
|
-
updatedAt: new Date(),
|
|
6400
|
-
};
|
|
6445
|
+
// Type-safe API call using the generated client
|
|
6446
|
+
const health = await api('GET /health').catch(() => null);
|
|
6401
6447
|
|
|
6402
6448
|
return (
|
|
6403
6449
|
<main style={{ padding: '2rem', fontFamily: 'system-ui' }}>
|
|
@@ -6410,21 +6456,14 @@ export default async function Home() {
|
|
|
6410
6456
|
{JSON.stringify(health, null, 2)}
|
|
6411
6457
|
</pre>
|
|
6412
6458
|
) : (
|
|
6413
|
-
<p>Unable to connect to API
|
|
6459
|
+
<p>Unable to connect to API</p>
|
|
6414
6460
|
)}
|
|
6415
6461
|
</section>
|
|
6416
6462
|
|
|
6417
|
-
<section style={{ marginTop: '2rem' }}>
|
|
6418
|
-
<h2>Shared Models</h2>
|
|
6419
|
-
<p>This user object is typed from @${options.name}/models:</p>
|
|
6420
|
-
<pre style={{ background: '#f0f0f0', padding: '1rem', borderRadius: '8px' }}>
|
|
6421
|
-
{JSON.stringify(exampleUser, null, 2)}
|
|
6422
|
-
</pre>
|
|
6423
|
-
</section>
|
|
6424
|
-
|
|
6425
6463
|
<section style={{ marginTop: '2rem' }}>
|
|
6426
6464
|
<h2>Next Steps</h2>
|
|
6427
6465
|
<ul>
|
|
6466
|
+
<li>Run <code>gkm openapi</code> to generate typed API client</li>
|
|
6428
6467
|
<li>Edit <code>apps/web/src/app/page.tsx</code> to customize this page</li>
|
|
6429
6468
|
<li>Add API routes in <code>apps/api/src/endpoints/</code></li>
|
|
6430
6469
|
<li>Define shared schemas in <code>packages/models/src/</code></li>
|
|
@@ -6434,11 +6473,8 @@ export default async function Home() {
|
|
|
6434
6473
|
);
|
|
6435
6474
|
}
|
|
6436
6475
|
`;
|
|
6437
|
-
const envLocal = `# API URL
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
# Other environment variables
|
|
6441
|
-
# NEXT_PUBLIC_API_URL=http://localhost:3000
|
|
6476
|
+
const envLocal = `# API URL for client-side requests
|
|
6477
|
+
NEXT_PUBLIC_API_URL=http://localhost:3000
|
|
6442
6478
|
`;
|
|
6443
6479
|
const gitignore = `.next/
|
|
6444
6480
|
node_modules/
|
|
@@ -6462,10 +6498,18 @@ node_modules/
|
|
|
6462
6498
|
path: "apps/web/src/app/layout.tsx",
|
|
6463
6499
|
content: layoutTsx
|
|
6464
6500
|
},
|
|
6501
|
+
{
|
|
6502
|
+
path: "apps/web/src/app/providers.tsx",
|
|
6503
|
+
content: providersTsx
|
|
6504
|
+
},
|
|
6465
6505
|
{
|
|
6466
6506
|
path: "apps/web/src/app/page.tsx",
|
|
6467
6507
|
content: pageTsx
|
|
6468
6508
|
},
|
|
6509
|
+
{
|
|
6510
|
+
path: "apps/web/src/api/index.ts",
|
|
6511
|
+
content: apiIndexTs
|
|
6512
|
+
},
|
|
6469
6513
|
{
|
|
6470
6514
|
path: "apps/web/.env.local",
|
|
6471
6515
|
content: envLocal
|