Repository navigation
Find and run dox commands from packages and the app - #8
Conversation
A command that is not built in now comes from the dox: commands: key in the pubspec.yaml of a package or of the app. The CLI writes .dart_tool/dox/commands.dart and runs it with dart run. dox help lists these commands by package. Built-in commands always win, and two packages with the same name print an error.
Bot reviewVerdict: changes requested (1 blocking). Checked:
No version bump. Changelog is under Unreleased. Blocking
Non-blocking
The design is simple enough: one file, one generated runner, one cache file. Good. |
The hook after each package command changed migration files even for commands that have nothing to do with migrations. Now dox migrate makes bin/migrate.dart when it is missing and goes on. Also: find package_config.json in a pub workspace, read path dependency pubspecs for the cache key, check the commands value with a strict pattern, and print the stack trace when a command throws.
Fixer reply
|
Bot reviewVerdict: changes requested (1 blocking). Checked: Blocking
Non-blocking
|
A commands library that was added after its key stayed missing until dart pub get. Now a run with warnings is not cached, so the next run looks again. Also: walk up to a workspace only for a real member, read every package pubspec for the cache key (absolute path deps too), list each package once in the clash error, and write the files with write-then-rename.
Fixer reply
|
Bot reviewVerdict: changes requested (2 blocking). Checked:
No version bump. Changelog is under Unreleased. Blocking
Non-blocking
|
A commands library that was removed after the cache was made broke every package command until the next dart pub get. Now a cache hit checks that each file is still there, and looks again when one is gone. In a pub workspace, an app saw the commands of members it does not use. Now only the packages reachable from the app in package_graph.json count. dox help <name> also says when a name has a clash.
Fixer reply
|
Bot reviewVerdict: changes requested (1 blocking). Checked at
No version bump. Changelog is under Unreleased. Blocking
Non-blocking
|
Members listed by a glob (like apps/*) were not found, because the workspace list was matched as text. Now dox reads .dart_tool/pub/workspace_ref.json, which dart pub get writes in each member.
Fixer replyBlocking, fixed: a workspace member now finds the root from |
Bot reviewVerdict: ok (0 blocking). Checked the workspace_ref.json fix (commit e352a8d):
|
Problem
Every
doxcommand is hard-coded incommand_registry.dart. A package can not add its own command.Change
When
dox <name>is not a built-in command:.dart_tool/package_config.json, and thedox: commands:key in the pubspec.yaml of each package and of the app..dart_tool/dox/commands.dart. It imports each commands library and runs the command by name.dart run(the samerunScriptasqueue:*, so signals and the exit code pass through)..dart_tool/dox/commands.json).name,description,usage,run). So it does not need a dox_core version, and the CLI tests run offline.dox: commands:. The exit code is the same as before (0).dox helplists package commands, one group per package, and marks names that are not used (built-in or clash).dox help <name>works for them. Outside an app, or with no package commands, it does not start Dart. The list is cached until a package or a commands library changes.db/migration/migrations.dartagain and makesbin/migrate.dartwhen it is missing (refreshMigrationFiles, shared withmake:migration). Sodox queue:tablethendox migrateworks.cryptoandyamlare now direct dependencies (they were transitive already).queue:*,schedule:*andbin/queue.dartdo not change.Related PRs
Command, docs): Add Command for package commands, and docs dox#312queue:table): Add dox queue:table dox-queue#13Tests
test/package_commands_test.dart(unit): package and app commands found, missing key, bad library paths (other package, missing file, list value, bad YAML), warnings kept in the cache, cache only changes with package_config.json or pubspec.yaml, outside an app.test/package_commands_e2e_test.dart: a temp app with local path packages. Runsdox <cmd>from this source: args, app command, exit code 3 passes through, clash (exit 1), built-in wins, unknown command hint,dox helpgroups,dox helpoutside an app.dox queue:tablewrote the migration andbin/migrate.dart, a second run exited 1, anddox migratemade the tables on SQLite.