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..0969beb20416 --- /dev/null +++ b/pkg/dartdev/lib/src/templates/empty.dart @@ -0,0 +1,56 @@ +// 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. + +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} + +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^4.0.0 + test: ^1.24.0 +''';