From 21cac172a4b2d86d1c90c4832595fb2a1e8f8477 Mon Sep 17 00:00:00 2001 From: fatme Date: Fri, 23 Mar 2018 12:46:40 +0200 Subject: [PATCH] Fix (publish): Remove binary-plist and use simple-plist instead In case when produced Info.plist is not a binary file, `tns publish ios` command fails because `bplist-parser` is not able to parse non-binary plist files. This PR replaces `bplist-parser` module with `sample-plist` that is able to parse binary and non-binary files. Fixes https://github.com/NativeScript/nativescript-cli/issues/3470 --- lib/common | 2 +- lib/definitions/simple-plist.d.ts | 4 ---- lib/services/ios-project-service.ts | 4 ++-- lib/services/itmstransporter-service.ts | 6 +++--- npm-shrinkwrap.json | 5 ----- package.json | 1 - test/ios-project-service.ts | 1 + 7 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 lib/definitions/simple-plist.d.ts diff --git a/lib/common b/lib/common index c222ae02ed..2b4ee454a1 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit c222ae02edb122f40501bb3f17d18ca5aff7791d +Subproject commit 2b4ee454a17575d3a1bb028fa8df42d78677b823 diff --git a/lib/definitions/simple-plist.d.ts b/lib/definitions/simple-plist.d.ts deleted file mode 100644 index adc559fc81..0000000000 --- a/lib/definitions/simple-plist.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module "simple-plist" { - export function readFile(filePath: string, callback?:(err: Error, obj: any) => void): void; - export function readFileSync(filePath: string): any; -} diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 365aa08448..a6055c3661 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -13,7 +13,6 @@ import * as plist from "plist"; import { IOSProvisionService } from "./ios-provision-service"; import { IOSEntitlementsService } from "./ios-entitlements-service"; import { XCConfigService } from "./xcconfig-service"; -import * as simplePlist from "simple-plist"; import * as mobileprovision from "ios-mobileprovision-finder"; import { SpawnOptions } from "child_process"; import { BUILD_XCCONFIG_FILE_NAME } from "../constants"; @@ -51,6 +50,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ private $xcode: IXcode, private $iOSEntitlementsService: IOSEntitlementsService, private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements, + private $plistParser: IPlistParser, private $sysInfo: ISysInfo, private $xCConfigService: XCConfigService) { super($fs, $projectDataService); @@ -1045,7 +1045,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f this.$errors.failWithoutHelp("The bundle at %s does not contain an Info.plist file.", libraryPath); } - const plistJson = simplePlist.readFileSync(infoPlistPath); + const plistJson = this.$plistParser.parseFileSync(infoPlistPath); const packageType = plistJson["CFBundlePackageType"]; if (packageType !== "FMWK") { diff --git a/lib/services/itmstransporter-service.ts b/lib/services/itmstransporter-service.ts index e60b23da2c..474aea69c0 100644 --- a/lib/services/itmstransporter-service.ts +++ b/lib/services/itmstransporter-service.ts @@ -10,7 +10,7 @@ export class ITMSTransporterService implements IITMSTransporterService { private _itunesConnectApplications: IiTunesConnectApplication[] = null; private _bundleIdentifier: string = null; - constructor(private $bplistParser: IBinaryPlistParser, + constructor(private $plistParser: IPlistParser, private $childProcess: IChildProcess, private $errors: IErrors, private $fs: IFileSystem, @@ -135,8 +135,8 @@ export class ITMSTransporterService implements IITMSTransporterService { } const appFile = path.join(payloadDir, allApps[0]); - const plistObject = await this.$bplistParser.parseFile(path.join(appFile, INFO_PLIST_FILE_NAME)); - const bundleId = plistObject && plistObject[0] && plistObject[0].CFBundleIdentifier; + const plistObject = await this.$plistParser.parseFile(path.join(appFile, INFO_PLIST_FILE_NAME)); + const bundleId = plistObject && plistObject.CFBundleIdentifier; if (!bundleId) { this.$errors.failWithoutHelp(`Unable to determine bundle identifier from ${ipaFileFullPath}.`); } diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index df0cdd4eed..b6af7f5bca 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -434,11 +434,6 @@ "stream-buffers": "2.2.0" } }, - "bplist-parser": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.0.tgz", - "integrity": "sha1-Ywgj8gVkN9Tb78IOhAF/i6xI4Ag=" - }, "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", diff --git a/package.json b/package.json index 28e0b4d7b2..e12acda886 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ ], "dependencies": { "@types/ora": "1.3.2", - "bplist-parser": "0.1.0", "bufferpack": "0.0.6", "byline": "4.2.1", "chalk": "1.1.0", diff --git a/test/ios-project-service.ts b/test/ios-project-service.ts index 8e9a09626c..e860bab8cc 100644 --- a/test/ios-project-service.ts +++ b/test/ios-project-service.ts @@ -120,6 +120,7 @@ function createTestInjector(projectPath: string, projectName: string): IInjector testInjector.register("settingsService", SettingsService); testInjector.register("httpClient", {}); testInjector.register("platformEnvironmentRequirements", {}); + testInjector.register("plistParser", {}); return testInjector; }