diff --git a/sidekick/analysis_options.yaml b/sidekick/analysis_options.yaml index 3a2cae01..ddf3293a 100644 --- a/sidekick/analysis_options.yaml +++ b/sidekick/analysis_options.yaml @@ -8,4 +8,5 @@ analyzer: linter: rules: - avoid_print: false \ No newline at end of file + avoid_print: false + unawaited_futures: true \ No newline at end of file diff --git a/sidekick/test/plugins_test.dart b/sidekick/test/plugins_test.dart index 5717c509..63a591d5 100644 --- a/sidekick/test/plugins_test.dart +++ b/sidekick/test/plugins_test.dart @@ -1,5 +1,4 @@ import 'package:dcli/dcli.dart'; -import 'package:dcli_core/dcli_core.dart'; import 'package:recase/recase.dart'; import 'package:sidekick_core/sidekick_core.dart'; import 'package:sidekick_core/src/commands/plugins/create_plugin_command.dart'; @@ -55,7 +54,7 @@ void main() { 'git init'.start(workingDirectory: pluginDir.path); 'git add .'.start(workingDirectory: pluginDir.path); - withEnvironment( + await withEnvironment( () async => 'git commit -m "initial"'.start(workingDirectory: pluginDir.path), // without this, `git commit` crashes on CI diff --git a/sidekick/test/recompile_test.dart b/sidekick/test/recompile_test.dart index d185cdc7..7d7e950b 100644 --- a/sidekick/test/recompile_test.dart +++ b/sidekick/test/recompile_test.dart @@ -33,7 +33,7 @@ void main() { printOnFailure(stdout); final stderr = await updateProcess.stderrStream().join('\n'); printOnFailure(stderr); - updateProcess.shouldExit(0); + await updateProcess.shouldExit(0); expect(stderr, contains('Installing dashi command line application')); expect(stderr, contains('Getting dependencies')); expect(stderr, contains('Bundling assets')); diff --git a/sidekick_core/analysis_options.yaml b/sidekick_core/analysis_options.yaml index bee6163d..ef85cbd8 100644 --- a/sidekick_core/analysis_options.yaml +++ b/sidekick_core/analysis_options.yaml @@ -3,4 +3,5 @@ include: package:lint/analysis_options_package.yaml linter: rules: avoid_print: false + unawaited_futures: true # public_member_api_docs: true \ No newline at end of file diff --git a/sidekick_core/lib/sidekick_core.dart b/sidekick_core/lib/sidekick_core.dart index 3694a5fa..e315cc1c 100644 --- a/sidekick_core/lib/sidekick_core.dart +++ b/sidekick_core/lib/sidekick_core.dart @@ -35,7 +35,9 @@ export 'package:sidekick_core/src/directory_ext.dart'; export 'package:sidekick_core/src/file_util.dart'; export 'package:sidekick_core/src/flutter.dart'; export 'package:sidekick_core/src/forward_command.dart'; +export 'package:sidekick_core/src/process.dart' show ProcessCompletion; export 'package:sidekick_core/src/repository.dart'; +export 'package:sidekick_core/src/sdk_initializer.dart'; export 'package:sidekick_core/src/sidekick_context.dart' show SidekickContext; export 'package:sidekick_core/src/sidekick_package.dart'; export 'package:sidekick_core/src/template/sidekick_package.template.dart'; @@ -45,7 +47,7 @@ export 'package:sidekick_core/src/template/sidekick_package.template.dart'; /// This is used by the update command to determine if your sidekick cli /// requires an update // DO NOT MANUALLY EDIT THIS VERSION, instead run `sk bump-version sidekick_core` -final Version version = Version.parse('3.0.0-preview.0'); +final Version version = Version.parse('2.1.2'); /// Initializes sidekick, call this at the very start of your CLI program /// diff --git a/sidekick_core/lib/src/commands/analyze_command.dart b/sidekick_core/lib/src/commands/analyze_command.dart index 961e67b5..c0fb5437 100644 --- a/sidekick_core/lib/src/commands/analyze_command.dart +++ b/sidekick_core/lib/src/commands/analyze_command.dart @@ -11,10 +11,12 @@ class DartAnalyzeCommand extends ForwardCommand { @override Future run() async { // running in root of project, includes all packages - exitCode = dart( + // TODO run for each package separately, with different SDK versions + final completion = await dart( ['analyze', ...argResults!.arguments], workingDirectory: SidekickContext.projectRoot, nothrow: true, ); + exitCode = completion.exitCode ?? 1; } } diff --git a/sidekick_core/lib/src/commands/dart_command.dart b/sidekick_core/lib/src/commands/dart_command.dart index f3cfb112..23465c49 100644 --- a/sidekick_core/lib/src/commands/dart_command.dart +++ b/sidekick_core/lib/src/commands/dart_command.dart @@ -12,6 +12,7 @@ class DartCommand extends ForwardCommand { @override Future run() async { - exitCode = dart(argResults!.arguments, nothrow: true); + final completion = await dart(argResults!.arguments, nothrow: true); + exitCode = completion.exitCode ?? 1; } } diff --git a/sidekick_core/lib/src/commands/deps_command.dart b/sidekick_core/lib/src/commands/deps_command.dart index 7fa4f8d1..069139de 100644 --- a/sidekick_core/lib/src/commands/deps_command.dart +++ b/sidekick_core/lib/src/commands/deps_command.dart @@ -62,7 +62,7 @@ class DepsCommand extends Command { } _warnIfNotInProject(); // only get deps for selected package - _getDependencies(package); + await _getDependencies(package); return; } @@ -89,7 +89,7 @@ class DepsCommand extends Command { for (final package in allPackages.whereNot(excluded.contains)) { try { - _getDependencies(package); + await _getDependencies(package); } catch (e, stack) { print('Error while getting dependencies for ${package.name} ' '(${package.root.path})'); @@ -101,14 +101,16 @@ class DepsCommand extends Command { printerr("\n\nErrors while getting dependencies:"); printerr(errorText); exitCode = 1; + } else { + exitCode = 0; } } - void _getDependencies(DartPackage package) { + Future _getDependencies(DartPackage package) async { print(yellow('=== package ${package.name} ===')); final packageDir = package.root; final dartOrFlutter = package.isFlutterPackage ? flutter : dart; - dartOrFlutter( + await dartOrFlutter( ['pub', 'get'], workingDirectory: packageDir, throwOnError: () => diff --git a/sidekick_core/lib/src/commands/flutter_command.dart b/sidekick_core/lib/src/commands/flutter_command.dart index b0b85c35..25ad8473 100644 --- a/sidekick_core/lib/src/commands/flutter_command.dart +++ b/sidekick_core/lib/src/commands/flutter_command.dart @@ -13,6 +13,7 @@ class FlutterCommand extends ForwardCommand { @override Future run() async { final args = argResults!.arguments; - exitCode = flutter(args, nothrow: true); + final completion = await flutter(args, nothrow: true); + exitCode = completion.exitCode ?? 1; } } diff --git a/sidekick_core/lib/src/commands/format_command.dart b/sidekick_core/lib/src/commands/format_command.dart index b82e789c..b8ef7019 100644 --- a/sidekick_core/lib/src/commands/format_command.dart +++ b/sidekick_core/lib/src/commands/format_command.dart @@ -101,7 +101,7 @@ class FormatCommand extends Command { } final int lineLength = getLineLength(package) ?? defaultLineLength; final allDartFiles = package.root.findFilesToFormat(globExcludes); - _format( + await _format( name: "package:${package.name}", lineLength: lineLength, files: allDartFiles, @@ -125,7 +125,7 @@ class FormatCommand extends Command { for (final file in filesInPackage) { allFiles.remove(file); } - _format( + await _format( name: "package:${package.name}", lineLength: resolvedLineLength, files: filesInPackage, @@ -133,7 +133,7 @@ class FormatCommand extends Command { ); } if (allFiles.isNotEmpty) { - _format( + await _format( name: "Other", lineLength: defaultLineLength, files: allFiles, @@ -154,12 +154,12 @@ class FormatCommand extends Command { } } - void _format({ + Future _format({ required String name, required int lineLength, required Iterable files, bool verify = false, - }) { + }) async { if (verify) { print("Verifying $name"); } else { @@ -171,7 +171,7 @@ class FormatCommand extends Command { } final progress = verify ? Progress.capture() : Progress.print(capture: true); - final exitCode = dart( + final completion = await dart( [ 'format', '-l', @@ -186,6 +186,7 @@ class FormatCommand extends Command { // should only be printed when the change is actually written to the files (when verify is false) progress: progress, ); + exitCode = completion.exitCode ?? 1; if (exitCode != 0) { foundFormatError = true; unformattedFiles.addAll( diff --git a/sidekick_core/lib/src/dart.dart b/sidekick_core/lib/src/dart.dart index 932e7124..690b437a 100644 --- a/sidekick_core/lib/src/dart.dart +++ b/sidekick_core/lib/src/dart.dart @@ -12,31 +12,31 @@ import 'package:sidekick_core/sidekick_core.dart'; /// /// If [throwOnError] is given and the command returns a non-zero exit code, /// the result of [throwOnError] will be thrown regardless of [nothrow] -int dart( +Future dart( List args, { Directory? workingDirectory, dcli.Progress? progress, bool nothrow = false, String Function()? throwOnError, -}) { +}) async { Directory? sdk = dartSdk; - if (sdk == null) { - if (flutterSdk != null) { - final embeddedSdk = flutterSdk!.directory('bin/cache/dart-sdk'); - if (!embeddedSdk.existsSync()) { - // Flutter SDK is not fully initialized, the Dart SDK not yet downloaded - // Execute flutter_tool to download the embedded dart runtime - flutter([], workingDirectory: workingDirectory, nothrow: true); - } - if (embeddedSdk.existsSync()) { - sdk = embeddedSdk; - } + if (sdk == null && flutterSdk != null) { + final embeddedSdk = flutterSdk!.directory('bin/cache/dart-sdk'); + if (!embeddedSdk.existsSync()) { + // Flutter SDK is not fully initialized, the Dart SDK not yet downloaded + // Execute flutter_tool to download the embedded dart runtime + await flutter([], workingDirectory: workingDirectory, nothrow: true); + } + if (embeddedSdk.existsSync()) { + sdk = embeddedSdk; } } if (sdk == null) { throw DartSdkNotSetException(); } + await initializeSdkForPackage(workingDirectory); + final dart = Platform.isWindows ? sdk.file('bin/dart.exe') : sdk.file('bin/dart'); @@ -55,7 +55,7 @@ int dart( throw throwOnError(); } - return exitCode; + return ProcessCompletion(exitCode: exitCode); } /// The Dart SDK path is not set in [initializeSidekick] (param [dartSdk], neither is is the [flutterSdk]) diff --git a/sidekick_core/lib/src/dart_package.dart b/sidekick_core/lib/src/dart_package.dart index 73a47404..a069fcc0 100644 --- a/sidekick_core/lib/src/dart_package.dart +++ b/sidekick_core/lib/src/dart_package.dart @@ -27,6 +27,13 @@ class DartPackage { return null; } + final workspaceFile = pubspec['workspace']; + if (workspaceFile != null) { + // Workspace files are not packages + // flutter.dev/go/pub-workspace + return null; + } + // Check for (optional) flutter dependency final deps = pubspec['dependencies'] as YamlMap?; final withFlutter = deps?.containsKey('flutter') ?? false; diff --git a/sidekick_core/lib/src/flutter.dart b/sidekick_core/lib/src/flutter.dart index 8a61e399..12598c08 100644 --- a/sidekick_core/lib/src/flutter.dart +++ b/sidekick_core/lib/src/flutter.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:dcli/dcli.dart' as dcli; import 'package:sidekick_core/sidekick_core.dart'; @@ -9,26 +11,19 @@ import 'package:sidekick_core/sidekick_core.dart'; /// /// If [throwOnError] is given and the command returns a non-zero exit code, /// the result of [throwOnError] will be thrown regardless of [nothrow] -int flutter( +Future flutter( List args, { Directory? workingDirectory, dcli.Progress? progress, bool nothrow = false, String Function()? throwOnError, -}) { +}) async { final sdk = flutterSdk; if (sdk == null) { throw FlutterSdkNotSetException(); } - for (final initializer in _sdkInitializers) { - initializer( - FlutterInitializerContext( - sdk: sdk, - packagePath: workingDirectory, - ), - ); - } + await initializeSdkForPackage(workingDirectory); int exitCode = -1; try { @@ -54,7 +49,7 @@ int flutter( throw throwOnError(); } - return exitCode; + return ProcessCompletion(exitCode: exitCode); } /// The Flutter SDK path is not set in [initializeSidekick] (param [flutterSdk]) @@ -91,39 +86,3 @@ Directory? systemFlutterSdk() { /// Returns the path to Flutter SDK of the `flutter` executable on `PATH` String? systemFlutterSdkPath() => systemFlutterSdk()?.path; - -/// Registers an initializer function that is called before executing the flutter command -/// to prepare the SDK, such as downloading it. -/// -/// Also this function will be called multiple times, once for each usage of the [flutter] method -Removable addFlutterSdkInitializer(FlutterInitializer initializer) { - if (!_sdkInitializers.contains(initializer)) { - _sdkInitializers.add(initializer); - } - return () => _sdkInitializers.remove(initializer); -} - -/// Can be called to remove a listener -typedef Removable = void Function(); - -/// Called by [flutter] before executing the flutter executable -typedef FlutterInitializer = Function(FlutterInitializerContext context); - -/// Initializers that have to be executed before executing the flutter command -List _sdkInitializers = []; - -/// Called by [flutter] before executing the flutter executable -class FlutterInitializerContext { - FlutterInitializerContext({ - this.sdk, - this.packagePath, - }); - - /// The Flutter SDK directory, this directory is set by flutterSdkPath in [initializeSidekick] - /// Make sure the SDK will be initialized in this directory - /// You may want to use a symlink to the actual SDK directory - final Directory? sdk; - - /// The package directory where the [flutter] and [dart] command is executed - final Directory? packagePath; -} diff --git a/sidekick_core/lib/src/process.dart b/sidekick_core/lib/src/process.dart new file mode 100644 index 00000000..7e39306f --- /dev/null +++ b/sidekick_core/lib/src/process.dart @@ -0,0 +1,17 @@ +/// All information about a process that has completed. +abstract interface class ProcessCompletion { + int? get exitCode; + + factory ProcessCompletion({ + required int exitCode, + }) = _ProcessResult; +} + +class _ProcessResult implements ProcessCompletion { + @override + final int? exitCode; + + _ProcessResult({ + required this.exitCode, + }); +} diff --git a/sidekick_core/lib/src/sdk_initializer.dart b/sidekick_core/lib/src/sdk_initializer.dart new file mode 100644 index 00000000..19ab1b02 --- /dev/null +++ b/sidekick_core/lib/src/sdk_initializer.dart @@ -0,0 +1,86 @@ +import 'dart:async'; + +import 'package:sidekick_core/sidekick_core.dart'; + +/// Registers an initializer function that is called before executing the [flutter] and [dart] commands +/// to prepare the SDKs, such as downloading it. +/// +/// Also this function will be called multiple times, once for each usage of the [flutter]/[dart] method +Removable addSdkInitializer(SdkInitializer initializer) { + if (!_sdkInitializers.contains(initializer)) { + _sdkInitializers.add(initializer); + } + return () => _sdkInitializers.remove(initializer); +} + +/// Can be called to remove a listener +typedef Removable = void Function(); + +/// Called by [flutter] before executing the flutter executable +typedef SdkInitializer = FutureOr Function(SdkInitializerContext context); + +/// Initializers that have to be executed before executing the flutter command +List _sdkInitializers = []; + +/// Calls all registered Flutter/Dart SDK initializers +/// +/// The [workingDirectory] is the directory where the [flutter]/[dart] commands are executed. +/// The enclosing Dart package will be used to determine the Flutter/Dart SDK version. +Future initializeSdkForPackage( + Directory? workingDirectory, +) async { + final where = workingDirectory ?? entryWorkingDirectory; + + final Directory? packageDir = + where.findParent((dir) => DartPackage.fromDirectory(dir) != null); + + final context = SdkInitializerContext( + flutterSdk: flutterSdk, + dartSdk: dartSdk, + packageDir: + packageDir != null ? DartPackage.fromDirectory(packageDir) : null, + workingDirectory: where, + ); + for (final initializer in _sdkInitializers) { + try { + await initializer(context); + } catch (e, stack) { + printerr("Error initializing SDKs:\n$e"); + printerr(stack); + } + } +} + +/// Called by [flutter] before executing the flutter executable +/// Called by [dart] before executing the dart executable +class SdkInitializerContext { + SdkInitializerContext({ + this.flutterSdk, + this.dartSdk, + this.packageDir, + this.workingDirectory, + }); + + /// The Flutter SDK directory, this directory is set by flutterSdkPath in [initializeSidekick] + /// Make sure the SDK will be initialized in this directory + /// + /// You may want to use a symlink to the actual SDK directory + /// + /// `null` when the Flutter SDK is not required + final Directory? flutterSdk; + + /// The Dart SDK directory, this directory is set by dartSdkPath in [initializeSidekick] + /// Make sure the SDK will be initialized in this directory + /// + /// You may want to use a symlink to the actual SDK directory + /// + /// `null` when the Dart SDK is not required + final Directory? dartSdk; + + /// The package directory where the [flutter] or [dart] command is executed + /// which follows directly after this initialization + final DartPackage? packageDir; + + /// The directory the [flutter] or [dart] command will be executed in + final Directory? workingDirectory; +} diff --git a/sidekick_core/pubspec.yaml b/sidekick_core/pubspec.yaml index 6b45b329..98ff0a90 100644 --- a/sidekick_core/pubspec.yaml +++ b/sidekick_core/pubspec.yaml @@ -1,6 +1,6 @@ name: sidekick_core description: Shared sidekick commands, plugin engine, migrations, templates and utilities for sidekick CLIs -version: 3.0.0-preview.0 +version: 2.1.2 repository: https://github.com/phntmxyz/sidekick/tree/main/sidekick_core issue_tracker: https://github.com/phntmxyz/sidekick/labels/sidekick_core topics: @@ -15,7 +15,7 @@ dependencies: cli_completion: ^0.3.0 dart_console2: '>=3.0.0 <3.1.0' dartx: ^1.1.0 - dcli: ^4.0.1-beta.4 + dcli: ^4.0.4 glob: ^2.0.2 http: '>=0.13.5 <2.0.0' meta: ^1.5.0 diff --git a/sidekick_core/test/dart_package.dart b/sidekick_core/test/dart_package_test.dart similarity index 81% rename from sidekick_core/test/dart_package.dart rename to sidekick_core/test/dart_package_test.dart index 3aba2e33..f73224cf 100644 --- a/sidekick_core/test/dart_package.dart +++ b/sidekick_core/test/dart_package_test.dart @@ -87,5 +87,24 @@ flutter: expect(package!.name, 'package_name'); expect(package.isFlutterPackage, isTrue); }); + + test('a workspace is not a DartPackage', () { + final tempDir = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDir.deleteSync(recursive: true)); + tempDir.file('pubspec.yaml') + ..createSync() + ..writeAsStringSync(''' +name: _ # Can be anything, _ by convention. +environment: + sdk: ^3.5.0 # Must be ^3.5.0 or later for workspace to be allowed +workspace: +- pkgs/app1 # The workspace-packages must be subdirectories +- pkgs/app2 +- pkgs/shared +'''); + + final package = DartPackage.fromDirectory(tempDir); + expect(package, isNull); + }); }); } diff --git a/sidekick_core/test/flutter_command_test.dart b/sidekick_core/test/flutter_command_test.dart index 7d281ad2..c26c107a 100644 --- a/sidekick_core/test/flutter_command_test.dart +++ b/sidekick_core/test/flutter_command_test.dart @@ -42,7 +42,7 @@ void main() { runner.addCommand(FlutterCommand()); bool called = false; - addFlutterSdkInitializer((conf) { + addSdkInitializer((conf) { fakeFlutterSdk(directory: tempDir); called = true; }); @@ -63,14 +63,14 @@ void main() { runner.addCommand(FlutterCommand()); bool called1 = false; - addFlutterSdkInitializer((sdkDir) { + addSdkInitializer((sdkDir) { // async fakeFlutterSdk(directory: tempDir); called1 = true; }); bool called2 = false; - addFlutterSdkInitializer((sdkDir) { + addSdkInitializer((sdkDir) { // sync called2 = true; }); @@ -91,12 +91,12 @@ void main() { runner.addCommand(FlutterCommand()); int called = 0; - void initializer(FlutterInitializerContext context) { + void initializer(SdkInitializerContext context) { called++; } - addFlutterSdkInitializer(initializer); - addFlutterSdkInitializer(initializer); + addSdkInitializer(initializer); + addSdkInitializer(initializer); await runner.run(['flutter']).onError((error, stackTrace) { // ignore @@ -115,11 +115,11 @@ void main() { runner.addCommand(FlutterCommand()); int called = 0; - void initializer(FlutterInitializerContext context) { + void initializer(SdkInitializerContext context) { called++; } - final remove = addFlutterSdkInitializer(initializer); + final remove = addSdkInitializer(initializer); await runner.run(['flutter']).onError((error, stackTrace) { // ignore diff --git a/sidekick_core/test/format_command_test.dart b/sidekick_core/test/format_command_test.dart index 1e0a9c57..e4239fd7 100644 --- a/sidekick_core/test/format_command_test.dart +++ b/sidekick_core/test/format_command_test.dart @@ -376,15 +376,15 @@ name: dashi ..writeAsStringSync(_dartFile140); final fakeStdout = FakeStdoutStream(); final fakeStderr = FakeStdoutStream(); - overrideIoStreams( + await overrideIoStreams( stderr: () => fakeStderr, stdout: () => fakeStdout, - body: () { + body: () async { final runner = initializeSidekick( dartSdkPath: systemDartSdkPath(), ); runner.addCommand(FormatCommand()); - expectLater( + await expectLater( () => runner.run(['format', '--verify']), throwsA(isA()), ); diff --git a/sidekick_core/test/update/patches/157_fix_usage_message.patch_test.dart b/sidekick_core/test/update/patches/157_fix_usage_message.patch_test.dart index 18d3a82c..d6d7d03b 100644 --- a/sidekick_core/test/update/patches/157_fix_usage_message.patch_test.dart +++ b/sidekick_core/test/update/patches/157_fix_usage_message.patch_test.dart @@ -13,7 +13,7 @@ void main() { tempDir.deleteSync(recursive: true); env['SIDEKICK_PACKAGE_HOME'] = null; }); - tempDir.file('test').writeAsString('# entrypoint file'); + tempDir.file('test').writeAsStringSync('# entrypoint file'); sidekickDir.file('pubspec.yaml').writeAsStringSync('name: test_sidekick'); final cliMainFile = sidekickDir.file('lib/test_sidekick.dart') ..createSync(recursive: true) diff --git a/sidekick_core/test/update/patches/192_add_format_command.patch_test.dart b/sidekick_core/test/update/patches/192_add_format_command.patch_test.dart index 1b462ef9..62bf31ba 100644 --- a/sidekick_core/test/update/patches/192_add_format_command.patch_test.dart +++ b/sidekick_core/test/update/patches/192_add_format_command.patch_test.dart @@ -13,7 +13,7 @@ void main() { tempDir.deleteSync(recursive: true); env['SIDEKICK_PACKAGE_HOME'] = null; }); - tempDir.file('dash').writeAsString('# entrypoint file'); + tempDir.file('dash').writeAsStringSync('# entrypoint file'); sidekickDir.file('pubspec.yaml').writeAsStringSync('name: dash_sidekick'); final cliMainFile = sidekickDir.file('lib/dash_sidekick.dart') ..createSync(recursive: true) diff --git a/sidekick_core/test/update/patches/208_remove_cli_name.patch_test.dart b/sidekick_core/test/update/patches/208_remove_cli_name.patch_test.dart index e47ef2a2..baabc7f7 100644 --- a/sidekick_core/test/update/patches/208_remove_cli_name.patch_test.dart +++ b/sidekick_core/test/update/patches/208_remove_cli_name.patch_test.dart @@ -13,7 +13,7 @@ void main() { tempDir.deleteSync(recursive: true); env['SIDEKICK_PACKAGE_HOME'] = null; }); - tempDir.file('dash').writeAsString('# entrypoint file'); + tempDir.file('dash').writeAsStringSync('# entrypoint file'); sidekickDir.file('pubspec.yaml').writeAsStringSync('name: dash_sidekick'); final cliMainFile = sidekickDir.file('lib/dash_sidekick.dart') ..createSync(recursive: true) diff --git a/sidekick_core/test/update/patches/253_add_lock_file.patch_test.dart b/sidekick_core/test/update/patches/253_add_lock_file.patch_test.dart index 01847791..1ac4de39 100644 --- a/sidekick_core/test/update/patches/253_add_lock_file.patch_test.dart +++ b/sidekick_core/test/update/patches/253_add_lock_file.patch_test.dart @@ -13,7 +13,7 @@ void main() { tempDir.deleteSync(recursive: true); env['SIDEKICK_PACKAGE_HOME'] = null; }); - tempDir.file('dash').writeAsString('# entrypoint file'); + tempDir.file('dash').writeAsStringSync('# entrypoint file'); sidekickDir.file('pubspec.yaml').writeAsStringSync('name: dash_sidekick'); final gitignore = sidekickDir.file('.gitignore'); gitignore.writeAsStringSync(testCase.fileContentBefore); diff --git a/sidekick_core/test/update/update_2_0_0_test.dart b/sidekick_core/test/update/update_2_0_0_test.dart index bf4323de..daa7df1f 100644 --- a/sidekick_core/test/update/update_2_0_0_test.dart +++ b/sidekick_core/test/update/update_2_0_0_test.dart @@ -15,7 +15,7 @@ void main() { tempDir.deleteSync(recursive: true); env['SIDEKICK_PACKAGE_HOME'] = null; }); - tempDir.file('test').writeAsString('# entrypoint file'); + tempDir.file('test').writeAsStringSync('# entrypoint file'); final pubspecFile = sidekickDir.file('pubspec.yaml'); final oldHttpVersion = Version(0, 13, 6); pubspecFile.writeAsStringSync(''' diff --git a/sidekick_plugin_installer/analysis_options.yaml b/sidekick_plugin_installer/analysis_options.yaml index 1011f768..c54aac43 100644 --- a/sidekick_plugin_installer/analysis_options.yaml +++ b/sidekick_plugin_installer/analysis_options.yaml @@ -2,4 +2,5 @@ include: package:lint/analysis_options_package.yaml linter: rules: - avoid_print: false \ No newline at end of file + avoid_print: false + unawaited_futures: true diff --git a/sidekick_plugin_installer/test/register_plugin_test.dart b/sidekick_plugin_installer/test/register_plugin_test.dart index 24692e1d..e8209b6c 100644 --- a/sidekick_plugin_installer/test/register_plugin_test.dart +++ b/sidekick_plugin_installer/test/register_plugin_test.dart @@ -10,7 +10,7 @@ void main() { dir.file('packages/dash/lib/dash.dart').writeAsStringSync( initialCliFileContentWithoutImportAndCommand, ); - registerPlugin( + await registerPlugin( sidekickCli: DartPackage.fromDirectory(dir.directory('packages/dash'))!, command: 'MyCommand()', @@ -29,7 +29,7 @@ void main() { dir.file('packages/dash/lib/dash.dart').writeAsStringSync( initialCliFileContentWithMyCommand, ); - registerPlugin( + await registerPlugin( sidekickCli: DartPackage.fromDirectory(dir.directory('packages/dash'))!, command: 'MyCommand()', @@ -46,7 +46,7 @@ void main() { dir.file('packages/dash/lib/dash.dart').writeAsStringSync( initialCliFileContentWithoutImportAndCommand, ); - registerPlugin( + await registerPlugin( sidekickCli: DartPackage.fromDirectory(dir.directory('packages/dash'))!, import: "import 'package:my_package/src/my_command.dart';", @@ -64,7 +64,7 @@ void main() { dir.file('packages/dash/lib/dash.dart').writeAsStringSync( initialCliFileContentWithMyImport, ); - registerPlugin( + await registerPlugin( sidekickCli: DartPackage.fromDirectory(dir.directory('packages/dash'))!, import: "import 'package:my_package/src/my_command.dart';", diff --git a/sidekick_vault/analysis_options.yaml b/sidekick_vault/analysis_options.yaml index 1011f768..c54aac43 100644 --- a/sidekick_vault/analysis_options.yaml +++ b/sidekick_vault/analysis_options.yaml @@ -2,4 +2,5 @@ include: package:lint/analysis_options_package.yaml linter: rules: - avoid_print: false \ No newline at end of file + avoid_print: false + unawaited_futures: true diff --git a/sidekick_vault/test/delete_test.dart b/sidekick_vault/test/delete_test.dart index cf72aed0..59ac6524 100644 --- a/sidekick_vault/test/delete_test.dart +++ b/sidekick_vault/test/delete_test.dart @@ -1,4 +1,3 @@ -import 'package:dcli_core/dcli_core.dart'; import 'package:sidekick_core/sidekick_core.dart'; import 'package:sidekick_vault/sidekick_vault.dart'; import 'package:test/test.dart'; diff --git a/sidekick_vault/test/unlock_test.dart b/sidekick_vault/test/unlock_test.dart index 92ac6ea2..3fabf5db 100644 --- a/sidekick_vault/test/unlock_test.dart +++ b/sidekick_vault/test/unlock_test.dart @@ -1,4 +1,3 @@ -import 'package:dcli_core/dcli_core.dart'; import 'package:sidekick_core/sidekick_core.dart'; import 'package:sidekick_vault/sidekick_vault.dart'; import 'package:test/test.dart'; diff --git a/sidekick_vault/test/vault_command_test.dart b/sidekick_vault/test/vault_command_test.dart index 5f5e90a9..8710e792 100644 --- a/sidekick_vault/test/vault_command_test.dart +++ b/sidekick_vault/test/vault_command_test.dart @@ -1,4 +1,3 @@ -import 'package:dcli_core/dcli_core.dart'; import 'package:sidekick_core/sidekick_core.dart'; import 'package:sidekick_vault/sidekick_vault.dart'; import 'package:test/test.dart'; diff --git a/sidekick_vault/tool/install.dart b/sidekick_vault/tool/install.dart index 9e4f914b..a5e79a34 100644 --- a/sidekick_vault/tool/install.dart +++ b/sidekick_vault/tool/install.dart @@ -23,13 +23,13 @@ Future main() async { print("- Generating package:${package.name}/src/vault.dart"); _writeVaultFile(vaultDir, package); - addImport( + await addImport( package.libDir.file('${package.name}.dart'), "import 'package:${package.name}/src/vault.dart';", ); print("- Adding vault command"); - registerPlugin( + await registerPlugin( sidekickCli: package, import: "import 'package:sidekick_vault/sidekick_vault.dart';", command: 'VaultCommand(vault: vault)',