Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/amplify-category-function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@aws-amplify/amplify-prompts": "2.8.7",
"@aws-sdk/client-ssm": "^3.624.0",
"archiver": "^7.0.1",
"aws-sdk": "^2.1464.0",
"chalk": "^4.1.1",
"cloudform-types": "^4.2.0",
"enquirer": "^2.3.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ const secretsUsageFooter = `Parameters will be of the form { Name: 'secretName',
const secretsUsageTemplate = (secretNames: string[]) =>
`${secretsUsageHeader}

const aws = require('aws-sdk');
const { SSMClient, GetParametersCommand } = require('@aws-sdk/client-ssm');

const { Parameters } = await (new aws.SSM())
.getParameters({
Names: ${JSON.stringify(secretNames)}.map(secretName => process.env[secretName]),
WithDecryption: true,
})
.promise();
const client = new SSMClient();
const { Parameters } = await client.send(new GetParametersCommand({
Names: ${JSON.stringify(secretNames)}.map(secretName => process.env[secretName]),
WithDecryption: true,
}));

${secretsUsageFooter}`;

Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@aws-amplify/amplify-util-uibuilder": "1.14.21",
"@aws-cdk/cloudformation-diff": "~2.68.0",
"@aws-sdk/client-amplify": "^3.624.0",
"@aws-sdk/client-cognito-identity-provider": "^3.624.0",
"amplify-codegen": "^4.10.3",
"amplify-dotnet-function-runtime-provider": "2.1.6",
"amplify-go-function-runtime-provider": "2.3.53",
Expand All @@ -75,7 +76,6 @@
"amplify-nodejs-function-runtime-provider": "2.5.31",
"amplify-python-function-runtime-provider": "2.4.53",
"aws-cdk-lib": "~2.189.1",
"aws-sdk": "^2.1464.0",
"chalk": "^4.1.1",
"ci-info": "^3.8.0",
"cli-table3": "^0.6.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/amplify-cli/src/commands/logout.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { stateManager } from '@aws-amplify/amplify-cli-core';
import { printer, prompter } from '@aws-amplify/amplify-prompts';
import { Context } from '../domain/context';
import { CognitoIdentityServiceProvider } from 'aws-sdk';
import { CognitoIdentityProviderClient, GlobalSignOutCommand } from '@aws-sdk/client-cognito-identity-provider';

export const run = async (context: Context) => {
const { appId } = context.parameters.options;
Expand All @@ -20,9 +20,9 @@ export const run = async (context: Context) => {
const useGlobalSignOut = await prompter.yesOrNo('Do you want to logout from all sessions?');

if (useGlobalSignOut) {
const cognitoISP = new CognitoIdentityServiceProvider({ region: amplifyAdminConfig.region });
const cognitoISP = new CognitoIdentityProviderClient({ region: amplifyAdminConfig.region });
try {
await cognitoISP.globalSignOut(amplifyAdminConfig.accessToken.jwtToken);
await cognitoISP.send(new GlobalSignOutCommand({ AccessToken: amplifyAdminConfig.accessToken.jwtToken }));
printer.info('Logged out globally.');
} catch (e) {
printer.error(`An error occurred during logout: ${e.message}`);
Expand Down
3 changes: 2 additions & 1 deletion packages/amplify-console-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"dependencies": {
"@aws-amplify/amplify-cli-core": "4.4.3",
"@aws-amplify/amplify-e2e-core": "5.7.6",
"@aws-sdk/client-amplify": "^3.624.0",
"@aws-sdk/client-cloudformation": "^3.624.0",
"@types/ini": "^1.3.30",
"aws-sdk": "^2.1464.0",
"dotenv": "^8.2.0",
"execa": "^5.1.1",
"fs-extra": "^8.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import { Amplify, CloudFormation } from 'aws-sdk';
import {
AmplifyClient,
ListAppsCommand,
DeleteAppCommand,
CreateAppCommand,
CreateBackendEnvironmentCommand,
} from '@aws-sdk/client-amplify';
import { CloudFormationClient, DeleteStackCommand } from '@aws-sdk/client-cloudformation';
import moment from 'moment';

import { getConfigFromProfile } from '../profile-helper';

export function getConfiguredAmplifyClient() {
const config = getConfigFromProfile();
return new Amplify(config);
return new AmplifyClient(config);
}

export function getConfiguredCFNClient() {
const config = getConfigFromProfile();
return new CloudFormation(config);
return new CloudFormationClient(config);
}

//delete all existing amplify console projects
export async function deleteAllAmplifyProjects(amplifyClient?: Amplify) {
export async function deleteAllAmplifyProjects(amplifyClient?: AmplifyClient) {
if (!amplifyClient) {
amplifyClient = getConfiguredAmplifyClient();
}
Expand All @@ -24,29 +31,29 @@ export async function deleteAllAmplifyProjects(amplifyClient?: Amplify) {
} while (token);
}

export async function deleteAmplifyStack(stackName: string, cfnClient?: CloudFormation) {
export async function deleteAmplifyStack(stackName: string, cfnClient?: CloudFormationClient) {
if (!cfnClient) cfnClient = getConfiguredCFNClient();
try {
await cfnClient.deleteStack({ StackName: stackName }).promise();
await cfnClient.send(new DeleteStackCommand({ StackName: stackName }));
} catch (err) {
// do nothing
}
}

async function PaginatedDeleteProjects(amplifyClient: any, token?: any) {
async function PaginatedDeleteProjects(amplifyClient: AmplifyClient, token?: string) {
const sequential = require('promise-sequential');
const maxResults = '25';
const listAppsResult = await amplifyClient
.listApps({
const maxResults = 25;
const listAppsResult = await amplifyClient.send(
new ListAppsCommand({
maxResults,
nextToken: token,
})
.promise();
}),
);

const deleteTasks = [];
listAppsResult.apps.forEach((app) => {
deleteTasks.push(async () => {
await amplifyClient.deleteApp({ appId: app.appId }).promise();
await amplifyClient.send(new DeleteAppCommand({ appId: app.appId }));
});
});
await sequential(deleteTasks);
Expand All @@ -61,7 +68,7 @@ export function generateBackendEnvParams(appId: string, projectName: string, env
return { appId, envName, stackName, deploymentBucketName };
}

export async function createConsoleApp(projectName: string, amplifyClient?: Amplify) {
export async function createConsoleApp(projectName: string, amplifyClient?: AmplifyClient) {
if (!amplifyClient) {
amplifyClient = getConfiguredAmplifyClient();
}
Expand All @@ -70,25 +77,25 @@ export async function createConsoleApp(projectName: string, amplifyClient?: Ampl
environmentVariables: { _LIVE_PACKAGE_UPDATES: '[{"pkg":"@aws-amplify/cli","type":"npm","version":"latest"}]' },
};

const createAppResponse = await amplifyClient.createApp(createAppParams).promise();
const createAppResponse = await amplifyClient.send(new CreateAppCommand(createAppParams));
return createAppResponse.app.appId;
}

export async function deleteConsoleApp(appId: string, amplifyClient?: Amplify) {
export async function deleteConsoleApp(appId: string, amplifyClient?: AmplifyClient) {
if (!amplifyClient) {
amplifyClient = getConfiguredAmplifyClient();
}
const deleteAppParams = {
appId,
};
try {
await amplifyClient.deleteApp(deleteAppParams).promise();
await amplifyClient.send(new DeleteAppCommand(deleteAppParams));
} catch (err) {
// Do nothing
}
}

export async function createBackendEnvironment(backendParams: any, amplifyClient?: Amplify) {
export async function createBackendEnvironment(backendParams: any, amplifyClient?: AmplifyClient) {
if (!amplifyClient) {
amplifyClient = getConfiguredAmplifyClient();
}
Expand All @@ -102,5 +109,5 @@ export async function createBackendEnvironment(backendParams: any, amplifyClient
deploymentArtifacts: deploymentBucketName,
};

await amplifyClient.createBackendEnvironment(createEnvParams).promise();
await amplifyClient.send(new CreateBackendEnvironmentCommand(createEnvParams));
}
1 change: 0 additions & 1 deletion packages/amplify-environment-parameters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"lodash": "^4.17.21"
},
"devDependencies": {
"aws-sdk": "^2.1464.0",
"mkdirp": "^1.0.4",
"ts-json-schema-generator": "~1.1.2"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/amplify-util-uibuilder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"@aws-amplify/amplify-prompts": "2.8.7",
"@aws-amplify/codegen-ui": "2.14.2",
"@aws-amplify/codegen-ui-react": "2.14.2",
"@aws-sdk/client-amplifybackend": "^3.624.0",
"@aws-sdk/client-amplifyuibuilder": "^3.624.0",
"amplify-codegen": "^4.10.3",
"aws-sdk": "^2.1464.0",
"fs-extra": "^8.1.0",
"node-fetch": "^2.6.7",
"ora": "^4.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`should sync amplify ui builder components can map generic data schema to start codegen job request 1`] = `
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import aws from 'aws-sdk'; // eslint-disable-line import/no-extraneous-dependencies
import { ExportComponentsCommand, CreateComponentCommand, GetMetadataCommand } from '@aws-sdk/client-amplifyuibuilder';
import * as extractArgsDependency from '../commands/utils/extractArgs';
import { run } from '../commands/cloneComponentsFromEnv';
import { isDataStoreEnabled } from '@aws-amplify/amplify-category-api';

const extractArgsDependencyMock = extractArgsDependency as any;
const awsMock = aws as any;
const mockSend = jest.fn();

jest.mock('@aws-sdk/client-amplifyuibuilder', () => ({
...jest.requireActual('@aws-sdk/client-amplifyuibuilder'),
AmplifyUIBuilderClient: jest.fn().mockImplementation(() => ({
send: mockSend,
})),
}));

jest.mock('../commands/utils/featureFlags', () => ({
getTransformerVersion: jest.fn().mockReturnValue(2),
Expand All @@ -18,21 +25,10 @@ jest.mock('@aws-amplify/amplify-cli-core');

const isDataStoreEnabledMocked = jest.mocked(isDataStoreEnabled);

const mockedComponentExport = jest.fn((envName: string) => {
if (envName === 'newEnvName') {
return {
entities: [],
};
}
return {
entities: [{}],
};
});
const mockedComponentCreate = jest.fn().mockReturnValue({ entity: {} });

describe('can clone components to new environment', () => {
let context: any;
beforeEach(() => {
mockSend.mockReset();
isDataStoreEnabledMocked.mockResolvedValue(true);
context = {
amplify: {
Expand All @@ -51,13 +47,19 @@ describe('can clone components to new environment', () => {
appId: 'appId',
environmentName: 'environmentName',
});
awsMock.AmplifyUIBuilder = jest.fn().mockReturnValue({
exportComponents: jest.fn(({ environmentName }) => ({
promise: () => mockedComponentExport(environmentName),
})),
createComponent: jest.fn().mockReturnValue({ promise: () => mockedComponentCreate() }),
getMetadata: jest.fn().mockReturnValue({
promise: jest.fn().mockReturnValue({

mockSend.mockImplementation((command) => {
if (command instanceof ExportComponentsCommand) {
if (command.input.environmentName === 'newEnvName') {
return Promise.resolve({ entities: [] });
}
return Promise.resolve({ entities: [{}] });
}
if (command instanceof CreateComponentCommand) {
return Promise.resolve({ entity: {} });
}
if (command instanceof GetMetadataCommand) {
return Promise.resolve({
features: {
autoGenerateForms: 'true',
autoGenerateViews: 'true',
Expand All @@ -66,14 +68,16 @@ describe('can clone components to new environment', () => {
isNonModelSupported: 'false',
},
},
}),
}),
});
}
return Promise.resolve({});
});
});

it('clones components to a new env', async () => {
await run(context);
expect(mockedComponentExport).toBeCalledTimes(2);
expect(mockedComponentCreate).toBeCalledTimes(1);
expect(mockSend).toHaveBeenCalledTimes(4);
expect(mockSend).toHaveBeenCalledWith(expect.any(ExportComponentsCommand));
expect(mockSend).toHaveBeenCalledWith(expect.any(CreateComponentCommand));
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AmplifyStudioClient } from '../clients'; // eslint-disable-line import/no-extraneous-dependencies
import { isFormDetachedFromModel, isFormSchemaCustomized, isStudioForm, deleteDetachedForms } from '../commands/utils';
import { Form } from 'aws-sdk/clients/amplifyuibuilder';
import { Form } from '@aws-sdk/client-amplifyuibuilder';

const amplifyStudioClientMock = AmplifyStudioClient as any;

Expand Down
Loading
Loading