@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
78 lines (77 loc) • 3.84 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var config_plugins_1 = require("@expo/config-plugins");
var fs = __importStar(require("fs"));
var path = __importStar(require("path"));
var completeIosVersion = '1.0.1'; // Update as needed
var podDependencyPattern = /pod 'PassageSwift',\s*'([\d.]+)'/;
var podDependency = "pod 'PassageSwift', '".concat(completeIosVersion, "'");
var modifyIOSPodfile = function (configuration) {
console.log('Passage: Checking iOS Podfile.');
return (0, config_plugins_1.withDangerousMod)(configuration, [
'ios',
function (config) {
var podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
if (!fs.existsSync(podfilePath)) {
console.warn("Passage: Podfile not found at path: ".concat(podfilePath, ". Skipping Podfile modification."));
return config;
}
var podfileContents = fs.readFileSync(podfilePath, 'utf-8');
// Check if the dependency is already present and extract the version
var existingVersionMatch = podfileContents.match(podDependencyPattern);
var 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 ".concat(existingVersion, " to ").concat(completeIosVersion, "."));
podfileContents = podfileContents.replace(podDependencyPattern, podDependency);
fs.writeFileSync(podfilePath, podfileContents);
console.log('Passage: Podfile updated successfully.');
}
}
else {
console.log("Passage: Adding '".concat(podDependency, "' to Podfile..."));
var targetIndex = podfileContents.lastIndexOf("target '");
if (targetIndex !== -1) {
var nextLineIndex = podfileContents.indexOf('\n', targetIndex);
podfileContents =
podfileContents.slice(0, nextLineIndex) +
" ".concat(podDependency, "\n") +
podfileContents.slice(nextLineIndex);
fs.writeFileSync(podfilePath, podfileContents);
console.log('Passage: Podfile updated successfully.');
}
}
console.log('Passage: iOS Podfile check complete.');
return config;
},
]);
};
exports.default = modifyIOSPodfile;
;