[flutter_tools] maintain file manifest for create (#59706)
First pass at fixing #57985 and implementing #59602 This doesn't have enough metadata to be useful for IDEs yet, but it prevents the issue from getting worse while we iterate on it.
This commit is contained in:
parent
2a7ee930c3
commit
a0334fb500
@ -278,6 +278,29 @@ class CreateCommand extends FlutterCommand {
|
|||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<Uri> get templateManifest => _templateManifest ??= _computeTemplateManifest();
|
||||||
|
Set<Uri> _templateManifest;
|
||||||
|
Set<Uri> _computeTemplateManifest() {
|
||||||
|
final String flutterToolsAbsolutePath = globals.fs.path.join(
|
||||||
|
Cache.flutterRoot,
|
||||||
|
'packages',
|
||||||
|
'flutter_tools',
|
||||||
|
);
|
||||||
|
final String manifestPath = globals.fs.path.join(
|
||||||
|
flutterToolsAbsolutePath,
|
||||||
|
'templates',
|
||||||
|
'template_manifest.json',
|
||||||
|
);
|
||||||
|
final Map<String, Object> manifest = json.decode(
|
||||||
|
globals.fs.file(manifestPath).readAsStringSync(),
|
||||||
|
) as Map<String, Object>;
|
||||||
|
return Set<Uri>.from(
|
||||||
|
(manifest['files'] as List<Object>)
|
||||||
|
.cast<String>()
|
||||||
|
.map<Uri>((String path) => Uri.file(globals.fs.path.join(flutterToolsAbsolutePath, path))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
if (argResults['list-samples'] != null) {
|
if (argResults['list-samples'] != null) {
|
||||||
@ -750,7 +773,11 @@ https://flutter.dev/docs/development/packages-and-plugins/developing-packages#pl
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> _renderTemplate(String templateName, Directory directory, Map<String, dynamic> context, { bool overwrite = false }) async {
|
Future<int> _renderTemplate(String templateName, Directory directory, Map<String, dynamic> context, { bool overwrite = false }) async {
|
||||||
final Template template = await Template.fromName(templateName, fileSystem: globals.fs);
|
final Template template = await Template.fromName(
|
||||||
|
templateName,
|
||||||
|
fileSystem: globals.fs,
|
||||||
|
templateManifest: templateManifest,
|
||||||
|
);
|
||||||
return template.render(directory, context, overwriteExisting: overwrite);
|
return template.render(directory, context, overwriteExisting: overwrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,13 @@ class IdeConfigCommand extends FlutterCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int _renderTemplate(String templateName, String dirPath, Map<String, dynamic> context) {
|
int _renderTemplate(String templateName, String dirPath, Map<String, dynamic> context) {
|
||||||
final Template template = Template(_templateDirectory, _templateDirectory, null, fileSystem: globals.fs);
|
final Template template = Template(
|
||||||
|
_templateDirectory,
|
||||||
|
_templateDirectory,
|
||||||
|
null,
|
||||||
|
fileSystem: globals.fs,
|
||||||
|
templateManifest: null,
|
||||||
|
);
|
||||||
return template.render(
|
return template.render(
|
||||||
globals.fs.directory(dirPath),
|
globals.fs.directory(dirPath),
|
||||||
context,
|
context,
|
||||||
|
@ -647,7 +647,7 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _overwriteFromTemplate(String path, Directory target) async {
|
Future<void> _overwriteFromTemplate(String path, Directory target) async {
|
||||||
final Template template = await Template.fromName(path, fileSystem: globals.fs);
|
final Template template = await Template.fromName(path, fileSystem: globals.fs, templateManifest: null);
|
||||||
template.render(
|
template.render(
|
||||||
target,
|
target,
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
@ -797,7 +797,7 @@ class AndroidProject extends FlutterProjectPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _overwriteFromTemplate(String path, Directory target) async {
|
Future<void> _overwriteFromTemplate(String path, Directory target) async {
|
||||||
final Template template = await Template.fromName(path, fileSystem: globals.fs);
|
final Template template = await Template.fromName(path, fileSystem: globals.fs, templateManifest: null);
|
||||||
template.render(
|
template.render(
|
||||||
target,
|
target,
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
|
@ -32,7 +32,9 @@ import 'globals.dart' as globals hide fs;
|
|||||||
class Template {
|
class Template {
|
||||||
Template(Directory templateSource, Directory baseDir, this.imageSourceDir, {
|
Template(Directory templateSource, Directory baseDir, this.imageSourceDir, {
|
||||||
@required FileSystem fileSystem,
|
@required FileSystem fileSystem,
|
||||||
}) : _fileSystem = fileSystem {
|
@required Set<Uri> templateManifest,
|
||||||
|
}) : _fileSystem = fileSystem,
|
||||||
|
_templateManifest = templateManifest {
|
||||||
_templateFilePaths = <String, String>{};
|
_templateFilePaths = <String, String>{};
|
||||||
|
|
||||||
if (!templateSource.existsSync()) {
|
if (!templateSource.existsSync()) {
|
||||||
@ -46,10 +48,14 @@ class Template {
|
|||||||
// We are only interesting in template *file* URIs.
|
// We are only interesting in template *file* URIs.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (_templateManifest != null && !_templateManifest.contains(Uri.file(entity.absolute.path))) {
|
||||||
|
globals.logger.printTrace('Skipping ${entity.absolute.path}, missing from the template manifest.');
|
||||||
|
// Skip stale files in the flutter_tools directory.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final String relativePath = fileSystem.path.relative(entity.path,
|
final String relativePath = fileSystem.path.relative(entity.path,
|
||||||
from: baseDir.absolute.path);
|
from: baseDir.absolute.path);
|
||||||
|
|
||||||
if (relativePath.contains(templateExtension)) {
|
if (relativePath.contains(templateExtension)) {
|
||||||
// If '.tmpl' appears anywhere within the path of this entity, it is
|
// If '.tmpl' appears anywhere within the path of this entity, it is
|
||||||
// is a candidate for rendering. This catches cases where the folder
|
// is a candidate for rendering. This catches cases where the folder
|
||||||
@ -59,14 +65,23 @@ class Template {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Template> fromName(String name, { @required FileSystem fileSystem }) async {
|
static Future<Template> fromName(String name, {
|
||||||
|
@required FileSystem fileSystem,
|
||||||
|
@required Set<Uri> templateManifest,
|
||||||
|
}) async {
|
||||||
// All named templates are placed in the 'templates' directory
|
// All named templates are placed in the 'templates' directory
|
||||||
final Directory templateDir = _templateDirectoryInPackage(name, fileSystem);
|
final Directory templateDir = _templateDirectoryInPackage(name, fileSystem);
|
||||||
final Directory imageDir = await _templateImageDirectory(name, fileSystem);
|
final Directory imageDir = await _templateImageDirectory(name, fileSystem);
|
||||||
return Template(templateDir, templateDir, imageDir, fileSystem: fileSystem);
|
return Template(
|
||||||
|
templateDir,
|
||||||
|
templateDir, imageDir,
|
||||||
|
fileSystem: fileSystem,
|
||||||
|
templateManifest: templateManifest,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final FileSystem _fileSystem;
|
final FileSystem _fileSystem;
|
||||||
|
final Set<Uri> _templateManifest;
|
||||||
static const String templateExtension = '.tmpl';
|
static const String templateExtension = '.tmpl';
|
||||||
static const String copyTemplateExtension = '.copy.tmpl';
|
static const String copyTemplateExtension = '.copy.tmpl';
|
||||||
static const String imageTemplateExtension = '.img.tmpl';
|
static const String imageTemplateExtension = '.img.tmpl';
|
||||||
|
291
packages/flutter_tools/templates/template_manifest.json
Normal file
291
packages/flutter_tools/templates/template_manifest.json
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
{
|
||||||
|
"version": 1.0,
|
||||||
|
"_comment": "A listing of all possible template output files.",
|
||||||
|
"files": [
|
||||||
|
"templates/app/.gitignore.tmpl",
|
||||||
|
"templates/app/.idea/libraries/Dart_SDK.xml.tmpl",
|
||||||
|
"templates/app/.idea/libraries/KotlinJavaRuntime.xml.tmpl",
|
||||||
|
"templates/app/.idea/modules.xml.tmpl",
|
||||||
|
"templates/app/.idea/runConfigurations/main_dart.xml.tmpl",
|
||||||
|
"templates/app/.idea/workspace.xml.tmpl",
|
||||||
|
"templates/app/.metadata.tmpl",
|
||||||
|
"templates/app/android-java.tmpl/app/build.gradle.tmpl",
|
||||||
|
"templates/app/android-java.tmpl/app/src/main/java/androidIdentifier/MainActivity.java.tmpl",
|
||||||
|
"templates/app/android-java.tmpl/build.gradle",
|
||||||
|
"templates/app/android-java.tmpl/projectName_android.iml.tmpl",
|
||||||
|
"templates/app/android-kotlin.tmpl/app/build.gradle.tmpl",
|
||||||
|
"templates/app/android-kotlin.tmpl/app/src/main/kotlin/androidIdentifier/MainActivity.kt.tmpl",
|
||||||
|
"templates/app/android-kotlin.tmpl/build.gradle",
|
||||||
|
"templates/app/android-kotlin.tmpl/projectName_android.iml.tmpl",
|
||||||
|
"templates/app/android.tmpl/.gitignore",
|
||||||
|
"templates/app/android.tmpl/app/src/debug/AndroidManifest.xml.tmpl",
|
||||||
|
"templates/app/android.tmpl/app/src/main/AndroidManifest.xml.tmpl",
|
||||||
|
"templates/app/android.tmpl/app/src/main/res/drawable/launch_background.xml",
|
||||||
|
"templates/app/android.tmpl/app/src/main/res/mipmap-hdpi/ic_launcher.png",
|
||||||
|
"templates/app/android.tmpl/app/src/main/res/mipmap-mdpi/ic_launcher.png",
|
||||||
|
"templates/app/android.tmpl/app/src/main/res/mipmap-xhdpi/ic_launcher.png",
|
||||||
|
"templates/app/android.tmpl/app/src/main/res/mipmap-xxhdpi/ic_launcher.png",
|
||||||
|
"templates/app/android.tmpl/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png",
|
||||||
|
"templates/app/android.tmpl/app/src/main/res/values/styles.xml",
|
||||||
|
"templates/app/android.tmpl/app/src/profile/AndroidManifest.xml.tmpl",
|
||||||
|
"templates/app/android.tmpl/gradle/wrapper/gradle-wrapper.properties",
|
||||||
|
"templates/app/android.tmpl/gradle.properties.tmpl",
|
||||||
|
"templates/app/android.tmpl/settings.gradle",
|
||||||
|
"templates/app/ios-objc.tmpl/Runner/AppDelegate.h",
|
||||||
|
"templates/app/ios-objc.tmpl/Runner/AppDelegate.m",
|
||||||
|
"templates/app/ios-objc.tmpl/Runner/main.m",
|
||||||
|
"templates/app/ios-objc.tmpl/Runner.xcodeproj/project.pbxproj.tmpl",
|
||||||
|
"templates/app/ios-objc.tmpl/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme",
|
||||||
|
"templates/app/ios-swift.tmpl/Runner/AppDelegate.swift",
|
||||||
|
"templates/app/ios-swift.tmpl/Runner/Runner-Bridging-Header.h",
|
||||||
|
"templates/app/ios-swift.tmpl/Runner.xcodeproj/project.pbxproj.tmpl",
|
||||||
|
"templates/app/ios-swift.tmpl/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme",
|
||||||
|
"templates/app/ios.tmpl/.gitignore",
|
||||||
|
"templates/app/ios.tmpl/Flutter/AppFrameworkInfo.plist",
|
||||||
|
"templates/app/ios.tmpl/Flutter/Debug.xcconfig",
|
||||||
|
"templates/app/ios.tmpl/Flutter/Release.xcconfig",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png",
|
||||||
|
"templates/app/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/README.md",
|
||||||
|
"templates/app/ios.tmpl/Runner/Base.lproj/LaunchScreen.storyboard",
|
||||||
|
"templates/app/ios.tmpl/Runner/Base.lproj/Main.storyboard",
|
||||||
|
"templates/app/ios.tmpl/Runner/Info.plist.tmpl",
|
||||||
|
"templates/app/ios.tmpl/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
|
||||||
|
"templates/app/ios.tmpl/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
|
||||||
|
"templates/app/ios.tmpl/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings",
|
||||||
|
"templates/app/ios.tmpl/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme",
|
||||||
|
"templates/app/ios.tmpl/Runner.xcworkspace/contents.xcworkspacedata",
|
||||||
|
"templates/app/ios.tmpl/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
|
||||||
|
"templates/app/ios.tmpl/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings",
|
||||||
|
"templates/app/lib/main.dart.tmpl",
|
||||||
|
"templates/app/linux.tmpl/my_application.cc.tmpl",
|
||||||
|
"templates/app/linux.tmpl/.gitignore",
|
||||||
|
"templates/app/linux.tmpl/CMakeLists.txt.tmpl",
|
||||||
|
"templates/app/linux.tmpl/flutter/.template_version",
|
||||||
|
"templates/app/linux.tmpl/flutter/CMakeLists.txt",
|
||||||
|
"templates/app/linux.tmpl/main.cc",
|
||||||
|
"templates/app/linux.tmpl/my_application.cc",
|
||||||
|
"templates/app/linux.tmpl/my_application.h",
|
||||||
|
"templates/app/linux.tmpl/window_configuration.cc.tmpl",
|
||||||
|
"templates/app/linux.tmpl/window_configuration.h",
|
||||||
|
"templates/app/macos.tmpl/.gitignore",
|
||||||
|
"templates/app/macos.tmpl/Flutter/Flutter-Debug.xcconfig",
|
||||||
|
"templates/app/macos.tmpl/Flutter/Flutter-Release.xcconfig",
|
||||||
|
"templates/app/macos.tmpl/Runner/AppDelegate.swift",
|
||||||
|
"templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png",
|
||||||
|
"templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png",
|
||||||
|
"templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png",
|
||||||
|
"templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png",
|
||||||
|
"templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png",
|
||||||
|
"templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png",
|
||||||
|
"templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png",
|
||||||
|
"templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json",
|
||||||
|
"templates/app/macos.tmpl/Runner/Base.lproj/MainMenu.xib",
|
||||||
|
"templates/app/macos.tmpl/Runner/Configs/AppInfo.xcconfig.tmpl",
|
||||||
|
"templates/app/macos.tmpl/Runner/Configs/Debug.xcconfig",
|
||||||
|
"templates/app/macos.tmpl/Runner/Configs/Release.xcconfig",
|
||||||
|
"templates/app/macos.tmpl/Runner/Configs/Warnings.xcconfig",
|
||||||
|
"templates/app/macos.tmpl/Runner/DebugProfile.entitlements",
|
||||||
|
"templates/app/macos.tmpl/Runner/Info.plist",
|
||||||
|
"templates/app/macos.tmpl/Runner/MainFlutterWindow.swift",
|
||||||
|
"templates/app/macos.tmpl/Runner/Release.entitlements",
|
||||||
|
"templates/app/macos.tmpl/Runner.xcodeproj/project.pbxproj.tmpl",
|
||||||
|
"templates/app/macos.tmpl/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
|
||||||
|
"templates/app/macos.tmpl/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme.tmpl",
|
||||||
|
"templates/app/macos.tmpl/Runner.xcworkspace/contents.xcworkspacedata",
|
||||||
|
"templates/app/macos.tmpl/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
|
||||||
|
"templates/app/projectName.iml.tmpl",
|
||||||
|
"templates/app/pubspec.yaml.tmpl",
|
||||||
|
"templates/app/README.md.tmpl",
|
||||||
|
"templates/app/test/widget_test.dart.tmpl",
|
||||||
|
"templates/app/web/favicon.png.copy.tmpl",
|
||||||
|
"templates/app/web/icons/Icon-192.png.copy.tmpl",
|
||||||
|
"templates/app/web/icons/Icon-512.png.copy.tmpl",
|
||||||
|
"templates/app/web/index.html.tmpl",
|
||||||
|
"templates/app/web/manifest.json.tmpl",
|
||||||
|
"templates/app/windows.tmpl/.gitignore",
|
||||||
|
"templates/app/windows.tmpl/AppConfiguration.props.tmpl",
|
||||||
|
"templates/app/windows.tmpl/flutter/.template_version",
|
||||||
|
"templates/app/windows.tmpl/FlutterBuild.vcxproj",
|
||||||
|
"templates/app/windows.tmpl/runner/flutter_window.cpp",
|
||||||
|
"templates/app/windows.tmpl/runner/flutter_window.h",
|
||||||
|
"templates/app/windows.tmpl/runner/main.cpp",
|
||||||
|
"templates/app/windows.tmpl/runner/resource.h",
|
||||||
|
"templates/app/windows.tmpl/runner/resources/app_icon.ico.img.tmpl",
|
||||||
|
"templates/app/windows.tmpl/runner/runner.exe.manifest",
|
||||||
|
"templates/app/windows.tmpl/runner/Runner.rc",
|
||||||
|
"templates/app/windows.tmpl/runner/run_loop.cpp",
|
||||||
|
"templates/app/windows.tmpl/runner/run_loop.h",
|
||||||
|
"templates/app/windows.tmpl/runner/utils.cpp",
|
||||||
|
"templates/app/windows.tmpl/runner/utils.h",
|
||||||
|
"templates/app/windows.tmpl/runner/win32_window.cpp",
|
||||||
|
"templates/app/windows.tmpl/runner/win32_window.h",
|
||||||
|
"templates/app/windows.tmpl/runner/window_configuration.cpp.tmpl",
|
||||||
|
"templates/app/windows.tmpl/runner/window_configuration.h",
|
||||||
|
"templates/app/windows.tmpl/Runner.sln",
|
||||||
|
"templates/app/windows.tmpl/Runner.vcxproj.filters",
|
||||||
|
"templates/app/windows.tmpl/Runner.vcxproj.tmpl",
|
||||||
|
"templates/app/windows.tmpl/scripts/bundle_assets_and_deps.bat",
|
||||||
|
"templates/app/windows.tmpl/scripts/prepare_dependencies.bat",
|
||||||
|
"templates/cocoapods/Podfile-ios-objc",
|
||||||
|
"templates/cocoapods/Podfile-ios-swift",
|
||||||
|
"templates/cocoapods/Podfile-macos",
|
||||||
|
"templates/driver/main_test.dart.tmpl",
|
||||||
|
"templates/module/android/gradle/build.gradle.copy.tmpl",
|
||||||
|
"templates/module/android/gradle/gradle.properties.tmpl",
|
||||||
|
"templates/module/android/host_app_common/app.tmpl/build.gradle.tmpl",
|
||||||
|
"templates/module/android/host_app_common/app.tmpl/src/main/AndroidManifest.xml.tmpl",
|
||||||
|
"templates/module/android/host_app_common/app.tmpl/src/main/java/androidIdentifier/host/MainActivity.java.tmpl",
|
||||||
|
"templates/module/android/host_app_common/app.tmpl/src/main/res/drawable/launch_background.xml",
|
||||||
|
"templates/module/android/host_app_common/app.tmpl/src/main/res/mipmap-hdpi/ic_launcher.png",
|
||||||
|
"templates/module/android/host_app_common/app.tmpl/src/main/res/values/styles.xml",
|
||||||
|
"templates/module/android/host_app_editable/settings.gradle.copy.tmpl",
|
||||||
|
"templates/module/android/host_app_ephemeral/settings.gradle.copy.tmpl",
|
||||||
|
"templates/module/android/library/Flutter.tmpl/build.gradle.tmpl",
|
||||||
|
"templates/module/android/library/Flutter.tmpl/flutter.iml.copy.tmpl",
|
||||||
|
"templates/module/android/library/Flutter.tmpl/src/main/AndroidManifest.xml.tmpl",
|
||||||
|
"templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/Flutter.java.tmpl",
|
||||||
|
"templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/FlutterFragment.java.tmpl",
|
||||||
|
"templates/module/android/library/include_flutter.groovy.copy.tmpl",
|
||||||
|
"templates/module/android/library/settings.gradle.copy.tmpl",
|
||||||
|
"templates/module/android/library_new_embedding/Flutter.tmpl/build.gradle.tmpl",
|
||||||
|
"templates/module/android/library_new_embedding/Flutter.tmpl/flutter.iml.copy.tmpl",
|
||||||
|
"templates/module/android/library_new_embedding/Flutter.tmpl/src/main/AndroidManifest.xml.tmpl",
|
||||||
|
"templates/module/android/library_new_embedding/include_flutter.groovy.copy.tmpl",
|
||||||
|
"templates/module/android/library_new_embedding/settings.gradle.copy.tmpl",
|
||||||
|
"templates/module/common/.gitignore.tmpl",
|
||||||
|
"templates/module/common/.idea/libraries/Dart_SDK.xml.tmpl",
|
||||||
|
"templates/module/common/.idea/modules.xml.tmpl",
|
||||||
|
"templates/module/common/.idea/workspace.xml.tmpl",
|
||||||
|
"templates/module/common/.metadata.tmpl",
|
||||||
|
"templates/module/common/lib/main.dart.tmpl",
|
||||||
|
"templates/module/common/projectName.iml.tmpl",
|
||||||
|
"templates/module/common/projectName_android.iml.tmpl",
|
||||||
|
"templates/module/common/pubspec.yaml.tmpl",
|
||||||
|
"templates/module/common/README.md.tmpl",
|
||||||
|
"templates/module/common/test/widget_test.dart.tmpl",
|
||||||
|
"templates/module/ios/host_app_editable_cocoapods/Config.tmpl/Flutter.xcconfig",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Config.tmpl/Debug.xcconfig",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Config.tmpl/Flutter.xcconfig",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Config.tmpl/Release.xcconfig",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/AppDelegate.h",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/AppDelegate.m",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Contents.json",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/LaunchImage.imageset/Contents.json",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/LaunchImage.imageset/LaunchImage.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/LaunchImage.imageset/README.md",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Base.lproj/LaunchScreen.storyboard",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Base.lproj/Main.storyboard",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/Info.plist.tmpl",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.tmpl/main.m",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/project.pbxproj.tmpl",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/project.xcworkspace/contents.xcworkspacedata",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.xcodeproj.tmpl/xcshareddata/xcschemes/Runner.xcscheme",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.xcworkspace.tmpl/contents.xcworkspacedata",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.xcworkspace.tmpl/xcshareddata/IDEWorkspaceChecks.plist",
|
||||||
|
"templates/module/ios/host_app_ephemeral/Runner.xcworkspace.tmpl/xcshareddata/WorkspaceSettings.xcsettings",
|
||||||
|
"templates/module/ios/host_app_ephemeral_cocoapods/Config.tmpl/Debug.xcconfig",
|
||||||
|
"templates/module/ios/host_app_ephemeral_cocoapods/Config.tmpl/Release.xcconfig",
|
||||||
|
"templates/module/ios/host_app_ephemeral_cocoapods/Podfile.copy.tmpl",
|
||||||
|
"templates/module/ios/host_app_ephemeral_cocoapods/Runner.tmpl/AppDelegate.m",
|
||||||
|
"templates/module/ios/library/Flutter.tmpl/AppFrameworkInfo.plist",
|
||||||
|
"templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl",
|
||||||
|
"templates/module/ios/library/Flutter.tmpl/projectName.podspec.tmpl",
|
||||||
|
"templates/module/ios/library/Flutter.tmpl/README.md",
|
||||||
|
"templates/module/README.md",
|
||||||
|
"templates/package/.gitignore.tmpl",
|
||||||
|
"templates/package/.idea/libraries/Dart_SDK.xml.tmpl",
|
||||||
|
"templates/package/.idea/modules.xml.tmpl",
|
||||||
|
"templates/package/.idea/workspace.xml.tmpl",
|
||||||
|
"templates/package/.metadata.tmpl",
|
||||||
|
"templates/package/CHANGELOG.md.tmpl",
|
||||||
|
"templates/package/lib/projectName.dart.tmpl",
|
||||||
|
"templates/package/LICENSE.tmpl",
|
||||||
|
"templates/package/projectName.iml.tmpl",
|
||||||
|
"templates/package/pubspec.yaml.tmpl",
|
||||||
|
"templates/package/README.md.tmpl",
|
||||||
|
"templates/package/test/projectName_test.dart.tmpl",
|
||||||
|
"templates/plugin/.gitignore.tmpl",
|
||||||
|
"templates/plugin/.idea/libraries/Dart_SDK.xml.tmpl",
|
||||||
|
"templates/plugin/.idea/modules.xml.tmpl",
|
||||||
|
"templates/plugin/.idea/runConfigurations/example_lib_main_dart.xml.tmpl",
|
||||||
|
"templates/plugin/.idea/workspace.xml.tmpl",
|
||||||
|
"templates/plugin/.metadata.tmpl",
|
||||||
|
"templates/plugin/android-java.tmpl/build.gradle.tmpl",
|
||||||
|
"templates/plugin/android-java.tmpl/projectName_android.iml.tmpl",
|
||||||
|
"templates/plugin/android-java.tmpl/src/main/java/androidIdentifier/pluginClass.java.tmpl",
|
||||||
|
"templates/plugin/android-kotlin.tmpl/build.gradle.tmpl",
|
||||||
|
"templates/plugin/android-kotlin.tmpl/projectName_android.iml.tmpl",
|
||||||
|
"templates/plugin/android-kotlin.tmpl/src/main/kotlin/androidIdentifier/pluginClass.kt.tmpl",
|
||||||
|
"templates/plugin/android.tmpl/.gitignore",
|
||||||
|
"templates/plugin/android.tmpl/gradle/wrapper/gradle-wrapper.properties",
|
||||||
|
"templates/plugin/android.tmpl/gradle.properties.tmpl",
|
||||||
|
"templates/plugin/android.tmpl/settings.gradle.tmpl",
|
||||||
|
"templates/plugin/android.tmpl/src/main/AndroidManifest.xml.tmpl",
|
||||||
|
"templates/plugin/CHANGELOG.md.tmpl",
|
||||||
|
"templates/plugin/ios-objc.tmpl/Classes/pluginClass.h.tmpl",
|
||||||
|
"templates/plugin/ios-objc.tmpl/Classes/pluginClass.m.tmpl",
|
||||||
|
"templates/plugin/ios-objc.tmpl/projectName.podspec.tmpl",
|
||||||
|
"templates/plugin/ios-swift.tmpl/Classes/pluginClass.h.tmpl",
|
||||||
|
"templates/plugin/ios-swift.tmpl/Classes/pluginClass.m.tmpl",
|
||||||
|
"templates/plugin/ios-swift.tmpl/Classes/SwiftpluginClass.swift.tmpl",
|
||||||
|
"templates/plugin/ios-swift.tmpl/projectName.podspec.tmpl",
|
||||||
|
"templates/plugin/ios.tmpl/.gitignore",
|
||||||
|
"templates/plugin/ios.tmpl/Assets/.gitkeep",
|
||||||
|
"templates/plugin/lib/projectName.dart.tmpl",
|
||||||
|
"templates/plugin/LICENSE.tmpl",
|
||||||
|
"templates/plugin/linux.tmpl/CMakeLists.txt.tmpl",
|
||||||
|
"templates/plugin/linux.tmpl/include/projectName.tmpl/projectName_plugin.h.tmpl",
|
||||||
|
"templates/plugin/linux.tmpl/projectName_plugin.cc.tmpl",
|
||||||
|
"templates/plugin/macos.tmpl/Classes/pluginClass.swift.tmpl",
|
||||||
|
"templates/plugin/macos.tmpl/projectName.podspec.tmpl",
|
||||||
|
"templates/plugin/projectName.iml.tmpl",
|
||||||
|
"templates/plugin/pubspec.yaml.tmpl",
|
||||||
|
"templates/plugin/README.md.tmpl",
|
||||||
|
"templates/plugin/test/projectName_test.dart.tmpl",
|
||||||
|
"templates/plugin/windows.tmpl/.gitignore",
|
||||||
|
"templates/plugin/windows.tmpl/plugin.vcxproj.filters",
|
||||||
|
"templates/plugin/windows.tmpl/plugin.vcxproj.tmpl",
|
||||||
|
"templates/plugin/windows.tmpl/PluginInfo.props.tmpl",
|
||||||
|
"templates/plugin/windows.tmpl/projectName_plugin.cpp.tmpl",
|
||||||
|
"templates/plugin/windows.tmpl/projectName_plugin.h.tmpl",
|
||||||
|
"templates/plugin/lib/projectName_web.dart.tmpl"
|
||||||
|
]
|
||||||
|
}
|
@ -39,10 +39,14 @@ void main() {
|
|||||||
// Set up enough of the packages to satisfy the templating code.
|
// Set up enough of the packages to satisfy the templating code.
|
||||||
final File packagesFile = globals.fs.file(
|
final File packagesFile = globals.fs.file(
|
||||||
globals.fs.path.join('flutter', 'packages', 'flutter_tools', '.packages'));
|
globals.fs.path.join('flutter', 'packages', 'flutter_tools', '.packages'));
|
||||||
|
final File flutterManifest = globals.fs.file(
|
||||||
|
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'template_manifest.json'))
|
||||||
|
..createSync(recursive: true);
|
||||||
final Directory templateImagesDirectory = globals.fs.directory('flutter_template_images');
|
final Directory templateImagesDirectory = globals.fs.directory('flutter_template_images');
|
||||||
templateImagesDirectory.createSync(recursive: true);
|
templateImagesDirectory.createSync(recursive: true);
|
||||||
packagesFile.createSync(recursive: true);
|
packagesFile.createSync(recursive: true);
|
||||||
packagesFile.writeAsStringSync('flutter_template_images:file:///${templateImagesDirectory.uri}');
|
packagesFile.writeAsStringSync('flutter_template_images:file:///${templateImagesDirectory.uri}');
|
||||||
|
flutterManifest.writeAsStringSync('{"files":[]}');
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider(),
|
DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider(),
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'dart:io'; // ignore: dart_io_import
|
||||||
|
|
||||||
|
import 'package:path/path.dart' as path; // ignore: package_path_import
|
||||||
|
import 'package:flutter_tools/src/convert.dart';
|
||||||
|
import '../src/common.dart';
|
||||||
|
|
||||||
|
/// Checks that all active template files are defined in the template_manifest.json
|
||||||
|
void main() {
|
||||||
|
test('Check template manifest is up to date', () {
|
||||||
|
final Map<String, Object> manifest = json.decode(
|
||||||
|
File('templates/template_manifest.json').readAsStringSync(),
|
||||||
|
) as Map<String, Object>;
|
||||||
|
final Set<Uri> declaredFileList = Set<Uri>.from(
|
||||||
|
(manifest['files'] as List<Object>).cast<String>().map<Uri>(path.toUri));
|
||||||
|
|
||||||
|
final Set<Uri> activeTemplateList = Directory('templates')
|
||||||
|
.listSync(recursive: true)
|
||||||
|
.whereType<File>()
|
||||||
|
.where((File file) => path.basename(file.path) != 'template_manifest.json' &&
|
||||||
|
path.basename(file.path) != '.DS_Store')
|
||||||
|
.map((File file) => file.uri)
|
||||||
|
.toSet();
|
||||||
|
|
||||||
|
final Set<Uri> difference = activeTemplateList.difference(declaredFileList);
|
||||||
|
|
||||||
|
expect(difference, isEmpty, reason: 'manifest and template directory should be in-sync');
|
||||||
|
});
|
||||||
|
}
|
@ -21,7 +21,13 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Template.render throws ToolExit when FileSystem exception is raised', () => testbed.run(() {
|
test('Template.render throws ToolExit when FileSystem exception is raised', () => testbed.run(() {
|
||||||
final Template template = Template(globals.fs.directory('examples'), globals.fs.currentDirectory, null, fileSystem: globals.fs);
|
final Template template = Template(
|
||||||
|
globals.fs.directory('examples'),
|
||||||
|
globals.fs.currentDirectory,
|
||||||
|
null,
|
||||||
|
fileSystem: globals.fs,
|
||||||
|
templateManifest: null,
|
||||||
|
);
|
||||||
final MockDirectory mockDirectory = MockDirectory();
|
final MockDirectory mockDirectory = MockDirectory();
|
||||||
when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException());
|
when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException());
|
||||||
|
|
||||||
@ -40,7 +46,13 @@ void main() {
|
|||||||
sourceImage.createSync(recursive: true);
|
sourceImage.createSync(recursive: true);
|
||||||
sourceImage.writeAsStringSync('Ceci n\'est pas une pipe');
|
sourceImage.writeAsStringSync('Ceci n\'est pas une pipe');
|
||||||
|
|
||||||
final Template template = Template(templateDir, templateDir, imageSourceDir, fileSystem: fileSystem);
|
final Template template = Template(
|
||||||
|
templateDir,
|
||||||
|
templateDir,
|
||||||
|
imageSourceDir,
|
||||||
|
fileSystem: fileSystem,
|
||||||
|
templateManifest: null,
|
||||||
|
);
|
||||||
template.render(destination, <String, Object>{});
|
template.render(destination, <String, Object>{});
|
||||||
|
|
||||||
final File destinationImage = destination.childFile(imageName);
|
final File destinationImage = destination.childFile(imageName);
|
||||||
@ -52,7 +64,7 @@ void main() {
|
|||||||
final MemoryFileSystem fileSystem = MemoryFileSystem();
|
final MemoryFileSystem fileSystem = MemoryFileSystem();
|
||||||
|
|
||||||
// Attempting to run pub in a test throws.
|
// Attempting to run pub in a test throws.
|
||||||
await expectLater(Template.fromName('app', fileSystem: fileSystem),
|
await expectLater(Template.fromName('app', fileSystem: fileSystem, templateManifest: null),
|
||||||
throwsUnsupportedError);
|
throwsUnsupportedError);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -66,7 +78,7 @@ void main() {
|
|||||||
packagesFile.createSync(recursive: true);
|
packagesFile.createSync(recursive: true);
|
||||||
|
|
||||||
// Attempting to run pub in a test throws.
|
// Attempting to run pub in a test throws.
|
||||||
await expectLater(Template.fromName('app', fileSystem: fileSystem),
|
await expectLater(Template.fromName('app', fileSystem: fileSystem, templateManifest: null),
|
||||||
throwsUnsupportedError);
|
throwsUnsupportedError);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -88,7 +100,7 @@ void main() {
|
|||||||
packagesFile.writeAsStringSync('flutter_template_images:file:///flutter_template_images');
|
packagesFile.writeAsStringSync('flutter_template_images:file:///flutter_template_images');
|
||||||
});
|
});
|
||||||
|
|
||||||
await Template.fromName('app', fileSystem: fileSystem);
|
await Template.fromName('app', fileSystem: fileSystem, templateManifest: null);
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Pub: () => MockPub(),
|
Pub: () => MockPub(),
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user