@igniter-js/cli 0.1.0 → 0.1.3

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.
@@ -0,0 +1,67 @@
1
+
2
+ You are an expert in Solidity, TypeScript, Node.js, Next.js 14 App Router, React, Vite, Viem v2, Wagmi v2, Shadcn UI, Radix UI, and Tailwind Aria.
3
+
4
+ Key Principles
5
+ - Write concise, technical responses with accurate TypeScript examples.
6
+ - Use functional, declarative programming. Avoid classes.
7
+ - Prefer iteration and modularization over duplication.
8
+ - Use descriptive variable names with auxiliary verbs (e.g., isLoading).
9
+ - Use lowercase with dashes for directories (e.g., components/auth-wizard).
10
+ - Favor named exports for components.
11
+ - Use the Receive an Object, Return an Object (RORO) pattern.
12
+
13
+ JavaScript/TypeScript
14
+ - Use "function" keyword for pure functions. Omit semicolons.
15
+ - Use TypeScript for all code. Prefer interfaces over types. Avoid enums, use maps.
16
+ - File structure: Exported component, subcomponents, helpers, static content, types.
17
+ - Avoid unnecessary curly braces in conditional statements.
18
+ - For single-line statements in conditionals, omit curly braces.
19
+ - Use concise, one-line syntax for simple conditional statements (e.g., if (condition) doSomething()).
20
+
21
+ Error Handling and Validation
22
+ - Prioritize error handling and edge cases:
23
+ - Handle errors and edge cases at the beginning of functions.
24
+ - Use early returns for error conditions to avoid deeply nested if statements.
25
+ - Place the happy path last in the function for improved readability.
26
+ - Avoid unnecessary else statements; use if-return pattern instead.
27
+ - Use guard clauses to handle preconditions and invalid states early.
28
+ - Implement proper error logging and user-friendly error messages.
29
+ - Consider using custom error types or error factories for consistent error handling.
30
+
31
+ React/Next.js
32
+ - Use functional components and TypeScript interfaces.
33
+ - Use declarative JSX.
34
+ - Use function, not const, for components.
35
+ - Use Shadcn UI, Radix, and Tailwind Aria for components and styling.
36
+ - Implement responsive design with Tailwind CSS.
37
+ - Use mobile-first approach for responsive design.
38
+ - Place static content and interfaces at file end.
39
+ - Use content variables for static content outside render functions.
40
+ - Minimize 'use client', 'useEffect', and 'setState'. Favor RSC.
41
+ - Use Zod for form validation.
42
+ - Wrap client components in Suspense with fallback.
43
+ - Use dynamic loading for non-critical components.
44
+ - Optimize images: WebP format, size data, lazy loading.
45
+ - Model expected errors as return values: Avoid using try/catch for expected errors in Server Actions. Use useActionState to manage these errors and return them to the client.
46
+ - Use error boundaries for unexpected errors: Implement error boundaries using error.tsx and global-error.tsx files to handle unexpected errors and provide a fallback UI.
47
+ - Use useActionState with react-hook-form for form validation.
48
+ - Code in services/ dir always throw user-friendly errors that tanStackQuery can catch and show to the user.
49
+ - Use next-safe-action for all server actions:
50
+ - Implement type-safe server actions with proper validation.
51
+ - Utilize the `action` function from next-safe-action for creating actions.
52
+ - Define input schemas using Zod for robust type checking and validation.
53
+ - Handle errors gracefully and return appropriate responses.
54
+ - Use import type { ActionResponse } from '@/types/actions'
55
+ - Ensure all server actions return the ActionResponse type
56
+ - Implement consistent error handling and success responses using ActionResponse
57
+
58
+ Key Conventions
59
+ 1. Rely on Next.js App Router for state changes.
60
+ 2. Prioritize Web Vitals (LCP, CLS, FID).
61
+ 3. Minimize 'use client' usage:
62
+ - Prefer server components and Next.js SSR features.
63
+ - Use 'use client' only for Web API access in small components.
64
+ - Avoid using 'use client' for data fetching or state management.
65
+
66
+ Refer to Next.js documentation for Data Fetching, Rendering, and Routing best practices.
67
+
@@ -0,0 +1,42 @@
1
+ ## Code Review Instructions
2
+ IMPORTANT: NEVER MODIFY A FILE WITHOUT DETAILING THE PLAN TO YOUR USER FIRST, ALWAYS REQUEST EXPRESS PERMISSION FROM YOUR USER;
3
+
4
+ ### 1. Review Process
5
+ 1. **Initial Analysis**
6
+ - Check code structure following Igniter.js patterns
7
+ - Identify potential security issues
8
+ - Evaluate test coverage
9
+ - Check compliance with SOLID and Clean Code
10
+
11
+ 2. **Verification Checklist**
12
+ - Clear and consistent naming
13
+ - Correct file structure
14
+ - Proper error handling
15
+ - Appropriate TypeScript typing
16
+ - Required documentation
17
+ - Unit/integration tests
18
+ - Performance and optimizations
19
+ - Security and validations
20
+
21
+ 3. **Feedback**
22
+ - Provide objective and constructive suggestions
23
+ - Prioritize critical issues
24
+ - Include code examples when relevant
25
+ - Justify suggested changes
26
+
27
+ ### 2. Response Format
28
+ ```markdown
29
+ ## Review Summary
30
+ - Status: [APPROVED|CHANGES_REQUESTED]
31
+ - Critical Issues: [number]
32
+ - Improvements: [number]
33
+
34
+ ## Issues
35
+ 1. [CRITICAL|IMPROVEMENT] - Concise description
36
+ - File: path/to/file
37
+ - Reason: Explanation
38
+ - Suggestion: Proposed code/solution
39
+
40
+ ## Recommendations
41
+ - List of general suggestions
42
+ ```
@@ -0,0 +1,55 @@
1
+ # Test Instructions
2
+ IMPORTANT: NEVER MODIFY A FILE WITHOUT DETAILING THE PLAN TO YOUR USER FIRST, ALWAYS REQUEST EXPRESS PERMISSION FROM YOUR USER;
3
+
4
+ # Testing Guidelines
5
+
6
+ ## 1. Testing Strategy & Framework
7
+ **Framework:** Vitest
8
+ **Core Principles:**
9
+ - Each test file mirrors source file structure
10
+ - Focus on behavior, not implementation
11
+ - Follow AAA pattern (Arrange, Act, Assert)
12
+ - Use descriptive test names
13
+ - Test both success and failure cases
14
+
15
+ ## 2. Test Types & Coverage
16
+ - **Unit Tests:** Individual components/functions
17
+ - **Integration Tests:** Interactions between features
18
+ - **E2E Tests:** Critical user flows
19
+ - **Coverage Goal:** Minimum 80% coverage
20
+
21
+ ## 3. Testing Process
22
+ 1. Ask user if testing is needed: "Would you like me to generate tests for this code?"
23
+ 2. If yes, analyze source code and dependencies
24
+ 3. Generate test plan following SOLID principles
25
+ 4. Request approval before implementation
26
+ 5. Create test files with appropriate naming
27
+
28
+ ## 4. Test File Structure
29
+ ```typescript
30
+ describe('Feature: [Component/Function Name]', () => {
31
+ describe('Given [context]', () => {
32
+ describe('When [action]', () => {
33
+ it('Then [expected result]', () => {
34
+ // AAA Pattern
35
+ // Arrange (Setup)
36
+ // Act (Execute)
37
+ // Assert (Verify)
38
+ })
39
+ })
40
+ })
41
+ })
42
+ ```
43
+
44
+ ## 5. Best Practices
45
+ - Use mocks for external dependencies
46
+ - Keep tests focused and independent
47
+ - Test edge cases and error scenarios
48
+ - Write maintainable test code
49
+ - Use utilities for common operations
50
+ - Follow TDD when applicable
51
+
52
+ ## 6. Naming Conventions
53
+ - Test files: `*.spec.ts` or `*.test.ts`
54
+ - Test suites: Clear feature description
55
+ - Test cases: Should describe behavior
@@ -1,3 +1,6 @@
1
1
  {
2
- "extends": ["@rocketseat/eslint-config/next", "next/core-web-vitals"],
3
- }
2
+ "extends": [
3
+ "@igniter-js/eslint-config/next",
4
+ "next/core-web-vitals"
5
+ ]
6
+ }
@@ -57,7 +57,9 @@ export const {{pascalCase name}}Controller = igniter.controller({
57
57
  body: z.object({
58
58
  {{#each fields}}
59
59
  {{#unless isRelation}}
60
- {{name}}: {{zodType}}.optional(),
60
+ {{#if (ne name "id")}}
61
+ {{name}}: {{#if isOptional}}{{zodType}}{{else}}{{zodType}}.optional(){{/if}},
62
+ {{/if}}
61
63
  {{/unless}}
62
64
  {{/each}}
63
65
  }),
@@ -1,3 +1,8 @@
1
+ {{#each fields}}
2
+ {{#if relations}}
3
+ import type { {{pascalCase type}} } from '../{{kebabCase type}}/{{kebabCase type}}.interface';
4
+ {{/if}}
5
+ {{/each}}
1
6
 
2
7
  /**
3
8
  * Represents a {{pascalCase name}} entity.
@@ -6,15 +11,17 @@ export interface {{pascalCase name}} {
6
11
  {{#each fields}}
7
12
  {{#if isRelation}}
8
13
  {{#if isList}}
9
- /** Array of IDs representing the related {{name}} entities */
14
+ /** Array of IDs representing the related {{pascalCase type}} entities */
10
15
  {{name}}Ids: string[];
16
+ /** Related {{pascalCase type}} entities */
17
+ {{name}}: {{pascalCase type}}[];
11
18
  {{else}}
12
- /** ID of the related {{name}} entity */
13
- {{name}}Id: string;
19
+ /** Related {{pascalCase type}} entity */
20
+ {{name}}: {{pascalCase type}};
14
21
  {{/if}}
15
22
  {{else}}
16
23
  /** {{pascalCase name}}'s {{name}} property */
17
- {{name}}{{#if isOptional}}?{{/if}}: {{lowerCase type}};
24
+ {{name}}: {{getTypeFormat type isRelation}}{{#if isOptional}}{{#unless hasDefault}} | null{{/unless}}{{/if}};
18
25
  {{/if}}
19
26
  {{/each}}
20
27
  }
@@ -24,17 +31,16 @@ export interface {{pascalCase name}} {
24
31
  */
25
32
  export interface Create{{pascalCase name}}DTO {
26
33
  {{#each fields}}
27
- {{#if isRelation}}
28
34
  {{#if isList}}
29
- /** Array of IDs for the {{name}} relationships to be created */
30
- {{name}}Ids: string[];
31
- {{else}}
32
- /** ID for the {{name}} relationship to be created */
33
- {{name}}Id: string;
34
- {{/if}}
35
+ /** Array of IDs for the {{pascalCase type}} relationships to be created */
36
+ {{name}}Ids{{#if (equals relations.type 'one-to-many')}}?{{/if}}: string[];
35
37
  {{else}}
36
- /** {{name}} value for the new {{pascalCase name}} */
37
- {{name}}{{#if isOptional}}?{{/if}}: {{lowerCase type}};
38
+ {{#unless (equals name (concat (lowerCase ../name) "Id"))}}
39
+ {{#unless isRelation}}
40
+ /** {{pascalCase name}}'s {{name}} property */
41
+ {{name}}{{#if isOptional}}?{{/if}}: {{getTypeFormat type isRelation}}{{#if isOptional}} | null{{/if}};
42
+ {{/unless}}
43
+ {{/unless}}
38
44
  {{/if}}
39
45
  {{/each}}
40
46
  }
@@ -44,28 +50,32 @@ export interface Create{{pascalCase name}}DTO {
44
50
  */
45
51
  export interface Update{{pascalCase name}}DTO {
46
52
  {{#each fields}}
47
- {{#if isRelation}}
48
53
  {{#if isList}}
49
- /** Array of IDs for the {{name}} relationships to be updated */
54
+ /** Array of IDs for the {{pascalCase type}} relationships to be created */
50
55
  {{name}}Ids?: string[];
51
56
  {{else}}
52
- /** ID for the {{name}} relationship to be updated */
53
- {{name}}Id?: string;
54
- {{/if}}
55
- {{else}}
56
- /** Updated {{name}} value */
57
- {{name}}?: {{lowerCase type}};
57
+ {{#unless (equals name (concat (lowerCase ../name) "Id"))}}
58
+ {{#unless isRelation}}
59
+ /** {{pascalCase name}}'s {{name}} property */
60
+ {{name}}?: {{getTypeFormat type isRelation}}{{#if isOptional}} | null{{/if}};
61
+ {{/unless}}
62
+ {{/unless}}
58
63
  {{/if}}
59
64
  {{/each}}
60
65
  }
61
66
 
62
67
  /**
63
- * Query parameters for fetching {{pascalCase name}} entities
68
+ * Query parameters for fetching Category entities
64
69
  */
65
70
  export interface {{pascalCase name}}QueryParams {
71
+ /** Current page number for pagination */
66
72
  page?: number;
73
+ /** Number of items to return per page */
67
74
  limit?: number;
75
+ /** Property to sort by */
68
76
  sortBy?: string;
77
+ /** Sort order */
69
78
  sortOrder?: 'asc' | 'desc';
79
+ /** Search term for filtering */
70
80
  search?: string;
71
81
  }
@@ -1,4 +1,3 @@
1
- import { randomUUID } from "crypto";
2
1
  import { igniter } from "@/igniter";
3
2
  import type { {{pascalCase name}}, Create{{pascalCase name}}DTO, Update{{pascalCase name}}DTO, {{pascalCase name}}QueryParams } from "../{{kebabCase name}}.interface";
4
3
 
@@ -37,9 +36,10 @@ export const {{pascalCase name}}FeatureProcedure = igniter.procedure({
37
36
  create: async (input: Create{{pascalCase name}}DTO): Promise<{{pascalCase name}}> => {
38
37
  return context.providers.database.{{camelCase name}}.create({
39
38
  data: {
40
- id: randomUUID(),
41
39
  {{#each fields}}
40
+ {{#unless isRelation}}
42
41
  {{name}}: input.{{name}},
42
+ {{/unless}}
43
43
  {{/each}}
44
44
  }
45
45
  });
@@ -56,9 +56,10 @@ export const {{pascalCase name}}FeatureProcedure = igniter.procedure({
56
56
  where: { id: params.id },
57
57
  data: {
58
58
  {{#each fields}}
59
+ {{#unless isRelation}}
59
60
  {{name}}: params.{{name}},
61
+ {{/unless}}
60
62
  {{/each}}
61
- updatedAt: new Date()
62
63
  }
63
64
  });
64
65
  },
@@ -26,7 +26,7 @@
26
26
  --chart-3: oklch(0.398 0.07 227.392);
27
27
  --chart-4: oklch(0.828 0.189 84.429);
28
28
  --chart-5: oklch(0.769 0.188 70.08);
29
- --radius: 0.625rem;
29
+ --radius: 1.5rem;
30
30
  --sidebar: oklch(0.985 0 0);
31
31
  --sidebar-foreground: oklch(0.145 0 0);
32
32
  --sidebar-primary: oklch(0.205 0 0);
@@ -1,50 +1,43 @@
1
- import localFont from "next/font/local";
1
+ import type { Metadata } from "next";
2
2
 
3
- import { type Metadata } from "next";
4
- import { Toaster } from 'sonner'
3
+ import { Geist, Geist_Mono } from "next/font/google";
5
4
  import { IgniterProvider } from '@igniter-js/core/client'
5
+ import { ThemeProvider } from "next-themes";
6
6
 
7
- import "./globals.css";
7
+ import "./globals.css"
8
8
 
9
- const geistSans = localFont({
10
- src: "./fonts/GeistVF.woff",
9
+ const geistSans = Geist({
11
10
  variable: "--font-geist-sans",
12
- weight: "100 900",
11
+ subsets: ["latin"],
13
12
  });
14
13
 
15
- const geistMono = localFont({
16
- src: "./fonts/GeistMonoVF.woff",
14
+ const geistMono = Geist_Mono({
17
15
  variable: "--font-geist-mono",
18
- weight: "100 900",
16
+ subsets: ["latin"],
19
17
  });
20
18
 
21
19
  export const metadata: Metadata = {
22
- title: "Igniter Framework",
23
- description: "A modern framework optimized for AI-powered development, featuring built-in best practices and type safety for rapid web applications",
20
+ title: "Igniter Boilerplate",
21
+ description: "A customizable boilerplate for Igniter applications",
24
22
  };
25
23
 
26
- /**
27
- * Root layout component that wraps the entire application
28
- * Business Rule: We need to await connection() to ensure proper request-time behavior in Next.js 15
29
- * @param children - React components to be rendered inside the layout
30
- */
31
- export default async function RootLayout({
24
+ export default function RootLayout({
32
25
  children,
33
26
  }: Readonly<{
34
27
  children: React.ReactNode;
35
28
  }>) {
36
29
  return (
37
- <html lang="pt-BR" suppressHydrationWarning>
38
- <body className="antialiased">
30
+ <html lang="en" suppressHydrationWarning>
31
+ <body
32
+ className={`${geistSans.variable} ${geistMono.variable} antialiased`}
33
+ >
39
34
  <ThemeProvider
40
35
  attribute="class"
41
36
  defaultTheme="system"
42
37
  enableSystem
43
38
  disableTransitionOnChange
44
- forcedTheme='light'
45
39
  >
46
40
  <IgniterProvider>
47
- <Toaster position="top-center" />
48
41
  {children}
49
42
  </IgniterProvider>
50
43
  </ThemeProvider>