Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@miakapp/cli",
"version": "4.0.0-alpha.8",
"version": "4.0.0-alpha.9",
"description": "Agent-first Miakapp command line: check, build, publish, activate and roll back home interfaces",
"type": "module",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function packageJson(home: string, artifact: string): string {
scripts: {
build: `bun build app/main.ts --format=iife --minify --outfile ${artifact}`,
typecheck: 'tsc --noEmit',
check: 'bun run build && miakapp check',
check: 'bun run build && node ./node_modules/@miakapp/cli/bin/miakapp.js check',
},
devDependencies: {
[PACKAGE_NAME]: CLI_VERSION,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
*/
export const PACKAGE_NAME = '@miakapp/cli';

export const CLI_VERSION = '4.0.0-alpha.8';
export const CLI_VERSION = '4.0.0-alpha.9';
21 changes: 20 additions & 1 deletion packages/cli/test/starter.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises';
import { chmod, symlink, mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { runInNewContext } from 'node:vm';
Expand Down Expand Up @@ -264,6 +264,25 @@ describe('the generated starter builds, typechecks, checks and runs', () => {
expect(host.json()).toMatchObject({ abi: 'miakapp.app/1', home_id: 'demo-home' });
});

test('the generated check uses its local CLI even when PATH contains an older global CLI', async () => {
const shadow = join(directory, 'shadow-bin');
await mkdir(shadow);
await writeFile(join(shadow, 'miakapp'), '#!/bin/sh\necho stale-global-cli >&2\nexit 81\n');
await chmod(join(shadow, 'miakapp'), 0o755);
await mkdir(join(directory, 'node_modules/@miakapp'), { recursive: true });
await symlink(join(REPOSITORY, 'packages/cli'), join(directory, 'node_modules/@miakapp/cli'), 'dir');
const pkg = JSON.parse(await readFile(join(directory, 'package.json'), 'utf8')) as { scripts: Record<string, string> };
const result = Bun.spawnSync(['sh', '-c', pkg.scripts['check']!], {
cwd: directory,
env: { ...process.env, PATH: `${shadow}:${process.env['PATH'] ?? ''}` },
stdout: 'pipe', stderr: 'pipe',
});
const output = result.stdout.toString() + result.stderr.toString();
expect(output).not.toContain('stale-global-cli');
expect(output).toContain('miakapp.app/1');
expect(result.exitCode).toBe(0);
});

test('with nothing shared it shows an honest empty state and no value', () => {
const fixture = frame({});
runInNewContext(bundle, fixture.context);
Expand Down
Loading