diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 2c54236..4406e56 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -3,6 +3,20 @@ name: Integration Tests on: [ push ] jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.22.0' + channel: 'stable' + + - uses: actions/checkout@v4 + + - name: Run tests + run: dart test + build: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 04c46f3..0e9e9c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.0.0 + +- Update to Sidekick 3.0 +- Update dcli to 4.0.4 +- Min Dart version is now 3.3.0 + ## 0.1.0 - Initial plugin version installing `puro` \ No newline at end of file diff --git a/README.md b/README.md index a36a483..7e093d4 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ The plugin interprets Flutter and Dart version constraints and defaults to the m name: package_name environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.3.0 <4.0.0' ``` ```bash @@ -51,7 +51,7 @@ name: package_name environment: flutter: '^3.19.6' - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.3.0 <4.0.0' ``` ```bash diff --git a/ci_test/pubspec.yaml b/ci_test/pubspec.yaml index e248e8c..08dce60 100644 --- a/ci_test/pubspec.yaml +++ b/ci_test/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: "3.3.0" + sdk: "3.4.0" dependencies: flutter: diff --git a/ci_test/skt_sidekick/lib/skt_sidekick.dart b/ci_test/skt_sidekick/lib/skt_sidekick.dart index 9929638..1cff54e 100644 --- a/ci_test/skt_sidekick/lib/skt_sidekick.dart +++ b/ci_test/skt_sidekick/lib/skt_sidekick.dart @@ -9,7 +9,7 @@ Future runSkt(List args) async { mainProjectPath: '.', flutterSdkPath: flutterSdkSymlink(), ); - addFlutterSdkInitializer(initializePuro); + addSdkInitializer(initializePuro); runner ..addCommand(FlutterCommand()) diff --git a/ci_test/skt_sidekick/pubspec.lock b/ci_test/skt_sidekick/pubspec.lock index 6a87d13..6972946 100644 --- a/ci_test/skt_sidekick/pubspec.lock +++ b/ci_test/skt_sidekick/pubspec.lock @@ -1,22 +1,6 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - sha256: "405666cd3cf0ee0a48d21ec67e65406aad2c726d9fa58840d3375e7bdcd32a07" - url: "https://pub.dev" - source: hosted - version: "60.0.0" - analyzer: - dependency: transitive - description: - name: analyzer - sha256: "1952250bd005bacb895a01bf1b4dc00e3ba1c526cf47dca54dfe24979c65f5b3" - url: "https://pub.dev" - source: hosted - version: "5.12.0" archive: dependency: transitive description: @@ -41,22 +25,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" - basic_utils: - dependency: transitive - description: - name: basic_utils - sha256: "8815477fcf58499e42326bd858e391442425fa57db9a45e48e15224c62049262" - url: "https://pub.dev" - source: hosted - version: "5.5.4" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" characters: dependency: transitive description: @@ -65,14 +33,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" - charcode: - dependency: transitive - description: - name: charcode - sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 - url: "https://pub.dev" - source: hosted - version: "1.3.1" checked_yaml: dependency: transitive description: @@ -105,14 +65,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.0" - cli_util: - dependency: transitive - description: - name: cli_util - sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19 - url: "https://pub.dev" - source: hosted - version: "0.4.1" clock: dependency: transitive description: @@ -137,14 +89,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" - coverage: - dependency: transitive - description: - name: coverage - sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb" - url: "https://pub.dev" - source: hosted - version: "1.6.4" crypto: dependency: transitive description: @@ -157,10 +101,18 @@ packages: dependency: transitive description: name: csv - sha256: "63ed2871dd6471193dffc52c0e6c76fb86269c00244d244297abbb355c84a86e" + sha256: c6aa2679b2a18cb57652920f674488d89712efaf4d3fdf2e537215b35fc19d6c url: "https://pub.dev" source: hosted - version: "5.1.1" + version: "6.0.0" + dart_console: + dependency: transitive + description: + name: dart_console + sha256: eae9ddd7bb69477a6e9821c75d575874e290887da09292732a35ab510d1de713 + url: "https://pub.dev" + source: hosted + version: "4.1.0" dart_console2: dependency: transitive description: @@ -181,18 +133,34 @@ packages: dependency: transitive description: name: dcli - sha256: "1b4a960f39e60d177dadbfc57059e391b69ac914c76dc6b91e5ba76b0f92d294" + sha256: fb9897c9c2171bc53a26b62e582a98b4e1df70a65bede073c1a11108950d0440 + url: "https://pub.dev" + source: hosted + version: "4.0.5" + dcli_common: + dependency: transitive + description: + name: dcli_common + sha256: fa90efc6f5105de865db51fed4204b41e13f5113425d5704e46e56889f1cc46a url: "https://pub.dev" source: hosted - version: "2.2.3" + version: "4.0.3" dcli_core: dependency: transitive description: name: dcli_core - sha256: "2d5281792dd2a4bf8b612335fd530e91d14f3829debde841720ed9a7552b3a27" + sha256: "4adec804e93b718d2b9efd7e4305c818219f65b8140833c7c12b10b198aff8c9" url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "4.0.7" + dcli_terminal: + dependency: transitive + description: + name: dcli_terminal + sha256: fc289acb2e03f20c0d9b97ad5f19bcfa0d9dd8323028fee182fa7249b7687891 + url: "https://pub.dev" + source: hosted + version: "4.0.3" equatable: dependency: transitive description: @@ -205,26 +173,26 @@ packages: dependency: transitive description: name: ffi - sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" file: dependency: transitive description: name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted - version: "6.1.4" - frontend_server_client: + version: "7.0.0" + fixnum: dependency: transitive description: - name: frontend_server_client - sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" url: "https://pub.dev" source: hosted - version: "3.2.0" + version: "1.1.0" functional_data: dependency: transitive description: @@ -257,14 +225,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.13.6" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" - url: "https://pub.dev" - source: hosted - version: "3.2.1" http_parser: dependency: transitive description: @@ -289,22 +249,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.18.1" - io: - dependency: transitive - description: - name: io - sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" json2yaml: dependency: transitive description: @@ -329,6 +273,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.0" + lists: + dependency: transitive + description: + name: lists + sha256: "4ca5c19ae4350de036a7e996cdd1ee39c93ac0a2b840f4915459b7d0a7d4ab27" + url: "https://pub.dev" + source: hosted + version: "1.0.1" logging: dependency: transitive description: @@ -345,14 +297,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.8" - matcher: - dependency: transitive - description: - name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" - url: "https://pub.dev" - source: hosted - version: "0.12.15" meta: dependency: transitive description: @@ -369,22 +313,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" - node_preamble: + native_synchronization: dependency: transitive description: - name: node_preamble - sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + name: native_synchronization + sha256: ff200fe0a64d733ff7d4dde2005271c297db81007604c8cd21037959858133ab url: "https://pub.dev" source: hosted - version: "2.0.2" - package_config: - dependency: transitive - description: - name: package_config - sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" - url: "https://pub.dev" - source: hosted - version: "2.1.0" + version: "0.2.0" path: dependency: transitive description: @@ -393,30 +329,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" - pointycastle: - dependency: transitive - description: - name: pointycastle - sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe" - url: "https://pub.dev" - source: hosted - version: "3.9.1" - pool: - dependency: transitive - description: - name: pool - sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" - url: "https://pub.dev" - source: hosted - version: "1.5.1" posix: dependency: transitive description: name: posix - sha256: "3ad26924254fd2354b0e2b95fc8b45ac392ad87434f8e64807b3a1ac077f2256" + sha256: a0117dc2167805aa9125b82eee515cc891819bac2f538c83646d355b16f58b9a url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "6.0.1" pub_semver: dependency: transitive description: @@ -441,6 +361,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + pubspec_manager: + dependency: transitive + description: + name: pubspec_manager + sha256: b2674161f3f69ed07bc164dc4172afc190d56f060a293a8eb6fa691e5ddf9b5c + url: "https://pub.dev" + source: hosted + version: "1.0.0" pubspec_parse: dependency: transitive description: @@ -456,22 +384,6 @@ packages: relative: true source: path version: "0.1.0" - quiver: - dependency: transitive - description: - name: quiver - sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 - url: "https://pub.dev" - source: hosted - version: "3.2.1" - random_string: - dependency: transitive - description: - name: random_string - sha256: "03b52435aae8cbdd1056cf91bfc5bf845e9706724dd35ae2e99fa14a1ef79d02" - url: "https://pub.dev" - source: hosted - version: "2.3.1" recase: dependency: transitive description: @@ -480,78 +392,46 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" - scope: - dependency: transitive - description: - name: scope - sha256: e0c880d8f0db2ffd2accd63eeb02396748f3b8a2f71bce4b7d3f8dab75fc8a74 - url: "https://pub.dev" - source: hosted - version: "3.0.0" - settings_yaml: - dependency: transitive - description: - name: settings_yaml - sha256: "7b24fabf8595da060cb98d72541d594c3d3c706272b4d7bec70b251473257909" - url: "https://pub.dev" - source: hosted - version: "6.0.0" - shelf: + runtime_named_locks: dependency: transitive description: - name: shelf - sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + name: runtime_named_locks + sha256: "5fe859c1ddeeb595f6528596157191b628d85ba3137f0da327d92153604f2f6b" url: "https://pub.dev" source: hosted - version: "1.4.1" - shelf_packages_handler: + version: "1.0.0-beta.6" + runtime_native_semaphores: dependency: transitive description: - name: shelf_packages_handler - sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + name: runtime_native_semaphores + sha256: bd5895d87f97543be6c9a5199b8a10483b9d6871327fe508ec89dbc2437c9220 url: "https://pub.dev" source: hosted - version: "3.0.2" - shelf_static: + version: "1.0.0-beta.6" + scope: dependency: transitive description: - name: shelf_static - sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e + name: scope + sha256: "80cf1cb727791fdaaa4131817974a6084815ed59b9ab02ef352c3a1badea488b" url: "https://pub.dev" source: hosted - version: "1.1.2" - shelf_web_socket: + version: "4.1.0" + settings_yaml: dependency: transitive description: - name: shelf_web_socket - sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + name: settings_yaml + sha256: "415bc91cbcfe8b66b0945fdad8823b439ec9bd31591db6c1a4d2d07cab97899d" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "8.1.0" sidekick_core: dependency: "direct main" description: name: sidekick_core - sha256: "23a62a757d8afa0f5384d2867e6b8e966fc2d9ace1a5b99c48fc0da14bb44d91" + sha256: "9af069c1c7b53fd388a807242d766e3f6dd236ca4afdbeb5c77ec83d6adcbedf" url: "https://pub.dev" source: hosted - version: "2.1.2" - source_map_stack_trace: - dependency: transitive - description: - name: source_map_stack_trace - sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - source_maps: - dependency: transitive - description: - name: source_maps - sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" - url: "https://pub.dev" - source: hosted - version: "0.10.12" + version: "3.0.0-preview.1" source_span: dependency: transitive description: @@ -560,22 +440,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" - stack_trace: + sprintf: dependency: transitive description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" url: "https://pub.dev" source: hosted - version: "1.11.1" - stream_channel: + version: "7.0.0" + stack_trace: dependency: transitive description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "1.11.1" string_scanner: dependency: transitive description: @@ -584,6 +464,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + strings: + dependency: transitive + description: + name: strings + sha256: "052836499f03897d3860a603b330c1ea3c8a14177b21f34b15a1295f36024aae" + url: "https://pub.dev" + source: hosted + version: "3.1.2" sum_types: dependency: transitive description: @@ -608,22 +496,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: daadc9baabec998b062c9091525aa95786508b1c48e9c30f1f891b8bf6ff2e64 - url: "https://pub.dev" - source: hosted - version: "0.5.2" - test_core: - dependency: transitive - description: - name: test_core - sha256: "3642b184882f79e76ca57a9230fb971e494c3c1fd09c21ae3083ce891bcc0aa1" - url: "https://pub.dev" - source: hosted - version: "0.5.2" time: dependency: transitive description: @@ -640,22 +512,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" - uri: + unicode: dependency: transitive description: - name: uri - sha256: "889eea21e953187c6099802b7b4cf5219ba8f3518f604a1033064d45b1b8268a" + name: unicode + sha256: "0f69e46593d65245774d4f17125c6084d2c20b4e473a983f6e21b7d7762218f1" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "0.3.1" uuid: dependency: transitive description: name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + sha256: "83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90" url: "https://pub.dev" source: hosted - version: "3.0.7" + version: "4.4.2" validators2: dependency: transitive description: @@ -664,46 +536,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583 - url: "https://pub.dev" - source: hosted - version: "11.10.0" - watcher: - dependency: transitive - description: - name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - web: - dependency: transitive - description: - name: web - sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05" - url: "https://pub.dev" - source: hosted - version: "0.4.2" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - sha256: "939ab60734a4f8fa95feacb55804fa278de28bdeef38e616dc08e44a84adea23" - url: "https://pub.dev" - source: hosted - version: "2.4.3" - webkit_inspection_protocol: - dependency: transitive - description: - name: webkit_inspection_protocol - sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" - url: "https://pub.dev" - source: hosted - version: "1.2.1" win32: dependency: transitive description: @@ -729,4 +561,4 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=3.2.6 <3.999.0" + dart: ">=3.3.0 <3.999.0" diff --git a/ci_test/skt_sidekick/pubspec.yaml b/ci_test/skt_sidekick/pubspec.yaml index 9845972..007449d 100644 --- a/ci_test/skt_sidekick/pubspec.yaml +++ b/ci_test/skt_sidekick/pubspec.yaml @@ -4,15 +4,17 @@ version: 0.0.1 publish_to: none environment: - sdk: ">=3.2.6 <4.0.0" + sdk: ">=3.3.0 <4.0.0" executables: main: dependencies: puro_sidekick_plugin: - git: https://github.com/phntmxyz/puro_sidekick_plugin - sidekick_core: ^2.1.2 + git: + url: https://github.com/phntmxyz/puro_sidekick_plugin + ref: update-core-to-3.0.0 + sidekick_core: ^3.0.0-preview.1 dev_dependencies: lint: ^2.0.0 @@ -23,4 +25,4 @@ dependency_overrides: # generated code, do not edit this manually sidekick: - cli_version: 2.1.2 + cli_version: 3.0.0-preview.1 diff --git a/lib/puro_sidekick_plugin.dart b/lib/puro_sidekick_plugin.dart index 0fc6558..cf17ad2 100644 --- a/lib/puro_sidekick_plugin.dart +++ b/lib/puro_sidekick_plugin.dart @@ -13,7 +13,7 @@ export 'package:puro_sidekick_plugin/src/flutter_sdk.dart' hide createSymlink, puroFlutterSdkPath; export 'package:puro_sidekick_plugin/src/puro.dart'; -void initializePuro(Directory sdk) { +void initializePuro(SdkInitializerContext context) { // Create folder for flutter sdk symlink final symlinkPath = flutterSdkSymlink(); @@ -21,7 +21,7 @@ void initializePuro(Directory sdk) { dcli.env['PURO_ROOT'] = puroRootDir.absolute.path; // Setup puro environment - _setupFlutterEnvironment(); + _setupFlutterEnvironment(context); // Create symlink to puro flutter sdk final flutterPath = puroFlutterSdkPath(); @@ -29,14 +29,11 @@ void initializePuro(Directory sdk) { createSymlink(symlinkPath, flutterPath); } -void _setupFlutterEnvironment() { +void _setupFlutterEnvironment(SdkInitializerContext context) { final sdkVersion = VersionParser( - packagePath: entryWorkingDirectory, + packagePath: context.packageDir?.root ?? SidekickContext.projectRoot, projectRoot: SidekickContext.projectRoot, ).getMaxFlutterSdkVersionFromPubspec(); - if (sdkVersion == null) { - throw Exception('No Flutter SDK version found in pubspec.yaml'); - } final progress = Progress.capture(); puro(['ls'], progress: progress); diff --git a/lib/src/commands/puro_command.dart b/lib/src/commands/puro_command.dart index c2d13e9..29abfe3 100644 --- a/lib/src/commands/puro_command.dart +++ b/lib/src/commands/puro_command.dart @@ -13,8 +13,7 @@ class PuroCommand extends ForwardCommand { Future run() async { final args = argResults!.arguments; - initializePuro(Directory.current); - - exitCode = puro(args); + final completion = await puro(args, nothrow: true); + exitCode = completion.exitCode ?? 1; } } diff --git a/lib/src/puro.dart b/lib/src/puro.dart index a381ab3..4385bc4 100644 --- a/lib/src/puro.dart +++ b/lib/src/puro.dart @@ -4,36 +4,44 @@ import 'package:sidekick_core/sidekick_core.dart'; /// Executes Flutter CLI via puro /// /// https://github.com/phntmxyz/puro_sidekick_plugin -int puro( +Future puro( List args, { Directory? workingDirectory, dcli.Progress? progress, + bool nothrow = false, String Function()? throwOnError, -}) { - final workingDir = entryWorkingDirectory.absolute; - +}) async { final puroPath = getPuroPath(); if (puroPath == null) { throw PuroNotFoundException(); } - final process = dcli.startFromArgs( - puroPath.path, - ['--no-update-check', '--no-install', ...args], - workingDirectory: workingDir.path, - nothrow: true, - progress: progress, - terminal: progress == null, - ); - - final exitCode = process.exitCode ?? -1; + int exitCode = -1; + try { + final process = dcli.startFromArgs( + puroPath.path, + ['--no-update-check', '--no-install', ...args], + workingDirectory: workingDirectory?.absolute.path, + nothrow: nothrow || throwOnError != null, + progress: progress, + terminal: progress == null, + ); + exitCode = process.exitCode ?? -1; + } catch (e) { + if (e is dcli.RunException) { + exitCode = e.exitCode ?? 1; + } + if (throwOnError == null) { + rethrow; + } + } if (exitCode != 0 && throwOnError != null) { throw throwOnError(); } - return exitCode; + return ProcessCompletion(exitCode: exitCode); } File? getPuroPath() { diff --git a/lib/src/version_parser.dart b/lib/src/version_parser.dart index 76cea7c..cc810ac 100644 --- a/lib/src/version_parser.dart +++ b/lib/src/version_parser.dart @@ -27,11 +27,13 @@ class VersionParser { /// If the flutter version is not available, it reads the dart sdk version /// and returns the flutter version of the upper bound dart version constraint /// Returns null if the version is not found - String? getMaxFlutterSdkVersionFromPubspec() { + String getMaxFlutterSdkVersionFromPubspec() { try { YamlMap? pubspec = _readPubspecFile(packagePath); if (pubspec == null) { - return null; + throw VersionParserException( + msg: 'No pubspec.yaml found in the package directory: $packagePath', + ); } // Check if the package is part of a workspace @@ -62,6 +64,7 @@ class VersionParser { if (flutterConstraint != null) { final flutterVersion = VersionConstraint.parse(flutterConstraint); + print('Found flutter version constraint: $flutterVersion'); for (final version in availableVersions.values) { if (flutterVersion.allows(version)) { return version.toString(); @@ -69,26 +72,31 @@ class VersionParser { } } else if (dartConstraint != null) { final dartVersion = VersionConstraint.parse(dartConstraint); + print('Found dart version constraint: $dartVersion'); for (final version in availableVersions.keys) { if (dartVersion.allows(version)) { return availableVersions[version].toString(); } } - } else { - print('No flutter or dart version constraint found in pubspec.yaml'); - return null; } - - return null; + throw VersionParserException( + msg: + 'No valid flutter or dart version constraint found in pubspec.yaml', + ); } on FileSystemException catch (e) { - print('Error reading pubspec.yaml: $e'); - return null; + throw VersionParserException( + msg: 'Error reading pubspec.yaml', + innerException: e, + ); } on YamlException catch (e) { - print('Error parsing pubspec.yaml: $e'); - return null; + throw VersionParserException( + msg: 'Error parsing pubspec.yaml', + innerException: e, + ); } catch (e) { - print('Unexpected error: $e'); - return null; + throw VersionParserException( + msg: 'Unexpected error: $e', + ); } } @@ -227,3 +235,18 @@ class VersionParser { ); } } + +class VersionParserException implements Exception { + VersionParserException({ + this.msg, + this.innerException, + }); + + String? msg; + Exception? innerException; + + @override + String toString() { + return 'Error parsing SDK versions: $msg ${innerException != null ? '\n$innerException' : ''}'; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 1bc5549..c49e14c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: puro_sidekick_plugin description: Sidekick plugin that uses the Flutter SDK managed by Puro in the repository and links it to the flutter and dart commands -version: 0.1.0 +version: 1.0.0 repository: https://github.com/phntmxyz/puro_sidekick_plugin issue_tracker: https://github.com/phntmxyz/puro_sidekick_plugin/issues topics: @@ -10,12 +10,12 @@ topics: - puro environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.3.0 <4.0.0' dependencies: - dcli: ^2.2.0 + dcli: ^4.0.4 pub_semver: ^2.1.4 - sidekick_core: ^2.0.0 + sidekick_core: ^3.0.0-preview.1 yaml: ^3.1.1 dev_dependencies: @@ -23,5 +23,5 @@ dev_dependencies: dart_style: ^2.2.0 indent: ^2.0.0 lint: '>=1.5.0 <=3.0.0' - sidekick_plugin_installer: ^1.0.0 + sidekick_plugin_installer: ^1.2.1 test: ^1.21.0 diff --git a/tool/install.dart b/tool/install.dart index e180f27..c0f6cb4 100644 --- a/tool/install.dart +++ b/tool/install.dart @@ -31,7 +31,7 @@ Future main() async { "import 'package:puro_sidekick_plugin/puro_sidekick_plugin.dart';", ); mainSourceFile.registerSdkInitializer( - 'addFlutterSdkInitializer(initializePuro);', + 'addSdkInitializer(initializePuro);', ); mainSourceFile.flush(); @@ -57,8 +57,11 @@ Future main() async { ); } - initializePuro(Directory.current); - puro(['flutter', '--version']); + final initialPackage = + DartPackage.fromDirectory(SidekickContext.projectRoot) ?? + SidekickContext.sidekickPackage; + initializePuro(SdkInitializerContext(packageDir: initialPackage)); + puro(['flutter', '--version'], workingDirectory: initialPackage.root); print(green('Successfully installed sidekick Puro plugin')); print('\nUsage: You can now execute the commands:\n'