From d07568cada94330ec35192897843bd1953e2d7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wo=CC=88stmann?= Date: Tue, 2 Jul 2024 12:33:55 +0200 Subject: [PATCH 1/3] dartdev: Add empty project template --- pkg/dartdev/lib/src/templates.dart | 2 + pkg/dartdev/lib/src/templates/empty.dart | 57 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 pkg/dartdev/lib/src/templates/empty.dart diff --git a/pkg/dartdev/lib/src/templates.dart b/pkg/dartdev/lib/src/templates.dart index fdbd1500c6d2..368c326a32a2 100644 --- a/pkg/dartdev/lib/src/templates.dart +++ b/pkg/dartdev/lib/src/templates.dart @@ -11,6 +11,7 @@ import 'package:path/path.dart' as p; import 'templates/cli.dart'; import 'templates/console.dart'; import 'templates/console_simple.dart'; +import 'templates/empty.dart'; import 'templates/package.dart'; import 'templates/server_shelf.dart'; import 'templates/web.dart'; @@ -24,6 +25,7 @@ final List generators = [ PackageGenerator(), ServerShelfGenerator(), WebGenerator(), + EmptyGenerator(), // Deprecated generators: ConsoleSimpleGenerator(), ]; diff --git a/pkg/dartdev/lib/src/templates/empty.dart b/pkg/dartdev/lib/src/templates/empty.dart new file mode 100644 index 000000000000..997157ac87d4 --- /dev/null +++ b/pkg/dartdev/lib/src/templates/empty.dart @@ -0,0 +1,57 @@ +// Copyright (c) 2021, 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 '../templates.dart'; +import 'common.dart' as common; + +/// A generator for an empty Dart project. +class EmptyGenerator extends DefaultGenerator { + EmptyGenerator() + : super( + 'empty', + 'Empty Project', + 'An empty Dart project', + categories: const ['dart'], + alternateId: 'empty-project', + ) { + addFile('.gitignore', _gitignore); + addFile('analysis_options.yaml', common.analysisOptions); + addFile('pubspec.yaml', _pubspec); + } + + @override + String getInstallInstructions( + String directory, { + String? scriptPath, + }) => + super.getInstallInstructions(directory); +} + +final String _gitignore = ''' +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock +'''; + +final String _pubspec = ''' +name: __projectName__ +description: A starting point for Dart libraries or applications. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + ${common.sdkConstraint} + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^4.0.0 + test: ^1.24.0 +'''; From 72022f3bd1ded3a49d25cdbd26f950810748401e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20W=C3=B6stmann?= Date: Tue, 5 Nov 2024 00:51:37 +0100 Subject: [PATCH 2/3] Update empty.dart --- pkg/dartdev/lib/src/templates/empty.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/dartdev/lib/src/templates/empty.dart b/pkg/dartdev/lib/src/templates/empty.dart index 997157ac87d4..92cd15ce293e 100644 --- a/pkg/dartdev/lib/src/templates/empty.dart +++ b/pkg/dartdev/lib/src/templates/empty.dart @@ -1,4 +1,4 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// Copyright (c) 2024, 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. From 7dd3a2db8bbc1b93a5bc335d7a7b427ca383ff70 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Tue, 5 Nov 2024 10:30:29 -0500 Subject: [PATCH 3/3] Update pkg/dartdev/lib/src/templates/empty.dart Co-authored-by: Alejandro Santiago --- pkg/dartdev/lib/src/templates/empty.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/dartdev/lib/src/templates/empty.dart b/pkg/dartdev/lib/src/templates/empty.dart index 92cd15ce293e..0969beb20416 100644 --- a/pkg/dartdev/lib/src/templates/empty.dart +++ b/pkg/dartdev/lib/src/templates/empty.dart @@ -47,7 +47,6 @@ version: 1.0.0 environment: ${common.sdkConstraint} -# Add regular dependencies here. dependencies: # path: ^1.8.0