expo-stripe-tap-to-pay
Version:
Expo config plugin to enable Tap to Pay on iPhone entitlements and set Apple Merchant ID.
42 lines (32 loc) • 1.11 kB
JavaScript
const fs = require("fs");
const path = require("path");
// Get the argument from the command line
const versionType = process.argv[2] || "patch";
// Define the path to the package.json file
const packageJsonPath = path.join(__dirname, "./package.json");
// Read the package.json file
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
// Split the current version into major, minor, and patch
const versionParts = packageJson.version.split(".").map(Number);
// Update the version based on the argument
switch (versionType) {
case "major":
versionParts[0] += 1;
versionParts[1] = 0;
versionParts[2] = 0;
break;
case "minor":
versionParts[1] += 1;
versionParts[2] = 0;
break;
case "patch":
default:
versionParts[2] += 1;
break;
}
// Join the version parts back into a string
packageJson.version = versionParts.join(".");
// Write the updated package.json back to the file
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
console.log(`Updated project version to ${packageJson.version}`);