StartCommand class
Spawns flutter run -d <device> detached, scrapes the VM Service URI
from stdout, writes ~/.artisan/state.json for downstream consumers.
Supports --device flag (default chrome). For non-chrome targets the
--web-port flag is omitted (flutter rejects it on desktop/mobile).
URI scrape regex matches both web and desktop/mobile stdout formats:
- Web:
Debug service listening on ws://127.0.0.1:8181/<token>/ws - Desktop/mobile:
A Dart VM Service on <Platform> is available at: http://127.0.0.1:<port>/<token>/Desktop/mobilehttp://...URIs are normalized tows://.../ws.
The optional --cdp-port=N flag enables a CDP-aware Chrome launch:
- Validates the Flutter SDK is at or above 3.30.0 (the version that
activates
--web-experimental-hot-reloadfor-d web-serverper flutter/flutter#170612). - Resolves a Chrome binary path (macOS bundle or Linux PATH).
- Pre-launches Chrome detached with
--remote-debugging-port=N,--remote-allow-origins=*, and a dedicated--user-data-dir. - Probes the debug port to confirm Chrome is reachable.
- Runs
flutter run -d web-server --web-port=<port> --web-experimental-hot-reload(silent remap from--device=chromebecause the chrome target would auto-launch its own conflicting Chrome). - Waits for the web-server log line "is being served at" so the URL is bound before any client attempts to connect.
- Navigates the pre-launched Chrome to the served URL via CDP Page.navigate. DWDS only emits "Debug service listening on ..." AFTER a debugger client connects, so the navigate must happen BEFORE the VM Service scrape; scraping first would deadlock the handshake (see commit 871d0a7).
- Scrapes the VM Service URI from the flutter run log (DWDS prints the "Debug service listening on ..." line once Chrome connected).
- Writes
chromePid,cdpPort, andtmpProfileDirto the state file so StopCommand can reap Chrome on teardown.
D6 Chrome reaper (POSIX, chrome target only) defers to V1.x; V1 ships the basic spawn + URI scrape + state.json write.
- Inheritance
-
- Object
- ArtisanCommand
- StartCommand
Constructors
Properties
- boot → CommandBoot
-
What boot context the dispatcher must establish before calling handle.
See CommandBoot for the V1 taxonomy (none, connected).
no setteroverride
- description → String
-
One-line description (rendered in
artisan listnext to name).no setteroverride - hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Dispatch key. Colons (
:) act as namespace prefixes forartisan listgrouping (e.g.dusk:snapgroups underdusk).no setteroverride - parsedSignature → CommandSignature?
-
Lazy-parsed signature. Cached for the lifetime of the instance.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- signature → String?
-
Optional Laravel-style signature DSL. When set, name derives from
it and configure auto-registers the declared options/flags.
no setterinherited
Methods
-
configure(
ArgParser parser) → void -
Auto-applies signature to the parser when set. Override to register
extra ArgParser features (mandatory options, aliases, custom value
validators). When you override, call
super.configure(parser)first if you also use the signature DSL.override -
handle(
ArtisanContext ctx) → Future< int> -
Execute the command. Returns the process exit code.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- cdpChromeBinaryResolver ↔ CdpChromeBinaryResolver
-
Test seam: Chrome binary resolver.
getter/setter pair
-
Test seam: Chrome Page.navigate (default opens a CDP WebSocket).
getter/setter pair
- cdpChromeProber ↔ CdpChromeProber
-
Test seam: Chrome /json/version probe (default duplicates the
fluttersdk_dusk ChromeFinder algorithm inline to avoid an inverted
cross-package dependency).
getter/setter pair
- cdpFifoMaker ↔ CdpFifoMaker?
-
Test seam: replaces mkfifo (no-op in tests; production stays POSIX-pure).
getter/setter pair
- cdpProcessRunner ↔ CdpProcessRunner
-
Test seam: Process.run replacement (flutter --version probe, mkfifo).
getter/setter pair
- cdpProcessStarter ↔ CdpProcessStarter
-
Test seam: Process.start replacement (Chrome + flutter wrapper).
getter/setter pair
- cdpTmpProfileDirRoot ↔ String?
-
Test seam: tmp profile dir root (default
/tmp).getter/setter pair - cdpVmServiceScraper ↔ CdpVmServiceScraper?
-
Test seam: VM Service URI scraper. When null, the production
_scrapeVmServiceUriFromFileis used.getter/setter pair - cdpWebServerReadyWaiter ↔ CdpWebServerReadyWaiter?
-
Test seam: web-server readiness waiter. When null, the production
_waitForWebServerReadypolls the log file for the "is being served at" marker; tests inject an instant-return fake.getter/setter pair - defaultChromeBinary → String? Function(String? envOverride)
-
Resolves the Chrome binary path: macOS canonical bundle, then Linux
PATH lookup. Returns null on Windows or when neither candidate exists.
envOverrideis reserved for V1.xDUSK_CHROME_BIN; currently ignored.no setter -
Production Chrome Page.navigate: HTTP /json/version + WebSocket connect
no setter
-
defaultChromeProbe
→ Future<
void> Function(int, Duration) -
Production Chrome probe: polls /json/version with retry on
SocketException, throws on HTTP 404 or timeout. Inline duplicate of
fluttersdk_dusk's ChromeFinder.probe algorithm (avoids inverted
cross-package dependency).
no setter
Static Methods
-
compareSemver(
String a, String b) → int -
Compares two semver-ish strings by numeric segments only. Strips dev /
build suffixes (everything after the first
-). Returns negative ifa<b, 0 if equal, positive ifa>b. Pads missing segments with 0 so3.30compares equal to3.30.0. -
normalizeVmServiceUri(
String raw) → String -
resolveChromeBinary(
{required bool isMacOs, required bool isLinux, required bool macAppExists(String), required String? pathLookup(String)}) → String? -
Pure resolver for testability: macOS bundle path, Linux PATH
google-chrome, otherwise null. Injects platform booleans and lookup functions so the real Platform / File / which dependencies stay out of unit tests.