-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
282 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import '../command.dart'; | ||
import 'workspace_list.dart'; | ||
|
||
class WorkspaceCommand extends PubCommand { | ||
@override | ||
String get description => 'Work with the pub workspace.'; | ||
|
||
@override | ||
String get name => 'workspace'; | ||
|
||
WorkspaceCommand() { | ||
addSubcommand(WorkspaceListCommand()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:convert'; | ||
|
||
import 'package:path/path.dart' as p; | ||
|
||
import '../command.dart'; | ||
import '../log.dart'; | ||
import '../utils.dart'; | ||
|
||
class WorkspaceListCommand extends PubCommand { | ||
@override | ||
String get description => | ||
'List all packages in the workspace, and their directory'; | ||
|
||
@override | ||
String get name => 'list'; | ||
|
||
WorkspaceListCommand() { | ||
argParser.addFlag( | ||
'json', | ||
negatable: false, | ||
help: 'output information in a json format', | ||
); | ||
} | ||
|
||
@override | ||
void runProtected() { | ||
if (argResults.flag('json')) { | ||
message( | ||
const JsonEncoder.withIndent(' ').convert({ | ||
'packages': [ | ||
...entrypoint.workspaceRoot.transitiveWorkspace.map( | ||
(package) => { | ||
'name': package.name, | ||
'path': p.canonicalize(package.dir), | ||
}, | ||
), | ||
], | ||
}), | ||
); | ||
} else { | ||
for (final line in renderTable( | ||
[ | ||
[format('Package', bold), format('Path', bold)], | ||
for (final package in entrypoint.workspaceRoot.transitiveWorkspace) | ||
[ | ||
format(package.name, (x) => x), | ||
format( | ||
'${p.relative(p.absolute(package.dir))}${p.separator}', | ||
(x) => x, | ||
), | ||
], | ||
], | ||
canUseAnsiCodes, | ||
)) { | ||
message(line); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.