build_daemon 1.0.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 92

This package provides support for running builds in a daemon.

1.0.0 #

  • Changed the ServerLog class to have separate level, message, loggerName, error, and stackTrace fields.
  • Accept file change notifications as Stream<List<WatchEvent>> instead of Stream<WatchEvent>. This allows file change notifications to be sent as batches of simultaneous changes, preventing over-triggering of builds.

0.6.1 #

  • Use HttpMultiServer to better support IPv6 and IPv4 workflows.

0.6.0 #

  • Add retry logic to the state file helpers runningVersion and currentOptions.
  • DaemonBuilder is now an abstract class.
  • Significantly increase doc comment coverage.

0.5.1 #

  • Support shutting down the daemon with a notification.

0.5.0 #

  • Add OutputLocation to DefaultBuildTarget.

0.4.2 #

  • Enable configuring the environment for the daemon.

0.4.1 #

  • Support closing a daemon client.
  • Fix a null set bug in the build target manager.

0.4.0 #

  • Replace the client log stream with an optional logHandler. This simplifies the logging logic and prevents the need for the client to print to stdio.

0.3.0 #

  • Forward daemon output while starting up / connecting.

0.2.3 #

  • Shutdown the daemon if no client connects within 30 seconds.

0.2.2 #

  • Resolve client path issues with running on Windows.

0.2.1 #

  • Resolve issues with running on Windows.
    • Close the lock file prior to deleting it.
    • Properly join paths and escape the workspace.

0.2.0 #

  • Support custom build results.
  • Options are no longer dynamic and are provided upon connecting.
  • Report OptionsSkew.
  • Prefix build daemon directory with username.
  • Forward filesystem changes to daemon builder.
  • Support custom build targets.

0.0.1 #

  • Initial Build Daemon support.

example/example.dart

// Copyright (c) 2019, 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:io';
import 'dart:math';

import 'package:build_daemon/client.dart';
import 'package:build_daemon/data/build_target.dart';
import 'package:path/path.dart' as p;

void main(List<String> args) async {
  BuildDaemonClient client;
  var workingDirectory =
      p.normalize(p.join(Directory.current.path + '/../example'));

  try {
    // First we connect to the daemon. This will start one if one is not
    // currently running.
    client = await BuildDaemonClient.connect(
        workingDirectory,
        [
          'pub',
          'run',
          'build_runner',
          'daemon',
          '--delete-conflicting-outputs',
        ],
        logHandler: print);
  } catch (e) {
    if (e is VersionSkew) {
      print('Version skew. Please disconnect all other clients '
          'before trying to start a new one.');
    } else if (e is OptionsSkew) {
      print('Options skew. Please disconnect all other clients '
          'before trying to start a new one.');
    } else {
      print('Unexpected error: $e');
    }

    exit(1);
  }
  if (client == null) throw Exception('Error connecting');
  print('Connected to Dart Build Daemon');

  // Next we register a build target (directory) to build.
  // Note this will not cause a build to occur unless there are relevant file
  // changes.
  if (Random().nextBool()) {
    client.registerBuildTarget(DefaultBuildTarget((b) => b
      ..target = 'web'
      ..outputLocation = OutputLocation((b) => b
        ..output = 'web_output'
        ..useSymlinks = false
        ..hoist = true).toBuilder()
      ..blackListPatterns.replace([RegExp(r'.*_test\.dart$')])));
    print('Registered example web target...');
  } else {
    client.registerBuildTarget(DefaultBuildTarget((b) => b
      ..target = 'test'
      ..outputLocation = OutputLocation((b) => b
        ..output = 'test_output'
        ..useSymlinks = true
        ..hoist = false).toBuilder()));

    print('Registered test target...');
  }

  // Handle events coming from the daemon.
  client.buildResults.listen((status) => print('BUILD STATUS: $status'));

  // Force a build of all registered targets.
  client.startBuild();

  await client.finished;
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  build_daemon: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:build_daemon/client.dart';
import 'package:build_daemon/constants.dart';
import 'package:build_daemon/daemon_builder.dart';
import 'package:build_daemon/data/build_request.dart';
import 'package:build_daemon/data/build_request.g.dart';
import 'package:build_daemon/data/build_status.dart';
import 'package:build_daemon/data/build_status.g.dart';
import 'package:build_daemon/data/build_target.dart';
import 'package:build_daemon/data/build_target.g.dart';
import 'package:build_daemon/data/build_target_request.dart';
import 'package:build_daemon/data/build_target_request.g.dart';
import 'package:build_daemon/data/serializers.dart';
import 'package:build_daemon/data/serializers.g.dart';
import 'package:build_daemon/data/server_log.dart';
import 'package:build_daemon/data/server_log.g.dart';
import 'package:build_daemon/data/shutdown_notification.dart';
import 'package:build_daemon/data/shutdown_notification.g.dart';
  
Version Uploaded Documentation Archive
1.0.0 May 23, 2019 Go to the documentation of build_daemon 1.0.0 Download build_daemon 1.0.0 archive
0.6.1 May 10, 2019 Go to the documentation of build_daemon 0.6.1 Download build_daemon 0.6.1 archive
0.6.0 Apr 24, 2019 Go to the documentation of build_daemon 0.6.0 Download build_daemon 0.6.0 archive
0.5.0 Mar 26, 2019 Go to the documentation of build_daemon 0.5.0 Download build_daemon 0.5.0 archive
0.4.2 Mar 4, 2019 Go to the documentation of build_daemon 0.4.2 Download build_daemon 0.4.2 archive
0.4.1 Feb 26, 2019 Go to the documentation of build_daemon 0.4.1 Download build_daemon 0.4.1 archive
0.4.0 Feb 13, 2019 Go to the documentation of build_daemon 0.4.0 Download build_daemon 0.4.0 archive
0.3.0 Feb 4, 2019 Go to the documentation of build_daemon 0.3.0 Download build_daemon 0.3.0 archive
0.2.3 Feb 1, 2019 Go to the documentation of build_daemon 0.2.3 Download build_daemon 0.2.3 archive
0.2.2 Jan 29, 2019 Go to the documentation of build_daemon 0.2.2 Download build_daemon 0.2.2 archive

All 13 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
92
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
92
Learn more about scoring.

We analyzed this package on Jun 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18

Platforms

Detected platforms: Flutter, other

Platform components identified in package: io.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
built_collection ^4.1.0 4.2.2
built_value ^6.3.0 6.6.0
http_multi_server ^2.0.0 2.1.0
logging ^0.11.0 0.11.3+2
package_resolver ^1.0.6 1.0.10
path ^1.6.2 1.6.2
pedantic ^1.0.0 1.7.0
pool ^1.3.6 1.4.0
shelf ^0.7.4 0.7.5
shelf_web_socket ^0.2.2+4 0.2.3
stream_transform ^0.0.14+1 0.0.19
watcher ^0.9.7 0.9.7+10
web_socket_channel ^1.0.9 1.0.13
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
fixnum 0.10.9
http 0.12.0+2
http_parser 3.1.3
matcher 0.12.5
meta 1.1.7
package_config 1.0.5
quiver 2.0.3
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^1.0.0
built_value_generator ^6.2.0
mockito ^4.0.0
test ^1.3.3
test_descriptor ^1.1.1
uuid ^2.0.0