From 67c71f0d8659a6bcc4b3176ee741df6c072953bc Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 18 May 2018 16:09:38 -0700 Subject: [PATCH] Use pkg:build_runner (#507) --- .travis.yml | 2 +- CHANGELOG.md | 4 + build.yaml | 23 +++ lib/generators/console_full.dart | 4 +- ...ole_full_data.dart => console_full.g.dart} | 28 +++- lib/generators/package_simple.dart | 4 +- ...simple_data.dart => package_simple.g.dart} | 34 ++-- lib/generators/server_shelf.dart | 4 +- ...er_shelf_data.dart => server_shelf.g.dart} | 25 ++- lib/generators/web_angular.dart | 4 +- ...b_angular_data.dart => web_angular.g.dart} | 58 +++++-- lib/generators/web_simple.dart | 4 +- ...web_simple_data.dart => web_simple.g.dart} | 34 ++-- lib/generators/web_stagexl.dart | 4 +- ...b_stagexl_data.dart => web_stagexl.g.dart} | 37 +++-- lib/src/cli_app.dart | 5 +- lib/src/cli_app.g.dart | 13 ++ pubspec.yaml | 7 +- tool/build-check.sh | 4 +- tool/builder.dart | 22 +++ tool/grind.dart | 147 ------------------ tool/src/code_generator.dart | 87 +++++++++++ tool/src/version_generator.dart | 29 ++++ ...n-check-and-update.sh => version-check.sh} | 10 +- 24 files changed, 362 insertions(+), 231 deletions(-) create mode 100644 build.yaml rename lib/generators/{console_full_data.dart => console_full.g.dart} (71%) rename lib/generators/{package_simple_data.dart => package_simple.g.dart} (74%) rename lib/generators/{server_shelf_data.dart => server_shelf.g.dart} (79%) rename lib/generators/{web_angular_data.dart => web_angular.g.dart} (86%) rename lib/generators/{web_simple_data.dart => web_simple.g.dart} (87%) rename lib/generators/{web_stagexl_data.dart => web_stagexl.g.dart} (96%) create mode 100644 lib/src/cli_app.g.dart create mode 100644 tool/builder.dart delete mode 100644 tool/grind.dart create mode 100644 tool/src/code_generator.dart create mode 100644 tool/src/version_generator.dart rename tool/{version-check-and-update.sh => version-check.sh} (71%) diff --git a/.travis.yml b/.travis.yml index f707ae74..24b4be81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ env: # important: w/o this top-level env, no job will be allowed to fail. - DISPLAY=:99.0 matrix: - CI_TASK=tool/travis.sh - - CI_TASK=tool/version-check-and-update.sh + - CI_TASK=tool/version-check.sh - CI_TASK=tool/build-check.sh - CI_TASK=tool/web-angular-test.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index d47a7002..d7907683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.2 + +- Internal cleanup. + ## 2.0.1 - All `web-` templates: diff --git a/build.yaml b/build.yaml new file mode 100644 index 00000000..d5022091 --- /dev/null +++ b/build.yaml @@ -0,0 +1,23 @@ +# Read about `build.yaml` at https://pub.dartlang.org/packages/build_config +targets: + $default: + sources: + include: + - tool/** + - pubspec.yaml + - lib/** + - templates/** + builders: + stagehand: + generate_for: + - lib/src/cli_app.dart + - lib/generators/*.dart + enabled: true + +builders: + stagehand: + # See https://github.com/dart-lang/build/issues/1423 + import: "../../../tool/builder.dart" + builder_factories: ["stagehandBuilder"] + build_extensions: {".dart": [".g.dart"]} + build_to: source diff --git a/lib/generators/console_full.dart b/lib/generators/console_full.dart index 988b7199..d32ed8a6 100644 --- a/lib/generators/console_full.dart +++ b/lib/generators/console_full.dart @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. import '../src/common.dart'; -import 'console_full_data.dart'; +part 'console_full.g.dart'; /// A generator for a hello world command-line application. class ConsoleFullGenerator extends DefaultGenerator { @@ -11,7 +11,7 @@ class ConsoleFullGenerator extends DefaultGenerator { : super('console-full', 'Console Application', 'A command-line application sample.', categories: const ['dart', 'console']) { - for (var file in decodeConcatenatedData(data)) { + for (var file in decodeConcatenatedData(_data)) { addTemplateFile(file); } diff --git a/lib/generators/console_full_data.dart b/lib/generators/console_full.g.dart similarity index 71% rename from lib/generators/console_full_data.dart rename to lib/generators/console_full.g.dart index 0bc81d1e..712e0c64 100644 --- a/lib/generators/console_full_data.dart +++ b/lib/generators/console_full.g.dart @@ -2,10 +2,19 @@ // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -const List data = const [ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'console_full.dart'; + +// ************************************************************************** +// Generator: DataGenerator +// ************************************************************************** + +const _data = const [ '.gitignore', 'text', - '''IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th + ''' +IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th Z2VzCi5wdWIvCmJ1aWxkLwojIFJlbW92ZSB0aGUgZm9sbG93aW5nIHBhdHRlcm4gaWYgeW91IHdp c2ggdG8gY2hlY2sgaW4geW91ciBsb2NrIGZpbGUKcHVic3BlYy5sb2NrCgojIERpcmVjdG9yeSBj cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', @@ -14,13 +23,15 @@ cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', 'IyMgMS4wLjAKCi0gSW5pdGlhbCB2ZXJzaW9uLCBjcmVhdGVkIGJ5IFN0YWdlaGFuZAo=', 'README.md', 'text', - '''IyBfX3Byb2plY3ROYW1lX18KCkEgc2FtcGxlIGNvbW1hbmQtbGluZSBhcHBsaWNhdGlvbi4KCkNy + ''' +IyBfX3Byb2plY3ROYW1lX18KCkEgc2FtcGxlIGNvbW1hbmQtbGluZSBhcHBsaWNhdGlvbi4KCkNy ZWF0ZWQgZnJvbSB0ZW1wbGF0ZXMgbWFkZSBhdmFpbGFibGUgYnkgU3RhZ2VoYW5kIHVuZGVyIGEg QlNELXN0eWxlCltsaWNlbnNlXShodHRwczovL2dpdGh1Yi5jb20vZGFydC1sYW5nL3N0YWdlaGFu ZC9ibG9iL21hc3Rlci9MSUNFTlNFKS4K''', 'analysis_options.yaml', 'text', - '''YW5hbHl6ZXI6CiAgc3Ryb25nLW1vZGU6IHRydWUKIyAgIGV4Y2x1ZGU6CiMgICAgIC0gcGF0aC90 + ''' +YW5hbHl6ZXI6CiAgc3Ryb25nLW1vZGU6IHRydWUKIyAgIGV4Y2x1ZGU6CiMgICAgIC0gcGF0aC90 by9leGNsdWRlZC9maWxlcy8qKgoKIyBMaW50IHJ1bGVzIGFuZCBkb2N1bWVudGF0aW9uLCBzZWUg aHR0cDovL2RhcnQtbGFuZy5naXRodWIuaW8vbGludGVyL2xpbnRzCmxpbnRlcjoKICBydWxlczoK ICAgIC0gY2FuY2VsX3N1YnNjcmlwdGlvbnMKICAgIC0gaGFzaF9hbmRfZXF1YWxzCiAgICAtIGl0 @@ -29,7 +40,8 @@ ZF90eXBlCiAgICAtIHRlc3RfdHlwZXNfaW5fZXF1YWxzCiAgICAtIHVucmVsYXRlZF90eXBlX2Vx dWFsaXR5X2NoZWNrcwogICAgLSB2YWxpZF9yZWdleHBzCg==''', 'bin/main.dart', 'text', - '''aW1wb3J0ICdwYWNrYWdlOl9fcHJvamVjdE5hbWVfXy9fX3Byb2plY3ROYW1lX18uZGFydCcgYXMg + ''' +aW1wb3J0ICdwYWNrYWdlOl9fcHJvamVjdE5hbWVfXy9fX3Byb2plY3ROYW1lX18uZGFydCcgYXMg X19wcm9qZWN0TmFtZV9fOwoKbWFpbihMaXN0PFN0cmluZz4gYXJndW1lbnRzKSB7CiAgcHJpbnQo J0hlbGxvIHdvcmxkOiAke19fcHJvamVjdE5hbWVfXy5jYWxjdWxhdGUoKX0hJyk7Cn0K''', 'lib/__projectName__.dart', @@ -37,14 +49,16 @@ J0hlbGxvIHdvcmxkOiAke19fcHJvamVjdE5hbWVfXy5jYWxjdWxhdGUoKX0hJyk7Cn0K''', 'aW50IGNhbGN1bGF0ZSgpIHsKICByZXR1cm4gNiAqIDc7Cn0K', 'pubspec.yaml', 'text', - '''bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBIHNhbXBsZSBjb21tYW5kLWxpbmUg + ''' +bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBIHNhbXBsZSBjb21tYW5kLWxpbmUg YXBwbGljYXRpb24uCiMgdmVyc2lvbjogMS4wLjAKIyBob21lcGFnZTogaHR0cHM6Ly93d3cuZXhh bXBsZS5jb20KIyBhdXRob3I6IF9fYXV0aG9yX18gPGVtYWlsQGV4YW1wbGUuY29tPgoKZW52aXJv bm1lbnQ6CiAgc2RrOiAnPj0yLjAuMC1kZXYuNTEuMCA8Mi4wLjAnCgojZGVwZW5kZW5jaWVzOgoj ICBwYXRoOiBeMS40LjEKCmRldl9kZXBlbmRlbmNpZXM6CiAgdGVzdDogXjAuMTIuMzAK''', 'test/__projectName___test.dart', 'text', - '''aW1wb3J0ICdwYWNrYWdlOl9fcHJvamVjdE5hbWVfXy9fX3Byb2plY3ROYW1lX18uZGFydCc7Cmlt + ''' +aW1wb3J0ICdwYWNrYWdlOl9fcHJvamVjdE5hbWVfXy9fX3Byb2plY3ROYW1lX18uZGFydCc7Cmlt cG9ydCAncGFja2FnZTp0ZXN0L3Rlc3QuZGFydCc7Cgp2b2lkIG1haW4oKSB7CiAgdGVzdCgnY2Fs Y3VsYXRlJywgKCkgewogICAgZXhwZWN0KGNhbGN1bGF0ZSgpLCA0Mik7CiAgfSk7Cn0K''' ]; diff --git a/lib/generators/package_simple.dart b/lib/generators/package_simple.dart index 3efe5411..c9f8036a 100644 --- a/lib/generators/package_simple.dart +++ b/lib/generators/package_simple.dart @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. import '../src/common.dart'; -import 'package_simple_data.dart'; +part 'package_simple.g.dart'; /// A generator for a pub library. class PackageSimpleGenerator extends DefaultGenerator { @@ -11,7 +11,7 @@ class PackageSimpleGenerator extends DefaultGenerator { : super('package-simple', 'Dart Package', 'A starting point for Dart libraries or applications.', categories: const ['dart']) { - for (var file in decodeConcatenatedData(data)) { + for (var file in decodeConcatenatedData(_data)) { addTemplateFile(file); } diff --git a/lib/generators/package_simple_data.dart b/lib/generators/package_simple.g.dart similarity index 74% rename from lib/generators/package_simple_data.dart rename to lib/generators/package_simple.g.dart index e74ba0e6..884f0ef7 100644 --- a/lib/generators/package_simple_data.dart +++ b/lib/generators/package_simple.g.dart @@ -2,10 +2,19 @@ // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -const List data = const [ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'package_simple.dart'; + +// ************************************************************************** +// Generator: DataGenerator +// ************************************************************************** + +const _data = const [ '.gitignore', 'text', - '''IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th + ''' +IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th Z2VzCi5wdWIvCmJ1aWxkLwojIFJlbW92ZSB0aGUgZm9sbG93aW5nIHBhdHRlcm4gaWYgeW91IHdp c2ggdG8gY2hlY2sgaW4geW91ciBsb2NrIGZpbGUKcHVic3BlYy5sb2NrCgojIERpcmVjdG9yeSBj cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', @@ -14,7 +23,8 @@ cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', 'IyMgMS4wLjAKCi0gSW5pdGlhbCB2ZXJzaW9uLCBjcmVhdGVkIGJ5IFN0YWdlaGFuZAo=', 'README.md', 'text', - '''IyBfX3Byb2plY3ROYW1lX18KCkEgbGlicmFyeSBmb3IgRGFydCBkZXZlbG9wZXJzLgoKQ3JlYXRl + ''' +IyBfX3Byb2plY3ROYW1lX18KCkEgbGlicmFyeSBmb3IgRGFydCBkZXZlbG9wZXJzLgoKQ3JlYXRl ZCBmcm9tIHRlbXBsYXRlcyBtYWRlIGF2YWlsYWJsZSBieSBTdGFnZWhhbmQgdW5kZXIgYSBCU0Qt c3R5bGUKW2xpY2Vuc2VdKGh0dHBzOi8vZ2l0aHViLmNvbS9kYXJ0LWxhbmcvc3RhZ2VoYW5kL2Js b2IvbWFzdGVyL0xJQ0VOU0UpLgoKIyMgVXNhZ2UKCkEgc2ltcGxlIHVzYWdlIGV4YW1wbGU6Cgog @@ -25,7 +35,8 @@ Z3MgYXQgdGhlIFtpc3N1ZSB0cmFja2VyXVt0cmFja2VyXS4KClt0cmFja2VyXTogaHR0cDovL2V4 YW1wbGUuY29tL2lzc3Vlcy9yZXBsYWNlbWUK''', 'analysis_options.yaml', 'text', - '''YW5hbHl6ZXI6CiAgc3Ryb25nLW1vZGU6IHRydWUKIyAgIGV4Y2x1ZGU6CiMgICAgIC0gcGF0aC90 + ''' +YW5hbHl6ZXI6CiAgc3Ryb25nLW1vZGU6IHRydWUKIyAgIGV4Y2x1ZGU6CiMgICAgIC0gcGF0aC90 by9leGNsdWRlZC9maWxlcy8qKgoKIyBMaW50IHJ1bGVzIGFuZCBkb2N1bWVudGF0aW9uLCBzZWUg aHR0cDovL2RhcnQtbGFuZy5naXRodWIuaW8vbGludGVyL2xpbnRzCmxpbnRlcjoKICBydWxlczoK ICAgIC0gY2FuY2VsX3N1YnNjcmlwdGlvbnMKICAgIC0gaGFzaF9hbmRfZXF1YWxzCiAgICAtIGl0 @@ -34,23 +45,27 @@ ZF90eXBlCiAgICAtIHRlc3RfdHlwZXNfaW5fZXF1YWxzCiAgICAtIHVucmVsYXRlZF90eXBlX2Vx dWFsaXR5X2NoZWNrcwogICAgLSB2YWxpZF9yZWdleHBzCg==''', 'example/__projectName___example.dart', 'text', - '''aW1wb3J0ICdwYWNrYWdlOl9fcHJvamVjdE5hbWVfXy9fX3Byb2plY3ROYW1lX18uZGFydCc7Cgpt + ''' +aW1wb3J0ICdwYWNrYWdlOl9fcHJvamVjdE5hbWVfXy9fX3Byb2plY3ROYW1lX18uZGFydCc7Cgpt YWluKCkgewogIHZhciBhd2Vzb21lID0gbmV3IEF3ZXNvbWUoKTsKICBwcmludCgnYXdlc29tZTog JHthd2Vzb21lLmlzQXdlc29tZX0nKTsKfQo=''', 'lib/__projectName__.dart', 'text', - '''Ly8vIFN1cHBvcnQgZm9yIGRvaW5nIHNvbWV0aGluZyBhd2Vzb21lLgovLy8KLy8vIE1vcmUgZGFy + ''' +Ly8vIFN1cHBvcnQgZm9yIGRvaW5nIHNvbWV0aGluZyBhd2Vzb21lLgovLy8KLy8vIE1vcmUgZGFy dGRvY3MgZ28gaGVyZS4KbGlicmFyeSBfX3Byb2plY3ROYW1lX187CgpleHBvcnQgJ3NyYy9fX3By b2plY3ROYW1lX19fYmFzZS5kYXJ0JzsKCi8vIFRPRE86IEV4cG9ydCBhbnkgbGlicmFyaWVzIGlu dGVuZGVkIGZvciBjbGllbnRzIG9mIHRoaXMgcGFja2FnZS4K''', 'lib/src/__projectName___base.dart', 'text', - '''Ly8gVE9ETzogUHV0IHB1YmxpYyBmYWNpbmcgdHlwZXMgaW4gdGhpcyBmaWxlLgoKLy8vIENoZWNr + ''' +Ly8gVE9ETzogUHV0IHB1YmxpYyBmYWNpbmcgdHlwZXMgaW4gdGhpcyBmaWxlLgoKLy8vIENoZWNr cyBpZiB5b3UgYXJlIGF3ZXNvbWUuIFNwb2lsZXI6IHlvdSBhcmUuCmNsYXNzIEF3ZXNvbWUgewog IGJvb2wgZ2V0IGlzQXdlc29tZSA9PiB0cnVlOwp9Cg==''', 'pubspec.yaml', 'text', - '''bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBIHN0YXJ0aW5nIHBvaW50IGZvciBE + ''' +bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBIHN0YXJ0aW5nIHBvaW50IGZvciBE YXJ0IGxpYnJhcmllcyBvciBhcHBsaWNhdGlvbnMuCiMgdmVyc2lvbjogMS4wLjAKIyBob21lcGFn ZTogaHR0cHM6Ly93d3cuZXhhbXBsZS5jb20KIyBhdXRob3I6IF9fYXV0aG9yX18gPGVtYWlsQGV4 YW1wbGUuY29tPgoKZW52aXJvbm1lbnQ6CiAgc2RrOiAnPj0yLjAuMC1kZXYuNTEuMCA8Mi4wLjAn @@ -58,7 +73,8 @@ CgojZGVwZW5kZW5jaWVzOgojICBwYXRoOiBeMS40LjEKCmRldl9kZXBlbmRlbmNpZXM6CiAgdGVz dDogXjAuMTIuMzAK''', 'test/__projectName___test.dart', 'text', - '''aW1wb3J0ICdwYWNrYWdlOl9fcHJvamVjdE5hbWVfXy9fX3Byb2plY3ROYW1lX18uZGFydCc7Cmlt + ''' +aW1wb3J0ICdwYWNrYWdlOl9fcHJvamVjdE5hbWVfXy9fX3Byb2plY3ROYW1lX18uZGFydCc7Cmlt cG9ydCAncGFja2FnZTp0ZXN0L3Rlc3QuZGFydCc7Cgp2b2lkIG1haW4oKSB7CiAgZ3JvdXAoJ0Eg Z3JvdXAgb2YgdGVzdHMnLCAoKSB7CiAgICBBd2Vzb21lIGF3ZXNvbWU7CgogICAgc2V0VXAoKCkg ewogICAgICBhd2Vzb21lID0gbmV3IEF3ZXNvbWUoKTsKICAgIH0pOwoKICAgIHRlc3QoJ0ZpcnN0 diff --git a/lib/generators/server_shelf.dart b/lib/generators/server_shelf.dart index eba217fb..487f9a8d 100644 --- a/lib/generators/server_shelf.dart +++ b/lib/generators/server_shelf.dart @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. import '../src/common.dart'; -import 'server_shelf_data.dart'; +part 'server_shelf.g.dart'; /// A generator for a server app built on `package:shelf`. class ServerShelfGenerator extends DefaultGenerator { @@ -11,7 +11,7 @@ class ServerShelfGenerator extends DefaultGenerator { : super('server-shelf', 'Web Server', 'A web server built using the shelf package.', categories: const ['dart', 'shelf', 'server']) { - for (var file in decodeConcatenatedData(data)) { + for (var file in decodeConcatenatedData(_data)) { addTemplateFile(file); } diff --git a/lib/generators/server_shelf_data.dart b/lib/generators/server_shelf.g.dart similarity index 79% rename from lib/generators/server_shelf_data.dart rename to lib/generators/server_shelf.g.dart index ae0c5a6f..076bc3f5 100644 --- a/lib/generators/server_shelf_data.dart +++ b/lib/generators/server_shelf.g.dart @@ -2,10 +2,19 @@ // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -const List data = const [ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'server_shelf.dart'; + +// ************************************************************************** +// Generator: DataGenerator +// ************************************************************************** + +const _data = const [ '.gitignore', 'text', - '''IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th + ''' +IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th Z2VzCi5wdWIvCmJ1aWxkLwojIFJlbW92ZSB0aGUgZm9sbG93aW5nIHBhdHRlcm4gaWYgeW91IHdp c2ggdG8gY2hlY2sgaW4geW91ciBsb2NrIGZpbGUKcHVic3BlYy5sb2NrCgojIERpcmVjdG9yeSBj cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', @@ -14,14 +23,16 @@ cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', 'IyMgMS4wLjAKCi0gSW5pdGlhbCB2ZXJzaW9uLCBjcmVhdGVkIGJ5IFN0YWdlaGFuZAo=', 'README.md', 'text', - '''IyBfX3Byb2plY3ROYW1lX18KCkEgd2ViIHNlcnZlciBidWlsdCB1c2luZyBbU2hlbGZdKGh0dHBz + ''' +IyBfX3Byb2plY3ROYW1lX18KCkEgd2ViIHNlcnZlciBidWlsdCB1c2luZyBbU2hlbGZdKGh0dHBz Oi8vcHViLmRhcnRsYW5nLm9yZy9wYWNrYWdlcy9zaGVsZikuCgpDcmVhdGVkIGZyb20gdGVtcGxh dGVzIG1hZGUgYXZhaWxhYmxlIGJ5IFN0YWdlaGFuZCB1bmRlciBhIEJTRC1zdHlsZQpbbGljZW5z ZV0oaHR0cHM6Ly9naXRodWIuY29tL2RhcnQtbGFuZy9zdGFnZWhh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Zi5SZXNwb25zZS5vaygn UmVxdWVzdCBmb3IgIiR7cmVxdWVzdC51cmx9IicpOwo=''', 'pubspec.yaml', 'text', - '''bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBIHdlYiBzZXJ2ZXIgYnVpbHQgdXNp + ''' +bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBIHdlYiBzZXJ2ZXIgYnVpbHQgdXNp bmcgdGhlIHNoZWxmIHBhY2thZ2UuCiMgdmVyc2lvbjogMS4wLjAKIyBob21lcGFnZTogaHR0cHM6 Ly93d3cuZXhhbXBsZS5jb20KIyBhdXRob3I6IF9fYXV0aG9yX18gPGVtYWlsQGV4YW1wbGUuY29t PgoKZW52aXJvbm1lbnQ6CiAgc2RrOiAnPj0yLjAuMC1kZXYuNTEuMCA8Mi4wLjAnCgpkZXBlbmRl diff --git a/lib/generators/web_angular.dart b/lib/generators/web_angular.dart index 529ae8dd..294eb61d 100644 --- a/lib/generators/web_angular.dart +++ b/lib/generators/web_angular.dart @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. import '../src/common.dart'; -import 'web_angular_data.dart'; +part 'web_angular.g.dart'; /// A generator for an Angular 2 application. class WebAngularGenerator extends DefaultGenerator { @@ -11,7 +11,7 @@ class WebAngularGenerator extends DefaultGenerator { : super('web-angular', 'AngularDart Web App', 'A web app with material design components.', categories: const ['dart', 'web']) { - for (var file in decodeConcatenatedData(data)) { + for (var file in decodeConcatenatedData(_data)) { addTemplateFile(file); } diff --git a/lib/generators/web_angular_data.dart b/lib/generators/web_angular.g.dart similarity index 86% rename from lib/generators/web_angular_data.dart rename to lib/generators/web_angular.g.dart index 3144ab1e..8b69c39c 100644 --- a/lib/generators/web_angular_data.dart +++ b/lib/generators/web_angular.g.dart @@ -2,10 +2,19 @@ // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -const List data = const [ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'web_angular.dart'; + +// ************************************************************************** +// Generator: DataGenerator +// ************************************************************************** + +const _data = const [ '.gitignore', 'text', - '''IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th + ''' +IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th Z2VzCi5wdWIvCmJ1aWxkLwojIFJlbW92ZSB0aGUgZm9sbG93aW5nIHBhdHRlcm4gaWYgeW91IHdp c2ggdG8gY2hlY2sgaW4geW91ciBsb2NrIGZpbGUKcHVic3BlYy5sb2NrCgojIERpcmVjdG9yeSBj cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', @@ -14,7 +23,8 @@ cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', 'IyMgMS4wLjAKCi0gSW5pdGlhbCB2ZXJzaW9uLCBjcmVhdGVkIGJ5IFN0YWdlaGFuZAo=', 'README.md', 'text', - '''IyBfX3Byb2plY3ROYW1lX18KCkEgd2ViIGFwcCB0aGF0IHVzZXMgW0FuZ3VsYXJEYXJ0XShodHRw + ''' +IyBfX3Byb2plY3ROYW1lX18KCkEgd2ViIGFwcCB0aGF0IHVzZXMgW0FuZ3VsYXJEYXJ0XShodHRw czovL3dlYmRldi5kYXJ0bGFuZy5vcmcvYW5ndWxhcikgYW5kCltBbmd1bGFyRGFydCBDb21wb25l bnRzXShodHRwczovL3dlYmRldi5kYXJ0bGFuZy5vcmcvY29tcG9uZW50cykuCgpDcmVhdGVkIGZy b20gdGVtcGxhdGVzIG1hZGUgYXZhaWxhYmxlIGJ5IFN0YWdlaGFuZCB1bmRlciBhIEJTRC1zdHls @@ -22,7 +32,8 @@ ZQpbbGljZW5zZV0oaHR0cHM6Ly9naXRodWIuY29tL2RhcnQtbGFuZy9zdGFnZWhhbmQvYmxvYi9t YXN0ZXIvTElDRU5TRSkuCg==''', 'analysis_options.yaml', 'text', - '''YW5hbHl6ZXI6CiAgc3Ryb25nLW1vZGU6IHRydWUKICBlcnJvcnM6CiAgICB1cmlfaGFzX25vdF9i + ''' +YW5hbHl6ZXI6CiAgc3Ryb25nLW1vZGU6IHRydWUKICBlcnJvcnM6CiAgICB1cmlfaGFzX25vdF9i ZWVuX2dlbmVyYXRlZDogaWdub3JlCiAgcGx1Z2luczoKICAgIC0gYW5ndWxhcgoKIyBMaW50IHJ1 bGVzIGFuZCBkb2N1bWVudGF0aW9uLCBzZWUgaHR0cDovL2RhcnQtbGFuZy5naXRodWIuaW8vbGlu dGVyL2xpbnRzCmxpbnRlcjoKICBydWxlczoKICAgIC0gY2FuY2VsX3N1YnNjcmlwdGlvbnMKICAg @@ -32,11 +43,13 @@ YWxzCiAgICAtIHVucmVsYXRlZF90eXBlX2VxdWFsaXR5X2NoZWNrcwogICAgLSB2YWxpZF9yZWdl eHBzCg==''', 'lib/app_component.css', 'text', - '''Omhvc3QgewogICAgLyogVGhpcyBpcyBlcXVpdmFsZW50IG9mIHRoZSAnYm9keScgc2VsZWN0b3Ig + ''' +Omhvc3QgewogICAgLyogVGhpcyBpcyBlcXVpdmFsZW50IG9mIHRoZSAnYm9keScgc2VsZWN0b3Ig b2YgYSBwYWdlLiAqLwp9Cg==''', 'lib/app_component.dart', 'text', - '''aW1wb3J0ICdwYWNrYWdlOmFuZ3VsYXIvYW5ndWxhci5kYXJ0JzsKCmltcG9ydCAnc3JjL3RvZG9f + ''' +aW1wb3J0ICdwYWNrYWdlOmFuZ3VsYXIvYW5ndWxhci5kYXJ0JzsKCmltcG9ydCAnc3JjL3RvZG9f bGlzdC90b2RvX2xpc3RfY29tcG9uZW50LmRhcnQnOwoKLy8gQW5ndWxhckRhcnQgaW5mbzogaHR0 cHM6Ly93ZWJkZXYuZGFydGxhbmcub3JnL2FuZ3VsYXIKLy8gQ29tcG9uZW50cyBpbmZvOiBodHRw czovL3dlYmRldi5kYXJ0bGFuZy5vcmcvY29tcG9uZW50cwoKQENvbXBvbmVudCgKICBzZWxlY3Rv @@ -46,18 +59,21 @@ bmVudF0sCikKY2xhc3MgQXBwQ29tcG9uZW50IHsKICAvLyBOb3RoaW5nIGhlcmUgeWV0LiBBbGwg bG9naWMgaXMgaW4gVG9kb0xpc3RDb21wb25lbnQuCn0K''', 'lib/app_component.html', 'text', - '''PGgxPk15IEZpcnN0IEFuZ3VsYXJEYXJ0IEFwcDwvaDE+Cgo8dG9kby1saXN0PjwvdG9kby1saXN0 + ''' +PGgxPk15IEZpcnN0IEFuZ3VsYXJEYXJ0IEFwcDwvaDE+Cgo8dG9kby1saXN0PjwvdG9kby1saXN0 Pgo=''', 'lib/src/todo_list/todo_list_component.css', 'text', - '''dWwgewogIGxpc3Qtc3R5bGU6IG5vbmU7CiAgcGFkZGluZy1sZWZ0OiAwOwp9CgpsaSB7CiAgbGlu + ''' +dWwgewogIGxpc3Qtc3R5bGU6IG5vbmU7CiAgcGFkZGluZy1sZWZ0OiAwOwp9CgpsaSB7CiAgbGlu ZS1oZWlnaHQ6IDNlbTsKfQoKbGk6aG92ZXIgewogIGJhY2tncm91bmQtY29sb3I6ICNFRUVFRUU7 Cn0KCmxpIG1hdGVyaWFsLWNoZWNrYm94IHsKICB2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlOwp9Cgps aSBtYXRlcmlhbC1mYWIgewogIGZsb2F0OiByaWdodDsKICB2ZXJ0aWNhbC1hbGlnbjogbWlkZGxl Owp9CgouZG9uZSB7CiAgdGV4dC1kZWNvcmF0aW9uOiBsaW5lLXRocm91Z2g7Cn0K''', 'lib/src/todo_list/todo_list_component.dart', 'text', - '''aW1wb3J0ICdkYXJ0OmFzeW5jJzsKCmltcG9ydCAncGFja2FnZTphbmd1bGFyL2FuZ3VsYXIuZGFy + ''' +aW1wb3J0ICdkYXJ0OmFzeW5jJzsKCmltcG9ydCAncGFja2FnZTphbmd1bGFyL2FuZ3VsYXIuZGFy dCc7CmltcG9ydCAncGFja2FnZTphbmd1bGFyX2NvbXBvbmVudHMvbWF0ZXJpYWxfaWNvbi9tYXRl cmlhbF9pY29uLmRhcnQnOwppbXBvcnQgJ3BhY2thZ2U6YW5ndWxhcl9jb21wb25lbnRzL21hdGVy aWFsX2lucHV0L21hdGVyaWFsX2lucHV0LmRhcnQnOwppbXBvcnQgJ3BhY2thZ2U6YW5ndWxhcl9j @@ -80,7 +96,8 @@ ZW1zLmFkZChuZXdUb2RvKTsKICAgIG5ld1RvZG8gPSAnJzsKICB9CgogIFN0cmluZyByZW1vdmUo aW50IGluZGV4KSA9PiBpdGVtcy5yZW1vdmVBdChpbmRleCk7Cn0K''', 'lib/src/todo_list/todo_list_component.html', 'text', - '''PCEtLSBDb21wb25lbnRzIGluZm86IGh0dHBzOi8vd2ViZGV2LmRhcnRsYW5nLm9yZy9jb21wb25l + ''' +PCEtLSBDb21wb25lbnRzIGluZm86IGh0dHBzOi8vd2ViZGV2LmRhcnRsYW5nLm9yZy9jb21wb25l bnRzIC0tPgo8ZGl2PgogIDxtYXRlcmlhbC1pbnB1dCBsYWJlbD0iV2hhdCBkbyB5b3UgbmVlZCB0 byBkbz8iCiAgICAgICAgICAgICAgICAgIGF1dG9Gb2N1cyBmbG9hdGluZ0xhYmVsIHN0eWxlPSJ3 aWR0aDo4MCUiCiAgICAgICAgICAgICAgICAgIFsobmdNb2RlbCldPSJuZXdUb2RvIgogICAgICAg @@ -99,14 +116,16 @@ PSJkZWxldGUiPjwvbWF0ZXJpYWwtaWNvbj4KICAgICAgICA8L21hdGVyaWFsLWZhYj4KICAgICAg PC9saT4KICA8L3VsPgo8L2Rpdj4K''', 'lib/src/todo_list/todo_list_service.dart', 'text', - '''aW1wb3J0ICdkYXJ0OmFzeW5jJzsKCmltcG9ydCAncGFja2FnZTphbmd1bGFyL2NvcmUuZGFydCc7 + ''' +aW1wb3J0ICdkYXJ0OmFzeW5jJzsKCmltcG9ydCAncGFja2FnZTphbmd1bGFyL2NvcmUuZGFydCc7 CgovLy8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LmRhcnQnOwppbXBvcnQgJ3BhY2th Z2U6X19wcm9qZWN0TmFtZV9fL2FwcF9jb21wb25lbnQuZGFydCc7CmltcG9ydCAncGFja2FnZTpf X3Byb2plY3ROYW1lX18vYXBwX2NvbXBvbmVudC50ZW1wbGF0ZS5kYXJ0JyBhcyBuZzsKCnZvaWQg @@ -131,7 +151,8 @@ Z1Rlc3QpOwoKICB0ZXN0KCdoZWFkaW5nJywgKCkgewogICAgZXhwZWN0KGZpeHR1cmUudGV4dCwg Y29udGFpbnMoJ015IEZpcnN0IEFuZ3VsYXJEYXJ0IEFwcCcpKTsKICB9KTsKfQo=''', 'web/favicon.png', 'binary', - '''iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAKLElEQVR4AeVbA3yj2xOd4tm2bdu2 + ''' +iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAKLElEQVR4AeVbA3yj2xOd4tm2bdu2 bdu2/V6DZm00apZvbduNs1nvNs0XVBvU85/5Z/uUmyZfkm95fr+pkTkz98zJvTewxdAPdwW9/wbo 4r0LdN69YYfAt1OLwRy6CEyBn+i9FfQSFpS6sUBlX1GoceiIiGug3+pdYbuDPnw6GAKfgFGaB8ZA MwzeiFBejVDmp+RtTAARsRwLSuhjtcMKWsdPoPVcxITBNgtL9dFgDr5MCU+giMDgekq6BuljBIOU @@ -180,7 +201,8 @@ Wl3liBeq7L1orJ0E2x2MVWcQEXrSiGaw1LUT0P4SOK76n6DzXAzbPUzBa4mECWAIbBprzjmgc90F OxRYzQf63qNZ/j3ovLvAFsL/AD2paxVjuEZQAAAAAElFTkSuQmCC''', 'web/index.html', 'text', - '''PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPl9fcHJvamVjdE5hbWVf + ''' +PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPl9fcHJvamVjdE5hbWVf XzwvdGl0bGU+CiAgICA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YW1pbHk6IFJvYm90bywgSGVsdmV0 diff --git a/lib/generators/web_simple.dart b/lib/generators/web_simple.dart index 3d0fe6cb..99e9094d 100644 --- a/lib/generators/web_simple.dart +++ b/lib/generators/web_simple.dart @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. import '../src/common.dart'; -import 'web_simple_data.dart'; +part 'web_simple.g.dart'; /// A generator for a uber-simple web application. class WebSimpleGenerator extends DefaultGenerator { @@ -11,7 +11,7 @@ class WebSimpleGenerator extends DefaultGenerator { : super('web-simple', 'Bare-bones Web App', 'A web app that uses only core Dart libraries.', categories: const ['dart', 'web']) { - for (var file in decodeConcatenatedData(data)) { + for (var file in decodeConcatenatedData(_data)) { addTemplateFile(file); } diff --git a/lib/generators/web_simple_data.dart b/lib/generators/web_simple.g.dart similarity index 87% rename from lib/generators/web_simple_data.dart rename to lib/generators/web_simple.g.dart index 65f96346..f3d996dd 100644 --- a/lib/generators/web_simple_data.dart +++ b/lib/generators/web_simple.g.dart @@ -2,10 +2,19 @@ // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -const List data = const [ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'web_simple.dart'; + +// ************************************************************************** +// Generator: DataGenerator +// ************************************************************************** + +const _data = const [ '.gitignore', 'text', - '''IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th + ''' +IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th Z2VzCi5wdWIvCmJ1aWxkLwojIFJlbW92ZSB0aGUgZm9sbG93aW5nIHBhdHRlcm4gaWYgeW91IHdp c2ggdG8gY2hlY2sgaW4geW91ciBsb2NrIGZpbGUKcHVic3BlYy5sb2NrCgojIERpcmVjdG9yeSBj cmVhdGVkIGJ5IGRhcnRkb2MKZG9jL2FwaS8K''', @@ -14,13 +23,15 @@ cmV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mRlc2NyaXB0aW9uOiBBbiBhYnNvbHV0ZSBiYXJlLWJvbmVz + ''' +bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBbiBhYnNvbHV0ZSBiYXJlLWJvbmVz IHdlYiBhcHAuCiMgdmVyc2lvbjogMS4wLjAKI2hvbWVwYWdlOiBodHRwczovL3d3dy5leGFtcGxl LmNvbQojYXV0aG9yOiBfX2F1dGhvcl9fIDxlbWFpbEBleGFtcGxlLmNvbT4KCmVudmlyb25tZW50 OgogIHNkazogJz49Mi4wLjAtZGV2LjUxLjAgPDIuMC4wJwoKI2RlcGVuZGVuY2llczoKIyAgcGF0 @@ -37,7 +49,8 @@ aDogXjEuNC4xCgpkZXZfZGVwZW5kZW5jaWVzOgogIGJ1aWxkX3J1bm5lcjogXjAuOC43CiAgYnVp bGRfd2ViX2NvbXBpbGVyczogXjAuNC4wCg==''', 'web/favicon.ico', 'binary', - '''iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAN + ''' +iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAN mUlEQVR42tWba3Ab1RXHFSCFJki7cZi2MxA7dkicQEmZhPIoUChpKBlaSMuEllIS27Ilyw+chNjy Q3JEWyCl00mhL1zIw3YgiXBI/NCupNXq/fIzGNr0c7/0Q4cpbUIhGUu6PffurrRSLFuStaJ8uF5J 1uPe3/2fc8+9e44KIaQqVYM/y3ZZrddKz3fzozfrg9yv9WHXRV3IOaePunwNUe6prTrdcvx/K0LX @@ -102,7 +115,8 @@ EWdRmi7oIFVl+nH3FQjPd+ZTT6RswTSGIM4CVI7eCfV/LogV5qCjF6H46VJxGn9JH+YutcwGLxtm VVUV9T8QJnnneGTPfwAAAABJRU5ErkJggg==''', 'web/index.html', 'text', - '''PCFET0NUWVBFIGh0bWw+Cgo8aHRtbD4KPGhlYWQ+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XNlcmlmOwp9 Cgojb3V0cHV0IHsKICBwYWRkaW5nOiAyMHB4OwogIHRleHQtYWxpZ246IGNlbnRlcjsKfQo=''' diff --git a/lib/generators/web_stagexl.dart b/lib/generators/web_stagexl.dart index e8f08b68..4db2ac4d 100644 --- a/lib/generators/web_stagexl.dart +++ b/lib/generators/web_stagexl.dart @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. import '../src/common.dart'; -import 'web_stagexl_data.dart'; +part 'web_stagexl.g.dart'; /// A generator for a StageXL web application. class WebStageXlGenerator extends DefaultGenerator { @@ -11,7 +11,7 @@ class WebStageXlGenerator extends DefaultGenerator { : super('web-stagexl', 'StageXL Web App', 'A starting point for 2D animation and games.', categories: const ['dart', 'web']) { - for (var file in decodeConcatenatedData(data)) { + for (var file in decodeConcatenatedData(_data)) { addTemplateFile(file); } diff --git a/lib/generators/web_stagexl_data.dart b/lib/generators/web_stagexl.g.dart similarity index 96% rename from lib/generators/web_stagexl_data.dart rename to lib/generators/web_stagexl.g.dart index a9c8e3c9..a72d5c95 100644 --- a/lib/generators/web_stagexl_data.dart +++ b/lib/generators/web_stagexl.g.dart @@ -2,10 +2,19 @@ // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -const List data = const [ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'web_stagexl.dart'; + +// ************************************************************************** +// Generator: DataGenerator +// ************************************************************************** + +const _data = const [ '.gitignore', 'text', - '''IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th + ''' +IyBGaWxlcyBhbmQgZGlyZWN0b3JpZXMgY3JlYXRlZCBieSBwdWIKLmRhcnRfdG9vbC8KLnBhY2th Z2VzCi5wdWIvCmJ1aWxkLwojIFJlbW92ZSB0aGUgZm9sbG93aW5nIHBhdHRlcm4gaWYgeW91IHdp c2ggdG8gY2hlY2sgaW4geW91ciBsb2NrIGZpbGUKcHVic3BlYy5s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ucmVsYXRlZF90eXBlX2Vx dWFsaXR5X2NoZWNrcwogICAgLSB2YWxpZF9yZWdleHBzCg==''', 'pubspec.yaml', 'text', - '''bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBIHNpbXBsZSBTdGFnZVhMIHdlYiBh + ''' +bmFtZTogX19wcm9qZWN0TmFtZV9fCmRlc2NyaXB0aW9uOiBBIHNpbXBsZSBTdGFnZVhMIHdlYiBh cHAuCiMgdmVyc2lvbjogMS4wLjAKI2hvbWVwYWdlOiBodHRwczovL3d3dy5leGFtcGxlLmNvbQoj YXV0aG9yOiBfX2F1dGhvcl9fIDxlbWFpbEBleGFtcGxlLmNvbT4KCmVudmlyb25tZW50OgogIHNk azogJz49Mi4wLjAtZGV2LjUxLjAgPDIuMC4wJwoKZGVwZW5kZW5jaWVzOgogIHN0YWdleGw6IF4x @@ -37,7 +49,8 @@ LjEuMAoKZGV2X2RlcGVuZGVuY2llczoKICBidWlsZF9ydW5uZXI6IF4wLjguNwogIGJ1aWxkX3dl Yl9jb21waWxlcnM6IF4wLjQuMAo=''', 'web/images/dart@1x.png', 'binary', - '''iVBORw0KGgoAAAANSUhEUgAAASwAAABQCAYAAACj6kh7AAAgkElEQVR4AeyaBWzrVhSG/8KYGdvY + ''' +iVBORw0KGgoAAAANSUhEUgAAASwAAABQCAYAAACj6kh7AAAgkElEQVR4AeyaBWzrVhSG/8KYGdvY jtsxCsZbRROMBWNmwWPmMTMzQ+vWydrw+hJ3zMzMzLyFzo7jXKmKtmjZC76eT/rLcK2cfv3vjdF0 nHFGOyyrAy7D922ExAP3IzKYQ8RKIxF8DHH7SCiI2tEQBEEQHKcTioR9GOKBz+BEiGWVR9gijA4T xqKEhD2Ce+9dB4ySmyAIQmNaVSxwD1IhYmERiyrDoWKyCA+k8XCMEB16DuGwSEsQhAa1qljwCJbU @@ -187,7 +200,8 @@ PSmyOeKNaeIRUQQQdQsskirf6F0yCym9ZaqOayN/I8cXhYN6rz0zf0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WdlIiBjbGFzcz0ic3RhZ2UtLWZ1bGxz Y3JlZW4iPjwvY2FudmFzPgoKPC9ib2R5Pgo8L2h0bWw+Cg==''', 'web/main.dart', 'text', - '''aW1wb3J0ICdkYXJ0OmFzeW5jJzsKaW1wb3J0ICdkYXJ0Omh0bWwnIGFzIGh0bWw7CmltcG9ydCAn + ''' +aW1wb3J0ICdkYXJ0OmFzeW5jJzsKaW1wb3J0ICdkYXJ0Omh0bWwnIGFzIGh0bWw7CmltcG9ydCAn cGFja2FnZTpzdGFnZXhsL3N0YWdleGwuZGFydCc7CmltcG9ydCAnZGFydDptYXRoJzsKCkZ1dHVy ZTxOdWxsPiBtYWluKCkgYXN5bmMgewogIFN0YWdlT3B0aW9ucyBvcHRpb25zID0gbmV3IFN0YWdl T3B0aW9ucygpCiAgICAuLmJhY2tncm91bmRDb2xvciA9IENvbG9yLldoaXRlCiAgICAuLnJlbmRl @@ -530,7 +546,8 @@ ZSBleGFtcGxlczoKICAvLyBodHRwczovL2dpdGh1Yi5jb20vYnA3NC9TdGFnZVhMX1NhbXBsZXMK fQo=''', 'web/styles.css', 'text', - '''QGltcG9ydCB1cmwoaHR0cHM6Ly9mb250cy5nb29nbGVhcGlzLmNvbS9jc3M/ZmFtaWx5PVJvYm90 + ''' +QGltcG9ydCB1cmwoaHR0cHM6Ly9mb250cy5nb29nbGVhcGlzLmNvbS9jc3M/ZmFtaWx5PVJvYm90 byk7CgpodG1sLCBib2R5LCAuc3RhZ2UtLWZ1bGxzY3JlZW4gewogICAgd2lkdGg6IDEwMCU7CiAg ICBoZWlnaHQ6IDEwMCU7CiAgICBtYXJnaW46IDA7CiAgICBwYWRkaW5nOiAwOwogICAgYm9yZGVy OiAwOwp9Cg==''' diff --git a/lib/src/cli_app.dart b/lib/src/cli_app.dart index df8b8e80..500c4328 100644 --- a/lib/src/cli_app.dart +++ b/lib/src/cli_app.dart @@ -14,10 +14,9 @@ import 'package:stagehand/src/common.dart'; import 'package:stagehand/stagehand.dart'; import 'package:usage/usage_io.dart'; -const String appName = 'stagehand'; +part 'cli_app.g.dart'; -// This version must be updated in tandem with the pubspec version. -const String appVersion = '2.0.1'; +const String appName = 'stagehand'; const String appPubInfo = 'https://pub.dartlang.org/packages/$appName.json'; diff --git a/lib/src/cli_app.g.dart b/lib/src/cli_app.g.dart new file mode 100644 index 00000000..63c96dc3 --- /dev/null +++ b/lib/src/cli_app.g.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2018, Google Inc. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'cli_app.dart'; + +// ************************************************************************** +// Generator: VersionGenerator +// ************************************************************************** + +const appVersion = '2.0.2-dev'; diff --git a/pubspec.yaml b/pubspec.yaml index 547392ef..98b671c9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ name: stagehand description: > A scaffolding generator for your Dart projects. Stagehand helps you get set up! -version: 2.0.1 +version: 2.0.2-dev homepage: https://github.com/dart-lang/stagehand author: Dart Team @@ -25,7 +25,10 @@ dependencies: usage: ^3.0.0 dev_dependencies: - ghpages_generator: ^0.3.0 + build: ^0.12.6 + build_config: ^0.2.1 + build_runner: ^0.8.9 grinder: ^0.8.0 + source_gen: ^0.8.1+1 test: ^0.12.30 yaml: ^2.1.2 diff --git a/tool/build-check.sh b/tool/build-check.sh index b08b79d0..e55dd90a 100755 --- a/tool/build-check.sh +++ b/tool/build-check.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Ensure that grind build was run. +# Ensure that "pub run build_runner build" was run and committed. # # Copyright (c) 2017, Google Inc. Please see the AUTHORS file for details. # All rights reserved. Use of this source code is governed by a BSD-style @@ -9,7 +9,7 @@ # Fast fail the script on failures. set -x -e -o pipefail -dart tool/grind.dart build +pub run build_runner build --delete-conflicting-outputs git status git add . git diff-index --quiet HEAD diff --git a/tool/builder.dart b/tool/builder.dart new file mode 100644 index 00000000..28e793cb --- /dev/null +++ b/tool/builder.dart @@ -0,0 +1,22 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. 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:source_gen/source_gen.dart'; +import 'package:build/build.dart'; + +import 'src/code_generator.dart'; +import 'src/version_generator.dart'; + +Builder stagehandBuilder([_]) => new PartBuilder([ + new VersionGenerator(), + new DataGenerator(), + ], header: _fileHeader); + +final _fileHeader = ''' +// Copyright (c) 2018, Google Inc. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// GENERATED CODE - DO NOT MODIFY BY HAND +'''; diff --git a/tool/grind.dart b/tool/grind.dart deleted file mode 100644 index 0e226724..00000000 --- a/tool/grind.dart +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) 2014, Google Inc. Please see the AUTHORS file for details. -// 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:convert'; -import 'dart:io'; -import 'dart:math' as math; - -import 'package:grinder/grinder.dart'; -import 'package:path/path.dart' as path; -import 'package:stagehand/stagehand.dart' as stagehand; - -const List _allowedDotFiles = const ['.gitignore']; - -final RegExp _binaryFileTypes = new RegExp( - r'\.(jpe?g|png|gif|ico|svg|ttf|eot|woff|woff2)$', - caseSensitive: false); - -main(List args) => grind(args); - -@Task('Concatenate the template files into runtime data files') -void build() { - stagehand.generators.forEach((generator) { - _concatenateFiles( - getDir('templates/${generator.id}'), - getFile( - 'lib/generators/${generator.id.replaceAll('-', '_')}_data.dart')); - }); - - // Update the readme.md file. - var f = getFile('README.md'); - var source = f.readAsStringSync(); - var fragment = stagehand.generators.map((g) { - return '* `${g.id}` - ${g.description}'; - }).join('\n'); - var newSource = _replaceInString( - source, '## Stagehand templates', '## Installation', fragment + '\n'); - f.writeAsStringSync(newSource); - - // Update the site/index.html file. - f = getFile('site/index.html'); - source = f.readAsStringSync(); - fragment = stagehand.generators.map((g) { - return '
  • ${g.id} - ${g.description}
  • '; - }).join('\n'); - newSource = - _replaceInString(source, '
      ', '
    ', fragment); - f.writeAsStringSync(newSource); -} - -@Task('Run each generator and analyze the output') -test() => new TestRunner().testAsync(files: 'test/validate_templates.dart'); - -void _concatenateFiles(Directory src, File target) { - log('Creating ${target.path}'); - - var str = _traverse(src, '').map((s) => ' ${_toStr(s)}').join(',\n'); - - target.writeAsStringSync(''' -// Copyright (c) ${_currentYear()}, Google Inc. Please see the AUTHORS file for details. -// All rights reserved. Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -const List data = const [ -$str -]; -'''); -} - -String _toStr(String s) { - if (s.contains('\n')) { - return "'''$s'''"; - } else { - return "'$s'"; - } -} - -Iterable _traverse(Directory dir, String root) sync* { - var files = _listSync(dir, recursive: false, followLinks: false); - for (var entity in files) { - if (entity is Link) continue; - - var name = path.basename(entity.path); - if (name == 'pubspec.lock') continue; - if (name == 'build' && entity is Directory) continue; - if (name.startsWith('.') && !_allowedDotFiles.contains(name)) continue; - - if (entity is Directory) { - yield* _traverse(entity, '$root$name/'); - } else { - yield '$root$name'; - yield _isBinaryFile(name) ? 'binary' : 'text'; - - var encoded = base64.encode((entity as File).readAsBytesSync()); - - // - // Logic to cut lines into 76-character chunks - // – makes for prettier source code - // - var lines = []; - var index = 0; - - while (index < encoded.length) { - var line = - encoded.substring(index, math.min(index + 76, encoded.length)); - lines.add(line); - index += line.length; - } - - yield lines.join('\r\n'); - } - } -} - -/// Returns `true` if the given [filename] matches common image file name -/// patterns. -bool _isBinaryFile(String filename) => _binaryFileTypes.hasMatch(filename); - -/// Return the list of children for the given directory. -/// -/// This list is normalized (by sorting on the file path) in order to prevent -/// large merge diffs in the generated template data files. -List _listSync(Directory dir, - {bool recursive: false, bool followLinks: true}) { - var results = dir.listSync(recursive: recursive, followLinks: followLinks); - results.sort((entity1, entity2) => entity1.path.compareTo(entity2.path)); - return results; -} - -/// Look for [start] and [end] in [source]; replace the current contents with -/// [replacement], and return the result. -String _replaceInString( - String source, String start, String end, String replacement) { - var startIndex = source.indexOf(start); - var endIndex = source.indexOf(end, startIndex + 1); - - if (startIndex == -1 || endIndex == -1) { - fail('Could not find text to replace'); - } - - return source.substring(0, startIndex + start.length + 1) + - replacement + - '\n' + - source.substring(endIndex); -} - -int _currentYear() => new DateTime.now().year; diff --git a/tool/src/code_generator.dart b/tool/src/code_generator.dart new file mode 100644 index 00000000..a335eae2 --- /dev/null +++ b/tool/src/code_generator.dart @@ -0,0 +1,87 @@ +// Copyright (c) 2018, Google Inc. Please see the AUTHORS file for details. +// 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:async'; +import 'dart:convert'; +import 'dart:math' as math; + +import 'package:build/build.dart'; +import 'package:path/path.dart' as p; +import 'package:glob/glob.dart'; +import 'package:source_gen/source_gen.dart'; + +const List _allowedDotFiles = const ['.gitignore']; +final RegExp _binaryFileTypes = new RegExp( + r'\.(jpe?g|png|gif|ico|svg|ttf|eot|woff|woff2)$', + caseSensitive: false); + +class DataGenerator extends Generator { + @override + FutureOr generate(LibraryReader library, BuildStep buildStep) async { + if (!p.isWithin('lib/generators', buildStep.inputId.path)) { + return null; + } + + if (buildStep.inputId.path.endsWith('_data.dart')) { + log.warning('temporary excluding ${buildStep.inputId.path}'); + return null; + } + + var name = + p.basenameWithoutExtension(buildStep.inputId.path).replaceAll('_', '-'); + + var filteredAssets = await buildStep + .findAssets(new Glob('templates/$name/**')) + .where((asset) { + var rootSegment = asset.pathSegments[2]; + + if (rootSegment == 'build' || rootSegment == 'pubspec.lock') { + return false; + } + + if (_allowedDotFiles.contains(rootSegment)) { + return true; + } + + return !rootSegment.startsWith('.'); + }).toList() + ..sort(); + + var items = await _getLines(filteredAssets, buildStep).map((item) { + if (item.contains('\n')) { + return "'''\n$item'''"; + } + return "'$item'"; + }).join(','); + + return 'const _data = const [$items];'; + } +} + +Stream _getLines(List ids, AssetReader reader) async* { + for (var id in ids) { + yield p.url.joinAll(id.pathSegments.skip(2)); + yield _binaryFileTypes.hasMatch(p.basename(id.path)) ? 'binary' : 'text'; + yield _base64encode(await reader.readAsBytes(id)); + } +} + +String _base64encode(List bytes) { + var encoded = base64.encode(bytes); + +// +// Logic to cut lines into 76-character chunks +// – makes for prettier source code +// + var lines = []; + var index = 0; + + while (index < encoded.length) { + var line = encoded.substring(index, math.min(index + 76, encoded.length)); + lines.add(line); + index += line.length; + } + + return lines.join('\r\n'); +} diff --git a/tool/src/version_generator.dart b/tool/src/version_generator.dart new file mode 100644 index 00000000..7dada567 --- /dev/null +++ b/tool/src/version_generator.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. 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:async'; + +import 'package:build/build.dart'; +import 'package:source_gen/source_gen.dart'; +import 'package:yaml/yaml.dart'; + +class VersionGenerator extends Generator { + @override + FutureOr generate(LibraryReader library, BuildStep buildStep) async { + if (buildStep.inputId.pathSegments.last != 'cli_app.dart') { + return null; + } + + var content = await buildStep + .readAsString(new AssetId(buildStep.inputId.package, 'pubspec.yaml')); + + var yaml = loadYaml(content) as Map; + + var versionString = yaml['version'] as String; + + return ''' +const appVersion = '$versionString'; +'''; + } +} diff --git a/tool/version-check-and-update.sh b/tool/version-check.sh similarity index 71% rename from tool/version-check-and-update.sh rename to tool/version-check.sh index 02e01d10..34a4607b 100755 --- a/tool/version-check-and-update.sh +++ b/tool/version-check.sh @@ -15,14 +15,12 @@ VERS_FROM_PUB=$(grep '^version:' pubspec.yaml | awk '{ print $2 }') echo "Version of stagehand from pubspec.yaml: $VERS_FROM_PUB" -CLIFILE=lib/src/cli_app.dart -if grep -qe "appVersion = '$VERS_FROM_PUB';" $CLIFILE; then - echo "✔ $CLIFILE has same version as pubspec." +VERSION_FILE=lib/src/cli_app.g.dart +if grep -qe "appVersion = '$VERS_FROM_PUB';" $VERSION_FILE; then + echo "✔ $VERSION_FILE has same version as pubspec." else EXIT_CODE=2 - grep "appVersion = " $CLIFILE - perl -i -pe "s/(appVersion = ')[^']*(';)/appVersion = '$VERS_FROM_PUB';/" $CLIFILE - echo "⚠️ $CLIFILE: HAS BEEN MODIFIED to use pubspec app version." + echo "⚠️ $VERSION_FILE: is outdated. Run 'pub run build_runner build'" fi CHANGELOG=CHANGELOG.md