amplify-frontend-android
Advanced tools
Comparing version 2.15.5-ext.0 to 2.16.0-ext11.0
@@ -6,10 +6,13 @@ # Change Log | ||
## [2.15.5-ext.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-android@2.15.3...amplify-frontend-android@2.15.5-ext.0) (2021-08-20) | ||
# [2.16.0-ext11.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-android@2.15.4...amplify-frontend-android@2.16.0-ext11.0) (2021-11-03) | ||
**Note:** Version bump only for package amplify-frontend-android | ||
### Features | ||
* amplify export ([67ecb2d](https://github.com/aws-amplify/amplify-cli/commit/67ecb2dfd9be4549700e9dc64db0f27de34d8990)), closes [#8547](https://github.com/aws-amplify/amplify-cli/issues/8547) [#8488](https://github.com/aws-amplify/amplify-cli/issues/8488) [#8486](https://github.com/aws-amplify/amplify-cli/issues/8486) [#8547](https://github.com/aws-amplify/amplify-cli/issues/8547) [#8488](https://github.com/aws-amplify/amplify-cli/issues/8488) [#8486](https://github.com/aws-amplify/amplify-cli/issues/8486) | ||
## [2.15.4](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-android@2.15.3...amplify-frontend-android@2.15.4) (2021-08-06) | ||
@@ -16,0 +19,0 @@ |
27
index.js
@@ -7,3 +7,10 @@ const path = require('path'); | ||
const constants = require('./lib/constants'); | ||
const { createAmplifyConfig, createAWSConfig, deleteAmplifyConfig } = require('./lib/frontend-config-creator'); | ||
const { | ||
createAmplifyConfig, | ||
getAmplifyConfig, | ||
createAWSConfig, | ||
getNewAWSConfigObject, | ||
deleteAmplifyConfig, | ||
writeToFile, | ||
} = require('./lib/frontend-config-creator'); | ||
@@ -23,3 +30,20 @@ const pluginName = 'android'; | ||
} | ||
/** | ||
* This function enables export to write these files to an external path | ||
* @param {TSContext} context | ||
* @param {metaWithOutput} amplifyResources | ||
* @param {cloudMetaWithOuput} amplifyCloudResources | ||
* @param {string} exportPath path to where the files need to be written | ||
*/ | ||
function createFrontendConfigsAtPath(context, amplifyResources, amplifyCloudResources, exportPath) { | ||
const newOutputsForFrontend = amplifyResources.outputsForFrontend; | ||
const cloudOutputsForFrontend = amplifyCloudResources.outputsForFrontend; | ||
const amplifyConfig = getAmplifyConfig(context, newOutputsForFrontend, cloudOutputsForFrontend); | ||
writeToFile(exportPath, constants.amplifyConfigFilename, amplifyConfig); | ||
const awsConfig = getNewAWSConfigObject(context, newOutputsForFrontend, cloudOutputsForFrontend); | ||
writeToFile(exportPath, constants.awsConfigFilename, awsConfig); | ||
} | ||
function createFrontendConfigs(context, amplifyResources, amplifyCloudResources) { | ||
@@ -78,2 +102,3 @@ const newOutputsForFrontend = amplifyResources.outputsForFrontend; | ||
createFrontendConfigs, | ||
createFrontendConfigsAtPath, | ||
displayFrontendDefaults, | ||
@@ -80,0 +105,0 @@ setFrontendDefaults, |
@@ -58,18 +58,21 @@ const constants = require('./constants'); | ||
function createAmplifyConfig(context, amplifyResources, cloudAmplifyResources) { | ||
const { amplify } = context; | ||
const projectPath = context.exeInfo ? context.exeInfo.localEnvInfo.projectPath : amplify.getEnvInfo().projectPath; | ||
const projectConfig = context.exeInfo ? context.exeInfo.projectConfig[constants.Label] : amplify.getProjectConfig()[constants.Label]; | ||
const frontendConfig = projectConfig.config; | ||
const srcDirPath = path.join(projectPath, frontendConfig.ResDir, 'raw'); | ||
const srcDirPath = getSrcDir(context).srcDirPath; | ||
fs.ensureDirSync(srcDirPath); | ||
// Native GA release requires entire awsconfiguration inside amplifyconfiguration auth plugin | ||
const amplifyConfig = getAmplifyConfig(context, amplifyResources, cloudAmplifyResources); | ||
const targetFilePath = path.join(srcDirPath, constants.amplifyConfigFilename); | ||
writeToFile(srcDirPath, constants.amplifyConfigFilename, amplifyConfig); | ||
} | ||
// Native GA release requires entire awsconfiguration inside amplifyconfiguration auth plugin | ||
function writeToFile(filePath, fileName, configObject) { | ||
fs.ensureDirSync(filePath); | ||
const targetFilePath = path.join(filePath, fileName); | ||
const jsonString = JSON.stringify(configObject, null, 4); | ||
fs.writeFileSync(targetFilePath, jsonString, 'utf8'); | ||
} | ||
function getAmplifyConfig(context, amplifyResources, cloudAmplifyResources) { | ||
const newAWSConfig = getNewAWSConfigObject(context, amplifyResources, cloudAmplifyResources); | ||
const amplifyConfig = amplifyConfigHelper.generateConfig(context, newAWSConfig); | ||
const jsonString = JSON.stringify(amplifyConfig, null, 4); | ||
fs.writeFileSync(targetFilePath, jsonString, 'utf8'); | ||
return amplifyConfig; | ||
} | ||
@@ -141,11 +144,15 @@ | ||
const projectConfig = context.exeInfo ? context.exeInfo.projectConfig[constants.Label] : amplify.getProjectConfig()[constants.Label]; | ||
const frontendConfig = projectConfig.config; | ||
const srcDirPath = path.join(projectPath, frontendConfig.ResDir, 'raw'); | ||
const targetFilePath = path.join(srcDirPath, constants.awsConfigFilename); | ||
let awsConfig = {}; | ||
if (fs.existsSync(targetFilePath)) { | ||
awsConfig = amplify.readJsonFile(targetFilePath); | ||
if (projectConfig) { | ||
const frontendConfig = projectConfig.config; | ||
const srcDirPath = path.join(projectPath, frontendConfig.ResDir, 'raw'); | ||
const targetFilePath = path.join(srcDirPath, constants.awsConfigFilename); | ||
if (fs.existsSync(targetFilePath)) { | ||
awsConfig = amplify.readJsonFile(targetFilePath); | ||
} | ||
} | ||
return awsConfig; | ||
@@ -165,13 +172,4 @@ } | ||
function generateAWSConfigFile(context, configOutput) { | ||
const { amplify } = context; | ||
const projectPath = context.exeInfo ? context.exeInfo.localEnvInfo.projectPath : amplify.getEnvInfo().projectPath; | ||
const projectConfig = context.exeInfo ? context.exeInfo.projectConfig[constants.Label] : amplify.getProjectConfig()[constants.Label]; | ||
const frontendConfig = projectConfig.config; | ||
const srcDirPath = path.join(projectPath, frontendConfig.ResDir, 'raw'); | ||
fs.ensureDirSync(srcDirPath); | ||
const targetFilePath = path.join(srcDirPath, constants.awsConfigFilename); | ||
const jsonString = JSON.stringify(configOutput, null, 4); | ||
fs.writeFileSync(targetFilePath, jsonString, 'utf8'); | ||
const { srcDirPath } = getSrcDir(context); | ||
writeToFile(srcDirPath, constants.awsConfigFilename, configOutput); | ||
} | ||
@@ -397,2 +395,2 @@ | ||
module.exports = { createAWSConfig, createAmplifyConfig, deleteAmplifyConfig }; | ||
module.exports = { createAWSConfig, getNewAWSConfigObject, createAmplifyConfig, getAmplifyConfig, deleteAmplifyConfig, writeToFile }; |
{ | ||
"name": "amplify-frontend-android", | ||
"version": "2.15.5-ext.0", | ||
"version": "2.16.0-ext11.0", | ||
"description": "amplify-cli front-end plugin for Android project", | ||
@@ -23,3 +23,3 @@ "repository": { | ||
}, | ||
"gitHead": "6d0282a77f5e4a200d8b2b76e227863d21ec9d33" | ||
"gitHead": "e2ba7d8fe44f14db1ff37f64eca4a8e3e0750691" | ||
} |
71333
725