mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 06:48:26 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -11,14 +11,14 @@ const ignoredDirectories = [
|
||||
'_tool',
|
||||
'_packages/web_startup_analyzer',
|
||||
'_packages/web_startup_analyzer/example',
|
||||
'samples_index'
|
||||
'samples_index',
|
||||
];
|
||||
|
||||
void main() async {
|
||||
final packageDirs = [
|
||||
...listPackageDirs(Directory.current)
|
||||
.map((path) => p.relative(path, from: Directory.current.path))
|
||||
.where((path) => !ignoredDirectories.contains(path))
|
||||
.where((path) => !ignoredDirectories.contains(path)),
|
||||
];
|
||||
|
||||
print('Building the sample index...');
|
||||
@@ -26,8 +26,9 @@ void main() async {
|
||||
await _run('samples_index', 'flutter', ['pub', 'run', 'grinder', 'deploy']);
|
||||
|
||||
// Create the directory each Flutter Web sample lives in
|
||||
Directory(p.join(Directory.current.path, 'samples_index', 'public', 'web'))
|
||||
.createSync(recursive: true);
|
||||
Directory(
|
||||
p.join(Directory.current.path, 'samples_index', 'public', 'web'),
|
||||
).createSync(recursive: true);
|
||||
|
||||
for (var i = 0; i < packageDirs.length; i++) {
|
||||
var directory = packageDirs[i];
|
||||
@@ -36,10 +37,19 @@ void main() async {
|
||||
|
||||
// Create the target directory
|
||||
var directoryName = p.basename(directory);
|
||||
var sourceBuildDir =
|
||||
p.join(Directory.current.path, directory, 'build', 'web');
|
||||
var targetDirectory = p.join(Directory.current.path, 'samples_index',
|
||||
'public', 'web', directoryName);
|
||||
var sourceBuildDir = p.join(
|
||||
Directory.current.path,
|
||||
directory,
|
||||
'build',
|
||||
'web',
|
||||
);
|
||||
var targetDirectory = p.join(
|
||||
Directory.current.path,
|
||||
'samples_index',
|
||||
'public',
|
||||
'web',
|
||||
directoryName,
|
||||
);
|
||||
|
||||
// Build the sample and copy the files
|
||||
await _run(directory, 'flutter', ['pub', 'get']);
|
||||
@@ -53,7 +63,10 @@ void main() async {
|
||||
|
||||
// Invokes run() and exits if the sub-process failed.
|
||||
Future<void> _run(
|
||||
String workingDir, String commandName, List<String> args) async {
|
||||
String workingDir,
|
||||
String commandName,
|
||||
List<String> args,
|
||||
) async {
|
||||
var success = await run(workingDir, commandName, args);
|
||||
if (!success) {
|
||||
exit(1);
|
||||
|
||||
@@ -9,7 +9,10 @@ const ansiRed = 31;
|
||||
const ansiMagenta = 35;
|
||||
|
||||
Future<bool> run(
|
||||
String workingDir, String commandName, List<String> args) async {
|
||||
String workingDir,
|
||||
String commandName,
|
||||
List<String> args,
|
||||
) async {
|
||||
var commandDescription = '`${([commandName, ...args]).join(' ')}`';
|
||||
|
||||
logWrapped(ansiMagenta, ' Running $commandDescription');
|
||||
@@ -25,7 +28,9 @@ Future<bool> run(
|
||||
|
||||
if (exitCode != 0) {
|
||||
logWrapped(
|
||||
ansiRed, ' Failed! ($exitCode) – $workingDir – $commandDescription');
|
||||
ansiRed,
|
||||
' Failed! ($exitCode) – $workingDir – $commandDescription',
|
||||
);
|
||||
return false;
|
||||
} else {
|
||||
logWrapped(ansiGreen, ' Success! – $workingDir – $commandDescription');
|
||||
|
||||
@@ -13,12 +13,14 @@ Future<void> main() async {
|
||||
/// contain `<base href="/samples/web/navigation_and_routing/">`
|
||||
Future<void> fixBaseTags() async {
|
||||
print('currentDir = ${Directory.current.path}');
|
||||
var builtSamplesDir = Directory(p.joinAll([
|
||||
// Parent directory
|
||||
...p.split(Directory.current.path),
|
||||
// path to built samples
|
||||
...p.split('samples_index/public/web')
|
||||
]));
|
||||
var builtSamplesDir = Directory(
|
||||
p.joinAll([
|
||||
// Parent directory
|
||||
...p.split(Directory.current.path),
|
||||
// path to built samples
|
||||
...p.split('samples_index/public/web'),
|
||||
]),
|
||||
);
|
||||
if (!await builtSamplesDir.exists()) {
|
||||
print('${builtSamplesDir.path} does not exist.');
|
||||
exit(1);
|
||||
@@ -40,7 +42,9 @@ Future<void> fixBaseTags() async {
|
||||
continue;
|
||||
}
|
||||
var newContents = contents.replaceFirst(
|
||||
regex, '<base href="/samples/web/$sampleDirName/">');
|
||||
regex,
|
||||
'<base href="/samples/web/$sampleDirName/">',
|
||||
);
|
||||
await index.writeAsString(newContents);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,10 @@ void _updateHtml(File htmlFile, String buildDir, String exampleDir) {
|
||||
|
||||
final newContent = content
|
||||
.replaceFirst('<head>', '<head>\n$_analytics')
|
||||
.replaceFirst(_emptyTitle,
|
||||
'<title>${_prettyName(exampleDir)} - Flutter web sample</title>');
|
||||
.replaceFirst(
|
||||
_emptyTitle,
|
||||
'<title>${_prettyName(exampleDir)} - Flutter web sample</title>',
|
||||
);
|
||||
|
||||
if (newContent == content) {
|
||||
print('!!! Did not replace contents in $filePath');
|
||||
@@ -79,10 +81,13 @@ void _updateHtml(File htmlFile, String buildDir, String exampleDir) {
|
||||
|
||||
final _underscoreOrSlash = RegExp('_|/');
|
||||
|
||||
String _prettyName(String input) =>
|
||||
input.split(_underscoreOrSlash).where((e) => e.isNotEmpty).map((e) {
|
||||
String _prettyName(String input) => input
|
||||
.split(_underscoreOrSlash)
|
||||
.where((e) => e.isNotEmpty)
|
||||
.map((e) {
|
||||
return e.substring(0, 1).toUpperCase() + e.substring(1);
|
||||
}).join(' ');
|
||||
})
|
||||
.join(' ');
|
||||
|
||||
// flutter.github.io
|
||||
const _analyticsId = 'UA-67589403-8';
|
||||
|
||||
@@ -2,7 +2,7 @@ name: tool
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
sdk: ^3.7.0-0
|
||||
|
||||
dependencies:
|
||||
markdown: ^7.0.0
|
||||
|
||||
@@ -9,10 +9,11 @@ import 'package:path/path.dart' as p;
|
||||
import 'common.dart';
|
||||
|
||||
void main() async {
|
||||
final packageDirs = listPackageDirs(Directory.current)
|
||||
.map((path) => p.relative(path, from: Directory.current.path))
|
||||
.where((path) => !p.dirname(path).startsWith('_'))
|
||||
.toList();
|
||||
final packageDirs =
|
||||
listPackageDirs(Directory.current)
|
||||
.map((path) => p.relative(path, from: Directory.current.path))
|
||||
.where((path) => !p.dirname(path).startsWith('_'))
|
||||
.toList();
|
||||
|
||||
print('Package dirs:\n${packageDirs.map((path) => ' $path').join('\n')}');
|
||||
|
||||
@@ -34,11 +35,14 @@ void main() async {
|
||||
results.add(false);
|
||||
continue;
|
||||
}
|
||||
results.add(await run(
|
||||
dir,
|
||||
'dart',
|
||||
['analyze', '--fatal-infos', '--fatal-warnings', '.'],
|
||||
));
|
||||
results.add(
|
||||
await run(dir, 'dart', [
|
||||
'analyze',
|
||||
'--fatal-infos',
|
||||
'--fatal-warnings',
|
||||
'.',
|
||||
]),
|
||||
);
|
||||
_printStatus(results);
|
||||
}
|
||||
|
||||
@@ -52,6 +56,8 @@ void _printStatus(List<bool> results) {
|
||||
var success = (successCount == results.length);
|
||||
var pct = 100 * successCount / results.length;
|
||||
|
||||
logWrapped(success ? ansiGreen : ansiRed,
|
||||
'$successCount of ${results.length} (${pct.toStringAsFixed(2)}%)');
|
||||
logWrapped(
|
||||
success ? ansiGreen : ansiRed,
|
||||
'$successCount of ${results.length} (${pct.toStringAsFixed(2)}%)',
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user