@coraltravelcenter/b2c-landing-builder 2.4.2 → 2.5.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 +4 -1
- package/package.json +1 -1
- package/src/config/validate-config.mjs +16 -2
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {SCRIPT_STACK_VALUES} from "./script-stack.mjs";
|
|
2
|
+
import {compareVersions, CURRENT_VERSION, PACKAGE_NAME} from "../update/check-update.mjs";
|
|
2
3
|
|
|
3
4
|
const PROJECT_NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
4
|
-
const SUPPORTED_SCHEMA_VERSIONS = new Set([1]);
|
|
5
|
+
const SUPPORTED_SCHEMA_VERSIONS = new Set([1, 2]);
|
|
6
|
+
const VERSION_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
5
7
|
const STACK_VALUES = {
|
|
6
8
|
script: SCRIPT_STACK_VALUES,
|
|
7
9
|
markup: new Set(["html", "pug"]),
|
|
@@ -16,9 +18,21 @@ export function validateConfig(config) {
|
|
|
16
18
|
if (!SUPPORTED_SCHEMA_VERSIONS.has(config.schemaVersion)) {
|
|
17
19
|
throw new Error(
|
|
18
20
|
`Unsupported schemaVersion ${JSON.stringify(config.schemaVersion)}. ` +
|
|
19
|
-
"This builder supports schemaVersion 1."
|
|
21
|
+
"This builder supports schemaVersion 1 and 2."
|
|
20
22
|
);
|
|
21
23
|
}
|
|
24
|
+
if (config.schemaVersion >= 2) {
|
|
25
|
+
const minVersion = config.builder?.minVersion;
|
|
26
|
+
if (!VERSION_RE.test(minVersion || "")) {
|
|
27
|
+
throw new Error("builder.minVersion must be a semantic version such as 2.5.0");
|
|
28
|
+
}
|
|
29
|
+
if (compareVersions(CURRENT_VERSION, minVersion) < 0) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Project requires ${PACKAGE_NAME} >= ${minVersion}, but ${CURRENT_VERSION} is installed. ` +
|
|
32
|
+
`Update manually: npm install --global ${PACKAGE_NAME}@latest`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
22
36
|
if (!PROJECT_NAME_RE.test(config.project?.name || "")) {
|
|
23
37
|
throw new Error("project.name must match ^[a-z0-9][a-z0-9-]*$");
|
|
24
38
|
}
|