blacksmith-cli 0.1.3 → 0.1.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.
Files changed (27) hide show
  1. package/dist/index.js +22 -9
  2. package/dist/index.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/templates/backend/utils/__init__.py.hbs +0 -0
  5. package/src/templates/backend/utils/models.py.hbs +11 -0
  6. package/src/templates/frontend/src/pages/home/home.tsx.hbs +93 -11
  7. package/src/templates/resource/api-hooks/index.ts.hbs +2 -0
  8. package/src/templates/resource/{frontend/hooks → api-hooks}/use-{{kebabs}}-query.ts.hbs +10 -2
  9. package/src/templates/resource/{frontend/hooks → api-hooks}/use-{{kebab}}-mutations.ts.hbs +1 -1
  10. package/src/templates/resource/backend/models.py.hbs +2 -3
  11. package/src/templates/resource/frontend/components/{{kebab}}-card.tsx.hbs +1 -1
  12. package/src/templates/resource/frontend/components/{{kebab}}-list.tsx.hbs +1 -1
  13. package/src/templates/resource/frontend/index.ts.hbs +1 -2
  14. package/src/templates/resource/frontend/pages/{{kebabs}}-page.tsx.hbs +1 -1
  15. package/src/templates/resource/frontend/pages/{{kebab}}-detail-page.tsx.hbs +3 -11
  16. package/src/templates/resource/pages/components/{{kebab}}-card.tsx.hbs +1 -1
  17. package/src/templates/resource/pages/components/{{kebab}}-list.tsx.hbs +1 -1
  18. package/src/templates/resource/pages/hooks/index.ts.hbs +9 -0
  19. package/src/templates/resource/pages/index.ts.hbs +1 -2
  20. package/src/templates/resource/pages/{{kebabs}}-page.tsx.hbs +1 -1
  21. package/src/templates/resource/pages/{{kebab}}-detail-page.tsx.hbs +3 -11
  22. package/src/templates/frontend/src/pages/home/components/features-grid.tsx.hbs +0 -88
  23. package/src/templates/frontend/src/pages/home/components/getting-started.tsx.hbs +0 -88
  24. package/src/templates/frontend/src/pages/home/components/hero-section.tsx.hbs +0 -47
  25. package/src/templates/frontend/src/pages/home/components/resources-section.tsx.hbs +0 -34
  26. package/src/templates/resource/pages/hooks/use-{{kebabs}}-query.ts.hbs +0 -35
  27. package/src/templates/resource/pages/hooks/use-{{kebab}}-mutations.ts.hbs +0 -39
package/dist/index.js CHANGED
@@ -311,7 +311,7 @@ pages/<page>/
311
311
  \u251C\u2500\u2500 routes.tsx # RouteObject[] using Path enum
312
312
  \u251C\u2500\u2500 index.ts # Re-exports public API
313
313
  \u251C\u2500\u2500 components/ # Child components
314
- \u2514\u2500\u2500 hooks/ # Data hooks
314
+ \u2514\u2500\u2500 hooks/ # Page-local hooks (UI logic, not API hooks)
315
315
  \`\`\`
316
316
  - See the \`page-structure\` skill for full conventions
317
317
  `;
@@ -1418,12 +1418,12 @@ const { data, errorMessage } = useApiQuery({
1418
1418
  import { postsRetrieveOptions } from '@/api/generated/@tanstack/react-query.gen'
1419
1419
 
1420
1420
  const { data: post, isLoading, errorMessage } = useApiQuery({
1421
- ...postsRetrieveOptions({ path: { id: Number(id) } }),
1421
+ ...postsRetrieveOptions({ path: { id: id! } }),
1422
1422
  })
1423
1423
 
1424
1424
  // Conditional query (skip until id is available)
1425
1425
  const { data } = useApiQuery({
1426
- ...postsRetrieveOptions({ path: { id: Number(id) } }),
1426
+ ...postsRetrieveOptions({ path: { id: id! } }),
1427
1427
  enabled: !!id,
1428
1428
  })
1429
1429
  \`\`\`
@@ -1478,7 +1478,7 @@ const deletePost = useApiMutation({
1478
1478
  })
1479
1479
 
1480
1480
  const handleDelete = async () => {
1481
- await deletePost.mutateAsync({ path: { id: Number(id) } })
1481
+ await deletePost.mutateAsync({ path: { id: id! } })
1482
1482
  navigate('/posts')
1483
1483
  }
1484
1484
  \`\`\`
@@ -1573,7 +1573,7 @@ export function useCreatePost() {
1573
1573
  })
1574
1574
  }
1575
1575
 
1576
- export function useUpdatePost(id: number) {
1576
+ export function useUpdatePost(id: string) {
1577
1577
  return useApiMutation({
1578
1578
  ...postsUpdateMutation(),
1579
1579
  invalidateKeys: [
@@ -1624,7 +1624,7 @@ pages/<page>/
1624
1624
  \u251C\u2500\u2500 routes.tsx # Exports RouteObject[] for this page
1625
1625
  \u251C\u2500\u2500 index.ts # Re-exports public members (routes)
1626
1626
  \u251C\u2500\u2500 components/ # Components private to this page (optional)
1627
- \u2514\u2500\u2500 hooks/ # Hooks private to this page (optional)
1627
+ \u2514\u2500\u2500 hooks/ # Page-local hooks (UI logic, not API hooks)
1628
1628
  \`\`\`
1629
1629
 
1630
1630
  **\`routes.tsx\`** \u2014 defines the route config using the \`Path\` enum:
@@ -1678,8 +1678,7 @@ export const postsRoutes: RouteObject[] = [
1678
1678
  **\`index.ts\`** \u2014 exports routes first:
1679
1679
  \`\`\`ts
1680
1680
  export { postsRoutes } from './routes'
1681
- export { usePosts } from './hooks/use-posts'
1682
- export { useCreatePost, useUpdatePost, useDeletePost } from './hooks/use-post-mutations'
1681
+ export { usePosts, useCreatePost, useUpdatePost, useDeletePost } from '@/api/hooks/posts'
1683
1682
  \`\`\`
1684
1683
 
1685
1684
  ### Route Paths (\`src/router/paths.ts\`)
@@ -3152,7 +3151,7 @@ function useOrdersPage() {
3152
3151
  orders: data?.results ?? [],
3153
3152
  pagination: { ...pagination, total: data?.count ?? 0 },
3154
3153
  search,
3155
- deleteOrder: (id: number) => deleteOrder.mutate({ path: { id } }),
3154
+ deleteOrder: (id: string) => deleteOrder.mutate({ path: { id } }),
3156
3155
  }
3157
3156
  }
3158
3157
  \`\`\`
@@ -4157,6 +4156,20 @@ async function makeResource(name) {
4157
4156
  } catch {
4158
4157
  syncSpinner.warn('Could not sync OpenAPI. Run "blacksmith sync" manually.');
4159
4158
  }
4159
+ const apiHooksDir = path7.join(frontendDir, "src", "api", "hooks", names.kebabs);
4160
+ const apiHooksSpinner = spinner(`Creating API hooks: api/hooks/${names.kebabs}/`);
4161
+ try {
4162
+ renderDirectory(
4163
+ path7.join(templatesDir, "resource", "api-hooks"),
4164
+ apiHooksDir,
4165
+ context
4166
+ );
4167
+ apiHooksSpinner.succeed(`Created frontend/src/api/hooks/${names.kebabs}/`);
4168
+ } catch (error) {
4169
+ apiHooksSpinner.fail("Failed to create API hooks");
4170
+ log.error(error.message);
4171
+ process.exit(1);
4172
+ }
4160
4173
  const frontendSpinner = spinner(`Creating frontend page: pages/${names.kebabs}/`);
4161
4174
  try {
4162
4175
  renderDirectory(