@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 CHANGED
@@ -60,7 +60,10 @@ npm create @coraltravelcenter/b2c-landing-vite
60
60
 
61
61
  ```js
62
62
  export default {
63
- schemaVersion: 1,
63
+ schemaVersion: 2,
64
+ builder: {
65
+ minVersion: "2.5.0",
66
+ },
64
67
  project: {
65
68
  name: "uae-promo",
66
69
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coraltravelcenter/b2c-landing-builder",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "CLI and build toolkit for B2C landing projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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
  }