Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dartdev: Add empty project template #56120

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/dartdev/lib/src/templates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +25,7 @@ final List<Generator> generators = [
PackageGenerator(),
ServerShelfGenerator(),
WebGenerator(),
EmptyGenerator(),
// Deprecated generators:
ConsoleSimpleGenerator(),
];
Expand Down
57 changes: 57 additions & 0 deletions pkg/dartdev/lib/src/templates/empty.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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}

# Add regular dependencies here.
bkonyi marked this conversation as resolved.
Show resolved Hide resolved
dependencies:
# path: ^1.8.0

dev_dependencies:
lints: ^4.0.0
test: ^1.24.0
''';