@cdktn/cli-core 0.21.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 (154) hide show
  1. package/README.md +3 -0
  2. package/ambient.d.ts +13 -0
  3. package/eslint.config.mjs +82 -0
  4. package/jest.config.js +20 -0
  5. package/package.json +139 -0
  6. package/src/lib/cdktf-config.d.ts +16 -0
  7. package/src/lib/cdktf-config.d.ts.map +1 -0
  8. package/src/lib/cdktf-config.js +108 -0
  9. package/src/lib/cdktf-project-io-handler.d.ts +20 -0
  10. package/src/lib/cdktf-project-io-handler.d.ts.map +1 -0
  11. package/src/lib/cdktf-project-io-handler.js +84 -0
  12. package/src/lib/cdktf-project.d.ts +111 -0
  13. package/src/lib/cdktf-project.d.ts.map +1 -0
  14. package/src/lib/cdktf-project.js +371 -0
  15. package/src/lib/cdktf-stack.d.ts +134 -0
  16. package/src/lib/cdktf-stack.d.ts.map +1 -0
  17. package/src/lib/cdktf-stack.js +386 -0
  18. package/src/lib/convert.d.ts +6 -0
  19. package/src/lib/convert.d.ts.map +1 -0
  20. package/src/lib/convert.js +51 -0
  21. package/src/lib/dependencies/cdktf-config-manager.d.ts +12 -0
  22. package/src/lib/dependencies/cdktf-config-manager.d.ts.map +1 -0
  23. package/src/lib/dependencies/cdktf-config-manager.js +36 -0
  24. package/src/lib/dependencies/dependency-manager.d.ts +95 -0
  25. package/src/lib/dependencies/dependency-manager.d.ts.map +1 -0
  26. package/src/lib/dependencies/dependency-manager.js +393 -0
  27. package/src/lib/dependencies/package-manager.d.ts +18 -0
  28. package/src/lib/dependencies/package-manager.d.ts.map +1 -0
  29. package/src/lib/dependencies/package-manager.js +581 -0
  30. package/src/lib/dependencies/prebuilt-providers.d.ts +23 -0
  31. package/src/lib/dependencies/prebuilt-providers.d.ts.map +1 -0
  32. package/src/lib/dependencies/prebuilt-providers.js +220 -0
  33. package/src/lib/dependencies/registry-api.d.ts +8 -0
  34. package/src/lib/dependencies/registry-api.d.ts.map +1 -0
  35. package/src/lib/dependencies/registry-api.js +77 -0
  36. package/src/lib/dependencies/version-constraints.d.ts +8 -0
  37. package/src/lib/dependencies/version-constraints.d.ts.map +1 -0
  38. package/src/lib/dependencies/version-constraints.js +95 -0
  39. package/src/lib/error-reporting.d.ts +10 -0
  40. package/src/lib/error-reporting.d.ts.map +1 -0
  41. package/src/lib/error-reporting.js +133 -0
  42. package/src/lib/errors.d.ts +6 -0
  43. package/src/lib/errors.d.ts.map +1 -0
  44. package/src/lib/errors.js +10 -0
  45. package/src/lib/execution-logs.d.ts +3 -0
  46. package/src/lib/execution-logs.d.ts.map +1 -0
  47. package/src/lib/execution-logs.js +47 -0
  48. package/src/lib/get.d.ts +25 -0
  49. package/src/lib/get.d.ts.map +1 -0
  50. package/src/lib/get.js +90 -0
  51. package/src/lib/helpers/stack-helpers.d.ts +16 -0
  52. package/src/lib/helpers/stack-helpers.d.ts.map +1 -0
  53. package/src/lib/helpers/stack-helpers.js +155 -0
  54. package/src/lib/index.d.ts +15 -0
  55. package/src/lib/index.d.ts.map +1 -0
  56. package/src/lib/index.js +44 -0
  57. package/src/lib/init.d.ts +37 -0
  58. package/src/lib/init.d.ts.map +1 -0
  59. package/src/lib/init.js +131 -0
  60. package/src/lib/local-provider-constraints.d.ts +28 -0
  61. package/src/lib/local-provider-constraints.d.ts.map +1 -0
  62. package/src/lib/local-provider-constraints.js +95 -0
  63. package/src/lib/local-provider-versions.d.ts +12 -0
  64. package/src/lib/local-provider-versions.d.ts.map +1 -0
  65. package/src/lib/local-provider-versions.js +73 -0
  66. package/src/lib/models/deploy-machine.d.ts +128 -0
  67. package/src/lib/models/deploy-machine.d.ts.map +1 -0
  68. package/src/lib/models/deploy-machine.js +280 -0
  69. package/src/lib/models/pty-process.d.ts +29 -0
  70. package/src/lib/models/pty-process.d.ts.map +1 -0
  71. package/src/lib/models/pty-process.js +132 -0
  72. package/src/lib/models/schema.d.ts +2307 -0
  73. package/src/lib/models/schema.d.ts.map +1 -0
  74. package/src/lib/models/schema.js +181 -0
  75. package/src/lib/models/terraform-cli.d.ts +72 -0
  76. package/src/lib/models/terraform-cli.d.ts.map +1 -0
  77. package/src/lib/models/terraform-cli.js +357 -0
  78. package/src/lib/models/terraform.d.ts +125 -0
  79. package/src/lib/models/terraform.d.ts.map +1 -0
  80. package/src/lib/models/terraform.js +72 -0
  81. package/src/lib/output.d.ts +23 -0
  82. package/src/lib/output.d.ts.map +1 -0
  83. package/src/lib/output.js +211 -0
  84. package/src/lib/provider-add.d.ts +15 -0
  85. package/src/lib/provider-add.d.ts.map +1 -0
  86. package/src/lib/provider-add.js +30 -0
  87. package/src/lib/server/terraform-logs.d.ts +2 -0
  88. package/src/lib/server/terraform-logs.d.ts.map +1 -0
  89. package/src/lib/server/terraform-logs.js +19 -0
  90. package/src/lib/synth-stack.d.ts +29 -0
  91. package/src/lib/synth-stack.d.ts.map +1 -0
  92. package/src/lib/synth-stack.js +251 -0
  93. package/src/lib/synth.d.ts +7 -0
  94. package/src/lib/synth.d.ts.map +1 -0
  95. package/src/lib/synth.js +67 -0
  96. package/src/lib/terraform-json.d.ts +1015 -0
  97. package/src/lib/terraform-json.d.ts.map +1 -0
  98. package/src/lib/terraform-json.js +82 -0
  99. package/src/lib/terraform-provider-lock.d.ts +25 -0
  100. package/src/lib/terraform-provider-lock.d.ts.map +1 -0
  101. package/src/lib/terraform-provider-lock.js +95 -0
  102. package/src/lib/watch.d.ts +16 -0
  103. package/src/lib/watch.d.ts.map +1 -0
  104. package/src/lib/watch.js +155 -0
  105. package/templates/csharp/.hooks.sscaff.js +63 -0
  106. package/templates/csharp/MainStack.cs +15 -0
  107. package/templates/csharp/MyTerraformStack.csproj +13 -0
  108. package/templates/csharp/Program.cs +17 -0
  109. package/templates/csharp/TestProgram.cs +42 -0
  110. package/templates/csharp/cdktf.json +11 -0
  111. package/templates/csharp/help +42 -0
  112. package/templates/csharp/{{}}.gitignore +345 -0
  113. package/templates/go/.hooks.sscaff.js +70 -0
  114. package/templates/go/cdktf.json +12 -0
  115. package/templates/go/go.mod +8 -0
  116. package/templates/go/help +32 -0
  117. package/templates/go/main.go +22 -0
  118. package/templates/go/main_test.go +42 -0
  119. package/templates/go/{{}}.gitignore +21 -0
  120. package/templates/java/.hooks.sscaff.js +64 -0
  121. package/templates/java/build.gradle +55 -0
  122. package/templates/java/cdktf.json +12 -0
  123. package/templates/java/gradle.properties +1 -0
  124. package/templates/java/gradlew +248 -0
  125. package/templates/java/gradlew.bat +92 -0
  126. package/templates/java/help +35 -0
  127. package/templates/java/settings.gradle +5 -0
  128. package/templates/java/src/main/java/com/mycompany/app/Main.java +16 -0
  129. package/templates/java/src/main/java/com/mycompany/app/MainStack.java +14 -0
  130. package/templates/java/src/test/java/com/company/app/MainTest.java +38 -0
  131. package/templates/java/{{}}.gitignore +14 -0
  132. package/templates/python/.hooks.sscaff.js +59 -0
  133. package/templates/python/Pipfile +7 -0
  134. package/templates/python/cdktf.json +12 -0
  135. package/templates/python/help +42 -0
  136. package/templates/python/main-test.py +26 -0
  137. package/templates/python/main.py +16 -0
  138. package/templates/python/{{}}.gitignore +7 -0
  139. package/templates/python-pip/.hooks.sscaff.js +63 -0
  140. package/templates/python-pip/cdktf.json +12 -0
  141. package/templates/python-pip/help +35 -0
  142. package/templates/python-pip/main-test.py +23 -0
  143. package/templates/python-pip/main.py +16 -0
  144. package/templates/python-pip/{{}}.gitignore +7 -0
  145. package/templates/typescript/.hooks.sscaff.js +78 -0
  146. package/templates/typescript/__tests__/main-test.ts +89 -0
  147. package/templates/typescript/cdktf.json +11 -0
  148. package/templates/typescript/help +51 -0
  149. package/templates/typescript/jest.config.js +187 -0
  150. package/templates/typescript/main.ts +14 -0
  151. package/templates/typescript/package.json +22 -0
  152. package/templates/typescript/setup.js +2 -0
  153. package/templates/typescript/tsconfig.json +35 -0
  154. package/templates/typescript/{{}}.gitignore +11 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ const { execSync } = require('child_process');
7
+ const { chmodSync } = require('fs');
8
+ const { readFileSync, writeFileSync } = require('fs');
9
+ const os = require('os');
10
+
11
+ exports.pre = () => {
12
+ try {
13
+ if (os.platform() === 'win32') {
14
+ execSync('where pip3')
15
+ }
16
+ else {
17
+ execSync('which pip3')
18
+ }
19
+ } catch {
20
+ console.error(`Unable to find "pip3".`)
21
+ process.exit(1);
22
+ }
23
+ };
24
+
25
+ exports.post = options => {
26
+ // Terraform Cloud configuration settings if the organization name and workspace is set.
27
+ if (options.OrganizationName != '') {
28
+ console.log(`\nGenerating Terraform Cloud configuration for '${options.OrganizationName}' organization and '${options.WorkspaceName}' workspace.....`)
29
+ terraformCloudConfig(options.$base, options.OrganizationName, options.WorkspaceName, options.TerraformRemoteHostname);
30
+ }
31
+
32
+ const pypi_cdktf = options.pypi_cdktf;
33
+ if (!pypi_cdktf) {
34
+ throw new Error(`missing context "pypi_cdktf"`);
35
+ }
36
+
37
+ writeFileSync('requirements.txt', pypi_cdktf + '\r\npytest\r\n', 'utf-8');
38
+
39
+ let installArgs = '';
40
+ if (!process.env.VIRTUAL_ENV) {
41
+ installArgs += '--user'
42
+ }
43
+ execSync(`pip3 install ${installArgs} -r requirements.txt`, { stdio: 'inherit' });
44
+ chmodSync('main.py', '700');
45
+
46
+ console.log(readFileSync('./help', 'utf-8'));
47
+ };
48
+
49
+ function terraformCloudConfig(baseName, organizationName, workspaceName, terraformRemoteHostname) {
50
+ template = readFileSync('./main.py', 'utf-8');
51
+
52
+ const templateWithImports = template.replace(`from cdktn import App, TerraformStack`,
53
+ `from cdktn import App, TerraformStack, CloudBackend, NamedCloudWorkspace`)
54
+
55
+ const result = templateWithImports.replace(`MyStack(app, "${baseName}")`, `stack = MyStack(app, "${baseName}")
56
+ CloudBackend(stack,
57
+ hostname='${terraformRemoteHostname}',
58
+ organization='${organizationName}',
59
+ workspaces=NamedCloudWorkspace('${workspaceName}')
60
+ )`);
61
+
62
+ writeFileSync('./main.py', result, 'utf-8');
63
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "language": "python",
3
+ "app": "python3 ./main.py",
4
+ "projectId": "{{projectId}}",
5
+ "sendCrashReports": "{{sendCrashReports}}",
6
+ "terraformProviders": [],
7
+ "terraformModules": [],
8
+ "codeMakerOutput": "imports",
9
+ "context": {
10
+ {{futureFlags}}
11
+ }
12
+ }
@@ -0,0 +1,35 @@
1
+ ========================================================================================================
2
+
3
+ Your cdktn Python project is ready!
4
+
5
+ cat help Prints this message
6
+
7
+ Compile:
8
+ python3 ./main.py Compile and run the python code.
9
+
10
+ Synthesize:
11
+ cdktn synth [stack] Synthesize Terraform resources to cdktf.out/
12
+
13
+ Diff:
14
+ cdktn diff [stack] Perform a diff (terraform plan) for the given stack
15
+
16
+ Deploy:
17
+ cdktn deploy [stack] Deploy the given stack
18
+
19
+ Destroy:
20
+ cdktn destroy [stack] Destroy the given stack
21
+
22
+ Learn more about using modules and providers https://cdk.tf/modules-and-providers
23
+
24
+ Use Providers:
25
+
26
+ Use the add command to add both prebuilt providers (if available) or locally generated providers:
27
+
28
+ cdktn provider add "aws@~>3.0" null kreuzwerker/docker
29
+
30
+ You can find all prebuilt providers on PyPI: https://pypi.org/user/cdktn-team/
31
+ You can also add these providers directly to your requirements.txt file.
32
+
33
+ You can also build any module or provider locally. Learn more: https://cdk.tf/modules-and-providers
34
+
35
+ ========================================================================================================
@@ -0,0 +1,23 @@
1
+ import pytest
2
+ from cdktn import Testing, TerraformStack
3
+
4
+ # The tests below are example tests, you can find more information at
5
+ # https://cdk.tf/testing
6
+
7
+
8
+ class TestMain:
9
+
10
+ stack = TerraformStack(Testing.app(), "stack")
11
+ #app_abstraction = MyApplicationsAbstraction(stack, "app-abstraction")
12
+ #synthesized = Testing.synth(stack)
13
+
14
+ # def test_should_contain_container(self):
15
+ # assert Testing.to_have_resource(self.synthesized, Container.TF_RESOURCE_TYPE)
16
+
17
+ # def test_should_use_an_ubuntu_image(self):
18
+ # assert Testing.to_have_resource_with_properties(self.synthesized, Image.TF_RESOURCE_TYPE, {
19
+ # "name": "ubuntu:latest",
20
+ # })
21
+
22
+ # def test_check_validity(self):
23
+ # assert Testing.to_be_valid_terraform(Testing.full_synth(stack))
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env python
2
+ from constructs import Construct
3
+ from cdktn import App, TerraformStack
4
+
5
+
6
+ class MyStack(TerraformStack):
7
+ def __init__(self, scope: Construct, id: str):
8
+ super().__init__(scope, id)
9
+
10
+ # define resources here
11
+
12
+
13
+ app = App()
14
+ MyStack(app, "{{ $base }}")
15
+
16
+ app.synth()
@@ -0,0 +1,7 @@
1
+ dist/
2
+ imports/*
3
+ !imports/__init__.py
4
+ .terraform
5
+ cdktf.out
6
+ cdktf.log
7
+ *terraform.*.tfstate*
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ const { execSync } = require("child_process");
7
+ const { readFileSync, writeFileSync } = require("fs");
8
+
9
+ exports.post = (ctx) => {
10
+ const silent = ctx.silent === "true" || ctx.silent === true;
11
+ // Terraform Cloud configuration settings if the organization name and workspace is set.
12
+ if (ctx.OrganizationName != "") {
13
+ if (!silent) {
14
+ console.log(
15
+ `\nGenerating Terraform Cloud configuration for '${ctx.OrganizationName}' organization and '${ctx.WorkspaceName}' workspace.....`
16
+ );
17
+ }
18
+ terraformCloudConfig(
19
+ ctx.$base,
20
+ ctx.OrganizationName,
21
+ ctx.WorkspaceName,
22
+ ctx.TerraformRemoteHostname
23
+ );
24
+ }
25
+
26
+ const npm_cdktf = ctx.npm_cdktf;
27
+ if (!npm_cdktf) {
28
+ throw new Error(`missing context "npm_cdktf"`);
29
+ }
30
+
31
+ installDeps([npm_cdktf, `constructs@10`], false, silent);
32
+ installDeps(
33
+ ["@types/node", "typescript", "jest", "@types/jest", "ts-jest", "ts-node"],
34
+ true,
35
+ silent
36
+ );
37
+
38
+ if (!silent) {
39
+ console.log(readFileSync("./help", "utf-8"));
40
+ }
41
+ };
42
+
43
+ function installDeps(deps, isDev, silent) {
44
+ const devDep = isDev ? "-D" : "";
45
+ // make sure we're installing dev dependencies as well
46
+ const env = Object.assign({}, process.env);
47
+ env["NODE_ENV"] = "development";
48
+
49
+ execSync(`npm install ${devDep} ${deps.join(" ")}`, {
50
+ stdio: silent ? "ignore" : "inherit",
51
+ env,
52
+ });
53
+ }
54
+
55
+ function terraformCloudConfig(
56
+ baseName,
57
+ organizationName,
58
+ workspaceName,
59
+ terraformRemoteHostname
60
+ ) {
61
+ template = readFileSync("./main.ts", "utf-8");
62
+
63
+ result = template.replace(
64
+ `import { App, TerraformStack } from "cdktn";`,
65
+ `import { App, TerraformStack, CloudBackend, NamedCloudWorkspace } from "cdktn";`
66
+ );
67
+ result = result.replace(
68
+ `new MyStack(app, "${baseName}");`,
69
+ `const stack = new MyStack(app, "${baseName}");
70
+ new CloudBackend(stack, {
71
+ hostname: "${terraformRemoteHostname}",
72
+ organization: "${organizationName}",
73
+ workspaces: new NamedCloudWorkspace("${workspaceName}")
74
+ });`
75
+ );
76
+
77
+ writeFileSync("./main.ts", result, "utf-8");
78
+ }
@@ -0,0 +1,89 @@
1
+ // Copyright (c) HashiCorp, Inc
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ import "cdktn/lib/testing/adapters/jest"; // Load types for expect matchers
4
+ // import { Testing } from "cdktn";
5
+
6
+ describe("My CDKTN Application", () => {
7
+ // The tests below are example tests, you can find more information at
8
+ // https://cdk.tf/testing
9
+ it.todo("should be tested");
10
+
11
+ // // All Unit tests test the synthesised terraform code, it does not create real-world resources
12
+ // describe("Unit testing using assertions", () => {
13
+ // it("should contain a resource", () => {
14
+ // // import { Image,Container } from "./.gen/providers/docker"
15
+ // expect(
16
+ // Testing.synthScope((scope) => {
17
+ // new MyApplicationsAbstraction(scope, "my-app", {});
18
+ // })
19
+ // ).toHaveResource(Container);
20
+
21
+ // expect(
22
+ // Testing.synthScope((scope) => {
23
+ // new MyApplicationsAbstraction(scope, "my-app", {});
24
+ // })
25
+ // ).toHaveResourceWithProperties(Image, { name: "ubuntu:latest" });
26
+ // });
27
+ // });
28
+
29
+ // describe("Unit testing using snapshots", () => {
30
+ // it("Tests the snapshot", () => {
31
+ // const app = Testing.app();
32
+ // const stack = new TerraformStack(app, "test");
33
+
34
+ // new TestProvider(stack, "provider", {
35
+ // accessKey: "1",
36
+ // });
37
+
38
+ // new TestResource(stack, "test", {
39
+ // name: "my-resource",
40
+ // });
41
+
42
+ // expect(Testing.synth(stack)).toMatchSnapshot();
43
+ // });
44
+
45
+ // it("Tests a combination of resources", () => {
46
+ // expect(
47
+ // Testing.synthScope((stack) => {
48
+ // new TestDataSource(stack, "test-data-source", {
49
+ // name: "foo",
50
+ // });
51
+
52
+ // new TestResource(stack, "test-resource", {
53
+ // name: "bar",
54
+ // });
55
+ // })
56
+ // ).toMatchInlineSnapshot();
57
+ // });
58
+ // });
59
+
60
+ // describe("Checking validity", () => {
61
+ // it("check if the produced terraform configuration is valid", () => {
62
+ // const app = Testing.app();
63
+ // const stack = new TerraformStack(app, "test");
64
+
65
+ // new TestDataSource(stack, "test-data-source", {
66
+ // name: "foo",
67
+ // });
68
+
69
+ // new TestResource(stack, "test-resource", {
70
+ // name: "bar",
71
+ // });
72
+ // expect(Testing.fullSynth(app)).toBeValidTerraform();
73
+ // });
74
+
75
+ // it("check if this can be planned", () => {
76
+ // const app = Testing.app();
77
+ // const stack = new TerraformStack(app, "test");
78
+
79
+ // new TestDataSource(stack, "test-data-source", {
80
+ // name: "foo",
81
+ // });
82
+
83
+ // new TestResource(stack, "test-resource", {
84
+ // name: "bar",
85
+ // });
86
+ // expect(Testing.fullSynth(app)).toPlanSuccessfully();
87
+ // });
88
+ // });
89
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "language": "typescript",
3
+ "app": "npx ts-node main.ts",
4
+ "projectId": "{{projectId}}",
5
+ "sendCrashReports": "{{sendCrashReports}}",
6
+ "terraformProviders": [],
7
+ "terraformModules": [],
8
+ "context": {
9
+ {{futureFlags}}
10
+ }
11
+ }
@@ -0,0 +1,51 @@
1
+ ========================================================================================================
2
+
3
+ Your CDKTN TypeScript project is ready!
4
+
5
+ cat help Print this message
6
+
7
+ Compile:
8
+ npm run get Import/update Terraform providers and modules (you should check-in this directory)
9
+ npm run compile Compile typescript code to javascript (or "npm run watch")
10
+ npm run watch Watch for changes and compile typescript in the background
11
+ npm run build Compile typescript
12
+
13
+ Synthesize:
14
+ cdktn synth [stack] Synthesize Terraform resources from stacks to cdktf.out/ (ready for 'terraform apply')
15
+
16
+ Diff:
17
+ cdktn diff [stack] Perform a diff (terraform plan) for the given stack
18
+
19
+ Deploy:
20
+ cdktn deploy [stack] Deploy the given stack
21
+
22
+ Destroy:
23
+ cdktn destroy [stack] Destroy the stack
24
+
25
+ Test:
26
+ npm run test Runs unit tests (edit __tests__/main-test.ts to add your own tests)
27
+ npm run test:watch Watches the tests and reruns them on change
28
+
29
+ Upgrades:
30
+ npm run upgrade Upgrade cdktn modules to latest version
31
+ npm run upgrade:next Upgrade cdktn modules to latest "@next" version (last commit)
32
+
33
+ Use Providers:
34
+
35
+ You can add prebuilt providers (if available) or locally generated ones using the add command:
36
+
37
+ cdktn provider add "aws@~>3.0" null kreuzwerker/docker
38
+
39
+ You can find all prebuilt providers on npm: https://www.npmjs.com/search?q=keywords:cdktf
40
+ You can also install these providers directly through npm:
41
+
42
+ npm install @cdktn/provider-aws
43
+ npm install @cdktn/provider-google
44
+ npm install @cdktn/provider-azurerm
45
+ npm install @cdktn/provider-docker
46
+ npm install @cdktn/provider-github
47
+ npm install @cdktn/provider-null
48
+
49
+ You can also build any module or provider locally. Learn more https://cdk.tf/modules-and-providers
50
+
51
+ ========================================================================================================
@@ -0,0 +1,187 @@
1
+ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2
+ /*
3
+ * For a detailed explanation regarding each configuration property, visit:
4
+ * https://jestjs.io/docs/configuration
5
+ */
6
+
7
+ module.exports = {
8
+
9
+ // All imported modules in your tests should be mocked automatically
10
+ // automock: false,
11
+
12
+ // Stop running tests after `n` failures
13
+ // bail: 0,
14
+
15
+ // The directory where Jest should store its cached dependency information
16
+ // cacheDirectory: "/private/var/folders/z_/v03l33d55fb57nrr3b1q03ch0000gq/T/jest_dz",
17
+
18
+ // Automatically clear mock calls and instances between every test
19
+ clearMocks: true,
20
+
21
+ // Indicates whether the coverage information should be collected while executing the test
22
+ // collectCoverage: false,
23
+
24
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
25
+ // collectCoverageFrom: undefined,
26
+
27
+ // The directory where Jest should output its coverage files
28
+ // coverageDirectory: undefined,
29
+
30
+ // An array of regexp pattern strings used to skip coverage collection
31
+ // coveragePathIgnorePatterns: [
32
+ // "/node_modules/"
33
+ // ],
34
+
35
+ // Indicates which provider should be used to instrument code for coverage
36
+ coverageProvider: "v8",
37
+
38
+ // A list of reporter names that Jest uses when writing coverage reports
39
+ // coverageReporters: [
40
+ // "json",
41
+ // "text",
42
+ // "lcov",
43
+ // "clover"
44
+ // ],
45
+
46
+ // An object that configures minimum threshold enforcement for coverage results
47
+ // coverageThreshold: undefined,
48
+
49
+ // A path to a custom dependency extractor
50
+ // dependencyExtractor: undefined,
51
+
52
+ // Make calling deprecated APIs throw helpful error messages
53
+ // errorOnDeprecated: false,
54
+
55
+ // Force coverage collection from ignored files using an array of glob patterns
56
+ // forceCoverageMatch: [],
57
+
58
+ // A path to a module which exports an async function that is triggered once before all test suites
59
+ // globalSetup: undefined,
60
+
61
+ // A path to a module which exports an async function that is triggered once after all test suites
62
+ // globalTeardown: undefined,
63
+
64
+ // A set of global variables that need to be available in all test environments
65
+ // globals: {},
66
+
67
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
68
+ // maxWorkers: "50%",
69
+
70
+ // An array of directory names to be searched recursively up from the requiring module's location
71
+ // moduleDirectories: [
72
+ // "node_modules"
73
+ // ],
74
+
75
+ // An array of file extensions your modules use
76
+ moduleFileExtensions: ["ts", "js", "json", "node"],
77
+
78
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
79
+ // moduleNameMapper: {},
80
+
81
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
82
+ // modulePathIgnorePatterns: [],
83
+
84
+ // Activates notifications for test results
85
+ // notify: false,
86
+
87
+ // An enum that specifies notification mode. Requires { notify: true }
88
+ // notifyMode: "failure-change",
89
+
90
+ // A preset that is used as a base for Jest's configuration
91
+ preset: "ts-jest",
92
+
93
+ // Run tests from one or more projects
94
+ // projects: undefined,
95
+
96
+ // Use this configuration option to add custom reporters to Jest
97
+ // reporters: undefined,
98
+
99
+ // Automatically reset mock state between every test
100
+ // resetMocks: false,
101
+
102
+ // Reset the module registry before running each individual test
103
+ // resetModules: false,
104
+
105
+ // A path to a custom resolver
106
+ // resolver: undefined,
107
+
108
+ // Automatically restore mock state between every test
109
+ // restoreMocks: false,
110
+
111
+ // The root directory that Jest should scan for tests and modules within
112
+ // rootDir: undefined,
113
+
114
+ // A list of paths to directories that Jest should use to search for files in
115
+ // roots: [
116
+ // "<rootDir>"
117
+ // ],
118
+
119
+ // Allows you to use a custom runner instead of Jest's default test runner
120
+ // runner: "jest-runner",
121
+
122
+ // The paths to modules that run some code to configure or set up the testing environment before each test
123
+ // setupFiles: [],
124
+
125
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
126
+ setupFilesAfterEnv: ["<rootDir>/setup.js"],
127
+
128
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
129
+ // slowTestThreshold: 5,
130
+
131
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
132
+ // snapshotSerializers: [],
133
+
134
+ // The test environment that will be used for testing
135
+ testEnvironment: "node",
136
+
137
+ // Options that will be passed to the testEnvironment
138
+ // testEnvironmentOptions: {},
139
+
140
+ // Adds a location field to test results
141
+ // testLocationInResults: false,
142
+
143
+ // The glob patterns Jest uses to detect test files
144
+ testMatch: [
145
+ "**/__tests__/**/*.ts",
146
+ "**/?(*.)+(spec|test).ts"
147
+ ],
148
+
149
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
150
+ testPathIgnorePatterns: ["/node_modules/", ".d.ts", ".js"],
151
+
152
+ // The regexp pattern or array of patterns that Jest uses to detect test files
153
+ // testRegex: [],
154
+
155
+ // This option allows the use of a custom results processor
156
+ // testResultsProcessor: undefined,
157
+
158
+ // This option allows use of a custom test runner
159
+ // testRunner: "jest-circus/runner",
160
+
161
+ // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
162
+ // testURL: "http://localhost",
163
+
164
+ // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
165
+ // timers: "real",
166
+
167
+ // A map from regular expressions to paths to transformers
168
+ // transform: undefined,
169
+
170
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
171
+ // transformIgnorePatterns: [
172
+ // "/node_modules/",
173
+ // "\\.pnp\\.[^\\/]+$"
174
+ // ],
175
+
176
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
177
+ // unmockedModulePathPatterns: undefined,
178
+
179
+ // Indicates whether each individual test should be reported during the run
180
+ // verbose: undefined,
181
+
182
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
183
+ // watchPathIgnorePatterns: [],
184
+
185
+ // Whether to use watchman for file crawling
186
+ // watchman: true,
187
+ };
@@ -0,0 +1,14 @@
1
+ import { Construct } from "constructs";
2
+ import { App, TerraformStack } from "cdktn";
3
+
4
+ class MyStack extends TerraformStack {
5
+ constructor(scope: Construct, id: string) {
6
+ super(scope, id);
7
+
8
+ // define resources here
9
+ }
10
+ }
11
+
12
+ const app = new App();
13
+ new MyStack(app, "{{ $base }}");
14
+ app.synth();
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "{{ $base }}",
3
+ "version": "1.0.0",
4
+ "main": "main.js",
5
+ "types": "main.ts",
6
+ "license": "MPL-2.0",
7
+ "private": true,
8
+ "scripts": {
9
+ "get": "cdktn get",
10
+ "build": "tsc",
11
+ "synth": "cdktn synth",
12
+ "compile": "tsc --pretty",
13
+ "watch": "tsc -w",
14
+ "test": "jest",
15
+ "test:watch": "jest --watch",
16
+ "upgrade": "npm i cdktn@latest cdktn-cli@latest",
17
+ "upgrade:next": "npm i cdktn@next cdktn-cli@next"
18
+ },
19
+ "engines": {
20
+ "node": ">=20.9"
21
+ }
22
+ }
@@ -0,0 +1,2 @@
1
+ const cdktn = require("cdktn");
2
+ cdktn.Testing.setupJest();
@@ -0,0 +1,35 @@
1
+ {
2
+ "compilerOptions": {
3
+ "alwaysStrict": true,
4
+ "declaration": true,
5
+ "experimentalDecorators": true,
6
+ "inlineSourceMap": true,
7
+ "inlineSources": true,
8
+ "lib": [
9
+ "es2018"
10
+ ],
11
+ "module": "CommonJS",
12
+ "noEmitOnError": true,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "noImplicitAny": true,
15
+ "noImplicitReturns": true,
16
+ "noImplicitThis": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "resolveJsonModule": true,
20
+ "strict": true,
21
+ "strictNullChecks": true,
22
+ "strictPropertyInitialization": true,
23
+ "stripInternal": true,
24
+ "target": "ES2018",
25
+ "incremental": true,
26
+ "skipLibCheck": true
27
+ },
28
+ "include": [
29
+ "**/*.ts"
30
+ ],
31
+ "exclude": [
32
+ "node_modules",
33
+ "cdktf.out"
34
+ ]
35
+ }
@@ -0,0 +1,11 @@
1
+ *.d.ts
2
+ *.js
3
+ node_modules
4
+ cdktf.out
5
+ cdktf.log
6
+ *terraform.*.tfstate*
7
+ .gen
8
+ .terraform
9
+ tsconfig.tsbuildinfo
10
+ !jest.config.js
11
+ !setup.js