@posthog/wizard 1.27.1 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/flask/flask-wizard-agent.d.ts +5 -0
- package/dist/src/flask/flask-wizard-agent.js +160 -0
- package/dist/src/flask/flask-wizard-agent.js.map +1 -0
- package/dist/src/flask/utils.d.ts +28 -0
- package/dist/src/flask/utils.js +363 -0
- package/dist/src/flask/utils.js.map +1 -0
- package/dist/src/lib/agent-interface.js +14 -1
- package/dist/src/lib/agent-interface.js.map +1 -1
- package/dist/src/lib/agent-runner.js +6 -0
- package/dist/src/lib/agent-runner.js.map +1 -1
- package/dist/src/lib/config.d.ts +12 -1
- package/dist/src/lib/config.js +79 -0
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/constants.d.ts +2 -1
- package/dist/src/lib/constants.js +3 -0
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/run.js +6 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/utils/anthropic-status.d.ts +28 -0
- package/dist/src/utils/anthropic-status.js +101 -0
- package/dist/src/utils/anthropic-status.js.map +1 -0
- package/package.json +1 -1
package/dist/src/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":";;;;;AAwCA,8BAqGC;AA7ID,qDAAuD;AAEvD,sEAAoE;AAGpE,+CAIyB;AACzB,qDAAsD;AACtD,0DAAkC;AAClC,gDAAwB;AACxB,yCAAqE;AACrE,uDAAsD;AACtD,iDAA8C;AAC9C,0DAAyD;AACzD,4EAA0E;AAC1E,uDAAsD;AACtD,wFAAqF;AACrF,sEAAoE;AACpE,mCAAsC;AACtC,kDAA0B;AAC1B,2CAAgD;AAEhD,qBAAY,CAAC,mBAAmB,GAAG,EAAE,CAAC;AAe/B,KAAK,UAAU,SAAS,CAAC,IAAU;IACxC,MAAM,SAAS,GAAG;QAChB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B,CAAC,OAAO,CAAC,CAAC;IAE7D,IAAI,mBAAmB,EAAE,CAAC;QACxB,eAAK,CAAC,GAAG,CAAC,OAAO,CACf,yBAAyB,IAAA,qCAAyB,EAAC,mBAAmB,CAAC,EAAE,CAC1E,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,MAAM,WAAW,GAAgB,MAAM,IAAA,8BAAgB,EACrD,eAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,6BAA6B;QACtC,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,uBAAW,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE;YAC/C,EAAE,KAAK,EAAE,uBAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,EAAE,KAAK,EAAE,uBAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,EAAE,KAAK,EAAE,uBAAW,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE;YACzD,EAAE,KAAK,EAAE,uBAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;YAC9C,EAAE,KAAK,EAAE,uBAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;YAC9C,EAAE,KAAK,EAAE,uBAAW,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE;SAC1D;KACF,CAAC,CACH,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { abortIfCancelled } from './utils/clack-utils';\n\nimport { runNextjsWizardAgent } from './nextjs/nextjs-wizard-agent';\nimport type { CloudRegion, WizardOptions } from './utils/types';\n\nimport {\n getIntegrationDescription,\n Integration,\n FeatureFlagDefinition,\n} from './lib/constants';\nimport { readEnvironment } from './utils/environment';\nimport clack from './utils/clack';\nimport path from 'path';\nimport { INTEGRATION_CONFIG, INTEGRATION_ORDER } from './lib/config';\nimport { runReactWizard } from './react/react-wizard';\nimport { analytics } from './utils/analytics';\nimport { runSvelteWizard } from './svelte/svelte-wizard';\nimport { runReactNativeWizard } from './react-native/react-native-wizard';\nimport { runAstroWizard } from './astro/astro-wizard';\nimport { runReactRouterWizardAgent } from './react-router/react-router-wizard-agent';\nimport { runDjangoWizardAgent } from './django/django-wizard-agent';\nimport { EventEmitter } from 'events';\nimport chalk from 'chalk';\nimport { RateLimitError } from './utils/errors';\n\nEventEmitter.defaultMaxListeners = 50;\n\ntype Args = {\n integration?: Integration;\n debug?: boolean;\n forceInstall?: boolean;\n installDir?: string;\n region?: CloudRegion;\n default?: boolean;\n signup?: boolean;\n localMcp?: boolean;\n ci?: boolean;\n apiKey?: string;\n};\n\nexport async function runWizard(argv: Args) {\n const finalArgs = {\n ...argv,\n ...readEnvironment(),\n };\n\n let resolvedInstallDir: string;\n if (finalArgs.installDir) {\n if (path.isAbsolute(finalArgs.installDir)) {\n resolvedInstallDir = finalArgs.installDir;\n } else {\n resolvedInstallDir = path.join(process.cwd(), finalArgs.installDir);\n }\n } else {\n resolvedInstallDir = process.cwd();\n }\n\n const wizardOptions: WizardOptions = {\n debug: finalArgs.debug ?? false,\n forceInstall: finalArgs.forceInstall ?? false,\n installDir: resolvedInstallDir,\n cloudRegion: finalArgs.region ?? undefined,\n default: finalArgs.default ?? false,\n signup: finalArgs.signup ?? false,\n localMcp: finalArgs.localMcp ?? false,\n ci: finalArgs.ci ?? false,\n apiKey: finalArgs.apiKey,\n };\n\n clack.intro(`Welcome to the PostHog setup wizard ✨`);\n\n if (wizardOptions.ci) {\n clack.log.info(chalk.dim('Running in CI mode'));\n }\n\n const integration =\n finalArgs.integration ?? (await getIntegrationForSetup(wizardOptions));\n\n analytics.setTag('integration', integration);\n\n try {\n switch (integration) {\n case Integration.nextjs:\n await runNextjsWizardAgent(wizardOptions);\n break;\n case Integration.react:\n await runReactWizard(wizardOptions);\n break;\n case Integration.svelte:\n await runSvelteWizard(wizardOptions);\n break;\n case Integration.reactNative:\n await runReactNativeWizard(wizardOptions);\n break;\n case Integration.astro:\n await runAstroWizard(wizardOptions);\n break;\n case Integration.reactRouter: {\n const flagValue = await analytics.getFeatureFlag(\n FeatureFlagDefinition.ReactRouter,\n );\n // In CI mode, bypass feature flags and always use the React Router wizard\n if (wizardOptions.ci || flagValue === true) {\n await runReactRouterWizardAgent(wizardOptions);\n } else {\n await runReactWizard(wizardOptions);\n }\n break;\n }\n case Integration.django:\n clack.log.info(\n `${chalk.yellow(\n '[BETA]',\n )} The Django wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n await runDjangoWizardAgent(wizardOptions);\n break;\n default:\n clack.log.error('No setup wizard selected!');\n }\n } catch (error) {\n analytics.captureException(error as Error, {\n integration,\n arguments: JSON.stringify(finalArgs),\n });\n\n await analytics.shutdown('error');\n\n if (error instanceof RateLimitError) {\n clack.log.error('Wizard usage limit reached. Please try again later.');\n } else {\n clack.log.error(\n `Something went wrong. You can read the documentation at ${chalk.cyan(\n `${INTEGRATION_CONFIG[integration].docsUrl}`,\n )} to set up PostHog manually.`,\n );\n }\n process.exit(1);\n }\n}\n\nasync function detectIntegration(\n options: Pick<WizardOptions, 'installDir'>,\n): Promise<Integration | undefined> {\n const integrationConfigs = Object.entries(INTEGRATION_CONFIG).sort(\n ([a], [b]) =>\n INTEGRATION_ORDER.indexOf(a as Integration) -\n INTEGRATION_ORDER.indexOf(b as Integration),\n );\n\n for (const [integration, config] of integrationConfigs) {\n const detected = await config.detect(options);\n if (detected) {\n return integration as Integration;\n }\n }\n}\n\nasync function getIntegrationForSetup(\n options: Pick<WizardOptions, 'installDir'>,\n) {\n const detectedIntegration = await detectIntegration(options);\n\n if (detectedIntegration) {\n clack.log.success(\n `Detected integration: ${getIntegrationDescription(detectedIntegration)}`,\n );\n return detectedIntegration;\n }\n\n const integration: Integration = await abortIfCancelled(\n clack.select({\n message: 'What do you want to set up?',\n options: [\n { value: Integration.nextjs, label: 'Next.js' },\n { value: Integration.astro, label: 'Astro' },\n { value: Integration.react, label: 'React' },\n { value: Integration.reactRouter, label: 'React Router' },\n { value: Integration.django, label: 'Django' },\n { value: Integration.svelte, label: 'Svelte' },\n { value: Integration.reactNative, label: 'React Native' },\n ],\n }),\n );\n\n return integration;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":";;;;;AAyCA,8BA+GC;AAxJD,qDAAuD;AAEvD,sEAAoE;AAGpE,+CAIyB;AACzB,qDAAsD;AACtD,0DAAkC;AAClC,gDAAwB;AACxB,yCAAqE;AACrE,uDAAsD;AACtD,iDAA8C;AAC9C,0DAAyD;AACzD,4EAA0E;AAC1E,uDAAsD;AACtD,wFAAqF;AACrF,sEAAoE;AACpE,mEAAiE;AACjE,mCAAsC;AACtC,kDAA0B;AAC1B,2CAAgD;AAEhD,qBAAY,CAAC,mBAAmB,GAAG,EAAE,CAAC;AAe/B,KAAK,UAAU,SAAS,CAAC,IAAU;IACxC,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI;QACP,GAAG,IAAA,6BAAe,GAAE;KACrB,CAAC;IAEF,IAAI,kBAA0B,CAAC;IAC/B,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1C,kBAAkB,GAAG,SAAS,CAAC,UAAU,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,kBAAkB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;IAED,MAAM,aAAa,GAAkB;QACnC,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,KAAK;QAC/B,YAAY,EAAE,SAAS,CAAC,YAAY,IAAI,KAAK;QAC7C,UAAU,EAAE,kB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KAAK,EAAE,SAAS,EAAE;YAC/C,EAAE,KAAK,EAAE,uBAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,EAAE,KAAK,EAAE,uBAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,EAAE,KAAK,EAAE,uBAAW,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE;YACzD,EAAE,KAAK,EAAE,uBAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;YAC9C,EAAE,KAAK,EAAE,uBAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,EAAE,KAAK,EAAE,uBAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;YAC9C,EAAE,KAAK,EAAE,uBAAW,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE;SAC1D;KACF,CAAC,CACH,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { abortIfCancelled } from './utils/clack-utils';\n\nimport { runNextjsWizardAgent } from './nextjs/nextjs-wizard-agent';\nimport type { CloudRegion, WizardOptions } from './utils/types';\n\nimport {\n getIntegrationDescription,\n Integration,\n FeatureFlagDefinition,\n} from './lib/constants';\nimport { readEnvironment } from './utils/environment';\nimport clack from './utils/clack';\nimport path from 'path';\nimport { INTEGRATION_CONFIG, INTEGRATION_ORDER } from './lib/config';\nimport { runReactWizard } from './react/react-wizard';\nimport { analytics } from './utils/analytics';\nimport { runSvelteWizard } from './svelte/svelte-wizard';\nimport { runReactNativeWizard } from './react-native/react-native-wizard';\nimport { runAstroWizard } from './astro/astro-wizard';\nimport { runReactRouterWizardAgent } from './react-router/react-router-wizard-agent';\nimport { runDjangoWizardAgent } from './django/django-wizard-agent';\nimport { runFlaskWizardAgent } from './flask/flask-wizard-agent';\nimport { EventEmitter } from 'events';\nimport chalk from 'chalk';\nimport { RateLimitError } from './utils/errors';\n\nEventEmitter.defaultMaxListeners = 50;\n\ntype Args = {\n integration?: Integration;\n debug?: boolean;\n forceInstall?: boolean;\n installDir?: string;\n region?: CloudRegion;\n default?: boolean;\n signup?: boolean;\n localMcp?: boolean;\n ci?: boolean;\n apiKey?: string;\n};\n\nexport async function runWizard(argv: Args) {\n const finalArgs = {\n ...argv,\n ...readEnvironment(),\n };\n\n let resolvedInstallDir: string;\n if (finalArgs.installDir) {\n if (path.isAbsolute(finalArgs.installDir)) {\n resolvedInstallDir = finalArgs.installDir;\n } else {\n resolvedInstallDir = path.join(process.cwd(), finalArgs.installDir);\n }\n } else {\n resolvedInstallDir = process.cwd();\n }\n\n const wizardOptions: WizardOptions = {\n debug: finalArgs.debug ?? false,\n forceInstall: finalArgs.forceInstall ?? false,\n installDir: resolvedInstallDir,\n cloudRegion: finalArgs.region ?? undefined,\n default: finalArgs.default ?? false,\n signup: finalArgs.signup ?? false,\n localMcp: finalArgs.localMcp ?? false,\n ci: finalArgs.ci ?? false,\n apiKey: finalArgs.apiKey,\n };\n\n clack.intro(`Welcome to the PostHog setup wizard ✨`);\n\n if (wizardOptions.ci) {\n clack.log.info(chalk.dim('Running in CI mode'));\n }\n\n const integration =\n finalArgs.integration ?? (await getIntegrationForSetup(wizardOptions));\n\n analytics.setTag('integration', integration);\n\n try {\n switch (integration) {\n case Integration.nextjs:\n await runNextjsWizardAgent(wizardOptions);\n break;\n case Integration.react:\n await runReactWizard(wizardOptions);\n break;\n case Integration.svelte:\n await runSvelteWizard(wizardOptions);\n break;\n case Integration.reactNative:\n await runReactNativeWizard(wizardOptions);\n break;\n case Integration.astro:\n await runAstroWizard(wizardOptions);\n break;\n case Integration.reactRouter: {\n const flagValue = await analytics.getFeatureFlag(\n FeatureFlagDefinition.ReactRouter,\n );\n // In CI mode, bypass feature flags and always use the React Router wizard\n if (wizardOptions.ci || flagValue === true) {\n await runReactRouterWizardAgent(wizardOptions);\n } else {\n await runReactWizard(wizardOptions);\n }\n break;\n }\n case Integration.django:\n clack.log.info(\n `${chalk.yellow(\n '[BETA]',\n )} The Django wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n await runDjangoWizardAgent(wizardOptions);\n break;\n case Integration.flask:\n clack.log.info(\n `${chalk.yellow(\n '[BETA]',\n )} The Flask wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n await runFlaskWizardAgent(wizardOptions);\n break;\n default:\n clack.log.error('No setup wizard selected!');\n }\n } catch (error) {\n analytics.captureException(error as Error, {\n integration,\n arguments: JSON.stringify(finalArgs),\n });\n\n await analytics.shutdown('error');\n\n if (error instanceof RateLimitError) {\n clack.log.error('Wizard usage limit reached. Please try again later.');\n } else {\n clack.log.error(\n `Something went wrong. You can read the documentation at ${chalk.cyan(\n `${INTEGRATION_CONFIG[integration].docsUrl}`,\n )} to set up PostHog manually.`,\n );\n }\n process.exit(1);\n }\n}\n\nasync function detectIntegration(\n options: Pick<WizardOptions, 'installDir'>,\n): Promise<Integration | undefined> {\n const integrationConfigs = Object.entries(INTEGRATION_CONFIG).sort(\n ([a], [b]) =>\n INTEGRATION_ORDER.indexOf(a as Integration) -\n INTEGRATION_ORDER.indexOf(b as Integration),\n );\n\n for (const [integration, config] of integrationConfigs) {\n const detected = await config.detect(options);\n if (detected) {\n return integration as Integration;\n }\n }\n}\n\nasync function getIntegrationForSetup(\n options: Pick<WizardOptions, 'installDir'>,\n) {\n const detectedIntegration = await detectIntegration(options);\n\n if (detectedIntegration) {\n clack.log.success(\n `Detected integration: ${getIntegrationDescription(detectedIntegration)}`,\n );\n return detectedIntegration;\n }\n\n const integration: Integration = await abortIfCancelled(\n clack.select({\n message: 'What do you want to set up?',\n options: [\n { value: Integration.nextjs, label: 'Next.js' },\n { value: Integration.astro, label: 'Astro' },\n { value: Integration.react, label: 'React' },\n { value: Integration.reactRouter, label: 'React Router' },\n { value: Integration.django, label: 'Django' },\n { value: Integration.flask, label: 'Flask' },\n { value: Integration.svelte, label: 'Svelte' },\n { value: Integration.reactNative, label: 'React Native' },\n ],\n }),\n );\n\n return integration;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type StatusCheckResult = {
|
|
2
|
+
status: 'operational';
|
|
3
|
+
} | {
|
|
4
|
+
status: 'degraded';
|
|
5
|
+
description: string;
|
|
6
|
+
} | {
|
|
7
|
+
status: 'down';
|
|
8
|
+
description: string;
|
|
9
|
+
} | {
|
|
10
|
+
status: 'unknown';
|
|
11
|
+
error: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Check the Anthropic/Claude status page for service health.
|
|
15
|
+
* Returns the current status indicator.
|
|
16
|
+
*/
|
|
17
|
+
export declare function checkAnthropicStatus(): Promise<StatusCheckResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Check Anthropic status and handle the result.
|
|
20
|
+
* - If down: Show error and exit
|
|
21
|
+
* - If degraded: Show warning and ask user to continue
|
|
22
|
+
* - If operational or unknown: Continue silently
|
|
23
|
+
*
|
|
24
|
+
* @returns true if the wizard should continue, false if it should abort
|
|
25
|
+
*/
|
|
26
|
+
export declare function checkAnthropicStatusWithPrompt(options?: {
|
|
27
|
+
ci?: boolean;
|
|
28
|
+
}): Promise<boolean>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkAnthropicStatus = checkAnthropicStatus;
|
|
7
|
+
exports.checkAnthropicStatusWithPrompt = checkAnthropicStatusWithPrompt;
|
|
8
|
+
const clack_1 = __importDefault(require("./clack"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const CLAUDE_STATUS_URL = 'https://status.claude.com/api/v2/status.json';
|
|
11
|
+
const CLAUDE_STATUS_PAGE = 'https://status.claude.com';
|
|
12
|
+
/**
|
|
13
|
+
* Check the Anthropic/Claude status page for service health.
|
|
14
|
+
* Returns the current status indicator.
|
|
15
|
+
*/
|
|
16
|
+
async function checkAnthropicStatus() {
|
|
17
|
+
try {
|
|
18
|
+
const controller = new AbortController();
|
|
19
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000); // 5 second timeout
|
|
20
|
+
const response = await fetch(CLAUDE_STATUS_URL, {
|
|
21
|
+
signal: controller.signal,
|
|
22
|
+
});
|
|
23
|
+
clearTimeout(timeoutId);
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
return {
|
|
26
|
+
status: 'unknown',
|
|
27
|
+
error: `Status page returned ${response.status}`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const data = (await response.json());
|
|
31
|
+
const indicator = data.status.indicator;
|
|
32
|
+
const description = data.status.description;
|
|
33
|
+
switch (indicator) {
|
|
34
|
+
case 'none':
|
|
35
|
+
return { status: 'operational' };
|
|
36
|
+
case 'minor':
|
|
37
|
+
return { status: 'degraded', description };
|
|
38
|
+
case 'major':
|
|
39
|
+
case 'critical':
|
|
40
|
+
return { status: 'down', description };
|
|
41
|
+
default:
|
|
42
|
+
return { status: 'unknown', error: `Unknown indicator: ${indicator}` };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
47
|
+
return { status: 'unknown', error: 'Request timed out' };
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
status: 'unknown',
|
|
51
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check Anthropic status and handle the result.
|
|
57
|
+
* - If down: Show error and exit
|
|
58
|
+
* - If degraded: Show warning and ask user to continue
|
|
59
|
+
* - If operational or unknown: Continue silently
|
|
60
|
+
*
|
|
61
|
+
* @returns true if the wizard should continue, false if it should abort
|
|
62
|
+
*/
|
|
63
|
+
async function checkAnthropicStatusWithPrompt(options = {}) {
|
|
64
|
+
const result = await checkAnthropicStatus();
|
|
65
|
+
if (result.status === 'down') {
|
|
66
|
+
clack_1.default.log.error(`${chalk_1.default.red('Claude/Anthropic services are currently experiencing issues.')}
|
|
67
|
+
|
|
68
|
+
${chalk_1.default.yellow('Status:')} ${result.description}
|
|
69
|
+
${chalk_1.default.yellow('Status page:')} ${CLAUDE_STATUS_PAGE}
|
|
70
|
+
|
|
71
|
+
The wizard relies on Claude to make changes to your project.
|
|
72
|
+
Please check the status page and try again later.`);
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (result.status === 'degraded') {
|
|
76
|
+
clack_1.default.log.warn(`${chalk_1.default.yellow('Claude/Anthropic services are partially degraded.')}
|
|
77
|
+
|
|
78
|
+
${chalk_1.default.yellow('Status:')} ${result.description}
|
|
79
|
+
${chalk_1.default.yellow('Status page:')} ${CLAUDE_STATUS_PAGE}
|
|
80
|
+
|
|
81
|
+
The wizard may not work reliably while services are degraded.`);
|
|
82
|
+
// In CI mode, continue with a warning
|
|
83
|
+
if (options.ci) {
|
|
84
|
+
clack_1.default.log.info('Continuing in CI mode despite degraded status...');
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
const shouldContinue = await clack_1.default.confirm({
|
|
88
|
+
message: 'Do you want to continue anyway?',
|
|
89
|
+
initialValue: false,
|
|
90
|
+
});
|
|
91
|
+
if (clack_1.default.isCancel(shouldContinue) || !shouldContinue) {
|
|
92
|
+
clack_1.default.log.info('Wizard cancelled. Please try again later.');
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
// For 'operational' or 'unknown' status, continue silently
|
|
98
|
+
// We don't want to block users if the status check itself fails
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=anthropic-status.js.map
|
|
@@ -0,0 +1 @@
|
|
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,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;YACf,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;YACnE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,eAAK,CAAC,OAAO,CAAC;YACzC,OAAO,EAAE,iCAAiC;YAC1C,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,IAAI,eAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACtD,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;YAC5D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2DAA2D;IAC3D,gEAAgE;IAChE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import clack from './clack';\nimport chalk from 'chalk';\n\nconst CLAUDE_STATUS_URL = 'https://status.claude.com/api/v2/status.json';\nconst CLAUDE_STATUS_PAGE = 'https://status.claude.com';\n\ntype StatusIndicator = 'none' | 'minor' | 'major' | 'critical';\n\ninterface ClaudeStatusResponse {\n page: {\n id: string;\n name: string;\n url: string;\n time_zone: string;\n updated_at: string;\n };\n status: {\n indicator: StatusIndicator;\n description: string;\n };\n}\n\nexport type StatusCheckResult =\n | { status: 'operational' }\n | { status: 'degraded'; description: string }\n | { status: 'down'; description: string }\n | { status: 'unknown'; error: string };\n\n/**\n * Check the Anthropic/Claude status page for service health.\n * Returns the current status indicator.\n */\nexport async function checkAnthropicStatus(): Promise<StatusCheckResult> {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 5000); // 5 second timeout\n\n const response = await fetch(CLAUDE_STATUS_URL, {\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n return {\n status: 'unknown',\n error: `Status page returned ${response.status}`,\n };\n }\n\n const data = (await response.json()) as ClaudeStatusResponse;\n const indicator = data.status.indicator;\n const description = data.status.description;\n\n switch (indicator) {\n case 'none':\n return { status: 'operational' };\n case 'minor':\n return { status: 'degraded', description };\n case 'major':\n case 'critical':\n return { status: 'down', description };\n default:\n return { status: 'unknown', error: `Unknown indicator: ${indicator}` };\n }\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n return { status: 'unknown', error: 'Request timed out' };\n }\n return {\n status: 'unknown',\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n}\n\n/**\n * Check Anthropic status and handle the result.\n * - If down: Show error and exit\n * - If degraded: Show warning and ask user to continue\n * - If operational or unknown: Continue silently\n *\n * @returns true if the wizard should continue, false if it should abort\n */\nexport async function checkAnthropicStatusWithPrompt(\n options: { ci?: boolean } = {},\n): Promise<boolean> {\n const result = await checkAnthropicStatus();\n\n if (result.status === 'down') {\n clack.log.error(\n `${chalk.red(\n 'Claude/Anthropic services are currently experiencing issues.',\n )}\n\n${chalk.yellow('Status:')} ${result.description}\n${chalk.yellow('Status page:')} ${CLAUDE_STATUS_PAGE}\n\nThe wizard relies on Claude to make changes to your project.\nPlease check the status page and try again later.`,\n );\n return false;\n }\n\n if (result.status === 'degraded') {\n clack.log.warn(\n `${chalk.yellow('Claude/Anthropic services are partially degraded.')}\n\n${chalk.yellow('Status:')} ${result.description}\n${chalk.yellow('Status page:')} ${CLAUDE_STATUS_PAGE}\n\nThe wizard may not work reliably while services are degraded.`,\n );\n\n // In CI mode, continue with a warning\n if (options.ci) {\n clack.log.info('Continuing in CI mode despite degraded status...');\n return true;\n }\n\n const shouldContinue = await clack.confirm({\n message: 'Do you want to continue anyway?',\n initialValue: false,\n });\n\n if (clack.isCancel(shouldContinue) || !shouldContinue) {\n clack.log.info('Wizard cancelled. Please try again later.');\n return false;\n }\n\n return true;\n }\n\n // For 'operational' or 'unknown' status, continue silently\n // We don't want to block users if the status check itself fails\n return true;\n}\n"]}
|
package/package.json
CHANGED