diff --git a/README.md b/README.md index c7b88a3..223b861 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ npm i scope-tags -D } ] ``` +> To use multiple files use a file name with `{x}` specifying current import map chunk. - Option `gitCommitCountLimit` is a maximum number of commits to search for when doing rev walk on git push hook - used just on the user side while running commands `--verify-unpushed-commits` or `--skip`. It this number is reached you'll get a warning and ignoring it may result in some files being ommited from tag verification. diff --git a/package.json b/package.json index 8092d78..8e4fb7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scope-tags", - "version": "0.1.20", + "version": "0.1.21", "description": "Output human readable test scope report for QA", "main": "dist/scope.js", "types": "dist/scope.d.ts", diff --git a/src/Commands/runReportForCommitListCommand.ts b/src/Commands/runReportForCommitListCommand.ts index 0d6b022..faa7f48 100644 --- a/src/Commands/runReportForCommitListCommand.ts +++ b/src/Commands/runReportForCommitListCommand.ts @@ -53,7 +53,9 @@ export async function runReportForCommitListCommand(args: Array, root: s if (!fileExists(project.useExternalImportMap)) { console.log(`'useExternalImportMap' - External map for project ${project.name} not found at ${project.useExternalImportMap}, so there won't be references found for files: ${project.supportedFiles}`); } else { - referenceFinders.push(new ExternalMapReferenceFinder(project.useExternalImportMap, project.supportedFiles)); + const externalMapReferenceFinder = new ExternalMapReferenceFinder(project.useExternalImportMap, project.supportedFiles); + referenceFinders.push(externalMapReferenceFinder); + Logger.setConfigurationProperty("Import map chunks", externalMapReferenceFinder.getImportMapChunkCount().toString()); } } }) diff --git a/src/References/ExternalMapReferenceFinder.ts b/src/References/ExternalMapReferenceFinder.ts index 65b6e64..3e62d7c 100644 --- a/src/References/ExternalMapReferenceFinder.ts +++ b/src/References/ExternalMapReferenceFinder.ts @@ -1,4 +1,5 @@ import { JSONFile } from "../FileSystem/JSONFile"; +import { fileExists } from "../FileSystem/fileSystemUtils"; import { IReferenceFinder, ReferencedFileInfo } from "./IReferenceFinder"; type FileImport = { file: string, imports: Array }; @@ -9,13 +10,36 @@ export class ExternalMapReferenceFinder implements IReferenceFinder { private _importMap: ImportMapFile; private _supportedFileExtensions: Array; + private _chunks: number = 0; + constructor(importMapFilePath: string, supportedFileExtensions: Array) { this._importMap = this._loadImportMap(importMapFilePath); this._supportedFileExtensions = supportedFileExtensions; } private _loadImportMap(path: string): ImportMapFile { - return JSONFile.loadFrom(path); + if (!path.includes("{x}")) { + return JSONFile.loadFrom(path); + } else { + let loadedImportMap: ImportMapFile = []; + + while (true) { + const currentChunkFilePath = path.replace("{x}", this._chunks.toString()); + + if (!fileExists(currentChunkFilePath)) { + return loadedImportMap; + } + + const loadedChunk = JSONFile.loadFrom(path); + loadedImportMap = loadedImportMap.concat(loadedChunk); + + this._chunks++; + } + } + } + + public getImportMapChunkCount(): number { + return this._chunks; } public getSupportedFilesExtension(): string[] { @@ -32,7 +56,7 @@ export class ExternalMapReferenceFinder implements IReferenceFinder { unused: false }); } - }) + }); return referenceList; }