Skip to content

Commit

Permalink
Analysis: hard code package version (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
greenrobot-team committed Jan 17, 2023
1 parent ff2cbb0 commit fd89044
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
11 changes: 4 additions & 7 deletions generator/lib/src/analysis/analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import 'dart:isolate';

import 'package:cryptography/cryptography.dart';
import 'package:http/http.dart' as http;
import 'package:objectbox_generator/src/analysis/build_properties.dart';
import 'package:pubspec_parse/pubspec_parse.dart';

import '../version.dart';
import 'build_properties.dart';

/// Sends anonymous data to analyze usage of this package.
///
/// Requires [tokenFilePath] to exist, otherwise does nothing. See the
Expand Down Expand Up @@ -79,12 +81,7 @@ class ObjectBoxAnalysis {
properties["distinct_id"] = distinctId;

properties["Tool"] = "Dart Generator";
// This is (in most cases) not the actually used version,
// but the version range allowed.
final obxDep = pubspec?.dependencies["objectbox"];
if (obxDep != null && obxDep is HostedDependency) {
properties["Version"] = obxDep.version.toString();
}
properties["Version"] = Version.current;

final dartVersion = RegExp('([0-9]+).([0-9]+).([0-9]+)')
.firstMatch(Platform.version)
Expand Down
8 changes: 8 additions & 0 deletions generator/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// See [Version.current].
class Version {
/// Version of this package.
///
/// This string is updated by the /tool/set-version.sh script
/// as part of the release process.
static const String current = "1.7.0";
}
3 changes: 3 additions & 0 deletions tool/set-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ update generator/pubspec.yaml "${versionExpr}"
update flutter_libs/pubspec.yaml "${versionExpr}"
update sync_flutter_libs/pubspec.yaml "${versionExpr}"

versionDartExpr="s/current = \".*\"/current = \"${version}\"/g"
update generator/lib/src/version.dart "${versionDartExpr}"

dependencyHigherExpr="s/objectbox: \^.*/objectbox: ^${version}/g"
update objectbox/example/flutter/event_management_tutorial/event_manager/pubspec.yaml "${dependencyHigherExpr}"
update objectbox/example/flutter/event_management_tutorial/many_to_many/pubspec.yaml "${dependencyHigherExpr}"
Expand Down

0 comments on commit fd89044

Please sign in to comment.