JezK
Edit File: resolution-map.js.map
{"version":3,"file":"resolution-map.js","names":["DIRECTORY_SEPARATOR","GLOBAL_NESTED_DEP_PATTERN","ResolutionMap","config","resolutionsByPackage","map","reporter","delayQueue","Set","resolutions","globPattern","info","parsePatternInfo","resolution","name","req","add","range","isValidPackagePath","warn","lang","directories","parsePackagePath","pop","semver","validRange","getExoticResolver","pattern","reqPattern","parentNames","normalizePattern","reqRange","modulePath","join","find","minimatch","valid","satisfies","shouldUpdateLockfile","lockfileEntry","resolutionEntry","resolved","remote"],"sourceRoot":"../src","sources":["resolution-map.js"],"sourcesContent":["/* @flow */\nimport semver from 'semver';\nimport minimatch from 'minimatch';\nimport map from './util/map';\nimport type Config from './config';\nimport type {Reporter} from './reporters';\nimport type {DependencyRequestPattern} from './types';\nimport {normalizePattern} from './util/normalize-pattern.js';\nimport parsePackagePath, {isValidPackagePath} from './util/parse-package-path';\nimport {getExoticResolver} from './resolvers';\nimport type {LockManifest} from './lockfile';\nimport type PackageReference from './package-reference';\n\nconst DIRECTORY_SEPARATOR = '/';\nconst GLOBAL_NESTED_DEP_PATTERN = '**/';\n\nexport type Resolution = {\n name: string,\n range: string,\n pattern: string,\n globPattern: string,\n};\n\nexport type ResolutionInternalMap = {\n [packageName: string]: Array<Resolution>,\n};\n\nexport type ResolutionEntry = {\n [packageName: string]: string,\n};\n\nexport default class ResolutionMap {\n constructor(config: Config) {\n this.resolutionsByPackage = map();\n this.config = config;\n this.reporter = config.reporter;\n this.delayQueue = new Set();\n }\n\n resolutionsByPackage: ResolutionInternalMap;\n config: Config;\n reporter: Reporter;\n delayQueue: Set<DependencyRequestPattern>;\n\n init(resolutions: ?ResolutionEntry = {}) {\n for (const globPattern in resolutions) {\n const info = this.parsePatternInfo(globPattern, resolutions[globPattern]);\n\n if (info) {\n const resolution = this.resolutionsByPackage[info.name] || [];\n this.resolutionsByPackage[info.name] = [...resolution, info];\n }\n }\n }\n\n addToDelayQueue(req: DependencyRequestPattern) {\n this.delayQueue.add(req);\n }\n\n parsePatternInfo(globPattern: string, range: string): ?Object {\n if (!isValidPackagePath(globPattern)) {\n this.reporter.warn(this.reporter.lang('invalidResolutionName', globPattern));\n return null;\n }\n\n const directories = parsePackagePath(globPattern);\n const name = directories.pop();\n\n if (!semver.validRange(range) && !getExoticResolver(range)) {\n this.reporter.warn(this.reporter.lang('invalidResolutionVersion', range));\n return null;\n }\n\n // For legacy support of resolutions, replace `name` with `**/name`\n if (name === globPattern) {\n globPattern = `${GLOBAL_NESTED_DEP_PATTERN}${name}`;\n }\n\n return {\n name,\n range,\n globPattern,\n pattern: `${name}@${range}`,\n };\n }\n\n find(reqPattern: string, parentNames: Array<string>): ?string {\n const {name, range: reqRange} = normalizePattern(reqPattern);\n const resolutions = this.resolutionsByPackage[name];\n\n if (!resolutions) {\n return '';\n }\n\n const modulePath = [...parentNames, name].join(DIRECTORY_SEPARATOR);\n const {pattern, range} = resolutions.find(({globPattern}) => minimatch(modulePath, globPattern)) || {};\n\n if (pattern) {\n if (semver.validRange(reqRange) && semver.valid(range) && !semver.satisfies(range, reqRange)) {\n this.reporter.warn(this.reporter.lang('incompatibleResolutionVersion', pattern, reqPattern));\n }\n }\n\n return pattern;\n }\n}\n\nexport const shouldUpdateLockfile = (lockfileEntry: ?LockManifest, resolutionEntry: ?PackageReference) => {\n if (!lockfileEntry || !resolutionEntry) {\n return false;\n }\n\n return lockfileEntry.resolved !== resolutionEntry.remote.resolved;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA8C;AAAA;AAI9C,IAAMA,mBAAmB,GA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