UNPKG

@passageidentity/passage-react-native

Version:

Passkey Complete for React Native - Go completely passwordless with a standalone auth solution in your React Native app with Passage by 1Password

51 lines (50 loc) 3.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _configPlugins = require("@expo/config-plugins"); var fs = _interopRequireWildcard(require("fs")); var path = _interopRequireWildcard(require("path")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } const completeIosVersion = '1.0.1'; // Update as needed const podDependencyPattern = /pod 'PassageSwift',\s*'([\d.]+)'/; const podDependency = `pod 'PassageSwift', '${completeIosVersion}'`; const modifyIOSPodfile = configuration => { console.log('Passage: Checking iOS Podfile.'); return (0, _configPlugins.withDangerousMod)(configuration, ['ios', config => { const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile'); if (!fs.existsSync(podfilePath)) { console.warn(`Passage: Podfile not found at path: ${podfilePath}. Skipping Podfile modification.`); return config; } let podfileContents = fs.readFileSync(podfilePath, 'utf-8'); // Check if the dependency is already present and extract the version const existingVersionMatch = podfileContents.match(podDependencyPattern); const existingVersion = existingVersionMatch ? existingVersionMatch[1] : null; if (existingVersion) { if (existingVersion === completeIosVersion) { console.log('Passage: Pod dependency is already up-to-date. No changes made.'); } else { console.log(`Passage: Updating Pod dependency from version ${existingVersion} to ${completeIosVersion}.`); podfileContents = podfileContents.replace(podDependencyPattern, podDependency); fs.writeFileSync(podfilePath, podfileContents); console.log('Passage: Podfile updated successfully.'); } } else { console.log(`Passage: Adding '${podDependency}' to Podfile...`); const targetIndex = podfileContents.lastIndexOf(`target '`); if (targetIndex !== -1) { const nextLineIndex = podfileContents.indexOf('\n', targetIndex); podfileContents = podfileContents.slice(0, nextLineIndex) + ` ${podDependency}\n` + podfileContents.slice(nextLineIndex); fs.writeFileSync(podfilePath, podfileContents); console.log('Passage: Podfile updated successfully.'); } } console.log('Passage: iOS Podfile check complete.'); return config; }]); }; var _default = exports.default = modifyIOSPodfile; //# sourceMappingURL=modifyIOSPodfile.js.map