@aws-cdk-testing/cli-integ 2.173.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/.eslintrc.js +9 -0
  2. package/LICENSE +2 -1
  3. package/bin/query-github.js +3 -3
  4. package/bin/query-github.ts +56 -0
  5. package/bin/run-suite.js +3 -3
  6. package/bin/run-suite.ts +140 -0
  7. package/bin/stage-distribution.js +3 -2
  8. package/bin/stage-distribution.ts +267 -0
  9. package/bin/test-root.ts +3 -0
  10. package/lib/aws.js +9 -6
  11. package/lib/aws.ts +263 -0
  12. package/lib/corking.ts +33 -0
  13. package/lib/eventually.js +3 -3
  14. package/lib/eventually.ts +42 -0
  15. package/lib/files.js +3 -2
  16. package/lib/files.ts +80 -0
  17. package/lib/github.js +6 -5
  18. package/lib/github.ts +43 -0
  19. package/lib/index.ts +13 -0
  20. package/lib/integ-test.ts +81 -0
  21. package/lib/lists.ts +9 -0
  22. package/lib/memoize.ts +14 -0
  23. package/lib/npm.ts +41 -0
  24. package/lib/package-sources/release-source.js +3 -2
  25. package/lib/package-sources/release-source.ts +81 -0
  26. package/lib/package-sources/repo-source.ts +111 -0
  27. package/lib/package-sources/repo-tools/npm.js +5 -4
  28. package/lib/package-sources/repo-tools/npm.ts +48 -0
  29. package/lib/package-sources/source.ts +35 -0
  30. package/lib/package-sources/subprocess.ts +15 -0
  31. package/lib/resource-pool.js +2 -2
  32. package/lib/resource-pool.ts +140 -0
  33. package/lib/resources.ts +4 -0
  34. package/lib/shell.js +8 -5
  35. package/lib/shell.ts +168 -0
  36. package/lib/staging/codeartifact.js +11 -8
  37. package/lib/staging/codeartifact.ts +387 -0
  38. package/lib/staging/maven.js +5 -3
  39. package/lib/staging/maven.ts +95 -0
  40. package/lib/staging/npm.ts +62 -0
  41. package/lib/staging/nuget.ts +75 -0
  42. package/lib/staging/parallel-shell.js +2 -2
  43. package/lib/staging/parallel-shell.ts +51 -0
  44. package/lib/staging/pypi.ts +50 -0
  45. package/lib/staging/usage-dir.ts +99 -0
  46. package/lib/with-aws.js +3 -2
  47. package/lib/with-aws.ts +67 -0
  48. package/lib/with-cdk-app.js +23 -14
  49. package/lib/with-cdk-app.ts +742 -0
  50. package/lib/with-cli-lib.ts +134 -0
  51. package/lib/with-packages.ts +15 -0
  52. package/lib/with-sam.js +7 -4
  53. package/lib/with-sam.ts +288 -0
  54. package/lib/with-temporary-directory.ts +35 -0
  55. package/lib/with-timeout.ts +33 -0
  56. package/lib/xpmutex.js +2 -2
  57. package/lib/xpmutex.ts +218 -0
  58. package/package.json +84 -62
  59. package/resources/cloud-assemblies/0.36.0/cdk.out +1 -0
  60. package/resources/cloud-assemblies/1.10.0-lookup-default-vpc/cdk.out +1 -0
  61. package/resources/cloud-assemblies/1.10.0-request-azs/cdk.out +1 -0
  62. package/tests/cli-integ-tests/bootstrapping.integtest.js +22 -13
  63. package/tests/cli-integ-tests/bootstrapping.integtest.ts +493 -0
  64. package/tests/cli-integ-tests/cli-lib.integtest.js +3 -2
  65. package/tests/cli-integ-tests/cli-lib.integtest.ts +90 -0
  66. package/tests/cli-integ-tests/cli.integtest.js +76 -49
  67. package/tests/cli-integ-tests/cli.integtest.ts +2874 -0
  68. package/tests/cli-integ-tests/garbage-collection.integtest.js +2 -2
  69. package/tests/cli-integ-tests/garbage-collection.integtest.ts +392 -0
  70. package/tests/init-csharp/init-csharp.integtest.ts +15 -0
  71. package/tests/init-fsharp/init-fsharp.integtest.ts +15 -0
  72. package/tests/init-go/init-go.integtest.ts +23 -0
  73. package/tests/init-java/init-java.integtest.ts +14 -0
  74. package/tests/init-javascript/init-javascript.integtest.ts +59 -0
  75. package/tests/init-python/init-python.integtest.ts +20 -0
  76. package/tests/init-typescript-app/init-typescript-app.integtest.ts +66 -0
  77. package/tests/init-typescript-lib/init-typescript-lib.integtest.ts +13 -0
  78. package/tests/tool-integrations/amplify.integtest.ts +43 -0
  79. package/tests/tool-integrations/with-tool-context.ts +14 -0
  80. package/tests/uberpackage/uberpackage.integtest.ts +11 -0
  81. package/resources/cdk-apps/cfn-include-app/.gitignore +0 -1
@@ -0,0 +1,59 @@
1
+ import * as path from 'path';
2
+ import * as fs from 'fs-extra';
3
+ import { integTest, withTemporaryDirectory, ShellHelper, withPackages } from '../../lib';
4
+
5
+ ['app', 'sample-app'].forEach(template => {
6
+ integTest(`init javascript ${template}`, withTemporaryDirectory(withPackages(async (context) => {
7
+ const shell = ShellHelper.fromContext(context);
8
+ await context.packages.makeCliAvailable();
9
+
10
+ await shell.shell(['cdk', 'init', '-l', 'javascript', template]);
11
+ await shell.shell(['npm', 'prune']);
12
+ await shell.shell(['npm', 'ls']); // this will fail if we have unmet peer dependencies
13
+ await shell.shell(['npm', 'run', 'test']);
14
+
15
+ await shell.shell(['cdk', 'synth']);
16
+ })));
17
+ });
18
+
19
+ integTest('Test importing CDK from ESM', withTemporaryDirectory(withPackages(async (context) => {
20
+ // Use 'cdk init -l=javascript' to get set up, but use a different file
21
+ const shell = ShellHelper.fromContext(context);
22
+ await context.packages.makeCliAvailable();
23
+
24
+ await shell.shell(['cdk', 'init', '-l', 'javascript', 'app']);
25
+
26
+ // Rewrite some files
27
+ await fs.writeFile(path.join(context.integTestDir, 'new-entrypoint.mjs'), `
28
+ // Test multiple styles of imports
29
+ import { Stack, aws_sns as sns } from 'aws-cdk-lib';
30
+ import { SqsSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
31
+ import * as sqs from 'aws-cdk-lib/aws-sqs';
32
+ import * as cdk from 'aws-cdk-lib';
33
+
34
+ class TestjsStack extends Stack {
35
+ constructor(scope, id, props) {
36
+ super(scope, id, props);
37
+
38
+ const queue = new sqs.Queue(this, 'TestjsQueue', {
39
+ visibilityTimeout: cdk.Duration.seconds(300)
40
+ });
41
+
42
+ const topic = new sns.Topic(this, 'TestjsTopic');
43
+
44
+ topic.addSubscription(new SqsSubscription(queue));
45
+ }
46
+ }
47
+
48
+ const app = new cdk.App();
49
+ new TestjsStack(app, 'TestjsStack');
50
+ `, { encoding: 'utf-8' });
51
+
52
+ // Rewrite 'cdk.json' to use new entrypoint
53
+ const cdkJson = await fs.readJson(path.join(context.integTestDir, 'cdk.json'));
54
+ cdkJson.app = 'node new-entrypoint.mjs';
55
+ await fs.writeJson(path.join(context.integTestDir, 'cdk.json'), cdkJson);
56
+
57
+ await shell.shell(['cdk', 'synth']);
58
+
59
+ })));
@@ -0,0 +1,20 @@
1
+ import * as path from 'path';
2
+ import { integTest, withTemporaryDirectory, ShellHelper, withPackages } from '../../lib';
3
+
4
+ ['app', 'sample-app'].forEach(template => {
5
+ integTest(`init python ${template}`, withTemporaryDirectory(withPackages(async (context) => {
6
+ context.packages.assertJsiiPackagesAvailable();
7
+
8
+ const shell = ShellHelper.fromContext(context);
9
+ await context.packages.makeCliAvailable();
10
+
11
+ await shell.shell(['cdk', 'init', '-l', 'python', template]);
12
+ const venvPath = path.resolve(context.integTestDir, '.venv');
13
+ const venv = { PATH: `${venvPath}/bin:${process.env.PATH}`, VIRTUAL_ENV: venvPath };
14
+
15
+ await shell.shell([`${venvPath}/bin/pip`, 'install', '-r', 'requirements.txt'], { modEnv: venv });
16
+ await shell.shell([`${venvPath}/bin/pip`, 'install', '-r', 'requirements-dev.txt'], { modEnv: venv });
17
+ await shell.shell([`${venvPath}/bin/pytest`], { modEnv: venv });
18
+ await shell.shell(['cdk', 'synth'], { modEnv: venv });
19
+ })));
20
+ });
@@ -0,0 +1,66 @@
1
+ import { promises as fs } from 'fs';
2
+ import * as path from 'path';
3
+ import { integTest, withTemporaryDirectory, ShellHelper, withPackages, TemporaryDirectoryContext } from '../../lib';
4
+ import { typescriptVersionsSync, typescriptVersionsYoungerThanDaysSync } from '../../lib/npm';
5
+
6
+ ['app', 'sample-app'].forEach(template => {
7
+ integTest(`typescript init ${template}`, withTemporaryDirectory(withPackages(async (context) => {
8
+ const shell = ShellHelper.fromContext(context);
9
+ await context.packages.makeCliAvailable();
10
+
11
+ await shell.shell(['cdk', 'init', '-l', 'typescript', template]);
12
+
13
+ await shell.shell(['npm', 'prune']);
14
+ await shell.shell(['npm', 'ls']); // this will fail if we have unmet peer dependencies
15
+ await shell.shell(['npm', 'run', 'build']);
16
+ await shell.shell(['npm', 'run', 'test']);
17
+
18
+ await shell.shell(['cdk', 'synth']);
19
+ })));
20
+ });
21
+
22
+ // Same as https://github.com/DefinitelyTyped/DefinitelyTyped?tab=readme-ov-file#support-window
23
+ const TYPESCRIPT_VERSION_AGE_DAYS = 2 * 365;
24
+
25
+ const TYPESCRIPT_VERSIONS = typescriptVersionsYoungerThanDaysSync(TYPESCRIPT_VERSION_AGE_DAYS, typescriptVersionsSync());
26
+
27
+ // eslint-disable-next-line no-console
28
+ console.log(TYPESCRIPT_VERSIONS);
29
+
30
+ /**
31
+ * Test our generated code with various versions of TypeScript
32
+ */
33
+ TYPESCRIPT_VERSIONS.forEach(tsVersion => {
34
+ integTest(`typescript ${tsVersion} init app`, withTemporaryDirectory(withPackages(async (context) => {
35
+ const shell = ShellHelper.fromContext(context);
36
+ await context.packages.makeCliAvailable();
37
+
38
+ await shell.shell(['node', '--version']);
39
+ await shell.shell(['npm', '--version']);
40
+
41
+ await shell.shell(['cdk', 'init', '-l', 'typescript', 'app', '--generate-only']);
42
+
43
+ // Necessary because recent versions of ts-jest require TypeScript>=4.3 but we
44
+ // still want to test with older versions as well.
45
+ await removeDevDependencies(context);
46
+
47
+ await shell.shell(['npm', 'install', '--save-dev', `typescript@${tsVersion}`]);
48
+ await shell.shell(['npm', 'install']); // Older versions of npm require this to be a separate step from the one above
49
+ await shell.shell(['npx', 'tsc', '--version']);
50
+ await shell.shell(['npm', 'prune']);
51
+ await shell.shell(['npm', 'ls']); // this will fail if we have unmet peer dependencies
52
+
53
+ // We just removed the 'jest' dependency so remove the tests as well because they won't compile
54
+ await shell.shell(['rm', '-rf', 'test/']);
55
+
56
+ await shell.shell(['npm', 'run', 'build']);
57
+ await shell.shell(['cdk', 'synth']);
58
+ })));
59
+ });
60
+
61
+ async function removeDevDependencies(context: TemporaryDirectoryContext) {
62
+ const filename = path.join(context.integTestDir, 'package.json');
63
+ const pj = JSON.parse(await fs.readFile(filename, { encoding: 'utf-8' }));
64
+ delete pj.devDependencies;
65
+ await fs.writeFile(filename, JSON.stringify(pj, undefined, 2), { encoding: 'utf-8' });
66
+ }
@@ -0,0 +1,13 @@
1
+ import { integTest, withTemporaryDirectory, ShellHelper, withPackages } from '../../lib';
2
+
3
+ integTest('typescript init lib', withTemporaryDirectory(withPackages(async (context) => {
4
+ const shell = ShellHelper.fromContext(context);
5
+ await context.packages.makeCliAvailable();
6
+
7
+ await shell.shell(['cdk', 'init', '-l', 'typescript', 'lib']);
8
+
9
+ await shell.shell(['npm', 'prune']);
10
+ await shell.shell(['npm', 'ls']); // this will fail if we have unmet peer dependencies
11
+ await shell.shell(['npm', 'run', 'build']);
12
+ await shell.shell(['npm', 'run', 'test']);
13
+ })));
@@ -0,0 +1,43 @@
1
+ import { promises as fs } from 'fs';
2
+ import * as path from 'path';
3
+ import { withToolContext } from './with-tool-context';
4
+ import { integTest, ShellHelper, TemporaryDirectoryContext } from '../../lib';
5
+
6
+ const TIMEOUT = 1800_000;
7
+
8
+ integTest('amplify integration', withToolContext(async (context) => {
9
+ const shell = ShellHelper.fromContext(context);
10
+
11
+ await shell.shell(['npm', 'create', '-y', 'amplify@latest']);
12
+ await shell.shell(['npx', 'ampx', 'configure', 'telemetry', 'disable']);
13
+
14
+ // This will create 'package.json' implicating a certain version of the CDK
15
+ await updateCdkDependency(context, context.packages.requestedCliVersion(), context.packages.requestedFrameworkVersion());
16
+ await shell.shell(['npm', 'install']);
17
+
18
+ await shell.shell(['npx', 'ampx', 'sandbox', '--once'], {
19
+ modEnv: {
20
+ AWS_REGION: context.aws.region,
21
+ },
22
+ });
23
+ try {
24
+
25
+ // Future code goes here, putting the try/finally here already so it doesn't
26
+ // get forgotten.
27
+
28
+ } finally {
29
+ await shell.shell(['npx', 'ampx', 'sandbox', 'delete', '--yes'], {
30
+ modEnv: {
31
+ AWS_REGION: context.aws.region,
32
+ },
33
+ });
34
+ }
35
+ }), TIMEOUT);
36
+
37
+ async function updateCdkDependency(context: TemporaryDirectoryContext, cliVersion: string, libVersion: string) {
38
+ const filename = path.join(context.integTestDir, 'package.json');
39
+ const pj = JSON.parse(await fs.readFile(filename, { encoding: 'utf-8' }));
40
+ pj.devDependencies['aws-cdk'] = cliVersion;
41
+ pj.devDependencies['aws-cdk-lib'] = libVersion;
42
+ await fs.writeFile(filename, JSON.stringify(pj, undefined, 2), { encoding: 'utf-8' });
43
+ }
@@ -0,0 +1,14 @@
1
+ import { TestContext } from '../../lib/integ-test';
2
+ import { AwsContext, withAws } from '../../lib/with-aws';
3
+ import { DisableBootstrapContext } from '../../lib/with-cdk-app';
4
+ import { PackageContext, withPackages } from '../../lib/with-packages';
5
+ import { TemporaryDirectoryContext, withTemporaryDirectory } from '../../lib/with-temporary-directory';
6
+
7
+ /**
8
+ * The default prerequisites for tests running tool integrations
9
+ */
10
+ export function withToolContext<A extends TestContext>(
11
+ block: (context: A & TemporaryDirectoryContext & PackageContext & AwsContext & DisableBootstrapContext
12
+ ) => Promise<void>) {
13
+ return withAws(withTemporaryDirectory(withPackages(block)));
14
+ }
@@ -0,0 +1,11 @@
1
+ import { integTest, withMonolithicCfnIncludeCdkApp } from '../../lib';
2
+
3
+ jest.setTimeout(600_000);
4
+
5
+ describe('uberpackage', () => {
6
+ integTest('works with cloudformation-include', withMonolithicCfnIncludeCdkApp(async (fixture) => {
7
+ fixture.log('Starting test of cfn-include with monolithic CDK');
8
+
9
+ await fixture.cdkSynth();
10
+ }));
11
+ });
@@ -1 +0,0 @@
1
- !cfn-include-app.js