@geekmidas/cli 0.27.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 +106 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +106 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/init/generators/models.ts +2 -11
- package/src/init/generators/web.ts +86 -37
- package/src/init/index.ts +15 -0
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";
|
|
@@ -4946,21 +4946,8 @@ function generateModelsPackage(options) {
|
|
|
4946
4946
|
version: "0.0.1",
|
|
4947
4947
|
private: true,
|
|
4948
4948
|
type: "module",
|
|
4949
|
-
exports: {
|
|
4950
|
-
|
|
4951
|
-
types: "./dist/index.d.ts",
|
|
4952
|
-
import: "./dist/index.js"
|
|
4953
|
-
},
|
|
4954
|
-
"./*": {
|
|
4955
|
-
types: "./dist/*.d.ts",
|
|
4956
|
-
import: "./dist/*.js"
|
|
4957
|
-
}
|
|
4958
|
-
},
|
|
4959
|
-
scripts: {
|
|
4960
|
-
build: "tsc",
|
|
4961
|
-
"build:watch": "tsc --watch",
|
|
4962
|
-
typecheck: "tsc --noEmit"
|
|
4963
|
-
},
|
|
4949
|
+
exports: { "./*": "./src/*.ts" },
|
|
4950
|
+
scripts: { typecheck: "tsc --noEmit" },
|
|
4964
4951
|
dependencies: { zod: "~4.1.0" },
|
|
4965
4952
|
devDependencies: { typescript: "~5.8.2" }
|
|
4966
4953
|
};
|
|
@@ -6312,6 +6299,8 @@ function generateWebAppFiles(options) {
|
|
|
6312
6299
|
},
|
|
6313
6300
|
dependencies: {
|
|
6314
6301
|
[modelsPackage]: "workspace:*",
|
|
6302
|
+
"@geekmidas/client": GEEKMIDAS_VERSIONS["@geekmidas/client"],
|
|
6303
|
+
"@tanstack/react-query": "~5.80.0",
|
|
6315
6304
|
next: "~16.1.0",
|
|
6316
6305
|
react: "~19.2.0",
|
|
6317
6306
|
"react-dom": "~19.2.0"
|
|
@@ -6368,7 +6357,68 @@ export default nextConfig;
|
|
|
6368
6357
|
],
|
|
6369
6358
|
exclude: ["node_modules"]
|
|
6370
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
|
+
`;
|
|
6371
6420
|
const layoutTsx = `import type { Metadata } from 'next';
|
|
6421
|
+
import { Providers } from './providers';
|
|
6372
6422
|
|
|
6373
6423
|
export const metadata: Metadata = {
|
|
6374
6424
|
title: '${options.name}',
|
|
@@ -6382,35 +6432,18 @@ export default function RootLayout({
|
|
|
6382
6432
|
}) {
|
|
6383
6433
|
return (
|
|
6384
6434
|
<html lang="en">
|
|
6385
|
-
<body>
|
|
6435
|
+
<body>
|
|
6436
|
+
<Providers>{children}</Providers>
|
|
6437
|
+
</body>
|
|
6386
6438
|
</html>
|
|
6387
6439
|
);
|
|
6388
6440
|
}
|
|
6389
6441
|
`;
|
|
6390
|
-
const pageTsx = `import
|
|
6442
|
+
const pageTsx = `import { api } from '@/api';
|
|
6391
6443
|
|
|
6392
6444
|
export default async function Home() {
|
|
6393
|
-
//
|
|
6394
|
-
const
|
|
6395
|
-
let health = null;
|
|
6396
|
-
|
|
6397
|
-
try {
|
|
6398
|
-
const response = await fetch(\`\${apiUrl}/health\`, {
|
|
6399
|
-
cache: 'no-store',
|
|
6400
|
-
});
|
|
6401
|
-
health = await response.json();
|
|
6402
|
-
} catch (error) {
|
|
6403
|
-
console.error('Failed to fetch health:', error);
|
|
6404
|
-
}
|
|
6405
|
-
|
|
6406
|
-
// Example: Type-safe model usage
|
|
6407
|
-
const exampleUser: User = {
|
|
6408
|
-
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
6409
|
-
email: 'user@example.com',
|
|
6410
|
-
name: 'Example User',
|
|
6411
|
-
createdAt: new Date(),
|
|
6412
|
-
updatedAt: new Date(),
|
|
6413
|
-
};
|
|
6445
|
+
// Type-safe API call using the generated client
|
|
6446
|
+
const health = await api('GET /health').catch(() => null);
|
|
6414
6447
|
|
|
6415
6448
|
return (
|
|
6416
6449
|
<main style={{ padding: '2rem', fontFamily: 'system-ui' }}>
|
|
@@ -6423,21 +6456,14 @@ export default async function Home() {
|
|
|
6423
6456
|
{JSON.stringify(health, null, 2)}
|
|
6424
6457
|
</pre>
|
|
6425
6458
|
) : (
|
|
6426
|
-
<p>Unable to connect to API
|
|
6459
|
+
<p>Unable to connect to API</p>
|
|
6427
6460
|
)}
|
|
6428
6461
|
</section>
|
|
6429
6462
|
|
|
6430
|
-
<section style={{ marginTop: '2rem' }}>
|
|
6431
|
-
<h2>Shared Models</h2>
|
|
6432
|
-
<p>This user object is typed from @${options.name}/models:</p>
|
|
6433
|
-
<pre style={{ background: '#f0f0f0', padding: '1rem', borderRadius: '8px' }}>
|
|
6434
|
-
{JSON.stringify(exampleUser, null, 2)}
|
|
6435
|
-
</pre>
|
|
6436
|
-
</section>
|
|
6437
|
-
|
|
6438
6463
|
<section style={{ marginTop: '2rem' }}>
|
|
6439
6464
|
<h2>Next Steps</h2>
|
|
6440
6465
|
<ul>
|
|
6466
|
+
<li>Run <code>gkm openapi</code> to generate typed API client</li>
|
|
6441
6467
|
<li>Edit <code>apps/web/src/app/page.tsx</code> to customize this page</li>
|
|
6442
6468
|
<li>Add API routes in <code>apps/api/src/endpoints/</code></li>
|
|
6443
6469
|
<li>Define shared schemas in <code>packages/models/src/</code></li>
|
|
@@ -6447,11 +6473,8 @@ export default async function Home() {
|
|
|
6447
6473
|
);
|
|
6448
6474
|
}
|
|
6449
6475
|
`;
|
|
6450
|
-
const envLocal = `# API URL
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
# Other environment variables
|
|
6454
|
-
# NEXT_PUBLIC_API_URL=http://localhost:3000
|
|
6476
|
+
const envLocal = `# API URL for client-side requests
|
|
6477
|
+
NEXT_PUBLIC_API_URL=http://localhost:3000
|
|
6455
6478
|
`;
|
|
6456
6479
|
const gitignore = `.next/
|
|
6457
6480
|
node_modules/
|
|
@@ -6475,10 +6498,18 @@ node_modules/
|
|
|
6475
6498
|
path: "apps/web/src/app/layout.tsx",
|
|
6476
6499
|
content: layoutTsx
|
|
6477
6500
|
},
|
|
6501
|
+
{
|
|
6502
|
+
path: "apps/web/src/app/providers.tsx",
|
|
6503
|
+
content: providersTsx
|
|
6504
|
+
},
|
|
6478
6505
|
{
|
|
6479
6506
|
path: "apps/web/src/app/page.tsx",
|
|
6480
6507
|
content: pageTsx
|
|
6481
6508
|
},
|
|
6509
|
+
{
|
|
6510
|
+
path: "apps/web/src/api/index.ts",
|
|
6511
|
+
content: apiIndexTs
|
|
6512
|
+
},
|
|
6482
6513
|
{
|
|
6483
6514
|
path: "apps/web/.env.local",
|
|
6484
6515
|
content: envLocal
|
|
@@ -6790,6 +6821,28 @@ async function initCommand(projectName, options = {}) {
|
|
|
6790
6821
|
});
|
|
6791
6822
|
} catch {}
|
|
6792
6823
|
}
|
|
6824
|
+
console.log("\nš¦ Initializing git repository...\n");
|
|
6825
|
+
try {
|
|
6826
|
+
(0, node_child_process.execSync)("git init", {
|
|
6827
|
+
cwd: targetDir,
|
|
6828
|
+
stdio: "pipe"
|
|
6829
|
+
});
|
|
6830
|
+
(0, node_child_process.execSync)("git branch -M main", {
|
|
6831
|
+
cwd: targetDir,
|
|
6832
|
+
stdio: "pipe"
|
|
6833
|
+
});
|
|
6834
|
+
(0, node_child_process.execSync)("git add .", {
|
|
6835
|
+
cwd: targetDir,
|
|
6836
|
+
stdio: "pipe"
|
|
6837
|
+
});
|
|
6838
|
+
(0, node_child_process.execSync)("git commit -m \"š Project created with @geekmidas/toolbox\"", {
|
|
6839
|
+
cwd: targetDir,
|
|
6840
|
+
stdio: "pipe"
|
|
6841
|
+
});
|
|
6842
|
+
console.log(" Initialized git repository on branch main");
|
|
6843
|
+
} catch {
|
|
6844
|
+
console.log(" Could not initialize git repository (git may not be installed)");
|
|
6845
|
+
}
|
|
6793
6846
|
printNextSteps(name$1, templateOptions, pkgManager);
|
|
6794
6847
|
}
|
|
6795
6848
|
/**
|