From 4f9e7b48c0a37ed12ff01732ba35002ca03fffec Mon Sep 17 00:00:00 2001 From: keeramis Date: Tue, 3 Sep 2024 12:13:51 -0700 Subject: [PATCH] Skip adding protected devices to non-protection products --- src/cmd/product.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/cmd/product.js b/src/cmd/product.js index 580735760..eadc4fd3b 100644 --- a/src/cmd/product.js +++ b/src/cmd/product.js @@ -42,8 +42,8 @@ module.exports = class ProductCommand extends CLICommandBase { .then(result => this.showDeviceAddResult(result)); } - showDeviceAddResult({ product, identifiers, status: { invalidDeviceIds = [], nonmemberDeviceIds = [] } } = {}){ - identifiers = filterDeviceIdentifiers(identifiers, invalidDeviceIds, nonmemberDeviceIds); + showDeviceAddResult({ product, identifiers, status: { invalidDeviceIds = [], nonmemberDeviceIds = [], protectedDeviceIds = [] } } = {}){ + identifiers = filterDeviceIdentifiers(identifiers, invalidDeviceIds, nonmemberDeviceIds, protectedDeviceIds); const message = []; if (identifiers.length){ @@ -75,6 +75,14 @@ module.exports = class ProductCommand extends CLICommandBase { ); } + if (protectedDeviceIds.length){ + message.push( + 'Skipped Protected IDs:', + dedupeAndStringifyIDList(protectedDeviceIds), + '' + ); + } + if (!identifiers.length){ throw new Error(message.join(os.EOL)); } @@ -200,9 +208,10 @@ function readDeviceListFile(file){ }); } -function filterDeviceIdentifiers(identifiers, invalid = [], nonmember = []){ +function filterDeviceIdentifiers(identifiers, invalid = [], nonmember = [], protectedDevice = []){ return identifiers.reduce((out, x) => { - if (!hasDeviceIdentifier(x, invalid) && !hasDeviceIdentifier(x, nonmember)){ + if (!hasDeviceIdentifier(x, invalid) && !hasDeviceIdentifier(x, nonmember) + && !hasDeviceIdentifier(x, protectedDevice)){ out.push(x); } return out;