diff --git a/packages/@aws-cdk-testing/cli-integ/lib/package-sources/release-source.ts b/packages/@aws-cdk-testing/cli-integ/lib/package-sources/release-source.ts index 544e9ef5dabf7..10b227678ef26 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/package-sources/release-source.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/package-sources/release-source.ts @@ -60,6 +60,10 @@ export class ReleasePackageSource implements IPackageSource { return this.version.split('.')[0] as string; } + public requestedCliVersion() { + return this.version; + } + public requestedFrameworkVersion() { return process.env.FRAMEWORK_VERSION!; } diff --git a/packages/@aws-cdk-testing/cli-integ/lib/package-sources/repo-source.ts b/packages/@aws-cdk-testing/cli-integ/lib/package-sources/repo-source.ts index 7a5f08ec71b98..e6d3714aa4b64 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/package-sources/repo-source.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/package-sources/repo-source.ts @@ -49,6 +49,10 @@ export class RepoPackageSource implements IPackageSource { return releaseJson.majorVersion; } + public requestedCliVersion(): string { + return '*'; + } + public requestedFrameworkVersion(): string { return '*'; } diff --git a/packages/@aws-cdk-testing/cli-integ/lib/package-sources/source.ts b/packages/@aws-cdk-testing/cli-integ/lib/package-sources/source.ts index 21e970701db94..88d0c4051d39a 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/package-sources/source.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/package-sources/source.ts @@ -14,6 +14,11 @@ export interface IPackageSource { initializeDotnetPackages(targetDir: string): Promise; + /** + * CLI version + */ + requestedCliVersion(): string; + /** * Framework version if it's different than the CLI version * diff --git a/packages/@aws-cdk-testing/cli-integ/tests/tool-integrations/amplify.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/tool-integrations/amplify.integtest.ts new file mode 100644 index 0000000000000..50be902ef31d2 --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/tests/tool-integrations/amplify.integtest.ts @@ -0,0 +1,27 @@ +import { promises as fs } from 'fs'; +import * as path from 'path'; +import { integTest, withTemporaryDirectory, ShellHelper, withPackages, TemporaryDirectoryContext } from '../../lib'; + +const TIMEOUT = 1800_000; + +integTest('amplify integration', withTemporaryDirectory(withPackages(async (context) => { + const shell = ShellHelper.fromContext(context); + + await shell.shell(['npm', 'create', '-y', 'amplify@latest']); + await shell.shell(['npx', 'ampx', 'configure', 'telemetry', 'disable']); + + // This will create 'package.json' implicating a certain version of the CDK + await updateCdkDependency(context, context.packages.requestedCliVersion(), context.packages.requestedFrameworkVersion()); + await shell.shell(['npm', 'install']); + + await shell.shell(['npx', 'ampx', 'sandbox', '--once']); + await shell.shell(['npx', 'ampx', 'sandbox', 'delete', '--yes']); +})), TIMEOUT); + +async function updateCdkDependency(context: TemporaryDirectoryContext, cliVersion: string, libVersion: string) { + const filename = path.join(context.integTestDir, 'package.json'); + const pj = JSON.parse(await fs.readFile(filename, { encoding: 'utf-8' })); + pj.devDependencies['aws-cdk'] = cliVersion; + pj.devDependencies['aws-cdk-lib'] = libVersion; + await fs.writeFile(filename, JSON.stringify(pj, undefined, 2), { encoding: 'utf-8' }); +}