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
6 changes: 2 additions & 4 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ msevents sessions --tech "Microsoft Foundry"
msevents sessions --tech "Azure Cosmos DB" --type lab
msevents sessions --speaker "Scott Hanselman"
msevents sessions --tech "Microsoft Foundry" --speaker "Yina Arenas"
msevents sessions --event build-2025 --query "Foundry"
msevents sessions --event build-2026 --query "Foundry"
msevents session BRK155
msevents refresh
msevents refresh --event build-2026
Expand All @@ -49,7 +49,7 @@ Available commands:
- `--tech <name>` search by technology (matches product, tags, topic, languages)
- `--speaker <name>` search by speaker name
- `--type <type>` filter by session type (breakout, lab, demo, keynote)
- `--event <id>` filter to a specific event (e.g., `build-2026`, `ignite-2025`)
- `--event <id>` filter to a specific event (e.g., `ignite-2026`, `build-2026`)
- `--limit <n>` max results (default: 10)
- `session <code>` looks up a specific session by code. Searches all cached events; disambiguates if the code appears in multiple events.
- `--event <id>` scope to a specific event
Expand All @@ -71,8 +71,6 @@ msevents session BRK155 --json
|-------|----------|--------|
| Ignite 2026 | `ignite-2026` | Live |
| Build 2026 | `build-2026` | Live |
| Ignite 2025 | `ignite-2025` | Live |
| Build 2025 | `build-2025` | Live |

Use `--event <id>` to filter to a single event. Without it, commands search across everything cached.

Expand Down
4 changes: 2 additions & 2 deletions cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/events-cli",
"version": "0.3.2",
"version": "0.3.3",
"description": "CLI for searching Microsoft flagship event sessions (Build, Ignite).",
"type": "module",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion cli/scripts/smoke-fixture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { normalizeCatalog } from '../dist/data/normalize.js';
const execFileAsync = promisify(execFile);
const cliRoot = fileURLToPath(new URL('..', import.meta.url));
const commandTimeoutMs = 60_000;
const eventId = 'build-2025';
const eventId = 'build-2026';

function assert(condition, message) {
if (!condition) throw new Error(message);
Expand Down
6 changes: 3 additions & 3 deletions cli/scripts/smoke-m365-plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { normalizeCatalog } from '../dist/data/normalize.js';
const execFileAsync = promisify(execFile);
const cliRoot = fileURLToPath(new URL('..', import.meta.url));
const commandTimeoutMs = 60_000;
const eventId = 'build-2025';
const eventId = 'build-2026';
const isWindows = process.platform === 'win32';
const { values: options } = parseArgs({ options: { package: { type: 'boolean' } } });
const sourceSkillsDir = join(cliRoot, '..', 'skills');
Expand Down Expand Up @@ -207,9 +207,9 @@ try {
assert(statusText.stdout.startsWith('Offline (MSEVENTS_OFFLINE)'), `Expected an offline line in status:\n${statusText.stdout}`);
assert(!statusText.stdout.includes('last check failed'), 'Expected the frozen meta to drop the failed-check state');

const missing = await snapshot('sessions', '--query', 'agents', '--event', 'ignite-2025', '--json');
const missing = await snapshot('sessions', '--query', 'agents', '--event', 'ignite-2026', '--json');
assert(missing.code === 0 && JSON.parse(missing.stdout).length === 0, 'Expected no results for an event outside the snapshot');
assert(missing.stderr.includes('no cached sessions for Microsoft Ignite 2025'), `Expected a missing-event notice:\n${missing.stderr}`);
assert(missing.stderr.includes('no cached sessions for Microsoft Ignite 2026'), `Expected a missing-event notice:\n${missing.stderr}`);

const all = await snapshot('sessions', '--query', 'Foundry', '--json');
assert(all.code === 0 && JSON.parse(all.stdout).length > 0, 'Expected a search across all events to use the bundled event');
Expand Down
10 changes: 0 additions & 10 deletions cli/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import type { EventConfig } from './contracts.js';

export const KNOWN_EVENTS: EventConfig[] = [
{
id: 'build-2025',
name: 'Microsoft Build 2025',
endpoint: 'https://aka.ms/build2025-session-info',
},
{
id: 'ignite-2025',
name: 'Microsoft Ignite 2025',
endpoint: 'https://aka.ms/ignite2025-session-info',
},
{
id: 'build-2026',
name: 'Microsoft Build 2026',
Expand Down
70 changes: 21 additions & 49 deletions cli/test/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ describe('automatic cache revalidation', () => {
});

it('skips remote checks when all caches were checked recently', async () => {
await writeCachedEvent('build-2025');
await writeCachedEvent('ignite-2025');
await writeCachedEvent('build-2026');
const originalMeta = await readMeta('build-2026');
await writeCachedEvent('ignite-2026');
Expand All @@ -129,20 +127,18 @@ describe('automatic cache revalidation', () => {

expect(fetchMock).not.toHaveBeenCalled();
expect(await readMeta('build-2026')).toEqual(originalMeta);
expect(sessions.map((s) => s.event).sort()).toEqual(['build-2025', 'build-2026', 'ignite-2025', 'ignite-2026']);
expect(sessions.map((s) => s.event).sort()).toEqual(['build-2026', 'ignite-2026']);
});

it('uses conditional GET when a cached event is due for revalidation', async () => {
const fetchedAt = '2026-05-07T01:00:00.000Z';
await writeCachedEvent('build-2025', {
await writeCachedEvent('build-2026', {
fetchedAt,
checkedAt: '2026-05-07T01:00:00.000Z',
nextCheckAt: '2026-05-07T02:00:00.000Z',
etag: '"abc"',
lastModified: 'Thu, 07 May 2026 01:00:00 GMT',
});
await writeCachedEvent('ignite-2025');
await writeCachedEvent('build-2026');
await writeCachedEvent('ignite-2026');
const fetchMock = vi.fn().mockResolvedValue(new Response(null, { status: 304 }));
vi.stubGlobal('fetch', fetchMock);
Expand All @@ -156,7 +152,7 @@ describe('automatic cache revalidation', () => {
'If-Modified-Since': 'Thu, 07 May 2026 01:00:00 GMT',
});

const updatedMeta = await readMeta('build-2025');
const updatedMeta = await readMeta('build-2026');
expect(updatedMeta?.fetchedAt).toBe(fetchedAt);
expect(updatedMeta?.checkedAt).toBe(NOW);
expect(updatedMeta?.lastCheckStatus).toBe('not-modified');
Expand All @@ -165,42 +161,39 @@ describe('automatic cache revalidation', () => {
});

it('keeps stale cache usable and backs off when revalidation fails', async () => {
await writeCachedEvent('build-2025', {
await writeCachedEvent('build-2026', {
checkedAt: '2026-05-07T01:00:00.000Z',
nextCheckAt: '2026-05-07T02:00:00.000Z',
consecutiveFailures: 1,
});
await writeCachedEvent('ignite-2025');
await writeCachedEvent('build-2026');
await writeCachedEvent('ignite-2026');
const fetchMock = vi.fn().mockRejectedValue(new TypeError('network down'));
vi.stubGlobal('fetch', fetchMock);

await ensureCache();

const sessions = await getAllCachedSessions();
expect(sessions.some((s) => s.event === 'build-2025')).toBe(true);
expect(sessions.some((s) => s.event === 'build-2026')).toBe(true);

const updatedMeta = await readMeta('build-2025');
const updatedMeta = await readMeta('build-2026');
expect(updatedMeta?.lastCheckStatus).toBe('failed');
expect(updatedMeta?.consecutiveFailures).toBe(2);
expect(updatedMeta?.checkedAt).toBe(NOW);
expect(Date.parse(updatedMeta?.nextCheckAt ?? '')).toBeGreaterThan(Date.parse(NOW));
});

it('repairs missing metadata after failed revalidation so backoff still applies', async () => {
await writeSessionsOnly('build-2025');
await writeCachedEvent('ignite-2025');
await writeCachedEvent('build-2026');
await writeSessionsOnly('build-2026');
await writeCachedEvent('ignite-2026');
const fetchMock = vi.fn().mockRejectedValue(new TypeError('network down'));
vi.stubGlobal('fetch', fetchMock);

await ensureCache();

expect(fetchMock).toHaveBeenCalledTimes(1);
const repairedMeta = await readMeta('build-2025');
const repairedMeta = await readMeta('build-2026');
expect(repairedMeta).toMatchObject({
eventId: 'build-2025',
eventId: 'build-2026',
sessionCount: 1,
lastCheckStatus: 'failed',
consecutiveFailures: 1,
Expand All @@ -216,14 +209,6 @@ describe('automatic cache revalidation', () => {

it('fetches and caches missing events automatically', async () => {
const fetchMock = vi.fn()
.mockResolvedValueOnce(jsonResponse(
[{ sessionCode: 'BRK101', title: 'Build 2025 session' }],
{ etag: '"2025"', 'last-modified': 'Thu, 07 May 2026 02:55:00 GMT' },
))
.mockResolvedValueOnce(jsonResponse(
[{ sessionCode: 'IGN301', title: 'Ignite 2025 session' }],
{ etag: '"ign2025"', 'last-modified': 'Thu, 07 May 2026 02:55:30 GMT' },
))
.mockResolvedValueOnce(jsonResponse(
[{ sessionCode: 'BRK202', title: 'Build 2026 session' }],
{ etag: '"2026"', 'last-modified': 'Thu, 07 May 2026 02:56:00 GMT' },
Expand All @@ -237,7 +222,7 @@ describe('automatic cache revalidation', () => {
await ensureCache();

const sessions = await getAllCachedSessions();
expect(sessions.map((s) => s.sessionCode).sort()).toEqual(['BRK101', 'BRK202', 'IGN301', 'IGN401']);
expect(sessions.map((s) => s.sessionCode).sort()).toEqual(['BRK202', 'IGN401']);

const build2026Meta = await readMeta('build-2026');
expect(build2026Meta?.lastCheckStatus).toBe('updated');
Expand All @@ -261,40 +246,30 @@ describe('automatic cache revalidation', () => {
expect(fetchMock).not.toHaveBeenCalled();
expect(sessions.map((s) => s.sessionCode)).toEqual(['BRK202']);
expect(await readMeta('build-2026')).toEqual(originalMeta);
expect(existsSync(join(cacheDir, 'build-2025-sessions.json'))).toBe(false);
expect(existsSync(join(cacheDir, 'ignite-2025-sessions.json'))).toBe(false);
expect(existsSync(join(cacheDir, 'ignite-2026-sessions.json'))).toBe(false);
});

it('fetches a different scoped event without refreshing an existing scoped cache', async () => {
await writeCachedEvent('build-2026', {}, 'BRK202');
const originalBuild2026Meta = await readMeta('build-2026');
const fetchMock = vi.fn().mockResolvedValue(jsonResponse(
[{ sessionCode: 'BRK101', title: 'Build 2025 session' }],
{ etag: '"2025"', 'last-modified': 'Thu, 07 May 2026 02:55:00 GMT' },
[{ sessionCode: 'IGN401', title: 'Ignite 2026 session' }],
{ etag: '"ign2026"', 'last-modified': 'Thu, 07 May 2026 02:56:30 GMT' },
));
vi.stubGlobal('fetch', fetchMock);

const sessions = await ensureCache('build-2025');
const sessions = await ensureCache('ignite-2026');

expect(fetchMock).toHaveBeenCalledTimes(1);
expect(fetchMock.mock.calls[0]?.[0]).toBe('https://aka.ms/build2025-session-info');
expect(sessions.map((s) => s.sessionCode)).toEqual(['BRK101']);
expect(fetchMock.mock.calls[0]?.[0]).toBe('https://aka.ms/ignite2026-session-info');
expect(sessions.map((s) => s.sessionCode)).toEqual(['IGN401']);
expect(await readMeta('build-2026')).toEqual(originalBuild2026Meta);
expect(existsSync(join(cacheDir, 'ignite-2025-sessions.json'))).toBe(false);
});

it('reuses existing caches and fetches missing caches when loading all events', async () => {
await writeCachedEvent('build-2026', {}, 'BRK202');
const originalBuild2026Meta = await readMeta('build-2026');
const fetchMock = vi.fn()
.mockResolvedValueOnce(jsonResponse(
[{ sessionCode: 'BRK101', title: 'Build 2025 session' }],
{ etag: '"2025"', 'last-modified': 'Thu, 07 May 2026 02:55:00 GMT' },
))
.mockResolvedValueOnce(jsonResponse(
[{ sessionCode: 'IGN301', title: 'Ignite 2025 session' }],
{ etag: '"ign2025"', 'last-modified': 'Thu, 07 May 2026 02:55:30 GMT' },
))
.mockResolvedValueOnce(jsonResponse(
[{ sessionCode: 'IGN401', title: 'Ignite 2026 session' }],
{ etag: '"ign2026"', 'last-modified': 'Thu, 07 May 2026 02:56:30 GMT' },
Expand All @@ -303,13 +278,11 @@ describe('automatic cache revalidation', () => {

const sessions = await ensureCache();

expect(fetchMock).toHaveBeenCalledTimes(3);
expect(fetchMock).toHaveBeenCalledTimes(1);
expect(fetchMock.mock.calls.map(([url]) => url)).toEqual([
'https://aka.ms/build2025-session-info',
'https://aka.ms/ignite2025-session-info',
'https://aka.ms/ignite2026-session-info',
]);
expect(sessions.map((s) => s.sessionCode).sort()).toEqual(['BRK101', 'BRK202', 'IGN301', 'IGN401']);
expect(sessions.map((s) => s.sessionCode).sort()).toEqual(['BRK202', 'IGN401']);
expect(await readMeta('build-2026')).toEqual(originalBuild2026Meta);
});

Expand All @@ -326,12 +299,11 @@ describe('automatic cache revalidation', () => {
expect(fetchMock.mock.calls[0]?.[0]).toBe('https://aka.ms/build2026-session-info');
expect(sessions.map((s) => s.event)).toEqual(['build-2026']);
expect(existsSync(join(cacheDir, 'build-2026-sessions.json'))).toBe(true);
expect(existsSync(join(cacheDir, 'build-2025-sessions.json'))).toBe(false);
expect(existsSync(join(cacheDir, 'ignite-2025-sessions.json'))).toBe(false);
expect(existsSync(join(cacheDir, 'ignite-2026-sessions.json'))).toBe(false);
});

it('does not fall back to unrelated cached events when scoped cache loading fails', async () => {
await writeCachedEvent('build-2025');
await writeCachedEvent('ignite-2026');
const fetchMock = vi.fn().mockRejectedValue(new TypeError('network down'));
vi.stubGlobal('fetch', fetchMock);

Expand Down
24 changes: 12 additions & 12 deletions cli/test/offline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function session(event: string, sessionCode: string): Session {
}

const dueMeta: CacheMeta = {
eventId: 'build-2025',
eventId: 'build-2026',
fetchedAt: '2020-01-01T00:00:00.000Z',
checkedAt: '2020-01-01T00:00:00.000Z',
nextCheckAt: '2020-01-01T00:20:00.000Z',
Expand Down Expand Up @@ -77,8 +77,8 @@ describe('offline mode (MSEVENTS_OFFLINE)', () => {
vi.stubGlobal('fetch', fetchMock);
vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
vi.spyOn(console, 'error').mockImplementation(() => {});
await writeFile(join(cacheDir, 'build-2025-sessions.json'), JSON.stringify([session('build-2025', 'BRK100')]));
await writeFile(join(cacheDir, 'build-2025-meta.json'), JSON.stringify(dueMeta));
await writeFile(join(cacheDir, 'build-2026-sessions.json'), JSON.stringify([session('build-2026', 'BRK100')]));
await writeFile(join(cacheDir, 'build-2026-meta.json'), JSON.stringify(dueMeta));
});

afterEach(async () => {
Expand All @@ -91,33 +91,33 @@ describe('offline mode (MSEVENTS_OFFLINE)', () => {
});

it('reads cached sessions without revalidating a cache that is due', async () => {
const sessions = await ensureCache('build-2025');
const sessions = await ensureCache('build-2026');

expect(sessions.map((s) => s.sessionCode)).toEqual(['BRK100']);
expect(fetchMock).not.toHaveBeenCalled();
expect(stderrOutput()).toBe('');
expect(JSON.parse(await readFile(join(cacheDir, 'build-2025-meta.json'), 'utf-8'))).toEqual(dueMeta);
expect(JSON.parse(await readFile(join(cacheDir, 'build-2026-meta.json'), 'utf-8'))).toEqual(dueMeta);
});

it('skips events with no cache, notes them once, and writes nothing', async () => {
const sessions = await ensureCache();

expect(sessions.map((s) => s.sessionCode)).toEqual(['BRK100']);
expect(fetchMock).not.toHaveBeenCalled();
const uncached = KNOWN_EVENTS.filter((e) => e.id !== 'build-2025').map((e) => e.name);
const uncached = KNOWN_EVENTS.filter((e) => e.id !== 'build-2026').map((e) => e.name);
expect(uncached.length).toBeGreaterThan(0);
expect(stderrOutput()).toBe(`Offline (MSEVENTS_OFFLINE): no cached sessions for ${uncached.join(', ')}.\n`);
expect((await readdir(cacheDir)).sort()).toEqual(['build-2025-meta.json', 'build-2025-sessions.json']);
expect((await readdir(cacheDir)).sort()).toEqual(['build-2026-meta.json', 'build-2026-sessions.json']);
});

it('returns no sessions for an uncached event', async () => {
expect(await ensureCache('ignite-2025')).toEqual([]);
expect(await ensureCache('ignite-2026')).toEqual([]);
expect(fetchMock).not.toHaveBeenCalled();
expect(stderrOutput()).toContain('no cached sessions for Microsoft Ignite 2025');
expect(stderrOutput()).toContain('no cached sessions for Microsoft Ignite 2026');
});

it('makes refresh fail without fetching', async () => {
await refresh('build-2025', true);
await refresh('build-2026', true);

expect(process.exitCode).toBe(1);
expect(fetchMock).not.toHaveBeenCalled();
Expand All @@ -127,8 +127,8 @@ describe('offline mode (MSEVENTS_OFFLINE)', () => {

describe('formatStatus in offline mode', () => {
const statuses = [
{ eventId: 'build-2025', meta: { ...dueMeta, lastCheckStatus: 'updated' as const } },
{ eventId: 'ignite-2025', meta: null },
{ eventId: 'build-2026', meta: { ...dueMeta, lastCheckStatus: 'updated' as const } },
{ eventId: 'ignite-2026', meta: null },
];

it('adds an offline line to text output', () => {
Expand Down
4 changes: 2 additions & 2 deletions cli/test/validate-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('validateEventId', () => {
});

it('returns true for a known event ID', () => {
expect(validateEventId('build-2025')).toBe(true);
expect(validateEventId('build-2026')).toBe(true);
expect(process.exitCode).toBeUndefined();
expect(console.error).not.toHaveBeenCalled();
});
Expand All @@ -25,7 +25,7 @@ describe('validateEventId', () => {
expect.stringContaining('Unknown event: unknown-event'),
);
expect(console.error).toHaveBeenCalledWith(
expect.stringContaining('build-2025'),
expect.stringContaining('build-2026'),
);
});
});
Loading