ToolJet/plugins/create-server-entry.js
Maurits Lourens 60f515d19c
Feature/2395 - add eslint to plugins (#2402)
* merge develop

* Add eslint dependencies, configs and scripts to plugins project

* run lint with Github action

* ignore tests and dist folders

* fun eslint with --fix and manual fixes, renamed __tests_ to __tests__

* add plugins packages folder to lint-staged config

* fix lint issue
2022-03-10 12:29:48 +05:30

19 lines
647 B
JavaScript

const { readdirSync, writeFileSync } = require('fs');
const packages = readdirSync('./packages', { withFileTypes: true }).filter(
(dirent) => dirent.isDirectory() && dirent.name !== 'common'
);
const imports = packages.map((dirent) => `import ${dirent.name} from './packages/${dirent.name}/lib'`);
imports.push(["import { QueryError, OAuthUnauthorizedClientError } from './packages/common/lib'"]);
const outs = `export default {\n${packages.map((dirent) => ` ${dirent.name}`).join(',\n')},
}`;
const content = `
${imports.join('\n')} \n
${outs}\n
export { QueryError, OAuthUnauthorizedClientError }
`;
writeFileSync('server.ts', content);