Suppress created file list for new "flutter create" projects (#93041)
This commit is contained in:
@@ -289,19 +289,46 @@ class CreateCommand extends CreateBase {
|
||||
int generatedFileCount = 0;
|
||||
switch (template) {
|
||||
case FlutterProjectType.app:
|
||||
generatedFileCount += await generateApp('app', relativeDir, templateContext, overwrite: overwrite);
|
||||
generatedFileCount += await generateApp(
|
||||
'app',
|
||||
relativeDir,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: !creatingNewProject,
|
||||
);
|
||||
break;
|
||||
case FlutterProjectType.skeleton:
|
||||
generatedFileCount += await generateApp('skeleton', relativeDir, templateContext, overwrite: overwrite);
|
||||
generatedFileCount += await generateApp(
|
||||
'skeleton',
|
||||
relativeDir,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: !creatingNewProject,
|
||||
);
|
||||
break;
|
||||
case FlutterProjectType.module:
|
||||
generatedFileCount += await _generateModule(relativeDir, templateContext, overwrite: overwrite);
|
||||
generatedFileCount += await _generateModule(
|
||||
relativeDir,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: !creatingNewProject,
|
||||
);
|
||||
break;
|
||||
case FlutterProjectType.package:
|
||||
generatedFileCount += await _generatePackage(relativeDir, templateContext, overwrite: overwrite);
|
||||
generatedFileCount += await _generatePackage(
|
||||
relativeDir,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: !creatingNewProject,
|
||||
);
|
||||
break;
|
||||
case FlutterProjectType.plugin:
|
||||
generatedFileCount += await _generatePlugin(relativeDir, templateContext, overwrite: overwrite);
|
||||
generatedFileCount += await _generatePlugin(
|
||||
relativeDir,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: !creatingNewProject,
|
||||
);
|
||||
break;
|
||||
}
|
||||
if (sampleCode != null) {
|
||||
@@ -367,13 +394,24 @@ Your $application code is in $relativeAppMain.
|
||||
return FlutterCommandResult.success();
|
||||
}
|
||||
|
||||
Future<int> _generateModule(Directory directory, Map<String, dynamic> templateContext, { bool overwrite = false }) async {
|
||||
Future<int> _generateModule(
|
||||
Directory directory,
|
||||
Map<String, dynamic> templateContext, {
|
||||
bool overwrite = false,
|
||||
bool printStatusWhenWriting = true,
|
||||
}) async {
|
||||
int generatedCount = 0;
|
||||
final String description = argResults.wasParsed('description')
|
||||
? stringArg('description')
|
||||
: 'A new flutter module project.';
|
||||
templateContext['description'] = description;
|
||||
generatedCount += await renderTemplate(globals.fs.path.join('module', 'common'), directory, templateContext, overwrite: overwrite);
|
||||
generatedCount += await renderTemplate(
|
||||
globals.fs.path.join('module', 'common'),
|
||||
directory,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: printStatusWhenWriting,
|
||||
);
|
||||
if (boolArg('pub')) {
|
||||
await pub.get(
|
||||
context: PubContext.create,
|
||||
@@ -390,13 +428,24 @@ Your $application code is in $relativeAppMain.
|
||||
return generatedCount;
|
||||
}
|
||||
|
||||
Future<int> _generatePackage(Directory directory, Map<String, dynamic> templateContext, { bool overwrite = false }) async {
|
||||
Future<int> _generatePackage(
|
||||
Directory directory,
|
||||
Map<String, dynamic> templateContext, {
|
||||
bool overwrite = false,
|
||||
bool printStatusWhenWriting = true,
|
||||
}) async {
|
||||
int generatedCount = 0;
|
||||
final String description = argResults.wasParsed('description')
|
||||
? stringArg('description')
|
||||
: 'A new Flutter package project.';
|
||||
templateContext['description'] = description;
|
||||
generatedCount += await renderTemplate('package', directory, templateContext, overwrite: overwrite);
|
||||
generatedCount += await renderTemplate(
|
||||
'package',
|
||||
directory,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: printStatusWhenWriting,
|
||||
);
|
||||
if (boolArg('pub')) {
|
||||
await pub.get(
|
||||
context: PubContext.createPackage,
|
||||
@@ -408,7 +457,12 @@ Your $application code is in $relativeAppMain.
|
||||
return generatedCount;
|
||||
}
|
||||
|
||||
Future<int> _generatePlugin(Directory directory, Map<String, dynamic> templateContext, { bool overwrite = false }) async {
|
||||
Future<int> _generatePlugin(
|
||||
Directory directory,
|
||||
Map<String, dynamic> templateContext, {
|
||||
bool overwrite = false,
|
||||
bool printStatusWhenWriting = true,
|
||||
}) async {
|
||||
// Plugins only add a platform if it was requested explicitly by the user.
|
||||
if (!argResults.wasParsed('platforms')) {
|
||||
for (final String platform in kAllCreatePlatforms) {
|
||||
@@ -430,7 +484,13 @@ Your $application code is in $relativeAppMain.
|
||||
? stringArg('description')
|
||||
: 'A new flutter plugin project.';
|
||||
templateContext['description'] = description;
|
||||
generatedCount += await renderTemplate('plugin', directory, templateContext, overwrite: overwrite);
|
||||
generatedCount += await renderTemplate(
|
||||
'plugin',
|
||||
directory,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: printStatusWhenWriting,
|
||||
);
|
||||
|
||||
if (boolArg('pub')) {
|
||||
await pub.get(
|
||||
@@ -461,7 +521,14 @@ Your $application code is in $relativeAppMain.
|
||||
templateContext['pluginProjectName'] = projectName;
|
||||
templateContext['androidPluginIdentifier'] = androidPluginIdentifier;
|
||||
|
||||
generatedCount += await generateApp('app', project.example.directory, templateContext, overwrite: overwrite, pluginExampleApp: true);
|
||||
generatedCount += await generateApp(
|
||||
'app',
|
||||
project.example.directory,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
pluginExampleApp: true,
|
||||
printStatusWhenWriting: printStatusWhenWriting,
|
||||
);
|
||||
return generatedCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -404,8 +404,12 @@ abstract class CreateBase extends FlutterCommand {
|
||||
/// If `overwrite` is true, overwrites existing files, `overwrite` defaults to `false`.
|
||||
@protected
|
||||
Future<int> renderTemplate(
|
||||
String templateName, Directory directory, Map<String, Object> context,
|
||||
{bool overwrite = false}) async {
|
||||
String templateName,
|
||||
Directory directory,
|
||||
Map<String, Object> context, {
|
||||
bool overwrite = false,
|
||||
bool printStatusWhenWriting = true,
|
||||
}) async {
|
||||
final Template template = await Template.fromName(
|
||||
templateName,
|
||||
fileSystem: globals.fs,
|
||||
@@ -413,7 +417,12 @@ abstract class CreateBase extends FlutterCommand {
|
||||
templateRenderer: globals.templateRenderer,
|
||||
templateManifest: _templateManifest,
|
||||
);
|
||||
return template.render(directory, context, overwriteExisting: overwrite);
|
||||
return template.render(
|
||||
directory,
|
||||
context,
|
||||
overwriteExisting: overwrite,
|
||||
printStatusWhenWriting: printStatusWhenWriting,
|
||||
);
|
||||
}
|
||||
|
||||
/// Merges named templates into a single template, output to `directory`.
|
||||
@@ -423,8 +432,12 @@ abstract class CreateBase extends FlutterCommand {
|
||||
/// If `overwrite` is true, overwrites existing files, `overwrite` defaults to `false`.
|
||||
@protected
|
||||
Future<int> renderMerged(
|
||||
List<String> names, Directory directory, Map<String, Object> context,
|
||||
{bool overwrite = false}) async {
|
||||
List<String> names,
|
||||
Directory directory,
|
||||
Map<String, Object> context, {
|
||||
bool overwrite = false,
|
||||
bool printStatusWhenWriting = true,
|
||||
}) async {
|
||||
final Template template = await Template.merged(
|
||||
names,
|
||||
directory,
|
||||
@@ -433,7 +446,12 @@ abstract class CreateBase extends FlutterCommand {
|
||||
templateRenderer: globals.templateRenderer,
|
||||
templateManifest: _templateManifest,
|
||||
);
|
||||
return template.render(directory, context, overwriteExisting: overwrite);
|
||||
return template.render(
|
||||
directory,
|
||||
context,
|
||||
overwriteExisting: overwrite,
|
||||
printStatusWhenWriting: printStatusWhenWriting,
|
||||
);
|
||||
}
|
||||
|
||||
/// Generate application project in the `directory` using `templateContext`.
|
||||
@@ -441,14 +459,20 @@ abstract class CreateBase extends FlutterCommand {
|
||||
/// If `overwrite` is true, overwrites existing files, `overwrite` defaults to `false`.
|
||||
@protected
|
||||
Future<int> generateApp(
|
||||
String templateName, Directory directory, Map<String, Object> templateContext,
|
||||
{bool overwrite = false, bool pluginExampleApp = false}) async {
|
||||
String templateName,
|
||||
Directory directory,
|
||||
Map<String, Object> templateContext, {
|
||||
bool overwrite = false,
|
||||
bool pluginExampleApp = false,
|
||||
bool printStatusWhenWriting = true,
|
||||
}) async {
|
||||
int generatedCount = 0;
|
||||
generatedCount += await renderMerged(
|
||||
<String>[templateName, 'app_shared'],
|
||||
directory,
|
||||
templateContext,
|
||||
overwrite: overwrite,
|
||||
printStatusWhenWriting: printStatusWhenWriting,
|
||||
);
|
||||
final FlutterProject project = FlutterProject.fromDirectory(directory);
|
||||
if (templateContext['android'] == true) {
|
||||
|
||||
Reference in New Issue
Block a user