1
0
mirror of https://github.com/flutter/samples.git synced 2026-03-31 08:44:26 +00:00

Add samples index (#359)

* add samples_index to web/ directory

Co-authored-by: Thea Flowers <theaflowers@google.com>

* add pub_get.dart script

* build sample index in peanut post build

* re-generate sample index with web demos

* print more details in peanut_post_build.dart

* add images for demos

* run generator

* update README

* add animations and provider shopper as symlinks

* add links to symlinked web demos

* use relative paths

* update cookbook images, urls, and description CSS

* use relative URL for navbar link

* unstage HTML files

* .gitignore generated HTML files

* add margin to toolbar

* rename escape functions

* add and update copyright headers

Co-authored-by: Thea Flowers <theaflowers@google.com>
This commit is contained in:
John Ryan
2020-03-09 16:17:08 -07:00
committed by GitHub
parent efab5b0644
commit 0a5a5109de
183 changed files with 3555 additions and 211 deletions

View File

@@ -1,10 +1,11 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Copyright 2020 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file
import 'dart:io';
import 'package:path/path.dart' as p;
import 'common.dart';
const _ansiGreen = 32;
const _ansiRed = 31;
@@ -20,14 +21,14 @@ void main() async {
final results = <bool>[];
for (var i = 0; i < packageDirs.length; i++) {
final dir = packageDirs[i];
_logWrapped(_ansiMagenta, '\n$dir (${i + 1} of ${packageDirs.length})');
results.add(await _run(dir, 'flutter', [
logWrapped(_ansiMagenta, '\n$dir (${i + 1} of ${packageDirs.length})');
results.add(await run(dir, 'flutter', [
'pub',
'pub',
'upgrade',
'--no-precompile',
]));
results.add(await _run(
results.add(await run(
dir,
'dartanalyzer',
['--fatal-infos', '--fatal-warnings', '.'],
@@ -45,45 +46,16 @@ void _printStatus(List<bool> results) {
var success = (successCount == results.length);
var pct = 100 * successCount / results.length;
_logWrapped(success ? _ansiGreen : _ansiRed,
logWrapped(success ? _ansiGreen : _ansiRed,
'$successCount of ${results.length} (${pct.toStringAsFixed(2)}%)');
}
void _logWrapped(int code, String message) {
print('\x1B[${code}m$message\x1B[0m');
}
Future<bool> _run(
String workingDir, String commandName, List<String> args) async {
var commandDescription = '`${([commandName]..addAll(args)).join(' ')}`';
_logWrapped(_ansiMagenta, ' Running $commandDescription');
var proc = await Process.start(
commandName,
args,
workingDirectory: Directory.current.path + '/' + workingDir,
mode: ProcessStartMode.inheritStdio,
);
var exitCode = await proc.exitCode;
if (exitCode != 0) {
_logWrapped(
_ansiRed, ' Failed! ($exitCode) $workingDir $commandDescription');
return false;
} else {
_logWrapped(_ansiGreen, ' Success! $workingDir $commandDescription');
return true;
}
}
Iterable<String> _listPackageDirs(Directory dir) sync* {
if (File('${dir.path}/pubspec.yaml').existsSync()) {
yield dir.path;
} else {
for (var subDir in dir
.listSync(followLinks: false)
.listSync(followLinks: true)
.whereType<Directory>()
.where((d) => !Uri.file(d.path).pathSegments.last.startsWith('.'))) {
yield* _listPackageDirs(subDir);