Initial Drupal 11 with DDEV setup

This commit is contained in:
gluebox
2025-10-08 11:39:17 -04:00
commit 89ef74b305
25344 changed files with 2599172 additions and 0 deletions

View File

@ -0,0 +1,64 @@
/**
* @file
* Callback returning the list of files to copy to the assets/vendor directory.
*/
const { globSync } = require('glob');
// There are a lot of CKEditor 5 packages, generate the list dynamically.
// Drupal-specific mapping between CKEditor 5 name and Drupal library name.
const ckeditor5PluginMapping = {
'block-quote': 'blockquote',
'basic-styles': 'basic',
};
/**
* Build the list of assets to be copied based on what exists in the filesystem.
*
* @param {string} packageFolder
* The path to node_modules folder.
*
* @return {DrupalLibraryAsset[]}
* List of libraries and files to process.
*/
module.exports = (packageFolder) => {
const fileList = [];
// Get all the CKEditor 5 packages.
const ckeditor5Dirs = globSync(`{${packageFolder}/@ckeditor/ckeditor5*,${packageFolder}/ckeditor5}`).sort();
for (const ckeditor5package of ckeditor5Dirs) {
// Add all the files in the build/ directory to the process array for
// copying.
const buildFiles = globSync(`${ckeditor5package}/build/**/*.js`, {
nodir: true,
});
if (buildFiles.length) {
// Clean up the path to get the original package name.
const pack = ckeditor5package.replace(`${packageFolder}/`, '');
// Use the package name to generate the plugin name. There are some
// exceptions that needs to be handled. Ideally remove the special cases.
let pluginName = pack.replace('@ckeditor/ckeditor5-', '');
// Target folder in the vendor/assets folder.
let folder = `ckeditor5/${pluginName.replace('@ckeditor/ckeditor5-', '')}`;
// Transform kebab-case to CamelCase.
let library = pluginName.replace(/-./g, (match) => match[1].toUpperCase());
// Special case for Drupal implementation.
if (ckeditor5PluginMapping.hasOwnProperty(pluginName)) {
library = ckeditor5PluginMapping[pluginName];
}
if (library === 'ckeditor5') {
folder = 'ckeditor5/ckeditor5-dll';
} else {
library = `ckeditor5.${library}`;
}
fileList.push({
pack,
library,
folder,
files: buildFiles.map((absolutePath) => ({
from: absolutePath.replace(`${ckeditor5package}/`, ''),
to: absolutePath.replace(`${ckeditor5package}/build/`, ''),
})),
});
}
}
return fileList;
};

View File

@ -0,0 +1,47 @@
const Terser = require('terser');
const path = require('node:path');
/**
* Process jQuery UI source files.
*
* Each file being processed creates 3 files under assets/vendor/jquery.ui/:
* - The original source for audit purposes, with a `.js` suffix.
* - The minified version for production use, with a `-min.js` suffix.
* - The source map for debugging purposes, with a `-min.js.map` suffix.
*
* @param {object} data
* Object passed to the callback.
* @param {object} data.file
* Normalized file information object.
* @param {string} data.file.from
* Path of the file in node_modules/ directory.
* @param {string} data.file.to
* Path of the file in core assets/vendor/ directory.
* @param {string} data.contents
* Content of the file being processed.
*
* @return {Promise<[{filename: string, contents: string}]>}
* Return a Promise that resolves into an array of file and content to create
* in the assets/vendor/ directory.
*/
module.exports = async ({ file: { from, to }, contents }) => {
const filename = `${to.slice(0, -3)}-min.js`;
const sourcemap = `${filename}.map`;
const { code, map } = await Terser.minify(
{ [path.basename(from)]: contents }, {
sourceMap: {
filename: path.basename(filename),
url: path.basename(sourcemap),
},
});
return [
// Original file.
{ filename: to, contents },
// Minified file.
{ filename, contents: code },
// Sourcemap file.
{ filename: sourcemap, contents: map },
];
};

View File

@ -0,0 +1,20 @@
/**
* Process map files.
*
* In the `sources` member, remove all "../" values at the start of the file
* names to avoid virtual files located outside of the library vendor folder.
*
* @param {object} data
* Object passed to the callback.
* @param {string} data.contents
* Content of the file being processed.
*
* @return {Promise<[{contents: string}]>}
* Return a Promise that resolves into an array of file and content to create
* in the assets/vendor/ directory.
*/
module.exports = ({ contents }) => {
const json = JSON.parse(contents);
json.sources = json.sources.map((source) => source.replace(/^(\.\.\/)+/, ''));
return [{ contents: JSON.stringify(json) }];
};