ToolJet/plugins/create-server-entry.js
Midhun G S c7d164c1c8
Added configuration to select plugins (#3024)
* Added configs to select plugins

* moving the configs to

* removing private from common

* fix

* removed if-env

* Fix

* docker compose changes

* review comments

* remove plugin build file

* revert docker file changes

* netlify changes

* netlify configs

* build script changes

* build script changes

* dockerfile changes

* add prebuild script
2022-05-20 19:32:46 +05:30

27 lines
871 B
JavaScript

const { readdirSync, writeFileSync } = require('fs');
const isPrivatePackage = (name) => {
if (process.env.NODE_ENV === 'production') {
return false;
}
const pkg = require(`./packages/${name}/package.json`);
return pkg.private;
};
const packages = readdirSync('./packages', { withFileTypes: true }).filter(
(dirent) => dirent.isDirectory() && dirent.name !== 'common' && !isPrivatePackage(dirent.name)
);
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);