From bf75b82b5d73b3ecfd3295a60d2e1fbc17177662 Mon Sep 17 00:00:00 2001 From: yugank1991 Date: Tue, 13 Aug 2019 14:14:14 +0530 Subject: [PATCH] updated the files --- firebase-rules.json | 6 +-- .../nativescript-copy-configuration-files.js | 46 +++++++++++++++++++ .../nativescript-copy-configuration-files.js | 45 ++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 hooks/before-prepare/nativescript-copy-configuration-files.js create mode 100644 hooks/before-watch/nativescript-copy-configuration-files.js diff --git a/firebase-rules.json b/firebase-rules.json index 7f3a9f236..b46e714c2 100644 --- a/firebase-rules.json +++ b/firebase-rules.json @@ -1,10 +1,10 @@ { "rules": { - ".read": "auth != null", - ".write": "auth != null", + ".read": "auth !== null", + ".write": "auth !== null", "users":{ "$token_id":{ - ".read": "auth.uid!== null", + ".read": "auth.uid !== null && data.child('userId').val() === auth.uid", ".write": "newData.child('userId').val() === auth.uid" } } diff --git a/hooks/before-prepare/nativescript-copy-configuration-files.js b/hooks/before-prepare/nativescript-copy-configuration-files.js new file mode 100644 index 000000000..48446d107 --- /dev/null +++ b/hooks/before-prepare/nativescript-copy-configuration-files.js @@ -0,0 +1,46 @@ +var nativeScriptConfig = require("./../../custom-hooks/nativescript-copy-configuration-files"); +module.exports = function ($logger, $projectData, hookArgs) { + return new Promise(function (resolve, reject) { + /* Decide whether to prepare for dev or prod environment */ + + var isReleaseBuild = (hookArgs.appFilesUpdaterOptions && hookArgs.appFilesUpdaterOptions.release) ? true : false; + if (isReleaseBuild) { + var validProdEnvs = ['prod', 'production']; + var isProdEnv = false; // building with --env.prod or --env.production flag + + if (hookArgs.platformSpecificData.env) { + Object.keys(hookArgs.platformSpecificData.env).forEach((key) => { + if (validProdEnvs.indexOf(key) > -1) { isProdEnv = true; } + }); + } + + var buildType = isProdEnv ? 'production' : 'development'; + + /* Handle preparing of Android xml files */ + + if (hookArgs.platform.toLowerCase() === 'android') { + + nativeScriptConfig.copyAndroidConfig($projectData.appResourcesDirectoryPath, // appResourcesDirPath + $projectData.projectDir, // projectDir + hookArgs.platformSpecificData.env.project, // projectName + buildType, //buildType + $logger); + resolve(); + + } else { + nativeScriptConfig.copyIosConfig($projectData.appResourcesDirectoryPath, // appResourcesDirPath + $projectData.projectDir, // projectDir + hookArgs.platformSpecificData.env.project, // projectName + buildType, //buildType + $logger, + hookArgs.platform.toLowerCase(), + $projectData.platformsDir, // platformsDir + isProdEnv); + resolve(); + } + + } else { + resolve(); + } + }); +}; \ No newline at end of file diff --git a/hooks/before-watch/nativescript-copy-configuration-files.js b/hooks/before-watch/nativescript-copy-configuration-files.js new file mode 100644 index 000000000..7e36d4769 --- /dev/null +++ b/hooks/before-watch/nativescript-copy-configuration-files.js @@ -0,0 +1,45 @@ +var nativeScriptConfig = require("./../../custom-hooks/nativescript-copy-configuration-files"); +module.exports = function ($logger, $projectData, hookArgs) { + return new Promise(function (resolve, reject) { + + /* Decide whether to prepare for dev or prod environment */ + var env = (hookArgs.platformSpecificData || hookArgs.prepareData).env; + // var isReleaseBuild = (hookArgs.appFilesUpdaterOptions && hookArgs.appFilesUpdaterOptions.release) ? true : false; + + const platformFromHookArgs = hookArgs && (hookArgs.platform || (hookArgs.prepareData && hookArgs.prepareData.platform)); + const platform = (platformFromHookArgs || '').toLowerCase(); + var validProdEnvs = ['prod', 'production']; + var isProdEnv = false; // building with --env.prod or --env.production flag + + if (env) { + Object.keys(env).forEach((key) => { + if (validProdEnvs.indexOf(key) > -1) { isProdEnv = true; } + }); + } + + var buildType = isProdEnv ? 'production' : 'development'; + + /* Handle preparing of Android xml files */ + + if (platform === 'android') { + nativeScriptConfig.copyAndroidConfig($projectData.appResourcesDirectoryPath, // appResourcesDirPath + $projectData.projectDir, // projectDir + env.project, // projectName + buildType, //buildType + $logger); + resolve(); + } else { + + nativeScriptConfig.copyIosConfig($projectData.appResourcesDirectoryPath, // appResourcesDirPath + $projectData.projectDir, // projectDir + env.project, // projectName + buildType, //buildType + $logger, + platform, + $projectData.platformsDir, // platformsDir + isProdEnv); + resolve(); + + } + }); +};