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
49 changes: 1 addition & 48 deletions bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ if (!satisfies(process.version, NODE_VERSION_RANGE)) {
import { runMCPInstall, runMCPRemove } from './src/mcp';
import type { CloudRegion, WizardOptions } from './src/utils/types';
import { runWizard } from './src/run';
import { runEventSetupWizard } from './src/nextjs/event-setup';
import {
readEnvironment,
isNonInteractiveEnvironment,
} from './src/utils/environment';
import path from 'path';
import { isNonInteractiveEnvironment } from './src/utils/environment';
import clack from './src/utils/clack';

if (isNonInteractiveEnvironment()) {
Expand Down Expand Up @@ -113,48 +108,6 @@ yargs(hideBin(process.argv))
void runWizard(options as unknown as WizardOptions);
},
)
.command(
'event-setup',
'Run the event setup wizard',
(yargs) => {
return yargs.options({
'install-dir': {
describe:
'Directory to run the wizard in\nenv: POSTHOG_WIZARD_INSTALL_DIR',
type: 'string',
},
});
},
(argv) => {
const finalArgs = {
...argv,
...readEnvironment(),
} as any;

let resolvedInstallDir: string;
if (finalArgs.installDir) {
if (path.isAbsolute(finalArgs.installDir)) {
resolvedInstallDir = finalArgs.installDir;
} else {
resolvedInstallDir = path.join(process.cwd(), finalArgs.installDir);
}
} else {
resolvedInstallDir = process.cwd();
}

const wizardOptions: WizardOptions = {
debug: finalArgs.debug ?? false,
installDir: resolvedInstallDir,
cloudRegion: finalArgs.region as CloudRegion | undefined,
default: finalArgs.default ?? false,
signup: finalArgs.signup ?? false,
forceInstall: false,
localMcp: finalArgs.localMcp ?? false,
};

void runEventSetupWizard(wizardOptions);
},
)
.command('mcp <command>', 'MCP server management commands', (yargs) => {
return yargs
.command(
Expand Down
11 changes: 5 additions & 6 deletions src/__tests__/run.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { runWizard } from '../run';
import { runNextjsWizard } from '../nextjs/nextjs-wizard';
import { runNextjsWizardAgent } from '../nextjs/nextjs-wizard-agent';
import { analytics } from '../utils/analytics';
import { Integration } from '../lib/constants';

jest.mock('../nextjs/nextjs-wizard');
jest.mock('../nextjs/nextjs-wizard-agent');
jest.mock('../utils/analytics');
jest.mock('../utils/clack');

const mockRunNextjsWizard = runNextjsWizard as jest.MockedFunction<
typeof runNextjsWizard
const mockRunNextjsWizardAgent = runNextjsWizardAgent as jest.MockedFunction<
typeof runNextjsWizardAgent
>;
const mockAnalytics = analytics as jest.Mocked<typeof analytics>;

Expand Down Expand Up @@ -38,7 +37,7 @@ describe('runWizard error handling', () => {
forceInstall: false,
};

mockRunNextjsWizard.mockRejectedValue(testError);
mockRunNextjsWizardAgent.mockRejectedValue(testError);

await expect(runWizard(testArgs)).rejects.toThrow('process.exit called');

Expand All @@ -53,7 +52,7 @@ describe('runWizard error handling', () => {
it('should not call captureException when wizard succeeds', async () => {
const testArgs = { integration: Integration.nextjs };

mockRunNextjsWizard.mockResolvedValue(undefined);
mockRunNextjsWizardAgent.mockResolvedValue(undefined);

await runWizard(testArgs);

Expand Down
9 changes: 0 additions & 9 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ export enum Integration {
astro = 'astro',
}

export enum FeatureFlagDefinition {
NextV2 = 'wizard-next-v2',
}

export enum WizardVariant {
Legacy = 'legacy',
Agent = 'agent',
}

export function getIntegrationDescription(type: string): string {
switch (type) {
case Integration.nextjs:
Expand Down
6 changes: 6 additions & 0 deletions src/lib/framework-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export interface FrameworkMetadata {
/** Message shown when user declines AI consent */
abortMessage: string;

/**
* Optional URL to docs for users with unsupported framework versions.
* If not provided, defaults to docsUrl.
*/
unsupportedVersionDocsUrl?: string;

/**
* Optional function to gather framework-specific context before agent runs.
* For Next.js: detects router type
Expand Down
Loading
Loading