cdk-from-cfn 0.270.0 → 0.271.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.
- package/README.md +28 -3
- package/index.d.ts +1 -1
- package/index.js +20 -13
- package/index_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,11 +11,29 @@ cargo install cdk-from-cfn
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```console
|
|
14
|
-
cdk-from-cfn [INPUT] [OUTPUT] --language <LANGUAGE> --stack-name <STACK_NAME>
|
|
14
|
+
cdk-from-cfn [INPUT] [OUTPUT] --language <LANGUAGE> --stack-name <STACK_NAME> [--as <stack|construct>]
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
- `INPUT` is the input file path (STDIN by default).
|
|
18
18
|
- `OUTPUT` is the output file path; if not specified, output will be printed on your command line (STDOUT by default).
|
|
19
|
+
- `--as` (optional) specifies the output type: `stack` (default) or `construct`. Use `construct` to generate a reusable CDK construct instead of a standalone stack.
|
|
20
|
+
|
|
21
|
+
### Class Type Option
|
|
22
|
+
|
|
23
|
+
By default, cdk-from-cfn generates code that extends `Stack`. You can use the `--as` flag to generate a reusable `Construct` instead:
|
|
24
|
+
|
|
25
|
+
```console
|
|
26
|
+
# Generate a Stack (default)
|
|
27
|
+
cdk-from-cfn template.json --language typescript --as stack
|
|
28
|
+
|
|
29
|
+
# Generate a Construct
|
|
30
|
+
cdk-from-cfn template.json --language typescript --as construct
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
When using `construct` mode:
|
|
34
|
+
- The generated class extends `Construct` instead of `Stack`
|
|
35
|
+
- Props interface does not extend `StackProps`
|
|
36
|
+
- Pseudo-parameters like `AWS::StackName` use `Stack.of(this)` to access the parent stack
|
|
19
37
|
|
|
20
38
|
## Node.js Module Usage
|
|
21
39
|
|
|
@@ -27,10 +45,17 @@ import * as cdk_from_cfn from 'cdk-from-cfn';
|
|
|
27
45
|
// get supported languages
|
|
28
46
|
cdk_from_cfn.supported_languages();
|
|
29
47
|
|
|
30
|
-
// transmute cfn template into cdk app
|
|
31
|
-
cdk_from_cfn.transmute(template, language, stackName)
|
|
48
|
+
// transmute cfn template into cdk app (generates a Stack by default)
|
|
49
|
+
cdk_from_cfn.transmute(template, language, stackName);
|
|
50
|
+
|
|
51
|
+
// transmute cfn template into a reusable Construct
|
|
52
|
+
cdk_from_cfn.transmute(template, language, stackName, 'construct');
|
|
32
53
|
```
|
|
33
54
|
|
|
55
|
+
The `transmute` function accepts an optional fourth parameter `classType`:
|
|
56
|
+
- `'stack'` (default): generates code extending `Stack`
|
|
57
|
+
- `'construct'`: generates code extending `Construct`
|
|
58
|
+
|
|
34
59
|
## Language and Feature support
|
|
35
60
|
|
|
36
61
|
| Name | Enabled by default | Description |
|
package/index.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export function supported_languages(): any[];
|
|
|
10
10
|
* Transforms the provided template into a CDK application in the specified
|
|
11
11
|
* language.
|
|
12
12
|
*/
|
|
13
|
-
export function transmute(template: string, language: string,
|
|
13
|
+
export function transmute(template: string, language: string, class_name: string, class_type?: string | null): string;
|
|
14
14
|
|
|
15
15
|
export function wasm_init(): void;
|
package/index.js
CHANGED
|
@@ -34,6 +34,10 @@ function getUint8ArrayMemory0() {
|
|
|
34
34
|
return cachedUint8ArrayMemory0;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
function isLikeNone(x) {
|
|
38
|
+
return x === undefined || x === null;
|
|
39
|
+
}
|
|
40
|
+
|
|
37
41
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
38
42
|
if (realloc === undefined) {
|
|
39
43
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -115,31 +119,34 @@ exports.supported_languages = supported_languages;
|
|
|
115
119
|
* language.
|
|
116
120
|
* @param {string} template
|
|
117
121
|
* @param {string} language
|
|
118
|
-
* @param {string}
|
|
122
|
+
* @param {string} class_name
|
|
123
|
+
* @param {string | null} [class_type]
|
|
119
124
|
* @returns {string}
|
|
120
125
|
*/
|
|
121
|
-
function transmute(template, language,
|
|
122
|
-
let
|
|
123
|
-
let
|
|
126
|
+
function transmute(template, language, class_name, class_type) {
|
|
127
|
+
let deferred6_0;
|
|
128
|
+
let deferred6_1;
|
|
124
129
|
try {
|
|
125
130
|
const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
126
131
|
const len0 = WASM_VECTOR_LEN;
|
|
127
132
|
const ptr1 = passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
128
133
|
const len1 = WASM_VECTOR_LEN;
|
|
129
|
-
const ptr2 = passStringToWasm0(
|
|
134
|
+
const ptr2 = passStringToWasm0(class_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
135
|
const len2 = WASM_VECTOR_LEN;
|
|
131
|
-
|
|
132
|
-
var
|
|
133
|
-
|
|
136
|
+
var ptr3 = isLikeNone(class_type) ? 0 : passStringToWasm0(class_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
137
|
+
var len3 = WASM_VECTOR_LEN;
|
|
138
|
+
const ret = wasm.transmute(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
139
|
+
var ptr5 = ret[0];
|
|
140
|
+
var len5 = ret[1];
|
|
134
141
|
if (ret[3]) {
|
|
135
|
-
|
|
142
|
+
ptr5 = 0; len5 = 0;
|
|
136
143
|
throw takeFromExternrefTable0(ret[2]);
|
|
137
144
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return getStringFromWasm0(
|
|
145
|
+
deferred6_0 = ptr5;
|
|
146
|
+
deferred6_1 = len5;
|
|
147
|
+
return getStringFromWasm0(ptr5, len5);
|
|
141
148
|
} finally {
|
|
142
|
-
wasm.__wbindgen_free(
|
|
149
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
exports.transmute = transmute;
|
package/index_bg.wasm
CHANGED
|
Binary file
|