forked from DhanushNehru/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-server-entry.js
More file actions
27 lines (21 loc) · 871 Bytes
/
create-server-entry.js
File metadata and controls
27 lines (21 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);