From 458848bce4b393bf27e26b9a045681b0e6c99ffa Mon Sep 17 00:00:00 2001 From: Van Date: Sun, 2 Jul 2017 16:48:29 +0800 Subject: [PATCH] update postlink script --- scripts/postlink/postlink.js | 17 ++++++++++++++++- scripts/postunlink/postunlink.js | 8 +++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/postlink/postlink.js b/scripts/postlink/postlink.js index bd659ed..d434865 100644 --- a/scripts/postlink/postlink.js +++ b/scripts/postlink/postlink.js @@ -105,7 +105,7 @@ function addURLTypesForTencentSDK() { plistContents = plist.build(parsedInfoPlist); fs.writeFileSync(plistPath, plistContents); }).then(function(){ - addAppIdToGradle() + addAppIdToPackageJson() }); } } @@ -199,3 +199,18 @@ function addSearchPaths(project, frameworkSearchPath) { }); }; +function addAppIdToPackageJson() { + var packagePath =path.join(__dirname,'../../../','../','./package.json'); + var packageFile = fs.readFileSync(packagePath, "utf8"); + inquirer.prompt([{ + type: "input", + name: "AppID", + message: "What is your Tencent SDK AppID for Android (hit to ignore)" + }]).then(function(answer) { + var key = answer.AppID || "app-id-here"; + package.qq_app_id=key + fs.writeFileSync(packagePath, JSON.stringify(package,null, 2)); + }); +} + + diff --git a/scripts/postunlink/postunlink.js b/scripts/postunlink/postunlink.js index 8ff8dc1..87ae1cb 100644 --- a/scripts/postunlink/postunlink.js +++ b/scripts/postunlink/postunlink.js @@ -32,7 +32,7 @@ removeLinkFunction(); removeAppID(); removeQueriesSchemes(); removeFrameworkAndSearchPath(); - +removeAppIdFromPackageJson(); function removeRCTLinkManagerHeader() { var linkHeaderImportStatement = `#import `; @@ -145,3 +145,9 @@ function removeSearchPaths(project, frameworkSearchPath) { } }); } +function removeAppIdFromPackageJson() { + var packagePath =path.join(__dirname,'../../../','../','./package.json'); + var packageFile = fs.readFileSync(packagePath, "utf8"); + delete package.qq_app_id + fs.writeFileSync(packagePath, JSON.stringify(package, null, 2)); +}