From dd02b19e445974a2af194bc273ba059399114bab Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Fri, 11 Oct 2024 15:34:52 -0400 Subject: [PATCH] feat(SmartNTT): support new file name --- lib/ntpUtil.js | 4 ++-- scripts/ntp-sponsored-images/generate.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ntpUtil.js b/lib/ntpUtil.js index d151f68f..8f585b05 100644 --- a/lib/ntpUtil.js +++ b/lib/ntpUtil.js @@ -93,7 +93,7 @@ const isValidSchemaVersion = (version) => { return version === jsonSchemaVersion } -const prepareAssets = (jsonFileUrl, targetResourceDir, targetJsonFileName) => { +const prepareAssets = (jsonFileUrl, targetResourceDir, targetJsonFileName = 'photo.json') => { return new Promise(function (resolve, reject) { let jsonFileBody = '{}' @@ -126,7 +126,7 @@ const prepareAssets = (jsonFileUrl, targetResourceDir, targetJsonFileName) => { return reject(error) } - createPhotoJsonFile(path.join(targetResourceDir, 'photo.json'), JSON.stringify(photoData)) + createPhotoJsonFile(path.join(targetResourceDir, targetJsonFileName), JSON.stringify(photoData)) // Download image files that specified in jsonFileUrl const imageFileNameList = getImageFileNameListFrom(photoData) diff --git a/scripts/ntp-sponsored-images/generate.js b/scripts/ntp-sponsored-images/generate.js index f03dbe70..e1962553 100644 --- a/scripts/ntp-sponsored-images/generate.js +++ b/scripts/ntp-sponsored-images/generate.js @@ -30,8 +30,12 @@ async function generateNTPSponsoredImages (dataUrl, targetComponents) { const targetResourceDir = path.join(rootResourceDir, regionPlatformName) mkdirp.sync(targetResourceDir) const regionPlatformPath = regionPlatformName.replace('-', '/') - const sourceJsonFileUrl = `${dataUrl}${regionPlatformPath}/photo.json` - await ntpUtil.prepareAssets(sourceJsonFileUrl, targetResourceDir) + const baseJsonFileUrl = `${dataUrl}${regionPlatformPath}` + + await Promise.all([ + ntpUtil.prepareAssets(`${baseJsonFileUrl}/photo.json`, targetResourceDir), + ntpUtil.prepareAssets(`${baseJsonFileUrl}/si-photo.json`, targetResourceDir, 'si-photo.json') + ]) } }