Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit a1829ba

Browse files
Add false secret lists, and enforce ordering (#4372)
1 parent 33ba6bc commit a1829ba

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ dev_dependencies:
3131
flutter_test:
3232
sdk: flutter
3333
pedantic: ^1.10.0
34+
35+
# The example deliberately includes limited-use secrets.
36+
false_secrets:
37+
- /example/web/index.html

packages/google_sign_in/google_sign_in/pubspec.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ dev_dependencies:
3636
integration_test:
3737
sdk: flutter
3838
pedantic: ^1.10.0
39+
40+
# The example deliberately includes limited-use secrets.
41+
false_secrets:
42+
- /example/android/app/google-services.json
43+
- /example/ios/Runner/GoogleService-Info.plist
44+
- /example/ios/RunnerTests/GoogleSignInTests.m
45+
- /example/lib/main.dart
46+
- /example/web/index.html

script/tool/lib/src/pubspec_check_command.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ class PubspecCheckCommand extends PackageLoopingCommand {
3939
'flutter:',
4040
'dependencies:',
4141
'dev_dependencies:',
42+
'false_secrets:',
4243
];
4344

4445
static const List<String> _majorPackageSections = <String>[
4546
'environment:',
4647
'dependencies:',
4748
'dev_dependencies:',
4849
'flutter:',
50+
'false_secrets:',
4951
];
5052

5153
static const String _expectedIssueLinkFormat =

script/tool/test/pubspec_check_command_test.dart

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ dev_dependencies:
113113
''';
114114
}
115115

116+
String falseSecretsSection() {
117+
return '''
118+
false_secrets:
119+
- /lib/main.dart
120+
''';
121+
}
122+
116123
test('passes for a plugin following conventions', () async {
117124
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
118125

@@ -122,6 +129,7 @@ ${environmentSection()}
122129
${flutterSection(isPlugin: true)}
123130
${dependenciesSection()}
124131
${devDependenciesSection()}
132+
${falseSecretsSection()}
125133
''');
126134

127135
final List<String> output = await runCapturingPrint(runner, <String>[
@@ -147,6 +155,7 @@ ${environmentSection()}
147155
${dependenciesSection()}
148156
${devDependenciesSection()}
149157
${flutterSection()}
158+
${falseSecretsSection()}
150159
''');
151160

152161
final List<String> output = await runCapturingPrint(runner, <String>[
@@ -399,7 +408,7 @@ ${dependenciesSection()}
399408
);
400409
});
401410

402-
test('fails when devDependencies section is out of order', () async {
411+
test('fails when dev_dependencies section is out of order', () async {
403412
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
404413

405414
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
@@ -426,6 +435,34 @@ ${dependenciesSection()}
426435
);
427436
});
428437

438+
test('fails when false_secrets section is out of order', () async {
439+
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
440+
441+
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
442+
${headerSection('plugin', isPlugin: true)}
443+
${environmentSection()}
444+
${flutterSection(isPlugin: true)}
445+
${dependenciesSection()}
446+
${falseSecretsSection()}
447+
${devDependenciesSection()}
448+
''');
449+
450+
Error? commandError;
451+
final List<String> output = await runCapturingPrint(
452+
runner, <String>['pubspec-check'], errorHandler: (Error e) {
453+
commandError = e;
454+
});
455+
456+
expect(commandError, isA<ToolExit>());
457+
expect(
458+
output,
459+
containsAllInOrder(<Matcher>[
460+
contains(
461+
'Major sections should follow standard repository ordering:'),
462+
]),
463+
);
464+
});
465+
429466
test('fails when an implemenation package is missing "implements"',
430467
() async {
431468
final Directory pluginDirectory = createFakePlugin(

0 commit comments

Comments
 (0)