Skip to content

Commit

Permalink
Revert "feat(uibuilder): nested collections support (#10763)" (#10777)
Browse files Browse the repository at this point in the history
This reverts commit 2918eb9.
  • Loading branch information
jhockett authored Jul 19, 2022
1 parent 150e6dc commit c36fa71
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 511 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import AWS from 'aws-sdk';
import { $TSContext } from 'amplify-cli-core';
import aws from './aws';
import { loadConfiguration } from '../configuration-manager';
import { $TSContext } from 'amplify-cli-core';

/**
* Amplify Backend Class
*/
export class AmplifyBackend {
private static instance: AmplifyBackend;
private readonly context: $TSContext;
public amplifyBackend: AWS.AmplifyBackend;

/**
* Configures the instance for the Amplify Backend Client
*/
static async getInstance(context: $TSContext, options = {}): Promise<AmplifyBackend> {
if (!AmplifyBackend.instance) {
let cred = {};
Expand All @@ -29,12 +23,6 @@ export class AmplifyBackend {

private constructor(context: $TSContext, creds, options = {}) {
this.context = context;
const { AMPLIFY_BACKEND_ENDPOINT, AMPLIFY_BACKEND_REGION } = process.env;
this.amplifyBackend = new aws.AmplifyBackend({
...creds,
...options,
...(AMPLIFY_BACKEND_ENDPOINT && { endpoint: AMPLIFY_BACKEND_ENDPOINT }),
...(AMPLIFY_BACKEND_REGION && { region: AMPLIFY_BACKEND_REGION }),
});
this.amplifyBackend = new aws.AmplifyBackend({ ...creds, ...options });
}
}
10 changes: 4 additions & 6 deletions packages/amplify-util-uibuilder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
"access": "public"
},
"dependencies": {
"@aws-amplify/codegen-ui": "^2.3.0",
"@aws-amplify/codegen-ui-react": "^2.3.0",
"@aws-amplify/codegen-ui": "^2.2.0",
"@aws-amplify/codegen-ui-react": "^2.2.0",
"amplify-cli-core": "2.11.0",
"amplify-prompts": "2.2.0",
"aws-sdk": "^2.1113.0",
"ora": "^4.0.3"
},
"devDependencies": {
"@types/fs-extra": "^8.0.1",
"@types/jest": "^26.0.20",
"@types/semver": "^7.1.0"
},
"jest": {
Expand All @@ -34,7 +33,6 @@
"collectCoverage": true,
"collectCoverageFrom": [
"src/**/*.ts",
"!**/*.test.ts",
"!**/node_modules/**",
"!src/__tests__/**",
"!lib/**"
Expand All @@ -45,7 +43,7 @@
],
"testEnvironment": "node",
"testURL": "http://localhost/",
"testRegex": "((src/(__tests__|__e2e__|__e2e_v2__))/.*.test.ts)$",
"testRegex": "(src/(__tests__|__e2e__|__e2e_v2__)/.*.test.ts)$",
"moduleFileExtensions": [
"ts",
"tsx",
Expand All @@ -61,4 +59,4 @@
"usePathForSuiteName": "true",
"addFileAttribute": "true"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import * as extractArgsDependency from '../commands/utils/extractArgs';
import * as listUiBuilderComponentsDependency from '../commands/utils/syncAmplifyUiBuilderComponents';
import { run } from '../commands/cloneComponentsFromEnv';

const extractArgsDependencyMock = extractArgsDependency as any;
const listUiBuilderComponentsDependencyMock = listUiBuilderComponentsDependency as any;

const extractArgsDependency_mock = extractArgsDependency as any;
const listUiBuilderComponentsDependency_mock = listUiBuilderComponentsDependency as any;
jest.mock('aws-sdk', () => {
return {
AmplifyUIBuilder: jest.fn(() => {
return {
createComponent: () => ({
promise: () => true,
}),
};
}),
};
});
jest.mock('../commands/utils/extractArgs');
jest.mock('../commands/utils/syncAmplifyUiBuilderComponents');
jest.mock('../clients', () => ({
AmplifyClientFactory: {
setClientInfo: jest.fn(),
amplifyUiBuilder: {
createComponent: () => ({
promise: () => true,
}),
},
amplifyBackend: jest.fn(),
},
}));

describe('can clone components to new environment', () => {
let context: any;
Expand All @@ -26,20 +24,14 @@ describe('can clone components to new environment', () => {
amplify: {
invokePluginMethod: () => true,
},
input: {
options: {
appId: 'testAppId',
envName: 'testEnvName',
},
},
};
extractArgsDependencyMock.extractArgs = jest.fn().mockImplementation(() => ({
extractArgsDependency_mock.extractArgs = jest.fn().mockImplementation(() => ({
sourceEnvName: 'sourceEnvName',
newEnvName: 'newEnvName',
appId: 'appId',
environmentName: 'environmentName',
}));
listUiBuilderComponentsDependencyMock.listUiBuilderComponents = jest.fn().mockImplementation((context: any, envName: any) => {
listUiBuilderComponentsDependency_mock.listUiBuilderComponents = jest.fn().mockImplementation((context: any, envName: any) => {
if (envName === 'newEnvName') {
return {
entities: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,31 @@ import * as notifyMissingPackagesDependency from '../commands/utils/notifyMissin
import * as listUiBuilderComponentsDependency from '../commands/utils/syncAmplifyUiBuilderComponents';
import * as generateUiBuilderComponentsDependency from '../commands/utils/syncAmplifyUiBuilderComponents';
import * as generateUiBuilderThemesDependency from '../commands/utils/syncAmplifyUiBuilderComponents';
import * as syncAmplifyBackendModelsDependency from '../commands/utils/getAmplifyDataSchema';
import * as listUiBuilderThemesDependency from '../commands/utils/syncAmplifyUiBuilderComponents';
import * as generateAmplifyUiBuilderIndexFileDependency from '../commands/utils/createUiBuilderComponent';
import { run } from '../commands/generateComponents';

jest.mock('../commands/utils/syncAmplifyUiBuilderComponents');
jest.mock('../commands/utils/createUiBuilderComponent');
jest.mock('../commands/utils/shouldRenderComponents');
jest.mock('../commands/utils/notifyMissingPackages');
jest.mock('../clients', () => ({
AmplifyClientFactory: {
setClientInfo: jest.fn(),
amplifyUiBuilder: {
createComponent: () => ({
promise: () => true,
}),
},
amplifyBackend: jest.fn(),
},
}));

const shouldRenderComponentsDependencyMock = shouldRenderComponentsDependency as any;
const notifyMissingPackagesDependencyMock = notifyMissingPackagesDependency as any;
const listUiBuilderComponentsDependencyMock = listUiBuilderComponentsDependency as any;
const generateUiBuilderComponentsDependencyMock = generateUiBuilderComponentsDependency as any;
const generateUiBuilderThemesDependencyMock = generateUiBuilderThemesDependency as any;
const syncAmplifyBackendModelsDependencyMock = syncAmplifyBackendModelsDependency as any;
const listUiBuilderThemesDependencyMock = listUiBuilderThemesDependency as any;
const generateAmplifyUiBuilderIndexFileDependencyMock = generateAmplifyUiBuilderIndexFileDependency as any;
const shouldRenderComponentsDependency_mock = shouldRenderComponentsDependency as any;
const notifyMissingPackagesDependency_mock = notifyMissingPackagesDependency as any;
const listUiBuilderComponentsDependency_mock = listUiBuilderComponentsDependency as any;
const generateUiBuilderComponentsDependency_mock = generateUiBuilderComponentsDependency as any;
const generateUiBuilderThemesDependency_mock = generateUiBuilderThemesDependency as any;
const listUiBuilderThemesDependency_mock = listUiBuilderThemesDependency as any;
const generateAmplifyUiBuilderIndexFileDependency_mock = generateAmplifyUiBuilderIndexFileDependency as any;

shouldRenderComponentsDependencyMock.shouldRenderComponents = jest.fn().mockImplementation(() => true);
notifyMissingPackagesDependencyMock.notifyMissingPackages = jest.fn().mockImplementation(() => true);
shouldRenderComponentsDependency_mock.shouldRenderComponents = jest.fn().mockImplementation(() => true);
notifyMissingPackagesDependency_mock.notifyMissingPackages = jest.fn().mockImplementation(() => true);

describe('can generate components', () => {
let context: any;
let schemas: any;
let generateUiBuilderComponents: any;
let generateUiBuilderThemes: any;
beforeEach(() => {
context = {
input: {
options: {
appId: 'testAppId',
envName: 'testEnvName',
},
},
};
context = {};
schemas = {
entities: [
{
Expand All @@ -58,29 +38,15 @@ describe('can generate components', () => {
},
],
};
listUiBuilderComponentsDependencyMock.listUiBuilderComponents = jest.fn().mockImplementation(() => schemas);
listUiBuilderThemesDependencyMock.listUiBuilderThemes = jest.fn().mockImplementation(() => schemas);
generateUiBuilderComponentsDependencyMock.generateUiBuilderComponents = jest.fn().mockImplementation(() => schemas.entities);
generateUiBuilderThemesDependencyMock.generateUiBuilderThemes = jest.fn().mockImplementation(() => schemas.entities);
syncAmplifyBackendModelsDependencyMock.getAmplifyBackendModels = jest.fn().mockImplementation(() => ({
models: {
Blog: {
id: {
name: 'id',
isArray: false,
type: 'ID',
isRequired: true,
attributes: [],
},
},
},
}));
generateAmplifyUiBuilderIndexFileDependencyMock.generateAmplifyUiBuilderIndexFile = jest.fn().mockImplementation(() => true);
listUiBuilderComponentsDependency_mock.listUiBuilderComponents = jest.fn().mockImplementation(() => schemas);
listUiBuilderThemesDependency_mock.listUiBuilderThemes = jest.fn().mockImplementation(() => schemas);
generateUiBuilderComponentsDependency_mock.generateUiBuilderComponents = jest.fn().mockImplementation(() => schemas.entities);
generateUiBuilderThemesDependency_mock.generateUiBuilderThemes = jest.fn().mockImplementation(() => schemas.entities);
generateAmplifyUiBuilderIndexFileDependency_mock.generateAmplifyUiBuilderIndexFile = jest.fn().mockImplementation(() => true);
});

it('runs generateComponents', async () => {
await run(context);
expect(generateUiBuilderComponentsDependencyMock.generateUiBuilderComponents).toBeCalledTimes(1);
expect(generateUiBuilderThemesDependencyMock.generateUiBuilderThemes).toBeCalledTimes(1);
expect(generateUiBuilderComponentsDependency_mock.generateUiBuilderComponents).toBeCalledTimes(1);
expect(generateUiBuilderThemesDependency_mock.generateUiBuilderThemes).toBeCalledTimes(1);
});
});

This file was deleted.

Loading

0 comments on commit c36fa71

Please sign in to comment.