dartx 0.0.8

  • README.md
  • Installing
  • Versions
  • 41

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.

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

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages 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

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

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

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Suggestions

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • The description is too long.

    Search engines will display only the first part of the description. Try to keep it under 180 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use dartx.dart.

Dependencies

Package Constraint Resolved Available
Dev dependencies
path any