Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Migrate version logic to pkg:build_version (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Sep 1, 2018
1 parent 39d9a18 commit 31250f9
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 46 deletions.
2 changes: 2 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ targets:
- lib/**
- templates/**
builders:
build_version:
enabled: true
stagehand:
generate_for:
- lib/src/cli_app.dart
Expand Down
8 changes: 4 additions & 4 deletions lib/src/cli_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:stagehand/src/common.dart';
import 'package:stagehand/stagehand.dart';
import 'package:usage/usage_io.dart';

part 'cli_app.g.dart';
import 'version.dart';

const String appName = 'stagehand';

Expand All @@ -38,7 +38,7 @@ class CliApp {
assert(generators != null);
assert(logger != null);

analytics = new AnalyticsIO(_gaTrackingId, appName, appVersion)
analytics = new AnalyticsIO(_gaTrackingId, appName, packageVersion)
// These `cdX` values MUST be tightly coordinated with Analytics config
// DO NOT modify unless you're certain what you're doing.
// Contact kevmoo@ if you have questions
Expand Down Expand Up @@ -85,10 +85,10 @@ class CliApp {
}

if (options['version']) {
_out('$appName version: $appVersion');
_out('$appName version: $packageVersion');
return http.get(appPubInfo).then((response) {
List versions = jsonDecode(response.body)['versions'];
if (appVersion != versions.last) {
if (packageVersion != versions.last) {
_out('Version ${versions.last} is available! Run `pub global activate'
' $appName` to get the latest.');
}
Expand Down
9 changes: 0 additions & 9 deletions lib/src/cli_app.g.dart

This file was deleted.

2 changes: 2 additions & 0 deletions lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dev_dependencies:
build: ^0.12.6
build_config: ^0.3.0
build_runner: ^0.10.0
build_version: ^1.0.0
glob: ^1.1.5
grinder: ^0.8.0
source_gen: ^0.9.0
Expand Down
2 changes: 0 additions & 2 deletions tool/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ 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(),
], '.g.dart');
29 changes: 0 additions & 29 deletions tool/src/version_generator.dart

This file was deleted.

4 changes: 2 additions & 2 deletions tool/version-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ VERS_FROM_PUB=$(grep '^version:' pubspec.yaml | awk '{ print $2 }')

echo "Version of stagehand from pubspec.yaml: $VERS_FROM_PUB"

VERSION_FILE=lib/src/cli_app.g.dart
if grep -qe "appVersion = '$VERS_FROM_PUB';" $VERSION_FILE; then
VERSION_FILE=lib/src/version.dart
if grep -qe "packageVersion = '$VERS_FROM_PUB';" $VERSION_FILE; then
echo "$VERSION_FILE has same version as pubspec."
else
EXIT_CODE=2
Expand Down

0 comments on commit 31250f9

Please sign in to comment.