Skip to content

Commit

Permalink
Merge branch 'master' into migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Hajdrik authored Sep 25, 2020
2 parents 806df65 + c630145 commit 31a0e3f
Show file tree
Hide file tree
Showing 112 changed files with 2,250 additions and 962 deletions.
214 changes: 146 additions & 68 deletions .circleci/config.yml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/amplify-app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.17.13](https://github.com/aws-amplify/amplify-cli/compare/amplify-app@2.17.12...amplify-app@2.17.13) (2020-09-25)

**Note:** Version bump only for package amplify-app





## [2.17.12](https://github.com/aws-amplify/amplify-cli/compare/amplify-app@2.17.11...amplify-app@2.17.12) (2020-09-16)

**Note:** Version bump only for package amplify-app
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-app",
"version": "2.17.12",
"version": "2.17.13",
"description": "Amplify CLI",
"repository": {
"type": "git",
Expand Down Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"amplify-frontend-android": "2.13.4",
"amplify-frontend-ios": "2.13.8",
"amplify-frontend-javascript": "2.16.3",
"amplify-frontend-javascript": "2.16.4",
"chalk": "^3.0.0",
"fs-extra": "^8.1.0",
"graphql": "^14.5.8",
Expand Down
11 changes: 11 additions & 0 deletions packages/amplify-category-analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.17.16](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-analytics@2.17.15...amplify-category-analytics@2.17.16) (2020-09-25)


### Bug Fixes

* data inconsitency ([#5344](https://github.com/aws-amplify/amplify-cli/issues/5344)) ([bfe1903](https://github.com/aws-amplify/amplify-cli/commit/bfe19038b5b676056f45d7ffcc4c2460057936d8))





## [2.17.15](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-analytics@2.17.14...amplify-category-analytics@2.17.15) (2020-09-16)

**Note:** Version bump only for package amplify-category-analytics
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-category-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-category-analytics",
"version": "2.17.15",
"version": "2.17.16",
"description": "amplify-cli analytics plugin",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,7 @@
"aws"
],
"dependencies": {
"amplify-category-auth": "2.19.1",
"amplify-category-auth": "2.20.0",
"fs-extra": "^8.1.0",
"inquirer": "^7.0.3",
"open": "^7.0.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/amplify-category-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.23.9](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-api@2.23.8...amplify-category-api@2.23.9) (2020-09-25)


### Bug Fixes

* data inconsitency ([#5344](https://github.com/aws-amplify/amplify-cli/issues/5344)) ([bfe1903](https://github.com/aws-amplify/amplify-cli/commit/bfe19038b5b676056f45d7ffcc4c2460057936d8))





## [2.23.8](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-api@2.23.7...amplify-category-api@2.23.8) (2020-09-16)


Expand Down
8 changes: 4 additions & 4 deletions packages/amplify-category-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-category-api",
"version": "2.23.8",
"version": "2.23.9",
"description": "amplify-cli api plugin",
"repository": {
"type": "git",
Expand All @@ -17,9 +17,9 @@
},
"dependencies": {
"@graphql-tools/merge": "^6.0.18",
"amplify-category-auth": "2.19.1",
"amplify-category-function": "2.25.0",
"amplify-util-headless-input": "1.2.1",
"amplify-category-auth": "2.20.0",
"amplify-category-function": "2.25.1",
"amplify-util-headless-input": "1.3.0",
"chalk": "^3.0.0",
"fs-extra": "^8.1.0",
"graphql": "^14.5.8",
Expand Down
16 changes: 16 additions & 0 deletions packages/amplify-category-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.20.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-auth@2.19.1...amplify-category-auth@2.20.0) (2020-09-25)


### Bug Fixes

* data inconsitency ([#5344](https://github.com/aws-amplify/amplify-cli/issues/5344)) ([bfe1903](https://github.com/aws-amplify/amplify-cli/commit/bfe19038b5b676056f45d7ffcc4c2460057936d8))


### Features

* headless update auth ([#5308](https://github.com/aws-amplify/amplify-cli/issues/5308)) ([b942f35](https://github.com/aws-amplify/amplify-cli/commit/b942f3589f1df1361ae7eb6e42f18dbf6900d1bf))





## [2.19.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-auth@2.19.0...amplify-category-auth@2.19.1) (2020-09-16)


Expand Down
10 changes: 5 additions & 5 deletions packages/amplify-category-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-category-auth",
"version": "2.19.1",
"version": "2.20.0",
"description": "amplify-cli authentication plugin",
"repository": {
"type": "git",
Expand All @@ -21,10 +21,10 @@
"test-watch": "jest --watch"
},
"dependencies": {
"amplify-category-function": "2.25.0",
"amplify-cli-core": "1.3.2",
"amplify-headless-interface": "1.3.0",
"amplify-util-headless-input": "1.2.1",
"amplify-category-function": "2.25.1",
"amplify-cli-core": "1.3.3",
"amplify-headless-interface": "1.4.0",
"amplify-util-headless-input": "1.3.0",
"aws-sdk": "^2.608.0",
"chalk": "^3.0.0",
"chalk-pipe": "^3.0.0",
Expand Down
44 changes: 3 additions & 41 deletions packages/amplify-category-auth/src/commands/auth/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ const { messages } = require('../../provider-utils/awscloudformation/assets/stri
const { getAuthResourceName } = require('../../utils/getAuthResourceName');
const { transformUserPoolGroupSchema } = require('../../provider-utils/awscloudformation/utils/transform-user-pool-group');
const path = require('path');
const { category } = require('../..');
const { attachPrevParamsToContext } = require('../../provider-utils/awscloudformation/utils/attach-prev-params-to-context');

const subcommand = 'update';
const category = 'auth';
let options;

module.exports = {
Expand Down Expand Up @@ -48,48 +49,9 @@ module.exports = {
context.print.error('Provider not configured for this category');
return;
}
return providerController.updateResource(context, category, options);
return providerController.updateResource(context, options);
})
.then(async name => {
// eslint-disable-line no-shadow
const resourceDirPath = path.join(amplify.pathManager.getBackendDirPath(), 'auth', name, 'parameters.json');
const authParameters = amplify.readJsonFile(resourceDirPath);
if (authParameters.dependsOn) {
amplify.updateamplifyMetaAfterResourceUpdate(category, name, 'dependsOn', authParameters.dependsOn);
}

let customAuthConfigured = false;
if (authParameters.triggers) {
const triggers = JSON.parse(authParameters.triggers);
customAuthConfigured =
triggers.DefineAuthChallenge &&
triggers.DefineAuthChallenge.length > 0 &&
triggers.CreateAuthChallenge &&
triggers.CreateAuthChallenge.length > 0 &&
triggers.VerifyAuthChallengeResponse &&
triggers.VerifyAuthChallengeResponse.length > 0;
}
amplify.updateamplifyMetaAfterResourceUpdate(category, resourceName, 'customAuth', customAuthConfigured);

// Update Identity Pool dependency attributes on userpool groups
const allResources = context.amplify.getProjectMeta();
if (allResources.auth && allResources.auth.userPoolGroups) {
let attributes = ['UserPoolId', 'AppClientIDWeb', 'AppClientID'];
if (authParameters.identityPoolName) {
attributes.push('IdentityPoolId');
}
const userPoolGroupDependsOn = [
{
category: 'auth',
resourceName,
attributes,
},
];

amplify.updateamplifyMetaAfterResourceUpdate('auth', 'userPoolGroups', 'dependsOn', userPoolGroupDependsOn);
await transformUserPoolGroupSchema(context);
}

const { print } = context;
print.success(`Successfully updated resource ${name} locally`);
print.info('');
Expand Down
13 changes: 10 additions & 3 deletions packages/amplify-category-auth/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ const { ENV_SPECIFIC_PARAMS } = require('./provider-utils/awscloudformation/cons

const { transformUserPoolGroupSchema } = require('./provider-utils/awscloudformation/utils/transform-user-pool-group');
const { uploadFiles } = require('./provider-utils/awscloudformation/utils/trigger-file-uploader');
const { validateAddAuthRequest } = require('amplify-util-headless-input');
const { getAddAuthRequestAdaptor } = require('./provider-utils/awscloudformation/utils/add-auth-request-adaptor');
const { getAddAuthHandler } = require('./provider-utils/awscloudformation/handlers/get-add-auth-handler');
const { validateAddAuthRequest, validateUpdateAuthRequest } = require('amplify-util-headless-input');
const { getAddAuthRequestAdaptor, getUpdateAuthRequestAdaptor } = require('./provider-utils/awscloudformation/utils/auth-request-adaptors');
const { getAddAuthHandler, getUpdateAuthHandler } = require('./provider-utils/awscloudformation/handlers/resource-handlers');
const { projectHasAuth } = require('./provider-utils/awscloudformation/utils/project-has-auth');
const { attachPrevParamsToContext } = require('./provider-utils/awscloudformation/utils/attach-prev-params-to-context');

// this function is being kept for temporary compatability.
async function add(context) {
Expand Down Expand Up @@ -317,6 +318,12 @@ const executeAmplifyHeadlessCommand = async (context, headlessPayload) => {
.then(getAddAuthRequestAdaptor(context.amplify.getProjectConfig().frontend))
.then(getAddAuthHandler(context));
return;
case 'update':
await attachPrevParamsToContext(context);
await validateUpdateAuthRequest(headlessPayload)
.then(getUpdateAuthRequestAdaptor(context.amplify.getProjectConfig().frontend, context.updatingAuth.requiredAttributes))
.then(getUpdateAuthHandler(context));
return;
default:
context.print.error(`Headless mode for ${context.input.command} auth is not implemented yet`);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export const safeDefaults = [
'userpoolClientRefreshTokenValidity',
];

export const protectedValues = [
// These attributes cannot be modified once the auth resource is created
export const immutableAttributes = [
'resourceName',
'userPoolName',
'identityPoolName',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { ServiceQuestionsResult } from '../service-walkthrough-types';
import { getAddAuthDefaultsApplier, getUpdateAuthDefaultsApplier } from '../utils/auth-defaults-appliers';
import { getResourceSynthesizer, getResourceUpdater } from '../utils/synthesize-resources';
import { getPostAddAuthMetaUpdater, getPostUpdateAuthMetaUpdater } from '../utils/amplify-meta-updaters';
import { getPostAddAuthMessagePrinter, getPostUpdateAuthMessagePrinter } from '../utils/message-printer';
import { supportedServices } from '../../supported-services';

/**
* Factory function that returns a ServiceQuestionsResult consumer that handles all of the resource generation logic.
* The consumer returns the resourceName of the generated resource.
* @param context The amplify context
*/
export const getAddAuthHandler = (context: any) => async (request: ServiceQuestionsResult) => {
const serviceMetadata = supportedServices[request.serviceName];
const { cfnFilename, defaultValuesFilename, provider } = serviceMetadata;
let projectName = context.amplify.getProjectConfig().projectName.toLowerCase();
const disallowedChars = /[^A-Za-z0-9]+/g;
projectName = projectName.replace(disallowedChars, '');
const requestWithDefaults = await getAddAuthDefaultsApplier(context, defaultValuesFilename, projectName)(request);
await getResourceSynthesizer(
context,
cfnFilename,
provider,
)(requestWithDefaults)
.then(req => req.resourceName!)
.then(getPostAddAuthMetaUpdater(context, { service: requestWithDefaults.serviceName, providerName: provider }))
.then(getPostAddAuthMessagePrinter(context.print))
.catch(err => {
context.print.info(err.stack);
context.print.error('There was an error adding the auth resource');
context.usageData.emitError(err);
process.exitCode = 1;
});
return requestWithDefaults.resourceName!;
};

export const getUpdateAuthHandler = (context: any) => async (request: ServiceQuestionsResult) => {
const { cfnFilename, defaultValuesFilename, provider } = supportedServices[request.serviceName];
const requestWithDefaults = await getUpdateAuthDefaultsApplier(defaultValuesFilename, context.updatingAuth)(request);
await getResourceUpdater(
context,
cfnFilename,
provider,
)(requestWithDefaults)
.then(req => req.resourceName!)
.then(getPostUpdateAuthMetaUpdater(context))
.then(getPostUpdateAuthMessagePrinter(context.print))
.catch(err => {
context.print.info(err.stack);
context.print.error('There was an error updating the auth resource');
context.usageData.emitError(err);
process.exitCode = 1;
});
return requestWithDefaults.resourceName!;
};
Loading

0 comments on commit 31a0e3f

Please sign in to comment.