Skip to content

Commit

Permalink
Merge pull request #1732 from hashicorp/fix-templates
Browse files Browse the repository at this point in the history
fix(cli): fix templates to properly indent cdktf.json and add RemoteBackend in TS template
  • Loading branch information
ansgarm authored Apr 20, 2022
2 parents 8768077 + cdc54c0 commit cbd5215
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/cdktf-cli/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function init({
const deps: any = await determineDeps(cdktfVersion, dist);

const futureFlags = Object.entries(FUTURE_FLAGS)
.map(([key, value]) => `"${key}": "${value}"`)
.map(([key, value]) => ` "${key}": "${value}"`)
.join(`,\n`);

await sscaff(templatePath, destination, {
Expand Down
18 changes: 9 additions & 9 deletions packages/cdktf-cli/templates/csharp/cdktf.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"language": "csharp",
"app": "dotnet run -p MyTerraformStack.csproj",
"projectId": "{{projectId}}",
"terraformProviders": [],
"terraformModules": [],
"context": {
{{futureFlags}}
}
}
"language": "csharp",
"app": "dotnet run -p MyTerraformStack.csproj",
"projectId": "{{projectId}}",
"terraformProviders": [],
"terraformModules": [],
"context": {
{{futureFlags}}
}
}
20 changes: 10 additions & 10 deletions packages/cdktf-cli/templates/go/cdktf.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"language": "go",
"app": "go run main.go",
"codeMakerOutput": "generated",
"projectId": "{{projectId}}",
"terraformProviders": [],
"terraformModules": [],
"context": {
{{futureFlags}}
}
}
"language": "go",
"app": "go run main.go",
"codeMakerOutput": "generated",
"projectId": "{{projectId}}",
"terraformProviders": [],
"terraformModules": [],
"context": {
{{futureFlags}}
}
}
4 changes: 2 additions & 2 deletions packages/cdktf-cli/templates/java/cdktf.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"terraformProviders": [],
"terraformModules": [],
"context": {
{{futureFlags}}
{{futureFlags}}
}
}
}
2 changes: 1 addition & 1 deletion packages/cdktf-cli/templates/python-pip/cdktf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"terraformModules": [],
"codeMakerOutput": "imports",
"context": {
{{futureFlags}}
{{futureFlags}}
}
}
4 changes: 2 additions & 2 deletions packages/cdktf-cli/templates/python/cdktf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"terraformModules": [],
"codeMakerOutput": "imports",
"context": {
{{futureFlags}}
{{futureFlags}}
}
}
}
10 changes: 5 additions & 5 deletions packages/cdktf-cli/templates/typescript/.hooks.sscaff.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ function installDeps(deps, isDev) {
function terraformCloudConfig(baseName, organizationName, workspaceName) {
template = readFileSync('./main.ts', 'utf-8');

result = template.replace(`import { App, TerraformStack } from 'cdktf';`, `import { App, TerraformStack, RemoteBackend } from 'cdktf';`);
result = result.replace(`new MyStack(app, '${baseName}');`, `const stack = new MyStack(app, '${baseName}');
result = template.replace(`import { App, TerraformStack } from "cdktf";`, `import { App, TerraformStack, RemoteBackend } from "cdktf";`);
result = result.replace(`new MyStack(app, "${baseName}");`, `const stack = new MyStack(app, "${baseName}");
new RemoteBackend(stack, {
hostname: 'app.terraform.io',
organization: '${organizationName}',
hostname: "app.terraform.io",
organization: "${organizationName}",
workspaces: {
name: '${workspaceName}'
name: "${workspaceName}"
}
});`);

Expand Down
4 changes: 2 additions & 2 deletions packages/cdktf-cli/templates/typescript/cdktf.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"terraformProviders": [],
"terraformModules": [],
"context": {
{{futureFlags}}
{{futureFlags}}
}
}
}

0 comments on commit cbd5215

Please sign in to comment.