dartx 0.0.8

  • README.md
  • Installing
  • Versions
  • 0

dartx #

The main purpose of dartx is that it allows easy to execute special standalone command-line scripts at any place. These scripts can to require for their operation other packages (uses import directives). They will be executed without requirements manually to install these dependent packages.

Dartx does not have any dependencies and can be distributed with a command-line scripts.

Dartx supports the command-line scripts that contains pubspec.yaml files inside the source code of these scripts.

Example of command-line script (example/serve.dart):

/*
@pubspec.yaml
name: serve
description: A sample static server
dependencies:
  shelf: any
  shelf_static: any
*/

import "dart:async";
import "dart:io";
import 'package:shelf/shelf_io.dart' as shelf_io;
import "package:shelf_static/shelf_static.dart";

void main() {
  var path = Directory.current.path;
  var handler = createStaticHandler(path, defaultDocument: "index.html");
  var port = 8080;
  var address = InternetAddress.LOOPBACK_IP_V4;
  shelf_io.serve(handler, address, port).then((server) {
    var address = server.address.address;
    var port = server.port;
    var url = "http://$address:$port";
    print("Static web server (shelf)");
    print("Url: $url");
    print("Path: $path");
    print("Press <ENTER> to exit");
    stdin.listen((data) {
      server.close(force: true);
      exit(0);
    });

    Timer.run(() => runBrowser(url));
  });
}

void runBrowser(String url) {
  var fail = false;
  switch (Platform.operatingSystem) {
    case "linux":
      Process.run("x-www-browser", [url]);
      break;
    case "macos":
      Process.run("open", [url]);
      break;
    case "windows":
      Process.run("explorer", [url]);
      break;
    default:
      fail = true;
      break;
  }

  if (!fail) {
    print("Start browsing...");
  }
}

To see it in action perform the following steps:

  1. Go to the dartx/example directory.
  2. Run command $DART_SDK/bin/dart ../bin/dartx.dart serve.dart.

Static web server will be executed even it uses shelf and shelf_static packages but dartx package does not declare in its pubspec.yaml these dependencies.

Principle of operation is very simple:

Before executing script dartx creates temporary directory and tells pub to get dependencies into this temporary directory.

Temporary directory will be deleted after the end of execution of command-line script.

Use this package as a library

1. Depend on it

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


dependencies:
  dartx: ^0.0.8

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

Version Uploaded Documentation Archive
0.0.8 Jan 11, 2017 Go to the documentation of dartx 0.0.8 Download dartx 0.0.8 archive
0.0.7 Jan 6, 2015 Go to the documentation of dartx 0.0.7 Download dartx 0.0.7 archive
0.0.6 Jan 5, 2015 Go to the documentation of dartx 0.0.6 Download dartx 0.0.6 archive
0.0.5 Jul 28, 2014 Go to the documentation of dartx 0.0.5 Download dartx 0.0.5 archive
0.0.3 Jul 4, 2014 Go to the documentation of dartx 0.0.3 Download dartx 0.0.3 archive
0.0.2 Jul 4, 2014 Go to the documentation of dartx 0.0.2 Download dartx 0.0.2 archive
0.0.1 Jul 3, 2014 Go to the documentation of dartx 0.0.1 Download dartx 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.