Skip to content

Commit

Permalink
prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
danylo-safonov-solid committed Nov 16, 2023
1 parent 020f003 commit 63550fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
8 changes: 4 additions & 4 deletions add_imports.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
file_url_prefix: 'https://deno.land/x/postgres@v0.17.0/'
file_url_prefix: https://deno.land/x/postgres@v0.17.0/

classes_map:
'query/query.ts':
query/query.ts:
- QueryObjectResult
'mod.ts':
mod.ts:
- QueryClient
- Client
- 'Client': PostgresClient
- Client: PostgresClient
- Transaction
18 changes: 7 additions & 11 deletions bin/add_imports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,16 @@ String createNewSource(String sourceString, Config config) {
.whereNotNull()
.toSet()
.where((alias) => config.classes.any((e) => e.$2 == alias))
.whereNot((e) => sourceString.contains('import { $e }'))
.whereNot((e) => sourceString.contains('self.$e = '))
.map((alias) => config.classes.firstWhere((e) => e.$2 == alias))
.toList();

final imports = classes.map((e) => config.importStringForClass(e.$1));
final assignments = classes.map((e) => 'self.${e.$2} = ${e.$1};');

return [
...[
((String, String) e) => config.importStringForClass(e.$1),
((String, String) e) => 'self.${e.$2} = ${e.$1};',
]
.map(
classes
.map((alias) => config.classes.firstWhere((e) => e.$2 == alias))
.map,
)
.flattened,
...imports,
...assignments,
sourceString,
].join('\n');
}

0 comments on commit 63550fe

Please sign in to comment.