Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added underlying terraform provider version to readme #342

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/cdktf-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export class CdktfConfig {
},
});

new ReadmeFile(project, "README.md", options);
new ReadmeFile(project, "README.md", {
...options,
underlyingTerraformVersion: actualProviderVersion,
});
}
}
52 changes: 42 additions & 10 deletions src/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ReadmeFileOptions extends FileBaseOptions {
fqproviderName: string;
providerVersion: string;
packageInfo: PackageInfo;
underlyingTerraformVersion: string;
}

export class ReadmeFile extends FileBase {
Expand All @@ -22,8 +23,13 @@ export class ReadmeFile extends FileBase {
}

protected synthesizeContent(resolver: IResolver) {
const { providerName, fqproviderName, providerVersion, packageInfo } =
resolver.resolve(this.options) as ReadmeFileOptions;
const {
providerName,
fqproviderName,
providerVersion,
packageInfo,
underlyingTerraformVersion,
} = resolver.resolve(this.options) as ReadmeFileOptions;

const fqpnURL = fqproviderName.includes("/")
? fqproviderName
Expand All @@ -33,33 +39,51 @@ export class ReadmeFile extends FileBase {
: "";

return `
# Terraform CDK ${providerName} Provider ${providerVersion}
# Terraform CDK ${providerName} Provider tracks ${providerVersion}

This repo builds and publishes the Terraform ${providerName} Provider bindings for [CDK for Terraform](https://cdk.tf).

${
underlyingTerraformVersion !== "<unknown>"
? `Is based directly on ${providerName} ${underlyingTerraformVersion}`
: ""
}

## Available Packages

### NPM

The npm package is available at [https://www.npmjs.com/package/${packageInfo.npm.name}](https://www.npmjs.com/package/${packageInfo.npm.name}).
The npm package is available at [https://www.npmjs.com/package/${
packageInfo.npm.name
}](https://www.npmjs.com/package/${packageInfo.npm.name}).

\`npm install ${packageInfo.npm.name}\`

### PyPI

The PyPI package is available at [https://pypi.org/project/${packageInfo.python.distName}](https://pypi.org/project/${packageInfo.python.distName}).
The PyPI package is available at [https://pypi.org/project/${
packageInfo.python.distName
}](https://pypi.org/project/${packageInfo.python.distName}).

\`pipenv install ${packageInfo.python.distName}\`

### Nuget

The Nuget package is available at [https://www.nuget.org/packages/${packageInfo.publishToNuget.packageId}](https://www.nuget.org/packages/${packageInfo.publishToNuget.packageId}).
The Nuget package is available at [https://www.nuget.org/packages/${
packageInfo.publishToNuget.packageId
}](https://www.nuget.org/packages/${packageInfo.publishToNuget.packageId}).

\`dotnet add package ${packageInfo.publishToNuget.packageId}\`

### Maven

The Maven package is available at [https://mvnrepository.com/artifact/${packageInfo.publishToMaven.mavenGroupId}/${packageInfo.publishToMaven.mavenArtifactId}](https://mvnrepository.com/artifact/${packageInfo.publishToMaven.mavenGroupId}/${packageInfo.publishToMaven.mavenArtifactId}).
The Maven package is available at [https://mvnrepository.com/artifact/${
packageInfo.publishToMaven.mavenGroupId
}/${
packageInfo.publishToMaven.mavenArtifactId
}](https://mvnrepository.com/artifact/${
packageInfo.publishToMaven.mavenGroupId
}/${packageInfo.publishToMaven.mavenArtifactId}).

\`\`\`
<dependency>
Expand All @@ -72,9 +96,13 @@ The Maven package is available at [https://mvnrepository.com/artifact/${packageI

### Go

The go package is generated into the [\`${packageInfo.publishToGo?.moduleName}\`](https://${packageInfo.publishToGo?.moduleName}) package.
The go package is generated into the [\`${
packageInfo.publishToGo?.moduleName
}\`](https://${packageInfo.publishToGo?.moduleName}) package.

\`go get ${packageInfo.publishToGo?.moduleName}/${packageInfo.publishToGo?.packageName}\`
\`go get ${packageInfo.publishToGo?.moduleName}/${
packageInfo.publishToGo?.packageName
}\`

## Docs

Expand All @@ -95,7 +123,11 @@ This project is explicitly not tracking the Terraform ${providerName} Provider v
These are the upstream dependencies:

- [Terraform CDK](https://cdk.tf)
- [Terraform ${providerName} Provider](https://registry.terraform.io/providers/${fqpnURL}/${versionURL})
- [Terraform ${providerName} Provider](https://registry.terraform.io/providers/${fqpnURL}/${
underlyingTerraformVersion !== "<unknown>"
? underlyingTerraformVersion
: versionURL
})
- This links to the minimum version being tracked, you can find the latest released version [in our releases](https://github.com/cdktf/cdktf-provider-${providerName}/releases)
- [Terraform Engine](https://terraform.io)

Expand Down
12 changes: 9 additions & 3 deletions test/__snapshots__/index.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.