amplify-frontend-android
Advanced tools
Comparing version 2.16.0-geo.0 to 2.17.0-ext23.0
@@ -6,3 +6,3 @@ # Change Log | ||
# [2.16.0-geo.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-android@2.15.4...amplify-frontend-android@2.16.0-geo.0) (2021-09-21) | ||
# [2.17.0-ext23.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-android@2.15.4...amplify-frontend-android@2.17.0-ext23.0) (2021-11-11) | ||
@@ -12,3 +12,3 @@ | ||
* **amplify-fronted-ios, amplify-frontend-android:** add geo config ([#8237](https://github.com/aws-amplify/amplify-cli/issues/8237)) ([52ac164](https://github.com/aws-amplify/amplify-cli/commit/52ac1645bb157bde29e07344e36b5c3c38484b67)) | ||
* amplify export ([2d0227c](https://github.com/aws-amplify/amplify-cli/commit/2d0227c662fca590a4c6f171808d27b585df1e03)), 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) | ||
@@ -15,0 +15,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, |
@@ -13,3 +13,2 @@ function generateConfig(context, newAWSConfig) { | ||
constructStorage(metadata, amplifyConfig); | ||
constructGeo(metadata, amplifyConfig); | ||
@@ -192,57 +191,4 @@ return amplifyConfig; | ||
function constructGeo(metadata, amplifyConfig) { | ||
const categoryName = 'geo'; | ||
const pluginName = 'awsLocationGeoPlugin'; | ||
if (metadata[categoryName] && Object.keys(metadata[categoryName]).length > 0) { | ||
let defaultMap = ''; | ||
const mapConfig = { | ||
items: {} | ||
}; | ||
let defaultPlaceIndex = ''; | ||
const placeIndexConfig = { | ||
items: [] | ||
}; | ||
Object.keys(metadata[categoryName]).forEach(r => { | ||
const resourceMeta = metadata[categoryName][r]; | ||
if (resourceMeta.output) { | ||
if (resourceMeta.service === 'Map') { | ||
const mapName = resourceMeta.output.Name; | ||
mapConfig.items[mapName] = { | ||
style: resourceMeta.output.Style | ||
} | ||
if(resourceMeta.isDefault === true) { | ||
defaultMap = mapName; | ||
} | ||
} | ||
else if (resourceMeta.service === 'PlaceIndex') { | ||
const placeIndexName = resourceMeta.output.Name; | ||
placeIndexConfig.items.push(placeIndexName); | ||
if(resourceMeta.isDefault === true) { | ||
defaultPlaceIndex = placeIndexName; | ||
} | ||
} | ||
} | ||
}); | ||
mapConfig.default = defaultMap; | ||
placeIndexConfig.default = defaultPlaceIndex; | ||
amplifyConfig[categoryName] = { | ||
plugins: {} | ||
}; | ||
amplifyConfig[categoryName].plugins[pluginName] = { | ||
region: metadata.providers.awscloudformation.Region | ||
}; | ||
if (Object.keys(mapConfig.items).length > 0) { | ||
amplifyConfig[categoryName].plugins[pluginName]['maps'] = mapConfig; | ||
} | ||
if (placeIndexConfig.items.length > 0) { | ||
amplifyConfig[categoryName].plugins[pluginName]['searchIndices'] = placeIndexConfig; | ||
} | ||
} | ||
} | ||
module.exports = { | ||
generateConfig, | ||
}; |
@@ -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.16.0-geo.0", | ||
"version": "2.17.0-ext23.0", | ||
"description": "amplify-cli front-end plugin for Android project", | ||
@@ -23,3 +23,3 @@ "repository": { | ||
}, | ||
"gitHead": "94629517325c7d477fd85c3d5cda4f0123f3e6d1" | ||
"gitHead": "9f024914a3263aeafac2e5e56d23c1e94e625b47" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71333
12
725