@ttoss/cloudformation 0.6.4 → 0.6.5
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/dist/esm/index.js +140 -123
- package/dist/index.js +157 -129
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
var __require = /* @__PURE__ */
|
|
2
|
+
var __require = /* @__PURE__ */(x => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
3
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined")
|
|
6
|
-
return require.apply(this, arguments);
|
|
4
|
+
}) : x)(function (x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
6
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
8
7
|
});
|
|
9
8
|
|
|
@@ -17,134 +16,145 @@ import * as path from "path";
|
|
|
17
16
|
|
|
18
17
|
// src/cloudFormationYamlTemplate.ts
|
|
19
18
|
import yaml from "js-yaml";
|
|
20
|
-
var cloudFormationTypes = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
19
|
+
var cloudFormationTypes = [{
|
|
20
|
+
tag: "!Equals",
|
|
21
|
+
options: {
|
|
22
|
+
kind: "sequence",
|
|
23
|
+
construct: data => {
|
|
24
|
+
return {
|
|
25
|
+
"Fn::Equals": data
|
|
26
|
+
};
|
|
28
27
|
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
tag: "!FindInMap",
|
|
31
|
+
options: {
|
|
32
|
+
kind: "sequence",
|
|
33
|
+
construct: data => {
|
|
34
|
+
return {
|
|
35
|
+
"Fn::FindInMap": data
|
|
36
|
+
};
|
|
37
37
|
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
tag: "!GetAtt",
|
|
41
|
+
options: {
|
|
42
|
+
kind: "scalar",
|
|
43
|
+
construct: data => {
|
|
44
|
+
return {
|
|
45
|
+
"Fn::GetAtt": data.split(".")
|
|
46
|
+
};
|
|
46
47
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
tag: "!GetAtt",
|
|
51
|
+
options: {
|
|
52
|
+
kind: "sequence",
|
|
53
|
+
construct: data => {
|
|
54
|
+
return {
|
|
55
|
+
"Fn::GetAtt": data
|
|
56
|
+
};
|
|
55
57
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
tag: "!If",
|
|
61
|
+
options: {
|
|
62
|
+
kind: "sequence",
|
|
63
|
+
construct: data => {
|
|
64
|
+
return {
|
|
65
|
+
"Fn::If": data
|
|
66
|
+
};
|
|
64
67
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
tag: "!ImportValue",
|
|
71
|
+
options: {
|
|
72
|
+
kind: "scalar",
|
|
73
|
+
construct: data => {
|
|
74
|
+
return {
|
|
75
|
+
"Fn::ImportValue": data
|
|
76
|
+
};
|
|
73
77
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
tag: "!Join",
|
|
81
|
+
options: {
|
|
82
|
+
kind: "sequence",
|
|
83
|
+
construct: data => {
|
|
84
|
+
return {
|
|
85
|
+
"Fn::Join": data
|
|
86
|
+
};
|
|
82
87
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
tag: "!Not",
|
|
91
|
+
options: {
|
|
92
|
+
kind: "sequence",
|
|
93
|
+
construct: data => {
|
|
94
|
+
return {
|
|
95
|
+
"Fn::Not": data
|
|
96
|
+
};
|
|
91
97
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
tag: "!Ref",
|
|
101
|
+
options: {
|
|
102
|
+
kind: "scalar",
|
|
103
|
+
construct: data => {
|
|
104
|
+
return {
|
|
105
|
+
Ref: data
|
|
106
|
+
};
|
|
100
107
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
tag: "!Sub",
|
|
111
|
+
options: {
|
|
112
|
+
kind: "scalar",
|
|
113
|
+
construct: data => {
|
|
114
|
+
return {
|
|
115
|
+
"Fn::Sub": data
|
|
116
|
+
};
|
|
109
117
|
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
tag: "!Sub",
|
|
121
|
+
options: {
|
|
122
|
+
kind: "sequence",
|
|
123
|
+
construct: data => {
|
|
124
|
+
return {
|
|
125
|
+
"Fn::Sub": data
|
|
126
|
+
};
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
|
-
];
|
|
121
|
-
var getYamlTypes =
|
|
122
|
-
return tagAndTypeArr.map(({
|
|
129
|
+
}];
|
|
130
|
+
var getYamlTypes = tagAndTypeArr => {
|
|
131
|
+
return tagAndTypeArr.map(({
|
|
132
|
+
tag,
|
|
133
|
+
options
|
|
134
|
+
}) => {
|
|
123
135
|
return new yaml.Type(tag, options);
|
|
124
136
|
});
|
|
125
137
|
};
|
|
126
138
|
var getSchema = (tagAndTypeArr = []) => {
|
|
127
|
-
return yaml.DEFAULT_SCHEMA.extend(
|
|
128
|
-
getYamlTypes([...tagAndTypeArr, ...cloudFormationTypes])
|
|
129
|
-
);
|
|
139
|
+
return yaml.DEFAULT_SCHEMA.extend(getYamlTypes([...tagAndTypeArr, ...cloudFormationTypes]));
|
|
130
140
|
};
|
|
131
141
|
var loadCloudFormationTemplate = (template, tagAndTypeArr = []) => {
|
|
132
|
-
return yaml.load(template, {
|
|
142
|
+
return yaml.load(template, {
|
|
143
|
+
schema: getSchema(tagAndTypeArr)
|
|
144
|
+
});
|
|
133
145
|
};
|
|
134
146
|
|
|
135
147
|
// src/readCloudFormationYamlTemplate.ts
|
|
136
148
|
var getTypes = () => {
|
|
137
|
-
return [
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return fs.readFileSync(path.resolve(process.cwd(), filePath)).toString();
|
|
144
|
-
}
|
|
149
|
+
return [{
|
|
150
|
+
tag: `!SubString`,
|
|
151
|
+
options: {
|
|
152
|
+
kind: "scalar",
|
|
153
|
+
construct: filePath => {
|
|
154
|
+
return fs.readFileSync(path.resolve(process.cwd(), filePath)).toString();
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
|
-
];
|
|
157
|
+
}];
|
|
148
158
|
};
|
|
149
159
|
var readCloudFormationYamlTemplate = ({
|
|
150
160
|
templatePath
|
|
@@ -160,18 +170,24 @@ var readCloudFormationYamlTemplate = ({
|
|
|
160
170
|
// src/readObjectFile.ts
|
|
161
171
|
import fs2 from "fs";
|
|
162
172
|
import yaml2 from "js-yaml";
|
|
163
|
-
var readYaml = ({
|
|
173
|
+
var readYaml = ({
|
|
174
|
+
path: path3
|
|
175
|
+
}) => {
|
|
164
176
|
const template = fs2.readFileSync(path3, "utf8") || JSON.stringify({});
|
|
165
177
|
return yaml2.load(template);
|
|
166
178
|
};
|
|
167
|
-
var readObjectFile = ({
|
|
179
|
+
var readObjectFile = ({
|
|
180
|
+
path: path3
|
|
181
|
+
}) => {
|
|
168
182
|
if (!fs2.existsSync(path3)) {
|
|
169
183
|
return {};
|
|
170
184
|
}
|
|
171
185
|
const extension = path3.split(".").pop();
|
|
172
186
|
if (extension === "ts") {
|
|
173
187
|
__require("ts-node").register({
|
|
174
|
-
compilerOptions: {
|
|
188
|
+
compilerOptions: {
|
|
189
|
+
module: "commonjs"
|
|
190
|
+
},
|
|
175
191
|
moduleTypes: {
|
|
176
192
|
"carlin.*": "cjs"
|
|
177
193
|
},
|
|
@@ -189,17 +205,17 @@ var readObjectFile = ({ path: path3 }) => {
|
|
|
189
205
|
return __require(path3);
|
|
190
206
|
}
|
|
191
207
|
if (extension === "yml" || extension === "yaml") {
|
|
192
|
-
return readYaml({
|
|
208
|
+
return readYaml({
|
|
209
|
+
path: path3
|
|
210
|
+
});
|
|
193
211
|
}
|
|
194
212
|
return {};
|
|
195
213
|
};
|
|
196
214
|
|
|
197
215
|
// src/findAndReadCloudFormationTemplate.ts
|
|
198
|
-
var defaultTemplatePaths = ["ts", "js", "yaml", "yml", "json"].map(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
);
|
|
216
|
+
var defaultTemplatePaths = ["ts", "js", "yaml", "yml", "json"].map(extension => {
|
|
217
|
+
return `./src/cloudformation.${extension}`;
|
|
218
|
+
});
|
|
203
219
|
var findAndReadCloudFormationTemplate = ({
|
|
204
220
|
templatePath: defaultTemplatePath
|
|
205
221
|
}) => {
|
|
@@ -215,11 +231,12 @@ var findAndReadCloudFormationTemplate = ({
|
|
|
215
231
|
const extension = templatePath?.split(".").pop();
|
|
216
232
|
const fullPath = path2.resolve(process.cwd(), templatePath);
|
|
217
233
|
if (["yaml", "yml"].includes(extension)) {
|
|
218
|
-
return readCloudFormationYamlTemplate({
|
|
234
|
+
return readCloudFormationYamlTemplate({
|
|
235
|
+
templatePath
|
|
236
|
+
});
|
|
219
237
|
}
|
|
220
|
-
return readObjectFile({
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
findAndReadCloudFormationTemplate,
|
|
224
|
-
readObjectFile as unstable_readObjectFile
|
|
238
|
+
return readObjectFile({
|
|
239
|
+
path: fullPath
|
|
240
|
+
});
|
|
225
241
|
};
|
|
242
|
+
export { findAndReadCloudFormationTemplate, readObjectFile as unstable_readObjectFile };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
"use strict";
|
|
3
|
+
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,26 +8,32 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
10
|
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
12
15
|
};
|
|
13
16
|
var __copyProps = (to, from, except, desc) => {
|
|
14
17
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
23
|
return to;
|
|
20
24
|
};
|
|
21
25
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
mod
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
31
|
+
value: mod,
|
|
32
|
+
enumerable: true
|
|
33
|
+
}) : target, mod));
|
|
34
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
35
|
+
value: true
|
|
36
|
+
}), mod);
|
|
30
37
|
|
|
31
38
|
// src/index.ts
|
|
32
39
|
var src_exports = {};
|
|
@@ -46,134 +53,145 @@ var path = __toESM(require("path"));
|
|
|
46
53
|
|
|
47
54
|
// src/cloudFormationYamlTemplate.ts
|
|
48
55
|
var import_js_yaml = __toESM(require("js-yaml"));
|
|
49
|
-
var cloudFormationTypes = [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
56
|
+
var cloudFormationTypes = [{
|
|
57
|
+
tag: "!Equals",
|
|
58
|
+
options: {
|
|
59
|
+
kind: "sequence",
|
|
60
|
+
construct: data => {
|
|
61
|
+
return {
|
|
62
|
+
"Fn::Equals": data
|
|
63
|
+
};
|
|
57
64
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
tag: "!FindInMap",
|
|
68
|
+
options: {
|
|
69
|
+
kind: "sequence",
|
|
70
|
+
construct: data => {
|
|
71
|
+
return {
|
|
72
|
+
"Fn::FindInMap": data
|
|
73
|
+
};
|
|
66
74
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
tag: "!GetAtt",
|
|
78
|
+
options: {
|
|
79
|
+
kind: "scalar",
|
|
80
|
+
construct: data => {
|
|
81
|
+
return {
|
|
82
|
+
"Fn::GetAtt": data.split(".")
|
|
83
|
+
};
|
|
75
84
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
tag: "!GetAtt",
|
|
88
|
+
options: {
|
|
89
|
+
kind: "sequence",
|
|
90
|
+
construct: data => {
|
|
91
|
+
return {
|
|
92
|
+
"Fn::GetAtt": data
|
|
93
|
+
};
|
|
84
94
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
tag: "!If",
|
|
98
|
+
options: {
|
|
99
|
+
kind: "sequence",
|
|
100
|
+
construct: data => {
|
|
101
|
+
return {
|
|
102
|
+
"Fn::If": data
|
|
103
|
+
};
|
|
93
104
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
tag: "!ImportValue",
|
|
108
|
+
options: {
|
|
109
|
+
kind: "scalar",
|
|
110
|
+
construct: data => {
|
|
111
|
+
return {
|
|
112
|
+
"Fn::ImportValue": data
|
|
113
|
+
};
|
|
102
114
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
tag: "!Join",
|
|
118
|
+
options: {
|
|
119
|
+
kind: "sequence",
|
|
120
|
+
construct: data => {
|
|
121
|
+
return {
|
|
122
|
+
"Fn::Join": data
|
|
123
|
+
};
|
|
111
124
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
tag: "!Not",
|
|
128
|
+
options: {
|
|
129
|
+
kind: "sequence",
|
|
130
|
+
construct: data => {
|
|
131
|
+
return {
|
|
132
|
+
"Fn::Not": data
|
|
133
|
+
};
|
|
120
134
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
tag: "!Ref",
|
|
138
|
+
options: {
|
|
139
|
+
kind: "scalar",
|
|
140
|
+
construct: data => {
|
|
141
|
+
return {
|
|
142
|
+
Ref: data
|
|
143
|
+
};
|
|
129
144
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
tag: "!Sub",
|
|
148
|
+
options: {
|
|
149
|
+
kind: "scalar",
|
|
150
|
+
construct: data => {
|
|
151
|
+
return {
|
|
152
|
+
"Fn::Sub": data
|
|
153
|
+
};
|
|
138
154
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
tag: "!Sub",
|
|
158
|
+
options: {
|
|
159
|
+
kind: "sequence",
|
|
160
|
+
construct: data => {
|
|
161
|
+
return {
|
|
162
|
+
"Fn::Sub": data
|
|
163
|
+
};
|
|
147
164
|
}
|
|
148
165
|
}
|
|
149
|
-
];
|
|
150
|
-
var getYamlTypes =
|
|
151
|
-
return tagAndTypeArr.map(({
|
|
166
|
+
}];
|
|
167
|
+
var getYamlTypes = tagAndTypeArr => {
|
|
168
|
+
return tagAndTypeArr.map(({
|
|
169
|
+
tag,
|
|
170
|
+
options
|
|
171
|
+
}) => {
|
|
152
172
|
return new import_js_yaml.default.Type(tag, options);
|
|
153
173
|
});
|
|
154
174
|
};
|
|
155
175
|
var getSchema = (tagAndTypeArr = []) => {
|
|
156
|
-
return import_js_yaml.default.DEFAULT_SCHEMA.extend(
|
|
157
|
-
getYamlTypes([...tagAndTypeArr, ...cloudFormationTypes])
|
|
158
|
-
);
|
|
176
|
+
return import_js_yaml.default.DEFAULT_SCHEMA.extend(getYamlTypes([...tagAndTypeArr, ...cloudFormationTypes]));
|
|
159
177
|
};
|
|
160
178
|
var loadCloudFormationTemplate = (template, tagAndTypeArr = []) => {
|
|
161
|
-
return import_js_yaml.default.load(template, {
|
|
179
|
+
return import_js_yaml.default.load(template, {
|
|
180
|
+
schema: getSchema(tagAndTypeArr)
|
|
181
|
+
});
|
|
162
182
|
};
|
|
163
183
|
|
|
164
184
|
// src/readCloudFormationYamlTemplate.ts
|
|
165
185
|
var getTypes = () => {
|
|
166
|
-
return [
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return fs.readFileSync(path.resolve(process.cwd(), filePath)).toString();
|
|
173
|
-
}
|
|
186
|
+
return [{
|
|
187
|
+
tag: `!SubString`,
|
|
188
|
+
options: {
|
|
189
|
+
kind: "scalar",
|
|
190
|
+
construct: filePath => {
|
|
191
|
+
return fs.readFileSync(path.resolve(process.cwd(), filePath)).toString();
|
|
174
192
|
}
|
|
175
193
|
}
|
|
176
|
-
];
|
|
194
|
+
}];
|
|
177
195
|
};
|
|
178
196
|
var readCloudFormationYamlTemplate = ({
|
|
179
197
|
templatePath
|
|
@@ -189,18 +207,24 @@ var readCloudFormationYamlTemplate = ({
|
|
|
189
207
|
// src/readObjectFile.ts
|
|
190
208
|
var import_fs = __toESM(require("fs"));
|
|
191
209
|
var import_js_yaml2 = __toESM(require("js-yaml"));
|
|
192
|
-
var readYaml = ({
|
|
210
|
+
var readYaml = ({
|
|
211
|
+
path: path3
|
|
212
|
+
}) => {
|
|
193
213
|
const template = import_fs.default.readFileSync(path3, "utf8") || JSON.stringify({});
|
|
194
214
|
return import_js_yaml2.default.load(template);
|
|
195
215
|
};
|
|
196
|
-
var readObjectFile = ({
|
|
216
|
+
var readObjectFile = ({
|
|
217
|
+
path: path3
|
|
218
|
+
}) => {
|
|
197
219
|
if (!import_fs.default.existsSync(path3)) {
|
|
198
220
|
return {};
|
|
199
221
|
}
|
|
200
222
|
const extension = path3.split(".").pop();
|
|
201
223
|
if (extension === "ts") {
|
|
202
224
|
require("ts-node").register({
|
|
203
|
-
compilerOptions: {
|
|
225
|
+
compilerOptions: {
|
|
226
|
+
module: "commonjs"
|
|
227
|
+
},
|
|
204
228
|
moduleTypes: {
|
|
205
229
|
"carlin.*": "cjs"
|
|
206
230
|
},
|
|
@@ -218,17 +242,17 @@ var readObjectFile = ({ path: path3 }) => {
|
|
|
218
242
|
return require(path3);
|
|
219
243
|
}
|
|
220
244
|
if (extension === "yml" || extension === "yaml") {
|
|
221
|
-
return readYaml({
|
|
245
|
+
return readYaml({
|
|
246
|
+
path: path3
|
|
247
|
+
});
|
|
222
248
|
}
|
|
223
249
|
return {};
|
|
224
250
|
};
|
|
225
251
|
|
|
226
252
|
// src/findAndReadCloudFormationTemplate.ts
|
|
227
|
-
var defaultTemplatePaths = ["ts", "js", "yaml", "yml", "json"].map(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
);
|
|
253
|
+
var defaultTemplatePaths = ["ts", "js", "yaml", "yml", "json"].map(extension => {
|
|
254
|
+
return `./src/cloudformation.${extension}`;
|
|
255
|
+
});
|
|
232
256
|
var findAndReadCloudFormationTemplate = ({
|
|
233
257
|
templatePath: defaultTemplatePath
|
|
234
258
|
}) => {
|
|
@@ -244,12 +268,16 @@ var findAndReadCloudFormationTemplate = ({
|
|
|
244
268
|
const extension = templatePath?.split(".").pop();
|
|
245
269
|
const fullPath = path2.resolve(process.cwd(), templatePath);
|
|
246
270
|
if (["yaml", "yml"].includes(extension)) {
|
|
247
|
-
return readCloudFormationYamlTemplate({
|
|
271
|
+
return readCloudFormationYamlTemplate({
|
|
272
|
+
templatePath
|
|
273
|
+
});
|
|
248
274
|
}
|
|
249
|
-
return readObjectFile({
|
|
275
|
+
return readObjectFile({
|
|
276
|
+
path: fullPath
|
|
277
|
+
});
|
|
250
278
|
};
|
|
251
279
|
// Annotate the CommonJS export names for ESM import in node:
|
|
252
280
|
0 && (module.exports = {
|
|
253
281
|
findAndReadCloudFormationTemplate,
|
|
254
282
|
unstable_readObjectFile
|
|
255
|
-
});
|
|
283
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/cloudformation",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "CloudFormation utils.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"ts-node": "^10.9.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ttoss/config": "^1.29.
|
|
27
|
-
"@ttoss/test-utils": "^1.20.
|
|
26
|
+
"@ttoss/config": "^1.29.2",
|
|
27
|
+
"@ttoss/test-utils": "^1.20.9",
|
|
28
28
|
"@types/jest": "^29.5.0",
|
|
29
29
|
"jest": "^29.5.0"
|
|
30
30
|
},
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "0609bb0f6e6a1c0999c29e7a5c8f8ebb1c6d3d7a"
|
|
36
36
|
}
|