-
Notifications
You must be signed in to change notification settings - Fork 4
/
esbuild.package.js
57 lines (54 loc) · 1.75 KB
/
esbuild.package.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const fs = require('fs');
const path = require('path');
const esbuild = require('esbuild');
const { clean } = require('esbuild-plugin-clean');
const { copyFolderFiles, addReleaseFlag } = require('@hackolade/hck-esbuild-plugins-pack');
const { EXCLUDED_EXTENSIONS, EXCLUDED_FILES, DEFAULT_RELEASE_FOLDER_PATH } = require('./buildConstants');
const packageData = JSON.parse(fs.readFileSync('./package.json').toString());
const RELEASE_FOLDER_PATH = path.join(DEFAULT_RELEASE_FOLDER_PATH, `${packageData.name}-${packageData.version}`);
const copyTeradataClient = () => ({
name: 'copyTeradataClient',
setup(build) {
build.onEnd(async () => {
try {
await fs.promises.cp(
path.resolve(__dirname, 'reverse_engineering', 'addons', 'TeradataClient.jar'),
path.join(RELEASE_FOLDER_PATH, 'addons', 'TeradataClient.jar'),
{ force: true },
);
} catch (err) {
// eslint-disable-next-line no-console
console.error('Copy TeradataClient.jar failed with:', err);
}
});
},
});
esbuild
.build({
entryPoints: [
path.resolve(__dirname, 'forward_engineering', 'api.js'),
path.resolve(__dirname, 'forward_engineering', 'ddlProvider.js'),
path.resolve(__dirname, 'reverse_engineering', 'api.js'),
],
bundle: true,
keepNames: true,
platform: 'node',
target: 'node18',
outdir: RELEASE_FOLDER_PATH,
minify: true,
logLevel: 'info',
plugins: [
clean({
patterns: [DEFAULT_RELEASE_FOLDER_PATH],
}),
copyFolderFiles({
fromPath: __dirname,
targetFolderPath: RELEASE_FOLDER_PATH,
excludedExtensions: EXCLUDED_EXTENSIONS,
excludedFiles: ['TeradataClient', ...EXCLUDED_FILES],
}),
copyTeradataClient(),
addReleaseFlag(path.resolve(RELEASE_FOLDER_PATH, 'package.json')),
],
})
.catch(() => process.exit(1));