Skip to content

Commit 61b1f6a

Browse files
authored
chore: point user towards docs when they face an issue (#33)
* chore: point user towards docs when they face an issue * 0.8.1 * chore: point to integration specific docs
1 parent f366ad3 commit 61b1f6a

7 files changed

Lines changed: 43 additions & 17 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@posthog/wizard",
3-
"version": "0.8.0",
3+
"version": "0.8.1",
44
"homepage": "https://github.com/posthog/wizard",
55
"repository": "https://github.com/posthog/wizard",
66
"description": "The PostHog wizard helps you to configure your project",

src/nextjs/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import fg from 'fast-glob';
33
import { abortIfCancelled } from '../utils/clack-utils';
44
import clack from '../utils/clack';
55
import type { WizardOptions } from '../utils/types';
6+
import { Integration } from '../lib/constants';
67

78
export function getNextJsVersionBucket(version: string | undefined) {
89
if (!version) {
@@ -82,6 +83,7 @@ export async function getNextJsRouter({
8283
},
8384
],
8485
}),
86+
Integration.nextjs,
8587
);
8688

8789
return result;

src/run.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { analytics } from './utils/analytics';
1313
import { runSvelteWizard } from './svelte/svelte-wizard';
1414
import { runReactNativeWizard } from './react-native/react-native-wizard';
1515
import { EventEmitter } from 'events';
16+
import chalk from 'chalk';
1617

1718
EventEmitter.defaultMaxListeners = 50;
1819

@@ -54,21 +55,30 @@ async function runWizard(argv: Args) {
5455

5556
analytics.setTag('integration', integration);
5657

57-
switch (integration) {
58-
case Integration.nextjs:
59-
await runNextjsWizard(wizardOptions);
60-
break;
61-
case Integration.react:
62-
await runReactWizard(wizardOptions);
63-
break;
64-
case Integration.svelte:
65-
await runSvelteWizard(wizardOptions);
66-
break;
67-
case Integration.reactNative:
68-
await runReactNativeWizard(wizardOptions);
69-
break;
70-
default:
71-
clack.log.error('No setup wizard selected!');
58+
try {
59+
switch (integration) {
60+
case Integration.nextjs:
61+
await runNextjsWizard(wizardOptions);
62+
break;
63+
case Integration.react:
64+
await runReactWizard(wizardOptions);
65+
break;
66+
case Integration.svelte:
67+
await runSvelteWizard(wizardOptions);
68+
break;
69+
case Integration.reactNative:
70+
await runReactNativeWizard(wizardOptions);
71+
break;
72+
default:
73+
clack.log.error('No setup wizard selected!');
74+
}
75+
} catch (error) {
76+
clack.log.error(
77+
`Something went wrong. You can read the documentation for PostHog at ${chalk.cyan(
78+
`${INTEGRATION_CONFIG[integration].docsUrl}`,
79+
)} to setup PostHog manually.`,
80+
);
81+
process.exit(1);
7282
}
7383
}
7484

src/steps/add-editor-rules.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const addEditorRulesStep = async ({
4141
},
4242
],
4343
}),
44+
integration,
4445
);
4546

4647
if (!addEditorRules) {

src/steps/create-pr.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export async function createPRStep({
232232
},
233233
],
234234
}),
235+
integration,
235236
);
236237

237238
if (!createPR) {

src/steps/upload-environment-variables/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const uploadEnvironmentVariablesStep = async (
5555
},
5656
],
5757
}),
58+
integration,
5859
);
5960

6061
if (!upload) {

src/utils/clack-utils.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ import {
2121
DEFAULT_HOST_URL,
2222
DUMMY_PROJECT_API_KEY,
2323
ISSUES_URL,
24+
type Integration,
2425
} from '../lib/constants';
2526
import { analytics } from './analytics';
2627
import clack from './clack';
2728
import { getCloudUrlFromRegion } from './urls';
29+
import { INTEGRATION_CONFIG } from '../lib/config';
2830

2931
interface ProjectData {
3032
projectApiKey: string;
@@ -64,11 +66,20 @@ export async function abort(message?: string, status?: number): Promise<never> {
6466

6567
export async function abortIfCancelled<T>(
6668
input: T | Promise<T>,
69+
integration?: Integration,
6770
): Promise<Exclude<T, symbol>> {
6871
await analytics.shutdown('cancelled');
6972

7073
if (clack.isCancel(await input)) {
71-
clack.cancel('Wizard setup cancelled.');
74+
const docsUrl = integration
75+
? INTEGRATION_CONFIG[integration].docsUrl
76+
: 'https://posthog.com/docs';
77+
78+
clack.cancel(
79+
`Wizard setup cancelled. You can read the documentation for ${
80+
integration ?? 'PostHog'
81+
} at ${chalk.cyan(docsUrl)} to continue with the setup manually.`,
82+
);
7283
process.exit(0);
7384
} else {
7485
return input as Exclude<T, symbol>;

0 commit comments

Comments
 (0)