opentool 0.8.23 → 0.8.25

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/cli/index.js CHANGED
@@ -1001,6 +1001,29 @@ var SUPPORTED_EXTENSIONS = [
1001
1001
  ".mjs",
1002
1002
  ".cjs"
1003
1003
  ];
1004
+ var MIN_TEMPLATE_CONFIG_VERSION = 2;
1005
+ function normalizeTemplateConfigVersion(value) {
1006
+ if (typeof value === "number" && Number.isFinite(value)) {
1007
+ return value;
1008
+ }
1009
+ if (typeof value !== "string") {
1010
+ return null;
1011
+ }
1012
+ const trimmed = value.trim();
1013
+ if (!trimmed) {
1014
+ return null;
1015
+ }
1016
+ if (/^\d+(?:\.\d+)?$/.test(trimmed)) {
1017
+ const numeric = Number.parseFloat(trimmed);
1018
+ return Number.isFinite(numeric) ? numeric : null;
1019
+ }
1020
+ const majorMatch = /^v?(\d+)(?:\..*)?$/i.exec(trimmed);
1021
+ if (!majorMatch) {
1022
+ return null;
1023
+ }
1024
+ const major = Number.parseInt(majorMatch[1], 10);
1025
+ return Number.isFinite(major) ? major : null;
1026
+ }
1004
1027
  async function validateCommand(options) {
1005
1028
  console.log("\u{1F50D} Validating OpenTool metadata...");
1006
1029
  try {
@@ -1186,9 +1209,15 @@ async function loadAndValidateTools(toolsDir, options = {}) {
1186
1209
  }
1187
1210
  const record = templateConfigRaw;
1188
1211
  const version = record.version;
1189
- if (typeof version !== "string" && typeof version !== "number") {
1212
+ const normalizedTemplateConfigVersion = normalizeTemplateConfigVersion(version);
1213
+ if (normalizedTemplateConfigVersion === null) {
1214
+ throw new Error(
1215
+ `${file}: profile.templateConfig.version must be a numeric string or number.`
1216
+ );
1217
+ }
1218
+ if (normalizedTemplateConfigVersion < MIN_TEMPLATE_CONFIG_VERSION) {
1190
1219
  throw new Error(
1191
- `${file}: profile.templateConfig.version must be a string or number.`
1220
+ `${file}: profile.templateConfig.version must be >= ${MIN_TEMPLATE_CONFIG_VERSION}.`
1192
1221
  );
1193
1222
  }
1194
1223
  const schema2 = record.schema;