forked from freee/freee-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
50 lines (44 loc) · 1.56 KB
/
Copy pathbuild.ts
File metadata and controls
50 lines (44 loc) · 1.56 KB
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
import { dependencies, version } from './package.json';
import { chmod, copyFile, mkdir, readdir } from 'fs/promises';
import { join } from 'path';
const entries = [
{ entrypoint: 'src/index.ts', output: './bin/freee-mcp.js' },
{ entrypoint: 'src/entry-remote.ts', output: './bin/freee-remote-mcp.js' },
{ entrypoint: 'src/sign/index.ts', output: './bin/freee-sign-mcp.js' },
{ entrypoint: 'src/sign/entry-remote.ts', output: './bin/freee-sign-remote-mcp.js' },
];
for (const { entrypoint, output } of entries) {
const result = await Bun.build({
entrypoints: [entrypoint],
external: Object.keys(dependencies),
minify: true,
target: 'node',
format: 'esm',
outdir: '.',
naming: { entry: output },
define: {
__PACKAGE_VERSION__: JSON.stringify(version),
},
banner: '#! /usr/bin/env node\n',
});
if (!result.success) {
console.error(`Build failed for ${entrypoint}:`);
for (const log of result.logs) {
console.error(log);
}
process.exit(1);
}
await chmod(output, 0o755);
console.log(`Built ${output}`);
}
// Copy minimal schema files to dist for npm package
const minimalSrcDir = './openapi/minimal';
const minimalDestDir = './dist/openapi/minimal';
await mkdir(minimalDestDir, { recursive: true });
const minimalFiles = await readdir(minimalSrcDir);
for (const file of minimalFiles) {
if (file.endsWith('.json')) {
await copyFile(join(minimalSrcDir, file), join(minimalDestDir, file));
}
}
console.log(`Copied ${minimalFiles.filter(f => f.endsWith('.json')).length} minimal schema files to dist/`);