diff --git a/src/metadata/a48.json b/src/metadata/a48.json index 4d8abec9..1c6baf01 100644 --- a/src/metadata/a48.json +++ b/src/metadata/a48.json @@ -810,7 +810,7 @@ "directoryName": "experiences", "inFolder": false, "metaFile": true, - "suffix": "", + "suffix": "site", "xmlName": "ExperienceBundle" }, { diff --git a/src/metadata/v47.json b/src/metadata/v47.json index 8786314a..d23ca793 100644 --- a/src/metadata/v47.json +++ b/src/metadata/v47.json @@ -803,6 +803,7 @@ "directoryName": "experiences", "inFolder": false, "metaFile": true, + "suffix": "site", "xmlName": "ExperienceBundle" }, { diff --git a/src/metadata/v49.json b/src/metadata/v49.json index 38b7ccb6..44346cd7 100644 --- a/src/metadata/v49.json +++ b/src/metadata/v49.json @@ -817,6 +817,7 @@ "directoryName": "experiences", "inFolder": false, "metaFile": true, + "suffix": "site", "xmlName": "ExperienceBundle" }, { diff --git a/src/metadata/v50.json b/src/metadata/v50.json index 38b7ccb6..44346cd7 100644 --- a/src/metadata/v50.json +++ b/src/metadata/v50.json @@ -817,6 +817,7 @@ "directoryName": "experiences", "inFolder": false, "metaFile": true, + "suffix": "site", "xmlName": "ExperienceBundle" }, { diff --git a/src/metadata/v51.json b/src/metadata/v51.json index d8977b0d..a35834e5 100644 --- a/src/metadata/v51.json +++ b/src/metadata/v51.json @@ -816,6 +816,7 @@ "directoryName": "experiences", "inFolder": false, "metaFile": true, + "suffix": "site", "xmlName": "ExperienceBundle" }, { diff --git a/src/metadata/v52.json b/src/metadata/v52.json index d8977b0d..a35834e5 100644 --- a/src/metadata/v52.json +++ b/src/metadata/v52.json @@ -816,6 +816,7 @@ "directoryName": "experiences", "inFolder": false, "metaFile": true, + "suffix": "site", "xmlName": "ExperienceBundle" }, { diff --git a/src/service/inResourceHandler.js b/src/service/inResourceHandler.js index ebaeec14..b474461c 100644 --- a/src/service/inResourceHandler.js +++ b/src/service/inResourceHandler.js @@ -4,6 +4,7 @@ const path = require('path') const fs = require('fs') const mc = require('../utils/metadataConstants') +const STATICRESOURCE_TYPE = 'staticresources' const elementSrc = {} class ResourceHandler extends StandardHandler { @@ -20,14 +21,16 @@ class ResourceHandler extends StandardHandler { 'u' ) ) + this._buildElementMap(srcPath) - const parsedElementName = path.parse(elementName) - if (!Object.prototype.hasOwnProperty.call(elementSrc, srcPath)) { - elementSrc[srcPath] = fs.readdirSync(srcPath) - } - + const matchingFiles = this._buildMatchingFiles(elementName) elementSrc[srcPath] - .filter(src => path.parse(src).name === parsedElementName.name) + .filter( + src => + (this.type === STATICRESOURCE_TYPE && + src.startsWith(path.parse(elementName).name)) || + matchingFiles.includes(src) + ) .forEach(src => this._copyFiles( path.normalize(path.join(srcPath, src)), @@ -70,6 +73,25 @@ class ResourceHandler extends StandardHandler { .replace(this.suffixRegex, '') ) } + + _buildMatchingFiles(elementName) { + const parsedElementName = path.parse(elementName).name + const matchingFiles = [parsedElementName] + if (StandardHandler.metadata[this.type].suffix) { + matchingFiles.push( + `${parsedElementName}.${StandardHandler.metadata[this.type].suffix}${ + mc.METAFILE_SUFFIX + }` + ) + } + return matchingFiles + } + + _buildElementMap(srcPath) { + if (!Object.prototype.hasOwnProperty.call(elementSrc, srcPath)) { + elementSrc[srcPath] = fs.readdirSync(srcPath) + } + } } module.exports = ResourceHandler