export_files_generator 1.0.9

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 50

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

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

with Flutter:


$ flutter packages get

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

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

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

Platforms

Detected platforms: Flutter, other

Primary library: package:export_files_generator/export_files_generator.dart with components: io.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use export_files_generator.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
scarabei ^1.4.6 1.5.1 4.0.0
scarabei_reyer ^1.4.6 1.5.1 4.0.1
Transitive dependencies
charcode 1.1.1
collection 1.14.5
convert 2.0.1
crypto 2.0.2+1
logging 0.11.3+1
path 1.5.1
typed_data 1.1.5
Dev dependencies
test ^0.12.0