本文整理汇总了TypeScript中plist.build函数的典型用法代码示例。如果您正苦于以下问题:TypeScript build函数的具体用法?TypeScript build怎么用?TypeScript build使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: modifyPlist
export default function modifyPlist(vkAppId: string, appDelegatePath: string) {
const plistPath = path.join(path.dirname(appDelegatePath), 'Info.plist');
const plistContents = fs.readFileSync(plistPath, 'utf8');
const plistJson = plist.parse(plistContents);
const schemes: string[] = plistJson.LSApplicationQueriesSchemes || [];
if (schemes.indexOf('vk') === -1) {
schemes.push('vk');
}
if (schemes.indexOf('vk-share') === -1) {
schemes.push('vk-share');
}
if (schemes.indexOf('vkauthorize') === -1) {
schemes.push('vkauthorize');
}
plistJson.LSApplicationQueriesSchemes = schemes;
let urlTypes: BundleURLType[] = plistJson.CFBundleURLTypes || [];
// remove all existing VK url types
const urlType = `vk${vkAppId}`;
urlTypes = urlTypes.filter(ut => !/vk\d+/.test(ut.CFBundleURLName));
urlTypes.push({ CFBundleTypeRole: 'Editor', CFBundleURLName: urlType, CFBundleURLSchemes: [urlType] });
plistJson.CFBundleURLTypes = urlTypes;
const newPlistContents = plist.build(plistJson);
fs.writeFileSync(plistPath, newPlistContents);
}
示例2: checkArgs
(async () => {
const command = await checkArgs();
if (command === Commands.Install) {
const userOptions = {
...(await (async () => {
console.log(getIntro());
return inquire();
})())
};
const label = 'us.shick.arrivals';
const plistPath = untildify(`~/Library/LaunchAgents/${label}.plist`);
const logPath = untildify(`~/Library/Logs/${label}`);
const outLogPath = path.resolve(logPath, 'arrivals.log');
const errLogPath = path.resolve(logPath, 'arrivals_error.log');
const execPath = process.execPath;
const scriptPath = path.resolve(__dirname, '../wrapper.js');
const workingDirectory = path.resolve(__dirname, '../../../');
const tpl = {
EnvironmentVariables: userOptions,
KeepAlive: false,
Label: label,
ProgramArguments: [execPath, scriptPath],
RunAtLoad: true,
StandardErrorPath: errLogPath,
StandardOutPath: outLogPath,
WorkingDirectory: workingDirectory
};
const plistData = plist.build(tpl).toString();
mkdirp.sync(logPath);
touch(outLogPath);
touch(errLogPath);
writeFileSync(plistPath, plistData);
try {
await execPromise(`launchctl load ${plistPath}`);
logger.info('launchdaemon loaded');
} catch (err) {
logger.error('Could not start: %s', err.message);
}
} else {
watch()
.then(() => {
logger.info('Arrivals has started!');
})
.catch(err => {
logger.error(err);
});
}
})().catch((err: Error) => {
示例3: build
private build(destinationLanguage: SupportedLanguage, parsed: any): string {
switch (destinationLanguage) {
case "xml":
case "tmlanguage":
return plist.build(parsed);
case "json":
case "json-tmlanguage":
return json.plain(parsed);
case "yaml":
case "yaml-tmlanguage":
return YAML.stringify(parsed, 6);
default:
return undefined;
}
}
示例4: f
function f(a: ReadonlyArray<string>) {
plist.build(a);
}
示例5: createApp
export async function createApp(opts: ElectronPackagerOptions, appOutDir: string, initializeApp: () => Promise<any>) {
const appInfo = opts.appInfo
const appFilename = appInfo.productFilename
const contentsPath = path.join(appOutDir, "Electron.app", "Contents")
const frameworksPath = path.join(contentsPath, "Frameworks")
const appPlistFilename = path.join(contentsPath, "Info.plist")
const helperPlistFilename = path.join(frameworksPath, "Electron Helper.app", "Contents", "Info.plist")
const helperEHPlistFilename = path.join(frameworksPath, "Electron Helper EH.app", "Contents", "Info.plist")
const helperNPPlistFilename = path.join(frameworksPath, "Electron Helper NP.app", "Contents", "Info.plist")
const result = await BluebirdPromise.all<any | n>([
initializeApp(),
BluebirdPromise.map<any | null>([appPlistFilename, helperPlistFilename, helperEHPlistFilename, helperNPPlistFilename, opts["extend-info"]], it => it == null ? it : readFile(it, "utf8"))
])
const fileContents: Array<string> = result[1]!
const appPlist = parsePlist(fileContents[0])
const helperPlist = parsePlist(fileContents[1])
const helperEHPlist = parsePlist(fileContents[2])
const helperNPPlist = parsePlist(fileContents[3])
// If an extend-info file was supplied, copy its contents in first
if (fileContents[4] != null) {
Object.assign(appPlist, parsePlist(fileContents[4]))
}
// Now set fields based on explicit options
const appBundleIdentifier = filterCFBundleIdentifier(appInfo.id)
const helperBundleIdentifier = filterCFBundleIdentifier(opts["helper-bundle-id"] || `${appBundleIdentifier}.helper`)
const buildVersion = appInfo.buildVersion
const appCategoryType = opts["app-category-type"]
const humanReadableCopyright = appInfo.copyright
appPlist.CFBundleDisplayName = appInfo.productName
appPlist.CFBundleIdentifier = appBundleIdentifier
appPlist.CFBundleName = appInfo.productName
helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
helperPlist.CFBundleIdentifier = helperBundleIdentifier
appPlist.CFBundleExecutable = appFilename
helperPlist.CFBundleName = appInfo.productName
helperPlist.CFBundleExecutable = `${appFilename} Helper`
helperEHPlist.CFBundleDisplayName = `${appFilename} Helper EH`
helperEHPlist.CFBundleIdentifier = `${helperBundleIdentifier}.EH`
helperEHPlist.CFBundleName = `${appInfo.productName} Helper EH`
helperEHPlist.CFBundleExecutable = `${appFilename} Helper EH`
helperNPPlist.CFBundleDisplayName = `${appInfo.productName} Helper NP`
helperNPPlist.CFBundleIdentifier = `${helperBundleIdentifier}.NP`
helperNPPlist.CFBundleName = `${appInfo.productName} Helper NP`
helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`
if (appInfo.version != null) {
appPlist.CFBundleShortVersionString = appPlist.CFBundleVersion = appInfo.version
}
if (buildVersion != null) {
appPlist.CFBundleVersion = buildVersion
}
if (opts.protocols && opts.protocols.length) {
appPlist.CFBundleURLTypes = opts.protocols.map(function (protocol: any) {
return {
CFBundleURLName: protocol.name,
CFBundleURLSchemes: [].concat(protocol.schemes)
}
})
}
if (appCategoryType) {
appPlist.LSApplicationCategoryType = appCategoryType
}
if (humanReadableCopyright) {
appPlist.NSHumanReadableCopyright = humanReadableCopyright
}
const promises: Array<BluebirdPromise<any | n>> = [
writeFile(appPlistFilename, buildPlist(appPlist)),
writeFile(helperPlistFilename, buildPlist(helperPlist)),
writeFile(helperEHPlistFilename, buildPlist(helperEHPlist)),
writeFile(helperNPPlistFilename, buildPlist(helperNPPlist)),
doRename(path.join(contentsPath, "MacOS"), "Electron", appPlist.CFBundleExecutable)
]
if (opts.icon != null) {
promises.push(copy(opts.icon, path.join(contentsPath, "Resources", appPlist.CFBundleIconFile)))
}
await BluebirdPromise.all(promises)
await moveHelpers(frameworksPath, appFilename)
await rename(path.dirname(contentsPath), path.join(appOutDir, `${appFilename}.app`))
}
示例6: createMacApp
export async function createMacApp(packager: PlatformPackager<any>, appOutDir: string, asarIntegrity: AsarIntegrity | null) {
const appInfo = packager.appInfo
const appFilename = appInfo.productFilename
const contentsPath = path.join(appOutDir, packager.electronDistMacOsAppName, "Contents")
const frameworksPath = path.join(contentsPath, "Frameworks")
const appPlistFilename = path.join(contentsPath, "Info.plist")
const helperPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper.app`, "Contents", "Info.plist")
const helperEHPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper EH.app`, "Contents", "Info.plist")
const helperNPPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper NP.app`, "Contents", "Info.plist")
const buildMetadata = packager.config!
const fileContents: Array<string> = await BluebirdPromise.map([appPlistFilename, helperPlistFilename, helperEHPlistFilename, helperNPPlistFilename, (buildMetadata as any)["extend-info"]], it => it == null ? it : readFile(it, "utf8"))
const appPlist = parsePlist(fileContents[0])
const helperPlist = parsePlist(fileContents[1])
const helperEHPlist = parsePlist(fileContents[2])
const helperNPPlist = parsePlist(fileContents[3])
// If an extend-info file was supplied, copy its contents in first
if (fileContents[4] != null) {
Object.assign(appPlist, parsePlist(fileContents[4]))
}
const macOptions = buildMetadata.mac || {}
if (macOptions.extendInfo != null) {
Object.assign(appPlist, macOptions.extendInfo)
}
const appBundleIdentifier = filterCFBundleIdentifier(appInfo.id)
const oldHelperBundleId = (buildMetadata as any)["helper-bundle-id"]
if (oldHelperBundleId != null) {
log.warn("build.helper-bundle-id is deprecated, please set as build.mac.helperBundleId")
}
const helperBundleIdentifier = filterCFBundleIdentifier(packager.platformSpecificBuildOptions.helperBundleId || oldHelperBundleId || `${appBundleIdentifier}.helper`)
const icon = await packager.getIconPath()
const oldIcon = appPlist.CFBundleIconFile
if (icon != null) {
appPlist.CFBundleIconFile = `${appFilename}.icns`
}
appPlist.CFBundleDisplayName = appInfo.productName
appPlist.CFBundleIdentifier = appBundleIdentifier
appPlist.CFBundleName = appInfo.productName
// https://github.com/electron-userland/electron-builder/issues/1278
appPlist.CFBundleExecutable = !appFilename.endsWith(" Helper") ? appFilename : appFilename.substring(0, appFilename.length - " Helper".length)
helperPlist.CFBundleExecutable = `${appFilename} Helper`
helperEHPlist.CFBundleExecutable = `${appFilename} Helper EH`
helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`
helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
helperEHPlist.CFBundleDisplayName = `${appInfo.productName} Helper EH`
helperNPPlist.CFBundleDisplayName = `${appInfo.productName} Helper NP`
helperPlist.CFBundleIdentifier = helperBundleIdentifier
helperEHPlist.CFBundleIdentifier = `${helperBundleIdentifier}.EH`
helperNPPlist.CFBundleIdentifier = `${helperBundleIdentifier}.NP`
appPlist.CFBundleShortVersionString = macOptions.bundleShortVersion || appInfo.version
appPlist.CFBundleVersion = appInfo.buildVersion
const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))
if (protocols.length > 0) {
appPlist.CFBundleURLTypes = protocols.map(protocol => {
const schemes = asArray(protocol.schemes)
if (schemes.length === 0) {
throw new Error(`Protocol "${protocol.name}": must be at least one scheme specified`)
}
return {
CFBundleURLName: protocol.name,
CFBundleTypeRole: protocol.role || "Editor",
CFBundleURLSchemes: schemes.slice()
}
})
}
const resourcesPath = path.join(contentsPath, "Resources")
const fileAssociations = packager.fileAssociations
if (fileAssociations.length > 0) {
appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
const extensions = asArray(fileAssociation.ext).map(normalizeExt)
const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)
let iconFile = appPlist.CFBundleIconFile
if (customIcon != null) {
iconFile = path.basename(customIcon)
await copyOrLinkFile(customIcon, path.join(resourcesPath, iconFile))
}
const result = {
CFBundleTypeExtensions: extensions,
CFBundleTypeName: fileAssociation.name || extensions[0],
CFBundleTypeRole: fileAssociation.role || "Editor",
CFBundleTypeIconFile: iconFile
} as any
//.........这里部分代码省略.........
示例7: stringify
stringify(content: any): string {
return plist.build(content);
}
示例8: createMacApp
export async function createMacApp(packager: MacPackager, appOutDir: string, asarIntegrity: AsarIntegrity | null, isMas: boolean) {
const appInfo = packager.appInfo
const appFilename = appInfo.productFilename
const contentsPath = path.join(appOutDir, packager.info.framework.distMacOsAppName, "Contents")
const frameworksPath = path.join(contentsPath, "Frameworks")
const loginItemPath = path.join(contentsPath, "Library", "LoginItems")
const appPlistFilename = path.join(contentsPath, "Info.plist")
const helperPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper.app`, "Contents", "Info.plist")
const helperEHPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper EH.app`, "Contents", "Info.plist")
const helperNPPlistFilename = path.join(frameworksPath, `${packager.electronDistMacOsExecutableName} Helper NP.app`, "Contents", "Info.plist")
const helperLoginPlistFilename = path.join(loginItemPath, `${packager.electronDistMacOsExecutableName} Login Helper.app`, "Contents", "Info.plist")
const buildMetadata = packager.config!
const fileContents: Array<string | null> = await BluebirdPromise.map([
appPlistFilename,
helperPlistFilename,
helperEHPlistFilename,
helperNPPlistFilename,
helperLoginPlistFilename,
(buildMetadata as any)["extend-info"]
], it => it == null ? it : orIfFileNotExist(readFile(it, "utf8"), null))
const appPlist = parsePlist(fileContents[0]!!)
const helperPlist = parsePlist(fileContents[1]!!)
const helperEHPlist = fileContents[2] == null ? null : parsePlist(fileContents[2]!!)
const helperNPPlist = fileContents[3] == null ? null : parsePlist(fileContents[3]!!)
const helperLoginPlist = fileContents[4] == null ? null : parsePlist(fileContents[4]!!)
// if an extend-info file was supplied, copy its contents in first
if (fileContents[5] != null) {
Object.assign(appPlist, parsePlist(fileContents[5]!!))
}
const oldHelperBundleId = (buildMetadata as any)["helper-bundle-id"]
if (oldHelperBundleId != null) {
log.warn("build.helper-bundle-id is deprecated, please set as build.mac.helperBundleId")
}
const helperBundleIdentifier = filterCFBundleIdentifier(packager.platformSpecificBuildOptions.helperBundleId || oldHelperBundleId || `${appInfo.macBundleIdentifier}.helper`)
await packager.applyCommonInfo(appPlist, contentsPath)
// required for electron-updater proxy
if (!isMas) {
configureLocalhostAts(appPlist)
}
helperPlist.CFBundleExecutable = `${appFilename} Helper`
helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
helperPlist.CFBundleIdentifier = helperBundleIdentifier
helperPlist.CFBundleVersion = appPlist.CFBundleVersion
function configureHelper(helper: any, postfix: string) {
helper.CFBundleExecutable = `${appFilename} Helper ${postfix}`
helper.CFBundleDisplayName = `${appInfo.productName} Helper ${postfix}`
helper.CFBundleIdentifier = `${helperBundleIdentifier}.${postfix}`
helper.CFBundleVersion = appPlist.CFBundleVersion
}
if (helperEHPlist != null) {
configureHelper(helperEHPlist, "EH")
}
if (helperNPPlist != null) {
configureHelper(helperNPPlist, "NP")
}
if (helperLoginPlist != null) {
helperLoginPlist.CFBundleExecutable = `${appFilename} Login Helper`
helperLoginPlist.CFBundleDisplayName = `${appInfo.productName} Login Helper`
// noinspection SpellCheckingInspection
helperLoginPlist.CFBundleIdentifier = `${appInfo.macBundleIdentifier}.loginhelper`
helperLoginPlist.CFBundleVersion = appPlist.CFBundleVersion
}
const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))
if (protocols.length > 0) {
appPlist.CFBundleURLTypes = protocols.map(protocol => {
const schemes = asArray(protocol.schemes)
if (schemes.length === 0) {
throw new InvalidConfigurationError(`Protocol "${protocol.name}": must be at least one scheme specified`)
}
return {
CFBundleURLName: protocol.name,
CFBundleTypeRole: protocol.role || "Editor",
CFBundleURLSchemes: schemes.slice()
}
})
}
const fileAssociations = packager.fileAssociations
if (fileAssociations.length > 0) {
appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
const extensions = asArray(fileAssociation.ext).map(normalizeExt)
const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)
let iconFile = appPlist.CFBundleIconFile
if (customIcon != null) {
iconFile = path.basename(customIcon)
await copyOrLinkFile(customIcon, path.join(path.join(contentsPath, "Resources"), iconFile))
}
const result = {
//.........这里部分代码省略.........