Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .firebaserc

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
- 'sites/docs/**'
- 'examples/**'
- 'packages/excerpter/**'
- 'firebase.json'
- 'tool/dash_site/**'
- 'tool/config/linkcheck-skip-list.txt'
- 'pubspec.yaml'
Expand All @@ -22,7 +21,6 @@ on:
- 'sites/docs/**'
- 'examples/**'
- 'packages/excerpter/**'
- 'firebase.json'
- 'tool/dash_site/**'
- 'tool/config/linkcheck-skip-list.txt'
- 'pubspec.yaml'
Expand Down
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions sites/docs/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"projects": {
"default": "flutter-docs-prod",
"devtools-staging": "flutter-website-dt-staging"
"sz": "sz-flutter",
"sz2": "sz-flutter-2"
}
}
2 changes: 1 addition & 1 deletion firebase.json → sites/docs/firebase.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hosting": {
"public": "_site",
"public": "build/jaspr",
"cleanUrls": true,
"trailingSlash": false,
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion sites/docs/src/content/contribute/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 5 additions & 21 deletions tool/dash_site/lib/src/commands/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -68,34 +67,19 @@ Future<int> 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;
}
Expand Down
5 changes: 1 addition & 4 deletions tool/dash_site/lib/src/commands/check_links.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ Future<int> _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,
Expand Down
5 changes: 1 addition & 4 deletions tool/dash_site/lib/src/commands/deploy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ final class DeployCommand extends Command<int> {
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;
Expand Down
2 changes: 1 addition & 1 deletion tool/dash_site/lib/src/commands/stage_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Future<String?> _deploySiteToStaging(
'--expires',
expires,
'--json',
], workingDirectory: path.join(repositoryRoot, site.firebaseConfigDirectory));
], workingDirectory: path.join(repositoryRoot, site.directory));

if (result.exitCode != 0) {
stderr.writeln(result.stderr);
Expand Down
25 changes: 2 additions & 23 deletions tool/dash_site/lib/src/sites.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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<String> buildOutputPathSegments;

/// The path segments for this site's content directory,
/// relative to the site's [directory].
final List<String> contentPathSegments;

/// The path segments for this site's Firebase config file.
final List<String> firebaseConfigPathSegments;

/// The hosting emulator port declared in this site's Firebase config.
///
/// The value must match the `emulators.hosting.port` value in
Expand All @@ -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.
///
Expand Down
12 changes: 9 additions & 3 deletions tool/dash_site/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

Expand Down
Loading