diff --git a/.circleci/config.yml b/.circleci/config.yml index a26ff94d19b..560a107b121 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -793,6 +793,14 @@ jobs: environment: TEST_SUITE: src/__tests__/api_2.test.ts CLI_REGION: eu-west-2 + api_3-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_0 + resource_class: large + steps: *ref_1 + environment: + TEST_SUITE: src/__tests__/api_3.test.ts + CLI_REGION: eu-central-1 auth_1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -800,7 +808,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/auth_1.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 auth_2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -808,7 +816,23 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/auth_2.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 + auth_3-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_0 + resource_class: large + steps: *ref_1 + environment: + TEST_SUITE: src/__tests__/auth_3.test.ts + CLI_REGION: ap-southeast-2 + auth_4-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_0 + resource_class: large + steps: *ref_1 + environment: + TEST_SUITE: src/__tests__/auth_4.test.ts + CLI_REGION: us-east-2 env-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -816,7 +840,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/env.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: us-west-2 feature-flags-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -824,7 +848,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/feature-flags.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: eu-west-2 function_1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -832,7 +856,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/function_1.test.ts - CLI_REGION: us-east-2 + CLI_REGION: eu-central-1 function_2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -840,7 +864,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/function_2.test.ts - CLI_REGION: us-west-2 + CLI_REGION: ap-northeast-1 init-special-case-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -848,7 +872,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/init-special-case.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: ap-southeast-1 layer-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -856,7 +880,23 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/layer.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-southeast-2 + migration-api-key-migration1-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_0 + resource_class: large + steps: *ref_1 + environment: + TEST_SUITE: src/__tests__/migration/api.key.migration1.test.ts + CLI_REGION: us-east-2 + migration-api-key-migration2-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_0 + resource_class: large + steps: *ref_1 + environment: + TEST_SUITE: src/__tests__/migration/api.key.migration2.test.ts + CLI_REGION: us-west-2 schema-auth-1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -864,7 +904,15 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-1.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: eu-west-2 + schema-auth-10-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_0 + resource_class: large + steps: *ref_1 + environment: + TEST_SUITE: src/__tests__/schema-auth-10.test.ts + CLI_REGION: eu-central-1 schema-auth-2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -872,7 +920,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-2.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-northeast-1 schema-auth-3-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -880,7 +928,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-3.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: ap-southeast-1 schema-auth-4-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -888,7 +936,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-4.test.ts - CLI_REGION: us-east-2 + CLI_REGION: ap-southeast-2 schema-auth-5-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -896,7 +944,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-5.test.ts - CLI_REGION: us-west-2 + CLI_REGION: us-east-2 schema-auth-6-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -904,7 +952,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-6.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: us-west-2 schema-auth-7-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -912,7 +960,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-7.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: eu-west-2 schema-auth-8-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -920,6 +968,14 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/schema-auth-8.test.ts + CLI_REGION: eu-central-1 + schema-auth-9-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_0 + resource_class: large + steps: *ref_1 + environment: + TEST_SUITE: src/__tests__/schema-auth-9.test.ts CLI_REGION: ap-northeast-1 schema-connection-amplify_e2e_tests: working_directory: ~/repo @@ -1001,13 +1057,13 @@ jobs: environment: TEST_SUITE: src/__tests__/plugin.test.ts CLI_REGION: us-east-2 - datastore-modegen-amplify_e2e_tests: + datastore-modelgen-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 resource_class: large steps: *ref_1 environment: - TEST_SUITE: src/__tests__/datastore-modegen.test.ts + TEST_SUITE: src/__tests__/datastore-modelgen.test.ts CLI_REGION: us-west-2 interactions-amplify_e2e_tests: working_directory: ~/repo @@ -1081,14 +1137,6 @@ jobs: environment: TEST_SUITE: src/__tests__/storage.test.ts CLI_REGION: eu-central-1 - migration-api-key-migration-amplify_e2e_tests: - working_directory: ~/repo - docker: *ref_0 - resource_class: large - steps: *ref_1 - environment: - TEST_SUITE: src/__tests__/migration/api.key.migration.test.ts - CLI_REGION: ap-northeast-1 migration-api-connection-migration-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 @@ -1096,7 +1144,7 @@ jobs: steps: *ref_1 environment: TEST_SUITE: src/__tests__/migration/api.connection.migration.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-northeast-1 workflows: version: 2 nightly_console_integration_tests: @@ -1193,7 +1241,7 @@ workflows: - plugin-amplify_e2e_tests - hostingPROD-amplify_e2e_tests - schema-key-amplify_e2e_tests - - datastore-modegen-amplify_e2e_tests + - datastore-modelgen-amplify_e2e_tests - predictions-amplify_e2e_tests - schema-model-amplify_e2e_tests - interactions-amplify_e2e_tests @@ -1203,10 +1251,10 @@ workflows: - storage-amplify_e2e_tests - schema-searchable-amplify_e2e_tests - init-amplify_e2e_tests - - migration-api-key-migration-amplify_e2e_tests + - migration-api-connection-migration-amplify_e2e_tests + - schema-connection-amplify_e2e_tests - schema-versioned-amplify_e2e_tests - amplify-app-amplify_e2e_tests - - migration-api-connection-migration-amplify_e2e_tests - schema-data-access-patterns-amplify_e2e_tests - tags-amplify_e2e_tests - analytics-amplify_e2e_tests @@ -1224,142 +1272,171 @@ workflows: - graphqlschemae2e requires: - publish_to_local_registry - - function_1-amplify_e2e_tests: + - auth_4-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-4-amplify_e2e_tests: + - migration-api-key-migration1-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-function-amplify_e2e_tests: + - schema-auth-5-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - amplify-configure-amplify_e2e_tests + - schema-function-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - auth_4-amplify_e2e_tests - plugin-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - function_1-amplify_e2e_tests + - migration-api-key-migration1-amplify_e2e_tests - hostingPROD-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-4-amplify_e2e_tests + - schema-auth-5-amplify_e2e_tests - api_1-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - function_2-amplify_e2e_tests: + - env-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-5-amplify_e2e_tests: + - migration-api-key-migration2-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-key-amplify_e2e_tests: + - schema-auth-6-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - api_1-amplify_e2e_tests - - datastore-modegen-amplify_e2e_tests: + - schema-key-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - function_2-amplify_e2e_tests + - env-amplify_e2e_tests + - datastore-modelgen-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - migration-api-key-migration2-amplify_e2e_tests - predictions-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-5-amplify_e2e_tests + - schema-auth-6-amplify_e2e_tests - api_2-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - init-special-case-amplify_e2e_tests: + - feature-flags-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-6-amplify_e2e_tests: + - schema-auth-1-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-model-amplify_e2e_tests: + - schema-auth-7-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - api_2-amplify_e2e_tests + - schema-model-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - feature-flags-amplify_e2e_tests - interactions-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - init-special-case-amplify_e2e_tests + - schema-auth-1-amplify_e2e_tests - delete-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-6-amplify_e2e_tests - - auth_1-amplify_e2e_tests: + - schema-auth-7-amplify_e2e_tests + - api_3-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - layer-amplify_e2e_tests: + - function_1-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-7-amplify_e2e_tests: + - schema-auth-10-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry + - schema-auth-8-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - api_3-amplify_e2e_tests - schema-predictions-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - auth_1-amplify_e2e_tests + - function_1-amplify_e2e_tests - hosting-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - layer-amplify_e2e_tests + - schema-auth-10-amplify_e2e_tests - storage-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-7-amplify_e2e_tests - - auth_2-amplify_e2e_tests: + - schema-auth-8-amplify_e2e_tests + - auth_1-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-1-amplify_e2e_tests: + - function_2-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-8-amplify_e2e_tests: + - schema-auth-2-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - schema-auth-9-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry + - auth_1-amplify_e2e_tests - schema-searchable-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - auth_2-amplify_e2e_tests + - function_2-amplify_e2e_tests - init-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-1-amplify_e2e_tests - - migration-api-key-migration-amplify_e2e_tests: + - schema-auth-2-amplify_e2e_tests + - migration-api-connection-migration-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-8-amplify_e2e_tests - - env-amplify_e2e_tests: + - schema-auth-9-amplify_e2e_tests + - auth_2-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-2-amplify_e2e_tests: + - init-special-case-amplify_e2e_tests: + filters: *ref_2 + requires: + - publish_to_local_registry + - schema-auth-3-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry @@ -1367,26 +1444,26 @@ workflows: filters: *ref_2 requires: - publish_to_local_registry + - auth_2-amplify_e2e_tests - schema-versioned-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - env-amplify_e2e_tests + - init-special-case-amplify_e2e_tests - amplify-app-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-2-amplify_e2e_tests - - migration-api-connection-migration-amplify_e2e_tests: + - schema-auth-3-amplify_e2e_tests + - auth_3-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-connection-amplify_e2e_tests - - feature-flags-amplify_e2e_tests: + - layer-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-3-amplify_e2e_tests: + - schema-auth-4-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry @@ -1394,13 +1471,14 @@ workflows: filters: *ref_2 requires: - publish_to_local_registry + - auth_3-amplify_e2e_tests - tags-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - feature-flags-amplify_e2e_tests + - layer-amplify_e2e_tests - analytics-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry - - schema-auth-3-amplify_e2e_tests + - schema-auth-4-amplify_e2e_tests diff --git a/packages/amplify-app/CHANGELOG.md b/packages/amplify-app/CHANGELOG.md index fd198456f92..e14e22a4f90 100644 --- a/packages/amplify-app/CHANGELOG.md +++ b/packages/amplify-app/CHANGELOG.md @@ -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 diff --git a/packages/amplify-app/package.json b/packages/amplify-app/package.json index 58462f160dc..a998ed7e94e 100644 --- a/packages/amplify-app/package.json +++ b/packages/amplify-app/package.json @@ -1,6 +1,6 @@ { "name": "amplify-app", - "version": "2.17.12", + "version": "2.17.13", "description": "Amplify CLI", "repository": { "type": "git", @@ -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", diff --git a/packages/amplify-category-analytics/CHANGELOG.md b/packages/amplify-category-analytics/CHANGELOG.md index 40b54dbc0fa..04799549cf3 100644 --- a/packages/amplify-category-analytics/CHANGELOG.md +++ b/packages/amplify-category-analytics/CHANGELOG.md @@ -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 diff --git a/packages/amplify-category-analytics/package.json b/packages/amplify-category-analytics/package.json index f7046df094b..c09beabdbbf 100644 --- a/packages/amplify-category-analytics/package.json +++ b/packages/amplify-category-analytics/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-analytics", - "version": "2.17.15", + "version": "2.17.16", "description": "amplify-cli analytics plugin", "repository": { "type": "git", @@ -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", diff --git a/packages/amplify-category-api/CHANGELOG.md b/packages/amplify-category-api/CHANGELOG.md index e91288c648f..2a8a43c9bfa 100644 --- a/packages/amplify-category-api/CHANGELOG.md +++ b/packages/amplify-category-api/CHANGELOG.md @@ -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) diff --git a/packages/amplify-category-api/package.json b/packages/amplify-category-api/package.json index 94c71d4f731..b1c9c5c8628 100644 --- a/packages/amplify-category-api/package.json +++ b/packages/amplify-category-api/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-api", - "version": "2.23.8", + "version": "2.23.9", "description": "amplify-cli api plugin", "repository": { "type": "git", @@ -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", diff --git a/packages/amplify-category-auth/CHANGELOG.md b/packages/amplify-category-auth/CHANGELOG.md index a75aea5d73c..3f54e0b7bb6 100644 --- a/packages/amplify-category-auth/CHANGELOG.md +++ b/packages/amplify-category-auth/CHANGELOG.md @@ -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) diff --git a/packages/amplify-category-auth/package.json b/packages/amplify-category-auth/package.json index ec08439d7f4..c5a2aebd86d 100644 --- a/packages/amplify-category-auth/package.json +++ b/packages/amplify-category-auth/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-auth", - "version": "2.19.1", + "version": "2.20.0", "description": "amplify-cli authentication plugin", "repository": { "type": "git", @@ -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", diff --git a/packages/amplify-category-auth/src/commands/auth/update.js b/packages/amplify-category-auth/src/commands/auth/update.js index fd599cbc558..312aee6f6cd 100644 --- a/packages/amplify-category-auth/src/commands/auth/update.js +++ b/packages/amplify-category-auth/src/commands/auth/update.js @@ -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 = { @@ -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(''); diff --git a/packages/amplify-category-auth/src/index.js b/packages/amplify-category-auth/src/index.js index c5f8f195b51..648fd9dfe97 100644 --- a/packages/amplify-category-auth/src/index.js +++ b/packages/amplify-category-auth/src/index.js @@ -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) { @@ -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; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/constants.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/constants.ts index d8a2093575b..912101ee63c 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/constants.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/constants.ts @@ -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', diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/handlers/get-add-auth-handler.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/handlers/get-add-auth-handler.ts deleted file mode 100644 index 41e4c7acf14..00000000000 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/handlers/get-add-auth-handler.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { ServiceQuestionsResult } from '../service-walkthrough-types'; -import { getAddAuthDefaultsApplier } from '../utils/add-auth-defaults-applier'; -import { getResourceSynthesizer } from '../utils/synthesize-resources'; -import { getPostAddAuthMetaUpdater } from '../utils/post-add-auth-meta-update'; -import { getPostAddAuthMessagePrinter } from '../utils/post-add-auth-message-printer'; - -/** - * 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 = require('../../supported-services').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)) - .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!; -}; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/handlers/resource-handlers.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/handlers/resource-handlers.ts new file mode 100644 index 00000000000..9a0f8914892 --- /dev/null +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/handlers/resource-handlers.ts @@ -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!; +}; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/index.js b/packages/amplify-category-auth/src/provider-utils/awscloudformation/index.js index 9d36e791d18..7dfae061d30 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/index.js +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/index.js @@ -1,21 +1,11 @@ const inquirer = require('inquirer'); const open = require('open'); -const path = require('path'); -const fs = require('fs-extra'); const _ = require('lodash'); const { getAuthResourceName } = require('../../utils/getAuthResourceName'); -const { verificationBucketName } = require('./utils/verification-bucket-name'); -const { - copyCfnTemplate, - removeDeprecatedProps, - createUserPoolGroups, - addAdminAuth, - saveResourceParameters, - lambdaTriggers, - copyS3Assets, -} = require('./utils/synthesize-resources'); -const { protectedValues, safeDefaults, ENV_SPECIFIC_PARAMS, privateKeys } = require('./constants'); -const { getAddAuthHandler } = require('./handlers/get-add-auth-handler'); +const { copyCfnTemplate, saveResourceParameters } = require('./utils/synthesize-resources'); +const { ENV_SPECIFIC_PARAMS, privateKeys } = require('./constants'); +const { getAddAuthHandler, getUpdateAuthHandler } = require('./handlers/resource-handlers'); +const { supportedServices } = require('../supported-services'); function serviceQuestions(context, defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename, serviceMetadata) { const serviceWalkthroughSrc = `${__dirname}/service-walkthroughs/${serviceWalkthroughFilename}`; @@ -24,156 +14,26 @@ function serviceQuestions(context, defaultValuesFilename, stringMapFilename, ser } async function addResource(context, service) { - const serviceMetadata = require('../supported-services').supportedServices[service]; + const serviceMetadata = supportedServices[service]; const { defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename } = serviceMetadata; return getAddAuthHandler(context)( await serviceQuestions(context, defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename, serviceMetadata), ); } -// may be able to consolidate this into just createUserPoolGroups -async function updateUserPoolGroups(context, resourceName, userPoolGroupList) { - if (userPoolGroupList && userPoolGroupList.length > 0) { - const userPoolGroupPrecedenceList = []; - - for (let i = 0; i < userPoolGroupList.length; i += 1) { - userPoolGroupPrecedenceList.push({ - groupName: userPoolGroupList[i], - precedence: i + 1, - }); - } - - const userPoolGroupFile = path.join( - context.amplify.pathManager.getBackendDirPath(), - 'auth', - 'userPoolGroups', - 'user-pool-group-precedence.json', - ); - - fs.outputFileSync(userPoolGroupFile, JSON.stringify(userPoolGroupPrecedenceList, null, 4)); - - context.amplify.updateamplifyMetaAfterResourceUpdate('auth', 'userPoolGroups', { - service: 'Cognito-UserPool-Groups', - providerPlugin: 'awscloudformation', - dependsOn: [ - { - category: 'auth', - resourceName, - attributes: ['UserPoolId', 'AppClientIDWeb', 'AppClientID', 'IdentityPoolId'], - }, - ], - }); - } -} - -async function updateResource(context, category, serviceResult) { - const { service, resourceName } = serviceResult; - let props = {}; - const serviceMetadata = require('../supported-services').supportedServices[service]; - const { cfnFilename, defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename, provider } = serviceMetadata; - - return serviceQuestions(context, defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename, serviceMetadata) - .then(async result => { - const defaultValuesSrc = `${__dirname}/assets/${defaultValuesFilename}`; - const { functionMap } = require(defaultValuesSrc); - const { authProviders } = require(`${__dirname}/assets/string-maps.js`); - - /* if user has used the default configuration, - * we populate base choices like authSelections and resourceName for them */ - if (!result.authSelections) { - result.authSelections = 'identityPoolAndUserPool'; - } - - const defaults = functionMap[result.authSelections](context.updatingAuth.resourceName); - - // removing protected values from results - for (let i = 0; i < protectedValues.length; i += 1) { - if (context.updatingAuth[protectedValues[i]]) { - delete result[protectedValues[i]]; - } - } - - if (result.useDefault && ['default', 'defaultSocial'].includes(result.useDefault)) { - for (let i = 0; i < safeDefaults.length; i += 1) { - delete context.updatingAuth[safeDefaults[i]]; - } - } - - await verificationBucketName(result, context.updatingAuth); - - props = Object.assign(defaults, removeDeprecatedProps(context.updatingAuth), result); - - const resources = context.amplify.getProjectMeta(); - - if (resources.auth.userPoolGroups) { - await updateUserPoolGroups(context, props.resourceName, result.userPoolGroupList); - } else { - await createUserPoolGroups(context, props.resourceName, result.userPoolGroupList); - } - - if (resources.api && resources.api.AdminQueries) { - // Find Existing functionName - let functionName; - if (resources.api.AdminQueries.dependsOn) { - const adminFunctionResource = resources.api.AdminQueries.dependsOn.find( - resource => resource.category === 'function' && resource.resourceName.includes('AdminQueries'), - ); - if (adminFunctionResource) { - functionName = adminFunctionResource.resourceName; - } - } - await addAdminAuth(context, props.resourceName, 'update', result.adminQueryGroup, functionName); - } else { - await addAdminAuth(context, props.resourceName, 'add', result.adminQueryGroup); - } - - const providerPlugin = context.amplify.getPluginInstance(context, provider); - const previouslySaved = providerPlugin.loadResourceParameters(context, 'auth', resourceName).triggers || '{}'; - await lambdaTriggers(props, context, JSON.parse(previouslySaved)); - - if ((!result.updateFlow && !result.thirdPartyAuth) || (result.updateFlow === 'manual' && !result.thirdPartyAuth)) { - delete props.selectedParties; - delete props.authProviders; - authProviders.forEach(a => { - if (props[a.answerHashKey]) { - delete props[a.answerHashKey]; - } - }); - if (props.googleIos) { - delete props.googleIos; - } - if (props.googleAndroid) { - delete props.googleAndroid; - } - if (props.audiences) { - delete props.audiences; - } - } - - if (props.useDefault === 'default' || props.hostedUI === false) { - delete props.oAuthMetadata; - delete props.hostedUIProviderMeta; - delete props.hostedUIProviderCreds; - delete props.hostedUIDomainName; - delete props.authProvidersUserPool; - } - - if (result.updateFlow !== 'updateUserPoolGroups' && result.updateFlow !== 'updateAdminQueries') { - await copyCfnTemplate(context, category, props, cfnFilename); - saveResourceParameters(context, provider, category, resourceName, props, ENV_SPECIFIC_PARAMS); - } - }) - .then(async () => { - await copyS3Assets(context, props); - return props.resourceName; - }); +async function updateResource(context, { service }) { + const serviceMetadata = supportedServices[service]; + const { defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename } = serviceMetadata; + return getUpdateAuthHandler(context)( + await serviceQuestions(context, defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename, serviceMetadata), + ); } async function updateConfigOnEnvInit(context, category, service) { - const srvcMetaData = require('../supported-services').supportedServices.Cognito; - const { defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename } = srvcMetaData; + const srvcMetaData = supportedServices.Cognito; + const { defaultValuesFilename, stringMapFilename, serviceWalkthroughFilename, provider } = srvcMetaData; - const providerPlugin = context.amplify.getPluginInstance(context, srvcMetaData.provider); + const providerPlugin = context.amplify.getPluginInstance(context, provider); // previously selected answers const resourceParams = providerPlugin.loadResourceParameters(context, 'auth', service); // ask only env specific questions @@ -240,8 +100,7 @@ async function migrate(context) { if (!Object.keys(existingAuth).length > 0) { return; } - const servicesMetadata = require('../supported-services').supportedServices; - const { provider, cfnFilename, defaultValuesFilename } = servicesMetadata.Cognito; + const { provider, cfnFilename, defaultValuesFilename } = supportedServices.Cognito; const defaultValuesSrc = `${__dirname}/assets/${defaultValuesFilename}`; const { roles } = require(defaultValuesSrc); @@ -420,8 +279,7 @@ async function openIdentityPoolConsole(context, region, identityPoolId) { } function getPermissionPolicies(context, service, resourceName, crudOptions) { - const serviceMetadata = require('../supported-services').supportedServices[service]; - const { serviceWalkthroughFilename } = serviceMetadata; + const { serviceWalkthroughFilename } = supportedServices[service]; const serviceWalkthroughSrc = `${__dirname}/service-walkthroughs/${serviceWalkthroughFilename}`; const { getIAMPolicies } = require(serviceWalkthroughSrc); diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/service-walkthrough-types.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/service-walkthrough-types.ts index 06e25821683..d7a184b4cfd 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/service-walkthrough-types.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/service-walkthrough-types.ts @@ -7,12 +7,14 @@ export type ServiceQuestionsResult = ServiceQuestionsBaseResult & PasswordPolicyResult & PasswordRecoveryResult & MfaResult & - AdminQueriesResult; + AdminQueriesResult & + Triggers; export interface ServiceQuestionsBaseResult { - serviceName: string; + serviceName: 'Cognito'; resourceName?: string; - useDefault: 'manual'; + useDefault: 'default' | 'defaultSocial' | 'manual'; + updateFlow?: 'default' | 'defaultSocial' | 'manual' | 'callbacks' | 'providers' | 'updateUserPoolGroups' | 'updateAdminQueries'; requiredAttributes: string[]; authSelections: 'userPoolOnly' | 'identityPoolAndUserPool'; userPoolName?: string; @@ -25,7 +27,7 @@ export interface ServiceQuestionsBaseResult { } export interface OAuthResult { - hostedUI: boolean; + hostedUI?: boolean; hostedUIDomainName?: string; hostedUIProviderMeta?: any; hostedUIProviderCreds?: any; @@ -87,6 +89,10 @@ export type PasswordPolicy = 'Requires Lowercase' | 'Requires Numbers' | 'Requir export type UsernameAttributes = 'username' | 'email' | 'phone_number' | 'email, phone_number'; +export interface Triggers { + triggers?: any; // TODO create a type for this +} + export enum TriggerType { CreateAuthChallenge = 'CreateAuthChallenge', CustomMessage = 'CustomMessage', diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/post-add-auth-meta-update.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts similarity index 51% rename from packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/post-add-auth-meta-update.ts rename to packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts index 7b0d01d9c9e..636ed0493a2 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/post-add-auth-meta-update.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts @@ -1,5 +1,6 @@ import * as path from 'path'; -import { JSONUtilities } from 'amplify-cli-core'; +import { JSONUtilities, $TSAny, pathManager } from 'amplify-cli-core'; +import { transformUserPoolGroupSchema } from './transform-user-pool-group'; /** * Factory function that returns a function that updates Amplify meta files after adding auth resource assets * @@ -54,3 +55,48 @@ export const getPostAddAuthMetaUpdater = (context: any, resultMetadata: { servic } return resourceName; }; + +/** + * Factory function that returns a function that updates Amplify meta files after updating auth resource assets + * @param context The amplify context + */ +export const getPostUpdateAuthMetaUpdater = (context: any) => async (resourceName: string) => { + const resourceDirPath = path.join(pathManager.getBackendDirPath(), 'auth', resourceName, 'parameters.json'); + const authParameters = JSONUtilities.readJson<$TSAny>(resourceDirPath); + if (authParameters.dependsOn) { + context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, '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; + } + context.amplify.updateamplifyMetaAfterResourceUpdate('auth', 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, + }, + ]; + + context.amplify.updateamplifyMetaAfterResourceUpdate('auth', 'userPoolGroups', 'dependsOn', userPoolGroupDependsOn); + await transformUserPoolGroupSchema(context); + } + return resourceName; +}; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/attach-prev-params-to-context.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/attach-prev-params-to-context.ts new file mode 100644 index 00000000000..20438b26992 --- /dev/null +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/attach-prev-params-to-context.ts @@ -0,0 +1,11 @@ +import { getAuthResourceName } from '../../../utils/getAuthResourceName'; +import { supportedServices } from '../../supported-services'; + +/** + * Some existing code relies on the existing auth parameters being attached to context.updatingAuth + */ +export const attachPrevParamsToContext = async (context: any) => { + const resourceName = await getAuthResourceName(context); + const providerPlugin = context.amplify.getPluginInstance(context, supportedServices.Cognito.provider); + context.updatingAuth = providerPlugin.loadResourceParameters(context, 'auth', resourceName); +}; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/add-auth-defaults-applier.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/auth-defaults-appliers.ts similarity index 58% rename from packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/add-auth-defaults-applier.ts rename to packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/auth-defaults-appliers.ts index 14f4e58c7c6..74be9716e8d 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/add-auth-defaults-applier.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/auth-defaults-appliers.ts @@ -2,6 +2,8 @@ import { ServiceQuestionsResult } from '../service-walkthrough-types'; import { verificationBucketName } from './verification-bucket-name'; import { merge } from 'lodash'; import { structureOAuthMetadata } from '../service-walkthroughs/auth-questions'; +import { removeDeprecatedProps } from './synthesize-resources'; +import { immutableAttributes, safeDefaults } from '../constants'; /** * Factory function that returns a function that applies default values to a ServiceQuestionsResult request. @@ -25,3 +27,25 @@ export const getAddAuthDefaultsApplier = (context: any, defaultValuesFilename: s * ensuring that manual entries override defaults */ return merge(functionMap[result.authSelections](result.resourceName), result, roles); }; + +export const getUpdateAuthDefaultsApplier = (defaultValuesFilename: string, previousResult: ServiceQuestionsResult) => async ( + result: ServiceQuestionsResult, +): Promise => { + const { functionMap } = await import(`../assets/${defaultValuesFilename}`); + if (!result.authSelections) { + result.authSelections = 'identityPoolAndUserPool'; + } + + const defaults = functionMap[result.authSelections](previousResult.resourceName); + + // ensure immutable attributes are removed from result + immutableAttributes.filter(pv => pv in previousResult).forEach(pv => delete (result as any)[pv]); + + if (['default', 'defaultSocial'].includes(result.useDefault)) { + safeDefaults.forEach(sd => delete (previousResult as any)[sd]); + } + + await verificationBucketName(result, previousResult); + + return merge(defaults, removeDeprecatedProps(previousResult), result); +}; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/add-auth-request-adaptor.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/auth-request-adaptors.ts similarity index 79% rename from packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/add-auth-request-adaptor.ts rename to packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/auth-request-adaptors.ts index f50fe36fa33..776f4605f22 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/add-auth-request-adaptor.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/auth-request-adaptors.ts @@ -9,6 +9,10 @@ import { CognitoIdentityPoolConfiguration, CognitoOAuthConfiguration, CognitoSocialProviderConfiguration, + UpdateAuthRequest, + CognitoUserPoolConfiguration, + CognitoUserPoolModification, + CognitoIdentityPoolModification, } from 'amplify-headless-interface'; import { identityPoolProviders, userPoolProviders } from '../service-walkthroughs/auth-questions'; import { merge } from 'lodash'; @@ -44,11 +48,48 @@ export const getAddAuthRequestAdaptor: AddAuthRequestAdaptorFactory = projectTyp return { serviceName: cognitoConfig.serviceName, resourceName, - useDefault: 'manual', requiredAttributes, - authSelections: cognitoConfig.includeIdentityPool ? 'identityPoolAndUserPool' : 'userPoolOnly', + ...immutableAttributeAdaptor(userPoolConfig, identityPoolConfig), + ...mutableAttributeAdaptor(projectType, requiredAttributes, userPoolConfig, cognitoConfig.includeIdentityPool, identityPoolConfig), + }; +}; + +export const getUpdateAuthRequestAdaptor = (projectType: string, requiredAttributes: string[]) => ({ + serviceModification, +}: UpdateAuthRequest): ServiceQuestionsResult => { + const idPoolModification = serviceModification.includeIdentityPool ? serviceModification.identityPoolModification : undefined; + return { + serviceName: serviceModification.serviceName, + requiredAttributes, + ...mutableAttributeAdaptor( + projectType, + requiredAttributes, + serviceModification.userPoolModification, + serviceModification.includeIdentityPool, + idPoolModification, + ), + }; +}; + +const immutableAttributeAdaptor = (userPoolConfig: CognitoUserPoolConfiguration, identityPoolConfig?: CognitoIdentityPoolConfiguration) => { + return { userPoolName: userPoolConfig.userPoolName, usernameAttributes: signinAttributeMap[userPoolConfig.signinMethod], + ...immutableIdentityPoolMap(identityPoolConfig), + }; +}; + +const mutableAttributeAdaptor = ( + projectType: string, + requiredAttributes: string[], + userPoolConfig: CognitoUserPoolConfiguration | CognitoUserPoolModification, + includeIdentityPool: boolean, + identityPoolConfig?: CognitoIdentityPoolConfiguration | CognitoIdentityPoolModification, +) => { + return { + useDefault: 'manual' as 'manual', + updateFlow: 'manual' as 'manual', + authSelections: includeIdentityPool ? 'identityPoolAndUserPool' : ('userPoolOnly' as 'userPoolOnly' | 'identityPoolAndUserPool'), userPoolGroups: (userPoolConfig.userPoolGroups?.length || 0) > 0, userPoolGroupList: (userPoolConfig.userPoolGroups || []).map(group => group.groupName), // TODO may need to map "customPolicy" userpoolClientRefreshTokenValidity: userPoolConfig.refreshTokenPeriod, @@ -58,14 +99,17 @@ export const getAddAuthRequestAdaptor: AddAuthRequestAdaptorFactory = projectTyp ...mfaMap(userPoolConfig.mfa), ...passwordRecoveryMap(userPoolConfig.passwordRecovery), ...passwordPolicyMap(userPoolConfig.passwordPolicy), - ...identityPoolMap(identityPoolConfig, projectType), + ...mutableIdentityPoolMap(projectType, identityPoolConfig), ...oauthMap(userPoolConfig.oAuth, requiredAttributes), }; }; // converts the oauth config to the existing format -const oauthMap = (oauthConfig?: CognitoOAuthConfiguration, requiredAttributes: string[] = []): OAuthResult & SocialProviderResult => { - if (!oauthConfig) return { hostedUI: false }; +const oauthMap = ( + oauthConfig?: CognitoOAuthConfiguration, + requiredAttributes: string[] = [], +): (OAuthResult & SocialProviderResult) | {} => { + if (!oauthConfig) return {}; return { hostedUI: true, hostedUIDomainName: oauthConfig.domainPrefix, @@ -109,7 +153,10 @@ const socialProviderMap = ( }; // converts the identity pool config to the existing format -const identityPoolMap = (idPoolConfig: CognitoIdentityPoolConfiguration | undefined, projectType: string): IdentityPoolResult => { +const mutableIdentityPoolMap = ( + projectType: string, + idPoolConfig?: CognitoIdentityPoolConfiguration | CognitoIdentityPoolModification, +): IdentityPoolResult => { if (!idPoolConfig) return { thirdPartyAuth: false, @@ -117,7 +164,6 @@ const identityPoolMap = (idPoolConfig: CognitoIdentityPoolConfiguration | undefi }; type AppIds = Pick; const result = { - identityPoolName: idPoolConfig.identityPoolName, allowUnauthenticatedIdentities: idPoolConfig.unauthenticatedLogin, thirdPartyAuth: !!idPoolConfig.identitySocialFederation, authProviders: (idPoolConfig.identitySocialFederation || []) @@ -136,6 +182,10 @@ const identityPoolMap = (idPoolConfig: CognitoIdentityPoolConfiguration | undefi return result; }; +const immutableIdentityPoolMap = (idPoolConfig?: CognitoIdentityPoolConfiguration) => ({ + identityPoolName: idPoolConfig?.identityPoolName, +}); + // converts the password policy to the existing format const passwordPolicyMap = (pwPolicy?: CognitoPasswordPolicy): PasswordPolicyResult => { if (!pwPolicy) return {}; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/message-printer.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/message-printer.ts new file mode 100644 index 00000000000..662bfc97f18 --- /dev/null +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/message-printer.ts @@ -0,0 +1,27 @@ +/** + * A factory function that returns a function that prints the "success message" after adding auth + * @param print The amplify print object + */ +export const getPostAddAuthMessagePrinter = (print: any) => (resourceName: string) => { + print.success(`Successfully added auth resource ${resourceName} locally`); + printCommonText(print); +}; + +/** + * A factory function that returns a function that prints the "success message" after updating auth + * @param context The amplify print object + */ +export const getPostUpdateAuthMessagePrinter = (print: any) => (resourceName: string) => { + print.success(`Successfully updated auth resource ${resourceName} locally`); + printCommonText(print); +}; + +const printCommonText = (print: any) => { + print.info(''); + print.success('Some next steps:'); + print.info('"amplify push" will build all your local backend resources and provision it in the cloud'); + print.info( + '"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud', + ); + print.info(''); +}; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/post-add-auth-message-printer.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/post-add-auth-message-printer.ts deleted file mode 100644 index f143359bf62..00000000000 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/post-add-auth-message-printer.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * A factory function that returns a function that prints the "success message" after adding auth - * @param context The amplify context - */ -export const getPostAddAuthMessagePrinter = (context: any) => (resourceName: string) => { - const { print } = context; - print.success(`Successfully added auth resource ${resourceName} locally`); - print.info(''); - print.success('Some next steps:'); - print.info('"amplify push" will build all your local backend resources and provision it in the cloud'); - print.info( - '"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud', - ); - print.info(''); -}; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/synthesize-resources.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/synthesize-resources.ts index f157fe1f72f..31597c2cf12 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/synthesize-resources.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/synthesize-resources.ts @@ -1,10 +1,12 @@ import { ServiceQuestionsResult } from '../service-walkthrough-types'; import * as path from 'path'; -import { existsSync, copySync } from 'fs-extra'; +import { existsSync, copySync, outputFileSync } from 'fs-extra'; import uuid from 'uuid'; import { cfnTemplateRoot, privateKeys, adminAuthAssetRoot, triggerRoot, ENV_SPECIFIC_PARAMS } from '../constants'; import { ServiceName as FunctionServiceName } from 'amplify-category-function'; import { pathManager, JSONUtilities } from 'amplify-cli-core'; +import { get } from 'lodash'; +import { authProviders } from '../assets/string-maps'; const category = 'auth'; @@ -12,29 +14,149 @@ const category = 'auth'; * Factory function that returns a function that synthesizes all resources based on a ServiceQuestionsResult request. * The function returns the request unchanged to enable .then() chaining * @param context The amplify context - * @param cfnFilename The template cfnFilename + * @param cfnFilename The template CFN filename * @param provider The cloud provider name */ export const getResourceSynthesizer = (context: any, cfnFilename: string, provider: string) => async ( request: Readonly, ) => { await lambdaTriggers(request, context, null); - await createUserPoolGroups(context, request.resourceName, request.userPoolGroupList); + await createUserPoolGroups(context, request.resourceName!, request.userPoolGroupList); await addAdminAuth(context, request.resourceName!, 'add', request.adminQueryGroup); await copyCfnTemplate(context, category, request, cfnFilename); saveResourceParameters(context, provider, category, request.resourceName!, request, ENV_SPECIFIC_PARAMS); - await copyS3Assets(context, request); + await copyS3Assets(request); return request; }; /** - * The functions below should not be exported, but they are for now because the update flow still uses them individually - * Once the update flow is also refactored, they will be internal to this file + * Factory function that returns a function that updates the auth resource based on a ServiceQuestionsResult request. + * The function retusn the request unchanged to enable .then() chaining * - * They are refactored with minimal modification from awscloudformation/indes.js + * The code is more-or-less refactored as-is from the existing update logic + * @param context The amplify context + * @param cfnFilename The template CFN filename + * @param provider The cloud provider name */ +export const getResourceUpdater = (context: any, cfnFilename: string, provider: string) => async (request: ServiceQuestionsResult) => { + const resources = context.amplify.getProjectMeta(); + if (resources.auth.userPoolGroups) { + await updateUserPoolGroups(context, request.resourceName!, request.userPoolGroupList); + } else { + await createUserPoolGroups(context, request.resourceName!, request.userPoolGroupList); + } + + const adminQueriesFunctionName = get<{ category: string; resourceName: string }[]>(resources, ['api', 'AdminQueries', 'dependsOn'], []) + .filter(resource => resource.category === 'function') + .map(resource => resource.resourceName) + .find(resourceName => resourceName.includes('AdminQueries')); + if (adminQueriesFunctionName) { + await addAdminAuth(context, request.resourceName!, 'update', request.adminQueryGroup, adminQueriesFunctionName); + } else { + await addAdminAuth(context, request.resourceName!, 'add', request.adminQueryGroup); + } + + const providerPlugin = context.amplify.getPluginInstance(context, provider); + const previouslySaved = providerPlugin.loadResourceParameters(context, 'auth', request.resourceName).triggers || '{}'; + await lambdaTriggers(request, context, JSON.parse(previouslySaved)); + + if ((!request.updateFlow && !request.thirdPartyAuth) || (request.updateFlow === 'manual' && !request.thirdPartyAuth)) { + delete request.selectedParties; + delete request.authProviders; + authProviders.forEach(a => delete (request as any)[a.answerHashKey]); + if (request.googleIos) { + delete request.googleIos; + } + if (request.googleAndroid) { + delete request.googleAndroid; + } + if (request.audiences) { + delete request.audiences; + } + } + + if (request.useDefault === 'default' || request.hostedUI === false) { + delete request.oAuthMetadata; + delete request.hostedUIProviderMeta; + delete request.hostedUIProviderCreds; + delete request.hostedUIDomainName; + delete request.authProvidersUserPool; + } -export const lambdaTriggers = async (coreAnswers: any, context: any, previouslySaved: any) => { + if (request.updateFlow !== 'updateUserPoolGroups' && request.updateFlow !== 'updateAdminQueries') { + await copyCfnTemplate(context, category, request, cfnFilename); + saveResourceParameters(context, provider, category, request.resourceName!, request, ENV_SPECIFIC_PARAMS); + } + await copyS3Assets(request); + return request; +}; + +/** + * The 3 functions below should not be exported, but they are for now because externalAuthEnable still uses them individually + */ +export const copyCfnTemplate = async (context: any, category: string, options: any, cfnFilename: string) => { + const targetDir = path.join(pathManager.getBackendDirPath(), category, options.resourceName); + + const copyJobs = [ + { + dir: cfnTemplateRoot, + template: cfnFilename, + target: path.join(targetDir, `${options.resourceName}-cloudformation-template.yml`), + paramsFile: path.join(targetDir, 'parameters.json'), + }, + ]; + + const privateParams = Object.assign({}, options); + privateKeys.forEach(p => delete privateParams[p]); + + return await context.amplify.copyBatch(context, copyJobs, privateParams, true); +}; + +export const saveResourceParameters = ( + context: any, + providerName: string, + category: string, + resource: string, + params: any, + envSpecificParams: any[] = [], +) => { + const provider = context.amplify.getPluginInstance(context, providerName); + let privateParams = Object.assign({}, params); + privateKeys.forEach(p => delete privateParams[p]); + privateParams = removeDeprecatedProps(privateParams); + provider.saveResourceParameters(context, category, resource, privateParams, envSpecificParams); +}; + +export const removeDeprecatedProps = (props: any) => { + [ + 'authRoleName', + 'unauthRoleName', + 'userpoolClientName', + 'roleName', + 'policyName', + 'mfaLambdaLogPolicy', + 'mfaPassRolePolicy', + 'mfaLambdaIAMPolicy', + 'userpoolClientLogPolicy', + 'userpoolClientLambdaPolicy', + 'lambdaLogPolicy', + 'openIdRolePolicy', + 'openIdLambdaIAMPolicy', + 'mfaLambdaRole', + 'openIdLambdaRoleName', + 'CreateAuthChallenge', + 'CustomMessage', + 'DefineAuthChallenge', + 'PostAuthentication', + 'PostConfirmation', + 'PreAuthentication', + 'PreSignup', + 'VerifyAuthChallengeResponse', + ].forEach(deprecatedField => delete props[deprecatedField]); + return props; +}; + +const lambdaTriggers = async (coreAnswers: any, context: any, previouslySaved: any) => { const { handleTriggers } = require('./trigger-flow-auth-helper'); let triggerKeyValues = {}; @@ -65,7 +187,7 @@ export const lambdaTriggers = async (coreAnswers: any, context: any, previouslyS coreAnswers.dependsOn = context.amplify.dependsOnBlock(context, dependsOnKeys, 'Cognito'); }; -export const createUserPoolGroups = async (context: any, resourceName: any, userPoolGroupList: any) => { +const createUserPoolGroups = async (context: any, resourceName: string, userPoolGroupList?: string[]) => { if (userPoolGroupList && userPoolGroupList.length > 0) { const userPoolGroupPrecedenceList = []; @@ -108,7 +230,41 @@ export const createUserPoolGroups = async (context: any, resourceName: any, user } }; -export const addAdminAuth = async ( +const updateUserPoolGroups = async (context: any, resourceName: string, userPoolGroupList?: string[]) => { + if (userPoolGroupList && userPoolGroupList.length > 0) { + const userPoolGroupPrecedenceList = []; + + for (let i = 0; i < userPoolGroupList.length; i += 1) { + userPoolGroupPrecedenceList.push({ + groupName: userPoolGroupList[i], + precedence: i + 1, + }); + } + + const userPoolGroupFile = path.join( + context.amplify.pathManager.getBackendDirPath(), + 'auth', + 'userPoolGroups', + 'user-pool-group-precedence.json', + ); + + outputFileSync(userPoolGroupFile, JSON.stringify(userPoolGroupPrecedenceList, null, 4)); + + context.amplify.updateamplifyMetaAfterResourceUpdate('auth', 'userPoolGroups', { + service: 'Cognito-UserPool-Groups', + providerPlugin: 'awscloudformation', + dependsOn: [ + { + category: 'auth', + resourceName, + attributes: ['UserPoolId', 'AppClientIDWeb', 'AppClientID', 'IdentityPoolId'], + }, + ], + }); + } +}; + +const addAdminAuth = async ( context: any, authResourceName: string, operation: 'update' | 'add', @@ -125,7 +281,7 @@ export const addAdminAuth = async ( } }; -export const createAdminAuthFunction = async ( +const createAdminAuthFunction = async ( context: any, authResourceName: string, functionName: string, @@ -202,7 +358,7 @@ export const createAdminAuthFunction = async ( } }; -export const createAdminAuthAPI = async (context: any, authResourceName: string, functionName: string, operation: 'update' | 'add') => { +const createAdminAuthAPI = async (context: any, authResourceName: string, functionName: string, operation: 'update' | 'add') => { const apiName = 'AdminQueries'; const targetDir = path.join(pathManager.getBackendDirPath(), 'api', apiName); const dependsOn = []; @@ -257,72 +413,10 @@ export const createAdminAuthAPI = async (context: any, authResourceName: string, } }; -export const copyCfnTemplate = async (context: any, category: string, options: any, cfnFilename: string) => { - const targetDir = path.join(pathManager.getBackendDirPath(), category, options.resourceName); - - const copyJobs = [ - { - dir: cfnTemplateRoot, - template: cfnFilename, - target: path.join(targetDir, `${options.resourceName}-cloudformation-template.yml`), - paramsFile: path.join(targetDir, 'parameters.json'), - }, - ]; - - const privateParams = Object.assign({}, options); - privateKeys.forEach(p => delete privateParams[p]); - - return await context.amplify.copyBatch(context, copyJobs, privateParams, true); -}; - -export const saveResourceParameters = ( - context: any, - providerName: string, - category: string, - resource: string, - params: any, - envSpecificParams: any[] = [], -) => { - const provider = context.amplify.getPluginInstance(context, providerName); - let privateParams = Object.assign({}, params); - privateKeys.forEach(p => delete privateParams[p]); - privateParams = removeDeprecatedProps(privateParams); - provider.saveResourceParameters(context, category, resource, privateParams, envSpecificParams); -}; - -export const removeDeprecatedProps = (props: any) => { - [ - 'authRoleName', - 'unauthRoleName', - 'userpoolClientName', - 'roleName', - 'policyName', - 'mfaLambdaLogPolicy', - 'mfaPassRolePolicy', - 'mfaLambdaIAMPolicy', - 'userpoolClientLogPolicy', - 'userpoolClientLambdaPolicy', - 'lambdaLogPolicy', - 'openIdRolePolicy', - 'openIdLambdaIAMPolicy', - 'mfaLambdaRole', - 'openIdLambdaRoleName', - 'CreateAuthChallenge', - 'CustomMessage', - 'DefineAuthChallenge', - 'PostAuthentication', - 'PostConfirmation', - 'PreAuthentication', - 'PreSignup', - 'VerifyAuthChallengeResponse', - ].forEach(deprecatedField => delete props[deprecatedField]); - return props; -}; - -export const copyS3Assets = async (context: any, props: any) => { - const targetDir = path.join(pathManager.getBackendDirPath(), 'auth', props.resourceName, 'assets'); - const triggers = props.triggers ? JSONUtilities.parse(props.triggers) : null; - const confirmationFileNeeded = props.triggers && triggers.CustomMessage && triggers.CustomMessage.includes('verification-link'); +const copyS3Assets = async (request: ServiceQuestionsResult) => { + const targetDir = path.join(pathManager.getBackendDirPath(), 'auth', request.resourceName!, 'assets'); + const triggers = request.triggers ? JSONUtilities.parse(request.triggers) : null; + const confirmationFileNeeded = request.triggers && triggers.CustomMessage && triggers.CustomMessage.includes('verification-link'); if (confirmationFileNeeded) { if (!existsSync(targetDir)) { const source = path.join(triggerRoot, 'CustomMessage/assets'); diff --git a/packages/amplify-category-function/CHANGELOG.md b/packages/amplify-category-function/CHANGELOG.md index d915b74710c..70f87971310 100644 --- a/packages/amplify-category-function/CHANGELOG.md +++ b/packages/amplify-category-function/CHANGELOG.md @@ -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.25.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-function@2.25.0...amplify-category-function@2.25.1) (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.25.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-function@2.24.1...amplify-category-function@2.25.0) (2020-09-16) diff --git a/packages/amplify-category-function/package.json b/packages/amplify-category-function/package.json index 4412314b13c..c63ca56bb18 100644 --- a/packages/amplify-category-function/package.json +++ b/packages/amplify-category-function/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-function", - "version": "2.25.0", + "version": "2.25.1", "description": "amplify-cli function plugin", "repository": { "type": "git", @@ -21,8 +21,8 @@ "aws" ], "dependencies": { - "amplify-category-storage": "2.7.8", - "amplify-cli-core": "1.3.2", + "amplify-category-storage": "2.7.9", + "amplify-cli-core": "1.3.3", "amplify-function-plugin-interface": "1.4.1", "cloudform-types": "4.2.0", "enquirer": "^2.3.5", diff --git a/packages/amplify-category-hosting/CHANGELOG.md b/packages/amplify-category-hosting/CHANGELOG.md index 194f037bffa..f1ac4c23904 100644 --- a/packages/amplify-category-hosting/CHANGELOG.md +++ b/packages/amplify-category-hosting/CHANGELOG.md @@ -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.4.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-hosting@2.4.2...amplify-category-hosting@2.4.3) (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.4.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-hosting@2.4.0...amplify-category-hosting@2.4.2) (2020-07-29) diff --git a/packages/amplify-category-hosting/package.json b/packages/amplify-category-hosting/package.json index fedd95d11cb..8d30ffeb620 100644 --- a/packages/amplify-category-hosting/package.json +++ b/packages/amplify-category-hosting/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-hosting", - "version": "2.4.2", + "version": "2.4.3", "description": "amplify-cli hosting plugin", "repository": { "type": "git", diff --git a/packages/amplify-category-interactions/CHANGELOG.md b/packages/amplify-category-interactions/CHANGELOG.md index 06fa201ddd9..d8d9d629773 100644 --- a/packages/amplify-category-interactions/CHANGELOG.md +++ b/packages/amplify-category-interactions/CHANGELOG.md @@ -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.4.16](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-interactions@2.4.15...amplify-category-interactions@2.4.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.4.15](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-interactions@2.4.14...amplify-category-interactions@2.4.15) (2020-09-16) **Note:** Version bump only for package amplify-category-interactions diff --git a/packages/amplify-category-interactions/package.json b/packages/amplify-category-interactions/package.json index a2681147ad7..041379d0c20 100644 --- a/packages/amplify-category-interactions/package.json +++ b/packages/amplify-category-interactions/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-interactions", - "version": "2.4.15", + "version": "2.4.16", "description": "amplify-cli interactions plugin", "repository": { "type": "git", @@ -15,7 +15,7 @@ "aws" ], "dependencies": { - "amplify-category-auth": "2.19.1", + "amplify-category-auth": "2.20.0", "fs-extra": "^8.1.0", "fuzzy": "^0.1.3", "inquirer": "^7.0.3", diff --git a/packages/amplify-category-notifications/CHANGELOG.md b/packages/amplify-category-notifications/CHANGELOG.md index 44a6a63d762..5f00375f87b 100644 --- a/packages/amplify-category-notifications/CHANGELOG.md +++ b/packages/amplify-category-notifications/CHANGELOG.md @@ -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.15.25](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-notifications@2.15.24...amplify-category-notifications@2.15.25) (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.15.24](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-notifications@2.15.23...amplify-category-notifications@2.15.24) (2020-09-16) **Note:** Version bump only for package amplify-category-notifications diff --git a/packages/amplify-category-notifications/package.json b/packages/amplify-category-notifications/package.json index 88ee35d9db3..93bc5fb7402 100644 --- a/packages/amplify-category-notifications/package.json +++ b/packages/amplify-category-notifications/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-notifications", - "version": "2.15.24", + "version": "2.15.25", "description": "amplify-cli notifications plugin", "repository": { "type": "git", @@ -18,7 +18,7 @@ "test": "jest --coverage" }, "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", diff --git a/packages/amplify-category-predictions/CHANGELOG.md b/packages/amplify-category-predictions/CHANGELOG.md index 23e4496cf24..a5d115313e6 100644 --- a/packages/amplify-category-predictions/CHANGELOG.md +++ b/packages/amplify-category-predictions/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.4.18](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-predictions@2.4.17...amplify-category-predictions@2.4.18) (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)) +* fixed bad import ([#5386](https://github.com/aws-amplify/amplify-cli/issues/5386)) ([60b7175](https://github.com/aws-amplify/amplify-cli/commit/60b71757f97b7267251288b420dbddfe074784f6)) +* fixed typos and bad import ([#5390](https://github.com/aws-amplify/amplify-cli/issues/5390)) ([0d2f632](https://github.com/aws-amplify/amplify-cli/commit/0d2f632029bc3c78434fe502899780649f3f74e3)) + + + + + ## [2.4.17](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-predictions@2.4.16...amplify-category-predictions@2.4.17) (2020-09-16) **Note:** Version bump only for package amplify-category-predictions diff --git a/packages/amplify-category-predictions/package.json b/packages/amplify-category-predictions/package.json index 916429cf1a9..cf1224ad484 100644 --- a/packages/amplify-category-predictions/package.json +++ b/packages/amplify-category-predictions/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-predictions", - "version": "2.4.17", + "version": "2.4.18", "description": "amplify-cli predictions plugin", "repository": { "type": "git", @@ -15,8 +15,8 @@ "aws" ], "dependencies": { - "amplify-category-auth": "2.19.1", - "amplify-category-function": "2.25.0", + "amplify-category-auth": "2.20.0", + "amplify-category-function": "2.25.1", "aws-sdk": "^2.608.0", "chalk": "^3.0.0", "fs-extra": "^8.1.0", diff --git a/packages/amplify-category-storage/CHANGELOG.md b/packages/amplify-category-storage/CHANGELOG.md index 6ffa69f09cf..1bf8a40209d 100644 --- a/packages/amplify-category-storage/CHANGELOG.md +++ b/packages/amplify-category-storage/CHANGELOG.md @@ -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.7.9](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-storage@2.7.8...amplify-category-storage@2.7.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.7.8](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-storage@2.7.7...amplify-category-storage@2.7.8) (2020-09-16) diff --git a/packages/amplify-category-storage/package.json b/packages/amplify-category-storage/package.json index 583983531ba..3a36f0a94d8 100644 --- a/packages/amplify-category-storage/package.json +++ b/packages/amplify-category-storage/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-storage", - "version": "2.7.8", + "version": "2.7.9", "description": "amplify-cli storage plugin", "repository": { "type": "git", @@ -15,8 +15,8 @@ "aws" ], "dependencies": { - "amplify-category-auth": "2.19.1", - "amplify-category-function": "2.25.0", + "amplify-category-auth": "2.20.0", + "amplify-category-function": "2.25.1", "fs-extra": "^8.1.0", "inquirer": "^7.0.3", "lodash": "^4.17.19", diff --git a/packages/amplify-category-xr/CHANGELOG.md b/packages/amplify-category-xr/CHANGELOG.md index a9aaaa71b19..a1733326f71 100644 --- a/packages/amplify-category-xr/CHANGELOG.md +++ b/packages/amplify-category-xr/CHANGELOG.md @@ -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.4.16](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-xr@2.4.15...amplify-category-xr@2.4.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.4.15](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-xr@2.4.14...amplify-category-xr@2.4.15) (2020-09-16) **Note:** Version bump only for package amplify-category-xr diff --git a/packages/amplify-category-xr/package.json b/packages/amplify-category-xr/package.json index f491ed037da..ca68f62d6e7 100644 --- a/packages/amplify-category-xr/package.json +++ b/packages/amplify-category-xr/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-xr", - "version": "2.4.15", + "version": "2.4.16", "description": "amplify-cli xr plugin", "repository": { "type": "git", @@ -19,7 +19,7 @@ "test-watch": "jest --watch" }, "dependencies": { - "amplify-category-auth": "2.19.1", + "amplify-category-auth": "2.20.0", "chalk": "^3.0.0", "fs-extra": "^8.1.0", "inquirer": "^7.0.3", diff --git a/packages/amplify-cli-core/CHANGELOG.md b/packages/amplify-cli-core/CHANGELOG.md index 827b4b19ec3..7d69bf77c70 100644 --- a/packages/amplify-cli-core/CHANGELOG.md +++ b/packages/amplify-cli-core/CHANGELOG.md @@ -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. +## [1.3.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-cli-core@1.3.2...amplify-cli-core@1.3.3) (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)) + + + + + ## [1.3.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-cli-core@1.3.1...amplify-cli-core@1.3.2) (2020-09-16) diff --git a/packages/amplify-cli-core/package.json b/packages/amplify-cli-core/package.json index e96e17df936..b2363223e55 100644 --- a/packages/amplify-cli-core/package.json +++ b/packages/amplify-cli-core/package.json @@ -1,6 +1,6 @@ { "name": "amplify-cli-core", - "version": "1.3.2", + "version": "1.3.3", "description": "Amplify CLI Core", "repository": { "type": "git", diff --git a/packages/amplify-cli/CHANGELOG.md b/packages/amplify-cli/CHANGELOG.md index 395afd20126..1054b42aff4 100644 --- a/packages/amplify-cli/CHANGELOG.md +++ b/packages/amplify-cli/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.29.3](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/cli@4.29.2...@aws-amplify/cli@4.29.3) (2020-09-25) + + +### Bug Fixes + +* abort being called multiple times ([#5302](https://github.com/aws-amplify/amplify-cli/issues/5302)) ([83b2d10](https://github.com/aws-amplify/amplify-cli/commit/83b2d109b6f3cf2e9962bad78607b6a41e7599e2)) +* data inconsitency ([#5344](https://github.com/aws-amplify/amplify-cli/issues/5344)) ([bfe1903](https://github.com/aws-amplify/amplify-cli/commit/bfe19038b5b676056f45d7ffcc4c2460057936d8)) + + + + + ## [4.29.2](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/cli@4.29.1...@aws-amplify/cli@4.29.2) (2020-09-16) diff --git a/packages/amplify-cli/package.json b/packages/amplify-cli/package.json index 48c3b8ae812..686c9ad66ba 100644 --- a/packages/amplify-cli/package.json +++ b/packages/amplify-cli/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/cli", - "version": "4.29.2", + "version": "4.29.3", "description": "Amplify CLI", "repository": { "type": "git", @@ -36,34 +36,34 @@ "@types/fs-extra": "^8.0.1", "@types/global-prefix": "^3.0.0", "@types/update-notifier": "^4.1.0", - "amplify-category-analytics": "2.17.15", - "amplify-category-api": "2.23.8", - "amplify-category-auth": "2.19.1", - "amplify-category-function": "2.25.0", - "amplify-category-hosting": "2.4.2", - "amplify-category-interactions": "2.4.15", - "amplify-category-notifications": "2.15.24", - "amplify-category-predictions": "2.4.17", - "amplify-category-storage": "2.7.8", - "amplify-category-xr": "2.4.15", - "amplify-cli-core": "1.3.2", - "amplify-codegen": "2.15.18", - "amplify-console-hosting": "1.4.4", + "amplify-category-analytics": "2.17.16", + "amplify-category-api": "2.23.9", + "amplify-category-auth": "2.20.0", + "amplify-category-function": "2.25.1", + "amplify-category-hosting": "2.4.3", + "amplify-category-interactions": "2.4.16", + "amplify-category-notifications": "2.15.25", + "amplify-category-predictions": "2.4.18", + "amplify-category-storage": "2.7.9", + "amplify-category-xr": "2.4.16", + "amplify-cli-core": "1.3.3", + "amplify-codegen": "2.15.19", + "amplify-console-hosting": "1.4.5", "amplify-dotnet-function-runtime-provider": "1.2.1", - "amplify-dotnet-function-template-provider": "1.3.1", + "amplify-dotnet-function-template-provider": "1.3.2", "amplify-frontend-android": "2.13.4", "amplify-frontend-ios": "2.13.8", - "amplify-frontend-javascript": "2.16.3", - "amplify-go-function-runtime-provider": "1.2.3", + "amplify-frontend-javascript": "2.16.4", + "amplify-go-function-runtime-provider": "1.2.4", "amplify-go-function-template-provider": "1.2.1", "amplify-java-function-runtime-provider": "1.2.1", "amplify-java-function-template-provider": "1.4.1", "amplify-nodejs-function-runtime-provider": "1.1.5", - "amplify-nodejs-function-template-provider": "1.4.0", - "amplify-provider-awscloudformation": "4.26.2", + "amplify-nodejs-function-template-provider": "1.4.1", + "amplify-provider-awscloudformation": "4.26.3", "amplify-python-function-runtime-provider": "1.2.3", "amplify-python-function-template-provider": "1.2.1", - "amplify-util-mock": "3.24.10", + "amplify-util-mock": "3.24.11", "chalk": "^3.0.0", "cli-table3": "^0.5.1", "colors": "^1.4.0", diff --git a/packages/amplify-codegen-appsync-model-plugin/CHANGELOG.md b/packages/amplify-codegen-appsync-model-plugin/CHANGELOG.md index 6340ec1d97b..edf332c2c7f 100644 --- a/packages/amplify-codegen-appsync-model-plugin/CHANGELOG.md +++ b/packages/amplify-codegen-appsync-model-plugin/CHANGELOG.md @@ -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. +## [1.20.6](https://github.com/aws-amplify/amplify-cli/compare/amplify-codegen-appsync-model-plugin@1.20.5...amplify-codegen-appsync-model-plugin@1.20.6) (2020-09-25) + + +### Bug Fixes + +* add owner field if owner auth is included in auth rules ([#5335](https://github.com/aws-amplify/amplify-cli/issues/5335)) ([2200f51](https://github.com/aws-amplify/amplify-cli/commit/2200f51c70ffa6c3fe88efa6b563e962668da3e0)) + + + + + ## [1.20.5](https://github.com/aws-amplify/amplify-cli/compare/amplify-codegen-appsync-model-plugin@1.20.4...amplify-codegen-appsync-model-plugin@1.20.5) (2020-08-31) **Note:** Version bump only for package amplify-codegen-appsync-model-plugin diff --git a/packages/amplify-codegen-appsync-model-plugin/package.json b/packages/amplify-codegen-appsync-model-plugin/package.json index f0df44018ee..07475f67bb4 100644 --- a/packages/amplify-codegen-appsync-model-plugin/package.json +++ b/packages/amplify-codegen-appsync-model-plugin/package.json @@ -1,6 +1,6 @@ { "name": "amplify-codegen-appsync-model-plugin", - "version": "1.20.5", + "version": "1.20.6", "repository": { "type": "git", "url": "https://github.com/aws-amplify/amplify-cli.git", diff --git a/packages/amplify-codegen/CHANGELOG.md b/packages/amplify-codegen/CHANGELOG.md index 985d90a9c8d..9327bd33562 100644 --- a/packages/amplify-codegen/CHANGELOG.md +++ b/packages/amplify-codegen/CHANGELOG.md @@ -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.15.19](https://github.com/aws-amplify/amplify-cli/compare/amplify-codegen@2.15.18...amplify-codegen@2.15.19) (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.15.18](https://github.com/aws-amplify/amplify-cli/compare/amplify-codegen@2.15.17...amplify-codegen@2.15.18) (2020-08-31) **Note:** Version bump only for package amplify-codegen diff --git a/packages/amplify-codegen/package.json b/packages/amplify-codegen/package.json index b3df1f7ad25..a3006f66047 100644 --- a/packages/amplify-codegen/package.json +++ b/packages/amplify-codegen/package.json @@ -1,6 +1,6 @@ { "name": "amplify-codegen", - "version": "2.15.18", + "version": "2.15.19", "description": "amplify code generator", "repository": { "type": "git", @@ -21,9 +21,9 @@ }, "dependencies": { "@graphql-codegen/core": "1.8.3", - "amplify-codegen-appsync-model-plugin": "1.20.5", + "amplify-codegen-appsync-model-plugin": "1.20.6", "amplify-graphql-docs-generator": "2.1.16", - "amplify-graphql-types-generator": "2.5.0", + "amplify-graphql-types-generator": "2.5.1", "chalk": "^3.0.0", "fs-extra": "^8.1.0", "glob-all": "^3.1.0", diff --git a/packages/amplify-codegen/src/commands/models.js b/packages/amplify-codegen/src/commands/models.js index 33d6df99501..f6f49a826fe 100644 --- a/packages/amplify-codegen/src/commands/models.js +++ b/packages/amplify-codegen/src/commands/models.js @@ -103,7 +103,9 @@ function getModelOutputPath(context) { const projectConfig = context.amplify.getProjectConfig(); switch (projectConfig.frontend) { case 'javascript': - return 'src'; + return projectConfig.javascript && projectConfig.javascript.config && projectConfig.javascript.config.SourceDir + ? path.normalize(projectConfig.javascript.config.SourceDir) + : 'src'; case 'android': return projectConfig.android && projectConfig.android.config && projectConfig.android.config.ResDir ? path.normalize(path.join(projectConfig.android.config.ResDir, '..', 'java')) diff --git a/packages/amplify-codegen/src/utils/getSchemaDownloadLocation.js b/packages/amplify-codegen/src/utils/getSchemaDownloadLocation.js index ab1edca5595..d62e77d819b 100644 --- a/packages/amplify-codegen/src/utils/getSchemaDownloadLocation.js +++ b/packages/amplify-codegen/src/utils/getSchemaDownloadLocation.js @@ -1,4 +1,4 @@ -const { join, dirname } = require('path'); +const path = require('path'); const getAndroidResDir = require('./getAndroidResDir'); const getFrontEndHandler = require('./getFrontEndHandler'); @@ -7,13 +7,18 @@ function getSchemaDownloadLocation(context) { let downloadDir; try { const androidResDir = getAndroidResDir(context); - downloadDir = join(dirname(androidResDir), 'graphql'); + downloadDir = path.join(path.dirname(androidResDir), 'graphql'); } catch (e) { + const projectConfig = context.amplify.getProjectConfig(); + const sourceDir = + projectConfig.javascript && projectConfig.javascript.config && projectConfig.javascript.config.SourceDir + ? path.normalize(projectConfig.javascript.config.SourceDir) + : 'src'; const frontEnd = getFrontEndHandler(context); - const outputPath = frontEnd === 'javascript' ? 'src' : ''; - downloadDir = join(outputPath, 'graphql'); + const outputPath = frontEnd === 'javascript' ? sourceDir : ''; + downloadDir = path.join(outputPath, 'graphql'); } - return join(downloadDir, 'schema.json'); + return path.join(downloadDir, 'schema.json'); } module.exports = getSchemaDownloadLocation; diff --git a/packages/amplify-codegen/tests/utils/getSchemaDownloadLocation.test.js b/packages/amplify-codegen/tests/utils/getSchemaDownloadLocation.test.js index 0d32944117f..b8a906853d8 100644 --- a/packages/amplify-codegen/tests/utils/getSchemaDownloadLocation.test.js +++ b/packages/amplify-codegen/tests/utils/getSchemaDownloadLocation.test.js @@ -8,43 +8,70 @@ jest.mock('../../src/utils/getAndroidResDir'); jest.mock('../../src/utils/getFrontEndHandler'); let mockContext; -const mockBackEndPath = 'MOCK_BACKEND_DIR'; +const mockProjectConfigDefault = 'MOCK_PROJECT_CONFIG'; +const mockProjectConfig = { + frontend: 'javascript', + javascript: { + config: { + SourceDir: 'web-client/src', + }, + }, +}; const mockResDir = 'MOCK_RES_DIR/Res'; const mockAPIName = 'FooAPI'; -const mockGetBackendDirPath = jest.fn(); + +const mockGetProjectConfigDefault = jest.fn(); +const mockGetProjectConfig = jest.fn(); describe('getSchemaDownloadLocation', () => { beforeEach(() => { jest.resetAllMocks(); - - mockGetBackendDirPath.mockReturnValue(mockBackEndPath); - + mockGetProjectConfigDefault.mockReturnValue(mockProjectConfigDefault); + mockGetProjectConfig.mockReturnValue(mockProjectConfig); getAndroidResDir.mockImplementation(() => { throw new Error(); }); getFrontendHandler.mockReturnValue('javascript'); + }); + + it('should use the src/graphql directory when used in JS frontend', () => { mockContext = { amplify: { - pathManager: { - getBackendDirPath: mockGetBackendDirPath, - }, + getProjectConfig: mockGetProjectConfigDefault, }, }; + const downloadLocation = getSchemaDownloadLocation(mockContext); + expect(downloadLocation).toEqual(join('src', 'graphql', 'schema.json')); }); - it('should use the src/graphql directory when used in JS frontend', () => { - const downloadLocation = getSchemaDownloadLocation(mockContext, mockAPIName); - expect(downloadLocation).toEqual(join('src', 'graphql', 'schema.json')); + it('should use the defined project config directory when used in JS frontend', () => { + mockContext = { + amplify: { + getProjectConfig: mockGetProjectConfig, + }, + }; + const downloadLocation = getSchemaDownloadLocation(mockContext); + expect(downloadLocation).toEqual(join('web-client', 'src', 'graphql', 'schema.json')); }); it('should use the graphql directory when used in iOS frontend', () => { + mockContext = { + amplify: { + getProjectConfig: mockGetProjectConfig, + }, + }; getFrontendHandler.mockReturnValue('iOS'); - const downloadLocation = getSchemaDownloadLocation(mockContext, mockAPIName); + const downloadLocation = getSchemaDownloadLocation(mockContext); expect(downloadLocation).toEqual(join('graphql', 'schema.json')); }); it('should use main directory in Android', () => { + mockContext = { + amplify: { + getProjectConfig: mockGetProjectConfig, + }, + }; getAndroidResDir.mockReturnValue(mockResDir); - const downloadLocation = getSchemaDownloadLocation(mockContext, mockAPIName); + const downloadLocation = getSchemaDownloadLocation(mockContext); expect(downloadLocation).toEqual(join(dirname(mockResDir), 'graphql', 'schema.json')); }); }); diff --git a/packages/amplify-console-hosting/CHANGELOG.md b/packages/amplify-console-hosting/CHANGELOG.md index 6deaeb8c5c3..96e49b888ad 100644 --- a/packages/amplify-console-hosting/CHANGELOG.md +++ b/packages/amplify-console-hosting/CHANGELOG.md @@ -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. +## [1.4.5](https://github.com/aws-amplify/amplify-cli/compare/amplify-console-hosting@1.4.4...amplify-console-hosting@1.4.5) (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)) + + + + + ## [1.4.4](https://github.com/aws-amplify/amplify-cli/compare/amplify-console-hosting@1.4.3...amplify-console-hosting@1.4.4) (2020-09-16) diff --git a/packages/amplify-console-hosting/package.json b/packages/amplify-console-hosting/package.json index 98820634a39..27ca645ecf2 100644 --- a/packages/amplify-console-hosting/package.json +++ b/packages/amplify-console-hosting/package.json @@ -1,12 +1,12 @@ { "name": "amplify-console-hosting", - "version": "1.4.4", + "version": "1.4.5", "description": "cli plugin for AWS Amplify Console hosting", "main": "index.js", "author": "Amazon Web Services", "license": "Apache-2.0", "dependencies": { - "amplify-cli-core": "1.3.2", + "amplify-cli-core": "1.3.3", "archiver": "^3.1.1", "aws-sdk": "^2.608.0", "chalk": "^3.0.0", diff --git a/packages/amplify-console-integration-tests/CHANGELOG.md b/packages/amplify-console-integration-tests/CHANGELOG.md index 29aa07b27ed..ed53afc1852 100644 --- a/packages/amplify-console-integration-tests/CHANGELOG.md +++ b/packages/amplify-console-integration-tests/CHANGELOG.md @@ -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. +## [1.2.25](https://github.com/aws-amplify/amplify-console-integration-tests/compare/amplify-console-integration-tests@1.2.24...amplify-console-integration-tests@1.2.25) (2020-09-25) + +**Note:** Version bump only for package amplify-console-integration-tests + + + + + ## [1.2.24](https://github.com/aws-amplify/amplify-console-integration-tests/compare/amplify-console-integration-tests@1.2.23...amplify-console-integration-tests@1.2.24) (2020-09-16) diff --git a/packages/amplify-console-integration-tests/package.json b/packages/amplify-console-integration-tests/package.json index deddcad21b4..ef42f8c2f95 100644 --- a/packages/amplify-console-integration-tests/package.json +++ b/packages/amplify-console-integration-tests/package.json @@ -1,6 +1,6 @@ { "name": "amplify-console-integration-tests", - "version": "1.2.24", + "version": "1.2.25", "description": "", "repository": { "type": "git", @@ -21,7 +21,7 @@ }, "dependencies": { "@types/ini": "^1.3.30", - "amplify-e2e-core": "1.6.2", + "amplify-e2e-core": "1.7.0", "aws-sdk": "^2.608.0", "dotenv": "^8.2.0", "esm": "^3.2.25", diff --git a/packages/amplify-dotnet-function-template-provider/CHANGELOG.md b/packages/amplify-dotnet-function-template-provider/CHANGELOG.md index 9f121d8cabc..0af3eda34f9 100644 --- a/packages/amplify-dotnet-function-template-provider/CHANGELOG.md +++ b/packages/amplify-dotnet-function-template-provider/CHANGELOG.md @@ -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. +## [1.3.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-dotnet-function-template-provider@1.3.1...amplify-dotnet-function-template-provider@1.3.2) (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)) + + + + + ## [1.3.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-dotnet-function-template-provider@1.3.0...amplify-dotnet-function-template-provider@1.3.1) (2020-08-31) **Note:** Version bump only for package amplify-dotnet-function-template-provider diff --git a/packages/amplify-dotnet-function-template-provider/package.json b/packages/amplify-dotnet-function-template-provider/package.json index 2272c07a473..c2430e3dda7 100644 --- a/packages/amplify-dotnet-function-template-provider/package.json +++ b/packages/amplify-dotnet-function-template-provider/package.json @@ -1,6 +1,6 @@ { "name": "amplify-dotnet-function-template-provider", - "version": "1.3.1", + "version": "1.3.2", "description": ".NET Core templates supplied by the Amplify Team", "repository": { "type": "git", diff --git a/packages/amplify-e2e-core/CHANGELOG.md b/packages/amplify-e2e-core/CHANGELOG.md index cf96bb37d96..049c5dbf462 100644 --- a/packages/amplify-e2e-core/CHANGELOG.md +++ b/packages/amplify-e2e-core/CHANGELOG.md @@ -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. +# [1.7.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-e2e-core@1.6.2...amplify-e2e-core@1.7.0) (2020-09-25) + + +### Features + +* headless update auth ([#5308](https://github.com/aws-amplify/amplify-cli/issues/5308)) ([b942f35](https://github.com/aws-amplify/amplify-cli/commit/b942f3589f1df1361ae7eb6e42f18dbf6900d1bf)) + + + + + ## [1.6.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-e2e-core@1.6.1...amplify-e2e-core@1.6.2) (2020-09-16) diff --git a/packages/amplify-e2e-core/package.json b/packages/amplify-e2e-core/package.json index 736571e3a6f..6002a63da12 100644 --- a/packages/amplify-e2e-core/package.json +++ b/packages/amplify-e2e-core/package.json @@ -1,6 +1,6 @@ { "name": "amplify-e2e-core", - "version": "1.6.2", + "version": "1.7.0", "description": "", "repository": { "type": "git", @@ -21,8 +21,8 @@ "clean": "rimraf ./lib" }, "dependencies": { - "amplify-cli-core": "1.3.2", - "amplify-headless-interface": "1.3.0", + "amplify-cli-core": "1.3.3", + "amplify-headless-interface": "1.4.0", "chalk": "^3.0.0", "execa": "^4.0.3", "fs-extra": "^8.1.0", diff --git a/packages/amplify-e2e-core/src/init/initProjectHelper.ts b/packages/amplify-e2e-core/src/init/initProjectHelper.ts index 3fe3d70c9f5..b02baede990 100644 --- a/packages/amplify-e2e-core/src/init/initProjectHelper.ts +++ b/packages/amplify-e2e-core/src/init/initProjectHelper.ts @@ -14,6 +14,7 @@ const defaultSettings = { profileName: '\r', region: process.env.CLI_REGION, local: false, + disableAmplifyAppCreation: true, }; export const amplifyRegions = [ @@ -33,8 +34,16 @@ export const amplifyRegions = [ export function initJSProjectWithProfile(cwd: string, settings: Object) { const s = { ...defaultSettings, ...settings }; + let env; + + if (s.disableAmplifyAppCreation === true) { + env = { + CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1', + }; + } + return new Promise((resolve, reject) => { - spawn(getCLIPath(), ['init'], { cwd, stripColors: true }) + spawn(getCLIPath(), ['init'], { cwd, stripColors: true, env }) .wait('Enter a name for the project') .sendLine(s.name) .wait('Enter a name for the environment') @@ -72,7 +81,13 @@ export function initJSProjectWithProfile(cwd: string, settings: Object) { export function initAndroidProjectWithProfile(cwd: string, settings: Object) { const s = { ...defaultSettings, ...settings }; return new Promise((resolve, reject) => { - spawn(getCLIPath(), ['init'], { cwd, stripColors: true }) + spawn(getCLIPath(), ['init'], { + cwd, + stripColors: true, + env: { + CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1', + }, + }) .wait('Enter a name for the project') .sendLine(s.name) .wait('Enter a name for the environment') @@ -102,7 +117,13 @@ export function initAndroidProjectWithProfile(cwd: string, settings: Object) { export function initIosProjectWithProfile(cwd: string, settings: Object) { const s = { ...defaultSettings, ...settings }; return new Promise((resolve, reject) => { - spawn(getCLIPath(), ['init'], { cwd, stripColors: true }) + spawn(getCLIPath(), ['init'], { + cwd, + stripColors: true, + env: { + CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1', + }, + }) .wait('Enter a name for the project') .sendLine(s.name) .wait('Enter a name for the environment') @@ -132,7 +153,13 @@ export function initProjectWithAccessKey(cwd: string, settings: { accessKeyId: s const s = { ...defaultSettings, ...settings }; return new Promise((resolve, reject) => { - let chain = spawn(getCLIPath(), ['init'], { cwd, stripColors: true }) + let chain = spawn(getCLIPath(), ['init'], { + cwd, + stripColors: true, + env: { + CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1', + }, + }) .wait('Enter a name for the project') .sendLine(s.name) .wait('Enter a name for the environment') @@ -176,7 +203,13 @@ export function initProjectWithAccessKey(cwd: string, settings: { accessKeyId: s export function initNewEnvWithAccessKey(cwd: string, s: { envName: string; accessKeyId: string; secretAccessKey: string }) { return new Promise((resolve, reject) => { - let chain = spawn(getCLIPath(), ['init'], { cwd, stripColors: true }) + let chain = spawn(getCLIPath(), ['init'], { + cwd, + stripColors: true, + env: { + CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1', + }, + }) .wait('Do you want to use an existing environment?') .sendLine('n') .wait('Enter a name for the environment') @@ -206,7 +239,13 @@ export function initNewEnvWithAccessKey(cwd: string, s: { envName: string; acces export function initNewEnvWithProfile(cwd: string, s: { envName: string }) { return new Promise((resolve, reject) => { - spawn(getCLIPath(), ['init'], { cwd, stripColors: true }) + spawn(getCLIPath(), ['init'], { + cwd, + stripColors: true, + env: { + CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1', + }, + }) .wait('Do you want to use an existing environment?') .sendLine('n') .wait('Enter a name for the environment') diff --git a/packages/amplify-e2e-core/src/utils/headless.ts b/packages/amplify-e2e-core/src/utils/headless.ts index 7514798fc90..6c46913e96c 100644 --- a/packages/amplify-e2e-core/src/utils/headless.ts +++ b/packages/amplify-e2e-core/src/utils/headless.ts @@ -1,21 +1,36 @@ -import { AddApiRequest, UpdateApiRequest } from 'amplify-headless-interface'; +import { AddApiRequest, AddAuthRequest, UpdateApiRequest, UpdateAuthRequest } from 'amplify-headless-interface'; import execa from 'execa'; import { getCLIPath } from '..'; -export const addHeadlessApi = (cwd: string, request: AddApiRequest) => { - return executeHeadlessCommand(cwd, 'api', 'add', request); +export const addHeadlessApi = async (cwd: string, request: AddApiRequest) => { + await executeHeadlessCommand(cwd, 'api', 'add', request); }; export const updateHeadlessApi = async (cwd: string, request: UpdateApiRequest) => { - return executeHeadlessCommand(cwd, 'api', 'update', request); + await executeHeadlessCommand(cwd, 'api', 'update', request); }; export const removeHeadlessApi = async (cwd: string, apiName: string) => { - await execa(getCLIPath(), ['remove', 'api', apiName, '--yes'], { cwd }); + await headlessRemoveResource(cwd, 'api', apiName); }; +export const addHeadlessAuth = async (cwd: string, request: AddAuthRequest) => { + await executeHeadlessCommand(cwd, 'auth', 'add', request); +}; + +export const updateHeadlessAuth = async (cwd: string, request: UpdateAuthRequest) => { + await executeHeadlessCommand(cwd, 'auth', 'update', request); +}; + +export const removeHeadlessAuth = async (cwd: string, authName: string) => { + await headlessRemoveResource(cwd, 'auth', authName); +}; + +const headlessRemoveResource = async (cwd: string, category: string, resourceName: string) => { + await execa(getCLIPath(), ['remove', category, resourceName, '--yes'], { cwd }); +}; const executeHeadlessCommand = async (cwd: string, category: string, operation: string, request: AnyHeadlessRequest) => { await execa(getCLIPath(), [operation, category, '--headless'], { input: JSON.stringify(request), cwd }); }; -type AnyHeadlessRequest = AddApiRequest | UpdateApiRequest; +type AnyHeadlessRequest = AddApiRequest | UpdateApiRequest | AddAuthRequest | UpdateAuthRequest; diff --git a/packages/amplify-e2e-core/src/utils/nexpect.ts b/packages/amplify-e2e-core/src/utils/nexpect.ts index 45aaa348ec8..840a2f26028 100644 --- a/packages/amplify-e2e-core/src/utils/nexpect.ts +++ b/packages/amplify-e2e-core/src/utils/nexpect.ts @@ -493,10 +493,21 @@ export function nspawn(command: string | string[], params: string[] = [], option command = command[0]; } + let childEnv = undefined; + + // If we have an environment passed in we've to add the current process' environment, otherwised the forked + // process would not have $PATH and others that is required to run amplify-cli successfully. + if (options.env) { + childEnv = { + ...process.env, + ...options.env, + }; + } + let context: Context = { command: command, cwd: options.cwd || undefined, - env: options.env || undefined, + env: childEnv || undefined, ignoreCase: options.ignoreCase || true, noOutputTimeout: options.noOutputTimeout || DEFAULT_NO_OUTPUT_TIMEOUT, params: params, diff --git a/packages/amplify-e2e-core/src/utils/pinpoint.ts b/packages/amplify-e2e-core/src/utils/pinpoint.ts index 6a7b05b12bf..e990230bbb3 100644 --- a/packages/amplify-e2e-core/src/utils/pinpoint.ts +++ b/packages/amplify-e2e-core/src/utils/pinpoint.ts @@ -69,9 +69,15 @@ export async function pinpointAppExist(pinpointProjectId: string): Promise { - let chain = spawn(getCLIPath(), ['init'], { cwd, stripColors: true }) + let chain = spawn(getCLIPath(), ['init'], { + cwd, + stripColors: true, + env: { + CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1', + }, + }) .wait('Enter a name for the project') .sendLine(settings.name) .wait('Enter a name for the environment') diff --git a/packages/amplify-e2e-tests/CHANGELOG.md b/packages/amplify-e2e-tests/CHANGELOG.md index 36674957ecb..d24a87a1c98 100644 --- a/packages/amplify-e2e-tests/CHANGELOG.md +++ b/packages/amplify-e2e-tests/CHANGELOG.md @@ -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.25.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-e2e-tests@2.24.0...amplify-e2e-tests@2.25.0) (2020-09-25) + + +### 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.24.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-e2e-tests@2.23.1...amplify-e2e-tests@2.24.0) (2020-09-16) diff --git a/packages/amplify-e2e-tests/package.json b/packages/amplify-e2e-tests/package.json index 0d4920b6d5c..bf1e00fa986 100644 --- a/packages/amplify-e2e-tests/package.json +++ b/packages/amplify-e2e-tests/package.json @@ -1,6 +1,6 @@ { "name": "amplify-e2e-tests", - "version": "2.24.0", + "version": "2.25.0", "description": "", "repository": { "type": "git", @@ -21,8 +21,8 @@ "setup-profile": "ts-node ./src/configure_tests.ts" }, "dependencies": { - "amplify-cli-core": "1.3.2", - "amplify-e2e-core": "1.6.2", + "amplify-cli-core": "1.3.3", + "amplify-e2e-core": "1.7.0", "aws-amplify": "^3.0.8", "aws-appsync": "^2.0.2", "aws-sdk": "^2.608.0", diff --git a/packages/amplify-e2e-tests/src/__tests__/__snapshots__/api_1.test.ts.snap b/packages/amplify-e2e-tests/src/__tests__/__snapshots__/api_3.test.ts.snap similarity index 100% rename from packages/amplify-e2e-tests/src/__tests__/__snapshots__/api_1.test.ts.snap rename to packages/amplify-e2e-tests/src/__tests__/__snapshots__/api_3.test.ts.snap diff --git a/packages/amplify-e2e-tests/src/__tests__/api_1.test.ts b/packages/amplify-e2e-tests/src/__tests__/api_1.test.ts index 75cf93236b0..e8eb25415c1 100644 --- a/packages/amplify-e2e-tests/src/__tests__/api_1.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/api_1.test.ts @@ -3,11 +3,6 @@ import { amplifyPushUpdate, deleteProject, initJSProjectWithProfile, - getSchemaPath, - addHeadlessApi, - updateHeadlessApi, - getProjectSchema, - removeHeadlessApi, addApiWithSchema, updateApiSchema, updateApiWithMultiAuth, @@ -20,9 +15,7 @@ import { } from 'amplify-e2e-core'; import path from 'path'; import { existsSync } from 'fs'; -import { TRANSFORM_CURRENT_VERSION, TRANSFORM_BASE_VERSION, writeTransformerConfiguration } from 'graphql-transformer-core'; -import { AddApiRequest, UpdateApiRequest } from 'amplify-headless-interface'; -import { readFileSync } from 'fs-extra'; +import { TRANSFORM_CURRENT_VERSION } from 'graphql-transformer-core'; import _ from 'lodash'; describe('amplify add api (GraphQL)', () => { @@ -151,143 +144,4 @@ describe('amplify add api (GraphQL)', () => { expect(transformConfig.Version).toBeDefined(); expect(transformConfig.Version).toEqual(TRANSFORM_CURRENT_VERSION); }); - - it('init a project and add the simple_model api, change transformer version to base version and push', async () => { - const name = `simplemodelv${TRANSFORM_BASE_VERSION}`; - await initJSProjectWithProfile(projRoot, { name }); - await addApiWithSchema(projRoot, 'simple_model.graphql'); - - const transformConfig = getTransformConfig(projRoot, name); - expect(transformConfig).toBeDefined(); - expect(transformConfig.Version).toBeDefined(); - expect(transformConfig.Version).toEqual(TRANSFORM_CURRENT_VERSION); - - transformConfig.Version = TRANSFORM_BASE_VERSION; - const apiRoot = path.join(projRoot, 'amplify', 'backend', 'api', name); - writeTransformerConfiguration(apiRoot, transformConfig); - - await amplifyPush(projRoot); - - const meta = getProjectMeta(projRoot); - const { output } = meta.api[name]; - const { GraphQLAPIIdOutput, GraphQLAPIEndpointOutput, GraphQLAPIKeyOutput } = output; - const { graphqlApi } = await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); - - expect(GraphQLAPIIdOutput).toBeDefined(); - expect(GraphQLAPIEndpointOutput).toBeDefined(); - expect(GraphQLAPIKeyOutput).toBeDefined(); - - expect(graphqlApi).toBeDefined(); - expect(graphqlApi.apiId).toEqual(GraphQLAPIIdOutput); - }); - - const addApiRequest: AddApiRequest = { - version: 1, - serviceConfiguration: { - serviceName: 'AppSync', - apiName: 'myApiName', - transformSchema: readFileSync(getSchemaPath('simple_model.graphql'), 'utf8'), - defaultAuthType: { - mode: 'API_KEY', - }, - }, - }; - - it('creates AppSync API in headless mode', async () => { - await initJSProjectWithProfile(projRoot, {}); - await addHeadlessApi(projRoot, addApiRequest); - await amplifyPush(projRoot); - - // verify - const meta = getProjectMeta(projRoot); - const { output } = meta.api.myApiName; - const { GraphQLAPIIdOutput, GraphQLAPIEndpointOutput, GraphQLAPIKeyOutput } = output; - const { graphqlApi } = await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); - - expect(GraphQLAPIIdOutput).toBeDefined(); - expect(GraphQLAPIEndpointOutput).toBeDefined(); - expect(GraphQLAPIKeyOutput).toBeDefined(); - - expect(graphqlApi).toBeDefined(); - expect(graphqlApi.apiId).toEqual(GraphQLAPIIdOutput); - }); - - const newSchema = readFileSync(getSchemaPath('two-model-schema.graphql'), 'utf8'); - - const updateApiRequest: UpdateApiRequest = { - version: 1, - serviceModification: { - serviceName: 'AppSync', - transformSchema: newSchema, - defaultAuthType: { - mode: 'AWS_IAM', - }, - additionalAuthTypes: [ - { - mode: 'API_KEY', - }, - ], - conflictResolution: { - defaultResolutionStrategy: { - type: 'OPTIMISTIC_CONCURRENCY', - }, - }, - }, - }; - - it('updates AppSync API in headless mode', async () => { - await initJSProjectWithProfile(projRoot, {}); - await addHeadlessApi(projRoot, addApiRequest); - await amplifyPush(projRoot); - await updateHeadlessApi(projRoot, updateApiRequest); - await amplifyPushUpdate(projRoot); - - // verify - const meta = getProjectMeta(projRoot); - const { output } = meta.api.myApiName; - const { GraphQLAPIIdOutput, GraphQLAPIEndpointOutput, GraphQLAPIKeyOutput } = output; - const { graphqlApi } = await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); - - expect(GraphQLAPIIdOutput).toBeDefined(); - expect(GraphQLAPIEndpointOutput).toBeDefined(); - expect(GraphQLAPIKeyOutput).toBeDefined(); - - expect(graphqlApi).toBeDefined(); - expect(graphqlApi.apiId).toEqual(GraphQLAPIIdOutput); - - expect(getTransformConfig(projRoot, 'myApiName')).toMatchSnapshot(); - expect(output.authConfig).toMatchSnapshot(); - expect(getProjectSchema(projRoot, 'myApiName')).toMatchSnapshot(); - }); - - it('removes AppSync API in headless mode', async () => { - await initJSProjectWithProfile(projRoot, {}); - await addHeadlessApi(projRoot, addApiRequest); - await amplifyPush(projRoot); - - // verify - const meta = getProjectMeta(projRoot); - const { output } = meta.api.myApiName; - const { GraphQLAPIIdOutput, GraphQLAPIEndpointOutput, GraphQLAPIKeyOutput } = output; - const { graphqlApi } = await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); - - expect(GraphQLAPIIdOutput).toBeDefined(); - expect(GraphQLAPIEndpointOutput).toBeDefined(); - expect(GraphQLAPIKeyOutput).toBeDefined(); - - expect(graphqlApi).toBeDefined(); - expect(graphqlApi.apiId).toEqual(GraphQLAPIIdOutput); - - await removeHeadlessApi(projRoot, 'myApiName'); - await amplifyPushUpdate(projRoot); - - const newMeta = getProjectMeta(projRoot); - expect(_.isEmpty(newMeta.api)).toBe(true); - try { - await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); - expect(true).toBe(false); // expecting failure - } catch (err) { - expect(err.message).toBe(`GraphQL API ${GraphQLAPIIdOutput} not found.`); - } - }); }); diff --git a/packages/amplify-e2e-tests/src/__tests__/api_2.test.ts b/packages/amplify-e2e-tests/src/__tests__/api_2.test.ts index 94db481b80f..eec66454416 100644 --- a/packages/amplify-e2e-tests/src/__tests__/api_2.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/api_2.test.ts @@ -8,8 +8,6 @@ import { addApiWithSchema, addApiWithSchemaAndConflictDetection, addRestApi, - updateApiSchema, - updateApiWithMultiAuth, updateAPIWithResolutionStrategy, apiUpdateToggleDataStore, addFunction, @@ -21,7 +19,7 @@ import { getProjectMeta, getTransformConfig, } from 'amplify-e2e-core'; -import { TRANSFORM_CURRENT_VERSION, TRANSFORM_BASE_VERSION, writeTransformerConfiguration } from 'graphql-transformer-core'; +import { TRANSFORM_CURRENT_VERSION } from 'graphql-transformer-core'; import _ from 'lodash'; // to deal with bug in cognito-identity-js @@ -54,7 +52,7 @@ describe('amplify add api (GraphQL)', () => { const { output } = meta.api[name]; const url = output.GraphQLAPIEndpointOutput as string; const apiKey = output.GraphQLAPIKeyOutput as string; - + const appSyncClient = new AWSAppSyncClient({ url, region, @@ -64,12 +62,9 @@ describe('amplify add api (GraphQL)', () => { apiKey, }, }); - + const createMutation = /* GraphQL */ ` - mutation CreateNote( - $input: CreateNoteInput! - $condition: ModelNoteConditionInput - ) { + mutation CreateNote($input: CreateNoteInput!, $condition: ModelNoteConditionInput) { createNote(input: $input, condition: $condition) { noteId note @@ -82,22 +77,19 @@ describe('amplify add api (GraphQL)', () => { } `; const createInput = { - input:{ + input: { noteId: '1', - note: 'initial note' - } + note: 'initial note', + }, }; const createResult = await appSyncClient.mutate({ mutation: gql(createMutation), fetchPolicy: 'no-cache', variables: createInput, - }) + }); const updateMutation = /* GraphQL */ ` - mutation UpdateNote( - $input: UpdateNoteInput! - $condition: ModelNoteConditionInput - ) { + mutation UpdateNote($input: UpdateNoteInput!, $condition: ModelNoteConditionInput) { updateNote(input: $input, condition: $condition) { noteId note @@ -113,7 +105,7 @@ describe('amplify add api (GraphQL)', () => { input: { noteId: createResult.data.createNote.noteId, note: 'note updated', - _version: createResult.data.createNote._version + _version: createResult.data.createNote._version, }, }; @@ -121,7 +113,7 @@ describe('amplify add api (GraphQL)', () => { mutation: gql(updateMutation), fetchPolicy: 'no-cache', variables: updateInput, - }) + }); expect(updateResult.data).toBeDefined(); expect(updateResult.data.updateNote).toBeDefined(); diff --git a/packages/amplify-e2e-tests/src/__tests__/api_3.test.ts b/packages/amplify-e2e-tests/src/__tests__/api_3.test.ts new file mode 100644 index 00000000000..266fafd3423 --- /dev/null +++ b/packages/amplify-e2e-tests/src/__tests__/api_3.test.ts @@ -0,0 +1,177 @@ +import { + amplifyPush, + amplifyPushUpdate, + deleteProject, + initJSProjectWithProfile, + getSchemaPath, + addHeadlessApi, + updateHeadlessApi, + getProjectSchema, + removeHeadlessApi, + addApiWithSchema, + createNewProjectDir, + deleteProjectDir, + getAppSyncApi, + getProjectMeta, + getTransformConfig, +} from 'amplify-e2e-core'; +import path from 'path'; +import { existsSync } from 'fs'; +import { TRANSFORM_CURRENT_VERSION, TRANSFORM_BASE_VERSION, writeTransformerConfiguration } from 'graphql-transformer-core'; +import { AddApiRequest, UpdateApiRequest } from 'amplify-headless-interface'; +import { readFileSync } from 'fs-extra'; +import _ from 'lodash'; + +describe('amplify add api (GraphQL)', () => { + let projRoot: string; + beforeEach(async () => { + projRoot = await createNewProjectDir('graphql-api'); + }); + + afterEach(async () => { + const metaFilePath = path.join(projRoot, 'amplify', '#current-cloud-backend', 'amplify-meta.json'); + if (existsSync(metaFilePath)) { + await deleteProject(projRoot); + } + deleteProjectDir(projRoot); + }); + + it('init a project and add the simple_model api, change transformer version to base version and push', async () => { + const name = `simplemodelv${TRANSFORM_BASE_VERSION}`; + await initJSProjectWithProfile(projRoot, { name }); + await addApiWithSchema(projRoot, 'simple_model.graphql'); + + const transformConfig = getTransformConfig(projRoot, name); + expect(transformConfig).toBeDefined(); + expect(transformConfig.Version).toBeDefined(); + expect(transformConfig.Version).toEqual(TRANSFORM_CURRENT_VERSION); + + transformConfig.Version = TRANSFORM_BASE_VERSION; + const apiRoot = path.join(projRoot, 'amplify', 'backend', 'api', name); + writeTransformerConfiguration(apiRoot, transformConfig); + + await amplifyPush(projRoot); + + const meta = getProjectMeta(projRoot); + const { output } = meta.api[name]; + const { GraphQLAPIIdOutput, GraphQLAPIEndpointOutput, GraphQLAPIKeyOutput } = output; + const { graphqlApi } = await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); + + expect(GraphQLAPIIdOutput).toBeDefined(); + expect(GraphQLAPIEndpointOutput).toBeDefined(); + expect(GraphQLAPIKeyOutput).toBeDefined(); + + expect(graphqlApi).toBeDefined(); + expect(graphqlApi.apiId).toEqual(GraphQLAPIIdOutput); + }); + + const addApiRequest: AddApiRequest = { + version: 1, + serviceConfiguration: { + serviceName: 'AppSync', + apiName: 'myApiName', + transformSchema: readFileSync(getSchemaPath('simple_model.graphql'), 'utf8'), + defaultAuthType: { + mode: 'API_KEY', + }, + }, + }; + + it('creates AppSync API in headless mode', async () => { + await initJSProjectWithProfile(projRoot, {}); + await addHeadlessApi(projRoot, addApiRequest); + await amplifyPush(projRoot); + + // verify + const meta = getProjectMeta(projRoot); + const { output } = meta.api.myApiName; + const { GraphQLAPIIdOutput, GraphQLAPIEndpointOutput, GraphQLAPIKeyOutput } = output; + const { graphqlApi } = await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); + + expect(GraphQLAPIIdOutput).toBeDefined(); + expect(GraphQLAPIEndpointOutput).toBeDefined(); + expect(GraphQLAPIKeyOutput).toBeDefined(); + + expect(graphqlApi).toBeDefined(); + expect(graphqlApi.apiId).toEqual(GraphQLAPIIdOutput); + }); + + const newSchema = readFileSync(getSchemaPath('two-model-schema.graphql'), 'utf8'); + + const updateApiRequest: UpdateApiRequest = { + version: 1, + serviceModification: { + serviceName: 'AppSync', + transformSchema: newSchema, + defaultAuthType: { + mode: 'AWS_IAM', + }, + additionalAuthTypes: [ + { + mode: 'API_KEY', + }, + ], + conflictResolution: { + defaultResolutionStrategy: { + type: 'OPTIMISTIC_CONCURRENCY', + }, + }, + }, + }; + + it('updates AppSync API in headless mode', async () => { + await initJSProjectWithProfile(projRoot, {}); + await addHeadlessApi(projRoot, addApiRequest); + await amplifyPush(projRoot); + await updateHeadlessApi(projRoot, updateApiRequest); + await amplifyPushUpdate(projRoot); + + // verify + const meta = getProjectMeta(projRoot); + const { output } = meta.api.myApiName; + const { GraphQLAPIIdOutput, GraphQLAPIEndpointOutput, GraphQLAPIKeyOutput } = output; + const { graphqlApi } = await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); + + expect(GraphQLAPIIdOutput).toBeDefined(); + expect(GraphQLAPIEndpointOutput).toBeDefined(); + expect(GraphQLAPIKeyOutput).toBeDefined(); + + expect(graphqlApi).toBeDefined(); + expect(graphqlApi.apiId).toEqual(GraphQLAPIIdOutput); + + expect(getTransformConfig(projRoot, 'myApiName')).toMatchSnapshot(); + expect(output.authConfig).toMatchSnapshot(); + expect(getProjectSchema(projRoot, 'myApiName')).toMatchSnapshot(); + }); + + it('removes AppSync API in headless mode', async () => { + await initJSProjectWithProfile(projRoot, {}); + await addHeadlessApi(projRoot, addApiRequest); + await amplifyPush(projRoot); + + // verify + const meta = getProjectMeta(projRoot); + const { output } = meta.api.myApiName; + const { GraphQLAPIIdOutput, GraphQLAPIEndpointOutput, GraphQLAPIKeyOutput } = output; + const { graphqlApi } = await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); + + expect(GraphQLAPIIdOutput).toBeDefined(); + expect(GraphQLAPIEndpointOutput).toBeDefined(); + expect(GraphQLAPIKeyOutput).toBeDefined(); + + expect(graphqlApi).toBeDefined(); + expect(graphqlApi.apiId).toEqual(GraphQLAPIIdOutput); + + await removeHeadlessApi(projRoot, 'myApiName'); + await amplifyPushUpdate(projRoot); + + const newMeta = getProjectMeta(projRoot); + expect(_.isEmpty(newMeta.api)).toBe(true); + try { + await getAppSyncApi(GraphQLAPIIdOutput, meta.providers.awscloudformation.Region); + expect(true).toBe(false); // expecting failure + } catch (err) { + expect(err.message).toBe(`GraphQL API ${GraphQLAPIIdOutput} not found.`); + } + }); +}); diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_1.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_1.test.ts index c581343af52..f6d90ae3e87 100644 --- a/packages/amplify-e2e-tests/src/__tests__/auth_1.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/auth_1.test.ts @@ -1,33 +1,16 @@ -import * as fs from 'fs-extra'; -import { - initJSProjectWithProfile, - initAndroidProjectWithProfile, - initIosProjectWithProfile, - deleteProject, - amplifyPushAuth, - amplifyPush, -} from 'amplify-e2e-core'; +import { initJSProjectWithProfile, deleteProject, amplifyPushAuth, amplifyPush } from 'amplify-e2e-core'; import { addAuthWithDefault, removeAuthWithDefault, addAuthWithDefaultSocial, addAuthWithGroupTrigger, addAuthWithRecaptchaTrigger, - addAuthWithCustomTrigger, - addAuthWithSignInSignOutUrl, - updateAuthWithoutCustomTrigger, - updateAuthRemoveRecaptchaTrigger, - updateAuthSignInSignOutUrl, addAuthViaAPIWithTrigger, - addAuthWithMaxOptions, - addAuthUserPoolOnly, } from 'amplify-e2e-core'; import { createNewProjectDir, deleteProjectDir, getProjectMeta, - getAwsAndroidConfig, - getAwsIOSConfig, getUserPool, getUserPoolClients, getLambdaFunction, diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_2.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_2.test.ts index b7d37ee2ff2..ea02421e7f6 100644 --- a/packages/amplify-e2e-tests/src/__tests__/auth_2.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/auth_2.test.ts @@ -1,24 +1,7 @@ -import * as fs from 'fs-extra'; -import { - initJSProjectWithProfile, - initAndroidProjectWithProfile, - initIosProjectWithProfile, - deleteProject, - amplifyPushAuth, - amplifyPush, -} from 'amplify-e2e-core'; +import { initJSProjectWithProfile, deleteProject, amplifyPushAuth } from 'amplify-e2e-core'; import { addAuthWithDefault, removeAuthWithDefault, - addAuthWithDefaultSocial, - addAuthWithGroupTrigger, - addAuthWithRecaptchaTrigger, - addAuthWithCustomTrigger, - addAuthWithSignInSignOutUrl, - updateAuthWithoutCustomTrigger, - updateAuthRemoveRecaptchaTrigger, - updateAuthSignInSignOutUrl, - addAuthViaAPIWithTrigger, addAuthWithMaxOptions, addAuthUserPoolOnly, getBackendAmplifyMeta, @@ -27,12 +10,11 @@ import { createNewProjectDir, deleteProjectDir, getProjectMeta, - getAwsAndroidConfig, - getAwsIOSConfig, getUserPool, getUserPoolClients, getLambdaFunction, } from 'amplify-e2e-core'; +import _ from 'lodash'; const defaultsSettings = { name: 'authTest', @@ -109,86 +91,3 @@ describe('amplify add auth...', () => { expect(defineFunction.Configuration.Environment.Variables.MODULES).toEqual('custom'); }); }); - -describe('amplify updating auth...', () => { - let projRoot: string; - beforeEach(async () => { - projRoot = await createNewProjectDir('auth-update'); - }); - - afterEach(async () => { - await deleteProject(projRoot); - deleteProjectDir(projRoot); - }); - - it('...should edit signin url on update', async () => { - const settings = { - signinUrl: 'http://localhost:3001/', - signoutUrl: 'http://localhost:3002/', - updatesigninUrl: 'http://localhost:3003/', - updatesignoutUrl: 'http://localhost:3004/', - }; - await initAndroidProjectWithProfile(projRoot, defaultsSettings); - await addAuthWithSignInSignOutUrl(projRoot, settings); - await updateAuthSignInSignOutUrl(projRoot, settings); - }); - - it('...should init a project and add auth with a custom trigger, and then update to remove the custom js while leaving the other js', async () => { - await initJSProjectWithProfile(projRoot, defaultsSettings); - await addAuthWithCustomTrigger(projRoot, {}); - await amplifyPushAuth(projRoot); - const meta = getProjectMeta(projRoot); - - const functionName = `${Object.keys(meta.auth)[0]}PreSignup-integtest`; - - const authMeta = Object.keys(meta.auth).map(key => meta.auth[key])[0]; - const id = authMeta.output.UserPoolId; - const userPool = await getUserPool(id, meta.providers.awscloudformation.Region); - const clientIds = [authMeta.output.AppClientIDWeb, authMeta.output.AppClientID]; - const clients = await getUserPoolClients(id, clientIds, meta.providers.awscloudformation.Region); - - const lambdaFunction = await getLambdaFunction(functionName, meta.providers.awscloudformation.Region); - const dirContents = fs.readdirSync(`${projRoot}/amplify/backend/function/${Object.keys(meta.auth)[0]}PreSignup/src`); - expect(dirContents.includes('custom.js')).toBeTruthy(); - expect(userPool.UserPool).toBeDefined(); - expect(clients).toHaveLength(2); - expect(lambdaFunction).toBeDefined(); - expect(lambdaFunction.Configuration.Environment.Variables.MODULES).toEqual('email-filter-blacklist,custom'); - - await updateAuthWithoutCustomTrigger(projRoot, {}); - await amplifyPushAuth(projRoot); - const updatedFunction = await getLambdaFunction(functionName, meta.providers.awscloudformation.Region); - const updatedDirContents = fs.readdirSync(`${projRoot}/amplify/backend/function/${Object.keys(meta.auth)[0]}PreSignup/src`); - expect(updatedDirContents.includes('custom.js')).toBeFalsy(); - expect(updatedDirContents.includes('email-filter-blacklist.js')).toBeTruthy(); - expect(updatedFunction.Configuration.Environment.Variables.MODULES).toEqual('email-filter-blacklist'); - }); - - it('...should init an android project and add customAuth flag, and remove flag when custom auth triggers are removed upon update ', async () => { - await initAndroidProjectWithProfile(projRoot, defaultsSettings); - await addAuthWithRecaptchaTrigger(projRoot, {}); - await amplifyPushAuth(projRoot); - let meta = getAwsAndroidConfig(projRoot); - expect(meta.Auth.Default.authenticationFlowType).toBeDefined(); - expect(meta.Auth.Default.authenticationFlowType).toEqual('CUSTOM_AUTH'); - await updateAuthRemoveRecaptchaTrigger(projRoot, {}); - await amplifyPushAuth(projRoot); - meta = getAwsAndroidConfig(projRoot); - expect(meta.Auth.Default.authenticationFlowType).toBeDefined(); - expect(meta.Auth.Default.authenticationFlowType).toEqual('USER_SRP_AUTH'); - }); - - it('...should init an ios project and add customAuth flag, and remove the flag when custom auth triggers are removed upon update', async () => { - await initIosProjectWithProfile(projRoot, defaultsSettings); - await addAuthWithRecaptchaTrigger(projRoot, {}); - await amplifyPushAuth(projRoot); - let meta = getAwsIOSConfig(projRoot); - expect(meta.Auth.Default.authenticationFlowType).toBeDefined(); - expect(meta.Auth.Default.authenticationFlowType).toEqual('CUSTOM_AUTH'); - await updateAuthRemoveRecaptchaTrigger(projRoot, {}); - await amplifyPushAuth(projRoot); - meta = getAwsIOSConfig(projRoot); - expect(meta.Auth.Default.authenticationFlowType).toBeDefined(); - expect(meta.Auth.Default.authenticationFlowType).toEqual('USER_SRP_AUTH'); - }); -}); diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_3.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_3.test.ts new file mode 100644 index 00000000000..8da02cfa602 --- /dev/null +++ b/packages/amplify-e2e-tests/src/__tests__/auth_3.test.ts @@ -0,0 +1,114 @@ +import * as fs from 'fs-extra'; +import { + initJSProjectWithProfile, + initAndroidProjectWithProfile, + initIosProjectWithProfile, + deleteProject, + amplifyPushAuth, +} from 'amplify-e2e-core'; +import { + addAuthWithRecaptchaTrigger, + addAuthWithCustomTrigger, + addAuthWithSignInSignOutUrl, + updateAuthWithoutCustomTrigger, + updateAuthRemoveRecaptchaTrigger, + updateAuthSignInSignOutUrl, +} from 'amplify-e2e-core'; +import { + createNewProjectDir, + deleteProjectDir, + getProjectMeta, + getAwsAndroidConfig, + getAwsIOSConfig, + getUserPool, + getUserPoolClients, + getLambdaFunction, +} from 'amplify-e2e-core'; +import _ from 'lodash'; + +const defaultsSettings = { + name: 'authTest', +}; + +describe('amplify updating auth...', () => { + let projRoot: string; + beforeEach(async () => { + projRoot = await createNewProjectDir('auth-update'); + }); + + afterEach(async () => { + await deleteProject(projRoot); + deleteProjectDir(projRoot); + }); + + it('...should edit signin url on update', async () => { + const settings = { + signinUrl: 'http://localhost:3001/', + signoutUrl: 'http://localhost:3002/', + updatesigninUrl: 'http://localhost:3003/', + updatesignoutUrl: 'http://localhost:3004/', + }; + await initAndroidProjectWithProfile(projRoot, defaultsSettings); + await addAuthWithSignInSignOutUrl(projRoot, settings); + await updateAuthSignInSignOutUrl(projRoot, settings); + }); + + it('...should init a project and add auth with a custom trigger, and then update to remove the custom js while leaving the other js', async () => { + await initJSProjectWithProfile(projRoot, defaultsSettings); + await addAuthWithCustomTrigger(projRoot, {}); + await amplifyPushAuth(projRoot); + const meta = getProjectMeta(projRoot); + + const functionName = `${Object.keys(meta.auth)[0]}PreSignup-integtest`; + + const authMeta = Object.keys(meta.auth).map(key => meta.auth[key])[0]; + const id = authMeta.output.UserPoolId; + const userPool = await getUserPool(id, meta.providers.awscloudformation.Region); + const clientIds = [authMeta.output.AppClientIDWeb, authMeta.output.AppClientID]; + const clients = await getUserPoolClients(id, clientIds, meta.providers.awscloudformation.Region); + + const lambdaFunction = await getLambdaFunction(functionName, meta.providers.awscloudformation.Region); + const dirContents = fs.readdirSync(`${projRoot}/amplify/backend/function/${Object.keys(meta.auth)[0]}PreSignup/src`); + expect(dirContents.includes('custom.js')).toBeTruthy(); + expect(userPool.UserPool).toBeDefined(); + expect(clients).toHaveLength(2); + expect(lambdaFunction).toBeDefined(); + expect(lambdaFunction.Configuration.Environment.Variables.MODULES).toEqual('email-filter-blacklist,custom'); + + await updateAuthWithoutCustomTrigger(projRoot, {}); + await amplifyPushAuth(projRoot); + const updatedFunction = await getLambdaFunction(functionName, meta.providers.awscloudformation.Region); + const updatedDirContents = fs.readdirSync(`${projRoot}/amplify/backend/function/${Object.keys(meta.auth)[0]}PreSignup/src`); + expect(updatedDirContents.includes('custom.js')).toBeFalsy(); + expect(updatedDirContents.includes('email-filter-blacklist.js')).toBeTruthy(); + expect(updatedFunction.Configuration.Environment.Variables.MODULES).toEqual('email-filter-blacklist'); + }); + + it('...should init an android project and add customAuth flag, and remove flag when custom auth triggers are removed upon update ', async () => { + await initAndroidProjectWithProfile(projRoot, defaultsSettings); + await addAuthWithRecaptchaTrigger(projRoot, {}); + await amplifyPushAuth(projRoot); + let meta = getAwsAndroidConfig(projRoot); + expect(meta.Auth.Default.authenticationFlowType).toBeDefined(); + expect(meta.Auth.Default.authenticationFlowType).toEqual('CUSTOM_AUTH'); + await updateAuthRemoveRecaptchaTrigger(projRoot, {}); + await amplifyPushAuth(projRoot); + meta = getAwsAndroidConfig(projRoot); + expect(meta.Auth.Default.authenticationFlowType).toBeDefined(); + expect(meta.Auth.Default.authenticationFlowType).toEqual('USER_SRP_AUTH'); + }); + + it('...should init an ios project and add customAuth flag, and remove the flag when custom auth triggers are removed upon update', async () => { + await initIosProjectWithProfile(projRoot, defaultsSettings); + await addAuthWithRecaptchaTrigger(projRoot, {}); + await amplifyPushAuth(projRoot); + let meta = getAwsIOSConfig(projRoot); + expect(meta.Auth.Default.authenticationFlowType).toBeDefined(); + expect(meta.Auth.Default.authenticationFlowType).toEqual('CUSTOM_AUTH'); + await updateAuthRemoveRecaptchaTrigger(projRoot, {}); + await amplifyPushAuth(projRoot); + meta = getAwsIOSConfig(projRoot); + expect(meta.Auth.Default.authenticationFlowType).toBeDefined(); + expect(meta.Auth.Default.authenticationFlowType).toEqual('USER_SRP_AUTH'); + }); +}); diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_4.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_4.test.ts new file mode 100644 index 00000000000..444304abceb --- /dev/null +++ b/packages/amplify-e2e-tests/src/__tests__/auth_4.test.ts @@ -0,0 +1,94 @@ +import * as fs from 'fs-extra'; +import { + initJSProjectWithProfile, + deleteProject, + amplifyPushAuth, + addHeadlessAuth, + updateHeadlessAuth, + removeHeadlessAuth, +} from 'amplify-e2e-core'; +import { addAuthWithDefault, getBackendAmplifyMeta } from 'amplify-e2e-core'; +import { createNewProjectDir, deleteProjectDir, getProjectMeta, getUserPool } from 'amplify-e2e-core'; +import { AddAuthRequest, CognitoUserPoolSigninMethod, CognitoUserProperty, UpdateAuthRequest } from 'amplify-headless-interface'; +import _ from 'lodash'; + +const defaultsSettings = { + name: 'authTest', +}; + +describe('headless auth', () => { + let projRoot: string; + beforeEach(async () => { + projRoot = await createNewProjectDir('auth-update'); + }); + + afterEach(async () => { + await deleteProject(projRoot); + deleteProjectDir(projRoot); + }); + it('adds auth resource', async () => { + const addAuthRequest: AddAuthRequest = { + version: 1, + resourceName: 'myAuthResource', + serviceConfiguration: { + serviceName: 'Cognito', + includeIdentityPool: false, + userPoolConfiguration: { + requiredSignupAttributes: [CognitoUserProperty.EMAIL, CognitoUserProperty.PHONE_NUMBER], + signinMethod: CognitoUserPoolSigninMethod.USERNAME, + }, + }, + }; + + await initJSProjectWithProfile(projRoot, defaultsSettings); + await addHeadlessAuth(projRoot, addAuthRequest); + await amplifyPushAuth(projRoot); + const meta = getProjectMeta(projRoot); + const id = Object.keys(meta.auth).map(key => meta.auth[key])[0].output.UserPoolId; + const userPool = await getUserPool(id, meta.providers.awscloudformation.Region); + expect(userPool.UserPool).toBeDefined(); + }); + + it('updates existing auth resource', async () => { + const updateAuthRequest: UpdateAuthRequest = { + version: 1, + serviceModification: { + serviceName: 'Cognito', + userPoolModification: { + userPoolGroups: [ + { + groupName: 'group1', + }, + { + groupName: 'group2', + }, + ], + }, + includeIdentityPool: true, + identityPoolModification: { + unauthenticatedLogin: true, + }, + }, + }; + + await initJSProjectWithProfile(projRoot, defaultsSettings); + await addAuthWithDefault(projRoot, {}); + await updateHeadlessAuth(projRoot, updateAuthRequest); + await amplifyPushAuth(projRoot); + const meta = getProjectMeta(projRoot); + const id = Object.keys(meta.auth).map(key => meta.auth[key])[0].output.UserPoolId; + const userPool = await getUserPool(id, meta.providers.awscloudformation.Region); + expect(userPool.UserPool).toBeDefined(); + expect(_.get(meta, ['auth', 'userPoolGroups'])).toBeDefined(); + }); + + it('removes auth resource', async () => { + await initJSProjectWithProfile(projRoot, defaultsSettings); + await addAuthWithDefault(projRoot, {}); + const { auth: authBefore } = getBackendAmplifyMeta(projRoot); + const authResourceName = _.keys(authBefore).find(() => true); // first element or undefined + await removeHeadlessAuth(projRoot, authResourceName); + const { auth: authAfter } = getBackendAmplifyMeta(projRoot); + expect(_.isEmpty(authAfter)).toBe(true); + }); +}); diff --git a/packages/amplify-e2e-tests/src/__tests__/datastore-modegen.test.ts b/packages/amplify-e2e-tests/src/__tests__/datastore-modelgen.test.ts similarity index 100% rename from packages/amplify-e2e-tests/src/__tests__/datastore-modegen.test.ts rename to packages/amplify-e2e-tests/src/__tests__/datastore-modelgen.test.ts diff --git a/packages/amplify-e2e-tests/src/__tests__/delete.test.ts b/packages/amplify-e2e-tests/src/__tests__/delete.test.ts index 4863fcd5b6c..2bffaf94c37 100644 --- a/packages/amplify-e2e-tests/src/__tests__/delete.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/delete.test.ts @@ -19,7 +19,7 @@ import { addS3 } from 'amplify-e2e-core'; import { amplifyPushWithoutCodegen } from 'amplify-e2e-core'; import { addAuthWithDefault } from 'amplify-e2e-core'; import * as fs from 'fs-extra'; -import { initProject, addPinpointAnalytics, pushToCloud, pinpointAppExist, amplifyDelete } from 'amplify-e2e-core'; +import { initProjectForPinpoint, addPinpointAnalytics, pushToCloud, pinpointAppExist, amplifyDelete } from 'amplify-e2e-core'; import { getAWSExportsPath } from '../aws-exports/awsExports'; import _ from 'lodash'; @@ -49,7 +49,7 @@ describe('amplify delete', () => { }); it('should delete pinpoint project', async () => { - await initProject(projRoot); + await initProjectForPinpoint(projRoot); const pinpointResourceName = await addPinpointAnalytics(projRoot); await pushToCloud(projRoot); const amplifyMeta = getProjectMeta(projRoot); diff --git a/packages/amplify-e2e-tests/src/__tests__/env.test.ts b/packages/amplify-e2e-tests/src/__tests__/env.test.ts index 672847e456b..d205be68646 100644 --- a/packages/amplify-e2e-tests/src/__tests__/env.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/env.test.ts @@ -127,7 +127,7 @@ describe('environment commands with Cognito Triggers', () => { }); it('init a project, pull environment', async () => { - await pullEnvironment(projRoot, {}); + await pullEnvironment(projRoot); const meta = getProjectMeta(projRoot); await validate(meta); }); @@ -155,7 +155,7 @@ describe('environment commands with recaptcha trigger', () => { await validate(meta); }); it('init a project, pull environment', async () => { - await pullEnvironment(projRoot, {}); + await pullEnvironment(projRoot); const meta = getProjectMeta(projRoot); await validate(meta); }); @@ -183,7 +183,7 @@ describe('environment commands with HostedUI params', () => { }); it('init a project, pull environment', async () => { - await pullEnvironment(projRoot, {}); + await pullEnvironment(projRoot); const meta = getProjectMeta(projRoot); await validate(meta); }); diff --git a/packages/amplify-e2e-tests/src/__tests__/feature-flags.test.ts b/packages/amplify-e2e-tests/src/__tests__/feature-flags.test.ts index 12b923cd123..14cf60fab36 100644 --- a/packages/amplify-e2e-tests/src/__tests__/feature-flags.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/feature-flags.test.ts @@ -23,7 +23,9 @@ describe('feature flags', () => { }); it('push and pull with multiple config files for environments', async () => { - await initJSProjectWithProfile(projRoot, {}); + await initJSProjectWithProfile(projRoot, { + disableAmplifyAppCreation: false, + }); await addApiWithSchema(projRoot, 'simple_model.graphql'); const envName = 'test'; diff --git a/packages/amplify-e2e-tests/src/__tests__/function_1.test.ts b/packages/amplify-e2e-tests/src/__tests__/function_1.test.ts index 6529bba64f0..a3147e8d4d2 100644 --- a/packages/amplify-e2e-tests/src/__tests__/function_1.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/function_1.test.ts @@ -1,20 +1,8 @@ import { initJSProjectWithProfile, deleteProject, amplifyPushAuth, amplifyPush } from 'amplify-e2e-core'; -import { addFunction, updateFunction, functionBuild, addLambdaTrigger, functionMockAssert, functionCloudInvoke } from 'amplify-e2e-core'; -import { addLayer, LayerOptions } from 'amplify-e2e-core'; +import { addFunction, updateFunction, functionBuild, addLambdaTrigger } from 'amplify-e2e-core'; import { addSimpleDDB } from 'amplify-e2e-core'; import { addKinesis } from 'amplify-e2e-core'; -import { - createNewProjectDir, - deleteProjectDir, - getProjectMeta, - getFunction, - overrideFunctionSrc, - getFunctionSrc, - overrideLayerCode, - overrideFunctionSrcPython, - overrideLayerCodePython, - overrideLayerCodeJava, -} from 'amplify-e2e-core'; +import { createNewProjectDir, deleteProjectDir, getProjectMeta, getFunction, overrideFunctionSrc, getFunctionSrc } from 'amplify-e2e-core'; import { addApiWithSchema } from 'amplify-e2e-core'; import { appsyncGraphQLRequest } from 'amplify-e2e-core'; diff --git a/packages/amplify-e2e-tests/src/__tests__/function_2.test.ts b/packages/amplify-e2e-tests/src/__tests__/function_2.test.ts index ed18eb9fd99..bfee8d0aeb4 100644 --- a/packages/amplify-e2e-tests/src/__tests__/function_2.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/function_2.test.ts @@ -1,27 +1,17 @@ -import { initJSProjectWithProfile, deleteProject, amplifyPushAuth, amplifyPush } from 'amplify-e2e-core'; -import { addFunction, updateFunction, functionBuild, addLambdaTrigger, functionMockAssert, functionCloudInvoke } from 'amplify-e2e-core'; +import { initJSProjectWithProfile, deleteProject, amplifyPushAuth } from 'amplify-e2e-core'; +import { addFunction, updateFunction, functionBuild, functionMockAssert, functionCloudInvoke } from 'amplify-e2e-core'; import { addLayer, addOptData, LayerOptions } from 'amplify-e2e-core'; -import { addSimpleDDB } from 'amplify-e2e-core'; -import { addKinesis } from 'amplify-e2e-core'; import { createNewProjectDir, deleteProjectDir, + getCloudWatchEventRule, getProjectMeta, getFunction, overrideFunctionSrc, - getFunctionSrc, overrideLayerCode, overrideFunctionSrcPython, overrideLayerCodePython, - overrideLayerCodeJava, } from 'amplify-e2e-core'; -import { addApiWithSchema } from 'amplify-e2e-core'; - -import { appsyncGraphQLRequest } from 'amplify-e2e-core'; -import { getCloudWatchLogs, putKinesisRecords, invokeFunction, getCloudWatchEventRule, getEventSourceMappings } from 'amplify-e2e-core'; -import fs from 'fs-extra'; -import path from 'path'; -import { retry, readJsonFile } from 'amplify-e2e-core'; describe('go function tests', () => { const helloWorldSuccessOutput = 'Hello Amplify!'; @@ -208,7 +198,7 @@ describe('amplify add/update/remove function based on schedule rule', () => { deleteProjectDir(projRoot); }); - it('add a schedule rule for daily ', async () => { + it('add a schedule rule for daily', async () => { await initJSProjectWithProfile(projRoot, {}); await addFunction( projRoot, @@ -325,7 +315,7 @@ describe('add function with layers for runtime nodeJS', () => { projRoot = await createNewProjectDir('functions'); await initJSProjectWithProfile(projRoot, {}); const settings = { - layerName: `testlayer${random}`, + layerName: `nodetestlayer${random}`, versionChanged: true, runtimes: ['nodejs'], }; @@ -352,7 +342,7 @@ describe('add function with layers for runtime nodeJS', () => { }, }, }; - functionName = `testfunction${random}`; + functionName = `nodetestfunction${random}`; await addFunction(projRoot, { functionTemplate: 'Hello World', layerOptions, name: functionName }, 'nodejs'); overrideFunctionSrc( projRoot, @@ -380,7 +370,7 @@ describe('add function with layers for runtime nodeJS', () => { await amplifyPushAuth(projRoot); const payload = '{}'; const response = await functionCloudInvoke(projRoot, { funcName: functionName, payload: payload }); - expect(JSON.parse(JSON.parse(response.Payload).body)).toEqual(helloWorldSuccessOutput); + expect(JSON.parse(JSON.parse(response.Payload.toString()).body)).toEqual(helloWorldSuccessOutput); }); }); @@ -394,7 +384,7 @@ describe('add function with layers for runtime python', () => { projRoot = await createNewProjectDir('functions'); await initJSProjectWithProfile(projRoot, {}); const settings = { - layerName: `testlayer${random}`, + layerName: `pytestlayer${random}`, versionChanged: true, runtimes: ['python'], }; @@ -412,7 +402,7 @@ describe('add function with layers for runtime python', () => { }, }, }; - functionName = `testfunction${random}`; + functionName = `pytestfunction${random}`; await addFunction(projRoot, { functionTemplate: 'Hello World', layerOptions, name: functionName }, 'python'); const functionCodePath = `${__dirname}/../../../amplify-e2e-tests/layerdata/python/index.py`; overrideFunctionSrcPython(projRoot, functionName, functionCodePath); @@ -422,10 +412,11 @@ describe('add function with layers for runtime python', () => { await deleteProject(projRoot); deleteProjectDir(projRoot); }); + it('can add project layers and external layers for python', async () => { await amplifyPushAuth(projRoot); const payload = '{}'; const response = await functionCloudInvoke(projRoot, { funcName: functionName, payload: payload }); - expect(JSON.parse(response.Payload).message).toEqual(helloWorldSuccessOutput); + expect(JSON.parse(response.Payload.toString()).message).toEqual(helloWorldSuccessOutput); }); }); diff --git a/packages/amplify-e2e-tests/src/__tests__/hosting.test.ts b/packages/amplify-e2e-tests/src/__tests__/hosting.test.ts index 02b4f509685..b6f7c752b87 100644 --- a/packages/amplify-e2e-tests/src/__tests__/hosting.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/hosting.test.ts @@ -23,10 +23,6 @@ describe('amplify add hosting', () => { deleteProjectDir(projRoot); }); - beforeEach(async () => {}); - - afterEach(async () => {}); - it('push creates correct amplify artifacts', async () => { expect(fs.existsSync(path.join(projRoot, 'amplify', 'backend', 'hosting', 'S3AndCloudFront'))).toBe(true); const projectMeta = getProjectMeta(projRoot); @@ -34,7 +30,7 @@ describe('amplify add hosting', () => { expect(projectMeta.hosting.S3AndCloudFront).toBeDefined(); }); - it('publish successfuly', async () => { + it('publish successfully', async () => { let error; try { await amplifyPublishWithoutUpdate(projRoot); diff --git a/packages/amplify-e2e-tests/src/__tests__/layer.test.ts b/packages/amplify-e2e-tests/src/__tests__/layer.test.ts index d4f87f74ceb..081385dda00 100644 --- a/packages/amplify-e2e-tests/src/__tests__/layer.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/layer.test.ts @@ -10,12 +10,10 @@ import { deleteProjectDir, initJSProjectWithProfile, getAppId, - getLayerVersion, getProjectMeta, LayerPermission, LayerPermissionName, LayerRuntimes, - listVersions, removeLayer, updateLayer, validateLayerDir, @@ -138,6 +136,21 @@ describe('amplify add lambda layer', () => { await validatePushedVersion(projRoot, settings.layerName, envName, 1, expectedPerms); await validateLayerMetadata(projRoot, settings.layerName, getProjectMeta(projRoot), newEnvName); }); +}); + +describe('amplify add lambda layer - with amplify console app', () => { + let projRoot: string; + const envName = 'integtest'; + + beforeEach(async () => { + projRoot = await createNewProjectDir('layers'); + await initJSProjectWithProfile(projRoot, { envName, disableAmplifyAppCreation: false }); + }); + + afterEach(async () => { + await deleteProject(projRoot); + deleteProjectDir(projRoot); + }); it('tests amplify pull on project with layer', async () => { const [shortId] = uuid().split('-'); diff --git a/packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration.test.ts b/packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration1.test.ts similarity index 54% rename from packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration.test.ts rename to packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration1.test.ts index ba2259d6072..66eb35a1fc2 100644 --- a/packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration1.test.ts @@ -67,63 +67,4 @@ describe('amplify add api', () => { amplifyPushUpdate(projRoot, /Attempting to edit the local secondary index SomeLSI on the TodoTable table in the Todo stack.*/), ).rejects.toThrowError('Process exited with non zero exit code 1'); }); - - it('init project, run invalid migration trying to add more than one gsi, and check for error', async () => { - const projectName = 'migratingkey'; - const initialSchema = 'migrations_key/initial_schema.graphql'; - const nextSchema1 = 'migrations_key/cant_add_more_gsi.graphql'; - await initJSProjectWithProfile(projRoot, { name: projectName }); - await addApiWithSchema(projRoot, initialSchema); - await amplifyPush(projRoot); - updateApiSchema(projRoot, projectName, nextSchema1); - await expect( - amplifyPushUpdate( - projRoot, - /Attempting to add more than 1 global secondary index SomeGSI1 and someGSI2 on the TodoTable table in the Todo stack.*/, - ), - ).rejects.toThrowError('Process exited with non zero exit code 1'); - }); - - it('init project, run invalid migration trying to delete more than one gsi, and check for error', async () => { - const projectName = 'migratingkey1'; - const initialSchema = 'migrations_key/initial_schema1.graphql'; - const nextSchema1 = 'migrations_key/cant_remove_more_gsi.graphql'; - await initJSProjectWithProfile(projRoot, { name: projectName }); - await addApiWithSchema(projRoot, initialSchema); - await amplifyPush(projRoot); - updateApiSchema(projRoot, projectName, nextSchema1); - await expect( - amplifyPushUpdate( - projRoot, - /Attempting to delete more than 1 global secondary index SomeGSI1 and someGSI2 on the TodoTable table in the Todo stack.*/, - ), - ).rejects.toThrowError('Process exited with non zero exit code 1'); - }); - - it('init project, run invalid migration trying to add and delete gsi, and check for error', async () => { - const projectName = 'migratingkey2'; - const initialSchema = 'migrations_key/initial_schema.graphql'; - const nextSchema1 = 'migrations_key/cant_update_delete_gsi.graphql'; - await initJSProjectWithProfile(projRoot, { name: projectName }); - await addApiWithSchema(projRoot, initialSchema); - await amplifyPush(projRoot); - updateApiSchema(projRoot, projectName, nextSchema1); - await expect( - amplifyPushUpdate( - projRoot, - /Attempting to add and delete a global secondary index SomeGSI1 and someGSI2 on the TodoTable table in the Todo stack.*/, - ), - ).rejects.toThrowError('Process exited with non zero exit code 1'); - }); - - it('init project, run valid migration adding a GSI', async () => { - const projectName = 'validaddinggsi'; - const initialSchema = 'migrations_key/initial_schema.graphql'; - const nextSchema1 = 'migrations_key/add_gsi.graphql'; - await initJSProjectWithProfile(projRoot, { name: projectName }); - await addApiWithSchema(projRoot, initialSchema); - await amplifyPush(projRoot); - updateApiSchema(projRoot, projectName, nextSchema1); - await amplifyPushUpdate(projRoot, /GraphQL endpoint:.*/); - }); }); diff --git a/packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration2.test.ts b/packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration2.test.ts new file mode 100644 index 00000000000..684d49957aa --- /dev/null +++ b/packages/amplify-e2e-tests/src/__tests__/migration/api.key.migration2.test.ts @@ -0,0 +1,74 @@ +import { initJSProjectWithProfile, deleteProject, amplifyPush, amplifyPushUpdate } from 'amplify-e2e-core'; +import { addApiWithSchema, updateApiSchema } from 'amplify-e2e-core'; +import { createNewProjectDir, deleteProjectDir } from 'amplify-e2e-core'; + +describe('amplify add api', () => { + let projRoot: string; + beforeEach(async () => { + projRoot = await createNewProjectDir('api-key-migration'); + }); + + afterEach(async () => { + await deleteProject(projRoot); + deleteProjectDir(projRoot); + }); + + it('init project, run invalid migration trying to add more than one gsi, and check for error', async () => { + const projectName = 'migratingkey'; + const initialSchema = 'migrations_key/initial_schema.graphql'; + const nextSchema1 = 'migrations_key/cant_add_more_gsi.graphql'; + await initJSProjectWithProfile(projRoot, { name: projectName }); + await addApiWithSchema(projRoot, initialSchema); + await amplifyPush(projRoot); + updateApiSchema(projRoot, projectName, nextSchema1); + await expect( + amplifyPushUpdate( + projRoot, + /Attempting to add more than 1 global secondary index SomeGSI1 and someGSI2 on the TodoTable table in the Todo stack.*/, + ), + ).rejects.toThrowError('Process exited with non zero exit code 1'); + }); + + it('init project, run invalid migration trying to delete more than one gsi, and check for error', async () => { + const projectName = 'migratingkey1'; + const initialSchema = 'migrations_key/initial_schema1.graphql'; + const nextSchema1 = 'migrations_key/cant_remove_more_gsi.graphql'; + await initJSProjectWithProfile(projRoot, { name: projectName }); + await addApiWithSchema(projRoot, initialSchema); + await amplifyPush(projRoot); + updateApiSchema(projRoot, projectName, nextSchema1); + await expect( + amplifyPushUpdate( + projRoot, + /Attempting to delete more than 1 global secondary index SomeGSI1 and someGSI2 on the TodoTable table in the Todo stack.*/, + ), + ).rejects.toThrowError('Process exited with non zero exit code 1'); + }); + + it('init project, run invalid migration trying to add and delete gsi, and check for error', async () => { + const projectName = 'migratingkey2'; + const initialSchema = 'migrations_key/initial_schema.graphql'; + const nextSchema1 = 'migrations_key/cant_update_delete_gsi.graphql'; + await initJSProjectWithProfile(projRoot, { name: projectName }); + await addApiWithSchema(projRoot, initialSchema); + await amplifyPush(projRoot); + updateApiSchema(projRoot, projectName, nextSchema1); + await expect( + amplifyPushUpdate( + projRoot, + /Attempting to add and delete a global secondary index SomeGSI1 and someGSI2 on the TodoTable table in the Todo stack.*/, + ), + ).rejects.toThrowError('Process exited with non zero exit code 1'); + }); + + it('init project, run valid migration adding a GSI', async () => { + const projectName = 'validaddinggsi'; + const initialSchema = 'migrations_key/initial_schema.graphql'; + const nextSchema1 = 'migrations_key/add_gsi.graphql'; + await initJSProjectWithProfile(projRoot, { name: projectName }); + await addApiWithSchema(projRoot, initialSchema); + await amplifyPush(projRoot); + updateApiSchema(projRoot, projectName, nextSchema1); + await amplifyPushUpdate(projRoot, /GraphQL endpoint:.*/); + }); +}); diff --git a/packages/amplify-e2e-tests/src/__tests__/schema-auth-10.test.ts b/packages/amplify-e2e-tests/src/__tests__/schema-auth-10.test.ts new file mode 100644 index 00000000000..64cb6226e3b --- /dev/null +++ b/packages/amplify-e2e-tests/src/__tests__/schema-auth-10.test.ts @@ -0,0 +1,26 @@ +import { initJSProjectWithProfile, deleteProject, createNewProjectDir, deleteProjectDir } from 'amplify-e2e-core'; +import { testSchema } from '../schema-api-directives'; + +describe('api directives @auth batch 8', () => { + let projectDir: string; + + beforeEach(async () => { + projectDir = await createNewProjectDir('auth8'); + await initJSProjectWithProfile(projectDir, {}); + }); + + afterEach(async () => { + await deleteProject(projectDir); + deleteProjectDir(projectDir); + }); + + it('auth generatesStaticGroup', async () => { + const testresult = await testSchema(projectDir, 'auth', 'generatesStaticGroup'); + expect(testresult).toBeTruthy(); + }); + + it('auth generatesDynamicGroup', async () => { + const testresult = await testSchema(projectDir, 'auth', 'generatesDynamicGroup'); + expect(testresult).toBeTruthy(); + }); +}); diff --git a/packages/amplify-e2e-tests/src/__tests__/schema-auth-7.test.ts b/packages/amplify-e2e-tests/src/__tests__/schema-auth-7.test.ts index e5fb95de688..f079ed2ea88 100644 --- a/packages/amplify-e2e-tests/src/__tests__/schema-auth-7.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/schema-auth-7.test.ts @@ -28,19 +28,4 @@ describe('api directives @auth batch 7', () => { const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth3'); expect(testresult).toBeTruthy(); }); - - it('auth fieldLevelAuth4', async () => { - const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth4'); - expect(testresult).toBeTruthy(); - }); - - it('auth fieldLevelAuth5', async () => { - const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth5'); - expect(testresult).toBeTruthy(); - }); - - it('auth fieldLevelAuth6', async () => { - const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth6'); - expect(testresult).toBeTruthy(); - }); }); diff --git a/packages/amplify-e2e-tests/src/__tests__/schema-auth-8.test.ts b/packages/amplify-e2e-tests/src/__tests__/schema-auth-8.test.ts index 2ab067fbc7f..735ead4c713 100644 --- a/packages/amplify-e2e-tests/src/__tests__/schema-auth-8.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/schema-auth-8.test.ts @@ -1,11 +1,11 @@ import { initJSProjectWithProfile, deleteProject, createNewProjectDir, deleteProjectDir } from 'amplify-e2e-core'; import { testSchema } from '../schema-api-directives'; -describe('api directives @auth batch 8', () => { +describe('api directives @auth batch 7', () => { let projectDir: string; beforeEach(async () => { - projectDir = await createNewProjectDir('auth8'); + projectDir = await createNewProjectDir('auth7'); await initJSProjectWithProfile(projectDir, {}); }); @@ -13,29 +13,18 @@ describe('api directives @auth batch 8', () => { await deleteProject(projectDir); deleteProjectDir(projectDir); }); - - it('auth fieldLevelAuth7', async () => { - const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth7'); - expect(testresult).toBeTruthy(); - }); - - it('auth fieldLevelAuth8', async () => { - const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth8'); - expect(testresult).toBeTruthy(); - }); - - it('auth generatesOwner', async () => { - const testresult = await testSchema(projectDir, 'auth', 'generatesOwner'); + it('auth fieldLevelAuth4', async () => { + const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth4'); expect(testresult).toBeTruthy(); }); - it('auth generatesStaticGroup', async () => { - const testresult = await testSchema(projectDir, 'auth', 'generatesStaticGroup'); + it('auth fieldLevelAuth5', async () => { + const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth5'); expect(testresult).toBeTruthy(); }); - it('auth generatesDynamicGroup', async () => { - const testresult = await testSchema(projectDir, 'auth', 'generatesDynamicGroup'); + it('auth fieldLevelAuth6', async () => { + const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth6'); expect(testresult).toBeTruthy(); }); }); diff --git a/packages/amplify-e2e-tests/src/__tests__/schema-auth-9.test.ts b/packages/amplify-e2e-tests/src/__tests__/schema-auth-9.test.ts new file mode 100644 index 00000000000..20a8b74d71e --- /dev/null +++ b/packages/amplify-e2e-tests/src/__tests__/schema-auth-9.test.ts @@ -0,0 +1,31 @@ +import { initJSProjectWithProfile, deleteProject, createNewProjectDir, deleteProjectDir } from 'amplify-e2e-core'; +import { testSchema } from '../schema-api-directives'; + +describe('api directives @auth batch 8', () => { + let projectDir: string; + + beforeEach(async () => { + projectDir = await createNewProjectDir('auth8'); + await initJSProjectWithProfile(projectDir, {}); + }); + + afterEach(async () => { + await deleteProject(projectDir); + deleteProjectDir(projectDir); + }); + + it('auth fieldLevelAuth7', async () => { + const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth7'); + expect(testresult).toBeTruthy(); + }); + + it('auth fieldLevelAuth8', async () => { + const testresult = await testSchema(projectDir, 'auth', 'fieldLevelAuth8'); + expect(testresult).toBeTruthy(); + }); + + it('auth generatesOwner', async () => { + const testresult = await testSchema(projectDir, 'auth', 'generatesOwner'); + expect(testresult).toBeTruthy(); + }); +}); diff --git a/packages/amplify-e2e-tests/src/init-special-cases/index.ts b/packages/amplify-e2e-tests/src/init-special-cases/index.ts index 490af3cbd5c..526d1716bf6 100644 --- a/packages/amplify-e2e-tests/src/init-special-cases/index.ts +++ b/packages/amplify-e2e-tests/src/init-special-cases/index.ts @@ -43,7 +43,13 @@ export async function initWithoutCredentialFileAndNoNewUserSetup(projRoot) { async function initWorkflow(cwd: string, settings: { accessKeyId: string; secretAccessKey: string; region: string }) { return new Promise((resolve, reject) => { - let chain = spawn(getCLIPath(), ['init'], { cwd, stripColors: true }) + let chain = spawn(getCLIPath(), ['init'], { + cwd, + stripColors: true, + env: { + CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1', + }, + }) .wait('Enter a name for the project') .sendCarriageReturn() .wait('Enter a name for the environment') diff --git a/packages/amplify-e2e-tests/typings/aws-matchers.d.ts b/packages/amplify-e2e-tests/typings/aws-matchers.d.ts index 4728d7dbcaa..f9f835f7448 100644 --- a/packages/amplify-e2e-tests/typings/aws-matchers.d.ts +++ b/packages/amplify-e2e-tests/typings/aws-matchers.d.ts @@ -2,5 +2,6 @@ namespace jest { interface Matchers { toBeIAMRoleWithArn(roleName: string, arn?: string): R; toBeAS3Bucket(bucketName: string): R; + toHaveValidPolicyConditionMatchingIdpId(idpId: string): R; } } diff --git a/packages/amplify-frontend-javascript/CHANGELOG.md b/packages/amplify-frontend-javascript/CHANGELOG.md index 021b6fecb51..d4837a335e3 100644 --- a/packages/amplify-frontend-javascript/CHANGELOG.md +++ b/packages/amplify-frontend-javascript/CHANGELOG.md @@ -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.16.4](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-javascript@2.16.3...amplify-frontend-javascript@2.16.4) (2020-09-25) + + +### Bug Fixes + +* **amplify-frontend-javascript:** fix headless pull ([42ccc0e](https://github.com/aws-amplify/amplify-cli/commit/42ccc0eb2316cbcc85256909ea1868a0e5398008)), closes [#5228](https://github.com/aws-amplify/amplify-cli/issues/5228) + + + + + ## [2.16.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-javascript@2.16.2...amplify-frontend-javascript@2.16.3) (2020-09-16) diff --git a/packages/amplify-frontend-javascript/package.json b/packages/amplify-frontend-javascript/package.json index a192032d6ac..29e55aa8aa6 100644 --- a/packages/amplify-frontend-javascript/package.json +++ b/packages/amplify-frontend-javascript/package.json @@ -1,6 +1,6 @@ { "name": "amplify-frontend-javascript", - "version": "2.16.3", + "version": "2.16.4", "description": "amplify-cli front-end plugin for JavaScript projects", "repository": { "type": "git", diff --git a/packages/amplify-go-function-runtime-provider/CHANGELOG.md b/packages/amplify-go-function-runtime-provider/CHANGELOG.md index 22d423d20be..801a522f416 100644 --- a/packages/amplify-go-function-runtime-provider/CHANGELOG.md +++ b/packages/amplify-go-function-runtime-provider/CHANGELOG.md @@ -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. +## [1.2.4](https://github.com/aws-amplify/amplify-cli/compare/amplify-go-function-runtime-provider@1.2.3...amplify-go-function-runtime-provider@1.2.4) (2020-09-25) + + +### Bug Fixes + +* enable building multiple go files, .exe extension for local invoke on Windows only ([#5262](https://github.com/aws-amplify/amplify-cli/issues/5262)) ([1936591](https://github.com/aws-amplify/amplify-cli/commit/1936591b0abfdc04f1172c88c554463c6aeb0877)) + + + + + ## [1.2.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-go-function-runtime-provider@1.2.2...amplify-go-function-runtime-provider@1.2.3) (2020-08-31) **Note:** Version bump only for package amplify-go-function-runtime-provider diff --git a/packages/amplify-go-function-runtime-provider/package.json b/packages/amplify-go-function-runtime-provider/package.json index 1ec84683d0c..cb65705a50a 100644 --- a/packages/amplify-go-function-runtime-provider/package.json +++ b/packages/amplify-go-function-runtime-provider/package.json @@ -1,6 +1,6 @@ { "name": "amplify-go-function-runtime-provider", - "version": "1.2.3", + "version": "1.2.4", "description": "Provides functionality related to functions in Go 1.x on AWS", "repository": { "type": "git", diff --git a/packages/amplify-graphql-types-generator/CHANGELOG.md b/packages/amplify-graphql-types-generator/CHANGELOG.md index 269151b135a..b421211d2e2 100644 --- a/packages/amplify-graphql-types-generator/CHANGELOG.md +++ b/packages/amplify-graphql-types-generator/CHANGELOG.md @@ -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.5.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-graphql-types-generator@2.5.0...amplify-graphql-types-generator@2.5.1) (2020-09-25) + + +### Bug Fixes + +* **amplify-graphql-types-generator:** use @aws-amplify/api-graphql instead of @aws-amplify/api ([#5350](https://github.com/aws-amplify/amplify-cli/issues/5350)) ([c5c5a8f](https://github.com/aws-amplify/amplify-cli/commit/c5c5a8f7a13ef5870d138b39a4ccb5d09b18e3a3)), closes [#4555](https://github.com/aws-amplify/amplify-cli/issues/4555) + + + + + # [2.5.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-graphql-types-generator@2.3.5...amplify-graphql-types-generator@2.5.0) (2020-07-29) diff --git a/packages/amplify-graphql-types-generator/package.json b/packages/amplify-graphql-types-generator/package.json index 949f5784ab3..fb5901c68be 100644 --- a/packages/amplify-graphql-types-generator/package.json +++ b/packages/amplify-graphql-types-generator/package.json @@ -1,6 +1,6 @@ { "name": "amplify-graphql-types-generator", - "version": "2.5.0", + "version": "2.5.1", "description": "Generate API code or type annotations based on a GraphQL schema and statements", "repository": { "type": "git", diff --git a/packages/amplify-headless-interface/CHANGELOG.md b/packages/amplify-headless-interface/CHANGELOG.md index 76d0803046e..5ecfcf4cbc8 100644 --- a/packages/amplify-headless-interface/CHANGELOG.md +++ b/packages/amplify-headless-interface/CHANGELOG.md @@ -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. +# [1.4.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-headless-interface@1.3.0...amplify-headless-interface@1.4.0) (2020-09-25) + + +### Features + +* headless update auth ([#5308](https://github.com/aws-amplify/amplify-cli/issues/5308)) ([b942f35](https://github.com/aws-amplify/amplify-cli/commit/b942f3589f1df1361ae7eb6e42f18dbf6900d1bf)) + + + + + # [1.3.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-headless-interface@1.2.0...amplify-headless-interface@1.3.0) (2020-09-09) diff --git a/packages/amplify-headless-interface/package.json b/packages/amplify-headless-interface/package.json index 05d840493ea..8e68b9b1177 100644 --- a/packages/amplify-headless-interface/package.json +++ b/packages/amplify-headless-interface/package.json @@ -1,6 +1,6 @@ { "name": "amplify-headless-interface", - "version": "1.3.0", + "version": "1.4.0", "description": "interfaces for amplify headless mode payloads", "main": "lib/index.js", "scripts": { diff --git a/packages/amplify-headless-interface/schemas/auth/1/UpdateAuthRequest.schema.json b/packages/amplify-headless-interface/schemas/auth/1/UpdateAuthRequest.schema.json new file mode 100644 index 00000000000..e13caf6c4b0 --- /dev/null +++ b/packages/amplify-headless-interface/schemas/auth/1/UpdateAuthRequest.schema.json @@ -0,0 +1,483 @@ +{ + "type": "object", + "properties": { + "version": { + "type": "number", + "enum": [ + 1 + ] + }, + "serviceModification": { + "anyOf": [ + { + "allOf": [ + { + "$ref": "#/definitions/BaseCognitoServiceModification" + }, + { + "$ref": "#/definitions/NoCognitoIdentityPool" + } + ] + }, + { + "allOf": [ + { + "$ref": "#/definitions/BaseCognitoServiceModification" + }, + { + "$ref": "#/definitions/ModifyCognitoIdentityPool" + } + ] + } + ] + } + }, + "required": [ + "serviceModification", + "version" + ], + "definitions": { + "BaseCognitoServiceModification": { + "type": "object", + "properties": { + "serviceName": { + "type": "string", + "enum": [ + "Cognito" + ] + }, + "userPoolModification": { + "$ref": "#/definitions/Pick" + } + }, + "required": [ + "serviceName", + "userPoolModification" + ] + }, + "Pick": { + "type": "object", + "properties": { + "userPoolGroups": { + "type": "array", + "items": { + "$ref": "#/definitions/CognitoUserPoolGroup" + } + }, + "adminQueries": { + "$ref": "#/definitions/CognitoAdminQueries" + }, + "mfa": { + "anyOf": [ + { + "$ref": "#/definitions/CognitoMFAOff" + }, + { + "$ref": "#/definitions/CognitoMFASettings" + } + ] + }, + "passwordPolicy": { + "$ref": "#/definitions/CognitoPasswordPolicy" + }, + "passwordRecovery": { + "anyOf": [ + { + "$ref": "#/definitions/CognitoEmailPasswordRecoveryConfiguration" + }, + { + "$ref": "#/definitions/CognitoSMSPasswordRecoveryConfiguration" + } + ] + }, + "refreshTokenPeriod": { + "type": "number" + }, + "readAttributes": { + "type": "array", + "items": { + "enum": [ + "ADDRESS", + "BIRTHDATE", + "EMAIL", + "EMAIL_VERIFIED", + "FAMILY_NAME", + "GENDER", + "GIVEN_NAME", + "LOCALE", + "MIDDLE_NAME", + "NAME", + "NICKNAME", + "PHONE_NUMBER", + "PHONE_NUMBER_VERIFIED", + "PICTURE", + "PREFERRED_USERNAME", + "PROFILE", + "UPDATED_AT", + "WEBSITE", + "ZONE_INFO" + ], + "type": "string" + } + }, + "writeAttributes": { + "type": "array", + "items": { + "enum": [ + "ADDRESS", + "BIRTHDATE", + "EMAIL", + "FAMILY_NAME", + "GENDER", + "GIVEN_NAME", + "LOCALE", + "MIDDLE_NAME", + "NAME", + "NICKNAME", + "PHONE_NUMBER", + "PICTURE", + "PREFERRED_USERNAME", + "PROFILE", + "UPDATED_AT", + "WEBSITE", + "ZONE_INFO" + ], + "type": "string" + } + }, + "oAuth": { + "$ref": "#/definitions/CognitoOAuthConfiguration" + }, + "addUserToGroup": { + "type": "object", + "properties": { + "groupName": { + "type": "string" + } + }, + "required": [ + "groupName" + ] + }, + "emailBlacklist": { + "type": "array", + "items": { + "type": "string" + } + }, + "emailWhitelist": { + "type": "array", + "items": { + "type": "string" + } + }, + "customAuthScaffolding": { + "type": "object", + "properties": { + "customChallengeAnswer": { + "type": "string" + } + }, + "required": [ + "customChallengeAnswer" + ] + } + } + }, + "CognitoUserPoolGroup": { + "type": "object", + "properties": { + "customPolicy": { + "type": "string" + }, + "groupName": { + "type": "string" + } + }, + "required": [ + "groupName" + ] + }, + "CognitoAdminQueries": { + "type": "object", + "properties": { + "permissions": { + "type": "object", + "properties": { + "restrictAccess": { + "type": "boolean" + }, + "groupName": { + "type": "string" + } + }, + "required": [ + "restrictAccess" + ] + } + }, + "required": [ + "permissions" + ] + }, + "CognitoMFAOff": { + "type": "object", + "properties": { + "mode": { + "type": "string", + "enum": [ + "OFF" + ] + } + }, + "required": [ + "mode" + ] + }, + "CognitoMFASettings": { + "type": "object", + "properties": { + "mode": { + "enum": [ + "ON", + "OPTIONAL" + ], + "type": "string" + }, + "mfaTypes": { + "type": "array", + "items": { + "enum": [ + "SMS", + "TOTP" + ], + "type": "string" + } + }, + "smsMessage": { + "type": "string" + }, + "mfaWithCaptcha": { + "type": "object", + "properties": { + "googleRecaptchaSecret": { + "type": "string" + } + }, + "required": [ + "googleRecaptchaSecret" + ] + } + }, + "required": [ + "mfaTypes", + "mode", + "smsMessage" + ] + }, + "CognitoPasswordPolicy": { + "type": "object", + "properties": { + "minimumLength": { + "type": "number" + }, + "additionalConstraints": { + "type": "array", + "items": { + "enum": [ + "REQUIRE_DIGIT", + "REQUIRE_LOWERCASE", + "REQUIRE_SYMBOL", + "REQUIRE_UPPERCASE" + ], + "type": "string" + } + } + } + }, + "CognitoEmailPasswordRecoveryConfiguration": { + "type": "object", + "properties": { + "deliveryMethod": { + "type": "string", + "enum": [ + "EMAIL" + ] + }, + "emailMessage": { + "type": "string" + }, + "emailSubject": { + "type": "string" + } + }, + "required": [ + "deliveryMethod", + "emailMessage", + "emailSubject" + ] + }, + "CognitoSMSPasswordRecoveryConfiguration": { + "type": "object", + "properties": { + "deliveryMethod": { + "type": "string", + "enum": [ + "SMS" + ] + }, + "smsMessage": { + "type": "string" + } + }, + "required": [ + "deliveryMethod", + "smsMessage" + ] + }, + "CognitoOAuthConfiguration": { + "type": "object", + "properties": { + "domainPrefix": { + "type": "string" + }, + "redirectSigninURIs": { + "type": "array", + "items": { + "type": "string" + } + }, + "redirectSignoutURIs": { + "type": "array", + "items": { + "type": "string" + } + }, + "oAuthGrantType": { + "enum": [ + "CODE", + "IMPLICIT" + ], + "type": "string" + }, + "oAuthScopes": { + "type": "array", + "items": { + "enum": [ + "AWS.COGNITO.SIGNIN.USER.ADMIN", + "EMAIL", + "OPENID", + "PHONE", + "PROFILE" + ], + "type": "string" + } + }, + "socialProviderConfigurations": { + "type": "array", + "items": { + "$ref": "#/definitions/CognitoSocialProviderConfiguration" + } + } + }, + "required": [ + "oAuthGrantType", + "oAuthScopes", + "redirectSigninURIs", + "redirectSignoutURIs" + ] + }, + "CognitoSocialProviderConfiguration": { + "type": "object", + "properties": { + "provider": { + "enum": [ + "FACEBOOK", + "GOOGLE", + "LOGIN_WITH_AMAZON" + ], + "type": "string" + }, + "clientId": { + "type": "string" + }, + "clientSecret": { + "type": "string" + } + }, + "required": [ + "clientId", + "clientSecret", + "provider" + ] + }, + "NoCognitoIdentityPool": { + "description": "Specifies that the Cognito configuration should not include an identity pool", + "type": "object", + "properties": { + "includeIdentityPool": { + "type": "boolean", + "enum": [ + false + ] + } + }, + "required": [ + "includeIdentityPool" + ] + }, + "ModifyCognitoIdentityPool": { + "type": "object", + "properties": { + "includeIdentityPool": { + "type": "boolean", + "enum": [ + true + ] + }, + "identityPoolModification": { + "$ref": "#/definitions/Pick" + } + }, + "required": [ + "identityPoolModification", + "includeIdentityPool" + ] + }, + "Pick": { + "type": "object", + "properties": { + "unauthenticatedLogin": { + "type": "boolean" + }, + "identitySocialFederation": { + "type": "array", + "items": { + "$ref": "#/definitions/CognitoIdentitySocialFederation" + } + } + } + }, + "CognitoIdentitySocialFederation": { + "type": "object", + "properties": { + "provider": { + "enum": [ + "AMAZON", + "FACEBOOK", + "GOOGLE" + ], + "type": "string" + }, + "clientId": { + "type": "string" + } + }, + "required": [ + "clientId", + "provider" + ] + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" +} \ No newline at end of file diff --git a/packages/amplify-headless-interface/scripts/generateSchemas.ts b/packages/amplify-headless-interface/scripts/generateSchemas.ts index c1c9550b6cf..a0f7fcb0f71 100644 --- a/packages/amplify-headless-interface/scripts/generateSchemas.ts +++ b/packages/amplify-headless-interface/scripts/generateSchemas.ts @@ -13,6 +13,11 @@ const typeDefs: TypeDef[] = [ category: 'auth', relativeSourcePaths: [path.join('auth', 'add.ts')], }, + { + typeName: 'UpdateAuthRequest', + category: 'auth', + relativeSourcePaths: ['add.ts', 'update.ts'].map(file => path.join('auth', file)), + }, { typeName: 'AddApiRequest', category: 'api', @@ -27,7 +32,7 @@ const typeDefs: TypeDef[] = [ typeName: 'UpdateApiRequest', category: 'api', relativeSourcePaths: ['add.ts', 'update.ts'].map(file => path.join('api', file)), - } + }, ]; const schemaFileName = (typeName: string) => `${typeName}.schema.json`; @@ -53,6 +58,7 @@ typeDefs.forEach(typeDef => { } fs.ensureFileSync(schemaFilePath); fs.writeFileSync(schemaFilePath, JSON.stringify(typeSchema, undefined, 4)); + console.log(`Schema version ${version} written for type ${typeDef.typeName}.`); }); // Interface types are expected to be exported as "typeName" in the file diff --git a/packages/amplify-headless-interface/src/index.ts b/packages/amplify-headless-interface/src/index.ts index 63cebf731d8..9df27325c23 100644 --- a/packages/amplify-headless-interface/src/index.ts +++ b/packages/amplify-headless-interface/src/index.ts @@ -1,4 +1,5 @@ export * from './interface/api/add'; export * from './interface/api/update'; export * from './interface/auth/add'; +export * from './interface/auth/update'; export * from './interface/storage/add'; diff --git a/packages/amplify-headless-interface/src/interface/auth/update.ts b/packages/amplify-headless-interface/src/interface/auth/update.ts new file mode 100644 index 00000000000..c7a0c0aeb97 --- /dev/null +++ b/packages/amplify-headless-interface/src/interface/auth/update.ts @@ -0,0 +1,36 @@ +import { CognitoUserPoolConfiguration, CognitoIdentityPoolConfiguration, NoCognitoIdentityPool } from './add'; + +export interface UpdateAuthRequest { + version: 1; + serviceModification: CognitoServiceModification; +} + +export type CognitoServiceModification = BaseCognitoServiceModification & (NoCognitoIdentityPool | ModifyCognitoIdentityPool); + +export interface BaseCognitoServiceModification { + serviceName: 'Cognito'; + userPoolModification: CognitoUserPoolModification; +} + +export interface ModifyCognitoIdentityPool { + includeIdentityPool: true; + identityPoolModification: CognitoIdentityPoolModification; +} + +export type CognitoUserPoolModification = Pick< + CognitoUserPoolConfiguration, + | 'userPoolGroups' + | 'adminQueries' + | 'mfa' + | 'passwordPolicy' + | 'passwordRecovery' + | 'refreshTokenPeriod' + | 'readAttributes' + | 'writeAttributes' + | 'oAuth' + | 'addUserToGroup' + | 'emailBlacklist' + | 'emailWhitelist' + | 'customAuthScaffolding' +>; +export type CognitoIdentityPoolModification = Pick; diff --git a/packages/amplify-migration-tests/CHANGELOG.md b/packages/amplify-migration-tests/CHANGELOG.md index c038b55bafc..4bf1733a826 100644 --- a/packages/amplify-migration-tests/CHANGELOG.md +++ b/packages/amplify-migration-tests/CHANGELOG.md @@ -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.18.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-migration-tests@2.18.2...amplify-migration-tests@2.18.3) (2020-09-25) + +**Note:** Version bump only for package amplify-migration-tests + + + + + ## [2.18.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-migration-tests@2.18.1...amplify-migration-tests@2.18.2) (2020-09-16) **Note:** Version bump only for package amplify-migration-tests diff --git a/packages/amplify-migration-tests/package.json b/packages/amplify-migration-tests/package.json index 2689b57fcb2..5bc9c47bd07 100644 --- a/packages/amplify-migration-tests/package.json +++ b/packages/amplify-migration-tests/package.json @@ -1,6 +1,6 @@ { "name": "amplify-migration-tests", - "version": "2.18.2", + "version": "2.18.3", "description": "", "repository": { "type": "git", @@ -22,7 +22,7 @@ "setup-profile": "ts-node ./src/configure_tests.ts" }, "dependencies": { - "amplify-e2e-core": "1.6.2", + "amplify-e2e-core": "1.7.0", "aws-sdk": "^2.608.0", "dotenv": "^8.2.0", "esm": "^3.2.25", diff --git a/packages/amplify-nodejs-function-template-provider/CHANGELOG.md b/packages/amplify-nodejs-function-template-provider/CHANGELOG.md index 45b2b60dcfb..e4b6b447b30 100644 --- a/packages/amplify-nodejs-function-template-provider/CHANGELOG.md +++ b/packages/amplify-nodejs-function-template-provider/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.4.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-nodejs-function-template-provider@1.4.0...amplify-nodejs-function-template-provider@1.4.1) (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)) +* fixed typos and bad import ([#5390](https://github.com/aws-amplify/amplify-cli/issues/5390)) ([0d2f632](https://github.com/aws-amplify/amplify-cli/commit/0d2f632029bc3c78434fe502899780649f3f74e3)) + + + + + # [1.4.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-nodejs-function-template-provider@1.3.1...amplify-nodejs-function-template-provider@1.4.0) (2020-09-16) diff --git a/packages/amplify-nodejs-function-template-provider/package.json b/packages/amplify-nodejs-function-template-provider/package.json index c69b8a054df..4c2c9284754 100644 --- a/packages/amplify-nodejs-function-template-provider/package.json +++ b/packages/amplify-nodejs-function-template-provider/package.json @@ -1,6 +1,6 @@ { "name": "amplify-nodejs-function-template-provider", - "version": "1.4.0", + "version": "1.4.1", "description": "Node JS templates supplied by the Amplify Team", "repository": { "type": "git", diff --git a/packages/amplify-provider-awscloudformation/CHANGELOG.md b/packages/amplify-provider-awscloudformation/CHANGELOG.md index dbaa5c7b836..6f331102fcf 100644 --- a/packages/amplify-provider-awscloudformation/CHANGELOG.md +++ b/packages/amplify-provider-awscloudformation/CHANGELOG.md @@ -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. +## [4.26.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-provider-awscloudformation@4.26.2...amplify-provider-awscloudformation@4.26.3) (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)) + + + + + ## [4.26.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-provider-awscloudformation@4.26.1...amplify-provider-awscloudformation@4.26.2) (2020-09-16) diff --git a/packages/amplify-provider-awscloudformation/package.json b/packages/amplify-provider-awscloudformation/package.json index 7291f7e42aa..1670f0348ef 100644 --- a/packages/amplify-provider-awscloudformation/package.json +++ b/packages/amplify-provider-awscloudformation/package.json @@ -1,6 +1,6 @@ { "name": "amplify-provider-awscloudformation", - "version": "4.26.2", + "version": "4.26.3", "description": "AWS CloudFormation Provider", "repository": { "type": "git", @@ -21,11 +21,11 @@ "watch": "tsc --watch" }, "dependencies": { - "amplify-category-auth": "2.19.1", - "amplify-category-function": "2.25.0", - "amplify-category-predictions": "2.4.17", - "amplify-cli-core": "1.3.2", - "amplify-codegen": "2.15.18", + "amplify-category-auth": "2.20.0", + "amplify-category-function": "2.25.1", + "amplify-category-predictions": "2.4.18", + "amplify-cli-core": "1.3.3", + "amplify-codegen": "2.15.19", "archiver": "^3.1.1", "aws-sdk": "^2.608.0", "bottleneck": "2.19.5", diff --git a/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js b/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js index 6ddb754f985..7c059831cee 100644 --- a/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js +++ b/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js @@ -111,8 +111,10 @@ async function init(amplifyServiceParams) { environmentVariables: { _LIVE_PACKAGE_UPDATES: '[{"pkg":"@aws-amplify/cli","type":"npm","version":"latest"}]' }, }; try { - const createAppResponse = await amplifyClient.createApp(createAppParams).promise(); - amplifyAppId = createAppResponse.app.appId; + if (amplifyAppCreationEnabled()) { + const createAppResponse = await amplifyClient.createApp(createAppParams).promise(); + amplifyAppId = createAppResponse.app.appId; + } } catch (e) { if (e.code === 'LimitExceededException') { // Do nothing @@ -259,8 +261,10 @@ async function postPushCheck(context) { }; try { - const createAppResponse = await amplifyClient.createApp(createAppParams).promise(); - amplifyAppId = createAppResponse.app.appId; + if (amplifyAppCreationEnabled()) { + const createAppResponse = await amplifyClient.createApp(createAppParams).promise(); + amplifyAppId = createAppResponse.app.appId; + } } catch (e) { if (e.code === 'LimitExceededException') { // Do nothing @@ -415,6 +419,8 @@ async function uploadFile(s3, filePath, key) { } } +const amplifyAppCreationEnabled = () => !process.env || process.env.CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION !== '1'; + module.exports = { init, deleteEnv, diff --git a/packages/amplify-util-headless-input/CHANGELOG.md b/packages/amplify-util-headless-input/CHANGELOG.md index 4df9e8cbf97..aea65ad7dcf 100644 --- a/packages/amplify-util-headless-input/CHANGELOG.md +++ b/packages/amplify-util-headless-input/CHANGELOG.md @@ -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. +# [1.3.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-util-headless-input@1.2.1...amplify-util-headless-input@1.3.0) (2020-09-25) + + +### Features + +* headless update auth ([#5308](https://github.com/aws-amplify/amplify-cli/issues/5308)) ([b942f35](https://github.com/aws-amplify/amplify-cli/commit/b942f3589f1df1361ae7eb6e42f18dbf6900d1bf)) + + + + + ## [1.2.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-util-headless-input@1.2.0...amplify-util-headless-input@1.2.1) (2020-09-09) **Note:** Version bump only for package amplify-util-headless-input diff --git a/packages/amplify-util-headless-input/package.json b/packages/amplify-util-headless-input/package.json index af685fee9e8..0de7f3bb632 100644 --- a/packages/amplify-util-headless-input/package.json +++ b/packages/amplify-util-headless-input/package.json @@ -1,6 +1,6 @@ { "name": "amplify-util-headless-input", - "version": "1.2.1", + "version": "1.3.0", "description": "Logic for validating objects against JSON-schema specs and performing version upgrades when necessary / possible", "main": "lib/index.js", "scripts": { @@ -16,7 +16,7 @@ "license": "Apache-2.0", "dependencies": { "ajv": "^6.12.2", - "amplify-headless-interface": "1.3.0" + "amplify-headless-interface": "1.4.0" }, "devDependencies": { "@types/json-schema": "^7.0.5" diff --git a/packages/amplify-util-headless-input/src/index.ts b/packages/amplify-util-headless-input/src/index.ts index 7349f582002..b9c8af504cd 100644 --- a/packages/amplify-util-headless-input/src/index.ts +++ b/packages/amplify-util-headless-input/src/index.ts @@ -4,9 +4,10 @@ import { addApiRequestSchemaSupplier, addAuthRequestSchemaSupplier, updateApiRequestSchemaSupplier, + updateAuthRequestSchemaSupplier, } from './schemaSuppliers'; import { noopUpgradePipeline } from './upgradePipelines'; -import { AddStorageRequest, AddApiRequest, AddAuthRequest, UpdateApiRequest } from 'amplify-headless-interface'; +import { AddStorageRequest, AddApiRequest, AddAuthRequest, UpdateAuthRequest, UpdateApiRequest } from 'amplify-headless-interface'; export const validateAddStorageRequest = (raw: string) => { return new HeadlessInputValidator(addStorageRequestSchemaSupplier, noopUpgradePipeline).validate(raw); @@ -23,3 +24,7 @@ export const validateUpdateApiRequest = (raw: string) => { export const validateAddAuthRequest = (raw: string) => { return new HeadlessInputValidator(addAuthRequestSchemaSupplier, noopUpgradePipeline).validate(raw); }; + +export const validateUpdateAuthRequest = (raw: string) => { + return new HeadlessInputValidator(updateAuthRequestSchemaSupplier, noopUpgradePipeline).validate(raw); +}; diff --git a/packages/amplify-util-headless-input/src/schemaSuppliers.ts b/packages/amplify-util-headless-input/src/schemaSuppliers.ts index 70cf71265cf..f4e21116f45 100644 --- a/packages/amplify-util-headless-input/src/schemaSuppliers.ts +++ b/packages/amplify-util-headless-input/src/schemaSuppliers.ts @@ -8,6 +8,10 @@ export const addAuthRequestSchemaSupplier: VersionedSchemaSupplier = version => return getSchema('AddAuthRequest', 'auth', version); }; +export const updateAuthRequestSchemaSupplier: VersionedSchemaSupplier = version => { + return getSchema('UpdateAuthRequest', 'auth', version); +}; + export const addApiRequestSchemaSupplier: VersionedSchemaSupplier = version => { return getSchema('AddApiRequest', 'api', version); }; diff --git a/packages/amplify-util-mock/CHANGELOG.md b/packages/amplify-util-mock/CHANGELOG.md index 91ed69033c2..ef7730dab4a 100644 --- a/packages/amplify-util-mock/CHANGELOG.md +++ b/packages/amplify-util-mock/CHANGELOG.md @@ -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. +## [3.24.11](https://github.com/aws-amplify/amplify-cli/compare/amplify-util-mock@3.24.10...amplify-util-mock@3.24.11) (2020-09-25) + +**Note:** Version bump only for package amplify-util-mock + + + + + ## [3.24.10](https://github.com/aws-amplify/amplify-cli/compare/amplify-util-mock@3.24.9...amplify-util-mock@3.24.10) (2020-09-16) diff --git a/packages/amplify-util-mock/package.json b/packages/amplify-util-mock/package.json index d3c561ddadd..cbab9049182 100644 --- a/packages/amplify-util-mock/package.json +++ b/packages/amplify-util-mock/package.json @@ -1,6 +1,6 @@ { "name": "amplify-util-mock", - "version": "3.24.10", + "version": "3.24.11", "description": "amplify cli plugin providing local testing", "repository": { "type": "git", @@ -27,8 +27,8 @@ "dependencies": { "@hapi/topo": "^5.0.0", "amplify-appsync-simulator": "1.23.2", - "amplify-category-function": "2.25.0", - "amplify-codegen": "2.15.18", + "amplify-category-function": "2.25.1", + "amplify-codegen": "2.15.19", "amplify-dynamodb-simulator": "1.14.2", "amplify-storage-simulator": "1.4.1", "chokidar": "^3.3.1", diff --git a/scripts/split-e2e-tests.ts b/scripts/split-e2e-tests.ts index 4501f7fe9d7..d72398a3783 100644 --- a/scripts/split-e2e-tests.ts +++ b/scripts/split-e2e-tests.ts @@ -19,7 +19,7 @@ const AWS_REGIONS_TO_RUN_TESTS = [ const KNOWN_SUITES_SORTED_ACCORDING_TO_RUNTIME = [ 'src/__tests__/plugin.test.ts', - 'src/__tests__/datastore-modegen.test.ts', + 'src/__tests__/datastore-modelgen.test.ts', 'src/__tests__/interactions.test.ts', 'src/__tests__/hosting.test.ts', 'src/__tests__/init.test.ts',