forked from anihalaney/rwa-trivia
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb30789
commit bf75b82
Showing
3 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
hooks/before-prepare/nativescript-copy-configuration-files.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
}); | ||
}; |
45 changes: 45 additions & 0 deletions
45
hooks/before-watch/nativescript-copy-configuration-files.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
|
||
} | ||
}); | ||
}; |