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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.2-wip

- Add a comment to the generated manifest (`functions.yaml`) to indicate that
it is managed by this package.

## 0.5.1

- Update constraint: `meta: ^1.17.0`
Expand Down
5 changes: 4 additions & 1 deletion lib/src/builder/manifest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import 'package:yaml_edit/yaml_edit.dart';
import '../common/cloud_run_id.dart';
import 'spec.dart';

const _manifestComment =
'# This file is generated by package:firebase_functions. Do not edit.';

/// Generates the YAML manifest string from discovered params and endpoints.
String generateManifestYaml(
Map<String, ParamSpec> params,
Expand All @@ -32,7 +35,7 @@ String generateManifestYaml(
final map = _buildManifestMap(params, endpoints);
final editor = YamlEditor('');
editor.update([], map);
return editor.toString();
return '$_manifestComment\n\n${editor.toString()}';
}

/// Builds the full manifest as a structured map.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name: firebase_functions
description: >-
Cloud Functions for Dart with support for the Firebase Admin SDK,
Cloud Storage and Firestore
version: 0.5.1
version: 0.5.2-wip
repository: https://github.com/firebase/firebase-functions-dart

environment:
Expand Down
7 changes: 7 additions & 0 deletions test/snapshots/manifest_snapshot_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ void main() {
expect(dartManifest['specVersion'], equals('v1alpha1'));
});

test('should have a comment at top', () {
final dartYaml = File(
'test/fixtures/dart_reference/functions.yaml',
).readAsStringSync();
expect(dartYaml, startsWith('#'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion startsWith('#') is too broad and doesn't fully validate the implementation. Since this is a snapshot test, it should verify the exact header string to ensure the generated manifest contains the correct 'Do not edit' warning and package attribution, preventing regressions in the header format.

      expect(dartYaml, startsWith('# This file is generated by package:firebase_functions. Do not edit.'));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a change-detector test.

});

// =========================================================================
// Params Tests
// =========================================================================
Expand Down
Loading