Files
sdk/pkg/dartdev/lib
Daco Harkes 991c48f689 [dartdev] dart run remote
Enables "run-from-remote" with `dart run`.

```
Run a Dart program from a file, a local package, or a remote package.

Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-executable> [args]]

<dart-file>
  A path to a Dart script (e.g., `bin/main.dart`).

<local-package>
  An executable from a local package dependency, in the format <package>[:<executable>].
  For example, `test:test` runs the `test` executable from the `test` package.
  If the executable is not specified, the package name is used.

<remote-executable>
  An executable from a remote package. This can be from a hosted package server
  (like pub.dev) or a git repository.

  When running a remote executable, all other command-line flags are disabled,
  except for the options for remote executables. `dart run <remote-executable>`
  uses `dart install` under the hood and compiles the app into a standalone
  executable, preventing passing VM options.

  From a hosted package server:
    <hosted-url>/<package>[@<version>][:<executable>]

    Downloads the package from a hosted package server and runs the specified
    executable.
    If a version is provided, the specified version is downloaded.
    If an executable is not specified, the package name is used.
    For example, `https://pub.dev/dcli@1.0.0:dcli_complete` runs the
    `dcli_complete` executable from version 1.0.0 of the `dcli` package.

  From a git repository:
    <git-url>[:<executable>]

    Clones the git repository and runs the specified executable from it.
    If an executable is not specified, the package name from the cloned
    repository's pubspec.yaml is used.
    The git url can be any valid git url.
```

Notable implementation decisions:

* Does not redownload if the pubspec.lock is identical from the last
  remote run. Always does a pub resolve to see if the pubspec.lock
  would be identical.
* pub urls must start with `https://`. This makes parsing with local
  file paths more tractible.
* git urls may use either urls, or git ssh. (Git SSH is not tested due
  to not wanting to run an ssh server locally.)
* Shares as much implementation with `dart install` as possible. The
  `dart install` implementation was made public where necessary. The
  `dart install` implementation was kept in place to keep the git diff
  small.
* Test lives in pkg/dartdev/test/native_assets/ so that its not run
  on a shard and xcode and git commands are available.

TEST=pkg/dartdev/test/native_assets/run_remote_test.dart
Closes: https://github.com/dart-lang/sdk/issues/61588
Change-Id: I6a641c670a61da309027d3f82c90f4b59e70933b
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457640
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2025-11-21 03:38:57 -08:00
..
2025-11-21 03:38:57 -08:00
2025-09-23 01:02:15 -07:00