export_files_generator 1.0.9

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 6

Recursively scans target folder for Dart projects (identifiable by pubsec.yaml file) and creates export files.

main

main(List<String> arguments) {
  ...
  File root = LocalFileSystem.ApplicationHome();
  if (arguments.length > 0) {
    String targetFolderPath = arguments[0]; //argument containing target folder path
    root = LocalFileSystem.newLocalFile(targetFolderPath);
  }

  if (!root.exists()) {
    Err.reportError("Folder not found: $root");
    Sys.exit();
  }

  ExportFilesGenerator.generate(root);
}

the code

static void generate(File root) {
    FileFilter pubsecFilter = (file) => file.getName() == PUBSEC;

    FilesList pubsecFiles = root.listAllChildren(fileFilter: pubsecFilter);

    for (File pubsec in pubsecFiles.toList()) {
      processProject(pubsec);
    }
  }

  static void processProject(File pubsec) {
    File project_root = pubsec.parent();
    String pubsecData = pubsec.readString();
    final String name = pubsecData.split(N)[0].replaceAll("name: ", "").replaceAll(N, "").replaceAll(R, "");
    L.d("project", project_root);
    L.d("   name", name);

    final File lib = project_root.child("lib");
    final File exportFile = lib.child(name + ".dart");

    FileFilter dartFilter = (file) => file.extensionIs("dart");

    final FilesList dartFiles = lib.listAllChildren(fileFilter: dartFilter);
    final List<String> exportFileContent = [];
    final RelativePath prefix = project_root.getAbsoluteFilePath().getRelativePath();
    for (final File dart in dartFiles.toList()) {
      final RelativePath dart_prefix = dart.getAbsoluteFilePath().getRelativePath();
      List<String> postfix = dart_prefix.steps();
      postfix = postfix.sublist(prefix.size() + 1, postfix.length); //lib
      final RelativePath split = Utils.newRelativePath(path_steps: postfix);
      final String fileName = split.getLastStep();
      if (fileName == ("main.dart")) {
        continue;
      }
      if (fileName == (exportFile.getName())) {
        continue;
      }
      exportFileContent.add("export 'package:" + name + RelativePath.SEPARATOR + split.toString() + "';");
      exportFileContent.add(N);

    }
    L.d("writing", exportFile);
    String data = exportFileContent.join("");

    exportFile.writeString(data);
    L.d("");
  }

Changelog

0.0.1

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

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


dependencies:
  export_files_generator: ^1.0.9

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.

3. Import it

Now in your Dart code, you can use:


import 'package:export_files_generator/export_files_generator.dart';
  
Version Uploaded Documentation Archive
1.0.9 Sep 29, 2017 Go to the documentation of export_files_generator 1.0.9 Download export_files_generator 1.0.9 archive
1.0.8 Sep 10, 2017 Go to the documentation of export_files_generator 1.0.8 Download export_files_generator 1.0.8 archive
1.0.7 Sep 10, 2017 Go to the documentation of export_files_generator 1.0.7 Download export_files_generator 1.0.7 archive
1.0.6 Sep 9, 2017 Go to the documentation of export_files_generator 1.0.6 Download export_files_generator 1.0.6 archive
1.0.5 Sep 9, 2017 Go to the documentation of export_files_generator 1.0.5 Download export_files_generator 1.0.5 archive
1.0.4 Sep 9, 2017 Go to the documentation of export_files_generator 1.0.4 Download export_files_generator 1.0.4 archive
1.0.3 Sep 9, 2017 Go to the documentation of export_files_generator 1.0.3 Download export_files_generator 1.0.3 archive
1.0.2 Sep 9, 2017 Go to the documentation of export_files_generator 1.0.2 Download export_files_generator 1.0.2 archive
1.0.1 Sep 9, 2017 Go to the documentation of export_files_generator 1.0.1 Download export_files_generator 1.0.1 archive
1.0.0 Sep 9, 2017 Go to the documentation of export_files_generator 1.0.0 Download export_files_generator 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
12
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
6
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.

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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0