Detalhes do pacote

barrel-maintainer

dsherret37MIT1.5.3

Automated real-time maintenance of barrels in ES2015.

code-generation, code-manipulation

readme (leia-me)

Barrel Maintainer

npm version

Automatically maintains barrels in real-time.

Automated real-time barrel maintenance

Video Overview

Installation

npm install -g barrel-maintainer

Usage

barrel-maintainer [options] [path]

Options:

  • --includeRootDir - Create a barrel in the root directory.
  • Quote type (specify one)
    • Defaults to the quote type used in the first found import declaration in your project.
    • --singleQuotes - Use single quotes.
    • --doubleQuotes - Use double quotes.
  • File extension for barrel (specify one)
    • Defaults to whichever file type your project has more of.
    • --ts - Create index.ts files.
    • --js - Create index.js files.
  • New lines (specify one)
    • --crlf - Use carriage return line feed newlines (default on windows)
    • --lf - Use line feed newlines (default elsewhere)

Ignoring Files

Add a /* barrel:ignore */ statement to the file:

/* barrel:ignore */
export function log(message: string) {
    console.log(message);
}

Exporting a Subset of a File's Exports

Given the following setup:

// classes.js
export ClassA {}
export ClassB {}

// index.js
export * from "./classes";

If you want the barrel to export a subset of the exports from classes.js, then edit the barrel to say so:

// index.js
export {ClassA} from "./classes";

These kind of changes won't be overwritten by the code manipulation.

Api

import BarrelMaintainer from "barrel-maintainer";

const maintainer = new BarrelMaintainer("myProject/src/", {
    includeRootDir: false,
    fileExtension: "js", // or "ts" (extension for barrel)
    quoteType: "'", // or "\""
    newLineType: "\r\n" // or "\n"
});

await maintainer.updateDirectory("myProject/src/subdir");
const watcher = maintainer.watchDirectory("myProject/src");

// then later (if necessary)
watcher.stop();

About

This project uses ts-morph to navigate and manipulate source code.

Disclaimer

This library will modify and delete source code. I am not responsible for any of its modifications or deletions!

Always use version control to verify and to be able to easily revert the changes it makes!

changelog (log de mudanças)

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.5.2 (2020-02-16)

1.5.1 (2019-08-03)

1.5.0 (2018-10-12)

Features

  • Update ts-simple-ast version. (5d3e5b3)

1.4.0 (2018-09-30)

Features

1.3.1 (2018-08-25)

Bug Fixes

  • Point barrel link to TypeScript Deep Dive (#4) (819de99)

1.3.0 (2018-08-25)

Features

  • Add TypeScript 3.0 support. (e0a4cb5)

1.2.11 (2018-02-07)

Bug Fixes

  • #3 - Fix flags coming before the path not working. (2247b67)

1.2.10 (2018-01-07)

Bug Fixes

  • Ignore declaration files. (031b351)

1.2.9 (2018-01-06)

Bug Fixes

  • Fix issue with files being overwritten (ts-simple-ast issue) (8a6f644)

1.2.8 (2018-01-02)

Bug Fixes

  • Renaming a directory should update the barrel. (3b92103)

1.2.7 (2018-01-01)

1.2.6 (2018-01-01)

Bug Fixes

  • Ignore permission errors when watching files. (df7fec9)

1.2.5 (2018-01-01)

Bug Fixes

  • Getting namespace insert index should be case insensitive. (cf69a6f)

1.2.4 (2017-12-31)

1.2.3 (2017-12-31)

1.2.2 (2017-12-31)

1.2.1 (2017-12-31)

Bug Fixes

  • Don't add exports for non-namespace exports that exist. (614d03f)

1.2.0 (2017-12-30)

Features

  • Insert export declarations in alphabetical order. (18a6f0b)

1.1.0 (2017-12-30)

Features

  • Add help and version commands. (b4404ed)
  • Selectively modify export declarations. (972905c)