@amplitude/wizard 1.0.0-beta.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/LICENSE +47 -0
- package/README.md +119 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +763 -0
- package/dist/package.json +144 -0
- package/dist/src/frameworks/android/android-wizard-agent.d.ts +6 -0
- package/dist/src/frameworks/android/android-wizard-agent.js +72 -0
- package/dist/src/frameworks/android/utils.d.ts +11 -0
- package/dist/src/frameworks/android/utils.js +32 -0
- package/dist/src/frameworks/django/django-wizard-agent.d.ts +8 -0
- package/dist/src/frameworks/django/django-wizard-agent.js +171 -0
- package/dist/src/frameworks/django/utils.d.ts +31 -0
- package/dist/src/frameworks/django/utils.js +305 -0
- package/dist/src/frameworks/fastapi/fastapi-wizard-agent.d.ts +11 -0
- package/dist/src/frameworks/fastapi/fastapi-wizard-agent.js +189 -0
- package/dist/src/frameworks/fastapi/utils.d.ts +26 -0
- package/dist/src/frameworks/fastapi/utils.js +257 -0
- package/dist/src/frameworks/flask/flask-wizard-agent.d.ts +8 -0
- package/dist/src/frameworks/flask/flask-wizard-agent.js +177 -0
- package/dist/src/frameworks/flask/utils.d.ts +28 -0
- package/dist/src/frameworks/flask/utils.js +343 -0
- package/dist/src/frameworks/flutter/flutter-wizard-agent.d.ts +4 -0
- package/dist/src/frameworks/flutter/flutter-wizard-agent.js +57 -0
- package/dist/src/frameworks/flutter/utils.d.ts +7 -0
- package/dist/src/frameworks/flutter/utils.js +64 -0
- package/dist/src/frameworks/generic/generic-wizard-agent.d.ts +2 -0
- package/dist/src/frameworks/generic/generic-wizard-agent.js +176 -0
- package/dist/src/frameworks/go/go-wizard-agent.d.ts +4 -0
- package/dist/src/frameworks/go/go-wizard-agent.js +57 -0
- package/dist/src/frameworks/go/utils.d.ts +5 -0
- package/dist/src/frameworks/go/utils.js +44 -0
- package/dist/src/frameworks/java/java-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/java/java-wizard-agent.js +73 -0
- package/dist/src/frameworks/java/utils.d.ts +15 -0
- package/dist/src/frameworks/java/utils.js +64 -0
- package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.d.ts +4 -0
- package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.js +57 -0
- package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.d.ts +3 -0
- package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.js +151 -0
- package/dist/src/frameworks/javascript-web/utils.d.ts +28 -0
- package/dist/src/frameworks/javascript-web/utils.js +153 -0
- package/dist/src/frameworks/nextjs/nextjs-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/nextjs/nextjs-wizard-agent.js +98 -0
- package/dist/src/frameworks/nextjs/utils.d.ts +12 -0
- package/dist/src/frameworks/nextjs/utils.js +51 -0
- package/dist/src/frameworks/python/python-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/python/python-wizard-agent.js +193 -0
- package/dist/src/frameworks/python/utils.d.ts +28 -0
- package/dist/src/frameworks/python/utils.js +146 -0
- package/dist/src/frameworks/react-native/react-native-wizard-agent.d.ts +6 -0
- package/dist/src/frameworks/react-native/react-native-wizard-agent.js +84 -0
- package/dist/src/frameworks/react-native/utils.d.ts +21 -0
- package/dist/src/frameworks/react-native/utils.js +82 -0
- package/dist/src/frameworks/react-router/react-router-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/react-router/react-router-wizard-agent.js +98 -0
- package/dist/src/frameworks/react-router/utils.d.ts +13 -0
- package/dist/src/frameworks/react-router/utils.js +160 -0
- package/dist/src/frameworks/swift/swift-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/swift/swift-wizard-agent.js +72 -0
- package/dist/src/frameworks/swift/utils.d.ts +12 -0
- package/dist/src/frameworks/swift/utils.js +82 -0
- package/dist/src/frameworks/unity/unity-wizard-agent.d.ts +6 -0
- package/dist/src/frameworks/unity/unity-wizard-agent.js +79 -0
- package/dist/src/frameworks/unity/utils.d.ts +12 -0
- package/dist/src/frameworks/unity/utils.js +66 -0
- package/dist/src/frameworks/unreal/unreal-wizard-agent.d.ts +6 -0
- package/dist/src/frameworks/unreal/unreal-wizard-agent.js +77 -0
- package/dist/src/frameworks/unreal/utils.d.ts +10 -0
- package/dist/src/frameworks/unreal/utils.js +29 -0
- package/dist/src/frameworks/vue/vue-wizard-agent.d.ts +4 -0
- package/dist/src/frameworks/vue/vue-wizard-agent.js +64 -0
- package/dist/src/lib/agent-hooks.d.ts +26 -0
- package/dist/src/lib/agent-hooks.js +118 -0
- package/dist/src/lib/agent-interface.d.ts +175 -0
- package/dist/src/lib/agent-interface.js +1217 -0
- package/dist/src/lib/agent-runner.d.ts +9 -0
- package/dist/src/lib/agent-runner.js +415 -0
- package/dist/src/lib/ampli-config.d.ts +105 -0
- package/dist/src/lib/ampli-config.js +178 -0
- package/dist/src/lib/api.d.ts +107 -0
- package/dist/src/lib/api.js +442 -0
- package/dist/src/lib/commandments.d.ts +1 -0
- package/dist/src/lib/commandments.js +24 -0
- package/dist/src/lib/console-query.d.ts +27 -0
- package/dist/src/lib/console-query.js +121 -0
- package/dist/src/lib/constants.d.ts +124 -0
- package/dist/src/lib/constants.js +170 -0
- package/dist/src/lib/detect-amplitude.d.ts +31 -0
- package/dist/src/lib/detect-amplitude.js +407 -0
- package/dist/src/lib/framework-config.d.ts +188 -0
- package/dist/src/lib/framework-config.js +21 -0
- package/dist/src/lib/health-checks/endpoints.d.ts +3 -0
- package/dist/src/lib/health-checks/endpoints.js +45 -0
- package/dist/src/lib/health-checks/index.d.ts +4 -0
- package/dist/src/lib/health-checks/index.js +22 -0
- package/dist/src/lib/health-checks/readiness.d.ts +24 -0
- package/dist/src/lib/health-checks/readiness.js +118 -0
- package/dist/src/lib/health-checks/statuspage.d.ts +9 -0
- package/dist/src/lib/health-checks/statuspage.js +104 -0
- package/dist/src/lib/health-checks/types.d.ts +31 -0
- package/dist/src/lib/health-checks/types.js +9 -0
- package/dist/src/lib/helper-functions.d.ts +1 -0
- package/dist/src/lib/helper-functions.js +5 -0
- package/dist/src/lib/middleware/benchmark.d.ts +54 -0
- package/dist/src/lib/middleware/benchmark.js +48 -0
- package/dist/src/lib/middleware/benchmarks/cache-tracker.d.ts +44 -0
- package/dist/src/lib/middleware/benchmarks/cache-tracker.js +80 -0
- package/dist/src/lib/middleware/benchmarks/compaction-tracker.d.ts +29 -0
- package/dist/src/lib/middleware/benchmarks/compaction-tracker.js +59 -0
- package/dist/src/lib/middleware/benchmarks/context-size-tracker.d.ts +26 -0
- package/dist/src/lib/middleware/benchmarks/context-size-tracker.js +55 -0
- package/dist/src/lib/middleware/benchmarks/cost-tracker.d.ts +16 -0
- package/dist/src/lib/middleware/benchmarks/cost-tracker.js +75 -0
- package/dist/src/lib/middleware/benchmarks/duration-tracker.d.ts +20 -0
- package/dist/src/lib/middleware/benchmarks/duration-tracker.js +39 -0
- package/dist/src/lib/middleware/benchmarks/index.d.ts +9 -0
- package/dist/src/lib/middleware/benchmarks/index.js +67 -0
- package/dist/src/lib/middleware/benchmarks/json-writer.d.ts +15 -0
- package/dist/src/lib/middleware/benchmarks/json-writer.js +144 -0
- package/dist/src/lib/middleware/benchmarks/summary.d.ts +9 -0
- package/dist/src/lib/middleware/benchmarks/summary.js +105 -0
- package/dist/src/lib/middleware/benchmarks/token-tracker.d.ts +40 -0
- package/dist/src/lib/middleware/benchmarks/token-tracker.js +76 -0
- package/dist/src/lib/middleware/benchmarks/turn-counter.d.ts +34 -0
- package/dist/src/lib/middleware/benchmarks/turn-counter.js +58 -0
- package/dist/src/lib/middleware/config.d.ts +24 -0
- package/dist/src/lib/middleware/config.js +96 -0
- package/dist/src/lib/middleware/index.d.ts +11 -0
- package/dist/src/lib/middleware/index.js +17 -0
- package/dist/src/lib/middleware/phase-detector.d.ts +8 -0
- package/dist/src/lib/middleware/phase-detector.js +63 -0
- package/dist/src/lib/middleware/pipeline.d.ts +29 -0
- package/dist/src/lib/middleware/pipeline.js +81 -0
- package/dist/src/lib/middleware/schemas.d.ts +27 -0
- package/dist/src/lib/middleware/schemas.js +84 -0
- package/dist/src/lib/middleware/types.d.ts +94 -0
- package/dist/src/lib/middleware/types.js +8 -0
- package/dist/src/lib/package-manager-detection.d.ts +42 -0
- package/dist/src/lib/package-manager-detection.js +292 -0
- package/dist/src/lib/registry.d.ts +3 -0
- package/dist/src/lib/registry.js +42 -0
- package/dist/src/lib/safe-tools.d.ts +2 -0
- package/dist/src/lib/safe-tools.js +214 -0
- package/dist/src/lib/wizard-session.d.ts +220 -0
- package/dist/src/lib/wizard-session.js +127 -0
- package/dist/src/lib/wizard-tools.d.ts +82 -0
- package/dist/src/lib/wizard-tools.js +499 -0
- package/dist/src/run.d.ts +19 -0
- package/dist/src/run.js +151 -0
- package/dist/src/steps/add-mcp-server-to-clients/MCPClient.d.ts +30 -0
- package/dist/src/steps/add-mcp-server-to-clients/MCPClient.js +141 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.d.ts +29 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.js +180 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude.d.ts +20 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude.js +63 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/codex.d.ts +28 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js +77 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.d.ts +24 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.js +60 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.d.ts +27 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.js +101 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/zed.d.ts +26 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/zed.js +102 -0
- package/dist/src/steps/add-mcp-server-to-clients/defaults.d.ts +44 -0
- package/dist/src/steps/add-mcp-server-to-clients/defaults.js +123 -0
- package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +19 -0
- package/dist/src/steps/add-mcp-server-to-clients/index.js +110 -0
- package/dist/src/steps/add-or-update-environment-variables.d.ts +10 -0
- package/dist/src/steps/add-or-update-environment-variables.js +188 -0
- package/dist/src/steps/index.d.ts +4 -0
- package/dist/src/steps/index.js +20 -0
- package/dist/src/steps/run-prettier.d.ts +5 -0
- package/dist/src/steps/run-prettier.js +90 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +11 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js +11 -0
- package/dist/src/steps/upload-environment-variables/index.d.ts +6 -0
- package/dist/src/steps/upload-environment-variables/index.js +37 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +15 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js +145 -0
- package/dist/src/telemetry.d.ts +2 -0
- package/dist/src/telemetry.js +12 -0
- package/dist/src/ui/index.d.ts +8 -0
- package/dist/src/ui/index.js +16 -0
- package/dist/src/ui/logging-ui.d.ts +56 -0
- package/dist/src/ui/logging-ui.js +157 -0
- package/dist/src/ui/tui/App.d.ts +6 -0
- package/dist/src/ui/tui/App.js +34 -0
- package/dist/src/ui/tui/components/AmplitudeLogo.d.ts +5 -0
- package/dist/src/ui/tui/components/AmplitudeLogo.js +81 -0
- package/dist/src/ui/tui/components/AmplitudeTextLogo.d.ts +3 -0
- package/dist/src/ui/tui/components/AmplitudeTextLogo.js +31 -0
- package/dist/src/ui/tui/components/ConsoleView.d.ts +23 -0
- package/dist/src/ui/tui/components/ConsoleView.js +220 -0
- package/dist/src/ui/tui/components/TitleBar.d.ts +6 -0
- package/dist/src/ui/tui/components/TitleBar.js +16 -0
- package/dist/src/ui/tui/console-commands.d.ts +16 -0
- package/dist/src/ui/tui/console-commands.js +31 -0
- package/dist/src/ui/tui/context/CommandModeContext.d.ts +2 -0
- package/dist/src/ui/tui/context/CommandModeContext.js +3 -0
- package/dist/src/ui/tui/flows.d.ts +48 -0
- package/dist/src/ui/tui/flows.js +154 -0
- package/dist/src/ui/tui/hooks/useScreenInput.d.ts +13 -0
- package/dist/src/ui/tui/hooks/useScreenInput.js +18 -0
- package/dist/src/ui/tui/hooks/useStdoutDimensions.d.ts +9 -0
- package/dist/src/ui/tui/hooks/useStdoutDimensions.js +29 -0
- package/dist/src/ui/tui/ink-ui.d.ts +62 -0
- package/dist/src/ui/tui/ink-ui.js +142 -0
- package/dist/src/ui/tui/primitives/CardLayout.d.ts +12 -0
- package/dist/src/ui/tui/primitives/CardLayout.js +9 -0
- package/dist/src/ui/tui/primitives/ConfirmationInput.d.ts +13 -0
- package/dist/src/ui/tui/primitives/ConfirmationInput.js +35 -0
- package/dist/src/ui/tui/primitives/DissolveTransition.d.ts +21 -0
- package/dist/src/ui/tui/primitives/DissolveTransition.js +143 -0
- package/dist/src/ui/tui/primitives/EventPlanViewer.d.ts +9 -0
- package/dist/src/ui/tui/primitives/EventPlanViewer.js +9 -0
- package/dist/src/ui/tui/primitives/KagiSmallWebViewer.d.ts +7 -0
- package/dist/src/ui/tui/primitives/KagiSmallWebViewer.js +101 -0
- package/dist/src/ui/tui/primitives/LoadingBox.d.ts +8 -0
- package/dist/src/ui/tui/primitives/LoadingBox.js +9 -0
- package/dist/src/ui/tui/primitives/LogViewer.d.ts +11 -0
- package/dist/src/ui/tui/primitives/LogViewer.js +55 -0
- package/dist/src/ui/tui/primitives/PickerMenu.d.ts +20 -0
- package/dist/src/ui/tui/primitives/PickerMenu.js +212 -0
- package/dist/src/ui/tui/primitives/ProgressList.d.ts +15 -0
- package/dist/src/ui/tui/primitives/ProgressList.js +29 -0
- package/dist/src/ui/tui/primitives/PromptLabel.d.ts +11 -0
- package/dist/src/ui/tui/primitives/PromptLabel.js +12 -0
- package/dist/src/ui/tui/primitives/ReportViewer.d.ts +12 -0
- package/dist/src/ui/tui/primitives/ReportViewer.js +99 -0
- package/dist/src/ui/tui/primitives/ScreenErrorBoundary.d.ts +26 -0
- package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js +29 -0
- package/dist/src/ui/tui/primitives/SlashCommandInput.d.ts +21 -0
- package/dist/src/ui/tui/primitives/SlashCommandInput.js +85 -0
- package/dist/src/ui/tui/primitives/SnakeGame.d.ts +1 -0
- package/dist/src/ui/tui/primitives/SnakeGame.js +1 -0
- package/dist/src/ui/tui/primitives/SplitView.d.ts +11 -0
- package/dist/src/ui/tui/primitives/SplitView.js +8 -0
- package/dist/src/ui/tui/primitives/TabContainer.d.ts +18 -0
- package/dist/src/ui/tui/primitives/TabContainer.js +30 -0
- package/dist/src/ui/tui/primitives/index.d.ts +23 -0
- package/dist/src/ui/tui/primitives/index.js +19 -0
- package/dist/src/ui/tui/router.d.ts +61 -0
- package/dist/src/ui/tui/router.js +104 -0
- package/dist/src/ui/tui/screen-registry.d.ts +19 -0
- package/dist/src/ui/tui/screen-registry.js +56 -0
- package/dist/src/ui/tui/screens/ActivationOptionsScreen.d.ts +12 -0
- package/dist/src/ui/tui/screens/ActivationOptionsScreen.js +57 -0
- package/dist/src/ui/tui/screens/AuthScreen.d.ts +18 -0
- package/dist/src/ui/tui/screens/AuthScreen.js +107 -0
- package/dist/src/ui/tui/screens/ChecklistScreen.d.ts +22 -0
- package/dist/src/ui/tui/screens/ChecklistScreen.js +122 -0
- package/dist/src/ui/tui/screens/DataIngestionCheckScreen.d.ts +24 -0
- package/dist/src/ui/tui/screens/DataIngestionCheckScreen.js +113 -0
- package/dist/src/ui/tui/screens/DataSetupScreen.d.ts +17 -0
- package/dist/src/ui/tui/screens/DataSetupScreen.js +73 -0
- package/dist/src/ui/tui/screens/IntroScreen.d.ts +16 -0
- package/dist/src/ui/tui/screens/IntroScreen.js +86 -0
- package/dist/src/ui/tui/screens/LoginScreen.d.ts +15 -0
- package/dist/src/ui/tui/screens/LoginScreen.js +65 -0
- package/dist/src/ui/tui/screens/LogoutScreen.d.ts +12 -0
- package/dist/src/ui/tui/screens/LogoutScreen.js +28 -0
- package/dist/src/ui/tui/screens/McpScreen.d.ts +26 -0
- package/dist/src/ui/tui/screens/McpScreen.js +148 -0
- package/dist/src/ui/tui/screens/OutageScreen.d.ts +10 -0
- package/dist/src/ui/tui/screens/OutageScreen.js +17 -0
- package/dist/src/ui/tui/screens/OutroScreen.d.ts +11 -0
- package/dist/src/ui/tui/screens/OutroScreen.js +69 -0
- package/dist/src/ui/tui/screens/RegionSelectScreen.d.ts +17 -0
- package/dist/src/ui/tui/screens/RegionSelectScreen.js +40 -0
- package/dist/src/ui/tui/screens/RunScreen.d.ts +16 -0
- package/dist/src/ui/tui/screens/RunScreen.js +212 -0
- package/dist/src/ui/tui/screens/SettingsOverrideScreen.d.ts +10 -0
- package/dist/src/ui/tui/screens/SettingsOverrideScreen.js +23 -0
- package/dist/src/ui/tui/screens/SetupScreen.d.ts +13 -0
- package/dist/src/ui/tui/screens/SetupScreen.js +73 -0
- package/dist/src/ui/tui/screens/SlackScreen.d.ts +25 -0
- package/dist/src/ui/tui/screens/SlackScreen.js +97 -0
- package/dist/src/ui/tui/services/mcp-installer.d.ts +25 -0
- package/dist/src/ui/tui/services/mcp-installer.js +82 -0
- package/dist/src/ui/tui/start-tui.d.ts +10 -0
- package/dist/src/ui/tui/start-tui.js +50 -0
- package/dist/src/ui/tui/store.d.ts +231 -0
- package/dist/src/ui/tui/store.js +568 -0
- package/dist/src/ui/tui/styles.d.ts +31 -0
- package/dist/src/ui/tui/styles.js +33 -0
- package/dist/src/ui/wizard-ui.d.ts +110 -0
- package/dist/src/ui/wizard-ui.js +18 -0
- package/dist/src/utils/ampli-settings.d.ts +37 -0
- package/dist/src/utils/ampli-settings.js +182 -0
- package/dist/src/utils/analytics.d.ts +35 -0
- package/dist/src/utils/analytics.js +133 -0
- package/dist/src/utils/anthropic-status.d.ts +17 -0
- package/dist/src/utils/anthropic-status.js +51 -0
- package/dist/src/utils/api-key-store.d.ts +35 -0
- package/dist/src/utils/api-key-store.js +176 -0
- package/dist/src/utils/bash.d.ts +2 -0
- package/dist/src/utils/bash.js +53 -0
- package/dist/src/utils/custom-headers.d.ts +9 -0
- package/dist/src/utils/custom-headers.js +23 -0
- package/dist/src/utils/debug.d.ts +23 -0
- package/dist/src/utils/debug.js +86 -0
- package/dist/src/utils/environment.d.ts +4 -0
- package/dist/src/utils/environment.js +76 -0
- package/dist/src/utils/file-utils.d.ts +2 -0
- package/dist/src/utils/file-utils.js +16 -0
- package/dist/src/utils/get-api-key.d.ts +17 -0
- package/dist/src/utils/get-api-key.js +50 -0
- package/dist/src/utils/logging.d.ts +9 -0
- package/dist/src/utils/logging.js +48 -0
- package/dist/src/utils/oauth.d.ts +53 -0
- package/dist/src/utils/oauth.js +354 -0
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +26 -0
- package/dist/src/utils/package-manager.d.ts +21 -0
- package/dist/src/utils/package-manager.js +208 -0
- package/dist/src/utils/semver.d.ts +21 -0
- package/dist/src/utils/semver.js +61 -0
- package/dist/src/utils/setup-utils.d.ts +82 -0
- package/dist/src/utils/setup-utils.js +467 -0
- package/dist/src/utils/shell-completions.d.ts +10 -0
- package/dist/src/utils/shell-completions.js +199 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/dist/src/utils/string.js +8 -0
- package/dist/src/utils/types.d.ts +72 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/src/utils/urls.d.ts +14 -0
- package/dist/src/utils/urls.js +69 -0
- package/dist/src/utils/vendor/is-unicorn-supported.d.ts +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js +23 -0
- package/dist/src/utils/wizard-abort.d.ts +13 -0
- package/dist/src/utils/wizard-abort.js +56 -0
- package/man/amplitude-wizard.1 +170 -0
- package/package.json +144 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* api-key-store — Persist and retrieve the Amplitude project API key.
|
|
4
|
+
*
|
|
5
|
+
* Storage strategy (tried in order):
|
|
6
|
+
* 1. macOS Keychain — `security` CLI, no extra deps
|
|
7
|
+
* 2. Linux keyring — `secret-tool` CLI (gnome-keyring / KWallet)
|
|
8
|
+
* 3. .env.local file — fallback; file is added to .gitignore automatically
|
|
9
|
+
*
|
|
10
|
+
* The key is scoped to the project directory so that different projects
|
|
11
|
+
* can have different API keys on the same machine.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.persistApiKey = persistApiKey;
|
|
15
|
+
exports.clearApiKey = clearApiKey;
|
|
16
|
+
exports.readApiKey = readApiKey;
|
|
17
|
+
exports.readApiKeyWithSource = readApiKeyWithSource;
|
|
18
|
+
const node_child_process_1 = require("node:child_process");
|
|
19
|
+
const node_fs_1 = require("node:fs");
|
|
20
|
+
const node_path_1 = require("node:path");
|
|
21
|
+
const node_crypto_1 = require("node:crypto");
|
|
22
|
+
const KEYCHAIN_SERVICE = 'amplitude-wizard';
|
|
23
|
+
const ENV_KEY_NAME = 'AMPLITUDE_API_KEY';
|
|
24
|
+
/** A short stable identifier for the project directory (used as keychain account). */
|
|
25
|
+
function projectHandle(installDir) {
|
|
26
|
+
return (0, node_crypto_1.createHash)('sha1').update(installDir).digest('hex').slice(0, 12);
|
|
27
|
+
}
|
|
28
|
+
// ── macOS Keychain ────────────────────────────────────────────────────────────
|
|
29
|
+
function keychainRead(account) {
|
|
30
|
+
try {
|
|
31
|
+
return (0, node_child_process_1.execSync)(`security find-generic-password -a "${account}" -s "${KEYCHAIN_SERVICE}" -w 2>/dev/null`, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function keychainWrite(account, key) {
|
|
38
|
+
try {
|
|
39
|
+
(0, node_child_process_1.execSync)(`security add-generic-password -U -a "${account}" -s "${KEYCHAIN_SERVICE}" -w "${key}"`, { stdio: 'ignore' });
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// ── Linux secret-tool ─────────────────────────────────────────────────────────
|
|
47
|
+
function secretToolRead(account) {
|
|
48
|
+
try {
|
|
49
|
+
return (0, node_child_process_1.execSync)(`secret-tool lookup service "${KEYCHAIN_SERVICE}" account "${account}" 2>/dev/null`, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function secretToolWrite(account, key) {
|
|
56
|
+
try {
|
|
57
|
+
// secret-tool requires stdin for the password
|
|
58
|
+
(0, node_child_process_1.execSync)(`printf '%s' "${key}" | secret-tool store --label="Amplitude API Key" service "${KEYCHAIN_SERVICE}" account "${account}"`, { stdio: ['pipe', 'ignore', 'ignore'] });
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// ── .env.local fallback ───────────────────────────────────────────────────────
|
|
66
|
+
function envRead(installDir) {
|
|
67
|
+
const envPath = (0, node_path_1.join)(installDir, '.env.local');
|
|
68
|
+
if (!(0, node_fs_1.existsSync)(envPath))
|
|
69
|
+
return null;
|
|
70
|
+
const contents = (0, node_fs_1.readFileSync)(envPath, 'utf8');
|
|
71
|
+
const match = contents.match(/^AMPLITUDE_API_KEY=(.+)$/m);
|
|
72
|
+
return match ? match[1].trim() : null;
|
|
73
|
+
}
|
|
74
|
+
function envWrite(installDir, key) {
|
|
75
|
+
const envPath = (0, node_path_1.join)(installDir, '.env.local');
|
|
76
|
+
if ((0, node_fs_1.existsSync)(envPath)) {
|
|
77
|
+
const contents = (0, node_fs_1.readFileSync)(envPath, 'utf8');
|
|
78
|
+
if (contents.includes(`${ENV_KEY_NAME}=`)) {
|
|
79
|
+
// Replace existing entry
|
|
80
|
+
(0, node_fs_1.writeFileSync)(envPath, contents.replace(/^AMPLITUDE_API_KEY=.*$/m, `${ENV_KEY_NAME}=${key}`), 'utf8');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
(0, node_fs_1.appendFileSync)(envPath, `\n${ENV_KEY_NAME}=${key}\n`, 'utf8');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
(0, node_fs_1.writeFileSync)(envPath, `${ENV_KEY_NAME}=${key}\n`, 'utf8');
|
|
88
|
+
}
|
|
89
|
+
// Ensure .gitignore covers .env.local
|
|
90
|
+
ensureGitignored(installDir, '.env.local');
|
|
91
|
+
}
|
|
92
|
+
function ensureGitignored(installDir, pattern) {
|
|
93
|
+
const gitignorePath = (0, node_path_1.join)(installDir, '.gitignore');
|
|
94
|
+
if ((0, node_fs_1.existsSync)(gitignorePath)) {
|
|
95
|
+
const contents = (0, node_fs_1.readFileSync)(gitignorePath, 'utf8');
|
|
96
|
+
if (contents.includes(pattern))
|
|
97
|
+
return;
|
|
98
|
+
(0, node_fs_1.appendFileSync)(gitignorePath, `\n# Amplitude wizard\n${pattern}\n`, 'utf8');
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
(0, node_fs_1.writeFileSync)(gitignorePath, `# Amplitude wizard\n${pattern}\n`, 'utf8');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// ── Public API ────────────────────────────────────────────────────────────────
|
|
105
|
+
/**
|
|
106
|
+
* Persist the Amplitude project API key for this project directory.
|
|
107
|
+
* Tries keychain first, falls back to .env.local.
|
|
108
|
+
* Returns which storage was used: 'keychain' | 'env'
|
|
109
|
+
*/
|
|
110
|
+
function persistApiKey(key, installDir) {
|
|
111
|
+
const account = projectHandle(installDir);
|
|
112
|
+
if (process.platform === 'darwin' && keychainWrite(account, key)) {
|
|
113
|
+
return 'keychain';
|
|
114
|
+
}
|
|
115
|
+
if (process.platform === 'linux' && secretToolWrite(account, key)) {
|
|
116
|
+
return 'keychain';
|
|
117
|
+
}
|
|
118
|
+
envWrite(installDir, key);
|
|
119
|
+
return 'env';
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Remove the stored API key for this project directory from the system
|
|
123
|
+
* keychain (macOS / Linux). Has no effect if no key is stored.
|
|
124
|
+
*/
|
|
125
|
+
function clearApiKey(installDir) {
|
|
126
|
+
const account = projectHandle(installDir);
|
|
127
|
+
if (process.platform === 'darwin') {
|
|
128
|
+
try {
|
|
129
|
+
(0, node_child_process_1.execSync)(`security delete-generic-password -a "${account}" -s "${KEYCHAIN_SERVICE}" 2>/dev/null`, { stdio: 'ignore' });
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// Key wasn't in keychain — ignore
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (process.platform === 'linux') {
|
|
136
|
+
try {
|
|
137
|
+
(0, node_child_process_1.execSync)(`secret-tool clear service "${KEYCHAIN_SERVICE}" account "${account}" 2>/dev/null`, { stdio: 'ignore' });
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
// Key wasn't in keyring — ignore
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Read a previously persisted API key for this project directory.
|
|
146
|
+
* Returns null if not found in any storage.
|
|
147
|
+
*/
|
|
148
|
+
function readApiKey(installDir) {
|
|
149
|
+
return readApiKeyWithSource(installDir)?.key ?? null;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Read a previously persisted API key, also returning which storage was used.
|
|
153
|
+
* Returns null if not found in any storage.
|
|
154
|
+
*/
|
|
155
|
+
function readApiKeyWithSource(installDir) {
|
|
156
|
+
const account = projectHandle(installDir);
|
|
157
|
+
if (process.platform === 'darwin') {
|
|
158
|
+
const key = keychainRead(account);
|
|
159
|
+
if (key)
|
|
160
|
+
return { key, source: 'keychain' };
|
|
161
|
+
}
|
|
162
|
+
if (process.platform === 'linux') {
|
|
163
|
+
const key = secretToolRead(account);
|
|
164
|
+
if (key)
|
|
165
|
+
return { key, source: 'keychain' };
|
|
166
|
+
}
|
|
167
|
+
// .env.local in the project directory
|
|
168
|
+
const envKey = envRead(installDir);
|
|
169
|
+
if (envKey)
|
|
170
|
+
return { key: envKey, source: 'env' };
|
|
171
|
+
// Also honour AMPLITUDE_API_KEY from the environment (e.g. already in .env)
|
|
172
|
+
const envVar = process.env.AMPLITUDE_API_KEY;
|
|
173
|
+
if (envVar)
|
|
174
|
+
return { key: envVar, source: 'env' };
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.executeSync = executeSync;
|
|
37
|
+
exports.execute = execute;
|
|
38
|
+
const child_process = __importStar(require("child_process"));
|
|
39
|
+
function executeSync(command) {
|
|
40
|
+
const output = child_process.execSync(command);
|
|
41
|
+
return output.toString();
|
|
42
|
+
}
|
|
43
|
+
function execute(command) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
child_process.exec(command, (error, stdout, _) => {
|
|
46
|
+
if (error) {
|
|
47
|
+
reject(error);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
resolve(stdout);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a list of custom headers for ANTHROPIC_CUSTOM_HEADERS.
|
|
3
|
+
*/
|
|
4
|
+
export declare function createCustomHeaders(): {
|
|
5
|
+
add(key: string, value: string): void;
|
|
6
|
+
/** Add a feature flag for Amplitude ($feature/<flagKey>: variant). */
|
|
7
|
+
addFlag(flagKey: string, variant: string): void;
|
|
8
|
+
encode(): string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCustomHeaders = createCustomHeaders;
|
|
4
|
+
const constants_1 = require("../lib/constants");
|
|
5
|
+
/**
|
|
6
|
+
* Builds a list of custom headers for ANTHROPIC_CUSTOM_HEADERS.
|
|
7
|
+
*/
|
|
8
|
+
function createCustomHeaders() {
|
|
9
|
+
const entries = [];
|
|
10
|
+
return {
|
|
11
|
+
add(key, value) {
|
|
12
|
+
const name = key.startsWith('x-') || key.startsWith('X-') ? key : `X-${key}`;
|
|
13
|
+
entries.push({ key: name, value });
|
|
14
|
+
},
|
|
15
|
+
addFlag(flagKey, variant) {
|
|
16
|
+
const headerName = constants_1.AMPLITUDE_FLAG_HEADER_PREFIX + flagKey.toUpperCase();
|
|
17
|
+
entries.push({ key: headerName, value: variant });
|
|
18
|
+
},
|
|
19
|
+
encode() {
|
|
20
|
+
return entries.map(({ key, value }) => `${key}: ${value}`).join('\n');
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function getLogFilePath(): string;
|
|
2
|
+
/**
|
|
3
|
+
* Configure the log file path and enable/disable state.
|
|
4
|
+
* Call before initLogFile() to override defaults.
|
|
5
|
+
*/
|
|
6
|
+
export declare function configureLogFile(opts: {
|
|
7
|
+
path?: string;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
}): void;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the log file with a run header.
|
|
12
|
+
* Call this at the start of each wizard run.
|
|
13
|
+
* Fails silently to avoid crashing the wizard.
|
|
14
|
+
*/
|
|
15
|
+
export declare function initLogFile(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Log a message to the log file.
|
|
18
|
+
* Always writes regardless of debug flag (when logging is enabled).
|
|
19
|
+
* Fails silently to avoid masking errors in catch blocks.
|
|
20
|
+
*/
|
|
21
|
+
export declare function logToFile(...args: unknown[]): void;
|
|
22
|
+
export declare function debug(...args: unknown[]): void;
|
|
23
|
+
export declare function enableDebugLogs(): void;
|
|
@@ -0,0 +1,86 @@
|
|
|
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.getLogFilePath = getLogFilePath;
|
|
7
|
+
exports.configureLogFile = configureLogFile;
|
|
8
|
+
exports.initLogFile = initLogFile;
|
|
9
|
+
exports.logToFile = logToFile;
|
|
10
|
+
exports.debug = debug;
|
|
11
|
+
exports.enableDebugLogs = enableDebugLogs;
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const logging_1 = require("./logging");
|
|
15
|
+
const ui_1 = require("../ui");
|
|
16
|
+
let debugEnabled = false;
|
|
17
|
+
let logFilePath = '/tmp/amplitude-wizard.log';
|
|
18
|
+
// Disable file logging in test environments — tests write via Vitest and
|
|
19
|
+
// pollute the shared log with hundreds of synthetic "Wizard failed" entries.
|
|
20
|
+
let logEnabled = process.env.NODE_ENV !== 'test';
|
|
21
|
+
const LOG_MAX_BYTES = 5 * 1024 * 1024; // 5 MB
|
|
22
|
+
function getLogFilePath() {
|
|
23
|
+
return logFilePath;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Configure the log file path and enable/disable state.
|
|
27
|
+
* Call before initLogFile() to override defaults.
|
|
28
|
+
*/
|
|
29
|
+
function configureLogFile(opts) {
|
|
30
|
+
if (opts.path !== undefined)
|
|
31
|
+
logFilePath = opts.path;
|
|
32
|
+
if (opts.enabled !== undefined)
|
|
33
|
+
logEnabled = opts.enabled;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Initialize the log file with a run header.
|
|
37
|
+
* Call this at the start of each wizard run.
|
|
38
|
+
* Fails silently to avoid crashing the wizard.
|
|
39
|
+
*/
|
|
40
|
+
function initLogFile() {
|
|
41
|
+
if (!logEnabled)
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
// Truncate the log if it has grown too large, keeping it manageable.
|
|
45
|
+
try {
|
|
46
|
+
if ((0, fs_1.statSync)(logFilePath).size > LOG_MAX_BYTES) {
|
|
47
|
+
(0, fs_1.truncateSync)(logFilePath, 0);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// File doesn't exist yet — that's fine
|
|
52
|
+
}
|
|
53
|
+
const header = `\n${'='.repeat(60)}\nAmplitude Wizard Run: ${new Date().toISOString()}\n${'='.repeat(60)}\n`;
|
|
54
|
+
(0, fs_1.appendFileSync)(logFilePath, header);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Silently ignore - logging is non-critical
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Log a message to the log file.
|
|
62
|
+
* Always writes regardless of debug flag (when logging is enabled).
|
|
63
|
+
* Fails silently to avoid masking errors in catch blocks.
|
|
64
|
+
*/
|
|
65
|
+
function logToFile(...args) {
|
|
66
|
+
if (!logEnabled)
|
|
67
|
+
return;
|
|
68
|
+
try {
|
|
69
|
+
const timestamp = new Date().toISOString();
|
|
70
|
+
const msg = args.map((a) => (0, logging_1.prepareMessage)(a)).join(' ');
|
|
71
|
+
(0, fs_1.appendFileSync)(logFilePath, `[${timestamp}] ${msg}\n`);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Silently ignore logging failures to avoid masking original errors
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function debug(...args) {
|
|
78
|
+
if (!debugEnabled) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const msg = args.map((a) => (0, logging_1.prepareMessage)(a)).join(' ');
|
|
82
|
+
(0, ui_1.getUI)().log.info(chalk_1.default.dim(msg));
|
|
83
|
+
}
|
|
84
|
+
function enableDebugLogs() {
|
|
85
|
+
debugEnabled = true;
|
|
86
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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.isNonInteractiveEnvironment = isNonInteractiveEnvironment;
|
|
7
|
+
exports.readEnvironment = readEnvironment;
|
|
8
|
+
exports.detectEnvVarPrefix = detectEnvVarPrefix;
|
|
9
|
+
const read_env_1 = __importDefault(require("read-env"));
|
|
10
|
+
const setup_utils_1 = require("./setup-utils");
|
|
11
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
12
|
+
const constants_1 = require("../lib/constants");
|
|
13
|
+
function isNonInteractiveEnvironment() {
|
|
14
|
+
if (constants_1.IS_DEV) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (!process.stdout.isTTY || !process.stderr.isTTY) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
function readEnvironment() {
|
|
23
|
+
const result = (0, read_env_1.default)('AMPLITUDE_WIZARD');
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
async function detectEnvVarPrefix(options) {
|
|
27
|
+
const packageJson = await (0, setup_utils_1.tryGetPackageJson)(options);
|
|
28
|
+
if (!packageJson)
|
|
29
|
+
return 'VITE_PUBLIC_';
|
|
30
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
31
|
+
const has = (name) => name in deps;
|
|
32
|
+
const hasAnyFile = async (patterns) => {
|
|
33
|
+
const matches = await (0, fast_glob_1.default)(patterns, {
|
|
34
|
+
cwd: options.installDir,
|
|
35
|
+
absolute: false,
|
|
36
|
+
onlyFiles: true,
|
|
37
|
+
ignore: ['**/node_modules/**'],
|
|
38
|
+
});
|
|
39
|
+
return matches.length > 0;
|
|
40
|
+
};
|
|
41
|
+
// --- Next.js
|
|
42
|
+
if (has('next') || (await hasAnyFile(['**/next.config.{js,ts,mjs,cjs}']))) {
|
|
43
|
+
return 'NEXT_PUBLIC_';
|
|
44
|
+
}
|
|
45
|
+
// --- Create React App
|
|
46
|
+
if (has('react-scripts') ||
|
|
47
|
+
has('create-react-app') ||
|
|
48
|
+
(await hasAnyFile(['**/config-overrides.js']))) {
|
|
49
|
+
return 'REACT_APP_';
|
|
50
|
+
}
|
|
51
|
+
// --- Vite (vanilla, TanStack, Solid, etc.)
|
|
52
|
+
// Note: Vite does not need PUBLIC_ but we use it to follow the docs, to improve the chances of an LLM getting it right.
|
|
53
|
+
if (has('vite') || (await hasAnyFile(['**/vite.config.{js,ts,mjs,cjs}']))) {
|
|
54
|
+
return 'VITE_PUBLIC_';
|
|
55
|
+
}
|
|
56
|
+
// --- SvelteKit
|
|
57
|
+
if (has('@sveltejs/kit') ||
|
|
58
|
+
(await hasAnyFile(['**/svelte.config.{js,ts}']))) {
|
|
59
|
+
return 'PUBLIC_';
|
|
60
|
+
}
|
|
61
|
+
// --- TanStack Start (uses Vite)
|
|
62
|
+
if (has('@tanstack/start') ||
|
|
63
|
+
(await hasAnyFile(['**/tanstack.config.{js,ts}']))) {
|
|
64
|
+
return 'VITE_PUBLIC_';
|
|
65
|
+
}
|
|
66
|
+
// --- SolidStart (uses Vite)
|
|
67
|
+
if (has('solid-start') || (await hasAnyFile(['**/solid.config.{js,ts}']))) {
|
|
68
|
+
return 'VITE_PUBLIC_';
|
|
69
|
+
}
|
|
70
|
+
// --- Astro
|
|
71
|
+
if (has('astro') || (await hasAnyFile(['**/astro.config.{js,ts,mjs}']))) {
|
|
72
|
+
return 'PUBLIC_';
|
|
73
|
+
}
|
|
74
|
+
// We default to Vite if we can't detect a specific framework, since it's the most commonly used.
|
|
75
|
+
return 'VITE_PUBLIC_';
|
|
76
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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.getDotGitignore = getDotGitignore;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
function getDotGitignore({ installDir, }) {
|
|
10
|
+
const gitignorePath = path_1.default.join(installDir, '.gitignore');
|
|
11
|
+
const gitignoreExists = fs_1.default.existsSync(gitignorePath);
|
|
12
|
+
if (gitignoreExists) {
|
|
13
|
+
return gitignorePath;
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AmplitudeZone } from '../lib/constants.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the Amplitude project API key for a given install directory.
|
|
4
|
+
*
|
|
5
|
+
* Resolution order:
|
|
6
|
+
* 1. Local storage — keychain / .env.local / AMPLITUDE_API_KEY env var
|
|
7
|
+
* 2. Amplitude backend — fetches org/workspace data with the provided
|
|
8
|
+
* OAuth id_token and picks the lowest-ranked environment's API key
|
|
9
|
+
*
|
|
10
|
+
* Returns null only if both sources come up empty.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAPIKey(params: {
|
|
13
|
+
installDir: string;
|
|
14
|
+
idToken: string;
|
|
15
|
+
zone: AmplitudeZone;
|
|
16
|
+
workspaceId?: string;
|
|
17
|
+
}): Promise<string | null>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAPIKey = getAPIKey;
|
|
4
|
+
const api_key_store_js_1 = require("./api-key-store.js");
|
|
5
|
+
const api_js_1 = require("../lib/api.js");
|
|
6
|
+
const debug_js_1 = require("./debug.js");
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the Amplitude project API key for a given install directory.
|
|
9
|
+
*
|
|
10
|
+
* Resolution order:
|
|
11
|
+
* 1. Local storage — keychain / .env.local / AMPLITUDE_API_KEY env var
|
|
12
|
+
* 2. Amplitude backend — fetches org/workspace data with the provided
|
|
13
|
+
* OAuth id_token and picks the lowest-ranked environment's API key
|
|
14
|
+
*
|
|
15
|
+
* Returns null only if both sources come up empty.
|
|
16
|
+
*/
|
|
17
|
+
async function getAPIKey(params) {
|
|
18
|
+
const { installDir, idToken, zone, workspaceId } = params;
|
|
19
|
+
// ── 1. Local storage ────────────────────────────────────────────────────────
|
|
20
|
+
const stored = (0, api_key_store_js_1.readApiKeyWithSource)(installDir);
|
|
21
|
+
if (stored)
|
|
22
|
+
return stored.key;
|
|
23
|
+
// ── 2. Amplitude backend ────────────────────────────────────────────────────
|
|
24
|
+
try {
|
|
25
|
+
const userInfo = await (0, api_js_1.fetchAmplitudeUser)(idToken, zone);
|
|
26
|
+
let foundWorkspace = false;
|
|
27
|
+
let foundEnvWithKey = false;
|
|
28
|
+
for (const org of userInfo.orgs) {
|
|
29
|
+
const workspace = workspaceId
|
|
30
|
+
? org.workspaces.find((ws) => ws.id === workspaceId)
|
|
31
|
+
: org.workspaces[0];
|
|
32
|
+
if (!workspace?.environments)
|
|
33
|
+
continue;
|
|
34
|
+
foundWorkspace = true;
|
|
35
|
+
const envsWithKey = workspace.environments
|
|
36
|
+
.filter((env) => env.app?.apiKey)
|
|
37
|
+
.sort((a, b) => a.rank - b.rank);
|
|
38
|
+
if (envsWithKey.length > 0)
|
|
39
|
+
foundEnvWithKey = true;
|
|
40
|
+
const apiKey = envsWithKey[0]?.app?.apiKey;
|
|
41
|
+
if (apiKey)
|
|
42
|
+
return apiKey;
|
|
43
|
+
}
|
|
44
|
+
(0, debug_js_1.logToFile)(`[getAPIKey] no key found: ${userInfo.orgs.length} org(s), foundWorkspace=${foundWorkspace}, foundEnvWithKey=${foundEnvWithKey}`);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
(0, debug_js_1.logToFile)(`[getAPIKey] backend fetch failed: ${err instanceof Error ? err.constructor.name : 'unknown'}`);
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function prepareMessage(msg: unknown): string;
|
|
2
|
+
export declare function l(msg: string): void;
|
|
3
|
+
export declare function nl(): void;
|
|
4
|
+
export declare function green(msg: string): void;
|
|
5
|
+
export declare function red(msg: string): void;
|
|
6
|
+
export declare function dim(msg: string): void;
|
|
7
|
+
export declare function yellow(msg: string): void;
|
|
8
|
+
export declare function cyan(msg: string): void;
|
|
9
|
+
export declare function debug(msg: unknown): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
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.prepareMessage = prepareMessage;
|
|
7
|
+
exports.l = l;
|
|
8
|
+
exports.nl = nl;
|
|
9
|
+
exports.green = green;
|
|
10
|
+
exports.red = red;
|
|
11
|
+
exports.dim = dim;
|
|
12
|
+
exports.yellow = yellow;
|
|
13
|
+
exports.cyan = cyan;
|
|
14
|
+
exports.debug = debug;
|
|
15
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
+
function prepareMessage(msg) {
|
|
17
|
+
if (typeof msg === 'string') {
|
|
18
|
+
return msg;
|
|
19
|
+
}
|
|
20
|
+
if (msg instanceof Error) {
|
|
21
|
+
return `${msg.stack || ''}`;
|
|
22
|
+
}
|
|
23
|
+
return JSON.stringify(msg, null, '\t');
|
|
24
|
+
}
|
|
25
|
+
function l(msg) {
|
|
26
|
+
console.log(msg);
|
|
27
|
+
}
|
|
28
|
+
function nl() {
|
|
29
|
+
return l('');
|
|
30
|
+
}
|
|
31
|
+
function green(msg) {
|
|
32
|
+
return l(chalk_1.default.green(prepareMessage(msg)));
|
|
33
|
+
}
|
|
34
|
+
function red(msg) {
|
|
35
|
+
return l(chalk_1.default.red(prepareMessage(msg)));
|
|
36
|
+
}
|
|
37
|
+
function dim(msg) {
|
|
38
|
+
return l(chalk_1.default.dim(prepareMessage(msg)));
|
|
39
|
+
}
|
|
40
|
+
function yellow(msg) {
|
|
41
|
+
return l(chalk_1.default.yellow(prepareMessage(msg)));
|
|
42
|
+
}
|
|
43
|
+
function cyan(msg) {
|
|
44
|
+
return l(chalk_1.default.cyan(prepareMessage(msg)));
|
|
45
|
+
}
|
|
46
|
+
function debug(msg) {
|
|
47
|
+
return l(chalk_1.default.italic.yellow(prepareMessage(msg)));
|
|
48
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Amplitude OAuth2/PKCE flow — adapted from Amplitude wizard's oauth.ts but
|
|
3
|
+
* hitting Amplitude's auth endpoints (same as the ampli CLI).
|
|
4
|
+
*
|
|
5
|
+
* Key difference from Amplitude: checks ~/.ampli.json for an existing ampli CLI
|
|
6
|
+
* session first, so users who ran `ampli login` can skip re-authenticating.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { type AmplitudeZone } from '../lib/constants.js';
|
|
10
|
+
declare const OAuthTokenResponseSchema: z.ZodObject<{
|
|
11
|
+
access_token: z.ZodString;
|
|
12
|
+
id_token: z.ZodString;
|
|
13
|
+
refresh_token: z.ZodString;
|
|
14
|
+
token_type: z.ZodString;
|
|
15
|
+
expires_in: z.ZodNumber;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;
|
|
18
|
+
export interface AmplitudeAuthResult {
|
|
19
|
+
idToken: string;
|
|
20
|
+
accessToken: string;
|
|
21
|
+
refreshToken: string;
|
|
22
|
+
zone: AmplitudeZone;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Performs the Amplitude OAuth2/PKCE flow.
|
|
26
|
+
*
|
|
27
|
+
* 1. Checks ~/.ampli.json for a valid existing session (shared with ampli CLI),
|
|
28
|
+
* unless forceFresh is true (used for new projects with no local ampli.json).
|
|
29
|
+
* 2. If none, opens the browser to auth.amplitude.com and awaits callback.
|
|
30
|
+
* 3. Stores the resulting tokens back to ~/.ampli.json.
|
|
31
|
+
*/
|
|
32
|
+
export declare function performAmplitudeAuth(options: {
|
|
33
|
+
zone?: AmplitudeZone;
|
|
34
|
+
/** Skip cached credentials and require fresh browser auth. */
|
|
35
|
+
forceFresh?: boolean;
|
|
36
|
+
}): Promise<AmplitudeAuthResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Exchanges a stored refresh token for a new access token.
|
|
39
|
+
* Uses the same /oauth2/token endpoint as the initial auth-code exchange.
|
|
40
|
+
*/
|
|
41
|
+
export declare function refreshAccessToken(refreshToken: string, zone?: AmplitudeZone): Promise<{
|
|
42
|
+
accessToken: string;
|
|
43
|
+
idToken: string;
|
|
44
|
+
refreshToken: string;
|
|
45
|
+
expiresAt: string;
|
|
46
|
+
}>;
|
|
47
|
+
export type OAuthConfig = {
|
|
48
|
+
scopes: string[];
|
|
49
|
+
signup?: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** @deprecated Use performAmplitudeAuth() directly. */
|
|
52
|
+
export declare function performOAuthFlow(_config: OAuthConfig): Promise<OAuthTokenResponse>;
|
|
53
|
+
export {};
|