@expo/config-plugins
Advanced tools
Comparing version 0.0.1-canary-20240415-cca04d8 to 0.0.1-canary-20240418-8d74597
@@ -16,5 +16,5 @@ "use strict"; | ||
} | ||
function _path() { | ||
const data = _interopRequireDefault(require("path")); | ||
_path = function () { | ||
function _fs() { | ||
const data = _interopRequireDefault(require("fs")); | ||
_fs = function () { | ||
return data; | ||
@@ -24,5 +24,5 @@ }; | ||
} | ||
function _XcodeProjectFile() { | ||
const data = require("./XcodeProjectFile"); | ||
_XcodeProjectFile = function () { | ||
function _path() { | ||
const data = _interopRequireDefault(require("path")); | ||
_path = function () { | ||
return data; | ||
@@ -57,20 +57,40 @@ }; | ||
function setPrivacyInfo(projectConfig, privacyManifests) { | ||
const projectName = (0, _Xcodeproj().getProjectName)(projectConfig.modRequest.projectRoot); | ||
const existingFileContent = (0, _XcodeProjectFile().readBuildSourceFile)({ | ||
project: projectConfig.modResults, | ||
nativeProjectRoot: projectConfig.modRequest.platformProjectRoot, | ||
filePath: _path().default.join(projectName, 'PrivacyInfo.xcprivacy') | ||
}); | ||
const { | ||
projectRoot, | ||
platformProjectRoot | ||
} = projectConfig.modRequest; | ||
const projectName = (0, _Xcodeproj().getProjectName)(projectRoot); | ||
const privacyFilePath = _path().default.join(platformProjectRoot, projectName, 'PrivacyInfo.xcprivacy'); | ||
const existingFileContent = getFileContents(privacyFilePath); | ||
const parsedContent = existingFileContent ? _plist().default.parse(existingFileContent) : {}; | ||
const mergedContent = mergePrivacyInfo(parsedContent, privacyManifests); | ||
const contents = _plist().default.build(mergedContent); | ||
projectConfig.modResults = (0, _XcodeProjectFile().createBuildSourceFile)({ | ||
project: projectConfig.modResults, | ||
nativeProjectRoot: projectConfig.modRequest.platformProjectRoot, | ||
fileContents: contents, | ||
filePath: _path().default.join(projectName, 'PrivacyInfo.xcprivacy'), | ||
overwrite: true | ||
}); | ||
ensureFileExists(privacyFilePath, contents); | ||
if (!projectConfig.modResults.hasFile(privacyFilePath)) { | ||
projectConfig.modResults = (0, _Xcodeproj().addResourceFileToGroup)({ | ||
filepath: privacyFilePath, | ||
groupName: projectName, | ||
project: projectConfig.modResults, | ||
isBuildFile: true, | ||
verbose: true | ||
}); | ||
} | ||
return projectConfig; | ||
} | ||
function getFileContents(filePath) { | ||
if (!_fs().default.existsSync(filePath)) { | ||
return null; | ||
} | ||
return _fs().default.readFileSync(filePath, { | ||
encoding: 'utf8' | ||
}); | ||
} | ||
function ensureFileExists(filePath, contents) { | ||
if (!_fs().default.existsSync(_path().default.dirname(filePath))) { | ||
_fs().default.mkdirSync(_path().default.dirname(filePath), { | ||
recursive: true | ||
}); | ||
} | ||
_fs().default.writeFileSync(filePath, contents); | ||
} | ||
function mergePrivacyInfo(existing, privacyManifests) { | ||
@@ -77,0 +97,0 @@ let { |
@@ -32,12 +32,1 @@ /// <reference types="xcode" /> | ||
}): XcodeProject; | ||
/** | ||
* Read a source file from the Xcode project | ||
* | ||
* @param nativeProjectRoot absolute path to the native app root `user/app/ios` | ||
* @param filePath path relative to the `nativeProjectRoot` for the file to read `user/app/ios/myapp/foobar.swift` | ||
*/ | ||
export declare function readBuildSourceFile({ project, nativeProjectRoot, filePath, }: { | ||
project: XcodeProject; | ||
nativeProjectRoot: string; | ||
filePath: string; | ||
}): string | null; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.createBuildSourceFile = createBuildSourceFile; | ||
exports.readBuildSourceFile = readBuildSourceFile; | ||
exports.withBuildSourceFile = void 0; | ||
@@ -101,22 +100,2 @@ function _fs() { | ||
} | ||
/** | ||
* Read a source file from the Xcode project | ||
* | ||
* @param nativeProjectRoot absolute path to the native app root `user/app/ios` | ||
* @param filePath path relative to the `nativeProjectRoot` for the file to read `user/app/ios/myapp/foobar.swift` | ||
*/ | ||
function readBuildSourceFile({ | ||
project, | ||
nativeProjectRoot, | ||
filePath | ||
}) { | ||
const absoluteFilePath = _path().default.join(nativeProjectRoot, filePath); | ||
if (!_fs().default.existsSync(absoluteFilePath)) { | ||
return null; | ||
} | ||
return _fs().default.readFileSync(absoluteFilePath, { | ||
encoding: 'utf8' | ||
}); | ||
} | ||
//# sourceMappingURL=XcodeProjectFile.js.map |
@@ -124,3 +124,3 @@ "use strict"; | ||
if (runtimeVersion === FINGERPRINT_RUNTIME_VERSION_SENTINEL) { | ||
throw new Error(`${FINGERPRINT_RUNTIME_VERSION_SENTINEL} is a reserved value for runtime version. To use a fingerprint runtime version, use the "fingerprintExperimental" runtime version policy.`); | ||
throw new Error(`${FINGERPRINT_RUNTIME_VERSION_SENTINEL} is a reserved value for runtime version. To use a fingerprint runtime version, use the "fingerprint" runtime version policy.`); | ||
} | ||
@@ -130,3 +130,3 @@ return runtimeVersion; | ||
throw new Error(`"${runtimeVersion}" is not a valid runtime version. Only a string or a runtime version policy is supported.`); | ||
} else if (runtimeVersion.policy === 'fingerprintExperimental') { | ||
} else if (runtimeVersion.policy === 'fingerprint') { | ||
console.warn(`Use of the experimental '${runtimeVersion.policy}' runtime policy may result in unexpected system behavior.`); | ||
@@ -149,3 +149,3 @@ return FINGERPRINT_RUNTIME_VERSION_SENTINEL; | ||
} else { | ||
// fingerprintExperimental is resolvable only at build time (not in config plugin). | ||
// fingerprint is resolvable only at build time (not in config plugin). | ||
throw new Error(`"${policy}" is not a valid runtime version policy type.`); | ||
@@ -152,0 +152,0 @@ } |
{ | ||
"name": "@expo/config-plugins", | ||
"version": "0.0.1-canary-20240415-cca04d8", | ||
"version": "0.0.1-canary-20240418-8d74597", | ||
"description": "A library for Expo config plugins", | ||
@@ -36,5 +36,5 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@expo/config-types": "51.0.0-canary-20240415-cca04d8", | ||
"@expo/json-file": "0.0.1-canary-20240415-cca04d8", | ||
"@expo/plist": "0.0.1-canary-20240415-cca04d8", | ||
"@expo/config-types": "51.0.0-canary-20240418-8d74597", | ||
"@expo/json-file": "0.0.1-canary-20240418-8d74597", | ||
"@expo/plist": "0.0.1-canary-20240418-8d74597", | ||
"@expo/sdk-runtime-versions": "^1.0.0", | ||
@@ -57,3 +57,3 @@ "chalk": "^4.1.2", | ||
"@types/xml2js": "~0.4.11", | ||
"expo-module-scripts": "0.0.1-canary-20240415-cca04d8" | ||
"expo-module-scripts": "0.0.1-canary-20240418-8d74597" | ||
}, | ||
@@ -63,3 +63,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "cca04d8dc8de4f4b08d86935e3e1f448ecbd6ec1" | ||
"gitHead": "8d74597a78a7b6548da17e7266a4e7734df3c7f3" | ||
} |
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
1092738
12781
21
+ Added@expo/config-types@51.0.0-canary-20240418-8d74597(transitive)
+ Added@expo/json-file@0.0.1-canary-20240418-8d74597(transitive)
+ Added@expo/plist@0.0.1-canary-20240418-8d74597(transitive)
- Removed@expo/config-types@51.0.0-canary-20240415-cca04d8(transitive)
- Removed@expo/json-file@0.0.1-canary-20240415-cca04d8(transitive)
- Removed@expo/plist@0.0.1-canary-20240415-cca04d8(transitive)