Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit a82dc44

Browse files
committed
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 NativeScript/nativescript-cli#3470
1 parent c222ae0 commit a82dc44

8 files changed

+38
-26
lines changed

bootstrap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ $injector.requireCommand("proxy|set", "./commands/proxy/proxy-set");
103103
$injector.requireCommand("proxy|clear", "./commands/proxy/proxy-clear");
104104

105105
$injector.require("utils", "./utils");
106-
$injector.require("bplistParser", "./bplist-parser");
106+
$injector.require("plistParser", "./plist-parser");
107107
$injector.require("winreg", "./winreg");
108108

109109
$injector.require("loggingLevels", "./mobile/logging-levels");

bplist-parser.ts

-17
This file was deleted.

declarations.d.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1365,8 +1365,17 @@ interface IUtils {
13651365
getMilliSecondsTimeout(defaultTimeout: number): number;
13661366
}
13671367

1368-
interface IBinaryPlistParser {
1368+
/**
1369+
* Used for parsing of .plist files
1370+
*/
1371+
interface IPlistParser {
1372+
/**
1373+
* Parses the .plist file and returns the result as object
1374+
* @param {string} plistFilePath Absolute path to .plist file
1375+
* @return {Promise<any>} The parsed object
1376+
*/
13691377
parseFile(plistFilePath: string): Promise<any>;
1378+
parseFileSync(plistFilePath: string): any;
13701379
}
13711380

13721381
interface IUserSettingsService extends UserSettings.IUserSettingsService {

definitions/bplist-parser.d.ts

-4
This file was deleted.

definitions/simple-plist.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "simple-plist" {
2+
export function readFile(filePath: string, callback?:(err: Error, obj: any) => void): void;
3+
export function readFileSync(filePath: string): any;
4+
}

mobile/ios/simulator/ios-simulator-application-manager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase {
88
private identifier: string,
99
private $options: ICommonOptions,
1010
private $fs: IFileSystem,
11-
private $bplistParser: IBinaryPlistParser,
11+
private $plistParser: IPlistParser,
1212
private $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider,
1313
private $deviceLogProvider: Mobile.IDeviceLogProvider,
1414
$logger: ILogger,
@@ -90,7 +90,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase {
9090
const applicationPath = this.iosSim.getApplicationPath(this.identifier, appIdentifier),
9191
pathToInfoPlist = path.join(applicationPath, "Info.plist");
9292

93-
return this.$fs.exists(pathToInfoPlist) ? (await this.$bplistParser.parseFile(pathToInfoPlist))[0] : null;
93+
return this.$fs.exists(pathToInfoPlist) ? await this.$plistParser.parseFile(pathToInfoPlist) : null;
9494
}
9595

9696
public async getDebuggableApps(): Promise<Mobile.IDeviceApplicationInformation[]> {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"Proton"
2727
],
2828
"dependencies": {
29-
"bplist-parser": "0.0.6",
3029
"bufferpack": "0.0.6",
3130
"byline": "4.2.1",
3231
"chalk": "1.0.0",
@@ -63,6 +62,7 @@
6362
"rimraf": "2.2.6",
6463
"semver": "5.3.0",
6564
"shelljs": "0.7.5",
65+
"simple-plist": "0.2.1",
6666
"source-map": "0.5.6",
6767
"tabtab": "https://github.com/Icenium/node-tabtab/tarball/master",
6868
"temp": "0.8.1",

plist-parser.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as simplePlist from "simple-plist";
2+
3+
export class PlistParser implements IPlistParser {
4+
public parseFile(plistFilePath: string): Promise<any> {
5+
return new Promise<any>((resolve, reject) => {
6+
simplePlist.readFile(plistFilePath, (err: Error, obj: any) => {
7+
if (err) {
8+
reject(err);
9+
} else {
10+
resolve(obj);
11+
}
12+
});
13+
});
14+
}
15+
16+
public parseFileSync(plistFilePath: string): any {
17+
return simplePlist.readFileSync(plistFilePath);
18+
}
19+
}
20+
$injector.register("plistParser", PlistParser);

0 commit comments

Comments
 (0)