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AAM,EAAE,OAAO,CAAC,YAAR,EAAT;AAAiC,MAAA,WAAjC;AAA8C,MAAA,aAAa,EAAE,aAAa,GAAG,oBAAH,GAAoB;AAA9F,KAAlC,CAAb;AACD,GAvBM,CAAP;AAwBD,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { asArray, log } from \"builder-util\"\nimport { copyDir, copyOrLinkFile, Filter, statOrNull, FileTransformer, USE_HARD_LINKS } from \"builder-util/out/fs\"\nimport { ensureDir } from \"fs-extra\"\nimport { Minimatch } from \"minimatch\"\nimport * as path from \"path\"\nimport { Configuration, FileSet, Packager, PlatformSpecificBuildOptions } from \"./index\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { createFilter, hasMagic } from \"./util/filter\"\n\n// https://github.com/electron-userland/electron-builder/issues/733\nconst minimatchOptions = {dot: true}\n\n// noinspection SpellCheckingInspection\nexport const excludedNames = \".git,.hg,.svn,CVS,RCS,SCCS,\" +\n \"__pycache__,.DS_Store,thumbs.db,.gitignore,.gitkeep,.gitattributes,.npmignore,\" +\n \".idea,.vs,.flowconfig,.jshintrc,.eslintrc,.circleci,\" +\n \".yarn-integrity,.yarn-metadata.json,yarn-error.log,yarn.lock,package-lock.json,npm-debug.log,\" +\n \"appveyor.yml,.travis.yml,circle.yml,.nyc_output\"\n\nexport const excludedExts = \"iml,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,suo,xproj,cc,d.ts\"\n\nfunction ensureNoEndSlash(file: string): string {\n if (path.sep !== \"/\") {\n file = file.replace(/\\//g, path.sep)\n }\n if (path.sep !== \"\\\\\") {\n file = file.replace(/\\\\/g, path.sep)\n }\n\n if (file.endsWith(path.sep)) {\n return file.substring(0, file.length - 1)\n }\n else {\n return file\n }\n}\n\n/** @internal */\nexport class FileMatcher {\n readonly from: string\n readonly to: string\n\n readonly patterns: Array<string>\n\n excludePatterns: Array<Minimatch> | null = null\n\n readonly isSpecifiedAsEmptyArray: boolean\n\n constructor(from: string, to: string, readonly macroExpander: (pattern: string) => string, patterns?: Array<string> | string | null | undefined) {\n this.from = ensureNoEndSlash(macroExpander(from))\n this.to = ensureNoEndSlash(macroExpander(to))\n this.patterns = asArray(patterns).map(it => this.normalizePattern(it))\n this.isSpecifiedAsEmptyArray = Array.isArray(patterns) && patterns.length === 0\n }\n\n normalizePattern(pattern: string) {\n if (pattern.startsWith(\"./\")) {\n pattern = pattern.substring(\"./\".length)\n }\n return path.posix.normalize(this.macroExpander(pattern.replace(/\\\\/g, \"/\")))\n }\n\n addPattern(pattern: string) {\n this.patterns.push(this.normalizePattern(pattern))\n }\n\n prependPattern(pattern: string) {\n this.patterns.unshift(this.normalizePattern(pattern))\n }\n\n isEmpty() {\n return this.patterns.length === 0\n }\n\n containsOnlyIgnore(): boolean {\n return !this.isEmpty() && this.patterns.find(it => !it.startsWith(\"!\")) == null\n }\n\n computeParsedPatterns(result: Array<Minimatch>, fromDir?: string): void {\n const relativeFrom = fromDir == null ? null : path.relative(fromDir, this.from)\n\n if (this.patterns.length === 0 && relativeFrom != null) {\n // file mappings, from here is a file\n result.push(new Minimatch(relativeFrom, minimatchOptions))\n return\n }\n\n for (let pattern of this.patterns) {\n if (relativeFrom != null) {\n pattern = path.join(relativeFrom, pattern)\n }\n\n const parsedPattern = new Minimatch(pattern, minimatchOptions)\n result.push(parsedPattern)\n\n // do not add if contains dot (possibly file if has extension)\n if (!pattern.includes(\".\") && !hasMagic(parsedPattern)) {\n // https://github.com/electron-userland/electron-builder/issues/545\n // add **/*\n result.push(new Minimatch(`${pattern}/**/*`, minimatchOptions))\n }\n }\n }\n\n createFilter(): Filter {\n const parsedPatterns: Array<Minimatch> = []\n this.computeParsedPatterns(parsedPatterns)\n return createFilter(this.from, parsedPatterns, this.excludePatterns)\n }\n\n toString() {\n return `from: ${this.from}, to: ${this.to}, patterns: ${this.patterns.join(\", \")}`\n }\n}\n\n/** @internal */\nexport function getMainFileMatchers(appDir: string, destination: string, macroExpander: (pattern: string) => string, platformSpecificBuildOptions: PlatformSpecificBuildOptions, platformPackager: PlatformPackager<any>, outDir: string, isElectronCompile: boolean): Array<FileMatcher> {\n const packager = platformPackager.info\n const buildResourceDir = path.resolve(packager.projectDir, packager.buildResourcesDir)\n\n let matchers = packager.isPrepackedAppAsar ? null : getFileMatchers(packager.config, \"files\", destination, {\n macroExpander,\n customBuildOptions: platformSpecificBuildOptions,\n globalOutDir: outDir,\n defaultSrc: appDir,\n })\n if (matchers == null) {\n matchers = [new FileMatcher(appDir, destination, macroExpander)]\n }\n\n const matcher = matchers[0]\n // add default patterns, but only if from equals to app dir\n if (matcher.from !== appDir) {\n return matchers\n }\n\n // https://github.com/electron-userland/electron-builder/issues/1741#issuecomment-311111418 so, do not use inclusive patterns\n const patterns = matcher.patterns\n\n const customFirstPatterns: Array<string> = []\n // electron-webpack - we need to copy only package.json and node_modules from root dir (and these files are added by default), so, explicit empty array is specified\n if (!matcher.isSpecifiedAsEmptyArray && (matcher.isEmpty() || matcher.containsOnlyIgnore())) {\n customFirstPatterns.push(\"**/*\")\n }\n else if (!patterns.includes(\"package.json\")) {\n patterns.push(\"package.json\")\n }\n\n // https://github.com/electron-userland/electron-builder/issues/1482\n const relativeBuildResourceDir = path.relative(matcher.from, buildResourceDir)\n if (relativeBuildResourceDir.length !== 0 && !relativeBuildResourceDir.startsWith(\".\")) {\n customFirstPatterns.push(`!${relativeBuildResourceDir}{,/**/*}`)\n }\n\n const relativeOutDir = matcher.normalizePattern(path.relative(packager.projectDir, outDir))\n if (!relativeOutDir.startsWith(\".\")) {\n customFirstPatterns.push(`!${relativeOutDir}{,/**/*}`)\n }\n\n // add our default exclusions after last user possibly defined \"all\"/permissive pattern\n let insertIndex = 0\n for (let i = patterns.length - 1; i >= 0; i--) {\n if (patterns[i].startsWith(\"**/\")) {\n insertIndex = i + 1\n break\n }\n }\n patterns.splice(insertIndex, 0, ...customFirstPatterns)\n\n patterns.push(`!**/*.{${excludedExts}${packager.config.includePdb === true ? \"\" : \",pdb\"}`)\n patterns.push(\"!**/._*\")\n patterns.push(\"!**/electron-builder.{yaml,yml,json,json5,toml}\")\n patterns.push(`!**/{${excludedNames}}`)\n\n if (isElectronCompile) {\n patterns.push(\"!.cache{,/**/*}\")\n }\n\n // https://github.com/electron-userland/electron-builder/issues/1969\n // exclude ony for app root, use .yarnclean to clean node_modules\n patterns.push(\"!.editorconfig\")\n\n const debugLogger = packager.debugLogger\n if (debugLogger.isEnabled) {\n //tslint:disable-next-line:no-invalid-template-strings\n debugLogger.add(`${macroExpander(\"${arch}\")}.firstOrDefaultFilePatterns`, patterns)\n }\n return matchers\n}\n\n/** @internal */\nexport function getNodeModuleFileMatcher(appDir: string, destination: string, macroExpander: (pattern: string) => string, platformSpecificBuildOptions: PlatformSpecificBuildOptions, packager: Packager): FileMatcher {\n // https://github.com/electron-userland/electron-builder/pull/2948#issuecomment-392241632\n // grab only excludes\n const matcher = new FileMatcher(appDir, destination, macroExpander)\n\n function addPatterns(patterns: Array<string | FileSet> | string | null | undefined | FileSet) {\n if (patterns == null) {\n return\n }\n else if (!Array.isArray(patterns)) {\n if (typeof patterns === \"string\" && patterns.startsWith(\"!\")) {\n matcher.addPattern(patterns)\n return\n }\n // ignore object form\n return\n }\n\n for (const pattern of patterns) {\n if (typeof pattern === \"string\") {\n if (pattern.startsWith(\"!\")) {\n matcher.addPattern(pattern)\n }\n }\n else {\n const fileSet = (pattern as FileSet)\n if (fileSet.from == null || fileSet.from === \".\") {\n for (const p of asArray(fileSet.filter)) {\n matcher.addPattern(p)\n }\n }\n }\n }\n }\n\n addPatterns(packager.config.files)\n addPatterns(platformSpecificBuildOptions.files)\n\n if (!matcher.isEmpty()) {\n matcher.prependPattern(\"**/*\")\n }\n\n const debugLogger = packager.debugLogger\n if (debugLogger.isEnabled) {\n //tslint:disable-next-line:no-invalid-template-strings\n debugLogger.add(`${macroExpander(\"${arch}\")}.nodeModuleFilePatterns`, matcher.patterns)\n }\n\n return matcher\n}\n\nexport interface GetFileMatchersOptions {\n readonly macroExpander: (pattern: string) => string\n readonly customBuildOptions: PlatformSpecificBuildOptions\n readonly globalOutDir: string\n\n readonly defaultSrc: string\n}\n\n/** @internal */\nexport function getFileMatchers(config: Configuration, name: \"files\" | \"extraFiles\" | \"extraResources\" | \"asarUnpack\" | \"extraDistFiles\", defaultDestination: string, options: GetFileMatchersOptions): Array<FileMatcher> | null {\n const defaultMatcher = new FileMatcher(options.defaultSrc, defaultDestination, options.macroExpander)\n const fileMatchers: Array<FileMatcher> = []\n\n function addPatterns(patterns: Array<string | FileSet> | string | null | undefined | FileSet) {\n if (patterns == null) {\n return\n }\n else if (!Array.isArray(patterns)) {\n if (typeof patterns === \"string\") {\n defaultMatcher.addPattern(patterns)\n return\n }\n patterns = [patterns]\n }\n\n for (const pattern of patterns) {\n if (typeof pattern === \"string\") {\n // use normalize to transform ./foo to foo\n defaultMatcher.addPattern(pattern)\n }\n else if (name === \"asarUnpack\") {\n throw new Error(`Advanced file copying not supported for \"${name}\"`)\n }\n else {\n const from = pattern.from == null ? options.defaultSrc : path.resolve(options.defaultSrc, pattern.from)\n const to = pattern.to == null ? defaultDestination : path.resolve(defaultDestination, pattern.to)\n fileMatchers.push(new FileMatcher(from, to, options.macroExpander, pattern.filter))\n }\n }\n }\n\n if (name !== \"extraDistFiles\") {\n addPatterns((config as any)[name])\n }\n addPatterns((options.customBuildOptions as any)[name])\n\n if (!defaultMatcher.isEmpty()) {\n // default matcher should be first in the array\n fileMatchers.unshift(defaultMatcher)\n }\n\n // we cannot exclude the whole out dir, because sometimes users want to use some file in the out dir in the patterns\n const relativeOutDir = defaultMatcher.normalizePattern(path.relative(options.defaultSrc, options.globalOutDir))\n if (!relativeOutDir.startsWith(\".\")) {\n defaultMatcher.addPattern(`!${relativeOutDir}/*-unpacked{,/**/*}`)\n }\n\n return fileMatchers.length === 0 ? null : fileMatchers\n}\n\n/** @internal */\nexport function copyFiles(matchers: Array<FileMatcher> | null, transformer: FileTransformer | null, isUseHardLink?: boolean): Promise<any> {\n if (matchers == null || matchers.length === 0) {\n return Promise.resolve()\n }\n\n return BluebirdPromise.map(matchers, async (matcher: FileMatcher) => {\n const fromStat = await statOrNull(matcher.from)\n if (fromStat == null) {\n log.warn({from: matcher.from}, `file source doesn't exist`)\n return\n }\n\n if (fromStat.isFile()) {\n const toStat = await statOrNull(matcher.to)\n // https://github.com/electron-userland/electron-builder/issues/1245\n if (toStat != null && toStat.isDirectory()) {\n return await copyOrLinkFile(matcher.from, path.join(matcher.to, path.basename(matcher.from)), fromStat, isUseHardLink)\n }\n\n await ensureDir(path.dirname(matcher.to))\n return await copyOrLinkFile(matcher.from, matcher.to, fromStat)\n }\n\n if (matcher.isEmpty() || matcher.containsOnlyIgnore()) {\n matcher.prependPattern(\"**/*\")\n }\n log.debug({matcher}, \"copying files using pattern\")\n return await copyDir(matcher.from, matcher.to, {filter: matcher.createFilter(), transformer, isUseHardLink: isUseHardLink ? USE_HARD_LINKS : null})\n })\n}"],"sourceRoot":""}
|