-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce build and serve commands to standardized CLI
- Loading branch information
Showing
7 changed files
with
110 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ jobs: | |
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- name: Fetch packages | ||
- name: Fetch Dart packages | ||
run: dart pub get | ||
- name: Check Dart code formatting | ||
run: dart run dart_site format-dart --check | ||
|
@@ -57,25 +57,42 @@ jobs: | |
linkcheck: | ||
name: Build site and check links | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
with: | ||
submodules: recursive | ||
- run: make build | ||
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b | ||
with: | ||
sdk: stable | ||
- name: Fetch packages | ||
- name: Fetch Dart packages | ||
run: dart pub get | ||
- name: Check for broken Markdown links | ||
run: dart run dart_site check-link-references | ||
- name: Validate the firebase.json file | ||
run: dart run dart_site verify-firebase-json | ||
- uses: pnpm/action-setup@ebcfd6995dade4b0104ac774445cef8b3b4635b0 | ||
with: | ||
version: 8 | ||
- uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
- run: npm install -g [email protected] | ||
cache: 'pnpm' | ||
- name: Install node dependencies | ||
run: pnpm install | ||
- name: Build site | ||
run: dart run dart_site build | ||
- name: Check for broken Markdown links | ||
run: dart run dart_site check-link-references | ||
- name: Check internal site links are functional | ||
run: dart run dart_site check-links | ||
|
||
firebase-check: | ||
name: Check firebase declaration | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
with: | ||
submodules: recursive | ||
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b | ||
with: | ||
sdk: stable | ||
- name: Fetch Dart packages | ||
run: dart pub get | ||
- name: Validate the firebase.json file | ||
run: dart run dart_site verify-firebase-json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
steps: | ||
- name: gcr.io/cloud-builders/git | ||
args: ['submodule', 'update', '--init', '--recursive'] | ||
- name: gcr.io/cloud-builders/docker | ||
entrypoint: '/bin/bash' | ||
args: | ||
- '-c' | ||
- |- | ||
set -e | ||
echo "Building the website using a makefile..." | ||
make build | ||
make write-prod-robots | ||
- name: gcr.io/flutter-dev-230821/firebase-ghcli | ||
entrypoint: '/bin/bash' | ||
args: | ||
- '-c' | ||
- |- | ||
set -e | ||
npm install | ||
npm run prod | ||
firebase deploy --project=dart-dev --only=hosting | ||
options: | ||
logging: CLOUD_LOGGING_ONLY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:args/command_runner.dart'; | ||
|
||
import '../utils.dart'; | ||
|
||
final class BuildSiteCommand extends Command<int> { | ||
static const String _releaseFlag = 'release'; | ||
|
||
BuildSiteCommand() { | ||
argParser.addFlag( | ||
_releaseFlag, | ||
defaultsTo: false, | ||
help: 'Build a release build for dart.dev.', | ||
); | ||
} | ||
|
||
@override | ||
String get description => 'Build the site.'; | ||
|
||
@override | ||
String get name => 'build'; | ||
|
||
@override | ||
Future<int> run() async { | ||
final productionRelease = argResults.get<bool>(_releaseFlag, false); | ||
|
||
final process = await Process.start( | ||
'npx', | ||
const ['eleventy'], | ||
environment: { | ||
'PRODUCTION': '$productionRelease', | ||
}, | ||
); | ||
|
||
await stdout.addStream(process.stdout); | ||
await stderr.addStream(process.stderr); | ||
|
||
final processExitCode = await process.exitCode; | ||
return processExitCode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:args/command_runner.dart'; | ||
|
||
final class ServeSiteCommand extends Command<int> { | ||
@override | ||
String get description => 'Serve the site locally.'; | ||
|
||
@override | ||
String get name => 'serve'; | ||
|
||
@override | ||
Future<int> run() async { | ||
final process = await Process.start( | ||
'npx', | ||
const ['eleventy', '--serve', '--incremental'], | ||
environment: const { | ||
'PRODUCTION': 'false', | ||
}, | ||
runInShell: true, | ||
mode: ProcessStartMode.inheritStdio, | ||
); | ||
|
||
final processExitCode = await process.exitCode; | ||
return processExitCode; | ||
} | ||
} |