-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtsup.config.ts
More file actions
52 lines (48 loc) · 1.69 KB
/
Copy pathtsup.config.ts
File metadata and controls
52 lines (48 loc) · 1.69 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
51
52
import { copyFileSync, mkdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { defineConfig } from 'tsup';
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8')) as { version: string };
const outDir = 'dist';
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm'],
target: 'node18',
outDir,
clean: true,
sourcemap: process.env.CI !== 'true',
dts: true,
splitting: false,
banner: {
js: '#!/usr/bin/env node',
},
define: {
'process.env.POSTHOG_API_KEY': JSON.stringify(process.env.POSTHOG_API_KEY || ''),
'process.env.CLI_VERSION': JSON.stringify(pkg.version),
},
esbuildPlugins: [
{
name: 'copy-assets',
setup(build) {
build.onEnd((result) => {
if (result.errors.length > 0) return;
const assetsDir = join(outDir, 'assets');
mkdirSync(assetsDir, { recursive: true });
copyFileSync('src/assets/forger.json', join(assetsDir, 'forger.json'));
// Compose files for `insforge local start`. They reference only
// published images and named volumes, so they run correctly from
// inside the installed package.
const localDir = join(assetsDir, 'local');
mkdirSync(localDir, { recursive: true });
for (const file of [
// The stack comes from InsForge's repository via its setup.sh. The
// only compose the CLI ships is the overlay carrying the telemetry
// stamp — see src/lib/local/checkout.ts.
'cli-overlay.yml',
]) {
copyFileSync(join('src/assets/local', file), join(localDir, file));
}
});
},
},
],
});