Skip to content

Commit ae81cd5

Browse files
sigurdmcommit-bot@chromium.org
authored andcommitted
Deprecate top level pub.
Also makes the `pub` shell script (and its .bat counterpart) forward to a `dart __deprecated_pub` command that implements the old top-level. This allows us to get rid of pub.dart.snapshot saving ~15 MB in a unzipped sdk. The reason for not forwarding directly to `dart pub` is that the interface is slightly different (for example there is no `dart pub --version`). The only new commit in pub is: `3c2ce330 Expose toplevel as a command` Bug: dart-lang/pub#2736 Change-Id: I6eb08d120c4844b3a12bc29544df6a868cd6fcc8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210582 Commit-Queue: Sigurd Meldgaard <[email protected]> Reviewed-by: Jonas Jensen <[email protected]>
1 parent 77fc025 commit ae81cd5

File tree

12 files changed

+23
-153
lines changed

12 files changed

+23
-153
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ vars = {
140140
"pool_rev": "7abe634002a1ba8a0928eded086062f1307ccfae",
141141
"process_rev": "56ece43b53b64c63ae51ec184b76bd5360c28d0b",
142142
"protobuf_rev": "c1eb6cb51af39ccbaa1a8e19349546586a5c8e31",
143-
"pub_rev": "9f2ddc02f066c68fb638ff65fbb73761ece23267",
143+
"pub_rev": "cd7a43f2109f7e5eb22e73c7f4e15d25fd57598e",
144144
"pub_semver_rev": "f50d80ef10c4b2fa5f4c8878036a4d9342c0cc82",
145145
"resource_rev": "6b79867d0becf5395e5819a75720963b8298e9a7",
146146
"root_certificates_rev": "692f6d6488af68e0121317a9c2c9eb393eb0ee50",

pkg/dartdev/lib/dartdev.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:devtools_server/devtools_server.dart';
1515
import 'package:meta/meta.dart';
1616
import 'package:pedantic/pedantic.dart';
1717
import 'package:pub/pub.dart';
18+
1819
import 'package:usage/usage.dart';
1920

2021
import 'src/analytics.dart';
@@ -36,6 +37,15 @@ import 'src/vm_interop_handler.dart';
3637
/// analytics logic, it has been moved here.
3738
Future<void> runDartdev(List<String> args, SendPort port) async {
3839
VmInteropHandler.initialize(port);
40+
41+
// TODO(sigurdm): Remove when top-level pub is removed.
42+
if (args[0] == '__deprecated_pub') {
43+
// This is the entry-point supporting the top-level `pub` script.
44+
// ignore: deprecated_member_use
45+
VmInteropHandler.exit(await deprecatedpubCommand().run(args.skip(1)));
46+
return;
47+
}
48+
3949
if (args.contains('run')) {
4050
// These flags have a format that can't be handled by package:args, so while
4151
// they are valid flags we'll assume the VM has verified them by this point.

pkg/dartdev/lib/src/commands/create.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,11 @@ class CreateCommand extends DartdevCommand {
102102
);
103103

104104
if (argResults['pub']) {
105-
if (!Sdk.checkArtifactExists(sdk.pubSnapshot)) {
106-
return 255;
107-
}
108105
log.stdout('');
109106
var progress = log.progress('Running pub get');
110107
var process = await startDartProcess(
111108
sdk,
112-
[sdk.pubSnapshot, 'get', '--no-precompile'],
109+
['pub', 'get'],
113110
cwd: dir,
114111
);
115112

pkg/dartdev/lib/src/sdk.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ class Sdk {
7878
'devtools',
7979
);
8080

81-
String get pubSnapshot => path.absolute(
82-
sdkPath,
83-
'bin',
84-
'snapshots',
85-
'pub.dart.snapshot',
86-
);
87-
8881
static bool checkArtifactExists(String path) {
8982
if (!File(path).existsSync()) {
9083
log.stderr('Could not find $path. Have you built the full '

pkg/dartdev/test/analytics_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ Future<void> main() async {
9999
});
100100
test('create', () {
101101
final p = project(logAnalytics: true);
102-
final result = p.runSync(['create', '-tpackage-simple', 'name']);
102+
final result =
103+
p.runSync(['create', '--no-pub', '-tpackage-simple', 'name']);
103104
expect(extractAnalytics(result), [
104105
{
105106
'hitType': 'screenView',
@@ -113,7 +114,7 @@ Future<void> main() async {
113114
'label': null,
114115
'value': null,
115116
'cd1': '0',
116-
'cd3': ' template ',
117+
'cd3': ' pub template ',
117118
}
118119
},
119120
{

pkg/dartdev/test/sdk_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ void _sdk() {
2525
expectFileExists(Sdk().analysisServerSnapshot);
2626
});
2727

28-
test('pub snapshot', () {
29-
expectFileExists(Sdk().pubSnapshot);
30-
});
31-
3228
test('dds snapshot', () {
3329
expectFileExists(Sdk().ddsSnapshot);
3430
});

sdk/BUILD.gn

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ declare_args() {
5656
# ........gen_kernel.dart.snapshot (if not on ia32)
5757
# ........kernel-service.dart.snapshot
5858
# ........kernel_worker.dart.snapshot
59-
# ........pub.dart.snapshot
6059
# ......resources/
6160
# ........dartdoc/
6261
# ...........packages
@@ -140,10 +139,6 @@ _platform_sdk_snapshots = [
140139
"frontend_server",
141140
"../utils/kernel-service:frontend_server",
142141
],
143-
[
144-
"pub",
145-
"../utils/pub",
146-
],
147142
]
148143
if (create_kernel_service_snapshot) {
149144
_platform_sdk_snapshots += [ [

sdk/bin/pub

Lines changed: 0 additions & 84 deletions
This file was deleted.

sdk/bin/pub_sdk

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ PROG_NAME="$(follow_links "$BASH_SOURCE")"
2828

2929
# Handle the case where dart-sdk/bin has been symlinked to.
3030
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
31-
31+
DART="$BIN_DIR/dart"
3232

3333
unset VM_OPTIONS
3434
declare -a VM_OPTIONS
@@ -39,12 +39,9 @@ if [[ $DART_VM_OPTIONS ]]; then
3939
VM_OPTIONS+=("${OPTIONS[@]}")
4040
fi
4141

42-
# Run the pub snapshot.
43-
DART="$BIN_DIR/dart"
44-
if array_contains "--no-preview-dart-2" "${VM_OPTIONS[@]}"; then
45-
echo "Pub no longer supports Dart 1"
46-
exit -1
47-
else
48-
SNAPSHOT="$BIN_DIR/snapshots/pub.dart.snapshot"
49-
exec "$DART" "${VM_OPTIONS[@]}" "$SNAPSHOT" "$@"
42+
if [ -t 2 ]; then # Only print warning when run in terminal.
43+
>&2 echo 'The top level `pub` command is deprecated. Use `dart pub` instead.'
5044
fi
45+
46+
# Forward to the `dart __deprecatedpub` command.
47+
exec "$DART" "${VM_OPTIONS[@]}" __deprecated_pub "$@"

sdk/bin/pub_sdk.bat

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ if not "_%DART_VM_OPTIONS%_" == "__" (
2828
)
2929
)
3030

31-
if defined USING_DART_1 (
32-
echo "Pub no longer supports Dart 1"
33-
) else (
34-
"%BIN_DIR%\dart" %VM_OPTIONS% "%BIN_DIR%\snapshots\pub.dart.snapshot" %*
35-
)
31+
echo "The top level `pub.bat` command is deprecated. Use `dart pub` instead." 1>&2
32+
"%BIN_DIR%\dart" %VM_OPTIONS% __deprecated_pub %*
3633

3734
endlocal
3835

utils/pub/.gitignore

Lines changed: 0 additions & 21 deletions
This file was deleted.

utils/pub/BUILD.gn

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)