Skip to content

[native_assets_cli] Separate out json_syntax_generator into separate package #2101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
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
2 changes: 2 additions & 0 deletions pkgs/hook/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ environment:
dev_dependencies:
dart_flutter_team_lints: ^2.1.1
json_schema: ^5.2.0
json_syntax_generator:
path: ../json_syntax_generator/
path: ^1.9.1
test: ^1.25.15
10 changes: 10 additions & 0 deletions pkgs/hook/test/schema/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ AllSchemas loadSchemas(List<Uri> directories) {
);
allSchemas[entry.key] = schema;
}

final allSchemasInverted = allSchemas.map(
(key, value) => MapEntry(value, key),
);
if (allSchemas.length != allSchemasInverted.length) {
throw StateError(
'Some schemas are not unique, try adding a unique title field.',
);
}

return allSchemas;
}

Expand Down
8 changes: 7 additions & 1 deletion pkgs/hook/tool/generate_schemas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'dart:convert';
import 'dart:io';

import '../test/schema/helpers.dart';
import 'generate_syntax.dart';
import 'normalize.dart';

void main() {
Expand Down Expand Up @@ -184,3 +183,10 @@ void generateEntryPoints() {

String definitionName(Hook hook, InputOrOutput inputOrOutput) =>
'${ucFirst(hook.name)}${ucFirst(inputOrOutput.name)}';

String ucFirst(String str) {
if (str.isEmpty) {
return '';
}
return str[0].toUpperCase() + str.substring(1);
}
Loading