mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Leave a version tag when creating project (#12846)
* Leave a version tag when creating project * Generalize .version to .metadata
This commit is contained in:
parent
b865b0eb2f
commit
c17099f474
@ -24,6 +24,7 @@ import '../ios/xcodeproj.dart';
|
||||
import '../plugins.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../template.dart';
|
||||
import '../version.dart';
|
||||
|
||||
class CreateCommand extends FlutterCommand {
|
||||
CreateCommand() {
|
||||
@ -298,6 +299,8 @@ To edit platform code in an IDE see https://flutter.io/platform-plugins/#edit-co
|
||||
'withPluginHook': withPluginHook,
|
||||
'androidLanguage': androidLanguage,
|
||||
'iosLanguage': iosLanguage,
|
||||
'flutterRevision': FlutterVersion.instance.frameworkRevision,
|
||||
'flutterChannel': FlutterVersion.instance.channel,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
8
packages/flutter_tools/templates/create/.metadata.tmpl
Normal file
8
packages/flutter_tools/templates/create/.metadata.tmpl
Normal file
@ -0,0 +1,8 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: {{flutterRevision}}
|
||||
channel: {{flutterChannel}}
|
||||
@ -12,15 +12,21 @@ import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/create.dart';
|
||||
import 'package:flutter_tools/src/dart/sdk.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
||||
const String frameworkRevision = '12345678';
|
||||
const String frameworkChannel = 'omega';
|
||||
|
||||
void main() {
|
||||
group('create', () {
|
||||
Directory temp;
|
||||
Directory projectDir;
|
||||
FlutterVersion mockFlutterVersion;
|
||||
|
||||
setUpAll(() {
|
||||
Cache.disableLocking();
|
||||
@ -29,6 +35,7 @@ void main() {
|
||||
setUp(() {
|
||||
temp = fs.systemTempDirectory.createTempSync('flutter_tools');
|
||||
projectDir = temp.childDirectory('flutter_project');
|
||||
mockFlutterVersion = new MockFlutterVersion();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@ -171,6 +178,8 @@ void main() {
|
||||
// Verify content and formatting
|
||||
testUsingContext('content', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
|
||||
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
|
||||
|
||||
final CreateCommand command = new CreateCommand();
|
||||
final CommandRunner<Null> runner = createTestCommandRunner(command);
|
||||
@ -229,6 +238,16 @@ void main() {
|
||||
final File xcodeProjectFile = fs.file(fs.path.join(projectDir.path, xcodeProjectPath));
|
||||
final String xcodeProject = xcodeProjectFile.readAsStringSync();
|
||||
expect(xcodeProject, contains('PRODUCT_BUNDLE_IDENTIFIER = com.foo.bar.flutterProject'));
|
||||
|
||||
final String versionPath = fs.path.join('.metadata');
|
||||
expectExists(versionPath);
|
||||
final String version = fs.file(fs.path.join(projectDir.path, versionPath)).readAsStringSync();
|
||||
expect(version, contains('version:'));
|
||||
expect(version, contains('revision: 12345678'));
|
||||
expect(version, contains('channel: omega'));
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FlutterVersion: () => mockFlutterVersion,
|
||||
});
|
||||
|
||||
// Verify that we can regenerate over an existing project.
|
||||
@ -334,3 +353,5 @@ Future<Null> _analyzeProject(String workingDir, {String target}) async {
|
||||
}
|
||||
expect(exec.exitCode, 0);
|
||||
}
|
||||
|
||||
class MockFlutterVersion extends Mock implements FlutterVersion {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user