Skip to content

Commit

Permalink
Merge branch 'master' into mock-env-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle authored Feb 10, 2021
2 parents 3d9fe6c + b866ccc commit 3fe813c
Show file tree
Hide file tree
Showing 234 changed files with 4,050 additions and 3,287 deletions.
21 changes: 12 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module.exports = {
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
'plugin:@typescript-eslint/eslint-recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
],
Expand Down Expand Up @@ -66,7 +65,6 @@ module.exports = {
// New rules
'class-methods-use-this': 'off',
'import/extensions': 'off',
'import/no-default-export': 'error',
'import/prefer-default-export': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-var-requires': 'off',
Expand All @@ -82,7 +80,6 @@ module.exports = {
'no-shadow': 'off',
'no-unneeded-ternary': 'off',
'no-unreachable': 'off',
'no-unused-expressions': 'off',
'no-useless-catch': 'off',
'no-useless-return': 'off',
'object-shorthand': 'off',
Expand All @@ -101,7 +98,6 @@ module.exports = {
'prettier/prettier': 'off',

// TODO needs to be enabled when fixing valid warnings of this error
'no-constant-condition': ['error', { checkLoops: false }],
//'no-param-reassign': ['error', { 'props': false }],
'no-param-reassign': 'off', // https://eslint.org/docs/rules/no-param-reassign
//'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }], // https://eslint.org/docs/rules/no-plusplus
Expand All @@ -115,7 +111,14 @@ module.exports = {
'no-use-before-define': 'off', // https://eslint.org/docs/rules/no-use-before-define
'prefer-destructuring': 'off', // https://eslint.org/docs/rules/prefer-destructuring
'prefer-object-spread': 'off', // https://eslint.org/docs/rules/prefer-object-spread
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/naming-convention': ['error', {
selector: 'default',
format: null
}, {
selector: ['class', 'interface'],
format: ['PascalCase']
}
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
Expand All @@ -127,7 +130,6 @@ module.exports = {
'no-return-await': 'off', // https://eslint.org/docs/rules/no-return-await

// TSLint existing rules
'@typescript-eslint/class-name-casing': 'error',
curly: 'off', // Enable later
'guard-for-in': 'error',
indent: 'off', // Enable later
Expand All @@ -141,7 +143,6 @@ module.exports = {
'no-eval': 'error',
'dot-notation': 'off', // Enable later
'no-trailing-spaces': 'error',
'no-unused-expressions': 'error',
semi: 'off', // Enable later,
'@typescript-eslint/typedef': 'off', // Enable later
//'@typescript-eslint/typedef': ['error', { propertyDeclaration:true, variableDeclaration: true, memberVariableDeclaration: true }],
Expand All @@ -166,7 +167,6 @@ module.exports = {
'default-case': 'off',
'no-return-assign': 'off',
'import/no-duplicates': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'no-throw-literal': 'off',
'react/static-property-placement': 'off',
'import/no-extraneous-dependencies': 'off',
Expand Down Expand Up @@ -203,6 +203,9 @@ module.exports = {
'no-constant-condition': 'off',
'operator-assignment': 'off',
'import/no-named-default': 'off',
'prefer-arrow-callback': 'off',
'arrow-body-style': 'off',
'camelcase': 'off'
},
overrides: [
{
Expand All @@ -225,7 +228,6 @@ module.exports = {
'default-case': 'error',
'no-return-assign': 'error',
'import/no-duplicates': 'error',
'@typescript-eslint/interface-name-prefix': 'error',
'no-throw-literal': 'error',
'react/static-property-placement': 'error',
'import/no-extraneous-dependencies': 'error',
Expand Down Expand Up @@ -264,6 +266,7 @@ module.exports = {
},
],
ignorePatterns: [
'scripts/',
'node_modules',
'dist',
'build',
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ packages/amplify-java-function-runtime-provider/resources/localinvoke/bin/
packages/**/reports/junit/*
test.out.log
*.tsbuildinfo
packages/amplify-graphiql-explorer/.eslintcache
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"lint-fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
"clean": "lerna run clean && lerna exec yarn rimraf tsconfig.tsbuildinfo && lerna clean --yes && yarn rimraf node_modules",
"build": "lerna run build",
"build-tests": "lerna run build-tests",
"production-build": "yarn --frozen-lockfile && lerna run build --concurrency 3 --stream",
"dev-build": "yarn && lerna run build",
"link-aa-dev": "cd packages/amplify-app && ln -s $(pwd)/bin/amplify-app $(yarn global bin)/amplify-app-dev && cd -",
Expand Down Expand Up @@ -57,7 +58,7 @@
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-push": "npm run lint && npm run test-changed",
"pre-push": "yarn build-tests && yarn run lint && yarn run test-changed",
"pre-commit": "yarn split-e2e-tests && pretty-quick --staged"
}
},
Expand All @@ -80,23 +81,30 @@
"@commitlint/config-lerna-scopes": "^8.1.0",
"@types/jest": "^26.0.20",
"@types/js-yaml": "^3.12.3",
"@typescript-eslint/eslint-plugin": "^2.16.0",
"@typescript-eslint/parser": "^2.16.0",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"babel-loader": "^8.1.0",
"babel-eslint": "^10.1.0",
"cmd-shim": "^3.0.3",
"codecov": "^3.7.0",
"commitizen": "^3.1.2",
"copyfiles": "^2.2.0",
"cz-conventional-changelog": "^3.0.2",
"eslint": "^6.8.0",
"eslint": "^7.19.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.9.0",
"eslint-config-prettier": "^7.2.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jest": "^23.6.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-json": "^2.0.1",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-spellcheck": "^0.0.17",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^3.10.1",
"execa": "^4.1.0",
"glob": "^7.1.6",
"husky": "^3.0.3",
Expand All @@ -112,7 +120,7 @@
"rimraf": "^3.0.0",
"ts-jest": "^26.4.4",
"ts-node": "^8.10.1",
"typescript": "^3.8.3"
"typescript": "^4.1.3"
},
"config": {
"commitizen": {
Expand Down
20 changes: 20 additions & 0 deletions packages/amplify-app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.21.0](https://github.com/aws-amplify/amplify-cli/compare/[email protected]@2.21.0) (2021-02-10)



# 4.42.0 (2021-02-09)


### Bug Fixes

* generate flutter amp config in lib ([#6571](https://github.com/aws-amplify/amplify-cli/issues/6571)) ([ecfb6d3](https://github.com/aws-amplify/amplify-cli/commit/ecfb6d3a1421787c2d48eb81c1625e30ca60216f))


### Features

* add Flutter support for Admin UI ([#6516](https://github.com/aws-amplify/amplify-cli/issues/6516)) ([d9ee44b](https://github.com/aws-amplify/amplify-cli/commit/d9ee44be73f43b11da2a07d21fd60108f49b1608))





## [2.20.8](https://github.com/aws-amplify/amplify-cli/compare/[email protected]@2.20.8) (2021-01-13)

**Note:** Version bump only for package amplify-app
Expand Down
9 changes: 5 additions & 4 deletions packages/amplify-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-app",
"version": "2.20.8",
"version": "2.21.0",
"description": "Amplify CLI",
"repository": {
"type": "git",
Expand Down Expand Up @@ -28,9 +28,10 @@
"@aws-amplify/cli": ">=4.37.0"
},
"dependencies": {
"amplify-frontend-android": "2.14.4",
"amplify-frontend-ios": "2.18.4",
"amplify-frontend-javascript": "2.20.4",
"amplify-frontend-android": "2.14.5",
"amplify-frontend-flutter": "0.3.0",
"amplify-frontend-ios": "2.18.5",
"amplify-frontend-javascript": "2.20.5",
"chalk": "^3.0.0",
"execa": "^4.1.0",
"fs-extra": "^8.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-app/src/framework-config-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const vueConfig = {
};

const emberConfig = {
SourceDir: '/',
SourceDir: './',
DistributionDir: 'dist',
BuildCommand: `${npm} run-script build -- -e production`,
StartCommand: `${npm} run-script start`,
Expand Down
6 changes: 6 additions & 0 deletions packages/amplify-app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ini = require('ini');
const semver = require('semver');
const { engines } = require('../package.json');
const { initializeAwsExports } = require('amplify-frontend-javascript');
const { initializeAmplifyConfiguration } = require('amplify-frontend-flutter');
const { callAmplify } = require('./call-amplify');

const isWin = process.platform.startsWith('win');
Expand Down Expand Up @@ -183,6 +184,7 @@ const guessPlatform = async (providedPlatform, providedJSFramework) => {
javascript: 'amplify-frontend-javascript',
android: 'amplify-frontend-android',
ios: 'amplify-frontend-ios',
flutter: 'amplify-frontend-flutter',
};

let suitableFrontend;
Expand Down Expand Up @@ -440,6 +442,10 @@ async function createAmplifyHelperFiles(frontend) {
await createIosHelperFiles();
}

if (frontend === 'flutter') {
initializeAmplifyConfiguration(path.resolve('lib'));
}

return frontend;
}

Expand Down
12 changes: 12 additions & 0 deletions packages/amplify-appsync-simulator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.25.1](https://github.com/aws-amplify/amplify-cli/compare/[email protected]@1.25.1) (2021-02-10)


### Bug Fixes

* **amplify-appsync-simulator:** allow token.iss ending with slash ([#6364](https://github.com/aws-amplify/amplify-cli/issues/6364)) ([cba5c4d](https://github.com/aws-amplify/amplify-cli/commit/cba5c4d82c186d61f01bf2a9552363289f7b6742))
* **amplify-velocity-template:** support 'get' and 'set' of array vars ([#5747](https://github.com/aws-amplify/amplify-cli/issues/5747)) ([b5f917a](https://github.com/aws-amplify/amplify-cli/commit/b5f917a81524feb64ec7e674c6213cb47fd7794c)), closes [#5741](https://github.com/aws-amplify/amplify-cli/issues/5741)





# [1.25.0](https://github.com/aws-amplify/amplify-cli/compare/[email protected]@1.25.0) (2021-01-08)


Expand Down
5 changes: 3 additions & 2 deletions packages/amplify-appsync-simulator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-appsync-simulator",
"version": "1.25.0",
"version": "1.25.1",
"description": "An AppSync Simulator to test AppSync API.",
"repository": {
"type": "git",
Expand All @@ -19,13 +19,14 @@
"scripts": {
"copy-assets": "yarn rimraf ./public && yarn copyfiles -u 3 \"../amplify-graphiql-explorer/build/**/*\" ./public",
"build": "yarn copy-assets && tsc",
"build-tests": "tsc --build tsconfig.tests.json",
"clean": "rimraf ./lib",
"watch": "tsc -w",
"start": "node ./lib/index.js",
"test": "jest"
},
"dependencies": {
"amplify-velocity-template": "1.4.2",
"amplify-velocity-template": "1.4.3",
"aws-sdk": "^2.765.0",
"chalk": "^3.0.0",
"cors": "^2.8.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { MESSAGE_TYPES } from '../../../../server/subscription/websocket-server/
const SOCKET_TIMEOUT = 10000;
jest.setTimeout(60000);

async function waitForConnection(socket: WS) {
async function waitForConnection(socket: WS): Promise<void> {
return new Promise((resolve, reject) => {
let done = false;
const timeoutHandle = setTimeout(() => {
Expand Down
17 changes: 5 additions & 12 deletions packages/amplify-appsync-simulator/src/velocity/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AmplifyAppSyncSimulatorAuthenticationType, AppSyncVTLTemplate } from '../type-definition';
import { Compile, parse } from 'amplify-velocity-template';
import { TemplateSentError, create as createUtil } from './util';
import { TemplateSentError, create as createUtil, ValidateError } from './util';
import { map as convertToJavaTypes, map } from './value-mapper/mapper';

import { AmplifyAppSyncSimulator } from '..';
Expand Down Expand Up @@ -57,6 +57,10 @@ export class VelocityTemplate {
try {
templateResult = this.compiler.render(context);
} catch (e) {
const lastError = context.util.errors.length && context.util.errors[context.util.errors.length - 1];
if (lastError && lastError instanceof ValidateError) {
return { result: lastError.data, errors: [...context.util.errors], isReturn: true, stash: context.ctx.stash.toJSON() };
}
return { result: null, errors: [...context.util.errors], isReturn: false, stash: context.ctx.stash.toJSON() };
}
const isReturn = this.compiler._state.return; // If the template has #return, then set the value
Expand Down Expand Up @@ -141,15 +145,4 @@ export class VelocityTemplate {
ctx: vtlContext,
};
}

private getRemoteIpAddress(request) {
if (request && request.connection && request.connection.remoteAddress) {
if (request.connection.remoteAddress.startsWith('::ffff:')) {
// IPv4 address in v6 format
return [request.connection.remoteAddress.replace('::ffff:', '')];
}
return [request.connection.remoteAddress];
}
return ['0.0.0.0'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class TemplateSentError extends Error {
extensions: any;
constructor(public message: string, public errorType: string, public data: any, public errorInfo: any, info: GraphQLResolveInfo) {
super(message);
Object.setPrototypeOf(this, TemplateSentError.prototype);
const fieldName = info.fieldName;
let path = info.path;
const pathArray = [];
Expand Down Expand Up @@ -36,10 +37,12 @@ export class TemplateSentError extends Error {
export class Unauthorized extends TemplateSentError {
constructor(gqlMessage, info: GraphQLResolveInfo) {
super(gqlMessage, 'Unauthorized', {}, {}, info);
Object.setPrototypeOf(this, Unauthorized.prototype);
}
}
export class ValidateError extends Error {
constructor(public message: string, public type: string, public data: any) {
super(message);
export class ValidateError extends TemplateSentError {
constructor(public message: string, info: GraphQLResolveInfo, public type: string = 'CustomTemplateException', public data: any = null) {
super(message, type, {}, {}, info);
Object.setPrototypeOf(this, ValidateError.prototype);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ export const generalUtils = {
getErrors() {
return this.errors;
},
validate(allGood, message, type, data) {
validate(allGood, message, errorType, data) {
if (allGood) return '';
throw new ValidateError(message, type, data);
const error = new ValidateError(message, this.info, errorType, data);
this.errors.push(error);
throw error;
},
isNull(value) {
return value === null || typeof value == 'undefined';
Expand Down
Loading

0 comments on commit 3fe813c

Please sign in to comment.