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
1 change: 1 addition & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ command:
workspaceChangelog: true
hooks:
preCommit: |
dart run scripts/generate_firebaseai_version.dart && \
dart run scripts/generate_dataconnect_version.dart && \
dart run scripts/generate_versions_spm.dart && \
git add packages/firebase_data_connect/firebase_data_connect/lib/src/dataconnect_version.dart
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_ai/firebase_ai/lib/src/base_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import 'client.dart';
import 'content.dart';
import 'developer/api.dart';
import 'error.dart';
import 'firebaseai_version.dart';
import 'imagen/imagen_api.dart';
import 'imagen/imagen_content.dart';
import 'imagen/imagen_edit.dart';
import 'imagen/imagen_reference.dart';
import 'live_api.dart';
import 'live_session.dart';
import 'tool.dart';
import 'vertex_version.dart';

part 'generative_model.dart';
part 'imagen/imagen_model.dart';
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_ai/firebase_ai/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'dart:convert';
import 'package:http/http.dart' as http;

import 'error.dart';
import 'vertex_version.dart';
import 'firebaseai_version.dart';

/// Client name to feed into the request.
const clientName = 'vertexai-dart/$packageVersion';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
// limitations under the License.

/// generated version number for the package, do not manually edit
const packageVersion = '2.0.0';
const packageVersion = '3.3.0';
65 changes: 65 additions & 0 deletions scripts/generate_firebaseai_version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:io' show Directory, File;
import 'package:path/path.dart' show joinAll;
import 'package:yaml/yaml.dart' show YamlMap, loadYaml;

Future<void> main() async {
final outputPath = joinAll(
[
Directory.current.path,
'packages',
'firebase_ai',
'firebase_ai',
'lib',
'src',
'firebaseai_version.dart',
],
);

final pubspecPath = joinAll(
[
Directory.current.path,
'packages',
'firebase_data_connect',
'firebase_data_connect',
'pubspec.yaml',
],
);
final yamlMap = loadYaml(File(pubspecPath).readAsStringSync()) as YamlMap;
final currentVersion = yamlMap['version'] as String;
final fileContents = File(outputPath).readAsStringSync();

final lines = fileContents.split('\n');

const versionLinePrefix = 'const packageVersion = ';
bool versionLineFound = false;
for (int i = 0; i < lines.length; i++) {
if (lines[i].startsWith(versionLinePrefix)) {
lines[i] = "$versionLinePrefix'$currentVersion';";
versionLineFound = true;
break;
}
}

if (!versionLineFound) {
lines.add("$versionLinePrefix'$currentVersion';");
}

// Join the lines back into a single string
final newFileContents = lines.join('\n');

await File(outputPath).writeAsString(newFileContents);
}
Loading