Skip to content

Commit

Permalink
Update settings.json, add "provideAssets" propertie
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Sep 25, 2018
1 parent 2fb4520 commit b16aaf2
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 32 deletions.
73 changes: 69 additions & 4 deletions build/build-modules-js/settings.json
Expand Up @@ -71,8 +71,9 @@
"awesomplete.min.js.map": "js/awesomplete.min.js.map",
"awesomplete.css.map": "css/awesomplete.css.map"
},
"assetsInfo": [
"provideAssets": [
{
"name": null,
"js": ["awesomplete.min.js"],
"css": ["awesomplete.css"]
}
Expand Down Expand Up @@ -119,6 +120,13 @@
"dist/cropper.css": "css/cropper.css",
"dist/cropper.min.css": "css/cropper.min.css"
},
"provideAssets": [
{
"name": null,
"js": ["cropper.min.js"],
"css": ["cropper.min.css"]
}
],
"dependencies": [],
"licenseFilename": "LICENSE"
},
Expand All @@ -128,6 +136,12 @@
"dist/diff.js": "js/diff.js",
"dist/diff.min.js": "js/diff.min.js"
},
"provideAssets": [
{
"name": null,
"js": ["diff.js"]
}
],
"dependencies": [],
"licenseFilename": "LICENSE"
},
Expand All @@ -141,6 +155,13 @@
"dist/dragula.css": "css/dragula.css",
"dist/dragula.min.css": "css/dragula.min.css"
},
"provideAssets": [
{
"name": null,
"js": ["dragula.min.js"],
"css": ["dragula.min.css"]
}
],
"dependencies": [],
"licenseFilename": "license"
},
Expand All @@ -151,6 +172,12 @@
"dist/focus-visible.min.js": "js/focus-visible.min.js",
"dist/focus-visible.min.js.map": "js/focus-visible.min.js.map"
},
"provideAssets": [
{
"name": null,
"js": ["focus-visible.min.js"]
}
],
"dependencies": [],
"licenseFilename": "LICENSE.md"
},
Expand All @@ -165,6 +192,12 @@
"scss": "scss",
"fonts": "fonts"
},
"provideAssets": [
{
"name": null,
"css": ["font-awesome.min.css"]
}
],
"dependencies": [],
"licenseFilename": ""
},
Expand All @@ -177,8 +210,11 @@
"filesExtra": {
"dist/jquery.min.map": "js/jquery.min.map"
},
"include": [
"jquery-migrate"
"provideAssets": [
{
"name": null,
"js": ["jquery.min.js"]
}
],
"dependencies": [],
"licenseFilename": "LICENSE.txt"
Expand All @@ -189,6 +225,13 @@
"dist/jquery-migrate.js": "js/jquery-migrate.js",
"dist/jquery-migrate.min.js": "js/jquery-migrate.min.js"
},
"provideAssets": [
{
"name": null,
"js": ["jquery-migrate.min.js"],
"dependencies": ["jquery"]
}
],
"dependencies": [
"jquery"
],
Expand Down Expand Up @@ -246,6 +289,12 @@
"js": {
"punycode.js": "js/punycode.js"
},
"provideAssets": [
{
"name": null,
"js": ["punycode.js"]
}
],
"dependencies": [],
"licenseFilename": "LICENSE-MIT.txt"
},
Expand All @@ -261,6 +310,14 @@
"filesExtra": {
"jquery.minicolors.png": "css/jquery.minicolors.png"
},
"provideAssets": [
{
"name": null,
"js": ["jquery.minicolors.min.j"],
"css": ["jquery.minicolors.css"],
"dependencies": ["jquery"]
}
],
"dependencies": [
"jquery"
],
Expand Down Expand Up @@ -303,7 +360,15 @@
"chosen.css": "css/chosen.css",
"chosen-sprite.png": "css/chosen-sprite.png",
"chosen-sprite@2x.png": "css/chosen-sprite@2x.png"
}
},
"provideAssets": [
{
"name": null,
"js": ["chosen.jquery.js"],
"css": ["chosen.css"],
"dependencies": ["jquery"]
}
]
}
},
"errorPages": {
Expand Down
55 changes: 27 additions & 28 deletions build/build-modules-js/update.js
Expand Up @@ -190,15 +190,7 @@ const copyFiles = (options) => {
if (!vendor[type]) return;

const dest = Path.join(mediaVendorPath, vendorName);
const files = copyFilesTo(vendor[type], modulePathRoot, dest, type);

// // Add to registry, in format suported by JHtml
// if (type === 'js' || type === 'css') {
// registryItem[type] = [];
// files.forEach((filePath) => {
// registryItem[type].push(`vendor/${vendorName}/${Path.basename(filePath)}`);
// });
// }
copyFilesTo(vendor[type], modulePathRoot, dest, type);
});

// Copy the license if exists
Expand All @@ -210,23 +202,6 @@ const copyFiles = (options) => {
}
}

// Add Assets to registry, if any
if (vendor.assetsInfo && vendor.assetsInfo.length) {
vendor.assetsInfo.forEach((assetInfo) => {

const registryItem = {
package: packageName,
name: assetInfo.name || vendorName,
version: moduleOptions.version,
dependencies: assetInfo.dependencies || [],
js: assetInfo.js || [],
css: assetInfo.css || [],
};

registry.assets[registryItem.name] = registryItem;
});
}

// Joomla's hack to expose the chosen base classes so we can extend it ourselves (it was better than the
// many hacks we had before. But I'm still ashamed of myself.
if (packageName === 'chosen-js') {
Expand All @@ -239,6 +214,30 @@ const copyFiles = (options) => {
fs.writeFileSync(chosenPath, ChosenJs, { encoding: 'UTF-8' });
}

// Add provided Assets to a registry, if any
if (vendor.provideAssets && vendor.provideAssets.length) {
vendor.provideAssets.forEach((assetInfo) => {

const registryItem = {
package: packageName,
name: assetInfo.name || vendorName,
version: moduleOptions.version,
dependencies: assetInfo.dependencies || [],
js: [],
css: [],
};

assetInfo.js && assetInfo.js.length && assetInfo.js.forEach((assetJS) => {
registryItem.js.push(`vendor/${vendorName}/${assetJS}`);
});
assetInfo.css && assetInfo.css.length && assetInfo.css.forEach((assetCSS) => {
registryItem.css.push(`vendor/${vendorName}/${assetCSS}`);
});

registry.assets[registryItem.name] = registryItem;
});
}

// eslint-disable-next-line no-console
console.log(`${packageName} was updated.`);
}
Expand Down Expand Up @@ -326,8 +325,8 @@ const copyAssets = (options) => {
Promise.resolve()
// Copy a fresh version of the files
.then(cleanVendors())
//
// // Copy a fresh version of the files

// Copy a fresh version of the files
.then(recreateMediaFolder())

// Copy a fresh version of the files
Expand Down

0 comments on commit b16aaf2

Please sign in to comment.