Skip to content

Commit 6075fe4

Browse files
authored
Merge branch 'main' into luan.new-template
2 parents c4cead0 + bbc0bab commit 6075fe4

File tree

7 files changed

+22
-13
lines changed

7 files changed

+22
-13
lines changed

lib/commands/create_command.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Future<void> createCommand(ArgResults command) async {
2424
'Choose a name for your project: ',
2525
desc: 'Note: this must be a valid dart identifier (no dashes). '
2626
'For example: my_game',
27+
validate: (it) => !it.contains('-') && it != 'test',
2728
);
2829

2930
final org = getString(
@@ -34,6 +35,7 @@ Future<void> createCommand(ArgResults command) async {
3435
desc: 'Note: this is a dot separated list of "packages", '
3536
'normally in reverse domain notation. '
3637
'For example: org.flame_engine.games',
38+
validate: (it) => !it.contains('-'),
3739
);
3840

3941
final versions = FlameVersionManager.singleton.versions;

lib/commands/version_command.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
import 'dart:io';
2-
3-
import 'package:ignite_cli/utils.dart';
1+
import 'package:ignite_cli/version.g.dart';
42
import 'package:process_run/process_run.dart';
5-
import 'package:yaml/yaml.dart';
63

74
Future<void> versionCommand() async {
85
print(r'$ ignite --version:');
9-
print(await getVersionFromPubspec());
6+
print(igniteVersion);
107
print('');
118
await runExecutableArguments('dart', ['--version'], verbose: true);
129
print('');
1310
await runExecutableArguments('flutter', ['--version'], verbose: true);
14-
}
15-
16-
Future<String> getVersionFromPubspec() async {
17-
final f = File(getBundledFile('pubspec.yaml'));
18-
final yaml = loadYaml(await f.readAsString()) as Map;
19-
return yaml['version'] as String;
20-
}
11+
}

lib/utils.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ String getString(
1717
String message, {
1818
required bool isInteractive,
1919
String? desc,
20+
bool Function(String)? validate,
2021
}) {
2122
var value = results[name] as String?;
2223
if (!isInteractive) {
@@ -29,7 +30,7 @@ String getString(
2930
if (desc != null) {
3031
stdout.write(ansi.darkGray.wrap('\n$desc\u{1B}[1A\r'));
3132
}
32-
value = prompts.get(message, validate: (it) => !it.contains('-'));
33+
value = prompts.get(message, validate: validate);
3334
if (desc != null) {
3435
stdout.write('\r\u{1B}[K');
3536
}

lib/version.g.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file is generated. Do not manually edit.
2+
String igniteVersion = '0.6.0';
3+

scripts/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash -xe
22

3+
./scripts/generate-version.sh
4+
35
# TODO(luan): use a wildcard once supported
46
function bundle {
57
dart run mason_cli:mason bundle $1 -t dart -o lib/templates/bricks/

scripts/generate-version.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash -xe
2+
3+
version=`cat pubspec.yaml | grep 'version: ' | cut -d ' ' -f 2`
4+
contents="// This file is generated. Do not manually edit.\nString igniteVersion = '$version';\n"
5+
echo "$contents" | sed 's/\\n/\n/g' > lib/version.g.dart

scripts/test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash -xe
2+
3+
./scripts/build.sh
4+
./scripts/analyze.sh
5+
(cd test ; ./run.sh)

0 commit comments

Comments
 (0)