2023-12-08 16:28:37 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const path = require( 'path' );
|
|
|
|
|
2024-05-09 09:52:03 +00:00
|
|
|
const extensionJson = require( '../extension.json' );
|
|
|
|
const modulesJson = require( '../lib/ve/build/modules.json' );
|
2023-12-08 16:28:37 +00:00
|
|
|
|
|
|
|
const ignored = [
|
|
|
|
'node_modules/',
|
|
|
|
'lib/',
|
|
|
|
'dist/',
|
|
|
|
'src/ve.track.js', // Re-implemented in MW
|
|
|
|
'src/ce/ve.ce.debug.js',
|
|
|
|
'tests/ve.qunit.local.js',
|
|
|
|
// Standalone / Demos
|
|
|
|
'demos/',
|
|
|
|
'src/init/sa/',
|
|
|
|
'tests/init/ve.init.sa.Platform.test.js',
|
|
|
|
'src/ui/dialogs/ve.ui.DiffDialog.js',
|
|
|
|
// Rebaser
|
|
|
|
'rebaser/',
|
|
|
|
'collab/',
|
|
|
|
'src/ve.FakePeer.js',
|
|
|
|
// TODO: Put these is a folder
|
|
|
|
'tests/ve.FakePeer.test.js',
|
|
|
|
'tests/dm/ve.dm.TransactionSquasher.test.js',
|
|
|
|
'tests/dm/ve.dm.RebaseServer.test.js',
|
|
|
|
'tests/dm/ve.dm.FakeMongo.js',
|
|
|
|
'tests/dm/ve.dm.FakeSocket.js',
|
|
|
|
'tests/dm/ve.dm.DocumentStore.test.js',
|
|
|
|
'tests/dm/ve.dm.TransportServer.test.js'
|
|
|
|
];
|
|
|
|
|
|
|
|
function addFilesToSet( files, set, basePath = '' ) {
|
|
|
|
if ( Array.isArray( files ) ) {
|
|
|
|
files.forEach( ( file ) => set.add( path.join( basePath, file.file || file ) ) );
|
|
|
|
} else if ( typeof files === 'string' ) {
|
|
|
|
set.add( path.join( basePath, files ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function isIgnored( filePath ) {
|
|
|
|
return ignored.some( ( ignorePath ) => {
|
|
|
|
const fullIgnorePath = path.join( 'lib/ve', ignorePath );
|
|
|
|
return filePath === fullIgnorePath || filePath.startsWith( fullIgnorePath );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
function addModulesToSet( modules, set, basePath = '' ) {
|
|
|
|
Object.values( modules ).forEach( ( module ) => {
|
|
|
|
[
|
|
|
|
'scripts',
|
|
|
|
'debugScripts',
|
|
|
|
'styles'
|
|
|
|
].forEach( ( property ) => {
|
|
|
|
if ( module[ property ] ) {
|
|
|
|
addFilesToSet( module[ property ], set, basePath );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
if ( module.skinStyles ) {
|
|
|
|
Object.values( module.skinStyles ).forEach( ( files ) => {
|
|
|
|
addFilesToSet( files, set, basePath );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkFiles() {
|
|
|
|
const extensionFiles = new Set();
|
|
|
|
addModulesToSet( extensionJson.ResourceModules, extensionFiles );
|
|
|
|
addModulesToSet( { QUnitTestModule: extensionJson.QUnitTestModule }, extensionFiles );
|
|
|
|
|
|
|
|
const modulesFiles = new Set();
|
|
|
|
addModulesToSet( modulesJson, modulesFiles, 'lib/ve' );
|
|
|
|
|
|
|
|
const missingFiles = Array.from( modulesFiles ).filter( ( file ) => {
|
|
|
|
return !extensionFiles.has( file ) && !isIgnored( file );
|
|
|
|
} );
|
|
|
|
|
|
|
|
if ( missingFiles.length ) {
|
2024-05-09 10:07:37 +00:00
|
|
|
console.error(
|
|
|
|
`${ missingFiles.length } file(s) from lib/ve/modules.json are missing from extension.json:\n\n` +
|
|
|
|
missingFiles.map( ( file ) => `* ${ file }\n` ).join( '' ) +
|
|
|
|
'\nIf any of these files are not required, add them to the ignore list in build/checkModules.js.'
|
|
|
|
);
|
|
|
|
// eslint-disable-next-line n/no-process-exit
|
|
|
|
process.exit( 1 );
|
2023-12-08 16:28:37 +00:00
|
|
|
} else {
|
|
|
|
console.log( 'No missing files.' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
checkFiles();
|