diff --git a/.gitignore b/.gitignore
index 8e22b7bee89..5b912082d28 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,10 +9,14 @@ node_modules
# Dart and Flutter
.flutter-plugins
.packages
-.pub/
-pubspec.lock
+.dart_tool
+# pubspec.lock
packages
-example.g/
+example.g
+
+# We haven't had any issues due to npm (sub-)package version discrepancies,
+# so we'll ignore the npm lock file for now.
+package-lock.json
src/_includes/code/**/android/
src/_includes/code/**/ios/
diff --git a/.travis.yml b/.travis.yml
index 379cf7262b7..393ac271b4e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
-language: node_js
-node_js: 10
-sudo: false
+language: dart
+dart: stable
# Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18
# https://github.com/flutter/flutter/issues/6207
@@ -22,12 +21,18 @@ env:
- TASK="bundle exec jekyll build"
before_install:
- - rvm install 2.4.3
- - rvm use 2.4.3
+ - source ./tool/env-set.sh
- ./tool/before_install.sh
+install:
+ - ./tool/install.sh
+ # - ./tool/write-ci-info.sh -v
+
script: $TASK
+after_script:
+ - if [[ $TASK == *build* ]]; then ./tool/check-links.sh || travis_terminate 1; fi
+
deploy:
- provider: script
script: ./tool/deploy.sh --install dash # TODO: drop dash
diff --git a/README.md b/README.md
index e834627c80e..91c9664421d 100644
--- a/README.md
+++ b/README.md
@@ -1,51 +1,87 @@
# [Flutter][]'s website
-The website for [Flutter][].
-
-[](https://cirrus-ci.com/github/flutter/website/master)
+[![Build Status SVG][]][Repo on Travis]
## Issues, bugs, and requests
We welcome contributions and feedback on our website!
Please file a request in our
-[issue tracker](https://github.com/flutter/flutter/issues/new)
+[issue tracker](https://github.com/flutter/website/issues/new)
and we'll take a look.
-## Developing
+For simple changes (such as to CSS and text), you probably don't need to build this site.
+Often you can make changes using the GitHub UI.
+
+If you want/need to build, read on.
+
+## Before you build this site
+
+### 1. Get the prerequisites
+
+Install the following tools if you don't have them already.
+
+- **[nvm][]**, the Node Version Manager.
+- **[rvm][]**, the Ruby Version Manager.
+- **[Flutter][Flutter install]**
+- **[Dart SDK][Dart install]**
-Install Jekyll and related tools by following the
-[instructions](https://help.github.com/articles/using-jekyll-with-pages/)
-provided by GitHub.
+> IMPORTANT: Follow the installation instructions for each of the tools
+carefully. In particular, configure your shell/environment so
+that the tools are available in every terminal/command window you create.
-A tldr version follows:
+### 2. Clone this repo _and_ its submodule
- 1. Ensure you have [Ruby](https://www.ruby-lang.org/en/documentation/installation/)
- installed; you need version 2.4.3 or later:
- `ruby --version`
+> NOTE: This repo has a git _submodule_, which affects how you clone it.
- 1. Ensure you have [Bundler](http://bundler.io/) installed; if not install with:
- `gem install bundler`
+To **clone [this repo][]**, follow the instructions given in the
+GitHub help on [Cloning a repository][], and _choose one_ of the following
+submodule-cloning techniques:
- 1. Install Ruby gems:
`bundle install`
- * On macOS, if you encounter errors while building native Ruby extensions, see [Installing Nokogiri](http://www.nokogiri.org/tutorials/installing_nokogiri.html#mac_os_x) for troubleshooting tips.
+- Clone this repo and its submodule _at the same_, use the
+ `--recurse-submodules` option:
+ `git clone --recurse-submodules https://github.com/flutter/website.git`
+- If you've already cloned this repo without its submodule, then run
+ this command from the repo root:
+ `git submodule update --init --remote`
- 1. Install tool for serving locally (one-time setup):
- `npm install -g superstatic`
+> IMPORTANT:
+> Whenever you update your repo, update the submodule as well:
+> `git pull; git submodule update --init --remote`
- 1. (Optional) If you plan to deploy to a firebase project, install this package (one-time setup):
- `npm install -g firebase-tools`
+### 3. Run installation scripts
+
+> NOTE: It is safe to (re-)run all of the commands and scripts given below even
+if you already have the required packages installed.
+
+**Open a terminal/command window** and execute the following commands:
+
+1. cd \ # change to
+ **root of this repo**
+1. `source ./tool/env-set.sh` #
+ initialize environment variables; install/use required Node & Ruby version
+1. `./tool/before-install.sh` #
+ install core set of required tools
+1. `./tool/install.sh` #
+ install everything else needed to build this site
+
+> IMPORTANT:
+> - Any time you create a **new terminal/command window** to work on
+> this repo, **repeat steps 1 and 2** above.
+> - If you upgrade Dart then rerun all of the steps above.
+
+## Developing
1. Create a branch.
1. Make your changes.
- 1. Test your changes by serving the site locally. Run either one of these commands:
+ 1. Test your changes by serving the site locally. Run either **one** of these commands:
- - `tool/serve.sh`
+ - `tool/serve.sh`, _or_
- `bundle exec jekyll serve --incremental --watch --livereload --port 4002`
1. Prior to submitting, run link validation:
- `rake checklinks`
+ `tool/check-links.sh`
## Deploy to a staging site
@@ -274,7 +310,7 @@ redirects (`rake checklinks` doesn't run the Firebase server) and it won't
check incoming links.
Before we can move the more complete
-[automated `linkcheck` solution](https://github.com/dart-lang/site-webdev/blob/master/scripts/check-links-using-fb.sh)
+[automated `linkcheck` solution](https://github.com/dart-lang/site-webdev/blob/master/tool/check-links-using-fb.sh)
from dartlang.org, we recommend manually running the following.
* First time setup:
@@ -301,3 +337,16 @@ from dartlang.org, we recommend manually running the following.
```
linkcheck :4002 --input-file tool/sitemap.txt
```
+
+[Build Status SVG]: https://travis-ci.org/flutter/website.svg?branch=dash
+[Cloning a repository]: https://help.github.com/articles/cloning-a-repository
+[Dart install]: https://www.dartlang.org/install
+[Flutter install]: https://flutter.io/get-started/install
+[Firebase]: https://firebase.google.com/
+[first-timers SVG]: https://img.shields.io/badge/first--timers--only-friendly-blue.svg?style=flat-square
+[first-timers]: https://www.firsttimersonly.com/
+[Jekyll]: https://jekyllrb.com/
+[nvm]: https://github.com/creationix/nvm#installation
+[Repo on Travis]: https://travis-ci.org/flutter/website
+[rvm]: https://rvm.io/rvm/install#installation
+[this repo]: https://github.com/flutter/website
diff --git a/analysis_options.yaml b/example/analysis_options.yaml
similarity index 100%
rename from analysis_options.yaml
rename to example/analysis_options.yaml
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
new file mode 100644
index 00000000000..29dbb50d39c
--- /dev/null
+++ b/example/pubspec.yaml
@@ -0,0 +1,16 @@
+name: flutter_io_examples
+
+environment:
+ sdk: '>=2.0.0-dev <3.0.0'
+
+dev_dependencies:
+ flutter_driver:
+ sdk: flutter
+ path: ^1.5.0
+ test: '>= 0.12.37 <2.0.0'
+ url_launcher: ^3.0.3
+ path_provider: ^0.4.1
+ shared_preferences: 0.4.1
+ transparent_image: 0.1.0
+ css_colors: 1.0.2
+ web_socket_channel: 1.0.9
diff --git a/package.json b/package.json
new file mode 100644
index 00000000000..ab851008ab9
--- /dev/null
+++ b/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "www.dartlang.org",
+ "version": "0.0.0",
+ "private": true,
+ "description": "www.dartlang.org",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dart-lang/site-www.git"
+ },
+ "devDependencies": {
+ "firebase-tools": "4.0.3",
+ "superstatic": "^5.0.2"
+ }
+}
diff --git a/pubspec.lock b/pubspec.lock
new file mode 100644
index 00000000000..7883e6e69c0
--- /dev/null
+++ b/pubspec.lock
@@ -0,0 +1,401 @@
+# Generated by pub
+# See https://www.dartlang.org/tools/pub/glossary#lockfile
+packages:
+ analyzer:
+ dependency: transitive
+ description:
+ name: analyzer
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.32.4"
+ args:
+ dependency: transitive
+ description:
+ name: args
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.5.0"
+ async:
+ dependency: transitive
+ description:
+ name: async
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.8"
+ build:
+ dependency: transitive
+ description:
+ name: build
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.12.7+3"
+ build_config:
+ dependency: transitive
+ description:
+ name: build_config
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.3.1+2"
+ build_resolvers:
+ dependency: transitive
+ description:
+ name: build_resolvers
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.2+3"
+ build_runner:
+ dependency: "direct dev"
+ description:
+ name: build_runner
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.10.1+1"
+ build_runner_core:
+ dependency: transitive
+ description:
+ name: build_runner_core
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.3.1+5"
+ built_collection:
+ dependency: transitive
+ description:
+ name: built_collection
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "4.0.0"
+ built_value:
+ dependency: transitive
+ description:
+ name: built_value
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "6.1.2"
+ charcode:
+ dependency: transitive
+ description:
+ name: charcode
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.2"
+ cli_util:
+ dependency: transitive
+ description:
+ name: cli_util
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.3+2"
+ code_builder:
+ dependency: transitive
+ description:
+ name: code_builder
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.1.3"
+ code_excerpt_updater:
+ dependency: "direct dev"
+ description:
+ path: "."
+ ref: HEAD
+ resolved-ref: "6e4b0405f528a788146bf6b6e2cd7b0de9f2b8bc"
+ url: "https://github.com/chalin/code_excerpt_updater.git"
+ source: git
+ version: "0.11.0"
+ code_excerpter:
+ dependency: "direct dev"
+ description:
+ path: "."
+ ref: HEAD
+ resolved-ref: "271e692bb0fd7886be65c441ee2849ccadf61b2f"
+ url: "https://github.com/chalin/code_excerpter.git"
+ source: git
+ version: "0.4.1"
+ collection:
+ dependency: transitive
+ description:
+ name: collection
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.14.11"
+ console:
+ dependency: transitive
+ description:
+ name: console
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.0.0"
+ convert:
+ dependency: transitive
+ description:
+ name: convert
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.2"
+ crypto:
+ dependency: transitive
+ description:
+ name: crypto
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.6"
+ csslib:
+ dependency: transitive
+ description:
+ name: csslib
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.14.5"
+ dart_style:
+ dependency: transitive
+ description:
+ name: dart_style
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.3"
+ fixnum:
+ dependency: transitive
+ description:
+ name: fixnum
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.10.8"
+ front_end:
+ dependency: transitive
+ description:
+ name: front_end
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.4"
+ glob:
+ dependency: transitive
+ description:
+ name: glob
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.7"
+ graphs:
+ dependency: transitive
+ description:
+ name: graphs
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.2+1"
+ html:
+ dependency: transitive
+ description:
+ name: html
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.13.3+3"
+ http_multi_server:
+ dependency: transitive
+ description:
+ name: http_multi_server
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.5"
+ http_parser:
+ dependency: transitive
+ description:
+ name: http_parser
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.1.3"
+ io:
+ dependency: transitive
+ description:
+ name: io
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.3.3"
+ json_annotation:
+ dependency: transitive
+ description:
+ name: json_annotation
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0"
+ kernel:
+ dependency: transitive
+ description:
+ name: kernel
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.3.4"
+ linkcheck:
+ dependency: "direct dev"
+ description:
+ name: linkcheck
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.4"
+ logging:
+ dependency: transitive
+ description:
+ name: logging
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.11.3+2"
+ matcher:
+ dependency: transitive
+ description:
+ name: matcher
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.12.3+1"
+ meta:
+ dependency: transitive
+ description:
+ name: meta
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.6"
+ mime:
+ dependency: transitive
+ description:
+ name: mime
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.9.6+2"
+ package_config:
+ dependency: transitive
+ description:
+ name: package_config
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.5"
+ path:
+ dependency: transitive
+ description:
+ name: path
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.6.2"
+ plugin:
+ dependency: transitive
+ description:
+ name: plugin
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.0+3"
+ pool:
+ dependency: transitive
+ description:
+ name: pool
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.3.6"
+ pub_semver:
+ dependency: transitive
+ description:
+ name: pub_semver
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.4.2"
+ pubspec_parse:
+ dependency: transitive
+ description:
+ name: pubspec_parse
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.2+2"
+ quiver:
+ dependency: transitive
+ description:
+ name: quiver
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.0+1"
+ shelf:
+ dependency: transitive
+ description:
+ name: shelf
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.7.3+3"
+ shelf_web_socket:
+ dependency: transitive
+ description:
+ name: shelf_web_socket
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.2+4"
+ source_span:
+ dependency: transitive
+ description:
+ name: source_span
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.4.1"
+ stack_trace:
+ dependency: transitive
+ description:
+ name: stack_trace
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.9.3"
+ stream_channel:
+ dependency: transitive
+ description:
+ name: stream_channel
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.6.8"
+ stream_transform:
+ dependency: transitive
+ description:
+ name: stream_transform
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.0.14+1"
+ string_scanner:
+ dependency: transitive
+ description:
+ name: string_scanner
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.4"
+ typed_data:
+ dependency: transitive
+ description:
+ name: typed_data
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.6"
+ utf:
+ dependency: transitive
+ description:
+ name: utf
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.9.0+5"
+ vector_math:
+ dependency: transitive
+ description:
+ name: vector_math
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.8"
+ watcher:
+ dependency: transitive
+ description:
+ name: watcher
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.9.7+10"
+ web_socket_channel:
+ dependency: transitive
+ description:
+ name: web_socket_channel
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.9"
+ yaml:
+ dependency: transitive
+ description:
+ name: yaml
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.15"
+sdks:
+ dart: ">=2.0.0 <3.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 0dd4cb94b97..568d5bb4731 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,20 +1,18 @@
-# TODO(chalin): Consider using two pubspecs:
-# - This main one should depend on the Dart VM and be used to run VM scripts.
-# - Another pubspec (possibly under exmaples.g), would be for running examples.
-
name: flutter_io
environment:
sdk: '>=2.0.0-dev <3.0.0'
dev_dependencies:
- flutter_driver:
- sdk: flutter
- path: ^1.5.0
- test: '>= 0.12.37 <2.0.0'
- url_launcher: ^3.0.3
- path_provider: ^0.4.1
- shared_preferences: 0.4.1
- transparent_image: 0.1.0
- css_colors: 1.0.2
- web_socket_channel: 1.0.9
+ build_runner: ^0.10.1
+ code_excerpt_updater: any
+ code_excerpter: any
+ linkcheck: ^2.0.4
+
+dependency_overrides:
+ code_excerpt_updater:
+ git: https://github.com/chalin/code_excerpt_updater.git
+ # path: ../code_excerpt_updater
+ code_excerpter:
+ git: https://github.com/chalin/code_excerpter.git
+ # path: ../code_excerpter
diff --git a/src/_includes/code/layout/main.dart b/src/_includes/code/layout/main.dart
deleted file mode 100644
index ff2ce532d52..00000000000
--- a/src/_includes/code/layout/main.dart
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:flutter/material.dart';
-
-void main() {
- runApp(MyApp());
-}
-
-class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(title: 'Flutter Demo Home Page'),
- );
- }
-}
-
-class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
-
- final String title;
-
- @override
- _MyHomePageState createState() => _MyHomePageState();
-}
-
-class _MyHomePageState extends State {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text(widget.title),
- ),
- body: Center(
- child: Text('Hello World'),
- ),
- );
- }
-}
diff --git a/tool/before_install.sh b/tool/before_install.sh
index e11a46fbf53..c853b2986ed 100755
--- a/tool/before_install.sh
+++ b/tool/before_install.sh
@@ -3,18 +3,43 @@
# Fast fail the script on failures.
set -e
-echo "Downloading Flutter"
+[[ -z "$DART_SITE_ENV_DEFS" ]] && . ./tool/env-set.sh
+
+if [[ "$1" == --force ]]; then FORCE=1; fi
+
+# if [[ -n "$TRAVIS" ]]; then
+# ./tool/env-info-and-check.sh
+# fi
+
+FLUTTER_ROOT=../flutter
+FLUTTER_BIN="$FLUTTER_ROOT/bin"
# Run doctor to download the Dart SDK that is vendored with Flutter
-(cd ..; git clone -b beta https://github.com/flutter/flutter.git ; cd flutter ; ./bin/flutter doctor)
+if [[ ! -e "$FLUTTER_ROOT" || -n "$FORCE" ]]; then
+ echo "Downloading Flutter"
+ (
+ set -x;
+ git clone -b beta https://github.com/flutter/flutter.git "$FLUTTER_ROOT";
+ "$FLUTTER_BIN/flutter" doctor
+ )
+else
+ echo "Flutter already installed: $FLUTTER_ROOT"
+fi
# Don't download oauth tool since we don't currently use it.
# echo "Download Google OAuth Tool"
# pip install --user google-oauth2l --upgrade
-if [[ -z "$TASK" || "$TASK" == *jekyll* || "$TASK" == *rake* ]]; then
- echo "Install bundler and gems"
- gem install bundler
- bundle install
-else
- echo "SKIPPING 'Install bundler and gems' since this isn't a jekyll build task"
-fi
+# Jekyll needs Ruby and the Ruby bundler
+travis_fold start before_install.ruby_bundler
+ if [[ -n "$TRAVIS" || -n "$FORCE" || -z "$(type -t bundler)" ]]; then
+ (set -x; gem install bundler)
+ else
+ echo "Bundler already installed. Use --force to reinstall/update."
+ fi
+travis_fold end before_install.ruby_bundler
+
+# ./tool/install-dart-sdk.sh
+
+travis_fold start before_install.pub
+ pub get
+travis_fold end before_install.pub
diff --git a/tool/build_check_deploy.sh b/tool/build_check_deploy.sh
index 1165f93929b..f88245fb7f4 100755
--- a/tool/build_check_deploy.sh
+++ b/tool/build_check_deploy.sh
@@ -67,7 +67,7 @@ function deploy() {
local project="$2"
while [[ "$remaining_tries" > 0 ]]; do
# FIREBASE_TOKEN is set in the .cirrus.yml file.
- firebase deploy --token "$FIREBASE_TOKEN" --non-interactive --project "$project" && break
+ npx firebase deploy --token "$FIREBASE_TOKEN" --non-interactive --project "$project" && break
remaining_tries=$(($remaining_tries - 1))
error "Error: Unable to deploy project $project to Firebase. Retrying in five seconds... ($remaining_tries tries left)"
sleep 5
@@ -123,26 +123,38 @@ echo "Using Dart SDK: $dart"
"$dart" --version
if [[ -n $PUB_CMD ]]; then
+ (
+ set -x;
+ rm -Rf example.g
+ mkdir -pv example.g
+ cp example/* example.g/
+ )
+
+ pushd example.g > /dev/null
"$flutter" packages $PUB_CMD
# Analyze the stand-alone sample code files
- for sample in src/_includes/code/*/*; do
+ for sample in ../src/_includes/code/*/*; do
if [[ -d "${sample}" ]]; then
echo "Run flutter packages $PUB_CMD on ${sample}"
"$flutter" packages $PUB_CMD ${sample}
fi
done
+ popd > /dev/null
fi
if [[ -n $CHECK_CODE ]]; then
echo "ANALYZING _includes/code/*:"
- "$flutter" analyze --no-current-package src/_includes/code/
+ (
+ cd example.g;
+ "$flutter" analyze --no-current-package ../src/_includes/code/*/
+ )
echo "EXTRACTING code snippets from the markdown:"
- "$dart" --preview-dart-2 tool/extract.dart
+ "$dart" tool/extract.dart
echo "ANALYZING extracted code snippets:"
- "$flutter" analyze --no-current-package example.g/
+ (cd example.g; "$flutter" analyze --no-current-package .)
echo "DARTFMT check of extracted code snippets:"
check_formatting example.g/*.dart
diff --git a/tool/check-links.sh b/tool/check-links.sh
new file mode 100755
index 00000000000..eff6d716e35
--- /dev/null
+++ b/tool/check-links.sh
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+#
+# Tweaked a copy of https://github.com/dart-lang/site-shared/blob/master/tool/serve.sh
+
+set -e -o pipefail
+
+[[ -z "$DART_SITE_ENV_DEFS" ]] && . ./tool/env-set.sh
+
+PORT=${SITE_LOCALHOST_PORT:-4002}
+
+set +e
+SITE=$(grep '^destination:' _config.yml | awk '{ print $2}')
+set -e
+: ${SITE:-_site}
+
+if [ ! -e "./$SITE" ]; then
+ echo "INFO: $SITE directory not found. Site not built? Skipping link checks."
+ exit 0
+fi
+
+set -x
+npx superstatic --port $PORT 2>&1 | tee > "$TMP/superstatic-log.txt" &
+set +x
+SERVER_PID=$!
+sleep 2
+if [[ -n "$TRAVIS" ]]; then sleep 2; fi
+
+if ! kill -0 $SERVER_PID > /dev/null 2>&1; then
+ echo; echo "WARNING: Failed to launch superstatic server. I'll assume it is already running."
+ if [[ -n "$TRAVIS" ]]; then
+ echo "Here's the report error (that we're ignoring):"; echo
+ cat "$TMP/superstatic-log.txt"
+ fi
+ echo
+ SERVER_PID=
+else
+ echo "Server PID: $SERVER_PID"
+fi
+
+# Don't check for external links yet since it seems to cause problems on Travis: --external
+set -x
+pub run linkcheck \
+ --skip-file ./tool/config/linkcheck-skip-list.txt \
+ :$PORT \
+ | tee "$TMP/linkcheck-log.txt"
+set +x
+
+if ! grep '^\s*0 errors' "$TMP/linkcheck-log.txt" | wc -l > /dev/null; then
+ CHECK_EXIT_CODE=1
+ echo; cat "$TMP/superstatic-log.txt"; echo
+else
+ CHECK_EXIT_CODE=0
+fi
+
+if [[ -n $SERVER_PID ]]; then kill $SERVER_PID; fi
+
+exit $CHECK_EXIT_CODE
diff --git a/tool/config/linkcheck-skip-list.txt b/tool/config/linkcheck-skip-list.txt
new file mode 100644
index 00000000000..3992a921bc2
--- /dev/null
+++ b/tool/config/linkcheck-skip-list.txt
@@ -0,0 +1,11 @@
+# Enter regexp pattern, one per line.
+
+# FIXME(Temporary):
+/web-analogs
+/flutter-for-*
+/get-startedflutter-for
+/using-ide
+/hot-reload
+/inspector
+/formatting
+/images/intellij/main-toolbar.png
diff --git a/tool/deploy.sh b/tool/deploy.sh
index f57f535fc9b..8a78e4b6c0e 100755
--- a/tool/deploy.sh
+++ b/tool/deploy.sh
@@ -2,23 +2,13 @@
if [ ! $(type -t travis_fold) ]; then travis_fold () { true; } fi
-function _installFBT() {
- _PKG="firebase-tools@4.0.3"
- if ! type -t firebase > /dev/null; then
- travis_fold start deploy.firebase-tools-install
- (set -x; npm install --global $_PKG)
- travis_fold end deploy.firebase-tools-install
- fi
-}
-
function _error() { echo "ERROR: $1"; exit 1; }
function _usage() {
- echo "Usage: $(basename $0) [--help] [--install] [--local] [--quiet] [firebase-project-name]";
+ echo "Usage: $(basename $0) [--help] [--local] [--quiet] [firebase-project-name]";
echo
echo " If unspecified, default firebase project is 'default'."
echo
- echo " --install Does a global npm install of firebase-tools if necessary."
echo " --local Deploy locally from an interactive shell where you are"
echo " already authenticated and logged in with firebase."
echo
@@ -28,7 +18,6 @@ function _usage() {
while [[ "$1" == -* ]]; do
case "$1" in
-h|--help) _usage;;
- -i|--install) _installFBT; shift;;
-l|--local) LOCAL=1; shift;;
-q|--quiet) QUIET=1; shift;;
*) _error echo "Unrecognized option: $1. Use --help for details.";;
@@ -50,4 +39,4 @@ if [[ -z $QUIET ]]; then
echo "Deploying to Firebase project: $_FB_PROJ"
set -x # Travis masks out secrets from logs so enabling command echo is safe.
fi
-firebase deploy $_ARGS
+npx firebase deploy $_ARGS
diff --git a/tool/env-set.sh b/tool/env-set.sh
new file mode 100644
index 00000000000..7c38c0c50fc
--- /dev/null
+++ b/tool/env-set.sh
@@ -0,0 +1,18 @@
+# This bash file is meant to be source'd, not executed.
+
+source tool/shared/env-set.sh
+
+# Temporary, until we start using site-shared:
+
+# nvm install 10
+# nvm use 10
+# rvm install 2.4.3
+# rvm use 2.4.3
+
+# function travis_fold () { true; }
+# export -f travis_fold
+
+# : ${TMP:=tmp}
+# [[ -e "$TMP" ]] || mkdir -pv "$TMP"
+
+# Site specific settings here: currently, none.
diff --git a/tool/install.sh b/tool/install.sh
new file mode 100755
index 00000000000..749b5cf7382
--- /dev/null
+++ b/tool/install.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+set -e -o pipefail
+
+cd `dirname $0`/..
+
+if [[ "$(node --version)" < "v10" ]]; then
+ echo "ERROR: bad version of node detected. If you have nvm installed, type:"
+ echo " nvm use"
+ echo "Aborting installation."
+ exit 1;
+else
+ echo "Node version: $(node --version)"
+fi
+
+travis_fold start install.npm_install
+ (set -x; npm install --no-optional)
+travis_fold end install.npm_install
+
+if [[ "$TASK" == build* ]]; then
+ travis_fold start install.bundle
+ (set -x; bundle install)
+ travis_fold end install.bundle
+fi
+
+echo "Installation done"
diff --git a/tool/serve.sh b/tool/serve.sh
index 878183f2066..39b5cbeb638 100755
--- a/tool/serve.sh
+++ b/tool/serve.sh
@@ -1,33 +1,47 @@
#!/usr/bin/env bash
#
-# Copied from https://github.com/dart-lang/site-shared/blob/master/tool/serve.sh
+# Tweaked a copy of https://github.com/dart-lang/site-shared/blob/master/tool/serve.sh
set -e -o pipefail
# Assume that this script will be linked to ~/scripts/foo or ~/tool/foo in the parent repo.
cd `dirname $0`/..
-SERVE=superstatic
+SERVE="npx superstatic"
+JEKYLL_OPTS="--incremental --watch "
while [[ "$1" == -* ]]; do
case "$1" in
- --dev) FILE=_config_dev.yml
- if [[ -e $FILE ]]; then
- CONFIG=",$FILE$CONFIG"
- else
- echo "Warning: $1 option ignored because $FILE not found"
- fi
- shift;;
- --pin-now) FILE=_config_now.yml
- if [[ -e $FILE ]]; then
- CONFIG=",$FILE$CONFIG"
- else
- echo "Warning: $1 option ignored because $FILE not found"
- fi
- shift;;
- --firebase) SERVE="firebase serve"; shift;;
- -h|--help) echo "Usage: $(basename $0) [--dev|--pin-now] [--firebase] [--help]"; exit 0;;
- *) echo "ERROR: Unrecognized option: $1. Use --help for details."; exit 1;;
+ --clean) CLEAN=1; shift;;
+ --dev) FILE=_config_dev.yml
+ if [[ -e $FILE ]]; then
+ CONFIG=",$FILE$CONFIG"
+ else
+ echo "Warning: $1 option ignored because $FILE not found"
+ fi
+ shift;;
+ --firebase) SERVE="npx firebase serve";
+ shift;;
+ -h|--help) echo "Usage: $(basename $0) [options]";
+ echo
+ echo " --clean Delete the content of site.g before building the site."
+ echo " --dev Build using _config_dev.yml."
+ echo " --firebase Serve using firebase rather than superstatic."
+ echo " --help Print this usage text."
+ echo " --pin-now Build using _config_now.yml."
+ echo " --trace Run jekyll build with --trace."
+ exit 0;;
+ --pin-now) FILE=_config_now.yml
+ if [[ -e $FILE ]]; then
+ CONFIG=",$FILE$CONFIG"
+ else
+ echo "Warning: $1 option ignored because $FILE not found"
+ fi
+ shift;;
+ --trace) JEKYLL_OPTS+="--trace ";
+ shift;;
+ *) echo "ERROR: Unrecognized option: $1. Use --help for details.";
+ exit 1;;
esac
done
@@ -35,12 +49,22 @@ if [[ -n $CONFIG ]]; then
CONFIG="--config _config.yml$CONFIG"
fi
-PORT=$(grep '^port:' _config.yml | awk '{ print $2}' || echo 4000)
+set +e
+DEST=$(grep '^destination:' _config.yml | awk '{ print $2}')
+set -e
+SITE_PATH="./${DEST:-_site}"
+if [[ -n $CLEAN ]]; then
+ if [[ -e "$SITE_PATH" ]]; then
+ (set -x; rm -Rf "$SITE_PATH/*")
+ else
+ echo "WARNING: $SITE_PATH doesn't exist, so there is nothing to clean."; echo
+ fi
+fi
-bundle exec jekyll build $CONFIG --incremental --watch &
+(set -x; bundle exec jekyll build $CONFIG $JEKYLL_OPTS) &
j_pid=$!
-$SERVE --port $PORT &
+(set -x; $SERVE --version; $SERVE --port ${SITE_LOCALHOST_PORT:-4002}) &
f_pid=$!
-echo "cached PIDs: $j_pid, $f_pid"
+echo "Cached PIDs for build and serve: $j_pid, $f_pid"
trap "{ kill $j_pid; kill $f_pid; exit 0;}" SIGINT
wait
diff --git a/tool/shared/env-set.sh b/tool/shared/env-set.sh
new file mode 100644
index 00000000000..3e9d83a7743
--- /dev/null
+++ b/tool/shared/env-set.sh
@@ -0,0 +1,105 @@
+# Temporary: copy of site-shared/tool/shared/env-set.sh
+#
+# - This script will be sourced from the host repo's REPO_ROOT/tool folder.
+# - REPO_ROOT/scripts/shared symlinks to site-shared/tool.
+# - REPO_ROOT contains `_config.yml` with a `port` field.
+
+_DART_SITE_ENV_SET_INSTALL_OPT="--install"
+
+if [[ $# -gt 0 ]]; then
+ case "$1" in
+ -h|--help) echo "source scripts/env-set.sh [--quick|--no-install]"
+ echo
+ echo " Runs nvm and rvm commands 'install' and 'use' to get required Node"
+ echo " and Ruby versions; then sets other required environment variables."
+ echo
+ echo " --no-install Skips nvm and rvm 'install' in favor of 'use'."
+ echo " --quick Do nothing if this script has already been sourced."
+ echo
+ return 0;;
+ -q|--quick) _DART_SITE_ENV_SET_INSTALL_OPT="--quick"; shift;;
+ -n|--no-install)
+ _DART_SITE_ENV_SET_INSTALL_OPT="--no-install"; shift;;
+ *) echo "ERROR: Unrecognized option for env-set.sh: $1. Use --help for details."
+ return 1;;
+ esac
+fi
+
+if [[ $# -gt 0 ]]; then
+ echo "ERROR: too many arguments passed to env-set.sh: $1. Use --help for details."
+ return 1
+fi
+
+if [[ "$_DART_SITE_ENV_SET_INSTALL_OPT" != "--quick" ]]; then
+ unset DART_SITE_ENV_DEFS
+fi
+
+if [[ -z "$(type -t rvm)" ]]; then
+ echo "ERROR: rvm not installed. See README setup instructions. Skipping setup."
+elif [[ -z "$(type -t nvm)" ]]; then
+ echo "ERROR: nvm not installed. See README setup instructions. Skipping setup."
+elif [[ -z "$DART_SITE_ENV_DEFS" ]]; then
+ export DART_SITE_ENV_DEFS=1
+ export ANSI_YELLOW="\033[33;1m"
+ export ANSI_RESET="\033[0m"
+ echo -e "${ANSI_YELLOW}Setting environment variables from tool/env-set.sh${ANSI_RESET}"
+
+ if [[ "$_DART_SITE_ENV_SET_INSTALL_OPT" == "--install" ]]; then
+ nvm install 10
+ else
+ nvm use 10
+ fi
+ source tool/shared/get-ruby.sh "$_DART_SITE_ENV_SET_INSTALL_OPT"
+
+ if [ ! $(type -t travis_fold) ]; then
+ # In case this is being run locally. Turn travis_fold into a noop.
+ travis_fold () { true; }
+ fi
+ export -f travis_fold
+
+ case "$(uname -a)" in
+ Darwin\ *) _OS_NAME=macos ;;
+ Linux\ *) _OS_NAME=linux ;;
+ *) _OS_NAME=linux ;;
+ esac
+ export _OS_NAME
+
+ : ${TMP:=$HOME/tmp}
+ : ${PKG:=$TMP/pkg}
+ export TMP
+ export PKG
+
+ if [[ -n "$TRAVIS" ]]; then
+ [[ ! -d "$TMP" ]] && mkdir "$TMP"
+ [[ ! -d "$PKG" ]] && mkdir "$PKG"
+ else
+ if [[ -z "$(type -t dart)" && ! $PATH =~ \/dart-sdk ]]; then
+ export DART_SDK="$PKG/dart-sdk"
+ # Updating PATH to include access to Dart bin.
+ export PATH="$PATH:$DART_SDK/bin"
+ export PATH="$PATH:$HOME/.pub-cache/bin"
+ fi
+ fi
+
+ export SITE_LOCALHOST_PORT=5000
+ if [[ ! -e _config.yml ]]; then
+ echo "WARNING: '_config.yml' file not found; setting SITE_LOCALHOST_PORT to $SITE_LOCALHOST_PORT."
+ else
+ export SITE_LOCALHOST_PORT=$(grep '^port:' _config.yml | awk '{ print $2}')
+ if [[ -z $SITE_LOCALHOST_PORT ]]; then
+ echo "WARNING: '_config.yml' file has no 'port' field; setting SITE_LOCALHOST_PORT to $SITE_LOCALHOST_PORT.";
+ fi
+ fi
+
+ if [[ -z $(git config push.recurseSubmodules) ]]; then
+ echo "INFO: git config push.recurseSubmodules is unset. Setting it to 'check':"
+ (set -x; git config push.recurseSubmodules check)
+ else
+ echo "INFO: git config push.recurseSubmodules is set to $(git config push.recurseSubmodules)."
+ fi
+ git config status.submodulesummary 1
+ echo "INFO: git config status.submodulesummary is set to $(git config status.submodulesummary)."
+
+fi
+
+return 0
diff --git a/tool/shared/get-ruby.sh b/tool/shared/get-ruby.sh
new file mode 100644
index 00000000000..faa83d4afa9
--- /dev/null
+++ b/tool/shared/get-ruby.sh
@@ -0,0 +1,32 @@
+# This bash file is meant to be source'd, not executed. It is a bit non-DRY
+# because we can't define local variables, nor can we use functions.
+
+DART_SITE_RUBY_VERS=ruby-2.4.3
+
+if ! rvm version | grep -q '(latest)'; then
+ rvm get stable
+fi
+
+echo "RVM current: $(rvm current)"
+if rvm current | grep -Fq $DART_SITE_RUBY_VERS; then
+ echo " Using $(rvm current) (rvm $(rvm version | awk '{print $2}'))"
+elif rvm list | grep -Fq $DART_SITE_RUBY_VERS; then
+ if [[ -n "$TRAVIS" ]]; then DEFAULT="--default "; fi
+ echo "Running: rvm ${DEFAULT}use $DART_SITE_RUBY_VERS"
+ rvm ${DEFAULT}use $DART_SITE_RUBY_VERS
+elif [[ -z "$1" || "$1" == "--install" ]]; then
+ echo "Running: rvm install $DART_SITE_RUBY_VERS"
+ rvm install $DART_SITE_RUBY_VERS
+else
+ echo "ERROR: ruby '$DART_SITE_RUBY_VERS' isn't locally available and --install option was not specified."
+ return 1
+fi
+
+echo "Ruby --version: $(ruby --version)"
+
+if [[ ! -e ~/.rvmrc ]] || ! grep -q rvm_silence_path_mismatch_check_flag ~/.rvmrc; then
+ echo rvm_silence_path_mismatch_check_flag=1 >> ~/.rvmrc
+ echo "Configured RVM so it doesn't complain if it isn't first in PATH"
+fi
+
+return 0