2021-09-04 14:43:25 +02:00
|
|
|
const utils = require('../utils');
|
|
|
|
const glob = require('glob');
|
|
|
|
const rootDir = utils.rootDir();
|
|
|
|
|
|
|
|
async function processDirectory(dir) {
|
2021-09-04 15:36:52 +02:00
|
|
|
const tsFiles = glob.sync('{**/*.ts,**/*.tsx}', {
|
2021-09-04 14:43:25 +02:00
|
|
|
cwd: dir,
|
|
|
|
}).filter(f => f !== 'index.ts');
|
|
|
|
|
2023-07-01 13:56:34 +02:00
|
|
|
tsFiles.sort();
|
|
|
|
|
2021-09-04 14:43:25 +02:00
|
|
|
const fileContent = [];
|
|
|
|
|
|
|
|
for (const tsFile of tsFiles) {
|
2021-09-04 16:15:25 +02:00
|
|
|
const f = utils.getFilename(tsFile);
|
2021-09-04 14:43:25 +02:00
|
|
|
fileContent.push(`import * as ${f} from './${f}';`);
|
|
|
|
}
|
|
|
|
|
|
|
|
fileContent.push('');
|
|
|
|
|
|
|
|
fileContent.push('const index:any[] = [');
|
|
|
|
|
|
|
|
for (const tsFile of tsFiles) {
|
2021-09-04 16:15:25 +02:00
|
|
|
const f = utils.getFilename(tsFile);
|
2021-09-04 14:43:25 +02:00
|
|
|
fileContent.push(`\t${f},`);
|
|
|
|
}
|
|
|
|
|
|
|
|
fileContent.push('];');
|
|
|
|
|
|
|
|
fileContent.push('');
|
|
|
|
|
|
|
|
fileContent.push('export default index;');
|
|
|
|
|
|
|
|
const destFile = `${dir}/index.ts`;
|
|
|
|
|
|
|
|
console.info(`Generating ${destFile}...`);
|
|
|
|
|
|
|
|
await utils.insertContentIntoFile(
|
|
|
|
destFile,
|
|
|
|
'// AUTO-GENERATED using `gulp buildCommandIndex`',
|
|
|
|
fileContent.join('\n'),
|
2023-08-22 12:58:53 +02:00
|
|
|
true,
|
2021-09-04 14:43:25 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
src: '',
|
|
|
|
fn: async function() {
|
|
|
|
await processDirectory(`${rootDir}/packages/app-desktop/commands`);
|
|
|
|
await processDirectory(`${rootDir}/packages/app-desktop/gui/MainScreen/commands`);
|
|
|
|
await processDirectory(`${rootDir}/packages/app-desktop/gui/NoteEditor/commands`);
|
|
|
|
await processDirectory(`${rootDir}/packages/app-desktop/gui/NoteList/commands`);
|
|
|
|
await processDirectory(`${rootDir}/packages/app-desktop/gui/NoteListControls/commands`);
|
|
|
|
await processDirectory(`${rootDir}/packages/app-desktop/gui/Sidebar/commands`);
|
|
|
|
await processDirectory(`${rootDir}/packages/lib/commands`);
|
|
|
|
},
|
|
|
|
};
|