From fee9c7c2ae3f2d7621d69c0f46ba75faddb8e2b3 Mon Sep 17 00:00:00 2001 From: Christian Eberling Date: Fri, 8 Oct 2021 14:46:07 +0200 Subject: [PATCH] feat: add extension option to support ESM --- README.md | 12 ++++++- barrelsby | 1 + barrelsby.json | 3 +- bin/builder.d.ts | 6 ++-- bin/builder.js | 16 +++++---- bin/builder.js.map | 2 +- bin/builder.test.js | 8 ++--- bin/builder.test.js.map | 2 +- bin/builders/fileSystem.d.ts | 3 +- bin/builders/fileSystem.js | 5 +-- bin/builders/fileSystem.js.map | 2 +- bin/builders/fileSystem.test.js | 33 ++++++++++++++++-- bin/builders/fileSystem.test.js.map | 2 +- bin/builders/flat.d.ts | 2 +- bin/builders/flat.js | 4 +-- bin/builders/flat.js.map | 2 +- bin/builders/flat.test.js | 8 ++--- bin/builders/flat.test.js.map | 2 +- bin/index.js | 4 ++- bin/index.js.map | 2 +- bin/index.test.js | 3 +- bin/index.test.js.map | 2 +- bin/options/extension.d.ts | 2 ++ bin/options/extension.js | 11 ++++++ bin/options/extension.js.map | 1 + bin/options/extension.test.d.ts | 1 + bin/options/extension.test.js | 17 ++++++++++ bin/options/extension.test.js.map | 1 + bin/options/options.d.ts | 1 + bin/options/options.js | 8 +++-- bin/options/options.js.map | 2 +- src/builder.test.ts | 10 +++--- src/builder.ts | 29 +++++++++++----- src/builders/fileSystem.test.ts | 52 +++++++++++++++++++++++++++-- src/builders/fileSystem.ts | 6 ++-- src/builders/flat.test.ts | 12 ++++--- src/builders/flat.ts | 5 +-- src/index.test.ts | 4 ++- src/index.ts | 5 ++- src/options/extension.test.ts | 16 +++++++++ src/options/extension.ts | 10 ++++++ src/options/options.ts | 7 ++++ 42 files changed, 256 insertions(+), 68 deletions(-) create mode 160000 barrelsby create mode 100644 bin/options/extension.d.ts create mode 100644 bin/options/extension.js create mode 100644 bin/options/extension.js.map create mode 100644 bin/options/extension.test.d.ts create mode 100644 bin/options/extension.test.js create mode 100644 bin/options/extension.test.js.map create mode 100644 src/options/extension.test.ts create mode 100644 src/options/extension.ts diff --git a/README.md b/README.md index db0fe4cd..cdb00b4f 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ than recursively searching child directories. ### `-n [name]` or `--name [name]` -Specifies the name to use for creating new barrels (and identifying old ones). `.ts` wil be +Specifies the name to use for creating new barrels (and identifying old ones). `.ts` will be appended if not included in the name. Barrels names will be defaulted to `index.ts`. ### `-s [mode]` or `--structure [mode]` @@ -212,6 +212,16 @@ Display the barrelsby version number. Display additional debug information. +### `-x [extension]`or `--extension [extension]` +Add extension suffix to exports (e.g. '.js'). Useful for ESM modules. + +```TypeScript +// Without --extension .js +export * from "./Slider"; +// With --extension .js +export * from "./Slider.js"; +``` + ## Requirements Requires node v6.0.0 or greater for ES6 syntax. diff --git a/barrelsby b/barrelsby new file mode 160000 index 00000000..f29f0145 --- /dev/null +++ b/barrelsby @@ -0,0 +1 @@ +Subproject commit f29f0145a29f51266e2a6fa8d97f6085569818f4 diff --git a/barrelsby.json b/barrelsby.json index e65aa0a4..6a230324 100644 --- a/barrelsby.json +++ b/barrelsby.json @@ -7,5 +7,6 @@ "structure": "filesystem", "verbose": true, "include": [".ts$"], - "exclude": ["zeta.ts$"] + "exclude": ["zeta.ts$"], + "extension": "" } diff --git a/bin/builder.d.ts b/bin/builder.d.ts index abeae5fb..67b16054 100644 --- a/bin/builder.d.ts +++ b/bin/builder.d.ts @@ -4,9 +4,9 @@ import { SemicolonCharacter } from "./options/noSemicolon"; import { StructureOption } from "./options/options"; import { QuoteCharacter } from "./options/quoteCharacter"; import { Directory, Location } from "./utilities"; -export declare function buildBarrels(destinations: Directory[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, barrelName: string, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean, structure: StructureOption | undefined, local: boolean, include: string[], exclude: string[]): void; -export declare type BarrelBuilder = (directory: Directory, modules: Location[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean) => string; +export declare function buildBarrels(destinations: Directory[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, barrelName: string, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean, structure: StructureOption | undefined, local: boolean, include: string[], exclude: string[], extension: string): void; +export declare type BarrelBuilder = (directory: Directory, modules: Location[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean, extension: string) => string; /** Builds the TypeScript */ -export declare function buildImportPath(directory: Directory, target: Location, baseUrl: BaseUrl): string; +export declare function buildImportPath(directory: Directory, target: Location, baseUrl: BaseUrl, extension: string): string; /** Strips the .ts or .tsx file extension from a path and returns the base filename. */ export declare function getBasename(relativePath: string): string; diff --git a/bin/builder.js b/bin/builder.js index eed5cae0..8a2aa353 100644 --- a/bin/builder.js +++ b/bin/builder.js @@ -11,7 +11,7 @@ const flat_1 = require("./builders/flat"); const header_1 = require("./builders/header"); const modules_1 = require("./modules"); const utilities_1 = require("./utilities"); -function buildBarrels(destinations, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, exportDefault, structure, local, include, exclude) { +function buildBarrels(destinations, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, exportDefault, structure, local, include, exclude, extension) { let builder; switch (structure) { default: @@ -23,13 +23,13 @@ function buildBarrels(destinations, quoteCharacter, semicolonCharacter, barrelNa break; } // Build the barrels. - destinations.forEach((destination) => buildBarrel(destination, builder, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, exportDefault, local, include, exclude)); + destinations.forEach((destination) => buildBarrel(destination, builder, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, exportDefault, local, include, exclude, extension)); } exports.buildBarrels = buildBarrels; // Build a barrel for the specified directory. -function buildBarrel(directory, builder, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, exportDefault, local, include, exclude) { +function buildBarrel(directory, builder, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, exportDefault, local, include, exclude, extension) { logger(`Building barrel @ ${directory.path}`); - const content = builder(directory, (0, modules_1.loadDirectoryModules)(directory, logger, include, exclude, local), quoteCharacter, semicolonCharacter, logger, baseUrl, exportDefault); + const content = builder(directory, (0, modules_1.loadDirectoryModules)(directory, logger, include, exclude, local), quoteCharacter, semicolonCharacter, logger, baseUrl, exportDefault, extension); const destination = path_1.default.join(directory.path, barrelName); if (content.length === 0) { // Skip empty barrels. @@ -51,7 +51,7 @@ function buildBarrel(directory, builder, quoteCharacter, semicolonCharacter, bar } } /** Builds the TypeScript */ -function buildImportPath(directory, target, baseUrl) { +function buildImportPath(directory, target, baseUrl, extension) { // If the base URL option is set then imports should be relative to there. const startLocation = baseUrl ? baseUrl : directory.path; const relativePath = path_1.default.relative(startLocation, target.path); @@ -60,8 +60,10 @@ function buildImportPath(directory, target, baseUrl) { if (directoryPath !== ".") { directoryPath = `.${path_1.default.sep}${directoryPath}`; } - // Strip off the .ts or .tsx from the file name. - const fileName = getBasename(relativePath); + // Strip off the .ts or .tsx from the file name, unless configured otherwise. + const baseName = getBasename(relativePath); + // Add .js extensions for esm compatibility + const fileName = baseName + extension; // Build the final path string. Use posix-style seperators. const location = `${directoryPath}${path_1.default.sep}${fileName}`; const convertedLocation = (0, utilities_1.convertPathSeparator)(location); diff --git a/bin/builder.js.map b/bin/builder.js.map index bb4fd966..6254ccf6 100644 --- a/bin/builder.js.map +++ b/bin/builder.js.map @@ -1 +1 @@ -{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,sDAA8D;AAC9D,0CAAkD;AAClD,8CAAoD;AACpD,uCAAiD;AAMjD,2CAKqB;AAErB,SAAgB,YAAY,CAC1B,YAAyB,EACzB,cAA8B,EAC9B,kBAAsC,EACtC,UAAkB,EAClB,MAAc,EACd,OAAgB,EAChB,aAAsB,EACtB,SAAsC,EACtC,KAAc,EACd,O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,SAAS,kBAAkB,CAAC,QAAgB,EAAE,OAAgB;IAC5D,OAAO,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,yBAAa,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClE,CAAC;AAED,uFAAuF;AACvF,SAAgB,WAAW,CAAC,YAAoB;IAC9C,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,IAAI,SAAS,GAAG,YAAY,CAAC;IAC7B,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,cAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACpD,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE;YACrC,SAAS,GAAG,OAAO,CAAC;SACrB;IACH,CAAC,CAAC,CAAC;IACH,0FAA0F;IAC1F,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,kCAWC"} \ No newline at end of file +{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,sDAA8D;AAC9D,0CAAkD;AAClD,8CAAoD;AACpD,uCAAiD;AAMjD,2CAKqB;AAErB,SAAgB,YAAY,CAC1B,YAAyB,EACzB,cAA8B,EAC9B,kBAAsC,EACtC,UAAkB,EAClB,MAAc,EACd,OAAgB,EAChB,aAAsB,EACtB,SAAsC,EACtC,KAAc,EACd,OAAiB,EACjB,OAAiB,EACjB,SAAiB;IAEjB,IAAI,OAAsB,CAAC;IAC3B,QAAQ,SAAS,EAAE;QACjB,QAAQ;QACR,KAAK,MAAM;YACT,OAAO,GAAG,sBAAe,CAAC;YAC1B,MAAM;QACR,KAAK,YAAY;YACf,OAAO,GAAG,kCAAqB,CAAC;YAChC,MAAM;KACT;IACD,qBAAqB;IACrB,YAAY,CAAC,OAA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,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClE,CAAC;AAED,uFAAuF;AACvF,SAAgB,WAAW,CAAC,YAAoB;IAC9C,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,IAAI,SAAS,GAAG,YAAY,CAAC;IAC7B,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,cAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACpD,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE;YACrC,SAAS,GAAG,OAAO,CAAC;SACrB;IACH,CAAC,CAAC,CAAC;IACH,0FAA0F;IAC1F,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,kCAWC"} \ No newline at end of file diff --git a/bin/builder.test.js b/bin/builder.test.js index 85275bdc..23a7bfae 100644 --- a/bin/builder.test.js +++ b/bin/builder.test.js @@ -43,7 +43,7 @@ describe("builder/builder module has a", () => { let logger; const runBuilder = (structure) => { logger = spySandbox.spy(); - Builder.buildBarrels(directory.directories, '"', ";", "barrel.ts", logger, undefined, false, structure, false, [], []); + Builder.buildBarrels(directory.directories, '"', ";", "barrel.ts", logger, undefined, false, structure, false, [], [], ""); }; beforeEach(() => { (0, mock_fs_1.default)(TestUtilities.mockFsConfiguration()); @@ -120,7 +120,7 @@ describe("builder/builder module has a", () => { let logger; const runBuilder = () => { logger = spySandbox.spy(); - Builder.buildBarrels(directory.directories, '"', ";", "barrel.ts", logger, undefined, false, "flat", false, [], []); + Builder.buildBarrels(directory.directories, '"', ";", "barrel.ts", logger, undefined, false, "flat", false, [], [], ""); }; beforeEach(() => { (0, mock_fs_1.default)(TestUtilities.mockFsConfiguration()); @@ -149,13 +149,13 @@ describe("builder/builder module has a", () => { }); it("should correctly build a path to a file in the same directory", () => { const target = getLocationByName(directory.files, "index.ts"); - const result = Builder.buildImportPath(directory, target, undefined); + const result = Builder.buildImportPath(directory, target, undefined, ""); chai_1.assert.equal(result, "./index"); }); it("should correctly build a path to a file in a child directory", () => { const childDirectory = getLocationByName(directory.directories, "directory2"); const target = getLocationByName(childDirectory.files, "script.ts"); - const result = Builder.buildImportPath(directory, target, undefined); + const result = Builder.buildImportPath(directory, target, undefined, ""); chai_1.assert.equal(result, "./directory2/script"); }); }); diff --git a/bin/builder.test.js.map b/bin/builder.test.js.map index 4a9ce56f..8e5cd8e5 100644 --- a/bin/builder.test.js.map +++ b/bin/builder.test.js.map @@ -1 +1 @@ -{"version":3,"file":"builder.test.js","sourceRoot":"","sources":["../src/builder.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,4CAAoB;AACpB,sDAA6B;AAC7B,kDAA0B;AAE1B,mDAAqC;AACrC,kEAAoD;AACpD,sDAAwC;AACxC,0DAA4C;AAC5C,mDAAqC;AAErC,+DAAiD;AAGjD,uCAAuC;AACvC,SAAS,iBAAiB,CAAC,SAAqB,EAAE,IAAY;IAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,IAAI,SAAoB,CAAC;QACzB,IAAI,UAA8B,CAAC;QACnC,IAAI,MAAsB,CAAC;QAC3B,MAAM,UAAU,GAAG,CAAC,SAAsC,EAAE,EAAE;YAC5D,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC;YAC1B,OAAO,CAAC,YAAY,CAClB,SAAS,CAAC,WAAW,EACrB,GAAG,EACH,GAAG,EACH,WAAW,EACX,MAAM,EACN,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,EACL,EAAE,EACF,EAAE,CACH,CAA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AG,EAAE;YACxD,MAAM,QAAQ,GAAG,yBAAyB,CAAC;YAC3C,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC7C,aAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,MAAM,QAAQ,GAAG,wBAAwB,CAAC;YAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC7C,aAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;YACnE,MAAM,QAAQ,GAAG,uBAAuB,CAAC;YACzC,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC7C,aAAM,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/bin/builders/fileSystem.d.ts b/bin/builders/fileSystem.d.ts index 0dfdb41c..b8540814 100644 --- a/bin/builders/fileSystem.d.ts +++ b/bin/builders/fileSystem.d.ts @@ -4,4 +4,5 @@ import { SemicolonCharacter } from "../options/noSemicolon"; import { QuoteCharacter } from "../options/quoteCharacter"; import { Directory, Location } from "../utilities"; export declare function buildFileSystemBarrel(directory: Directory, modules: Location[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, _: Logger, // Not used -baseUrl: BaseUrl): string; +baseUrl: BaseUrl, __: boolean, // exportDefault only in flat mode +extension: string): string; diff --git a/bin/builders/fileSystem.js b/bin/builders/fileSystem.js index 436f8fd5..fe486a99 100644 --- a/bin/builders/fileSystem.js +++ b/bin/builders/fileSystem.js @@ -45,13 +45,14 @@ function compareImports(a, b) { return a.path < b.path ? -1 : 1; } function buildFileSystemBarrel(directory, modules, quoteCharacter, semicolonCharacter, _, // Not used -baseUrl) { +baseUrl, __, // exportDefault only in flat mode +extension) { const structure = {}; let content = ""; modules .map((module) => ({ module, - path: (0, builder_1.buildImportPath)(directory, module, baseUrl), + path: (0, builder_1.buildImportPath)(directory, module, baseUrl, extension), })) .sort(compareImports) .forEach((imported) => { diff --git a/bin/builders/fileSystem.js.map b/bin/builders/fileSystem.js.map index e047c076..ee14e687 100644 --- a/bin/builders/fileSystem.js.map +++ b/bin/builders/fileSystem.js.map @@ -1 +1 @@ -{"version":3,"file":"fileSystem.js","sourceRoot":"","sources":["../../src/builders/fileSystem.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,wCAA6C;AAK7C,4CAKsB;AAEtB,SAAS,SAAS,CAChB,SAA0B,EAC1B,mBAA2B;IAE3B,MAAM,eAAe,GAAG,mBAAmB,GAAG,uBAAW,CAAC;IAC1D,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/C,OAAO,IAAI;EACb,eAAe,GAAG,GAAG,IAAI,CAAC;QACxB,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,OAAO,IAAI,QAAQ,CAAC;SACrB;aAAM;YACL,OAAO,IAAI,SAAS,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;SACjD;QACD,OAAO,IAAI,GAAG,CAAC;KAChB;IACD,OAAO,IAAI,OAAO;EAClB,mBAAmB,GAAG,CAAC;AACzB,CAAC;AAMD,SAAS,wBAAwB,CAC/B,SAA0B,EAC1B,SAAmB,EACnB,IAAY,EACZ,SAAiB;IAEjB,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,EAAY,CAAC;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IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,OAAO,IAAI,WAAW,QAAQ,OAAO,GAAG,IAAI,kBAAkB;CACnE,CAAC;SACG;aAAM;YACL,OAAO,IAAI,gBAAgB,GAAG,MAAM,SAAS,CAC3C,QAAQ,EACR,EAAE,CACH,GAAG,kBAAkB;CAC3B,CAAC;SACG;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AA5CD,sDA4CC"} \ No newline at end of file diff --git a/bin/builders/fileSystem.test.js b/bin/builders/fileSystem.test.js index 7970eca0..25188045 100644 --- a/bin/builders/fileSystem.test.js +++ b/bin/builders/fileSystem.test.js @@ -28,7 +28,7 @@ describe("builder/fileSystem module has a", () => { const logger = () => void 0; beforeEach(() => { const rootDirectory = TestUtilities.mockDirectoryTree(); - output = FileSystem.buildFileSystemBarrel(rootDirectory, TestUtilities.mockModules(rootDirectory), '"', ";", logger, undefined); + output = FileSystem.buildFileSystemBarrel(rootDirectory, TestUtilities.mockModules(rootDirectory), '"', ";", logger, undefined, false, ""); }); it("should produce the correct output", () => { TestUtilities.assertMultiLine(output, `import * as barrelts from "./barrel"; @@ -59,7 +59,7 @@ export {indexts as index}; const logger = () => void 0; beforeEach(() => { const rootDirectory = TestUtilities.mockDirectoryTree(); - output = FileSystem.buildFileSystemBarrel(rootDirectory, TestUtilities.mockModules(rootDirectory), "'", ";", logger, undefined); + output = FileSystem.buildFileSystemBarrel(rootDirectory, TestUtilities.mockModules(rootDirectory), "'", ";", logger, undefined, false, ""); }); it("should produce the correct output", () => { TestUtilities.assertMultiLine(output, `import * as barrelts from './barrel'; @@ -89,7 +89,7 @@ export {indexts as index}; const logger = () => void 0; beforeEach(() => { const rootDirectory = TestUtilities.mockDirectoryTree(); - output = FileSystem.buildFileSystemBarrel(rootDirectory, TestUtilities.mockModules(rootDirectory), '"', "", logger, undefined); + output = FileSystem.buildFileSystemBarrel(rootDirectory, TestUtilities.mockModules(rootDirectory), '"', "", logger, undefined, false, ""); }); it("should produce the correct output", () => { TestUtilities.assertMultiLine(output, `import * as barrelts from "./barrel" @@ -108,6 +108,33 @@ export const directory3 = { program: directory3programts, } export {indexts as index} +`); + }); + }); + describe("when using extension suffix", () => { + let output; + const logger = () => void 0; + beforeEach(() => { + const rootDirectory = TestUtilities.mockDirectoryTree(); + output = FileSystem.buildFileSystemBarrel(rootDirectory, TestUtilities.mockModules(rootDirectory), '"', "", logger, undefined, false, ".js"); + }); + it("should produce the correct output", () => { + TestUtilities.assertMultiLine(output, `import * as barrelts from "./barrel.js" +import * as directory2directory4deeplyNestedts from "./directory2/directory4/deeplyNested.js" +import * as directory2scriptts from "./directory2/script.js" +import * as directory3programts from "./directory3/program.js" +import * as indexts from "./index.js" +export {barrelts as barrel} +export const directory2 = { + directory4: { + deeplyNested: directory2directory4deeplyNestedts, + }, + script: directory2scriptts, +} +export const directory3 = { + program: directory3programts, +} +export {indexts as index} `); }); }); diff --git a/bin/builders/fileSystem.test.js.map b/bin/builders/fileSystem.test.js.map index 44732d50..ee2caa81 100644 --- a/bin/builders/fileSystem.test.js.map +++ b/bin/builders/fileSystem.test.js.map @@ -1 +1 @@ -{"version":3,"file":"fileSystem.test.js","sourceRoot":"","sources":["../../src/builders/fileSystem.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gEAAkD;AAClD,yDAA2C;AAE3C,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;QACnD,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;YAC/C,IAAI,MAAc,CAAC;YACnB,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;YAC5B,UAAU,CAAC,GAAG,EAAE;gBACd,MAAM,aAAa,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC;gBACxD,MAAM,GAAG,UAAU,CAAC,qBAAqB,CACvC,aAAa,EACb,aAAa,CAAC,WAAW,CAAC,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QAC5B,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,aAAa,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC;YACxD,MAAM,GAAG,UAAU,CAAC,qBAAqB,CACvC,aAAa,EACb,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,EACxC,GAAG,EACH,EAAE,EACF,MAAM,EACN,SAAS,CACV,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,aAAa,CAAC,eAAe,CAC3B,MAAM,EACN;;;;;;;;;;;;;;;;CAgBP,CACM,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"fileSystem.test.js","sourceRoot":"","sources":["../../src/builders/fileSystem.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gEAAkD;AAClD,yDAA2C;AAE3C,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;QACnD,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;YAC/C,IAAI,MAAc,CAAC;YACnB,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;YAC5B,UAAU,CAAC,GAAG,EAAE;gBACd,MAAM,aAAa,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC;gBACxD,MAAM,GAAG,UAAU,CAAC,qBAAqB,CACvC,aAAa,EACb,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,EACxC,GAAG,EACH,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,EACL,EAAE,CACH,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;gBAC3C,aAAa,CAAC,eAAe,CAC3B,MAAM,EACN;;;;;;;;;;;;;;;;CAgBT,CACQ,CAAC;YACJ,CA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F,MAAM,EACN,SAAS,EACT,KAAK,EACL,EAAE,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,aAAa,CAAC,eAAe,CAC3B,MAAM,EACN;;;;;;;;;;;;;;;;CAgBP,CACM,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;QAC3C,IAAI,MAAc,CAAC;QACnB,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAC5B,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,aAAa,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC;YACxD,MAAM,GAAG,UAAU,CAAC,qBAAqB,CACvC,aAAa,EACb,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,EACxC,GAAG,EACH,EAAE,EACF,MAAM,EACN,SAAS,EACT,KAAK,EACL,KAAK,CACN,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,aAAa,CAAC,eAAe,CAC3B,MAAM,EACN;;;;;;;;;;;;;;;;CAgBP,CACM,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/bin/builders/flat.d.ts b/bin/builders/flat.d.ts index 1a34db5d..1334d921 100644 --- a/bin/builders/flat.d.ts +++ b/bin/builders/flat.d.ts @@ -3,4 +3,4 @@ import { Logger } from "../options/logger"; import { SemicolonCharacter } from "../options/noSemicolon"; import { QuoteCharacter } from "../options/quoteCharacter"; import { Directory, Location } from "../utilities"; -export declare function buildFlatBarrel(directory: Directory, modules: Location[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean): string; +export declare function buildFlatBarrel(directory: Directory, modules: Location[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean, extension: string): string; diff --git a/bin/builders/flat.js b/bin/builders/flat.js index f2e66a88..c88ef2ac 100644 --- a/bin/builders/flat.js +++ b/bin/builders/flat.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.buildFlatBarrel = void 0; const builder_1 = require("../builder"); -function buildFlatBarrel(directory, modules, quoteCharacter, semicolonCharacter, logger, baseUrl, exportDefault) { +function buildFlatBarrel(directory, modules, quoteCharacter, semicolonCharacter, logger, baseUrl, exportDefault, extension) { return modules.reduce((previous, current) => { - const importPath = (0, builder_1.buildImportPath)(directory, current, baseUrl); + const importPath = (0, builder_1.buildImportPath)(directory, current, baseUrl, extension); logger(`Including path ${importPath}`); if (exportDefault) { const filename = (0, builder_1.getBasename)(current.path); diff --git a/bin/builders/flat.js.map b/bin/builders/flat.js.map index 78d18afb..b53ae14f 100644 --- a/bin/builders/flat.js.map +++ b/bin/builders/flat.js.map @@ -1 +1 @@ -{"version":3,"file":"flat.js","sourceRoot":"","sources":["../../src/builders/flat.ts"],"names":[],"mappings":";;;AAAA,wCAA0D;AAO1D,SAAgB,eAAe,CAC7B,SAAoB,EACpB,OAAmB,EACnB,cAA8B,EAC9B,kBAAsC,EACtC,MAAc,EACd,OAAgB,EAChB,aAAsB;IAEtB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,QAAgB,EAAE,OAAiB,EAAE,EAAE;QAC5D,MAAM,UAAU,GAAG,IAAA,yBAAe,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,CAAC,kBAAkB,UAAU,EAAE,CAAC,CAAC;QACvC,IAAI,aAAa,EAAE;YACjB,MAAM,QAAQ,GAAG,IAAA,qBAAW,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3C,QAAQ,IAAI,uBAAuB,QAAQ,WAAW,cAAc,GAAG,UAAU,GAAG,cAAc,GAAG,kBAAkB;CAC5H,CAAC;SACG;QACD,OAAO,CAAC,QAAQ,IAAI,iBAAiB,cAAc,GAAG,UAAU,GAAG,cAAc,GAAG,kBAAkB;CACzG,CAAC,CAAC;IACD,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AApBD,0CAoBC"} \ No newline at end of file +{"version":3,"file":"flat.js","sourceRoot":"","sources":["../../src/builders/flat.ts"],"names":[],"mappings":";;;AAAA,wCAA0D;AAO1D,SAAgB,eAAe,CAC7B,SAAoB,EACpB,OAAmB,EACnB,cAA8B,EAC9B,kBAAsC,EACtC,MAAc,EACd,OAAgB,EAChB,aAAsB,EACtB,SAAiB;IAEjB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,QAAgB,EAAE,OAAiB,EAAE,EAAE;QAC5D,MAAM,UAAU,GAAG,IAAA,yBAAe,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3E,MAAM,CAAC,kBAAkB,UAAU,EAAE,CAAC,CAAC;QACvC,IAAI,aAAa,EAAE;YACjB,MAAM,QAAQ,GAAG,IAAA,qBAAW,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3C,QAAQ,IAAI,uBAAuB,QAAQ,WAAW,cAAc,GAAG,UAAU,GAAG,cAAc,GAAG,kBAAkB;CAC5H,CAAC;SACG;QACD,OAAO,CAAC,QAAQ,IAAI,iBAAiB,cAAc,GAAG,UAAU,GAAG,cAAc,GAAG,kBAAkB;CACzG,CAAC,CAAC;IACD,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AArBD,0CAqBC"} \ No newline at end of file diff --git a/bin/builders/flat.test.js b/bin/builders/flat.test.js index 85cbd0b0..ad021d0d 100644 --- a/bin/builders/flat.test.js +++ b/bin/builders/flat.test.js @@ -36,7 +36,7 @@ describe("builder/flat module has a", () => { const directory = TestUtilities.mockDirectoryTree(); spySandbox = sinon_1.default.createSandbox(); logger = spySandbox.spy(); - output = Flat.buildFlatBarrel(directory, TestUtilities.mockModules(directory), '"', ";", logger, undefined, false); + output = Flat.buildFlatBarrel(directory, TestUtilities.mockModules(directory), '"', ";", logger, undefined, false, ""); }); afterEach(() => { spySandbox.restore(); @@ -74,7 +74,7 @@ export * from "./directory3/program"; const directory = TestUtilities.mockDirectoryTree(); spySandbox = sinon_1.default.createSandbox(); logger = spySandbox.spy(); - output = Flat.buildFlatBarrel(directory, TestUtilities.mockModules(directory), "'", ";", logger, undefined, false); + output = Flat.buildFlatBarrel(directory, TestUtilities.mockModules(directory), "'", ";", logger, undefined, false, ""); }); afterEach(() => { spySandbox.restore(); @@ -112,7 +112,7 @@ export * from './directory3/program'; const directory = TestUtilities.mockDirectoryTree(); spySandbox = sinon_1.default.createSandbox(); logger = spySandbox.spy(); - output = Flat.buildFlatBarrel(directory, TestUtilities.mockModules(directory), '"', "", logger, undefined, false); + output = Flat.buildFlatBarrel(directory, TestUtilities.mockModules(directory), '"', "", logger, undefined, false, ""); }); afterEach(() => { spySandbox.restore(); @@ -147,7 +147,7 @@ export * from "./directory3/program" const directory = TestUtilities.mockDirectoryTree(); spySandbox = sinon_1.default.createSandbox(); logger = spySandbox.spy(); - output = Flat.buildFlatBarrel(directory, TestUtilities.mockModules(directory), '"', ";", logger, undefined, true); + output = Flat.buildFlatBarrel(directory, TestUtilities.mockModules(directory), '"', ";", logger, undefined, true, ""); }); afterEach(() => { spySandbox.restore(); diff --git a/bin/builders/flat.test.js.map b/bin/builders/flat.test.js.map index 9f404f64..90269747 100644 --- a/bin/builders/flat.test.js.map +++ b/bin/builders/flat.test.js.map @@ -1 +1 @@ -{"version":3,"file":"flat.test.js","sourceRoot":"","sources":["../../src/builders/flat.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,kDAA0B;AAE1B,gEAAkD;AAClD,6CAA+B;AAE/B,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,QAAQ,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G,EAAE;gBAC9E,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACpC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/bin/index.js b/bin/index.js index dbc5751b..2c1c18fe 100644 --- a/bin/index.js +++ b/bin/index.js @@ -5,6 +5,7 @@ const destinations_1 = require("./destinations"); const fileTree_1 = require("./fileTree"); const barrelName_1 = require("./options/barrelName"); const baseUrl_1 = require("./options/baseUrl"); +const extension_1 = require("./options/extension"); const logger_1 = require("./options/logger"); const noSemicolon_1 = require("./options/noSemicolon"); const quoteCharacter_1 = require("./options/quoteCharacter"); @@ -25,6 +26,7 @@ function main(args) { const baseUrl = (0, baseUrl_1.getCombinedBaseUrl)(rootPath, args.baseUrl); // Build the directory tree. const rootTree = (0, fileTree_1.buildTree)(rootPath, barrelName, logger); + const extension = (0, extension_1.getExtension)(args.extension); // Work out which directories should have barrels. const destinations = (0, destinations_1.getDestinations)(rootTree, args.location, barrelName, logger); // Potentially there are some existing barrels that need removing. @@ -32,7 +34,7 @@ function main(args) { // Create the barrels. const quoteCharacter = (0, quoteCharacter_1.getQuoteCharacter)(args.singleQuotes); const semicolonCharacter = (0, noSemicolon_1.getSemicolonCharacter)(args.noSemicolon); - (0, builder_1.buildBarrels)(destinations, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, !!args.exportDefault, args.structure, !!args.local, [].concat(args.include || []), [].concat(args.exclude || [], ["node_modules"])); + (0, builder_1.buildBarrels)(destinations, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, !!args.exportDefault, args.structure, !!args.local, [].concat(args.include || []), [].concat(args.exclude || [], ["node_modules"]), extension); } module.exports = main; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/bin/index.js.map b/bin/index.js.map index 3b474731..1f80b0b4 100644 --- a/bin/index.js.map +++ b/bin/index.js.map @@ -1 +1 @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+++ b/bin/index.test.js @@ -58,6 +58,7 @@ describe("main module", () => { singleQuotes: true, structure: "flat", verbose: true, + extension: "", }; const builtTree = { mock: "built tree" }; const buildTreeSpy = spySandbox @@ -101,7 +102,7 @@ describe("main module", () => { (0, chai_1.assert)(buildTreeSpy.calledOnceWithExactly(rootPath, barrelName, logger)); (0, chai_1.assert)(getDestinationsSpy.calledOnceWithExactly(builtTree, args.location, barrelName, logger)); (0, chai_1.assert)(purgeSpy.calledOnceWithExactly(builtTree, args.delete, barrelName, logger)); - (0, chai_1.assert)(buildBarrelsSpy.calledOnceWithExactly(destinations, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, args.exportDefault, args.structure, args.local, args.include, [...args.exclude, "node_modules"])); + (0, chai_1.assert)(buildBarrelsSpy.calledOnceWithExactly(destinations, quoteCharacter, semicolonCharacter, barrelName, logger, baseUrl, args.exportDefault, args.structure, args.local, args.include, [...args.exclude, "node_modules"], args.extension)); }); }); //# sourceMappingURL=index.test.js.map \ No newline at end of file diff --git a/bin/index.test.js.map b/bin/index.test.js.map index 508d4f77..917f12fe 100644 --- a/bin/index.test.js.map +++ b/bin/index.test.js.map @@ -1 +1 @@ -{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,kDAA0B;AAE1B,mDAAqC;AACrC,6DAA+C;AAC/C,qDAAuC;AACvC,oDAA2B;AAC3B,iEAAmD;AACnD,2DAA6C;AAC7C,yDAA2C;AAC3C,mEAAqD;AACrD,yEAA2D;AAC3D,6DAA+C;AAC/C,+CAAiC;AAEjC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,UAA8B,CAAC;IACnC,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG,eAAK,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CA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AAC,CAAC;QAC5E,IAAA,aAAM,EAAC,YAAY,CAAC,qBAAqB,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QACzE,IAAA,aAAM,EACJ,kBAAkB,CAAC,qBAAqB,CACtC,SAAS,EACT,IAAI,CAAC,QAAQ,EACb,UAAU,EACV,MAAM,CACP,CACF,CAAC;QACF,IAAA,aAAM,EACJ,QAAQ,CAAC,qBAAqB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAC3E,CAAC;QACF,IAAA,aAAM,EACJ,eAAe,CAAC,qBAAqB,CACnC,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,OAAO,EACZ,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAClC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,kDAA0B;AAE1B,mDAAqC;AACrC,6DAA+C;AAC/C,qDAAuC;AACvC,oDAA2B;AAC3B,iEAAmD;AACnD,2DAA6C;AAC7C,yDAA2C;AAC3C,mEAAqD;AACrD,yEAA2D;AAC3D,6DAA+C;AAC/C,+CAAiC;AAEjC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,UAA8B,CAAC;IACnC,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG,eAAK,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC,CAA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5E,IAAA,aAAM,EAAC,YAAY,CAAC,qBAAqB,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QACzE,IAAA,aAAM,EACJ,kBAAkB,CAAC,qBAAqB,CACtC,SAAS,EACT,IAAI,CAAC,QAAQ,EACb,UAAU,EACV,MAAM,CACP,CACF,CAAC;QACF,IAAA,aAAM,EACJ,QAAQ,CAAC,qBAAqB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAC3E,CAAC;QACF,IAAA,aAAM,EACJ,eAAe,CAAC,qBAAqB,CACnC,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,OAAO,EACZ,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EACjC,IAAI,CAAC,SAAS,CACf,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/bin/options/extension.d.ts b/bin/options/extension.d.ts new file mode 100644 index 00000000..962dce0f --- /dev/null +++ b/bin/options/extension.d.ts @@ -0,0 +1,2 @@ +export declare type Extension = string; +export declare function getExtension(extension?: string): Extension; diff --git a/bin/options/extension.js b/bin/options/extension.js new file mode 100644 index 00000000..30c5f845 --- /dev/null +++ b/bin/options/extension.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getExtension = void 0; +function getExtension(extension) { + if (typeof extension !== "string") { + throw new Error("Unable to append extension. Option --extension [string] requires a string to use as suffix."); + } + return extension; +} +exports.getExtension = getExtension; +//# sourceMappingURL=extension.js.map \ No newline at end of file diff --git a/bin/options/extension.js.map b/bin/options/extension.js.map new file mode 100644 index 00000000..9c56258d --- /dev/null +++ b/bin/options/extension.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/options/extension.ts"],"names":[],"mappings":";;;AAEA,SAAgB,YAAY,CAAC,SAAkB;IAC7C,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QACjC,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;KACH;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAPD,oCAOC"} \ No newline at end of file diff --git a/bin/options/extension.test.d.ts b/bin/options/extension.test.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/bin/options/extension.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/bin/options/extension.test.js b/bin/options/extension.test.js new file mode 100644 index 00000000..9af7a8c4 --- /dev/null +++ b/bin/options/extension.test.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai_1 = require("chai"); +const extension_1 = require("./extension"); +describe("options/extension module has a", () => { + describe("getExtension function that", () => { + it("should resolve the correct extension", () => { + chai_1.assert.strictEqual((0, extension_1.getExtension)(".js"), ".js"); + }); + it("should throw if option is not array is passed", () => { + chai_1.assert.throws(() => (0, extension_1.getExtension)(false)); + chai_1.assert.throws(() => (0, extension_1.getExtension)(1)); + chai_1.assert.throws(() => (0, extension_1.getExtension)([])); + }); + }); +}); +//# sourceMappingURL=extension.test.js.map \ No newline at end of file diff --git a/bin/options/extension.test.js.map b/bin/options/extension.test.js.map new file mode 100644 index 00000000..c6bc4b7f --- /dev/null +++ b/bin/options/extension.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extension.test.js","sourceRoot":"","sources":["../../src/options/extension.test.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,2CAA2C;AAE3C,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,aAAM,CAAC,WAAW,CAAC,IAAA,wBAAY,EAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,aAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,wBAAY,EAAC,KAAY,CAAC,CAAC,CAAC;YAChD,aAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,wBAAY,EAAC,CAAQ,CAAC,CAAC,CAAC;YAC5C,aAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,wBAAY,EAAC,EAAS,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/bin/options/options.d.ts b/bin/options/options.d.ts index 325c33e1..03e6d27c 100644 --- a/bin/options/options.d.ts +++ b/bin/options/options.d.ts @@ -19,6 +19,7 @@ export interface Arguments { structure?: StructureOption; version?: boolean; verbose?: boolean; + extension?: string; } export declare function getOptionsConfig(configParser: any): { [key: string]: Options; diff --git a/bin/options/options.js b/bin/options/options.js index 3dd538f3..9f49682a 100644 --- a/bin/options/options.js +++ b/bin/options/options.js @@ -2,8 +2,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.getOptionsConfig = void 0; function getOptionsConfig(configParser) { - // tslint:disable-next-line:no-console - console.log(configParser); return { b: { type: "string", @@ -88,6 +86,12 @@ function getOptionsConfig(configParser) { description: "Display additional logging information", default: false, }, + x: { + type: "string", + alias: "extension", + description: "add suffix to exports (e.g. '.js')", + default: "", + }, }; } exports.getOptionsConfig = getOptionsConfig; diff --git a/bin/options/options.js.map b/bin/options/options.js.map index 7aa33145..ebfca937 100644 --- a/bin/options/options.js.map +++ b/bin/options/options.js.map @@ -1 +1 @@ -{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options/options.ts"],"names":[],"mappings":";;;AA2BA,SAAgB,gBAAgB,C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AAM;YACb,WAAW,EAAE,+BAA+B;YAC5C,OAAO,EAAE,OAAO;SACjB;QACD,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,8CAA8C;YAC3D,OAAO,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;YAC/B,OAAO,EAAE,MAAM;SAChB;QACD,CAAC,EAAE;YACD,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,cAAc;YACrB,WAAW,EACT,kEAAkE;YACpE,OAAO,EAAE,KAAK;SACf;QACD,CAAC,EAAE;YACD,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,sEAAsE;YACxE,OAAO,EAAE,KAAK;SACf;QACD,CAAC,EAAE;YACD,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,wCAAwC;YACrD,OAAO,EAAE,KAAK;SACf;KACF,CAAC;AACJ,CAAC;AAhGD,4CAgGC"} \ No newline at end of file +{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options/options.ts"],"names":[],"mappings":";;;AA4BA,SAAgB,gBAAgB,CAAC,YAAiB;IAGhD,OAAO;QACL,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,CAAC;YACR,WAAW,EACT,0FAA0F;SAC7F;QACD,CAAC,EAAE;YACD,MAAM,EAAE,IAAI;YACZ,YAAY;YACZ,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,kCAAkC;SAChD;QACD,CAAC,EAAE;YACD,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,8CAA8C;YAC3D,OAAO,EAAE,CAAC,IAAI,CAAC;SAChB;QACD,CAAC,EAAE;YACD,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,+BAA+B;YAC5C,OAAO,EAAE,KAAK;SACf;QACD,C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AAK;SACf;QACD,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,oCAAoC;YACjD,OAAO,EAAE,EAAE;SACZ;KACF,CAAC;AACJ,CAAC;AApGD,4CAoGC"} \ No newline at end of file diff --git a/src/builder.test.ts b/src/builder.test.ts index b46640f3..c1dbae72 100644 --- a/src/builder.test.ts +++ b/src/builder.test.ts @@ -35,7 +35,8 @@ describe("builder/builder module has a", () => { structure, false, [], - [] + [], + "" ); }; beforeEach(() => { @@ -130,7 +131,8 @@ describe("builder/builder module has a", () => { "flat", false, [], - [] + [], + "" ); }; beforeEach(() => { @@ -160,7 +162,7 @@ describe("builder/builder module has a", () => { }); it("should correctly build a path to a file in the same directory", () => { const target = getLocationByName(directory.files, "index.ts"); - const result = Builder.buildImportPath(directory, target, undefined); + const result = Builder.buildImportPath(directory, target, undefined, ""); assert.equal(result, "./index"); }); it("should correctly build a path to a file in a child directory", () => { @@ -169,7 +171,7 @@ describe("builder/builder module has a", () => { "directory2" ) as Directory; const target = getLocationByName(childDirectory.files, "script.ts"); - const result = Builder.buildImportPath(directory, target, undefined); + const result = Builder.buildImportPath(directory, target, undefined, ""); assert.equal(result, "./directory2/script"); }); }); diff --git a/src/builder.ts b/src/builder.ts index c70ae4a5..de65ede3 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -28,7 +28,8 @@ export function buildBarrels( structure: StructureOption | undefined, local: boolean, include: string[], - exclude: string[] + exclude: string[], + extension: string ): void { let builder: BarrelBuilder; switch (structure) { @@ -53,7 +54,8 @@ export function buildBarrels( exportDefault, local, include, - exclude + exclude, + extension ) ); } @@ -70,7 +72,8 @@ function buildBarrel( exportDefault: boolean, local: boolean, include: string[], - exclude: string[] + exclude: string[], + extension: string ) { logger(`Building barrel @ ${directory.path}`); const content = builder( @@ -80,7 +83,8 @@ function buildBarrel( semicolonCharacter, logger, baseUrl, - exportDefault + exportDefault, + extension ); const destination = path.join(directory.path, barrelName); if (content.length === 0) { @@ -110,14 +114,16 @@ export type BarrelBuilder = ( semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, - exportDefault: boolean + exportDefault: boolean, + extension: string ) => string; /** Builds the TypeScript */ export function buildImportPath( directory: Directory, target: Location, - baseUrl: BaseUrl + baseUrl: BaseUrl, + extension: string ): string { // If the base URL option is set then imports should be relative to there. const startLocation = baseUrl ? baseUrl : directory.path; @@ -127,8 +133,13 @@ export function buildImportPath( if (directoryPath !== ".") { directoryPath = `.${path.sep}${directoryPath}`; } - // Strip off the .ts or .tsx from the file name. - const fileName = getBasename(relativePath); + + // Strip off the .ts or .tsx from the file name, unless configured otherwise. + const baseName = getBasename(relativePath); + + // Add .js extensions for esm compatibility + const fileName = baseName + extension; + // Build the final path string. Use posix-style seperators. const location = `${directoryPath}${path.sep}${fileName}`; const convertedLocation = convertPathSeparator(location); @@ -143,7 +154,7 @@ function stripThisDirectory(location: string, baseUrl: BaseUrl) { export function getBasename(relativePath: string) { const mayBeSuffix = [".ts", ".tsx", ".d.ts"]; let mayBePath = relativePath; - mayBeSuffix.map((suffix) => { + mayBeSuffix.forEach((suffix) => { const tmpPath = path.basename(relativePath, suffix); if (tmpPath.length < mayBePath.length) { mayBePath = tmpPath; diff --git a/src/builders/fileSystem.test.ts b/src/builders/fileSystem.test.ts index 41fa9b7e..c7b1b261 100644 --- a/src/builders/fileSystem.test.ts +++ b/src/builders/fileSystem.test.ts @@ -14,7 +14,9 @@ describe("builder/fileSystem module has a", () => { '"', ";", logger, - undefined + undefined, + false, + "" ); }); it("should produce the correct output", () => { @@ -56,7 +58,9 @@ export {indexts as index}; "'", ";", logger, - undefined + undefined, + false, + "" ); }); it("should produce the correct output", () => { @@ -97,7 +101,9 @@ export {indexts as index}; '"', "", logger, - undefined + undefined, + false, + "" ); }); it("should produce the correct output", () => { @@ -119,6 +125,46 @@ export const directory3 = { program: directory3programts, } export {indexts as index} +` + ); + }); + }); + + describe("when using extension suffix", () => { + let output: string; + const logger = () => void 0; + beforeEach(() => { + const rootDirectory = TestUtilities.mockDirectoryTree(); + output = FileSystem.buildFileSystemBarrel( + rootDirectory, + TestUtilities.mockModules(rootDirectory), + '"', + "", + logger, + undefined, + false, + ".js" + ); + }); + it("should produce the correct output", () => { + TestUtilities.assertMultiLine( + output, + `import * as barrelts from "./barrel.js" +import * as directory2directory4deeplyNestedts from "./directory2/directory4/deeplyNested.js" +import * as directory2scriptts from "./directory2/script.js" +import * as directory3programts from "./directory3/program.js" +import * as indexts from "./index.js" +export {barrelts as barrel} +export const directory2 = { + directory4: { + deeplyNested: directory2directory4deeplyNestedts, + }, + script: directory2scriptts, +} +export const directory3 = { + program: directory3programts, +} +export {indexts as index} ` ); }); diff --git a/src/builders/fileSystem.ts b/src/builders/fileSystem.ts index 0d10c99e..8d5cede4 100644 --- a/src/builders/fileSystem.ts +++ b/src/builders/fileSystem.ts @@ -74,7 +74,9 @@ export function buildFileSystemBarrel( quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, _: Logger, // Not used - baseUrl: BaseUrl + baseUrl: BaseUrl, + __: boolean, // exportDefault only in flat mode + extension: string ): string { const structure: ExportStructure = {}; let content = ""; @@ -82,7 +84,7 @@ export function buildFileSystemBarrel( .map( (module: Location): Import => ({ module, - path: buildImportPath(directory, module, baseUrl), + path: buildImportPath(directory, module, baseUrl, extension), }) ) .sort(compareImports) diff --git a/src/builders/flat.test.ts b/src/builders/flat.test.ts index af655194..027e80c6 100644 --- a/src/builders/flat.test.ts +++ b/src/builders/flat.test.ts @@ -21,7 +21,8 @@ describe("builder/flat module has a", () => { ";", logger, undefined, - false + false, + "" ); }); afterEach(() => { @@ -71,7 +72,8 @@ export * from "./directory3/program"; ";", logger, undefined, - false + false, + "" ); }); afterEach(() => { @@ -121,7 +123,8 @@ export * from './directory3/program'; "", logger, undefined, - false + false, + "" ); }); afterEach(() => { @@ -168,7 +171,8 @@ export * from "./directory3/program" ";", logger, undefined, - true + true, + "" ); }); afterEach(() => { diff --git a/src/builders/flat.ts b/src/builders/flat.ts index d2c9b6d2..38d4d87e 100644 --- a/src/builders/flat.ts +++ b/src/builders/flat.ts @@ -12,10 +12,11 @@ export function buildFlatBarrel( semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, - exportDefault: boolean + exportDefault: boolean, + extension: string ): string { return modules.reduce((previous: string, current: Location) => { - const importPath = buildImportPath(directory, current, baseUrl); + const importPath = buildImportPath(directory, current, baseUrl, extension); logger(`Including path ${importPath}`); if (exportDefault) { const filename = getBasename(current.path); diff --git a/src/index.test.ts b/src/index.test.ts index ec8c7e6a..3ed6b9fe 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -36,6 +36,7 @@ describe("main module", () => { singleQuotes: true, structure: "flat", verbose: true, + extension: "", }; const builtTree: any = { mock: "built tree" }; @@ -112,7 +113,8 @@ describe("main module", () => { args.structure, args.local, args.include, - [...args.exclude, "node_modules"] + [...args.exclude, "node_modules"], + args.extension ) ); }); diff --git a/src/index.ts b/src/index.ts index e3ef9eb5..dfdb4fd0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ import { getDestinations } from "./destinations"; import { buildTree } from "./fileTree"; import { getBarrelName } from "./options/barrelName"; import { getCombinedBaseUrl } from "./options/baseUrl"; +import { getExtension } from "./options/extension"; import { getLogger } from "./options/logger"; import { getSemicolonCharacter } from "./options/noSemicolon"; import { Arguments, LocationOption } from "./options/options"; @@ -29,6 +30,7 @@ function main(args: Arguments) { // Build the directory tree. const rootTree = buildTree(rootPath, barrelName, logger); + const extension = getExtension(args.extension); // Work out which directories should have barrels. const destinations: Directory[] = getDestinations( @@ -55,7 +57,8 @@ function main(args: Arguments) { args.structure, !!args.local, ([] as string[]).concat(args.include || []), - ([] as string[]).concat(args.exclude || [], ["node_modules"]) + ([] as string[]).concat(args.exclude || [], ["node_modules"]), + extension ); } diff --git a/src/options/extension.test.ts b/src/options/extension.test.ts new file mode 100644 index 00000000..532a9e6c --- /dev/null +++ b/src/options/extension.test.ts @@ -0,0 +1,16 @@ +import { assert } from "chai"; +import { getExtension } from "./extension"; + +describe("options/extension module has a", () => { + describe("getExtension function that", () => { + it("should resolve the correct extension", () => { + assert.strictEqual(getExtension(".js"), ".js"); + }); + + it("should throw if option is not array is passed", () => { + assert.throws(() => getExtension(false as any)); + assert.throws(() => getExtension(1 as any)); + assert.throws(() => getExtension([] as any)); + }); + }); +}); diff --git a/src/options/extension.ts b/src/options/extension.ts new file mode 100644 index 00000000..2242338f --- /dev/null +++ b/src/options/extension.ts @@ -0,0 +1,10 @@ +export type Extension = string; + +export function getExtension(extension?: string): Extension { + if (typeof extension !== "string") { + throw new Error( + "Unable to append extension. Option --extension [string] requires a string to use as suffix." + ); + } + return extension; +} diff --git a/src/options/options.ts b/src/options/options.ts index 19e22fde..94608427 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -23,6 +23,7 @@ export interface Arguments { structure?: StructureOption; version?: boolean; verbose?: boolean; + extension?: string; } export function getOptionsConfig(configParser: any): { @@ -118,5 +119,11 @@ export function getOptionsConfig(configParser: any): { description: "Display additional logging information", default: false, }, + x: { + type: "string", + alias: "extension", + description: "add suffix to exports (e.g. '.js')", + default: "", + }, }; }