@extrahorizon/exh-cli 1.12.0-dev-153-e5a1b1d → 1.12.0-dev-154-7343f7f
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.
|
@@ -35,8 +35,8 @@ async function buildTemplate(name, templateFilesByName, callChain = []) {
|
|
|
35
35
|
else {
|
|
36
36
|
templateConfig = { ...templateFile, name };
|
|
37
37
|
}
|
|
38
|
-
if (!(0, utils_1.isV1Template)(templateConfig)
|
|
39
|
-
|
|
38
|
+
if (!(0, utils_1.isV1Template)(templateConfig)) {
|
|
39
|
+
validateV2Template(templateConfig);
|
|
40
40
|
}
|
|
41
41
|
return templateConfig;
|
|
42
42
|
}
|
|
@@ -132,8 +132,21 @@ function resolveVariableValue(value) {
|
|
|
132
132
|
}
|
|
133
133
|
return resolved;
|
|
134
134
|
}
|
|
135
|
+
function validateV2Template(template) {
|
|
136
|
+
if (!/^[A-Za-z][A-Za-z0-9_-]{0,49}$/.test(template.name)) {
|
|
137
|
+
throw new Error(`Template name '${template.name}' is invalid. Template names must start with a letter and can only contain letters, numbers, underscores and hyphens, and be at most 50 characters long.`);
|
|
138
|
+
}
|
|
139
|
+
if (Object.keys(template.outputs || {}).length < 1) {
|
|
140
|
+
throw new Error(`Template '${template.name}' must have at least one output defined.`);
|
|
141
|
+
}
|
|
142
|
+
for (const outputName of Object.keys(template.outputs)) {
|
|
143
|
+
if (!/^[A-Za-z][A-Za-z0-9_-]{0,49}$/.test(outputName)) {
|
|
144
|
+
throw new Error(`Output name '${outputName}' is invalid. Output names must start with a letter and can only contain letters, numbers, underscores and hyphens, and be at most 50 characters long.`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
135
148
|
function v1ExtendingV2Error(extendsTemplate, callChain) {
|
|
136
|
-
return new Error(`You cannot extend a v2 template ('${extendsTemplate}') in a v1 template
|
|
149
|
+
return new Error(`You cannot extend a v2 template ('${extendsTemplate}') in a v1 template.` +
|
|
137
150
|
`In ${renderCallChain(callChain)}`);
|
|
138
151
|
}
|
|
139
152
|
function v1VariableNotFoundError(variableName, extendsTemplate, callChain) {
|
|
@@ -142,7 +155,7 @@ function v1VariableNotFoundError(variableName, extendsTemplate, callChain) {
|
|
|
142
155
|
`in ${renderCallChain(callChain)}`);
|
|
143
156
|
}
|
|
144
157
|
function v2ExtendingV1Error(extendsTemplate, callChain) {
|
|
145
|
-
return new Error(`You cannot extend a v1 template ('${extendsTemplate}') in a v2 template
|
|
158
|
+
return new Error(`You cannot extend a v1 template ('${extendsTemplate}') in a v2 template.` +
|
|
146
159
|
`In ${renderCallChain(callChain)}`);
|
|
147
160
|
}
|
|
148
161
|
function v2VariableNotFoundError(variableName, extendsTemplate, callChain) {
|