From 5cbd7349ed8475ad3f3681abb5d49ddaeefb477a Mon Sep 17 00:00:00 2001 From: Adam Stolcenburg Date: Tue, 28 Jul 2026 14:10:21 +0200 Subject: [PATCH] Accept package configs with any packageType value This also changes package config validation to match the specification: - entryPoint is considered mandatory - versionName is optional Ref: #RDKEAPPRT-936 --- bolt/src/PackageConfig.cjs | 18 ++++++++++++++++-- bolt/src/pack.cjs | 12 ++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/bolt/src/PackageConfig.cjs b/bolt/src/PackageConfig.cjs index c0e32f3..bd6295e 100644 --- a/bolt/src/PackageConfig.cjs +++ b/bolt/src/PackageConfig.cjs @@ -26,17 +26,31 @@ class PackageConfig { } static validate(config) { - if ((config.packageType === "base" || config.packageType === "runtime" || config.packageType === "application") && + if (typeof config === "object" && config !== null && + typeof config.packageType === "string" && typeof config.id === "string" && typeof config.version === "string" && typeof config.entryPoint === "string" && - typeof config.name === "string") { + typeof config.name === "string" && + (config.versionName === undefined || typeof config.versionName === "string")) { return; } else { throw new Error(`Invalid config:\n ${JSON.stringify(config, null, 2)}`); } } + static isKnownPackageType(packageType) { + switch (packageType) { + case "base": + case "runtime": + case "application": + case "service": + case "resource": + return true; + } + return false; + } + static fromPath(path) { try { const data = JSON.parse(readFileSync(path)); diff --git a/bolt/src/pack.cjs b/bolt/src/pack.cjs index 03779fb..9758931 100644 --- a/bolt/src/pack.cjs +++ b/bolt/src/pack.cjs @@ -23,16 +23,12 @@ const { ZIPPackageBuilder } = require('./ZIPPackageBuilder.cjs'); const { commonOptions } = require('./commonOptions.cjs'); const { exec, execv, assertFile } = require('./utils.cjs'); const { statSync, mkdirSync, rmSync, readFileSync } = require('node:fs'); +const { PackageConfig } = require('./PackageConfig.cjs'); function validateConfig(config) { - if ((config.packageType === "base" || config.packageType === "runtime" || config.packageType === "application") && - typeof config.id === "string" && - typeof config.version === "string" && - typeof config.versionName === "string" && - typeof config.name === "string") { - return; - } else { - throw new Error(`Invalid config:\n ${JSON.stringify(config, null, 2)}`); + PackageConfig.validate(config); + if (!PackageConfig.isKnownPackageType(config.packageType)) { + console.warn(`Warning: Unknown packageType: ${config.packageType}`); } }