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