From 1577149ddcf2fba47846f2b0305308c4b5a9cf88 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 --- .vscode/tasks.json | 50 ++++++++++++++++++-------- .vscode/tasks.json.old | 31 +++++++++++++++++ README.md | 12 ++++++- barrelsby.json | 3 +- bin/builder.d.ts | 8 ++--- bin/builder.js | 43 +++++++++++++++++------ bin/builder.js.map | 2 +- bin/builder.test.js | 16 ++++----- 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 | 6 ++-- bin/builders/flat.js.map | 2 +- bin/builders/flat.test.js | 8 ++--- bin/builders/flat.test.js.map | 2 +- bin/index.js | 2 +- bin/index.js.map | 2 +- bin/index.test.js | 3 +- bin/index.test.js.map | 2 +- bin/options/options.d.ts | 1 + bin/options/options.js | 8 +++-- bin/options/options.js.map | 2 +- bin/utilities.d.ts | 4 +++ bin/utilities.js | 8 ++++- bin/utilities.js.map | 2 +- src/builder.test.ts | 28 ++++++++++----- src/builder.ts | 54 +++++++++++++++++++++++------ src/builders/fileSystem.test.ts | 52 +++++++++++++++++++++++++-- src/builders/fileSystem.ts | 6 ++-- src/builders/flat.test.ts | 6 +++- src/builders/flat.ts | 9 ++--- src/index.test.ts | 4 ++- src/index.ts | 3 +- src/options/options.ts | 7 ++++ src/utilities.ts | 11 ++++++ 39 files changed, 347 insertions(+), 99 deletions(-) create mode 100644 .vscode/tasks.json.old diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 178d5b07..639e9cb2 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,31 +1,51 @@ { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format - "version": "0.1.0", + "version": "2.0.0", "command": "npm", - "isShellCommand": true, - "showOutput": "always", - "suppressTaskName": true, "echoCommand": true, "tasks": [ { - "taskName": "install", - "args": ["install"] + "label": "install", + "type": "shell", + "args": [ + "install" + ], + "problemMatcher": [] }, { - "taskName": "update", - "args": ["update"] + "label": "update", + "type": "shell", + "args": [ + "update" + ], + "problemMatcher": [] }, { - "taskName": "test", - "args": ["run", "test"], - "problemMatcher": "$tsc" + "label": "test", + "type": "shell", + "args": [ + "run", + "test" + ], + "problemMatcher": "$tsc", + "group": { + "_id": "test", + "isDefault": false + } }, { - "taskName": "build", - "args": ["run", "build"], - "isBuildCommand": true, - "problemMatcher": "$tsc" + "label": "build", + "type": "shell", + "args": [ + "run", + "build" + ], + "problemMatcher": "$tsc", + "group": { + "_id": "build", + "isDefault": false + } } ] } \ No newline at end of file diff --git a/.vscode/tasks.json.old b/.vscode/tasks.json.old new file mode 100644 index 00000000..178d5b07 --- /dev/null +++ b/.vscode/tasks.json.old @@ -0,0 +1,31 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "0.1.0", + "command": "npm", + "isShellCommand": true, + "showOutput": "always", + "suppressTaskName": true, + "echoCommand": true, + "tasks": [ + { + "taskName": "install", + "args": ["install"] + }, + { + "taskName": "update", + "args": ["update"] + }, + { + "taskName": "test", + "args": ["run", "test"], + "problemMatcher": "$tsc" + }, + { + "taskName": "build", + "args": ["run", "build"], + "isBuildCommand": true, + "problemMatcher": "$tsc" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index db0fe4cd..f4876220 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 +export * from "./Slider"; +// With --extension +export * from "./Slider.js"; +``` + ## Requirements Requires node v6.0.0 or greater for ES6 syntax. 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..b3b8bba1 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: boolean): void; +export declare type BarrelBuilder = (directory: Directory, modules: Location[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean, extension: boolean) => 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: boolean): string; /** Strips the .ts or .tsx file extension from a path and returns the base filename. */ -export declare function getBasename(relativePath: string): string; +export declare function getBaseNameWithoutExtension(relativePath: string): string; diff --git a/bin/builder.js b/bin/builder.js index eed5cae0..5c69a37f 100644 --- a/bin/builder.js +++ b/bin/builder.js @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getBasename = exports.buildImportPath = exports.buildBarrels = void 0; +exports.getBaseNameWithoutExtension = exports.buildImportPath = exports.buildBarrels = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const fileSystem_1 = require("./builders/fileSystem"); @@ -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,8 @@ function buildBarrel(directory, builder, quoteCharacter, semicolonCharacter, bar } } /** Builds the TypeScript */ -function buildImportPath(directory, target, baseUrl) { +function buildImportPath(directory, target, baseUrl, extension) { + var _a; // 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 +61,16 @@ 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); + let fileName; + if (extension) { + // Replace extension with compiled version if possible, or leave extension. + fileName = + (_a = getBaseNameWithCompiledExtension(relativePath)) !== null && _a !== void 0 ? _a : path_1.default.basename(relativePath); + } + else { + // Strip off the .ts or .tsx from the file name. + fileName = getBaseNameWithoutExtension(relativePath); + } // Build the final path string. Use posix-style seperators. const location = `${directoryPath}${path_1.default.sep}${fileName}`; const convertedLocation = (0, utilities_1.convertPathSeparator)(location); @@ -72,10 +81,10 @@ function stripThisDirectory(location, baseUrl) { return baseUrl ? location.replace(utilities_1.thisDirectory, "") : location; } /** Strips the .ts or .tsx file extension from a path and returns the base filename. */ -function getBasename(relativePath) { +function getBaseNameWithoutExtension(relativePath) { const mayBeSuffix = [".ts", ".tsx", ".d.ts"]; let mayBePath = relativePath; - mayBeSuffix.map((suffix) => { + mayBeSuffix.forEach((suffix) => { const tmpPath = path_1.default.basename(relativePath, suffix); if (tmpPath.length < mayBePath.length) { mayBePath = tmpPath; @@ -84,5 +93,17 @@ function getBasename(relativePath) { // Return whichever path is shorter. If they're the same length then nothing was stripped. return mayBePath; } -exports.getBasename = getBasename; +exports.getBaseNameWithoutExtension = getBaseNameWithoutExtension; +/** Keep extension or replace with with js compatible suffix if possible. */ +function getBaseNameWithCompiledExtension(suffixedPath) { + let fileName; + Object.keys(utilities_1.compiledExtensions).forEach((suffix) => { + if (path_1.default.basename(suffixedPath, suffix) < path_1.default.basename(suffixedPath)) { + // Remove and append the associated compiled file extension + fileName = + path_1.default.basename(suffixedPath, suffix) + utilities_1.compiledExtensions[suffix]; + } + }); + return fileName; +} //# sourceMappingURL=builder.js.map \ No newline at end of file diff --git a/bin/builder.js.map b/bin/builder.js.map index bb4fd966..f243f761 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,OAAiB,EACjB,OAAiB;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,OAAO,CAAC,CAAC,WAAsB,EAAE,EAAE,CAC9C,WAAW,CACT,WAAW,EACX,OAAO,EACP,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,OAAO,EACP,aAAa,EACb,KAAK,EACL,OAAO,EACP,OAAO,CACR,CACF,CAAC;AACJ,CAAC;AAvCD,oCAuCC;AAED,8CAA8C;AAC9C,SAAS,WAAW,CAClB,SAAoB,EACpB,OAAsB,EACtB,cAA8B,EA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AS,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,2CAMqB;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,SAAkB;IAElB,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,OAAO,CAAC,CAAC,WAAsB,EAAE,EAAE,CAC9C,WAAW,CACT,WAAW,EACX,OAAO,EACP,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,OAAO,EACP,aAAa,EACb,KAAK,EACL,OAAO,EACP,OAAO,EACP,SAAS,CACV,CACF,CAAC;AACJ,CAAC;AAzCD,oCAyCC;AAED,8CAA8C;AAC9C,SAAS,WAAW,CAClB,SAAoB,EACpB,OAAsB,EACtB,cAA8B,EAC9B,kBAAsC,EACtC,UAAkB,EAClB,MAAc,EACd,OAAgB,EAChB,aAAsB,EACtB,KAAc,EACd,OAAiB,EACjB,OAAiB,EACjB,SAAkB;IAElB,MAAM,CAAC,qBAAqB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,OAAO,CACrB,SAAS,EACT,IAAA,8BAA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AC;SACrB;IACH,CAAC,CAAC,CAAC;IACH,0FAA0F;IAC1F,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,kEAWC;AAED,4EAA4E;AAC5E,SAAS,gCAAgC,CACvC,YAAoB;IAEpB,IAAI,QAAQ,CAAC;IAEb,MAAM,CAAC,IAAI,CAAC,8BAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACjD,IAAI,cAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,cAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YACrE,2DAA2D;YAC3D,QAAQ;gBACN,cAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,8BAAkB,CAAC,MAAM,CAAC,CAAC;SACpE;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC"} \ No newline at end of file diff --git a/bin/builder.test.js b/bin/builder.test.js index 85275bdc..5b472a8e 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, [], [], 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, [], [], false); }; beforeEach(() => { (0, mock_fs_1.default)(TestUtilities.mockFsConfiguration()); @@ -149,35 +149,35 @@ 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, false); 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, false); chai_1.assert.equal(result, "./directory2/script"); }); }); describe("getBasename function that", () => { it("should correctly strip .ts from the filename", () => { const fileName = "./random/path/file.ts"; - const result = Builder.getBasename(fileName); + const result = Builder.getBaseNameWithoutExtension(fileName); chai_1.assert.equal(result, "file"); }); it("should correctly strip .d.ts from the filename", () => { const fileName = "./random/path/file.d.ts"; - const result = Builder.getBasename(fileName); + const result = Builder.getBaseNameWithoutExtension(fileName); chai_1.assert.equal(result, "file"); }); it("should correctly strip .tsx from the filename", () => { const fileName = "./random/path/file.tsx"; - const result = Builder.getBasename(fileName); + const result = Builder.getBaseNameWithoutExtension(fileName); chai_1.assert.equal(result, "file"); }); it("should not strip extensions from non-typescript filenames", () => { const fileName = "./random/path/file.cs"; - const result = Builder.getBasename(fileName); + const result = Builder.getBaseNameWithoutExtension(fileName); chai_1.assert.equal(result, "file.cs"); }); }); diff --git a/bin/builder.test.js.map b/bin/builder.test.js.map index 4a9ce56f..8b7db0ba 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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C;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..d1f2beeb 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: boolean): 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..9f901f09 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,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MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,2BAAe,EAAE,EAAE,CAAC,CAAC;QACxD,OAAO,IAAI,eAAe,KAAK,SAAS,cAAc,GAAG,QAAQ,CAAC,IAAI,GAAG,cAAc,GAAG,kBAAkB;CACjH,CAAC;QACI,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5D,wBAAwB,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IACL,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/C,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAChC,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..8683ed2f 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, 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, 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, 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, true); + }); + 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..d542a4ed 100644 --- a/bin/builders/fileSystem.test.js.map +++ b/bin/builders/fileSystem.test.js.map @@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C,WAAW,CAAC,aAAa,CAAC,EACxC,GAAG,EACH,GAAG,EACH,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;QACH,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;YAC9E,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACvC,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,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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;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..ed6a3302 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: boolean): string; diff --git a/bin/builders/flat.js b/bin/builders/flat.js index f2e66a88..2c51788d 100644 --- a/bin/builders/flat.js +++ b/bin/builders/flat.js @@ -2,12 +2,12 @@ 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); + const filename = (0, builder_1.getBaseNameWithoutExtension)(current.path); previous += `export { default as ${filename} } from ${quoteCharacter}${importPath}${quoteCharacter}${semicolonCharacter} `; } diff --git a/bin/builders/flat.js.map b/bin/builders/flat.js.map index 78d18afb..709a830d 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,wCAA0E;AAO1E,SAAgB,eAAe,CAC7B,SAAoB,EACpB,OAAmB,EACnB,cAA8B,EAC9B,kBAAsC,EACtC,MAAc,EACd,OAAgB,EAChB,aAAsB,EACtB,SAAkB;IAElB,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,qCAA2B,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3D,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..9de2e483 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, 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, 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, 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, false); }); afterEach(() => { spySandbox.restore(); diff --git a/bin/builders/flat.test.js.map b/bin/builders/flat.test.js.map index 9f404f64..1948c27e 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,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC7C,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;YAC/C,IAAI,MAAc,CAAC;YACnB,IAAI,UAA8B,CAAC;YACnC,IAAI,MAAsB,CAAC;YAC3B,UAAU,CAAC,GAAG,EAAE;gBACd,MAAM,SAAS,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC;gBACpD,UAAU,GAAG,eAAK,CAAC,aAAa,EAAE,CAAC;gBACnC,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC;gBAC1B,MAAM,GAAG,IAAI,CAAC,eAAe,CAC3B,SAAS,EACT,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,EACpC,GAAG,EACH,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,CACN,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,SAAS,CAAC,GAAG,EAAE;gBACb,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,CAA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AAe,CAC3B,SAAS,EACT,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,EACpC,GAAG,EACH,GAAG,EACH,MAAM,EACN,SAAS,EACT,IAAI,CACL,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,SAAS,CAAC,GAAG,EAAE;gBACb,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;gBAC3C,aAAa,CAAC,eAAe,CAC3B,MAAM,EACN;;;;;;;;;;CAUT,CACQ,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,sEAAsE,EAAE,GAAG,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 +{"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,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC7C,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;YAC/C,IAAI,MAAc,CAAC;YACnB,IAAI,UAA8B,CAAC;YACnC,IAAI,MAAsB,CAAC;YAC3B,UAAU,CAAC,GAAG,EAAE;gBACd,MAAM,SAAS,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC;gBACpD,UAAU,GAAG,eAAK,CAAC,aAAa,EAAE,CAAC;gBACnC,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC;gBAC1B,MAAM,GAAG,IAAI,CAAC,eAAe,CAC3B,SAAS,EACT,aAAa,CAAC,WAAW,CAAC,SA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CAAC,GAAG,EAAE;gBACd,MAAM,SAAS,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC;gBACpD,UAAU,GAAG,eAAK,CAAC,aAAa,EAAE,CAAC;gBACnC,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC;gBAC1B,MAAM,GAAG,IAAI,CAAC,eAAe,CAC3B,SAAS,EACT,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,EACpC,GAAG,EACH,GAAG,EACH,MAAM,EACN,SAAS,EACT,IAAI,EACJ,KAAK,CACN,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,SAAS,CAAC,GAAG,EAAE;gBACb,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;gBAC3C,aAAa,CAAC,eAAe,CAC3B,MAAM,EACN;;;;;;;;;;CAUT,CACQ,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,sEAAsE,EAAE,GAAG,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..cb6c9122 100644 --- a/bin/index.js +++ b/bin/index.js @@ -32,7 +32,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"]), !!args.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..c1f45579 100644 --- a/bin/index.js.map +++ b/bin/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA,uCAAyC;AACzC,iDAAiD;AACjD,yCAAuC;AACvC,qDAAqD;AACrD,+CAAuD;AACvD,6CAA6C;AAC7C,uDAA8D;AAE9D,6DAA6D;AAC7D,iDAAqD;AACrD,mCAAgC;AAGhC,oFAAoF;AACpF,gEAAgE;AAChE,SAAS,IAAI,CAAC,IAAe;;IAC3B,oCAAoC;IACpC,yEAAyE;IACzE,MAAM,MAAM,GAAG,IAAA,kBAAS,EAAC,IAAI,CAAC,OAAkB,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,IAAA,0BAAa,EAAC,IAAI,CAAC,IAAc,EAAE,MAAM,CAAC,CAAC;IAC9D,MAAM,GAAG,GACP,MAAA,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;QAC5B,CAAC,CAAC,MAAA,IAAI,CAAC,SAAS,0CAAE,KAAK,EAAE;QACzB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,mCAAI,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,IAAA,0BAAe,EAAC,GAAG,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,IAAA,4BAAkB,EAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAE3D,4BAA4B;IAC5B,MAAM,QAAQ,GAAG,IAAA,oBAAS,EAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAEzD,kDAAkD;IAClD,MAAM,YAAY,GAAgB,IAAA,8BAAe,EAC/C,QAAQ,EACR,IAAI,CAAC,QAA0B,EAC/B,UAAU,EACV,MAAM,CACP,CAAC;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;AACJ,CAAC;AAED,iBAAS,IAAI,CAAC"} \ No newline at end of file diff --git a/bin/index.test.js b/bin/index.test.js index 5bc5d17c..da5096c9 100644 --- a/bin/index.test.js +++ b/bin/index.test.js @@ -58,6 +58,7 @@ describe("main module", () => { singleQuotes: true, structure: "flat", verbose: true, + extension: false, }; 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..95a0cdeb 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,E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CAAC,CAAC;QAC7D,IAAA,aAAM,EAAC,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,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,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/options.d.ts b/bin/options/options.d.ts index 325c33e1..ebf0c249 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?: boolean; } export declare function getOptionsConfig(configParser: any): { [key: string]: Options; diff --git a/bin/options/options.js b/bin/options/options.js index 3dd538f3..b163aa07 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: "boolean", + alias: "extension", + description: "Keep suffix on exports (e.g. '.js' or '.jsx')", + default: false, + }, }; } exports.getOptionsConfig = getOptionsConfig; diff --git a/bin/options/options.js.map b/bin/options/options.js.map index 7aa33145..8e954fa7 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,CAAC,YAAiB;IAGhD,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1B,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,CAAC,EAAE;YACD,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,SAAS;YAChB,WAAW,EACT,sEAAsE;SACzE;QACD,CAAC,EAAE;YACD,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,eAAe;YACtB,WAAW,EACT,wFAAwF;SAC3F;QACD,CAAC,EAAE;YACD,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,SAAS;YAChB,WAAW,EACT,sEAAsE;SACzE;QACD,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,4CAA4C;YACzD,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC;YACrD,OAAO,EAAE,KAAK;SACf;QACD,CAAC,EAAE;YACD,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,iDAAiD;YAC9D,OAAO,EAAE,KAAK;SACf;QACD,CAAC,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;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;Y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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;QACD,CAAC,EAAE;YACD,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,+CAA+C;YAC5D,OAAO,EAAE,KAAK;SACf;KACF,CAAC;AACJ,CAAC;AApGD,4CAoGC"} \ No newline at end of file diff --git a/bin/utilities.d.ts b/bin/utilities.d.ts index 1bd34145..d1038d53 100644 --- a/bin/utilities.d.ts +++ b/bin/utilities.d.ts @@ -20,3 +20,7 @@ export declare const isTypeScriptFile: RegExp; export declare const nonAlphaNumeric: RegExp; export declare const thisDirectory: RegExp; export declare const indentation = " "; +export interface CompiledExtensions { + [key: string]: string; +} +export declare const compiledExtensions: CompiledExtensions; diff --git a/bin/utilities.js b/bin/utilities.js index 7f83f660..6ebe8f18 100644 --- a/bin/utilities.js +++ b/bin/utilities.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.indentation = exports.thisDirectory = exports.nonAlphaNumeric = exports.isTypeScriptFile = exports.convertPathSeparator = void 0; +exports.compiledExtensions = exports.indentation = exports.thisDirectory = exports.nonAlphaNumeric = exports.isTypeScriptFile = exports.convertPathSeparator = void 0; /** Convert path separator from windows to unix */ function convertPathSeparator(path) { return path.replace(/\\+/g, "/"); @@ -10,4 +10,10 @@ exports.isTypeScriptFile = /\.tsx?$/m; exports.nonAlphaNumeric = /\W+/g; exports.thisDirectory = /^\.[\\\/]/g; exports.indentation = " "; +exports.compiledExtensions = { + ".ts": ".js", + ".tsx": ".jsx", + // ".mts": ".mjs", // Not supported yet. Added with Typescript 4.5 + // ".cts": ".cjs", // Not supported yet. Added with Typescript 4.5 +}; //# sourceMappingURL=utilities.js.map \ No newline at end of file diff --git a/bin/utilities.js.map b/bin/utilities.js.map index 09eb6e2d..78da9129 100644 --- a/bin/utilities.js.map +++ b/bin/utilities.js.map @@ -1 +1 @@ -{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":";;;AAkBA,kDAAkD;AAClD,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAFD,oDAEC;AAEY,QAAA,gBAAgB,GAAG,UAAU,CAAC;AAC9B,QAAA,eAAe,GAAG,MAAM,CAAC;AACzB,QAAA,aAAa,GAAG,YAAY,CAAC;AAC7B,QAAA,WAAW,GAAG,IAAI,CAAC"} \ No newline at end of file +{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":";;;AAkBA,kDAAkD;AAClD,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAFD,oDAEC;AAEY,QAAA,gBAAgB,GAAG,UAAU,CAAC;AAC9B,QAAA,eAAe,GAAG,MAAM,CAAC;AACzB,QAAA,aAAa,GAAG,YAAY,CAAC;AAC7B,QAAA,WAAW,GAAG,IAAI,CAAC;AAMnB,QAAA,kBAAkB,GAAuB;IACpD,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,MAAM;IACd,kEAAkE;IAClE,kEAAkE;CAC1D,CAAC"} \ No newline at end of file diff --git a/src/builder.test.ts b/src/builder.test.ts index b46640f3..1d2bda0c 100644 --- a/src/builder.test.ts +++ b/src/builder.test.ts @@ -35,7 +35,8 @@ describe("builder/builder module has a", () => { structure, false, [], - [] + [], + false ); }; beforeEach(() => { @@ -130,7 +131,8 @@ describe("builder/builder module has a", () => { "flat", false, [], - [] + [], + false ); }; beforeEach(() => { @@ -160,7 +162,12 @@ 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, + false + ); assert.equal(result, "./index"); }); it("should correctly build a path to a file in a child directory", () => { @@ -169,29 +176,34 @@ 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, + false + ); assert.equal(result, "./directory2/script"); }); }); describe("getBasename function that", () => { it("should correctly strip .ts from the filename", () => { const fileName = "./random/path/file.ts"; - const result = Builder.getBasename(fileName); + const result = Builder.getBaseNameWithoutExtension(fileName); assert.equal(result, "file"); }); it("should correctly strip .d.ts from the filename", () => { const fileName = "./random/path/file.d.ts"; - const result = Builder.getBasename(fileName); + const result = Builder.getBaseNameWithoutExtension(fileName); assert.equal(result, "file"); }); it("should correctly strip .tsx from the filename", () => { const fileName = "./random/path/file.tsx"; - const result = Builder.getBasename(fileName); + const result = Builder.getBaseNameWithoutExtension(fileName); assert.equal(result, "file"); }); it("should not strip extensions from non-typescript filenames", () => { const fileName = "./random/path/file.cs"; - const result = Builder.getBasename(fileName); + const result = Builder.getBaseNameWithoutExtension(fileName); assert.equal(result, "file.cs"); }); }); diff --git a/src/builder.ts b/src/builder.ts index c70ae4a5..471fa2bc 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -11,6 +11,7 @@ import { SemicolonCharacter } from "./options/noSemicolon"; import { StructureOption } from "./options/options"; import { QuoteCharacter } from "./options/quoteCharacter"; import { + compiledExtensions, convertPathSeparator, Directory, Location, @@ -28,7 +29,8 @@ export function buildBarrels( structure: StructureOption | undefined, local: boolean, include: string[], - exclude: string[] + exclude: string[], + extension: boolean ): void { let builder: BarrelBuilder; switch (structure) { @@ -53,7 +55,8 @@ export function buildBarrels( exportDefault, local, include, - exclude + exclude, + extension ) ); } @@ -70,7 +73,8 @@ function buildBarrel( exportDefault: boolean, local: boolean, include: string[], - exclude: string[] + exclude: string[], + extension: boolean ) { logger(`Building barrel @ ${directory.path}`); const content = builder( @@ -80,7 +84,8 @@ function buildBarrel( semicolonCharacter, logger, baseUrl, - exportDefault + exportDefault, + extension ); const destination = path.join(directory.path, barrelName); if (content.length === 0) { @@ -110,14 +115,16 @@ export type BarrelBuilder = ( semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, - exportDefault: boolean + exportDefault: boolean, + extension: boolean ) => string; /** Builds the TypeScript */ export function buildImportPath( directory: Directory, target: Location, - baseUrl: BaseUrl + baseUrl: BaseUrl, + extension: boolean ): string { // If the base URL option is set then imports should be relative to there. const startLocation = baseUrl ? baseUrl : directory.path; @@ -127,8 +134,19 @@ export function buildImportPath( if (directoryPath !== ".") { directoryPath = `.${path.sep}${directoryPath}`; } - // Strip off the .ts or .tsx from the file name. - const fileName = getBasename(relativePath); + + let fileName; + + if (extension) { + // Replace extension with compiled version if possible, or leave extension. + fileName = + getBaseNameWithCompiledExtension(relativePath) ?? + path.basename(relativePath); + } else { + // Strip off the .ts or .tsx from the file name. + fileName = getBaseNameWithoutExtension(relativePath); + } + // Build the final path string. Use posix-style seperators. const location = `${directoryPath}${path.sep}${fileName}`; const convertedLocation = convertPathSeparator(location); @@ -140,10 +158,10 @@ function stripThisDirectory(location: string, baseUrl: BaseUrl) { } /** Strips the .ts or .tsx file extension from a path and returns the base filename. */ -export function getBasename(relativePath: string) { +export function getBaseNameWithoutExtension(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; @@ -152,3 +170,19 @@ export function getBasename(relativePath: string) { // Return whichever path is shorter. If they're the same length then nothing was stripped. return mayBePath; } + +/** Keep extension or replace with with js compatible suffix if possible. */ +function getBaseNameWithCompiledExtension( + suffixedPath: string +): string | undefined { + let fileName; + + Object.keys(compiledExtensions).forEach((suffix) => { + if (path.basename(suffixedPath, suffix) < path.basename(suffixedPath)) { + // Remove and append the associated compiled file extension + fileName = + path.basename(suffixedPath, suffix) + compiledExtensions[suffix]; + } + }); + return fileName; +} diff --git a/src/builders/fileSystem.test.ts b/src/builders/fileSystem.test.ts index 41fa9b7e..2c56279b 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, + false ); }); it("should produce the correct output", () => { @@ -56,7 +58,9 @@ export {indexts as index}; "'", ";", logger, - undefined + undefined, + false, + false ); }); it("should produce the correct output", () => { @@ -97,7 +101,9 @@ export {indexts as index}; '"', "", logger, - undefined + undefined, + false, + 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, + true + ); + }); + 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..55549580 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: boolean ): 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..53005dd4 100644 --- a/src/builders/flat.test.ts +++ b/src/builders/flat.test.ts @@ -21,6 +21,7 @@ describe("builder/flat module has a", () => { ";", logger, undefined, + false, false ); }); @@ -71,6 +72,7 @@ export * from "./directory3/program"; ";", logger, undefined, + false, false ); }); @@ -121,6 +123,7 @@ export * from './directory3/program'; "", logger, undefined, + false, false ); }); @@ -168,7 +171,8 @@ export * from "./directory3/program" ";", logger, undefined, - true + true, + false ); }); afterEach(() => { diff --git a/src/builders/flat.ts b/src/builders/flat.ts index d2c9b6d2..e8844610 100644 --- a/src/builders/flat.ts +++ b/src/builders/flat.ts @@ -1,4 +1,4 @@ -import { buildImportPath, getBasename } from "../builder"; +import { buildImportPath, getBaseNameWithoutExtension } from "../builder"; import { BaseUrl } from "../options/baseUrl"; import { Logger } from "../options/logger"; import { SemicolonCharacter } from "../options/noSemicolon"; @@ -12,13 +12,14 @@ export function buildFlatBarrel( semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, - exportDefault: boolean + exportDefault: boolean, + extension: boolean ): 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); + const filename = getBaseNameWithoutExtension(current.path); previous += `export { default as ${filename} } from ${quoteCharacter}${importPath}${quoteCharacter}${semicolonCharacter} `; } diff --git a/src/index.test.ts b/src/index.test.ts index ec8c7e6a..c7049052 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: false, }; 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..5214c729 100644 --- a/src/index.ts +++ b/src/index.ts @@ -55,7 +55,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"]), + !!args.extension ); } diff --git a/src/options/options.ts b/src/options/options.ts index 19e22fde..13496e95 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?: boolean; } export function getOptionsConfig(configParser: any): { @@ -118,5 +119,11 @@ export function getOptionsConfig(configParser: any): { description: "Display additional logging information", default: false, }, + x: { + type: "boolean", + alias: "extension", + description: "Keep suffix on exports (e.g. '.js' or '.jsx')", + default: false, + }, }; } diff --git a/src/utilities.ts b/src/utilities.ts index 2998a2b7..979fd5a0 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -25,3 +25,14 @@ export const isTypeScriptFile = /\.tsx?$/m; export const nonAlphaNumeric = /\W+/g; export const thisDirectory = /^\.[\\\/]/g; export const indentation = " "; + +export interface CompiledExtensions { + [key: string]: string; +} + +export const compiledExtensions: CompiledExtensions = { + ".ts": ".js", + ".tsx": ".jsx", + // ".mts": ".mjs", // Not supported yet. Added with Typescript 4.5 + // ".cts": ".cjs", // Not supported yet. Added with Typescript 4.5 +} as const;