diff --git a/bun.lock b/bun.lock index 2936597..cbaa9c1 100644 --- a/bun.lock +++ b/bun.lock @@ -1,6 +1,5 @@ { "lockfileVersion": 1, - "configVersion": 0, "workspaces": { "": { "name": "miakapi", diff --git a/packages/cli/package.json b/packages/cli/package.json index 6d6f04f..ece0c59 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@miakapp/cli", - "version": "4.0.0-alpha.3", + "version": "4.0.0-alpha.4", "description": "Agent-first Miakapp command line: check, build, publish, activate and roll back home components", "type": "module", "engines": { @@ -20,6 +20,7 @@ "sideEffects": false, "scripts": { "build": "tsc -p tsconfig.build.json", + "prepack": "bun run build", "test": "bun test test/", "typecheck": "tsc --noEmit", "check": "bun run typecheck && bun run build && bun run test" diff --git a/packages/cli/src/version.ts b/packages/cli/src/version.ts index f3f814f..41544e8 100644 --- a/packages/cli/src/version.ts +++ b/packages/cli/src/version.ts @@ -12,4 +12,4 @@ */ export const PACKAGE_NAME = '@miakapp/cli'; -export const CLI_VERSION = '4.0.0-alpha.3'; +export const CLI_VERSION = '4.0.0-alpha.4'; diff --git a/packages/cli/test/package.test.ts b/packages/cli/test/package.test.ts new file mode 100644 index 0000000..9e05137 --- /dev/null +++ b/packages/cli/test/package.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, test } from 'bun:test'; +import { resolve } from 'node:path'; + +const PACKAGE_DIRECTORY = resolve(import.meta.dir, '..'); +const manifest = (await Bun.file(new URL('../package.json', import.meta.url)).json()) as { + scripts?: Record; +}; + +interface PackResult { + files: Array<{ path: string }>; +} + +describe('the published package', () => { + test('builds the executable payload during prepack', () => { + expect(manifest.scripts?.['prepack']).toBe('bun run build'); + + const build = Bun.spawnSync(['bun', 'run', 'build'], { + cwd: PACKAGE_DIRECTORY, + stdout: 'pipe', + stderr: 'pipe', + }); + expect(build.exitCode).toBe(0); + + const packed = Bun.spawnSync( + ['npm', 'pack', '--dry-run', '--ignore-scripts', '--json'], + { + cwd: PACKAGE_DIRECTORY, + stdout: 'pipe', + stderr: 'pipe', + }, + ); + expect(packed.exitCode).toBe(0); + + const results = JSON.parse(packed.stdout.toString()) as PackResult[]; + const files = results[0]?.files.map(({ path }) => path).sort() ?? []; + expect(files).toContain('assets/agent-guide.md'); + expect(files).toContain('bin/miakapp.js'); + expect(files).toContain('dist/main.js'); + }); +});