maxsim-flutter 1.17.0 → 1.18.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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules-writer.d.ts","sourceRoot":"","sources":["../../src/claude-setup/rules-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAsKzD,wBAAsB,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB3F"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
function frontmatter(paths) {
|
|
4
|
+
const pathLines = paths.map((p) => ` - "${p}"`).join('\n');
|
|
5
|
+
return `---\npaths:\n${pathLines}\n---\n\n`;
|
|
6
|
+
}
|
|
7
|
+
function generateArchitectureRule() {
|
|
8
|
+
return (frontmatter(['lib/**', 'test/**']) +
|
|
9
|
+
`# Clean Architecture Rules
|
|
10
|
+
|
|
11
|
+
This project follows Clean Architecture with three layers:
|
|
12
|
+
|
|
13
|
+
- **domain**: Entities, repository interfaces, use cases. No Flutter or package dependencies.
|
|
14
|
+
- **data**: Repository implementations, data sources, DTOs. Implements domain interfaces.
|
|
15
|
+
- **presentation**: UI widgets, controllers, Riverpod providers. Depends on domain use cases only.
|
|
16
|
+
|
|
17
|
+
## Rules
|
|
18
|
+
- Never import from \`presentation\` into \`domain\` or \`data\`.
|
|
19
|
+
- Never import from \`data\` into \`domain\`.
|
|
20
|
+
- Use cases live in \`domain/use_cases/\` and contain business logic only.
|
|
21
|
+
- Repository interfaces are defined in \`domain/repositories/\`.
|
|
22
|
+
- All external dependencies (network, database) are injected via interfaces.
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
function generateRiverpodRule() {
|
|
26
|
+
return (frontmatter(['lib/**']) +
|
|
27
|
+
`# Riverpod Patterns
|
|
28
|
+
|
|
29
|
+
Use Riverpod for all state management and dependency injection.
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
- Use \`ref.watch\` for reactive reads inside \`build()\` methods.
|
|
33
|
+
- Use \`ref.read\` for one-time reads in event handlers.
|
|
34
|
+
- Prefer \`AsyncNotifierProvider\` for async state with loading/error handling.
|
|
35
|
+
- Annotate providers with \`@riverpod\` and run \`build_runner\` to generate code.
|
|
36
|
+
- Keep providers small and focused — one responsibility per provider.
|
|
37
|
+
`);
|
|
38
|
+
}
|
|
39
|
+
function generateGoRouterRule() {
|
|
40
|
+
return (frontmatter(['lib/**']) +
|
|
41
|
+
`# go_router Navigation Rules
|
|
42
|
+
|
|
43
|
+
Use go_router for declarative navigation.
|
|
44
|
+
|
|
45
|
+
## Rules
|
|
46
|
+
- Define all routes in a central \`AppRouter\` class.
|
|
47
|
+
- Use typed routes with \`GoRoute\` path parameters.
|
|
48
|
+
- Redirect guards for authentication go in the \`redirect\` callback.
|
|
49
|
+
- Prefer \`context.go()\` for full navigation stack replacement.
|
|
50
|
+
- Use \`context.push()\` for stacked navigation.
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
function generateTestingRule() {
|
|
54
|
+
return (frontmatter(['test/**']) +
|
|
55
|
+
`# Testing Conventions
|
|
56
|
+
|
|
57
|
+
All features must have corresponding test coverage.
|
|
58
|
+
|
|
59
|
+
## Rules
|
|
60
|
+
- Mirror the \`lib/\` structure under \`test/\`.
|
|
61
|
+
- Unit test every use case, repository, and provider.
|
|
62
|
+
- Use \`mocktail\` or \`mockito\` for mocking dependencies.
|
|
63
|
+
- Widget tests go in \`test/presentation/\`.
|
|
64
|
+
- Integration tests go in \`test/integration/\`.
|
|
65
|
+
- Aim for 80%+ statement and branch coverage.
|
|
66
|
+
`);
|
|
67
|
+
}
|
|
68
|
+
function generateSecurityRule() {
|
|
69
|
+
return (frontmatter(['lib/**']) +
|
|
70
|
+
`# Security Guidelines
|
|
71
|
+
|
|
72
|
+
Follow these security best practices in all code.
|
|
73
|
+
|
|
74
|
+
## Rules
|
|
75
|
+
- Never hardcode secrets, API keys, or credentials in source code.
|
|
76
|
+
- Use \`flutter_secure_storage\` for sensitive user data.
|
|
77
|
+
- Validate and sanitize all user inputs before use.
|
|
78
|
+
- Use HTTPS for all network requests; never allow plain HTTP in production.
|
|
79
|
+
- Apply the principle of least privilege for permissions.
|
|
80
|
+
- Redact sensitive data from logs.
|
|
81
|
+
`);
|
|
82
|
+
}
|
|
83
|
+
function generateAuthRule() {
|
|
84
|
+
return (frontmatter(['lib/features/auth/**', 'test/features/auth/**']) +
|
|
85
|
+
`# Authentication Rules
|
|
86
|
+
|
|
87
|
+
Guidelines for the auth feature module.
|
|
88
|
+
|
|
89
|
+
## Rules
|
|
90
|
+
- All auth state is managed through the auth provider — never store tokens in plain SharedPreferences.
|
|
91
|
+
- Use secure storage for auth tokens and session data.
|
|
92
|
+
- Protect routes by checking auth state in go_router redirect guards.
|
|
93
|
+
- On logout, clear all cached user data and navigate to the login screen.
|
|
94
|
+
- Handle token refresh transparently in the API client interceptor.
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
function generateApiRule() {
|
|
98
|
+
return (frontmatter(['lib/core/api/**', 'lib/data/**']) +
|
|
99
|
+
`# API & HTTP Client Rules
|
|
100
|
+
|
|
101
|
+
Guidelines for HTTP networking with Dio.
|
|
102
|
+
|
|
103
|
+
## Rules
|
|
104
|
+
- All API calls go through the central Dio client configured in \`core/api/\`.
|
|
105
|
+
- Use interceptors for auth token injection and token refresh.
|
|
106
|
+
- Map HTTP error responses to typed domain failures — never expose raw Dio exceptions to use cases.
|
|
107
|
+
- Use \`retrofit\` or a repository pattern to abstract API endpoints.
|
|
108
|
+
- Log requests and responses only in debug mode; never log sensitive data.
|
|
109
|
+
`);
|
|
110
|
+
}
|
|
111
|
+
function generateDatabaseRule() {
|
|
112
|
+
return (frontmatter(['lib/data/**', 'test/data/**']) +
|
|
113
|
+
`# Database & Local Storage Rules
|
|
114
|
+
|
|
115
|
+
Guidelines for local database and storage access.
|
|
116
|
+
|
|
117
|
+
## Rules
|
|
118
|
+
- All database access is encapsulated in repository implementations under \`data/\`.
|
|
119
|
+
- Use Drift (or Hive/Isar) for structured local data; never raw file I/O for app data.
|
|
120
|
+
- Define database schema migrations explicitly — never drop and recreate tables.
|
|
121
|
+
- Expose only domain models from repositories — never leak database entities to \`domain\` or \`presentation\`.
|
|
122
|
+
- Use transactions for multi-step writes to ensure consistency.
|
|
123
|
+
`);
|
|
124
|
+
}
|
|
125
|
+
function generateI18nRule() {
|
|
126
|
+
return (frontmatter(['lib/**']) +
|
|
127
|
+
`# Internationalization (i18n) Rules
|
|
128
|
+
|
|
129
|
+
Guidelines for localization.
|
|
130
|
+
|
|
131
|
+
## Rules
|
|
132
|
+
- All user-visible strings must be externalized in ARB files under \`l10n/\`.
|
|
133
|
+
- Never hardcode display strings in widget code.
|
|
134
|
+
- Use \`AppLocalizations.of(context)!\` to access translations.
|
|
135
|
+
- Add new strings to all supported locale files before shipping.
|
|
136
|
+
- Use ICU message format for plurals and gender variations.
|
|
137
|
+
`);
|
|
138
|
+
}
|
|
139
|
+
export async function writeRules(context, outputPath) {
|
|
140
|
+
const rulesDir = join(outputPath, '.claude', 'rules');
|
|
141
|
+
await mkdir(rulesDir, { recursive: true });
|
|
142
|
+
// Core rules — always generated
|
|
143
|
+
await writeFile(join(rulesDir, 'architecture.md'), generateArchitectureRule(), 'utf-8');
|
|
144
|
+
await writeFile(join(rulesDir, 'riverpod.md'), generateRiverpodRule(), 'utf-8');
|
|
145
|
+
await writeFile(join(rulesDir, 'go-router.md'), generateGoRouterRule(), 'utf-8');
|
|
146
|
+
await writeFile(join(rulesDir, 'testing.md'), generateTestingRule(), 'utf-8');
|
|
147
|
+
await writeFile(join(rulesDir, 'security.md'), generateSecurityRule(), 'utf-8');
|
|
148
|
+
// Conditional module rules
|
|
149
|
+
if (context.modules.auth) {
|
|
150
|
+
await writeFile(join(rulesDir, 'auth.md'), generateAuthRule(), 'utf-8');
|
|
151
|
+
}
|
|
152
|
+
if (context.modules.api) {
|
|
153
|
+
await writeFile(join(rulesDir, 'api.md'), generateApiRule(), 'utf-8');
|
|
154
|
+
}
|
|
155
|
+
if (context.modules.database) {
|
|
156
|
+
await writeFile(join(rulesDir, 'database.md'), generateDatabaseRule(), 'utf-8');
|
|
157
|
+
}
|
|
158
|
+
if (context.modules.i18n) {
|
|
159
|
+
await writeFile(join(rulesDir, 'i18n.md'), generateI18nRule(), 'utf-8');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=rules-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules-writer.js","sourceRoot":"","sources":["../../src/claude-setup/rules-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,SAAS,WAAW,CAAC,KAAe;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,OAAO,gBAAgB,SAAS,WAAW,CAAC;AAC9C,CAAC;AAED,SAAS,wBAAwB;IAC/B,OAAO,CACL,WAAW,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAClC;;;;;;;;;;;;;;CAcH,CACE,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB;IAC3B,OAAO,CACL,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC;QACvB;;;;;;;;;;CAUH,CACE,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB;IAC3B,OAAO,CACL,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC;QACvB;;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