Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature create many #55

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions lib/src/commands/create/create_view_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CreateViewCommand extends Command with ProjectStructureValidator {
@override
Future<void> run() async {
try {
final viewName = argResults!.rest.first;
final List<String> viewNames = argResults!.rest;
var templateType = argResults![ksTemplateType] as String?;
final workingDirectory =
argResults!.rest.length > 1 ? argResults!.rest[1] : null;
Expand All @@ -84,20 +84,24 @@ class CreateViewCommand extends Command with ProjectStructureValidator {
// We assign this when it's not null so there should be no default value for this
templateType ??= _configService.preferWeb ? 'web' : 'empty';

await _templateService.renderTemplate(
templateName: name,
name: viewName,
outputPath: workingDirectory,
verbose: true,
excludeRoute: argResults![ksExcludeRoute],
useBuilder: argResults![ksV1] ?? _configService.v1,
templateType: templateType,
);
for (var i = 0; i < viewNames.length; i++) {
await _templateService.renderTemplate(
templateName: name,
name: viewNames[i],
outputPath: workingDirectory,
verbose: true,
excludeRoute: argResults![ksExcludeRoute],
useBuilder: argResults![ksV1] ?? _configService.v1,
templateType: templateType,
);

await _analyticsService.createViewEvent(
name: viewNames[i],
arguments: argResults!.arguments,
);
}

await _processService.runBuildRunner(workingDirectory: workingDirectory);
await _analyticsService.createViewEvent(
name: viewName,
arguments: argResults!.arguments,
);
} catch (e, s) {
_log.error(message: e.toString());
unawaited(_analyticsService.logExceptionEvent(
Expand Down