wlmaker 1.6.0 → 1.7.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/chunk-7KUDXB2F.mjs +83 -0
- package/dist/chunk-BVPCRMD4.mjs +79 -0
- package/dist/chunk-FXU2ADDY.mjs +146 -0
- package/dist/chunk-KBIXWYFD.mjs +164 -0
- package/dist/chunk-LHUDYCA5.mjs +85 -0
- package/dist/chunk-OTFDN3HG.mjs +263 -0
- package/dist/cli.mjs +6287 -2734
- package/dist/generator-DDKHXUAT.mjs +9 -0
- package/dist/generator-PEYFNXBT.mjs +9 -0
- package/dist/generator-PWZL3JNY.mjs +9 -0
- package/dist/project-RTR7EV3X.mjs +17 -0
- package/package.json +2 -4
- package/dist/chunk-OXBECDQE.mjs +0 -81
- package/dist/postinstall.mjs +0 -11
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/generators/collaborative/collaborative-templates.ts
|
|
4
|
+
import { camelCase, pascalCase } from "change-case";
|
|
5
|
+
var COLLABORATIVE_DEPS = [
|
|
6
|
+
"app_base",
|
|
7
|
+
"dio",
|
|
8
|
+
"equatable",
|
|
9
|
+
"flutter_bloc",
|
|
10
|
+
"freezed_annotation",
|
|
11
|
+
"get_it",
|
|
12
|
+
"go_router",
|
|
13
|
+
"injectable",
|
|
14
|
+
"json_annotation"
|
|
15
|
+
];
|
|
16
|
+
var COLLABORATIVE_DEV_DEPS = [
|
|
17
|
+
"build_runner",
|
|
18
|
+
"freezed",
|
|
19
|
+
"injectable_generator",
|
|
20
|
+
"json_serializable",
|
|
21
|
+
"very_good_analysis"
|
|
22
|
+
];
|
|
23
|
+
var COLLABORATIVE_OVERRIDE_EXCLUDE = /* @__PURE__ */ new Set([
|
|
24
|
+
"analyzer",
|
|
25
|
+
"dart_style",
|
|
26
|
+
"build_runner",
|
|
27
|
+
"source_gen"
|
|
28
|
+
]);
|
|
29
|
+
function collaborativePubspec(featureName, description, versions) {
|
|
30
|
+
const depLines = [" app_base:"];
|
|
31
|
+
for (const dep of COLLABORATIVE_DEPS) {
|
|
32
|
+
if (dep === "app_base") continue;
|
|
33
|
+
const version = versions.dependencies[dep] ?? versions.devDependencies[dep];
|
|
34
|
+
if (version) {
|
|
35
|
+
depLines.push(` ${dep}: ${version}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const devDepLines = [
|
|
39
|
+
" flutter_test:",
|
|
40
|
+
" sdk: flutter"
|
|
41
|
+
];
|
|
42
|
+
for (const dep of COLLABORATIVE_DEV_DEPS) {
|
|
43
|
+
const version = versions.devDependencies[dep] ?? versions.dependencies[dep];
|
|
44
|
+
if (version) {
|
|
45
|
+
devDepLines.push(` ${dep}: ${version}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const overrideLines = [];
|
|
49
|
+
for (const [name, version] of Object.entries(versions.dependencyOverrides)) {
|
|
50
|
+
if (!COLLABORATIVE_OVERRIDE_EXCLUDE.has(name)) {
|
|
51
|
+
overrideLines.push(` ${name}: ${version}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const overridesSection = overrideLines.length > 0 ? `
|
|
55
|
+
dependency_overrides:
|
|
56
|
+
${overrideLines.join("\n")}
|
|
57
|
+
` : "";
|
|
58
|
+
return `name: ${featureName}
|
|
59
|
+
description: "${description}"
|
|
60
|
+
version: 0.0.1
|
|
61
|
+
publish_to: none
|
|
62
|
+
|
|
63
|
+
environment:
|
|
64
|
+
sdk: ^3.8.1
|
|
65
|
+
flutter: ">=1.17.0"
|
|
66
|
+
|
|
67
|
+
dependencies:
|
|
68
|
+
flutter:
|
|
69
|
+
sdk: flutter
|
|
70
|
+
${depLines.join("\n")}
|
|
71
|
+
|
|
72
|
+
dev_dependencies:
|
|
73
|
+
${devDepLines.join("\n")}
|
|
74
|
+
${overridesSection}
|
|
75
|
+
flutter:
|
|
76
|
+
uses-material-design: true
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
function featureDiTemplate(featureName) {
|
|
80
|
+
const pascal = pascalCase(featureName);
|
|
81
|
+
return `import 'package:injectable/injectable.dart';
|
|
82
|
+
|
|
83
|
+
@InjectableInit.microPackage()
|
|
84
|
+
void init${pascal}Package() {}
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
function blocsModuleTemplate(featureName) {
|
|
88
|
+
return `import 'package:injectable/injectable.dart';
|
|
89
|
+
|
|
90
|
+
@module
|
|
91
|
+
abstract class BlocsModule {}
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
function datasourcesModuleTemplate(featureName) {
|
|
95
|
+
return `import 'package:injectable/injectable.dart';
|
|
96
|
+
|
|
97
|
+
@module
|
|
98
|
+
abstract class DatasourcesModule {}
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
function repositoriesModuleTemplate(featureName) {
|
|
102
|
+
return `import 'package:injectable/injectable.dart';
|
|
103
|
+
|
|
104
|
+
@module
|
|
105
|
+
abstract class RepositoriesModule {}
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
function usecasesModuleTemplate(featureName) {
|
|
109
|
+
return `import 'package:injectable/injectable.dart';
|
|
110
|
+
|
|
111
|
+
@module
|
|
112
|
+
abstract class UseCasesModule {}
|
|
113
|
+
`;
|
|
114
|
+
}
|
|
115
|
+
function collaborativeBlocTemplate(featureName, pascal) {
|
|
116
|
+
return `import 'package:flutter_bloc/flutter_bloc.dart';
|
|
117
|
+
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
118
|
+
|
|
119
|
+
part '${featureName}_bloc.freezed.dart';
|
|
120
|
+
part '${featureName}_event.dart';
|
|
121
|
+
part '${featureName}_state.dart';
|
|
122
|
+
|
|
123
|
+
class ${pascal}Bloc extends Bloc<${pascal}Event, ${pascal}State> {
|
|
124
|
+
${pascal}Bloc() : super(const ${pascal}State.initial()) {
|
|
125
|
+
on<_Started>(_onStarted);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
Future<void> _onStarted(
|
|
129
|
+
_Started event,
|
|
130
|
+
Emitter<${pascal}State> emit,
|
|
131
|
+
) async {
|
|
132
|
+
emit(const ${pascal}State.loading());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
}
|
|
137
|
+
function collaborativeBlocEventTemplate(featureName, pascal) {
|
|
138
|
+
return `part of '${featureName}_bloc.dart';
|
|
139
|
+
|
|
140
|
+
@freezed
|
|
141
|
+
sealed class ${pascal}Event with _$${pascal}Event {
|
|
142
|
+
const factory ${pascal}Event.started() = _Started;
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
function collaborativeBlocStateTemplate(featureName, pascal) {
|
|
147
|
+
return `part of '${featureName}_bloc.dart';
|
|
148
|
+
|
|
149
|
+
@freezed
|
|
150
|
+
sealed class ${pascal}State with _$${pascal}State {
|
|
151
|
+
const factory ${pascal}State.initial() = _Initial;
|
|
152
|
+
const factory ${pascal}State.loading() = _Loading;
|
|
153
|
+
const factory ${pascal}State.error(String message) = _Error;
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
function collaborativePageTemplate(featureName, pascal) {
|
|
158
|
+
const routePath = "/" + featureName.replace(/^feature_/, "");
|
|
159
|
+
return `import 'package:flutter/material.dart';
|
|
160
|
+
import 'package:go_router/go_router.dart';
|
|
161
|
+
import 'package:${featureName}/presentation/pages/views/views.dart';
|
|
162
|
+
|
|
163
|
+
class ${pascal}Page extends GoRoute {
|
|
164
|
+
${pascal}Page({super.name, super.routes})
|
|
165
|
+
: super(
|
|
166
|
+
path: fullPath,
|
|
167
|
+
pageBuilder: (context, state) =>
|
|
168
|
+
const MaterialPage(child: ${pascal}View()),
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
static const fullPath = '${routePath}';
|
|
172
|
+
|
|
173
|
+
static void open(BuildContext context) => context.go(fullPath);
|
|
174
|
+
}
|
|
175
|
+
`;
|
|
176
|
+
}
|
|
177
|
+
function collaborativeViewTemplate(pascal) {
|
|
178
|
+
return `import 'package:flutter/material.dart';
|
|
179
|
+
|
|
180
|
+
class ${pascal}View extends StatelessWidget {
|
|
181
|
+
const ${pascal}View({super.key});
|
|
182
|
+
|
|
183
|
+
@override
|
|
184
|
+
Widget build(BuildContext context) {
|
|
185
|
+
return Scaffold(
|
|
186
|
+
appBar: AppBar(title: const Text('${pascal}')),
|
|
187
|
+
body: const Center(child: Text('${pascal}')),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
`;
|
|
192
|
+
}
|
|
193
|
+
function emptyBarrelTemplate() {
|
|
194
|
+
return "";
|
|
195
|
+
}
|
|
196
|
+
function mainBarrelTemplate(featureName) {
|
|
197
|
+
return `export 'data/api/bff/bff.dart';
|
|
198
|
+
export 'data/datasources/datasources.dart';
|
|
199
|
+
export 'data/models/models.dart';
|
|
200
|
+
export 'data/repositories/repositories.dart';
|
|
201
|
+
export 'domain/entities/entities.dart';
|
|
202
|
+
export 'domain/repositories/repositories.dart';
|
|
203
|
+
export 'domain/usecases/usecases.dart';
|
|
204
|
+
export 'presentation/bloc/bloc.dart';
|
|
205
|
+
export 'presentation/pages/pages.dart';
|
|
206
|
+
export 'presentation/pages/views/views.dart';
|
|
207
|
+
export 'di/${featureName}_di.dart';
|
|
208
|
+
`;
|
|
209
|
+
}
|
|
210
|
+
function collaborativeGitignore() {
|
|
211
|
+
return `# Miscellaneous
|
|
212
|
+
*.class
|
|
213
|
+
*.log
|
|
214
|
+
*.pyc
|
|
215
|
+
*.swp
|
|
216
|
+
.DS_Store
|
|
217
|
+
.atom/
|
|
218
|
+
.buildlog/
|
|
219
|
+
.history
|
|
220
|
+
.svn/
|
|
221
|
+
migrate_working_dir/
|
|
222
|
+
|
|
223
|
+
# IntelliJ related
|
|
224
|
+
*.iml
|
|
225
|
+
*.ipr
|
|
226
|
+
*.iws
|
|
227
|
+
.idea/
|
|
228
|
+
|
|
229
|
+
# Flutter/Dart/Pub related
|
|
230
|
+
/pubspec.lock
|
|
231
|
+
**/doc/api/
|
|
232
|
+
.dart_tool/
|
|
233
|
+
.flutter-plugins
|
|
234
|
+
.flutter-plugins-dependencies
|
|
235
|
+
build/
|
|
236
|
+
|
|
237
|
+
coverage/
|
|
238
|
+
`;
|
|
239
|
+
}
|
|
240
|
+
function blocRegistrationSnippet(featureName, pascal) {
|
|
241
|
+
const blocClass = `${pascal}Bloc`;
|
|
242
|
+
const blocVar = camelCase(blocClass);
|
|
243
|
+
return ` @injectable
|
|
244
|
+
${blocClass} ${blocVar}() => ${blocClass}();`;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export {
|
|
248
|
+
collaborativePubspec,
|
|
249
|
+
featureDiTemplate,
|
|
250
|
+
blocsModuleTemplate,
|
|
251
|
+
datasourcesModuleTemplate,
|
|
252
|
+
repositoriesModuleTemplate,
|
|
253
|
+
usecasesModuleTemplate,
|
|
254
|
+
collaborativeBlocTemplate,
|
|
255
|
+
collaborativeBlocEventTemplate,
|
|
256
|
+
collaborativeBlocStateTemplate,
|
|
257
|
+
collaborativePageTemplate,
|
|
258
|
+
collaborativeViewTemplate,
|
|
259
|
+
emptyBarrelTemplate,
|
|
260
|
+
mainBarrelTemplate,
|
|
261
|
+
collaborativeGitignore,
|
|
262
|
+
blocRegistrationSnippet
|
|
263
|
+
};
|