projen-cdktf-hybrid-construct 0.1.49 → 0.1.52
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.
- package/.projenrc.ts +1 -1
- package/README.md +102 -5
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/publishing.d.ts +13 -0
- package/lib/publishing.js +35 -0
- package/package.json +3 -1
package/.projenrc.ts
CHANGED
@@ -13,7 +13,7 @@ const project = new typescript.TypeScriptProject({
|
|
13
13
|
license: "MIT",
|
14
14
|
copyrightOwner: "Daniel Schmidt",
|
15
15
|
|
16
|
-
deps: ["projen", "@types/uuid", "uuid"],
|
16
|
+
deps: ["projen", "@types/uuid", "uuid", "@types/change-case", "change-case"],
|
17
17
|
devDeps: ["fs-extra", "glob", "@types/fs-extra", "@types/glob"],
|
18
18
|
|
19
19
|
release: true,
|
package/README.md
CHANGED
@@ -21,7 +21,6 @@ If you want to write a CDKTF construct and also publish it as a Terraform Module
|
|
21
21
|
const { HybridModule } = require("projen-cdktf-hybrid-construct");
|
22
22
|
|
23
23
|
const project = new HybridModule({
|
24
|
-
defaultReleaseBranch: "main",
|
25
24
|
// The name of the module & repository need to start with terraform-cdk-
|
26
25
|
name: "terraform-cdk-my-new-hybrid-construct",
|
27
26
|
repositoryUrl:
|
@@ -68,7 +67,7 @@ project.synth();
|
|
68
67
|
If you want to republish an existing Terraform module as a CDKTF construct or if you want to repackage them with an easier to use API you can use the `TerraformModule` template.
|
69
68
|
|
70
69
|
```js
|
71
|
-
const {
|
70
|
+
const { TerraformModule } = require("projen-cdktf-hybrid-construct");
|
72
71
|
|
73
72
|
const project = new TerraformModule({
|
74
73
|
name: "my-module",
|
@@ -93,6 +92,106 @@ const project = new TerraformModule({
|
|
93
92
|
project.synth();
|
94
93
|
```
|
95
94
|
|
95
|
+
## Publishing
|
96
|
+
|
97
|
+
### Open Source
|
98
|
+
|
99
|
+
We have a helper method for easy configuration, but there are still some manual steps required.
|
100
|
+
|
101
|
+
```js
|
102
|
+
const {
|
103
|
+
HybridModule,
|
104
|
+
publishToRegistries,
|
105
|
+
} = require("projen-cdktf-hybrid-construct");
|
106
|
+
|
107
|
+
const project = new HybridModule({
|
108
|
+
// ... all the other options
|
109
|
+
...publishToRegistries({
|
110
|
+
name: "my-new-hybrid-construct",
|
111
|
+
namespace: "my-org",
|
112
|
+
registries: ["npm", "pypi", "nuget", "maven"],
|
113
|
+
}),
|
114
|
+
});
|
115
|
+
```
|
116
|
+
|
117
|
+
#### Terraform
|
118
|
+
|
119
|
+
1. [Sign in at the registry](https://registry.terraform.io/sign-in)
|
120
|
+
2. [Select your repository](https://registry.terraform.io/github/create) and create the module
|
121
|
+
|
122
|
+
Please make sure your repository name starts with `terraform-cdk-`.
|
123
|
+
|
124
|
+
#### npm (Typescript)
|
125
|
+
|
126
|
+
1. Create an account at [npmjs.com](https://npmjs.com/)
|
127
|
+
2. Create an [automation token](https://docs.npmjs.com/creating-and-viewing-access-tokens) on npm
|
128
|
+
3. Create a [GitHub Action Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with the name `NPM_TOKEN` and the value of the token
|
129
|
+
|
130
|
+
#### pypi (Python)
|
131
|
+
|
132
|
+
1. Create an account at [pypi.org](https://pypi.org/)
|
133
|
+
2. Create an [API token](https://pypi.org/help/#apitoken) on pypi
|
134
|
+
3. Create a [GitHub Action Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with the name `TWINE_USERNAME` and the value `__token__` and a second one with the name `TWINE_PASSWORD` and the value of the token
|
135
|
+
4. Set the `publishToPypi` section in the options of `HybridModule` or `TerraformModule` (or use the helper mentioned above)
|
136
|
+
|
137
|
+
```js
|
138
|
+
const name = "name-of-my-hybrid-construct";
|
139
|
+
new HybridModule({
|
140
|
+
name,
|
141
|
+
// ... other options
|
142
|
+
publishToPypi: {
|
143
|
+
distName: name,
|
144
|
+
module: name.replace(/-/g, "_"),
|
145
|
+
},
|
146
|
+
});
|
147
|
+
```
|
148
|
+
|
149
|
+
#### Maven (Java)
|
150
|
+
|
151
|
+
1. [Create a Sonatype account and repository](https://central.sonatype.org/publish/publish-guide/#introduction)
|
152
|
+
2. Create [GitHub Action Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) to configure maven:
|
153
|
+
- `MAVEN_USERNAME`
|
154
|
+
- `MAVEN_PASSWORD`
|
155
|
+
- `MAVEN_STAGING_PROFILE_ID`
|
156
|
+
- `MAVEN_GPG_PRIVATE_KEY_PASSPHRASE`
|
157
|
+
- `MAVEN_GPG_PRIVATE_KEY_PASSPHRASE`
|
158
|
+
3. Setup the `publishToMaven` section in the options of `HybridModule` or `TerraformModule` (or use the helper mentioned above)
|
159
|
+
|
160
|
+
```js
|
161
|
+
const githubNamespace = "my-org";
|
162
|
+
const name = "name-of-my-hybrid-construct";
|
163
|
+
new HybridModule({
|
164
|
+
name,
|
165
|
+
// ... other options
|
166
|
+
publishToMaven: {
|
167
|
+
javaPackage: name.replace(/-/g, "_"),
|
168
|
+
mavenGroupId: `com.${githubNamespace}`,
|
169
|
+
mavenArtifactId: name,
|
170
|
+
},
|
171
|
+
});
|
172
|
+
```
|
173
|
+
|
174
|
+
#### NuGet (C#)
|
175
|
+
|
176
|
+
1. [Create a NuGet account](https://www.nuget.org/users/account/LogOn) (you might need to create a Microsoft Account if you don't have one)
|
177
|
+
2. [Create API keys](https://docs.microsoft.com/en-us/nuget/nuget-org/publish-a-package#create-api-keys)
|
178
|
+
3. Create a [GitHub Action Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with the name `NUGET_API_KEY` and the value of the token
|
179
|
+
4. Setup the `publishToNuget` section in the options of `HybridModule` or `TerraformModule` (or use the helper mentioned above)
|
180
|
+
|
181
|
+
```js
|
182
|
+
const githubNamespace = "my-org";
|
183
|
+
const name = "name-of-my-hybrid-construct";
|
184
|
+
|
185
|
+
new HybridModule({
|
186
|
+
name,
|
187
|
+
// ... other options
|
188
|
+
publishToNuget: {
|
189
|
+
dotNetNamespace: `MyOrg.NameOfMyHybridConstruct`,
|
190
|
+
packageId: `MyOrg.NameOfMyHybridConstruct`,
|
191
|
+
},
|
192
|
+
});
|
193
|
+
```
|
194
|
+
|
96
195
|
### Roadmap
|
97
196
|
|
98
197
|
- [x] Add dedicated file for HCL templates
|
@@ -101,8 +200,6 @@ project.synth();
|
|
101
200
|
- [x] [Auto-generate parts of the docs](https://github.com/terraform-aws-modules/terraform-aws-eks/blob/e90c877a741ab3cc4215376a70f7bcc360b6a3d2/.github/workflows/pre-commit.yml)
|
102
201
|
- [x] Add example folder to project using this
|
103
202
|
- [x] Add testing strategy
|
203
|
+
- [x] Add construct / option / docs to publish existing module as construct
|
104
204
|
- [ ] Add deployment scripts to Artifactory
|
105
205
|
- [ ] Add deployment scripts to Github Packages
|
106
|
-
- [x] Add construct / option / docs to publish existing module as construct
|
107
|
-
- [ ] Add construct for managing multiple repos like this
|
108
|
-
- [ ] Add option to manager projen template to bootstrap cdktf app that deploys Artifactory?
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./hybrid-module"), exports);
|
18
18
|
__exportStar(require("./terraform-module"), exports);
|
19
|
-
|
19
|
+
__exportStar(require("./publishing"), exports);
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLGtEQUFnQztBQUNoQyxxREFBbUM7QUFDbkMsK0NBQTZCIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSBcIi4vaHlicmlkLW1vZHVsZVwiO1xuZXhwb3J0ICogZnJvbSBcIi4vdGVycmFmb3JtLW1vZHVsZVwiO1xuZXhwb3J0ICogZnJvbSBcIi4vcHVibGlzaGluZ1wiO1xuIl19
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { ConstructLibraryOptions } from "projen/lib/cdk";
|
2
|
+
export declare type Registry = "npm" | "maven" | "nuget" | "pypi";
|
3
|
+
export declare type PublishOptions = {
|
4
|
+
name: string;
|
5
|
+
namespace: string;
|
6
|
+
registries: Registry[];
|
7
|
+
};
|
8
|
+
declare type Mutable<T> = {
|
9
|
+
-readonly [k in keyof T]: T[k];
|
10
|
+
};
|
11
|
+
declare type Config = Mutable<Pick<ConstructLibraryOptions, "publishToPypi" | "publishToMaven" | "publishToNuget" | "releaseToNpm">>;
|
12
|
+
export declare function publishToRegistries(options: PublishOptions): Config;
|
13
|
+
export {};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.publishToRegistries = void 0;
|
4
|
+
const change_case_1 = require("change-case");
|
5
|
+
function publishToRegistries(options) {
|
6
|
+
const { name, namespace, registries } = options;
|
7
|
+
const sanitizedNamespace = namespace.replace(/-/gi, "_");
|
8
|
+
const sanitizedName = name.replace(/-/gi, "_");
|
9
|
+
const config = {
|
10
|
+
releaseToNpm: registries.includes("npm"),
|
11
|
+
};
|
12
|
+
if (registries.includes("pypi")) {
|
13
|
+
config.publishToPypi = {
|
14
|
+
distName: `${sanitizedNamespace}-${sanitizedName}`,
|
15
|
+
module: `${sanitizedNamespace}_${sanitizedName}`,
|
16
|
+
};
|
17
|
+
}
|
18
|
+
if (registries.includes("maven")) {
|
19
|
+
config.publishToMaven = {
|
20
|
+
javaPackage: `com.${sanitizedNamespace}.${sanitizedName}`,
|
21
|
+
mavenGroupId: `com.${sanitizedNamespace}`,
|
22
|
+
mavenArtifactId: sanitizedName,
|
23
|
+
};
|
24
|
+
}
|
25
|
+
if (registries.includes("nuget")) {
|
26
|
+
const nugetName = `${(0, change_case_1.pascalCase)(namespace)}.${(0, change_case_1.pascalCase)(name)}`;
|
27
|
+
config.publishToNuget = {
|
28
|
+
dotNetNamespace: nugetName,
|
29
|
+
packageId: nugetName,
|
30
|
+
};
|
31
|
+
}
|
32
|
+
return config;
|
33
|
+
}
|
34
|
+
exports.publishToRegistries = publishToRegistries;
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGlzaGluZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9wdWJsaXNoaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDZDQUF5QztBQXFCekMsU0FBZ0IsbUJBQW1CLENBQUMsT0FBdUI7SUFDekQsTUFBTSxFQUFFLElBQUksRUFBRSxTQUFTLEVBQUUsVUFBVSxFQUFFLEdBQUcsT0FBTyxDQUFDO0lBQ2hELE1BQU0sa0JBQWtCLEdBQUcsU0FBUyxDQUFDLE9BQU8sQ0FBQyxLQUFLLEVBQUUsR0FBRyxDQUFDLENBQUM7SUFDekQsTUFBTSxhQUFhLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLEVBQUUsR0FBRyxDQUFDLENBQUM7SUFDL0MsTUFBTSxNQUFNLEdBQVc7UUFDckIsWUFBWSxFQUFFLFVBQVUsQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDO0tBQ3pDLENBQUM7SUFFRixJQUFJLFVBQVUsQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLEVBQUU7UUFDL0IsTUFBTSxDQUFDLGFBQWEsR0FBRztZQUNyQixRQUFRLEVBQUUsR0FBRyxrQkFBa0IsSUFBSSxhQUFhLEVBQUU7WUFDbEQsTUFBTSxFQUFFLEdBQUcsa0JBQ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Fja2FnZTogYGNvbS4ke3Nhbml0aXplZE5hbWVzcGFjZX0uJHtzYW5pdGl6ZWROYW1lfWAsXG4gICAgICBtYXZlbkdyb3VwSWQ6IGBjb20uJHtzYW5pdGl6ZWROYW1lc3BhY2V9YCxcbiAgICAgIG1hdmVuQXJ0aWZhY3RJZDogc2FuaXRpemVkTmFtZSxcbiAgICB9O1xuICB9XG4gIGlmIChyZWdpc3RyaWVzLmluY2x1ZGVzKFwibnVnZXRcIikpIHtcbiAgICBjb25zdCBudWdldE5hbWUgPSBgJHtwYXNjYWxDYXNlKG5hbWVzcGFjZSl9LiR7cGFzY2FsQ2FzZShuYW1lKX1gO1xuICAgIGNvbmZpZy5wdWJsaXNoVG9OdWdldCA9IHtcbiAgICAgIGRvdE5ldE5hbWVzcGFjZTogbnVnZXROYW1lLFxuICAgICAgcGFja2FnZUlkOiBudWdldE5hbWUsXG4gICAgfTtcbiAgfVxuICByZXR1cm4gY29uZmlnO1xufVxuIl19
|
package/package.json
CHANGED
@@ -53,13 +53,15 @@
|
|
53
53
|
"typescript": "^4.6.4"
|
54
54
|
},
|
55
55
|
"dependencies": {
|
56
|
+
"@types/change-case": "^2.3.1",
|
56
57
|
"@types/uuid": "^8.3.4",
|
58
|
+
"change-case": "^4.1.2",
|
57
59
|
"projen": "^0.53.6",
|
58
60
|
"uuid": "^8.3.2"
|
59
61
|
},
|
60
62
|
"main": "lib/index.js",
|
61
63
|
"license": "MIT",
|
62
|
-
"version": "0.1.
|
64
|
+
"version": "0.1.52",
|
63
65
|
"jest": {
|
64
66
|
"testMatch": [
|
65
67
|
"<rootDir>/src/**/__tests__/**/*.ts?(x)",
|