How to use simple-plist - 10 common examples

To help you get started, we’ve selected a few simple-plist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nowsecure / node-applesign / lib / session.js View on Github external
adjustEntitlements (file, entMobProv, next) {
    const teamId = entMobProv['com.apple.developer.team-identifier'];
    const appId = entMobProv['application-identifier'];
    /* TODO: check if this supports binary plist too */
    let ent = machoEntitlements.parseFile(file);
    if (ent === null) {
      console.error('Cannot find entitlements in binary. Using defaults');
      ent = defaultEntitlements(appId, teamId);
      // return next();
    }
    let entMacho = plist.parse(ent.toString().trim());
    if (this.config.selfSignedProvision) { /* */
      this.emit('message', 'Using an unsigned provisioning');
      const newEntitlementsFile = file + '.entitlements';
      const newEntitlements = plistBuild(entMacho).toString();
      fs.writeFileSync(newEntitlementsFile, newEntitlements);
      this.config.entitlement = newEntitlementsFile;
      return next();
    }
    let changed = false;
    if (this.config.cloneEntitlements) {
      this.emit('message', 'Cloning entitlements');
      entMacho = entMobProv;
      changed = true;
    } else {
      const k = 'com.apple.developer.icloud-container-identifiers';
      if (entMacho[k]) {
github nowsecure / node-applesign / lib / session.js View on Github external
return tools.getMobileProvisionPlist(this.config.mobileprovision, (err, data) => {
          if (err) {
            return next(err);
          }
          const mainBin = path.join(this.config.appdir, getExecutable(this.config.appdir));
          let ent = machoEntitlements.parseFile(mainBin);
          if (ent === null) {
            console.error('Cannot find entitlements in binary. Using defaults');
            const entMobProv = data['Entitlements'];
            const teamId = entMobProv['com.apple.developer.team-identifier'];
            const appId = entMobProv['application-identifier'];
            ent = defaultEntitlements(appId, teamId);
          }
          data['Entitlements'] = plist.parse(ent.toString().trim());
          fs.writeFileSync(mobileProvision, plistBuild(data).toString());
          /* TODO: self-sign mobile provisioning */
          next();
        });
      }
github appcelerator / ioslib / src / xcode.js View on Github external
this.simDeviceTypes[id] = deviceType;
				} catch (e) {
					// squelch
				}
			}
		}

		// runtimes
		const runtimesDir = path.join(dir, 'Runtimes');
		if (isDir(runtimesDir)) {
			// regex to extract the version from the runtime name
			const runtimeNameRegExp = /\s(\d+(?:\.\d+(?:\.\d+)?)?)$/;

			for (const name of fs.readdirSync(runtimesDir)) {
				try {
					let info = plist.readFileSync(path.join(runtimesDir, name, 'Contents/Info.plist'));
					const runtime = {
						name: info.CFBundleName,
						version: null
					};
					const id = info.CFBundleIdentifier;
					const m = info.CFBundleName.match(runtimeNameRegExp);
					if (m) {
						runtime.version = m[1];
					}

					try {
						info = plist.readFileSync(path.join(runtimesDir, name, 'Contents/Resources/profile.plist'));
						if (!runtime.version || info.defaultVersionString.startsWith(runtime.version)) {
							runtime.version = info.defaultVersionString;
						}
					} catch (e) {
github appcelerator / ioslib / src / xcode.js View on Github external
// device types
		const deviceTypesDir = path.join(dir, 'DeviceTypes');
		if (isDir(deviceTypesDir)) {
			for (const name of fs.readdirSync(deviceTypesDir)) {
				try {
					let info = plist.readFileSync(path.join(deviceTypesDir, name, 'Contents/Info.plist'));
					const deviceType = {
						name: info.CFBundleName,
						model: 'unknown',
						supportsWatch: false
					};
					const id = info.CFBundleIdentifier;

					try {
						info = plist.readFileSync(path.join(deviceTypesDir, name, 'Contents/Resources/profile.plist'));
						if (info.modelIdentifier) {
							deviceType.model = info.modelIdentifier;
						}
					} catch (e) {
						// squelch
					}

					try {
						info = plist.readFileSync(path.join(deviceTypesDir, name, 'Contents/Resources/capabilities.plist'));
						deviceType.supportsWatch = !!info.capabilities['watch-companion'];
					} catch (e) {
						// squelch
					}

					this.simDeviceTypes[id] = deviceType;
				} catch (e) {
github appcelerator / ioslib / src / xcode.js View on Github external
model: 'unknown',
						supportsWatch: false
					};
					const id = info.CFBundleIdentifier;

					try {
						info = plist.readFileSync(path.join(deviceTypesDir, name, 'Contents/Resources/profile.plist'));
						if (info.modelIdentifier) {
							deviceType.model = info.modelIdentifier;
						}
					} catch (e) {
						// squelch
					}

					try {
						info = plist.readFileSync(path.join(deviceTypesDir, name, 'Contents/Resources/capabilities.plist'));
						deviceType.supportsWatch = !!info.capabilities['watch-companion'];
					} catch (e) {
						// squelch
					}

					this.simDeviceTypes[id] = deviceType;
				} catch (e) {
					// squelch
				}
			}
		}

		// runtimes
		const runtimesDir = path.join(dir, 'Runtimes');
		if (isDir(runtimesDir)) {
			// regex to extract the version from the runtime name
github matiassingers / ipa-metadata / index.js View on Github external
unzipper.on('extract', function() {
    var path = glob.sync(output.path + '/Payload/*/')[0];

    data.metadata = plist.readFileSync(path + 'Info.plist');

    async.parallel([
      async.apply(provisioning, path + 'embedded.mobileprovision'),
      async.apply(entitlements, path)
    ], function(error, results){
      if(error){
        return cleanUp(error);
      }

      data.provisioning = results[0];

      // Hard to serialize and it looks messy in output
      delete data.provisioning.DeveloperCertificates;

      data.entitlements = results[1];
github appcelerator / ioslib / src / xcode.js View on Github external
return [];
		}

		const nameRegExp = new RegExp(`^${sdkTypeName}(.*).sdk$`);
		const results = new Set();

		for (const name of fs.readdirSync(dir)) {
			const m = name.match(nameRegExp);
			const subdir = m && path.join(dir, name);
			if (!m || !isDir(subdir)) {
				continue;
			}
			let ver = m[1] || null;
			try {
				const plistFile = path.join(subdir, 'System/Library/CoreServices/SystemVersion.plist');
				const info = plist.readFileSync(plistFile);
				if (info.ProductVersion) {
					ver = info.ProductVersion;
				}
			} catch (e) {
				// squelch
			}
			results.add(ver);
		}

		return Array.from(results).sort(version.rcompare);
	}
github nowsecure / node-applesign / index.js View on Github external
function getExecutable (appdir) {
  if (!appdir) {
    throw new Error('No application directory is provided');
  }
  const plistPath = path.join(appdir, 'Info.plist');
  try {
    const plistData = plist.readFileSync(plistPath);
    const cfBundleExecutable = plistData['CFBundleExecutable'];
    if (cfBundleExecutable) {
      return cfBundleExecutable;
    }
  } catch (e) {
    // do nothing
  }
  const exename = path.basename(appdir);
  const dotap = exename.indexOf('.app');
  return (dotap === -1) ? exename : exename.substring(0, dotap);
}
github KhaosT / HAP-NodeJS / src / lib / gen / importAsClasses.ts View on Github external
import fs from 'fs';
import path from 'path';

import plist from 'simple-plist';

import { Characteristic, Formats, Units } from "../Characteristic";

/**
 * This module is intended to be run from the command line. It is a script that extracts Apple's Service
 * and Characteristic UUIDs and structures from Apple's own HomeKit Accessory Simulator app.
 */

// assumed location of the plist we need (might want to make this a command-line argument at some point)
var plistPath = '/Applications/HomeKit Accessory Simulator.app/Contents/Frameworks/HAPAccessoryKit.framework/Versions/A/Resources/default.metadata.plist';
var metadata = plist.readFileSync(plistPath);

// begin writing the output file
var outputPath = path.join(__dirname, '..', '..', '..', 'src', 'lib', 'gen', 'HomeKitTypes.generated.ts');
var output = fs.createWriteStream(outputPath);

output.write("// THIS FILE IS AUTO-GENERATED - DO NOT MODIFY\n");
output.write("\n");
// output.write("var inherits = require('util').inherits;\n");
output.write("import {\n");
output.write("  Characteristic,\n");
output.write("  CharacteristicProps,\n");
output.write("  Formats,\n");
output.write("  Perms,\n");
output.write("  Units,\n");
output.write("} from '../Characteristic';\n");
output.write("import { Service } from '../Service';\n");
github nowsecure / node-applesign / lib / session.js View on Github external
function getExecutable (appdir, exename) {
  if (appdir) {
    const plistPath = path.join(appdir, 'Info.plist');
    try {
      const plistData = plist.readFileSync(plistPath);
      const cfBundleExecutable = plistData['CFBundleExecutable'];
      if (cfBundleExecutable) {
        return cfBundleExecutable;
      }
    } catch (e) {
      // do nothing
    }
  }
  return exename;
}

simple-plist

A wrapper utility for interacting with plist data.

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis