diff --git a/.firebaserc b/.firebaserc deleted file mode 100644 index 4c0003aef7a..00000000000 --- a/.firebaserc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "projects": { - "default": "flutter-docs-prod", - "devtools-staging": "flutter-website-dt-staging", - "flutter-dev": "flutter-dev-230821", - "staging-1": "flutter-io-staging-1", - "staging-2": "flutter-io-staging-2", - "sz": "sz-flutter", - "sz2": "sz-flutter-2", - "ft": "flutter-web-staging", - "ats": "tony-flutter-site", - "filiph": "flutter-website-filiph-staging" - } -} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c44f28c7696..959208c7120 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,7 +8,6 @@ on: - 'sites/docs/**' - 'examples/**' - 'packages/excerpter/**' - - 'firebase.json' - 'tool/dash_site/**' - 'tool/config/linkcheck-skip-list.txt' - 'pubspec.yaml' @@ -22,7 +21,6 @@ on: - 'sites/docs/**' - 'examples/**' - 'packages/excerpter/**' - - 'firebase.json' - 'tool/dash_site/**' - 'tool/config/linkcheck-skip-list.txt' - 'pubspec.yaml' diff --git a/AGENTS.md b/AGENTS.md index 62929dde037..478c011e62e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,6 +36,8 @@ they use [Jaspr Content](https://docs.jaspr.site/content). for the sidenav, glossary, and various indices. - `sites/docs/src/_includes/`: Liquid partial files written in Markdown. + - `sites/docs/firebase.json`: + Firebase Hosting configuration for docs.flutter.dev. - `sites/www/`: The implementation of flutter.dev, written in Dart using Jaspr and Jaspr Content. diff --git a/sites/docs/.firebaserc b/sites/docs/.firebaserc new file mode 100644 index 00000000000..5091f2cd9cf --- /dev/null +++ b/sites/docs/.firebaserc @@ -0,0 +1,8 @@ +{ + "projects": { + "default": "flutter-docs-prod", + "devtools-staging": "flutter-website-dt-staging" + "sz": "sz-flutter", + "sz2": "sz-flutter-2" + } +} diff --git a/firebase.json b/sites/docs/firebase.json similarity index 99% rename from firebase.json rename to sites/docs/firebase.json index 79245abc9f9..111fa1c1b67 100644 --- a/firebase.json +++ b/sites/docs/firebase.json @@ -1,6 +1,6 @@ { "hosting": { - "public": "_site", + "public": "build/jaspr", "cleanUrls": true, "trailingSlash": false, "ignore": [ diff --git a/sites/docs/src/content/contribute/docs/index.md b/sites/docs/src/content/contribute/docs/index.md index 0a3a41ca468..42ea347fbe8 100644 --- a/sites/docs/src/content/contribute/docs/index.md +++ b/sites/docs/src/content/contribute/docs/index.md @@ -81,7 +81,7 @@ This document is a work in progress. - `eleventy.config.ts` The entrypoint for the site's [11ty][] static-site generation setup. -- `firebase.json` +- `sites/docs/firebase.json` Configuration for [Firebase Hosting][] that is used for the staged and deployed sites. diff --git a/tool/dash_site/lib/src/commands/build.dart b/tool/dash_site/lib/src/commands/build.dart index 1f3846bb200..25904d6dd69 100644 --- a/tool/dash_site/lib/src/commands/build.dart +++ b/tool/dash_site/lib/src/commands/build.dart @@ -5,7 +5,6 @@ import 'dart:io'; import 'package:args/command_runner.dart'; -import 'package:io/io.dart' as io; import 'package:path/path.dart' as path; import '../sites.dart'; @@ -68,34 +67,19 @@ Future buildSite(Site site, {required bool productionRelease}) async { return processExitCode; } - final originalOutputDirectoryPath = path.join( + final buildOutputDirectoryPath = path.join( repositoryRoot, - site.jasprBuildOutputDirectory, + site.buildOutputDirectory, ); - if (!Directory(originalOutputDirectoryPath).existsSync()) { + if (!Directory(buildOutputDirectoryPath).existsSync()) { stderr.writeln( 'Error: Jaspr output directory not found at: ' - '$originalOutputDirectoryPath', + '$buildOutputDirectoryPath', ); return 1; } - final siteOutputDirectoryPath = path.join( - repositoryRoot, - site.buildOutputDirectory, - ); - if (path.normalize(originalOutputDirectoryPath) != - path.normalize(siteOutputDirectoryPath)) { - final outputDirectory = Directory(siteOutputDirectoryPath); - if (outputDirectory.existsSync()) { - outputDirectory.deleteSync(recursive: true); - } - - // Copy the entire site output to the configured output directory. - io.copyPathSync(originalOutputDirectoryPath, siteOutputDirectoryPath); - } - - _move404File(siteOutputDirectoryPath); + _move404File(buildOutputDirectoryPath); return 0; } diff --git a/tool/dash_site/lib/src/commands/check_links.dart b/tool/dash_site/lib/src/commands/check_links.dart index 17b9217eb95..857418e50ff 100644 --- a/tool/dash_site/lib/src/commands/check_links.dart +++ b/tool/dash_site/lib/src/commands/check_links.dart @@ -68,10 +68,7 @@ Future _checkLinks({ 'Using firebase-tools $firebaseToolsVersion to start the ' 'Firebase hosting emulator asynchronously...', ); - final firebaseConfigDirectory = path.join( - repositoryRoot, - site.firebaseConfigDirectory, - ); + final firebaseConfigDirectory = path.join(repositoryRoot, site.directory); final firebaseConfigFileName = path.basename(site.firebaseConfigPath); final emulatorProcess = await Process.start( firebaseCliExecutable, diff --git a/tool/dash_site/lib/src/commands/deploy.dart b/tool/dash_site/lib/src/commands/deploy.dart index 08ad3ef73da..32e15181080 100644 --- a/tool/dash_site/lib/src/commands/deploy.dart +++ b/tool/dash_site/lib/src/commands/deploy.dart @@ -72,10 +72,7 @@ final class DeployCommand extends Command { final deploy = await Process.start( firebaseCliExecutable, ['deploy', '--project=$project', '--only=$only'], - workingDirectory: path.join( - repositoryRoot, - selectedSite.firebaseConfigDirectory, - ), + workingDirectory: path.join(repositoryRoot, selectedSite.directory), mode: ProcessStartMode.inheritStdio, ); return deploy.exitCode; diff --git a/tool/dash_site/lib/src/commands/stage_preview.dart b/tool/dash_site/lib/src/commands/stage_preview.dart index a5862cc29a6..5f3ec85dc48 100644 --- a/tool/dash_site/lib/src/commands/stage_preview.dart +++ b/tool/dash_site/lib/src/commands/stage_preview.dart @@ -208,7 +208,7 @@ Future _deploySiteToStaging( '--expires', expires, '--json', - ], workingDirectory: path.join(repositoryRoot, site.firebaseConfigDirectory)); + ], workingDirectory: path.join(repositoryRoot, site.directory)); if (result.exitCode != 0) { stderr.writeln(result.stderr); diff --git a/tool/dash_site/lib/src/sites.dart b/tool/dash_site/lib/src/sites.dart index 51c69ba5f85..7fdeda40dc5 100644 --- a/tool/dash_site/lib/src/sites.dart +++ b/tool/dash_site/lib/src/sites.dart @@ -10,9 +10,7 @@ enum Site { /// The Flutter documentation site. docs( host: 'docs.flutter.dev', - buildOutputPathSegments: ['_site'], contentPathSegments: ['src', 'content'], - firebaseConfigPathSegments: ['firebase.json'], firebaseEmulatorPort: 5502, defaultFirebaseProjectId: 'flutter-docs-prod', supportsCodeExcerpts: true, @@ -21,18 +19,14 @@ enum Site { /// The Flutter marketing site. www( host: 'flutter.dev', - buildOutputPathSegments: ['sites', 'www', 'build', 'jaspr'], contentPathSegments: ['content'], - firebaseConfigPathSegments: ['sites', 'www', 'firebase.json'], firebaseEmulatorPort: 5503, defaultFirebaseProjectId: 'flutter-dev-230821', ); const Site({ required this.host, - required this.buildOutputPathSegments, required this.contentPathSegments, - required this.firebaseConfigPathSegments, required this.firebaseEmulatorPort, required this.defaultFirebaseProjectId, this.supportsCodeExcerpts = false, @@ -44,17 +38,10 @@ enum Site { /// The canonical base URL where this site is hosted in production. String get baseUrl => 'https://$host'; - /// The path segments for this site's production build output directory, - /// relative to the repository root. - final List buildOutputPathSegments; - /// The path segments for this site's content directory, /// relative to the site's [directory]. final List contentPathSegments; - /// The path segments for this site's Firebase config file. - final List firebaseConfigPathSegments; - /// The hosting emulator port declared in this site's Firebase config. /// /// The value must match the `emulators.hosting.port` value in @@ -80,18 +67,10 @@ enum Site { path.joinAll([directory, ...contentPathSegments]); /// The directory where this site's production build output should end up. - String get buildOutputDirectory => path.joinAll(buildOutputPathSegments); - - /// The directory where Jaspr writes this site's production build, - /// before it is copied to [buildOutputDirectory] if different. - String get jasprBuildOutputDirectory => - path.join(directory, 'build', 'jaspr'); + String get buildOutputDirectory => path.join(directory, 'build', 'jaspr'); /// The location of this site's Firebase config file. - String get firebaseConfigPath => path.joinAll(firebaseConfigPathSegments); - - /// The directory containing this site's Firebase config file. - String get firebaseConfigDirectory => path.dirname(firebaseConfigPath); + String get firebaseConfigPath => path.join(directory, 'firebase.json'); /// The ports Jaspr uses when serving this site locally. /// diff --git a/tool/dash_site/lib/src/utils.dart b/tool/dash_site/lib/src/utils.dart index 09b5de5f5fb..8cdf5359192 100644 --- a/tool/dash_site/lib/src/utils.dart +++ b/tool/dash_site/lib/src/utils.dart @@ -13,9 +13,15 @@ final String repositoryRoot = () { final packageConfigPath = path.fromUri(Isolate.packageConfigSync); final maybeRoot = path.dirname(path.dirname(packageConfigPath)); - // As a quick confidence check, verify that the - // root directory contains the firebase.json file. - if (!File(path.join(maybeRoot, 'firebase.json')).existsSync()) { + // Verify this is the website repository by checking + // the dash_site tool exists where expected. + final dashSitePubspec = path.join( + maybeRoot, + 'tool', + 'dash_site', + 'pubspec.yaml', + ); + if (!File(dashSitePubspec).existsSync()) { throw StateError('Try running the tool from the root directory.'); }