thedesk/app/node_modules/app-builder-lib/out/util/config.js.map
2019-09-12 23:38:13 +09:00

2 lines
18 KiB
Plaintext

{"version":3,"sources":["../../src/util/config.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AACA,MAAM,cAAc,GAAG,OAAO,CAAC,uBAAD,CAA9B,C,CAIA;;;AACA,SAAS,YAAT,CAAsB,MAAtB,EAA6C,iBAA7C,EAA6E;AAC3E;AACA,QAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,MAAM,CAAC,OAArB,IAAgC,iBAAiB,CAAC,OAAlD,GAA4D,IAA5E;;AACA,MAAI,OAAO,IAAI,IAAf,EAAqB;AACnB,WAAQ,iBAAyB,CAAC,OAAlC;AACD;;AAED,iCAAW,MAAX,EAAmB,iBAAnB;;AAEA,MAAI,OAAO,IAAI,IAAf,EAAqB;AACnB;AACD;;AAED,QAAM,UAAU,GAAG,MAAM,CAAC,OAA1B;;AACA,MAAI,UAAU,CAAC,MAAX,KAAsB,CAA1B,EAA6B;AAC3B,IAAA,MAAM,CAAC,OAAP,GAAiB,OAAjB;AACD,GAFD,MAGK;AACH;AACA,IAAA,MAAM,CAAC,MAAP,CAAc,UAAU,CAAC,CAAD,CAAxB,EAA6B,OAA7B;AACD;AACF;;AAEM,eAAe,SAAf,CAAyB,UAAzB,EACyB,UADzB,EAEyB,iBAFzB,EAGyB,eAAA,GAAuD,KAAI,eAAJ,EAAS,MAAM,4CAAqB,yBAAS,IAAI,CAAC,IAAL,CAAU,UAAV,EAAsB,cAAtB,CAAT,CAArB,CAAf,C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d;AAwBD;;AAED,MAAM,qBAAqB,GAAG,CAAC,KAAD,EAAQ,KAAR,CAA9B;;AAEO,eAAe,0BAAf,CAA0C,UAA1C,EAA8D,UAA9D,EAAmG;AACxG,MAAI,UAAU,IAAI,IAAlB,EAAwB;AACtB,UAAM,YAAY,GAAG,IAAI,CAAC,OAAL,CAAa,UAAb,EAAyB,UAAzB,CAArB;AACA,UAAM,IAAI,GAAG,MAAM,sBAAW,YAAX,CAAnB;;AACA,QAAI,IAAI,IAAI,IAAZ,EAAkB;AAChB,YAAM,KAAI,wCAAJ,EAA8B,yBAAyB,UAAU,gBAAjE,CAAN;AACD,KAFD,MAGK,IAAI,CAAC,IAAI,CAAC,WAAL,EAAL,EAAyB;AAC5B,YAAM,KAAI,wCAAJ,EAA8B,yBAAyB,UAAU,qBAAjE,CAAN;AACD,KAFI,MAGA,IAAI,UAAU,KAAK,YAAnB,EAAiC;AACpC,yBAAI,IAAJ,CAAS;AAAC,QAAA,YAAY,EAAE;AAAf,OAAT,EAAqC,4FAArC;AACD;;AACD,WAAO,YAAP;AACD;;AAED,OAAK,MAAM,GAAX,IAAkB,qBAAlB,EAAyC;AACvC,UAAM,YAAY,GAAG,IAAI,CAAC,IAAL,CAAU,UAAV,EAAsB,GAAtB,CAArB;AACA,UAAM,WAAW,GAAG,IAAI,CAAC,IAAL,CAAU,YAAV,EAAwB,cAAxB,CAApB;AACA,UAAM,IAAI,GAAG,MAAM,sBAAW,WAAX,CAAnB;;AACA,QAAI,IAAI,IAAI,IAAR,IAAgB,IAAI,CAAC,MAAL,EAApB,EAAmC;AACjC,aAAO,YAAP;AACD;AACF;;AACD,SAAO,UAAP;AACD,C","sourcesContent":["import { DebugLogger, deepAssign, InvalidConfigurationError, log, safeStringifyJson } from \"builder-util\"\nimport { statOrNull } from \"builder-util/out/fs\"\nimport { readJson } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { getConfig as _getConfig, loadParentConfig, orNullIfFileNotExist, ReadConfigRequest } from \"read-config-file\"\nimport { FileSet } from \"..\"\nimport { Configuration } from \"../configuration\"\nimport { reactCra } from \"../presets/rectCra\"\nconst validateSchema = require(\"@develar/schema-utils\")\n\ndeclare const PACKAGE_VERSION: string\n\n// https://github.com/electron-userland/electron-builder/issues/1847\nfunction mergePublish(config: Configuration, configFromOptions: Configuration) {\n // if config from disk doesn't have publish (or object), no need to handle, it will be simply merged by deepAssign\n const publish = Array.isArray(config.publish) ? configFromOptions.publish : null\n if (publish != null) {\n delete (configFromOptions as any).publish\n }\n\n deepAssign(config, configFromOptions)\n\n if (publish == null) {\n return\n }\n\n const listOnDisk = config.publish as Array<any>\n if (listOnDisk.length === 0) {\n config.publish = publish\n }\n else {\n // apply to first\n Object.assign(listOnDisk[0], publish)\n }\n}\n\nexport async function getConfig(projectDir: string,\n configPath: string | null,\n configFromOptions: Configuration | null | undefined,\n packageMetadata: Lazy<{ [key: string]: any } | null> = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, \"package.json\"))))): Promise<Configuration> {\n const configRequest: ReadConfigRequest = {packageKey: \"build\", configFilename: \"electron-builder\", projectDir, packageMetadata}\n const configAndEffectiveFile = await _getConfig<Configuration>(configRequest, configPath)\n const config = configAndEffectiveFile == null ? {} : configAndEffectiveFile.result\n if (configFromOptions != null) {\n mergePublish(config, configFromOptions)\n }\n\n if (configAndEffectiveFile != null) {\n log.info({file: configAndEffectiveFile.configFile == null ? 'package.json (\"build\" field)' : configAndEffectiveFile.configFile}, \"loaded configuration\")\n }\n\n if (config.extends == null && config.extends !== null) {\n const metadata = await packageMetadata.value || {}\n const devDependencies = metadata.devDependencies\n const dependencies = metadata.dependencies\n if ((dependencies != null && \"react-scripts\" in dependencies) || (devDependencies != null && \"react-scripts\" in devDependencies)) {\n config.extends = \"react-cra\"\n }\n else if (devDependencies != null && \"electron-webpack\" in devDependencies) {\n let file = \"electron-webpack/out/electron-builder.js\"\n try {\n file = require.resolve(file)\n }\n catch (ignore) {\n file = require.resolve(\"electron-webpack/electron-builder.yml\")\n }\n config.extends = `file:${file}`\n }\n }\n\n let parentConfig: Configuration | null\n if (config.extends === \"react-cra\") {\n parentConfig = await reactCra(projectDir)\n log.info({preset: config.extends}, \"loaded parent configuration\")\n }\n else if (config.extends != null) {\n const parentConfigAndEffectiveFile = await loadParentConfig<Configuration>(configRequest, config.extends)\n log.info({file: parentConfigAndEffectiveFile.configFile}, \"loaded parent configuration\")\n parentConfig = parentConfigAndEffectiveFile.result\n }\n else {\n parentConfig = null\n }\n\n return doMergeConfigs(config, parentConfig)\n}\n\n// normalize for easy merge\nfunction normalizeFiles(configuration: Configuration, name: \"files\" | \"extraFiles\" | \"extraResources\") {\n let value = configuration[name]\n if (value == null) {\n return\n }\n\n if (!Array.isArray(value)) {\n value = [value]\n }\n\n itemLoop: for (let i = 0; i < value.length; i++) {\n let item = value[i]\n if (typeof item === \"string\") {\n // merge with previous if possible\n if (i !== 0) {\n let prevItemIndex = i - 1\n let prevItem: FileSet\n do {\n prevItem = value[prevItemIndex--] as FileSet\n } while (prevItem == null)\n\n if (prevItem.from == null && prevItem.to == null) {\n if (prevItem.filter == null) {\n prevItem.filter = [item]\n }\n else {\n (prevItem.filter as Array<string>).push(item)\n }\n value[i] = null as any\n continue itemLoop\n }\n }\n\n item = {\n filter: [item],\n }\n value[i] = item\n }\n else if (Array.isArray(item)) {\n throw new Error(`${name} configuration is invalid, nested array not expected for index ${i}: ` + item)\n }\n\n // make sure that merge logic is not complex - unify different presentations\n if (item.from === \".\") {\n item.from = undefined\n }\n\n if (item.to === \".\") {\n item.to = undefined\n }\n\n if (item.filter != null && typeof item.filter === \"string\") {\n item.filter = [item.filter]\n }\n }\n\n configuration[name] = value.filter(it => it != null)\n}\n\nfunction mergeFiles(configuration: Configuration, parentConfiguration: Configuration, mergedConfiguration: Configuration, name: \"files\" | \"extraFiles\" | \"extraResources\") {\n const list = configuration[name] as Array<FileSet> | null\n const parentList = parentConfiguration[name] as Array<FileSet> | null\n if (list == null || parentList == null) {\n return\n }\n\n const result = list.slice()\n mergedConfiguration[name] = result\n\n itemLoop: for (const item of parentConfiguration.files as Array<FileSet>) {\n for (const existingItem of list) {\n if (existingItem.from === item.from && existingItem.to === item.to) {\n if (item.filter != null) {\n if (existingItem.filter == null) {\n existingItem.filter = item.filter.slice()\n }\n else {\n existingItem.filter = (item.filter as Array<string>).concat(existingItem.filter)\n }\n }\n\n continue itemLoop\n }\n }\n\n // existing item not found, simply add\n result.push(item)\n }\n}\n\nexport function doMergeConfigs(configuration: Configuration, parentConfiguration: Configuration | null) {\n normalizeFiles(configuration, \"files\")\n normalizeFiles(configuration, \"extraFiles\")\n normalizeFiles(configuration, \"extraResources\")\n\n if (parentConfiguration == null) {\n return deepAssign(getDefaultConfig(), configuration)\n }\n\n normalizeFiles(parentConfiguration, \"files\")\n normalizeFiles(parentConfiguration, \"extraFiles\")\n normalizeFiles(parentConfiguration, \"extraResources\")\n\n const result = deepAssign(getDefaultConfig(), parentConfiguration, configuration)\n mergeFiles(configuration, parentConfiguration, result, \"files\")\n return result\n}\n\nfunction getDefaultConfig(): Configuration {\n return {\n directories: {\n output: \"dist\",\n buildResources: \"build\",\n },\n }\n}\n\nconst schemeDataPromise = new Lazy(() => readJson(path.join(__dirname, \"..\", \"..\", \"scheme.json\")))\n\nexport async function validateConfig(config: Configuration, debugLogger: DebugLogger) {\n const extraMetadata = config.extraMetadata\n if (extraMetadata != null) {\n if (extraMetadata.build != null) {\n throw new InvalidConfigurationError(`--em.build is deprecated, please specify as -c\"`)\n }\n if (extraMetadata.directories != null) {\n throw new InvalidConfigurationError(`--em.directories is deprecated, please specify as -c.directories\"`)\n }\n }\n\n const oldConfig: any = config\n if (oldConfig.npmSkipBuildFromSource === false) {\n throw new InvalidConfigurationError(`npmSkipBuildFromSource is deprecated, please use buildDependenciesFromSource\"`)\n }\n if (oldConfig.appImage != null && oldConfig.appImage.systemIntegration != null) {\n throw new InvalidConfigurationError(`appImage.systemIntegration is deprecated, https://github.com/TheAssassin/AppImageLauncher is used for desktop integration\"`)\n }\n\n // noinspection JSUnusedGlobalSymbols\n validateSchema(await schemeDataPromise.value, config, {\n name: `electron-builder ${PACKAGE_VERSION}`,\n postFormatter: (formattedError: string, error: any): string => {\n if (debugLogger.isEnabled) {\n debugLogger.add(\"invalidConfig\", safeStringifyJson(error))\n }\n\n const site = \"https://www.electron.build\"\n let url = `${site}/configuration/configuration`\n const targets = new Set([\"mac\", \"dmg\", \"pkg\", \"mas\", \"win\", \"nsis\", \"appx\", \"linux\", \"appimage\", \"snap\"])\n const dataPath: string = error.dataPath == null ? null : error.dataPath\n const targetPath = dataPath.startsWith(\".\") ? dataPath.substr(1).toLowerCase() : null\n if (targetPath != null && targets.has(targetPath)) {\n url = `${site}/configuration/${targetPath}`\n }\n\n return `${formattedError}\\n How to fix:\n 1. Open ${url}\n 2. Search the option name on the page (or type in into Search to find across the docs).\n * Not found? The option was deprecated or not exists (check spelling).\n * Found? Check that the option in the appropriate place. e.g. \"title\" only in the \"dmg\", not in the root.\n`\n },\n })\n}\n\nconst DEFAULT_APP_DIR_NAMES = [\"app\", \"www\"]\n\nexport async function computeDefaultAppDirectory(projectDir: string, userAppDir: string | null | undefined): Promise<string> {\n if (userAppDir != null) {\n const absolutePath = path.resolve(projectDir, userAppDir)\n const stat = await statOrNull(absolutePath)\n if (stat == null) {\n throw new InvalidConfigurationError(`Application directory ${userAppDir} doesn't exist`)\n }\n else if (!stat.isDirectory()) {\n throw new InvalidConfigurationError(`Application directory ${userAppDir} is not a directory`)\n }\n else if (projectDir === absolutePath) {\n log.warn({appDirectory: userAppDir}, `Specified application directory equals to project dir — superfluous or wrong configuration`)\n }\n return absolutePath\n }\n\n for (const dir of DEFAULT_APP_DIR_NAMES) {\n const absolutePath = path.join(projectDir, dir)\n const packageJson = path.join(absolutePath, \"package.json\")\n const stat = await statOrNull(packageJson)\n if (stat != null && stat.isFile()) {\n return absolutePath\n }\n }\n return projectDir\n}\n"],"sourceRoot":""}