@expo/config-plugins
Advanced tools
Comparing version 3.0.1 to 3.0.2
import { ConfigPlugin } from '../Plugin.types'; | ||
import { InfoPlist } from './IosConfig.types'; | ||
export declare function applyPermissions<Defaults extends Record<string, string> = Record<string, string>>(defaults: Defaults, permissions: Partial<Record<keyof Defaults, string | false>>, infoPlist: InfoPlist): InfoPlist; | ||
/** | ||
* Apply permissions and their respective descriptions to the iOS Info.plist. | ||
* Providing a null description will remove the permission from the Info.plist. | ||
* Helper method for creating mods to apply default permissions. | ||
* | ||
* @param config | ||
* @param permissions record of strings where the key matches Info.plist permissions and the values are the permission descriptions. | ||
* @param action | ||
*/ | ||
export declare const withPermissions: ConfigPlugin<Record<string, string | null>>; | ||
export declare function applyPermissions(permissions: Record<string, string | null>, infoPlist: Record<string, any>): InfoPlist; | ||
export declare function createPermissionsPlugin<Defaults extends Record<string, string> = Record<string, string>>(defaults: Defaults, name?: string): ConfigPlugin<Record<keyof Defaults, string | false | undefined>>; |
@@ -7,4 +7,14 @@ "use strict"; | ||
exports.applyPermissions = applyPermissions; | ||
exports.withPermissions = void 0; | ||
exports.createPermissionsPlugin = createPermissionsPlugin; | ||
function _debug() { | ||
const data = _interopRequireDefault(require("debug")); | ||
_debug = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _iosPlugins() { | ||
@@ -20,38 +30,20 @@ const data = require("../plugins/ios-plugins"); | ||
/** | ||
* Apply permissions and their respective descriptions to the iOS Info.plist. | ||
* Providing a null description will remove the permission from the Info.plist. | ||
* | ||
* @param config | ||
* @param permissions record of strings where the key matches Info.plist permissions and the values are the permission descriptions. | ||
*/ | ||
const withPermissions = (config, permissions) => { | ||
return (0, _iosPlugins().withInfoPlist)(config, async config => { | ||
config.modResults = applyPermissions(permissions, config.modResults); | ||
return config; | ||
}); | ||
}; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.withPermissions = withPermissions; | ||
const debug = (0, _debug().default)('config-plugins:ios:permissions'); | ||
function applyPermissions(permissions, infoPlist) { | ||
const entries = Object.entries(permissions); | ||
function applyPermissions(defaults, permissions, infoPlist) { | ||
const entries = Object.entries(defaults); | ||
if (entries.length === 0) {// TODO: Debug warn | ||
// console.warn('[withPermissions] no permissions were provided'); | ||
if (entries.length === 0) { | ||
debug(`No defaults provided: ${JSON.stringify(permissions)}`); | ||
} | ||
for (const [permission, description] of entries) { | ||
if (description == null) { | ||
if (permissions[permission] === false) { | ||
debug(`Deleting "${permission}"`); | ||
delete infoPlist[permission]; | ||
} else { | ||
const existingPermission = infoPlist[permission]; | ||
if (existingPermission && existingPermission !== description) {// TODO: Debug warn | ||
// console.warn( | ||
// `[withPermissionsIos][conflict] permission "${permission}" is already defined in the Info.plist with description "${existingPermission}"` | ||
// ); | ||
} | ||
infoPlist[permission] = description; | ||
infoPlist[permission] = permissions[permission] || infoPlist[permission] || description; | ||
debug(`Setting "${permission}" to "${infoPlist[permission]}"`); | ||
} | ||
@@ -62,2 +54,23 @@ } | ||
} | ||
/** | ||
* Helper method for creating mods to apply default permissions. | ||
* | ||
* @param action | ||
*/ | ||
function createPermissionsPlugin(defaults, name) { | ||
const withIosPermissions = (config, permissions) => (0, _iosPlugins().withInfoPlist)(config, async config => { | ||
config.modResults = applyPermissions(defaults, permissions, config.modResults); | ||
return config; | ||
}); | ||
if (name) { | ||
Object.defineProperty(withIosPermissions, 'name', { | ||
value: name | ||
}); | ||
} | ||
return withIosPermissions; | ||
} | ||
//# sourceMappingURL=Permissions.js.map |
@@ -12,2 +12,12 @@ "use strict"; | ||
function _debug() { | ||
const data = _interopRequireDefault(require("debug")); | ||
_debug = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _withMod() { | ||
@@ -23,2 +33,6 @@ const data = require("./withMod"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const debug = (0, _debug().default)('config-plugins:base-mods'); | ||
function createBaseMod({ | ||
@@ -55,2 +69,3 @@ methodName, | ||
const filePath = await getFilePath(results, props); | ||
debug(`mods.${platform}.${modName}: file path: ${filePath || '[skipped]'}`); | ||
const modResults = await read(filePath, results, props); | ||
@@ -57,0 +72,0 @@ results = await nextMod({ ...results, |
@@ -11,2 +11,12 @@ "use strict"; | ||
function _debug() { | ||
const data = _interopRequireDefault(require("debug")); | ||
_debug = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _path() { | ||
@@ -88,2 +98,4 @@ const data = _interopRequireDefault(require("path")); | ||
const debug = (0, _debug().default)('config-plugins:mod-compiler'); | ||
function withDefaultBaseMods(config, props = {}) { | ||
@@ -204,2 +216,3 @@ config = (0, _withIosBaseMods().withIosBaseMods)(config, props); | ||
if (platforms && !platforms.includes(platformName)) { | ||
debug(`skip platform: ${platformName}`); | ||
continue; | ||
@@ -213,2 +226,3 @@ } | ||
entries = sortMods(entries, orders[platformName]); | ||
debug(`run in order: ${entries.map(([name]) => name).join(', ')}`); | ||
@@ -215,0 +229,0 @@ const platformProjectRoot = _path().default.join(projectRoot, platformName); |
{ | ||
"name": "@expo/config-plugins", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "A library for Expo config plugins", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
930805
11166