cdk-from-cfn 0.3.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 +72 -0
- package/index.d.ts +16 -0
- package/index.js +209 -0
- package/index_bg.wasm +0 -0
- package/package.json +18 -0
package/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# cdk_from_cfn
|
2
|
+
|
3
|
+
In a world where people want to use the full extent of the cdk, there **was** no product that would transform all your
|
4
|
+
JSON/YAML into beautiful typescript...until now.
|
5
|
+
|
6
|
+
cdk_from_cfn will take your JSON/YAML and output the equivalent typescript.
|
7
|
+
|
8
|
+
## User Guide
|
9
|
+
|
10
|
+
```console
|
11
|
+
$ cargo build --release
|
12
|
+
$ ./target/release/cdk_from_cfn [INPUT] [OUTPUT]
|
13
|
+
```
|
14
|
+
|
15
|
+
- `INPUT` is the input file path (STDIN by default).
|
16
|
+
- `OUTPUT` is the output file path; if not specified, output will be printed on your command line (STDOUT by default).
|
17
|
+
|
18
|
+
### Cargo Features
|
19
|
+
|
20
|
+
Name | Enabled by default | Description
|
21
|
+
-------------|:------------------:|---------------------------------------------
|
22
|
+
`typescript` | :heavy_check_mark: | Enables support for TypeScript output
|
23
|
+
`golang` | :heavy_check_mark: | Enables support for Go output
|
24
|
+
`java` | :heavy_check_mark: | Enables support for Java output
|
25
|
+
`Python` | :heavy_check_mark: | Enables support for Python output
|
26
|
+
`csharp` | :heavy_check_mark: | Enables support for C# output
|
27
|
+
|
28
|
+
You can enable experimental languages (not enabled by default) by enabling the relevant feature:
|
29
|
+
|
30
|
+
```console
|
31
|
+
$ cargo build --release --features=<feature-name>
|
32
|
+
Finished release [optimized] target(s) in 0.17s
|
33
|
+
```
|
34
|
+
|
35
|
+
If you want to disable on-by-default languages, you can pass `--no-default-features`:
|
36
|
+
|
37
|
+
```console
|
38
|
+
$ cargo build --release --no-default-features --features=golang
|
39
|
+
Finished release [optimized] target(s) in 0.17s
|
40
|
+
```
|
41
|
+
|
42
|
+
## Implemented
|
43
|
+
|
44
|
+
- [x] Fn::FindInMap
|
45
|
+
- [x] Fn::Join
|
46
|
+
- [x] Fn::Sub
|
47
|
+
- [x] Ref
|
48
|
+
- [x] Fn::And
|
49
|
+
- [x] Fn::Equals
|
50
|
+
- [x] Fn::If
|
51
|
+
- [x] Fn::Not
|
52
|
+
- [x] Fn::Or
|
53
|
+
- [x] Fn::GetAtt
|
54
|
+
- [x] Fn::Base64 support
|
55
|
+
- [x] Fn::ImportValue support
|
56
|
+
- [x] Fn::Select support
|
57
|
+
- [x] Resource ordering based on dependencies
|
58
|
+
- [x] Conditions are emitted in ts but not attached to resource conditions
|
59
|
+
- [x] Metadata emission for updates to asgs / lambda functions.
|
60
|
+
- [x] Emission of outputs / exports
|
61
|
+
- [x] Fn::GetAZs support
|
62
|
+
- [x] Adding depends-on, and ordering based on it too.
|
63
|
+
- [x] Deletion policy
|
64
|
+
- [x] Fn::Cidr support
|
65
|
+
|
66
|
+
## Remaining
|
67
|
+
|
68
|
+
There are known unsupported features. Working on them in priority order:
|
69
|
+
|
70
|
+
- [ ] Create policy
|
71
|
+
- [ ] ssm metadata references
|
72
|
+
- [ ] secretsmanager references
|
package/index.d.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
/* tslint:disable */
|
2
|
+
/* eslint-disable */
|
3
|
+
/**
|
4
|
+
* Returns an array containing all supported language names.
|
5
|
+
* @returns {any[]}
|
6
|
+
*/
|
7
|
+
export function supported_languages(): any[];
|
8
|
+
/**
|
9
|
+
* Transforms the provided template into a CDK application in the specified
|
10
|
+
* language.
|
11
|
+
* @param {string} template
|
12
|
+
* @param {string} language
|
13
|
+
* @param {string} stack_name
|
14
|
+
* @returns {string}
|
15
|
+
*/
|
16
|
+
export function transmute(template: string, language: string, stack_name: string): string;
|
package/index.js
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
let imports = {};
|
2
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
3
|
+
let wasm;
|
4
|
+
const { TextDecoder, TextEncoder } = require(`util`);
|
5
|
+
|
6
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
7
|
+
|
8
|
+
cachedTextDecoder.decode();
|
9
|
+
|
10
|
+
let cachedUint8Memory0 = null;
|
11
|
+
|
12
|
+
function getUint8Memory0() {
|
13
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
14
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
15
|
+
}
|
16
|
+
return cachedUint8Memory0;
|
17
|
+
}
|
18
|
+
|
19
|
+
function getStringFromWasm0(ptr, len) {
|
20
|
+
ptr = ptr >>> 0;
|
21
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
22
|
+
}
|
23
|
+
|
24
|
+
const heap = new Array(128).fill(undefined);
|
25
|
+
|
26
|
+
heap.push(undefined, null, true, false);
|
27
|
+
|
28
|
+
let heap_next = heap.length;
|
29
|
+
|
30
|
+
function addHeapObject(obj) {
|
31
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
32
|
+
const idx = heap_next;
|
33
|
+
heap_next = heap[idx];
|
34
|
+
|
35
|
+
heap[idx] = obj;
|
36
|
+
return idx;
|
37
|
+
}
|
38
|
+
|
39
|
+
let cachedInt32Memory0 = null;
|
40
|
+
|
41
|
+
function getInt32Memory0() {
|
42
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
43
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
44
|
+
}
|
45
|
+
return cachedInt32Memory0;
|
46
|
+
}
|
47
|
+
|
48
|
+
let cachedUint32Memory0 = null;
|
49
|
+
|
50
|
+
function getUint32Memory0() {
|
51
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
52
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
53
|
+
}
|
54
|
+
return cachedUint32Memory0;
|
55
|
+
}
|
56
|
+
|
57
|
+
function getObject(idx) { return heap[idx]; }
|
58
|
+
|
59
|
+
function dropObject(idx) {
|
60
|
+
if (idx < 132) return;
|
61
|
+
heap[idx] = heap_next;
|
62
|
+
heap_next = idx;
|
63
|
+
}
|
64
|
+
|
65
|
+
function takeObject(idx) {
|
66
|
+
const ret = getObject(idx);
|
67
|
+
dropObject(idx);
|
68
|
+
return ret;
|
69
|
+
}
|
70
|
+
|
71
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
72
|
+
ptr = ptr >>> 0;
|
73
|
+
const mem = getUint32Memory0();
|
74
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
75
|
+
const result = [];
|
76
|
+
for (let i = 0; i < slice.length; i++) {
|
77
|
+
result.push(takeObject(slice[i]));
|
78
|
+
}
|
79
|
+
return result;
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* Returns an array containing all supported language names.
|
83
|
+
* @returns {any[]}
|
84
|
+
*/
|
85
|
+
module.exports.supported_languages = function() {
|
86
|
+
try {
|
87
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
88
|
+
wasm.supported_languages(retptr);
|
89
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
90
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
91
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
92
|
+
wasm.__wbindgen_free(r0, r1 * 4);
|
93
|
+
return v1;
|
94
|
+
} finally {
|
95
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
96
|
+
}
|
97
|
+
};
|
98
|
+
|
99
|
+
let WASM_VECTOR_LEN = 0;
|
100
|
+
|
101
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
102
|
+
|
103
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
104
|
+
? function (arg, view) {
|
105
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
106
|
+
}
|
107
|
+
: function (arg, view) {
|
108
|
+
const buf = cachedTextEncoder.encode(arg);
|
109
|
+
view.set(buf);
|
110
|
+
return {
|
111
|
+
read: arg.length,
|
112
|
+
written: buf.length
|
113
|
+
};
|
114
|
+
});
|
115
|
+
|
116
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
117
|
+
|
118
|
+
if (realloc === undefined) {
|
119
|
+
const buf = cachedTextEncoder.encode(arg);
|
120
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
121
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
122
|
+
WASM_VECTOR_LEN = buf.length;
|
123
|
+
return ptr;
|
124
|
+
}
|
125
|
+
|
126
|
+
let len = arg.length;
|
127
|
+
let ptr = malloc(len, 1) >>> 0;
|
128
|
+
|
129
|
+
const mem = getUint8Memory0();
|
130
|
+
|
131
|
+
let offset = 0;
|
132
|
+
|
133
|
+
for (; offset < len; offset++) {
|
134
|
+
const code = arg.charCodeAt(offset);
|
135
|
+
if (code > 0x7F) break;
|
136
|
+
mem[ptr + offset] = code;
|
137
|
+
}
|
138
|
+
|
139
|
+
if (offset !== len) {
|
140
|
+
if (offset !== 0) {
|
141
|
+
arg = arg.slice(offset);
|
142
|
+
}
|
143
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
144
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
145
|
+
const ret = encodeString(arg, view);
|
146
|
+
|
147
|
+
offset += ret.written;
|
148
|
+
}
|
149
|
+
|
150
|
+
WASM_VECTOR_LEN = offset;
|
151
|
+
return ptr;
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* Transforms the provided template into a CDK application in the specified
|
155
|
+
* language.
|
156
|
+
* @param {string} template
|
157
|
+
* @param {string} language
|
158
|
+
* @param {string} stack_name
|
159
|
+
* @returns {string}
|
160
|
+
*/
|
161
|
+
module.exports.transmute = function(template, language, stack_name) {
|
162
|
+
let deferred5_0;
|
163
|
+
let deferred5_1;
|
164
|
+
try {
|
165
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
166
|
+
const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
167
|
+
const len0 = WASM_VECTOR_LEN;
|
168
|
+
const ptr1 = passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
169
|
+
const len1 = WASM_VECTOR_LEN;
|
170
|
+
const ptr2 = passStringToWasm0(stack_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
171
|
+
const len2 = WASM_VECTOR_LEN;
|
172
|
+
wasm.transmute(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
173
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
174
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
175
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
176
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
177
|
+
var ptr4 = r0;
|
178
|
+
var len4 = r1;
|
179
|
+
if (r3) {
|
180
|
+
ptr4 = 0; len4 = 0;
|
181
|
+
throw takeObject(r2);
|
182
|
+
}
|
183
|
+
deferred5_0 = ptr4;
|
184
|
+
deferred5_1 = len4;
|
185
|
+
return getStringFromWasm0(ptr4, len4);
|
186
|
+
} finally {
|
187
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
188
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
189
|
+
}
|
190
|
+
};
|
191
|
+
|
192
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
193
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
194
|
+
return addHeapObject(ret);
|
195
|
+
};
|
196
|
+
|
197
|
+
module.exports.__wbindgen_error_new = function(arg0, arg1) {
|
198
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
199
|
+
return addHeapObject(ret);
|
200
|
+
};
|
201
|
+
|
202
|
+
const path = require('path').join(__dirname, 'index_bg.wasm');
|
203
|
+
const bytes = require('fs').readFileSync(path);
|
204
|
+
|
205
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
206
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
207
|
+
wasm = wasmInstance.exports;
|
208
|
+
module.exports.__wasm = wasm;
|
209
|
+
|
package/index_bg.wasm
ADDED
Binary file
|
package/package.json
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"name": "cdk-from-cfn",
|
3
|
+
"description": "Turn AWS CloudFormation templates into AWS CDK applications",
|
4
|
+
"version": "0.3.0",
|
5
|
+
"license": "MIT OR Apache-2.0",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "https://github.com/cdklabs/cdk-from-cfn"
|
9
|
+
},
|
10
|
+
"files": [
|
11
|
+
"index_bg.wasm",
|
12
|
+
"index.js",
|
13
|
+
"index.d.ts"
|
14
|
+
],
|
15
|
+
"main": "index.js",
|
16
|
+
"homepage": "https://github.com/cdklabs/cdk-from-cfn#readme",
|
17
|
+
"types": "index.d.ts"
|
18
|
+
}
|