Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer installation as a dev-dependency #2511

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Running the example app

1. In the root directory of `webdev`, run
`pub global activate --source path webdev`
1. Uncomment the dwds dependency override in `/webdev/webdev/pubspec.yaml`, then
run `dart run build_runner build` from `/webdev/webdev` directory
- *Note: You will have to comment and build, and then uncomment and build,
each time you need to pick up new changes*
1. From `/webdev/example`, run `webdev serve --debug --verbose` (Note: all
options can be found by running `webdev help serve`)
1. Run `dart run build_runner build` from `webdev/` directory to update build
artifacts.
1. From `example/`, run `dart run webdev serve --debug --verbose` (Note: all
options can be found by running `dart run webdev help serve`)
1. Type opt/alt-d in the browser. This is required to start the VM.
1. \[OPTIONAL\] If you need to connect a locally running DevTools (instructions
for running
Expand Down
6 changes: 6 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ environment:
dev_dependencies:
build_runner: ^2.4.0
build_web_compilers: ^4.0.4
webdev:
path: ../webdev

dependency_overrides:
dwds:
path: ../dwds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this needs a trailing newline

4 changes: 4 additions & 0 deletions webdev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 3.7.0-wip

- Suggest using as a dev-dependency instead of as a globally activated package.
The global flow will still work - but there will be no compatibility
checking of dependencies.

## 3.6.0

- Update `dwds` constraint to `24.1.0`.
Expand Down
26 changes: 4 additions & 22 deletions webdev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,18 @@ A command-line tool for developing and deploying web applications with Dart.

The latest release of `webdev` requires Dart SDK `2.18.0` or later.

To use `webdev` with a package, make sure you have entries in `pubspec.yaml`
similar to:

```yaml
...
dev_dependencies:
build_runner: ^2.4.0
build_web_compilers: ^4.0.4
...
```

## Installation

`webdev` is not meant to be used as a dependency. Instead, it should be
["activated"][activating].
To use `webdev` with a package, add it to the `dev_dependencies` in `pubspec.yaml`:

```console
$ dart pub global activate webdev
$ dart pub add dev:webdev
```

Learn more about activating and using packages [here][pub global].

## Usage

`webdev` provides two commands: `serve` and `build`.

Run them with `dart run webdev serve` and `dart run webdev build`.

### `webdev serve`

```
Expand Down Expand Up @@ -149,8 +135,4 @@ Usage: webdev build [arguments]
-v, --verbose Enables verbose logging.

Run "webdev help" to see global options.

```

[activating]: https://dart.dev/tools/pub/cmd/pub-global#activating-a-package
[pub global]: https://dart.dev/tools/pub/cmd/pub-global
13 changes: 0 additions & 13 deletions webdev/bin/webdev.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ Future main(List<String> args) async {
if (e.path != null) {
print(' ${e.path}');
}
exitCode = ExitCode.config.code;
} on PackageException catch (e) {
final withUnsupportedArg =
e.unsupportedArgument != null ? ' with --${e.unsupportedArgument}' : '';
print(red
.wrap('$_boldApp could not run$withUnsupportedArg for this project.'));
for (final detail in e.details) {
print(yellow.wrap(detail.error));
if (detail.description != null) {
print(detail.description);
}
}

exitCode = ExitCode.config.code;
} on IsolateSpawnException catch (e) {
print(red.wrap('$_boldApp failed with an unexpected exception.'));
Expand Down
11 changes: 1 addition & 10 deletions webdev/lib/src/command/build_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import 'package:logging/logging.dart' as logging;

import '../daemon_client.dart';
import '../logging.dart';
import '../pubspec.dart';
import 'configuration.dart';
import 'shared.dart';

Expand Down Expand Up @@ -51,15 +50,7 @@ class BuildCommand extends Command<int> {
final configuration = Configuration.fromArgs(argResults);
configureLogWriter(configuration.verbose);

List<String> arguments;
try {
await validatePubspecLock(configuration);
arguments = buildRunnerArgs(configuration)..addAll(validExtraArgs);
} on PackageException catch (e) {
logWriter(logging.Level.SEVERE, 'Pubspec errors: ',
error: '${e.details}');
rethrow;
}
final arguments = buildRunnerArgs(configuration)..addAll(validExtraArgs);

try {
logWriter(logging.Level.INFO, 'Connecting to the build daemon...');
Expand Down
8 changes: 0 additions & 8 deletions webdev/lib/src/command/daemon_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import '../daemon/app_domain.dart';
import '../daemon/daemon.dart';
import '../daemon/daemon_domain.dart';
import '../logging.dart';
import '../pubspec.dart';
import '../serve/dev_workflow.dart';
import '../serve/utils.dart';
import 'configuration.dart';
Expand Down Expand Up @@ -65,13 +64,6 @@ class DaemonCommand extends Command<int> {
defaultConfiguration: Configuration(
launchInChrome: true, debug: true, autoRun: false, release: false));
configureLogWriter(configuration.verbose);
// Validate the pubspec first to ensure we are in a Dart project.
try {
await validatePubspecLock(configuration);
} on PackageException catch (e) {
logWriter(Level.SEVERE, 'Pubspec errors: ', error: '${e.details}');
rethrow;
}

Daemon? daemon;
DevWorkflow? workflow;
Expand Down
8 changes: 0 additions & 8 deletions webdev/lib/src/command/serve_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import 'dart:async';

import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:logging/logging.dart';

import '../logging.dart';
import '../pubspec.dart';
import '../serve/dev_workflow.dart';
import 'configuration.dart';
import 'shared.dart';
Expand Down Expand Up @@ -96,12 +94,6 @@ refresh: Performs a full page refresh.
Configuration configuration;
configuration = Configuration.fromArgs(argResults);
configureLogWriter(configuration.verbose);
try {
await validatePubspecLock(configuration);
} on PackageException catch (e) {
logWriter(Level.SEVERE, 'Pubspec errors: ', error: '${e.details}');
rethrow;
}
// Forward remaining arguments as Build Options to the Daemon.
// This isn't documented. Should it be advertised?
final buildOptions = buildRunnerArgs(configuration)
Expand Down
8 changes: 0 additions & 8 deletions webdev/lib/src/command/shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// 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:async';
import 'dart:io';

import 'package:args/args.dart';
import 'package:path/path.dart' as p;

import '../pubspec.dart';
import 'configuration.dart';

final lineLength = stdout.hasTerminal ? stdout.terminalColumns : 80;
Expand Down Expand Up @@ -102,12 +100,6 @@ List<String> buildRunnerArgs(Configuration configuration) {
return arguments;
}

Future<void> validatePubspecLock(Configuration configuration) async {
final pubspecLock = await PubspecLock.read();
await checkPubspecLock(pubspecLock,
requireBuildWebCompilers: configuration.requireBuildWebCompilers);
}

/// Checks that the normalized form of [path] is a top level directory under
/// such as `web` or `test`.
///
Expand Down
Loading
Loading