mirror of https://github.com/AMT-Cheif/drift.git
Fix analysis plugin for moor, migrate options
This commit is contained in:
parent
d6671f0462
commit
662b9d5721
|
@ -1,3 +1,7 @@
|
|||
## 1.0.2-dev
|
||||
|
||||
- Also transform `analysis_options.yaml` files in the `drift_dev migrate` command.
|
||||
|
||||
## 1.0.1
|
||||
|
||||
This is the initial release of the `drift_dev` package (formally known as `moor_generator`).
|
||||
|
|
|
@ -78,6 +78,8 @@ class MigrateCommand extends MoorCommand {
|
|||
await _transformPubspec(file);
|
||||
} else if (_buildYamlPattern.hasMatch(name)) {
|
||||
await _transformBuildYaml(file);
|
||||
} else if (name == 'analysis_options') {
|
||||
await _transformAnalysisOptions(file);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -251,6 +253,37 @@ class MigrateCommand extends MoorCommand {
|
|||
|
||||
await file.writeAsString(writer.content);
|
||||
}
|
||||
|
||||
Future<void> _transformAnalysisOptions(File file) async {
|
||||
// Replace moor with drift from the `analyzer/plugins` key.
|
||||
var content = await file.readAsString();
|
||||
YamlNode node;
|
||||
try {
|
||||
node = loadYamlNode(content, sourceUrl: file.uri);
|
||||
} on Exception {
|
||||
print('Could not parse analysis options in ${file.path}, skipping.');
|
||||
}
|
||||
|
||||
if (node is YamlMap) {
|
||||
final analyzer = node['analyzer'];
|
||||
if (analyzer is YamlMap) {
|
||||
final plugins = analyzer['plugins'];
|
||||
|
||||
if (plugins is YamlList) {
|
||||
for (final entry in plugins.nodes) {
|
||||
if (entry is YamlScalar && entry.value == 'moor') {
|
||||
final span = entry.span;
|
||||
content = content.replaceRange(
|
||||
span.start.offset, span.end.offset, 'drift');
|
||||
|
||||
await file.writeAsString(content);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _StringRewriter {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: drift_dev
|
||||
description: Dev-dependency for users of drift. Contains a the generator and development tools.
|
||||
version: 1.0.1
|
||||
version: 1.0.2-dev
|
||||
repository: https://github.com/simolus3/moor
|
||||
homepage: https://drift.simonbinder.eu/
|
||||
issue_tracker: https://github.com/simolus3/moor/issues
|
||||
|
|
|
@ -302,6 +302,35 @@ targets:
|
|||
drift_dev|not_shared:
|
||||
options:
|
||||
another: option
|
||||
''')
|
||||
]).validate();
|
||||
});
|
||||
|
||||
_test('transforms analysis option files', () async {
|
||||
await _setup(
|
||||
const [],
|
||||
additional: [
|
||||
d.file('analysis_options.yaml', '''
|
||||
# a comment
|
||||
analyzer:
|
||||
plugins:
|
||||
# comment 2
|
||||
- moor # another
|
||||
# another
|
||||
''')
|
||||
],
|
||||
);
|
||||
|
||||
await _apply();
|
||||
|
||||
await d.dir('app', [
|
||||
d.file('analysis_options.yaml', r'''
|
||||
# a comment
|
||||
analyzer:
|
||||
plugins:
|
||||
# comment 2
|
||||
- drift # another
|
||||
# another
|
||||
''')
|
||||
]).validate();
|
||||
});
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## 4.6.1-dev
|
||||
|
||||
- Fix the moor analyzer plugin
|
||||
|
||||
## 4.6.0
|
||||
|
||||
- Add `DoUpdate.withExcluded` to refer to the excluded row in an upsert clause.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: moor
|
||||
description: Moor is a safe and reactive persistence library for Dart applications
|
||||
version: 4.6.0
|
||||
version: 4.6.1-dev
|
||||
repository: https://github.com/simolus3/moor
|
||||
homepage: https://moor.simonbinder.eu/
|
||||
issue_tracker: https://github.com/simolus3/moor/issues
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:moor_generator/plugin.dart' as plugin;
|
||||
import 'package:moor_generator/integrations/plugin.dart' as plugin;
|
||||
import 'package:web_socket_channel/io.dart';
|
||||
|
||||
const useDebuggingVariant = false;
|
||||
|
|
Loading…
Reference in New Issue