diff --git a/web/_tool/build_ci.dart b/web/_tool/build_ci.dart index 29bf7c50b..7ec84c992 100644 --- a/web/_tool/build_ci.dart +++ b/web/_tool/build_ci.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:path/path.dart' as p; import 'common.dart'; +import 'fix_base_tags.dart'; final ignoredDirectories = ['_tool', 'samples_index']; @@ -40,6 +41,9 @@ main() async { await _run(directory, 'flutter', ['build', 'web']); await _run(directory, 'mv', [sourceBuildDir, targetDirectory]); } + + // Update the tags in each index.html file + await fixBaseTags(); } // Invokes run() and exits if the sub-process failed. diff --git a/web/_tool/fix_base_tags.dart b/web/_tool/fix_base_tags.dart new file mode 100644 index 000000000..d81977b33 --- /dev/null +++ b/web/_tool/fix_base_tags.dart @@ -0,0 +1,50 @@ +import 'dart:io'; +import 'package:path/path.dart' as p; + +Future main() async { + await fixBaseTags(); +} + +/// Changes each sample's `` tag in index.html to +/// `` +/// +/// For example, after building using `build_ci.dart, +/// `../samples_index/public/web/navigation_and_routing/index.html` should +/// contain ` +Future 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') + ])); + if (!await builtSamplesDir.exists()) { + print('${builtSamplesDir.path} does not exist.'); + exit(1); + } + + await for (var builtSample in builtSamplesDir.list()) { + if (builtSample is Directory) { + var index = File(p.join(builtSample.path, 'index.html')); + if (!await index.exists()) { + throw ('no index.html file found in ${builtSample.path}'); + } + + var sampleDirName = p + .split(builtSample.path) + .last; + + if (await index.exists()) { + final regex = RegExp(''); + var contents = await index.readAsString(); + if (!contents.contains(regex)) { + continue; + } + var newContents = contents.replaceFirst( + regex, ''); + await index.writeAsString(newContents); + } + } + } +} diff --git a/web/charts/pubspec.lock b/web/charts/pubspec.lock index 5ba77e90c..fccf9a5ac 100644 --- a/web/charts/pubspec.lock +++ b/web/charts/pubspec.lock @@ -54,7 +54,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: transitive description: diff --git a/web/filipino_cuisine/pubspec.lock b/web/filipino_cuisine/pubspec.lock index bfefd9d8d..f94dde2d8 100644 --- a/web/filipino_cuisine/pubspec.lock +++ b/web/filipino_cuisine/pubspec.lock @@ -75,7 +75,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: transitive description: diff --git a/web/github_dataviz/pubspec.lock b/web/github_dataviz/pubspec.lock index 80010d113..31810fcc9 100644 --- a/web/github_dataviz/pubspec.lock +++ b/web/github_dataviz/pubspec.lock @@ -54,7 +54,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: transitive description: @@ -110,4 +110,4 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0 <3.0.0"