run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<int> run() async {
_section('dpk');
_report(_Status.ok, 'dpk ${pubspec.version}');
_report(_Status.ok, 'Dart ${Platform.version.split(' ').first}');
_report(_Status.ok, 'Scripts run with ${shellCommand('').executable}');
await _checkGit();
_section('Project');
final Project project;
try {
project = Project.load(
context.targetDirectory,
cacheDirectoryOverride: context.invocation.cacheDirectory,
);
} on Exception catch (e) {
_report(_Status.problem, '$e');
return _finish();
}
final workspace = project.workspace;
_report(_Status.ok, 'Config: ${displayPath(project.configPath)}');
_report(
_Status.ok,
workspace.isWorkspace
? 'Workspace root ${workspace.root.name} with '
'${workspace.packages.length} workspace packages'
: 'Standalone package ${workspace.root.name}',
);
if (workspace.current != workspace.root) {
_report(_Status.ok, 'Current package: ${workspace.current.name}');
}
_report(
_Status.ok,
'${project.scripts.length} scripts, mode: ${project.config.mode.name}',
);
for (final warning in project.warnings) {
_report(_Status.warning, warning.toString());
}
final stale = [
for (final update in planPubspecUpdates(project))
if (update.changed) displayPath(update.path),
];
if (stale.isEmpty) {
_report(_Status.ok, 'Pubspecs match the catalog and sorting rules');
} else {
_report(
_Status.warning,
'dpk get would update ${stale.join(', ')}. Run "dpk get".',
);
}
final lockfile = File(p.join(workspace.root.path, 'pubspec.lock'));
if (!lockfile.existsSync()) {
_report(_Status.warning, 'No pubspec.lock yet. Run "dpk get".');
}
if (project.isProjectMode) {
await _checkProjectMode(project);
}
return _finish();
}