Skip to content

Commit f402c2e

Browse files
committed
Automate updating libraryVersion.
1 parent 9ca7981 commit f402c2e

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

melos.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ command:
1414
changelog: false
1515
packageFilters:
1616
noPrivate: true
17+
hooks:
18+
# Automatically update libraryVersion:
19+
preCommit: |
20+
dart run tool/update_version.dart
21+
git add packages/powersync/lib/src/version.dart
1722
publish:
1823
hooks:
1924
pre: sh tool/download_binaries.sh

packages/powersync/lib/src/user_agent/user_agent_native.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ String? powerSyncUserAgent() {
99
dart = "Dart/$dartVersion";
1010
}
1111
// Ideally we'd get an OS version, but that's quite complex.
12-
12+
// Platform.operatingSystemVersion is very verbose.
1313
return 'PowerSync/$libraryVersion ($dart; ${Platform.operatingSystem})';
1414
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// TODO: auto-update when bumping the version
2-
const libraryVersion = '1.6.4';
1+
const String libraryVersion = '1.6.4';

pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ packages:
506506
source: hosted
507507
version: "1.2.1"
508508
yaml:
509-
dependency: transitive
509+
dependency: "direct main"
510510
description:
511511
name: yaml
512512
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ dev_dependencies:
1212
melos: ^3.4.0
1313
test: ^1.25.0
1414
path: ^1.0.0
15+
yaml: ^3.1.2

tool/update_version.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'dart:io';
2+
import 'package:yaml/yaml.dart';
3+
4+
void main() {
5+
final pubspecFile = File('packages/powersync/pubspec.yaml');
6+
final pubspecContent = pubspecFile.readAsStringSync();
7+
final yaml = loadYaml(pubspecContent);
8+
final version = yaml['version'];
9+
10+
final versionFile = File('packages/powersync/lib/src/version.dart');
11+
versionFile.writeAsStringSync("const String libraryVersion = '$version';\n");
12+
}

0 commit comments

Comments
 (0)