Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ melos run lint:all

- SDK uses semantic versioning
- Version managed in `packages/stream_feeds/pubspec.yaml`
- `packages/stream_feeds/lib/src/version.dart` is **generated** from that version by `tools/generate_version.dart`,
which runs automatically on every `melos bootstrap` (`command.bootstrap.hooks.post`). Never edit it by hand — it is
the SDK version reported in the `X-Stream-Client` header, and bootstrapping will overwrite any manual change.
- `stream_feeds` is the only published package; releases go out behind a single `vX.Y.Z` tag
- Below `1.0.0` the Dart convention shifts every slot down one: a breaking release is a **minor** bump, a
feature release is a **patch** bump, and a change with no public API impact is a build (`+1`) bump. See
Expand Down
8 changes: 8 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ command:
retrofit_generator: ^10.2.6
test: ^1.26.3

hooks:
# Syncs lib/src/version.dart with the version in stream_feeds' pubspec.
post: melos run version:update

scripts:
version:update:
run: dart tools/generate_version.dart
description: Updates packages/stream_feeds/lib/src/version.dart from its pubspec.yaml version.

postclean:
run: melos run clean:flutter --no-select
description: Runs "flutter clean" in all Flutter packages
Expand Down
4 changes: 4 additions & 0 deletions packages/stream_feeds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ the new names at your earliest convenience.

- Raised the minimum Dart SDK to `^3.12.0`.

### 🐞 Fixed

- Fixed the `X-Stream-Client` header values: the SDK identifier was duplicated, the version was hardcoded, and the OS was never reported.

## 0.5.1
- Added missing state updates for the websocket events.
- Add appeal-related methods to moderation client: `appeal`, `getAppeal`, and `queryAppeals`.
Expand Down
14 changes: 9 additions & 5 deletions packages/stream_feeds/lib/src/client/feeds_client_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import '../state/query/members_query.dart';
import '../state/query/moderation_configs_query.dart';
import '../state/query/poll_votes_query.dart';
import '../state/query/polls_query.dart';
import '../version.dart';
import '../ws/feeds_ws_event.dart';
import 'endpoint_config.dart';

Expand Down Expand Up @@ -220,12 +221,15 @@ class StreamFeedsClientImpl implements StreamFeedsClient {
late final PollsRepository _pollsRepository;
late final CapabilitiesRepository _capabilitiesRepository;

// TODO: Fill this with correct values
static const _sdkName = 'stream-feeds';
static const _sdkIdentifier = 'dart';

late final _systemEnvironmentManager = SystemEnvironmentManager(
environment: const SystemEnvironment(
sdkName: 'stream-feeds-dart',
sdkIdentifier: 'dart',
sdkVersion: '0.3.0',
environment: SystemEnvironment(
sdkName: _sdkName,
sdkIdentifier: _sdkIdentifier,
sdkVersion: packageVersion,
osName: CurrentPlatform.operatingSystem,
),
);

Expand Down
22 changes: 15 additions & 7 deletions packages/stream_feeds/lib/src/feeds_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,29 @@ abstract interface class StreamFeedsClient {

/// Updates the system environment information used by the client.
///
/// It allows you to set environment-specific information that will be
/// included in API requests, such as the application name, platform details,
/// and version information.
/// Sets the environment-specific information reported in the
/// `X-Stream-Client` header of API requests, such as the application name
/// and version, and the operating system and device details.
///
/// [SystemEnvironment.sdkName], [SystemEnvironment.sdkIdentifier] and
/// [SystemEnvironment.sdkVersion] identify the SDK itself and are owned by
/// it, so pass through the values the SDK already reports rather than custom
/// ones.
///
/// Example:
/// ```dart
/// client.updateSystemEnvironment(
/// SystemEnvironment(
/// name: 'my_app',
/// version: '1.0.0',
/// const SystemEnvironment(
/// sdkName: 'stream-feeds',
/// sdkIdentifier: 'dart',
/// sdkVersion: '0.5.1',
/// appName: 'my_app',
/// appVersion: '1.0.0',
/// ),
/// );
/// ```
///
/// See [SystemEnvironment] for more information on the available fields.
/// See [SystemEnvironment] for the available fields.
void updateSystemEnvironment(SystemEnvironment environment);

/// Establishes a connection to the Stream service.
Expand Down
13 changes: 13 additions & 0 deletions packages/stream_feeds/lib/src/version.dart

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

4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ packages:
source: hosted
version: "2.0.5"
path:
dependency: transitive
dependency: "direct dev"
description:
name: path
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
Expand Down Expand Up @@ -266,7 +266,7 @@ packages:
source: hosted
version: "1.1.1"
yaml:
dependency: transitive
dependency: "direct dev"
description:
name: yaml
sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce
Expand Down
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ environment:

dev_dependencies:
melos: ^6.2.0
# Used by tools/generate_version.dart.
path: ^1.9.0
yaml: ^3.1.3
45 changes: 45 additions & 0 deletions tools/generate_version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// ignore_for_file: avoid_print

import 'dart:io' show Directory, File;

import 'package:path/path.dart' as p;
import 'package:yaml/yaml.dart';

/// Updates the version constant in stream_feeds/lib/src/version.dart based on
/// the version in its pubspec.yaml file.
Future<void> main() async {
// Target the stream_feeds package
const packageName = 'stream_feeds';
final rootDir = Directory.current.path;
final packageDir = p.join(rootDir, 'packages', packageName);
final pubspecPath = p.join(packageDir, 'pubspec.yaml');
final versionFilePath = p.join(packageDir, 'lib', 'src', 'version.dart');

print('Reading version from $pubspecPath');

// Read version from pubspec.yaml
final yamlMap = loadYaml(File(pubspecPath).readAsStringSync()) as YamlMap;
final version = yamlMap['version'] as String;

print('Found version: $version');

// Read the existing version file
final versionFile = File(versionFilePath);
if (!versionFile.existsSync()) {
print('Error: Version file not found at $versionFilePath');
return;
}

final fileContent = versionFile.readAsStringSync();

// Update the version constant
final updatedContent = fileContent.replaceFirst(
RegExp('const String packageVersion = .+;'),
"const String packageVersion = '$version';",
);

// Write the changes back to the file
await versionFile.writeAsString(updatedContent);

print('✓ Successfully updated version to $version in $versionFilePath');
}
Loading