1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00
Files
samples/web/_tool/build_ci.dart
John Ryan 3f5ab56485 Add workflow to deploy the sample index (#791)
* Add workflow to build and deploy the sample index

* update gh-pages action

* fix yaml

* create web/ directory in build

* grammar

* add ignored directories

* revert pubspec.lock files

* add job to run _tool/verify_samples.dart

* Update filipino_cuisine for Flutter 2

* remove timeflow demo.

The unnamed List constructor is now deprecated, refactoring
this code to use add() requires more knowledge about the code for
this demo.
https://dart.dev/null-safety/understanding-null-safety#no-unnamed-list-constructor

* update slide_puzzle

* ensure stable channel is used to verify

* move verify web demos action into separate yaml file - avoid running
on each flutter version.

* add on: pull_request

* update slide_puzzle

* Update gh-pages.yml

* Add copyright header
2021-05-06 10:26:15 -07:00

44 lines
1.5 KiB
Dart

// Copyright 2021 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
import 'dart:io';
import 'package:path/path.dart' as p;
import 'common.dart';
final ignoredDirectories = ['_tool', 'samples_index'];
main() async {
final packageDirs = [
...listPackageDirs(Directory.current)
.map((path) => p.relative(path, from: Directory.current.path))
.where((path) => !ignoredDirectories.contains(path))
];
print('Building the sample index...');
await run('samples_index', 'pub', ['get']);
await run('samples_index', 'pub', ['run', 'grinder', 'deploy']);
// Create the directory each Flutter Web sample lives in
Directory(p.join(Directory.current.path, 'samples_index', 'public', 'web'))
.createSync(recursive: true);
for (var i = 0; i < packageDirs.length; i++) {
var directory = packageDirs[i];
logWrapped(ansiMagenta, '\n$directory (${i + 1} of ${packageDirs.length})');
// Create the target directory
var directoryName = p.basename(directory);
var sourceBuildDir =
p.join(Directory.current.path, directory, 'build', 'web');
var targetDirectory = p.join(Directory.current.path, 'samples_index',
'public', 'web', directoryName);
// Build the sample and copy the files
await run(directory, 'flutter', ['pub', 'get']);
await run(directory, 'flutter', ['build', 'web']);
await run(directory, 'mv', [sourceBuildDir, targetDirectory]);
}
}