workos 0.0.24 → 0.1.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/.claude-plugin/plugin.json +13 -0
- package/LICENSE +47 -0
- package/README.md +154 -1
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +163 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.config.d.ts +52 -0
- package/dist/cli.config.js +70 -0
- package/dist/cli.config.js.map +1 -0
- package/dist/package.json +87 -0
- package/dist/src/commands/install-skill.d.ts +20 -0
- package/dist/src/commands/install-skill.js +130 -0
- package/dist/src/commands/install-skill.js.map +1 -0
- package/dist/src/commands/install.d.ts +22 -0
- package/dist/src/commands/install.js +57 -0
- package/dist/src/commands/install.js.map +1 -0
- package/dist/src/commands/login.d.ts +1 -0
- package/dist/src/commands/login.js +141 -0
- package/dist/src/commands/login.js.map +1 -0
- package/dist/src/commands/logout.d.ts +1 -0
- package/dist/src/commands/logout.js +17 -0
- package/dist/src/commands/logout.js.map +1 -0
- package/dist/src/dashboard/components/AnimatedLogo.d.ts +8 -0
- package/dist/src/dashboard/components/AnimatedLogo.js +16 -0
- package/dist/src/dashboard/components/AnimatedLogo.js.map +1 -0
- package/dist/src/dashboard/components/CompletionView.d.ts +13 -0
- package/dist/src/dashboard/components/CompletionView.js +21 -0
- package/dist/src/dashboard/components/CompletionView.js.map +1 -0
- package/dist/src/dashboard/components/ConfirmPrompt.d.ts +9 -0
- package/dist/src/dashboard/components/ConfirmPrompt.js +25 -0
- package/dist/src/dashboard/components/ConfirmPrompt.js.map +1 -0
- package/dist/src/dashboard/components/CredentialsForm.d.ts +10 -0
- package/dist/src/dashboard/components/CredentialsForm.js +47 -0
- package/dist/src/dashboard/components/CredentialsForm.js.map +1 -0
- package/dist/src/dashboard/components/Dashboard.d.ts +3 -0
- package/dist/src/dashboard/components/Dashboard.js +100 -0
- package/dist/src/dashboard/components/Dashboard.js.map +1 -0
- package/dist/src/dashboard/components/DashboardLayout.d.ts +24 -0
- package/dist/src/dashboard/components/DashboardLayout.js +25 -0
- package/dist/src/dashboard/components/DashboardLayout.js.map +1 -0
- package/dist/src/dashboard/components/DiffPanel.d.ts +9 -0
- package/dist/src/dashboard/components/DiffPanel.js +136 -0
- package/dist/src/dashboard/components/DiffPanel.js.map +1 -0
- package/dist/src/dashboard/components/InlinePrompt.d.ts +8 -0
- package/dist/src/dashboard/components/InlinePrompt.js +19 -0
- package/dist/src/dashboard/components/InlinePrompt.js.map +1 -0
- package/dist/src/dashboard/components/OutputPanel.d.ts +10 -0
- package/dist/src/dashboard/components/OutputPanel.js +100 -0
- package/dist/src/dashboard/components/OutputPanel.js.map +1 -0
- package/dist/src/dashboard/components/Panel.d.ts +12 -0
- package/dist/src/dashboard/components/Panel.js +6 -0
- package/dist/src/dashboard/components/Panel.js.map +1 -0
- package/dist/src/dashboard/components/TextInput.d.ts +13 -0
- package/dist/src/dashboard/components/TextInput.js +57 -0
- package/dist/src/dashboard/components/TextInput.js.map +1 -0
- package/dist/src/dashboard/components/WelcomeArt.d.ts +2 -0
- package/dist/src/dashboard/components/WelcomeArt.js +9 -0
- package/dist/src/dashboard/components/WelcomeArt.js.map +1 -0
- package/dist/src/dashboard/hooks/useAnimation.d.ts +7 -0
- package/dist/src/dashboard/hooks/useAnimation.js +24 -0
- package/dist/src/dashboard/hooks/useAnimation.js.map +1 -0
- package/dist/src/dashboard/hooks/useKeyboard.d.ts +8 -0
- package/dist/src/dashboard/hooks/useKeyboard.js +18 -0
- package/dist/src/dashboard/hooks/useKeyboard.js.map +1 -0
- package/dist/src/dashboard/hooks/useTerminalSize.d.ts +8 -0
- package/dist/src/dashboard/hooks/useTerminalSize.js +23 -0
- package/dist/src/dashboard/hooks/useTerminalSize.js.map +1 -0
- package/dist/src/dashboard/index.d.ts +6 -0
- package/dist/src/dashboard/index.js +36 -0
- package/dist/src/dashboard/index.js.map +1 -0
- package/dist/src/dashboard/lib/diff-utils.d.ts +21 -0
- package/dist/src/dashboard/lib/diff-utils.js +271 -0
- package/dist/src/dashboard/lib/diff-utils.js.map +1 -0
- package/dist/src/dashboard/lib/logo-frames.d.ts +20 -0
- package/dist/src/dashboard/lib/logo-frames.js +109 -0
- package/dist/src/dashboard/lib/logo-frames.js.map +1 -0
- package/dist/src/dashboard/lib/welcome-art.d.ts +1 -0
- package/dist/src/dashboard/lib/welcome-art.js +5 -0
- package/dist/src/dashboard/lib/welcome-art.js.map +1 -0
- package/dist/src/dashboard/types.d.ts +5 -0
- package/dist/src/dashboard/types.js +2 -0
- package/dist/src/dashboard/types.js.map +1 -0
- package/dist/src/lib/__tests__/test-utils.d.ts +40 -0
- package/dist/src/lib/__tests__/test-utils.js +108 -0
- package/dist/src/lib/__tests__/test-utils.js.map +1 -0
- package/dist/src/lib/adapters/cli-adapter.d.ts +56 -0
- package/dist/src/lib/adapters/cli-adapter.js +318 -0
- package/dist/src/lib/adapters/cli-adapter.js.map +1 -0
- package/dist/src/lib/adapters/dashboard-adapter.d.ts +30 -0
- package/dist/src/lib/adapters/dashboard-adapter.js +97 -0
- package/dist/src/lib/adapters/dashboard-adapter.js.map +1 -0
- package/dist/src/lib/adapters/index.d.ts +3 -0
- package/dist/src/lib/adapters/index.js +3 -0
- package/dist/src/lib/adapters/index.js.map +1 -0
- package/dist/src/lib/adapters/types.d.ts +41 -0
- package/dist/src/lib/adapters/types.js +2 -0
- package/dist/src/lib/adapters/types.js.map +1 -0
- package/dist/src/lib/agent-interface.d.ts +75 -0
- package/dist/src/lib/agent-interface.js +563 -0
- package/dist/src/lib/agent-interface.js.map +1 -0
- package/dist/src/lib/agent-runner.d.ts +9 -0
- package/dist/src/lib/agent-runner.js +213 -0
- package/dist/src/lib/agent-runner.js.map +1 -0
- package/dist/src/lib/api.d.ts +25 -0
- package/dist/src/lib/api.js +120 -0
- package/dist/src/lib/api.js.map +1 -0
- package/dist/src/lib/config.d.ts +60 -0
- package/dist/src/lib/config.js +88 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/constants.d.ts +32 -0
- package/dist/src/lib/constants.js +53 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/credentials.d.ts +19 -0
- package/dist/src/lib/credentials.js +55 -0
- package/dist/src/lib/credentials.js.map +1 -0
- package/dist/src/lib/env-writer.d.ts +14 -0
- package/dist/src/lib/env-writer.js +39 -0
- package/dist/src/lib/env-writer.js.map +1 -0
- package/dist/src/lib/events.d.ts +114 -0
- package/dist/src/lib/events.js +19 -0
- package/dist/src/lib/events.js.map +1 -0
- package/dist/src/lib/framework-config.d.ts +108 -0
- package/dist/src/lib/framework-config.js +11 -0
- package/dist/src/lib/framework-config.js.map +1 -0
- package/dist/src/lib/helper-functions.d.ts +1 -0
- package/dist/src/lib/helper-functions.js +2 -0
- package/dist/src/lib/helper-functions.js.map +1 -0
- package/dist/src/lib/port-detection.d.ts +7 -0
- package/dist/src/lib/port-detection.js +112 -0
- package/dist/src/lib/port-detection.js.map +1 -0
- package/dist/src/lib/progress-tracker.d.ts +22 -0
- package/dist/src/lib/progress-tracker.js +47 -0
- package/dist/src/lib/progress-tracker.js.map +1 -0
- package/dist/src/lib/run-with-core.d.ts +2 -0
- package/dist/src/lib/run-with-core.js +266 -0
- package/dist/src/lib/run-with-core.js.map +1 -0
- package/dist/src/lib/safe-tools.d.ts +2 -0
- package/dist/src/lib/safe-tools.js +212 -0
- package/dist/src/lib/safe-tools.js.map +1 -0
- package/dist/src/lib/settings.d.ts +59 -0
- package/dist/src/lib/settings.js +36 -0
- package/dist/src/lib/settings.js.map +1 -0
- package/dist/src/lib/token-refresh.d.ts +12 -0
- package/dist/src/lib/token-refresh.js +26 -0
- package/dist/src/lib/token-refresh.js.map +1 -0
- package/dist/src/lib/validation/build-validator.d.ts +9 -0
- package/dist/src/lib/validation/build-validator.js +118 -0
- package/dist/src/lib/validation/build-validator.js.map +1 -0
- package/dist/src/lib/validation/index.d.ts +3 -0
- package/dist/src/lib/validation/index.js +3 -0
- package/dist/src/lib/validation/index.js.map +1 -0
- package/dist/src/lib/validation/types.d.ts +41 -0
- package/dist/src/lib/validation/types.js +2 -0
- package/dist/src/lib/validation/types.js.map +1 -0
- package/dist/src/lib/validation/validator.d.ts +6 -0
- package/dist/src/lib/validation/validator.js +647 -0
- package/dist/src/lib/validation/validator.js.map +1 -0
- package/dist/src/lib/wizard-core.d.ts +200 -0
- package/dist/src/lib/wizard-core.js +392 -0
- package/dist/src/lib/wizard-core.js.map +1 -0
- package/dist/src/lib/wizard-core.types.d.ts +73 -0
- package/dist/src/lib/wizard-core.types.js +2 -0
- package/dist/src/lib/wizard-core.types.js.map +1 -0
- package/dist/src/lib/workos-management.d.ts +32 -0
- package/dist/src/lib/workos-management.js +142 -0
- package/dist/src/lib/workos-management.js.map +1 -0
- package/dist/src/nextjs/nextjs-wizard-agent.d.ts +6 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js +97 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js.map +1 -0
- package/dist/src/nextjs/utils.d.ts +8 -0
- package/dist/src/nextjs/utils.js +53 -0
- package/dist/src/nextjs/utils.js.map +1 -0
- package/dist/src/react/react-wizard-agent.d.ts +2 -0
- package/dist/src/react/react-wizard-agent.js +47 -0
- package/dist/src/react/react-wizard-agent.js.map +1 -0
- package/dist/src/react-router/react-router-wizard-agent.d.ts +6 -0
- package/dist/src/react-router/react-router-wizard-agent.js +103 -0
- package/dist/src/react-router/react-router-wizard-agent.js.map +1 -0
- package/dist/src/react-router/utils.d.ts +19 -0
- package/dist/src/react-router/utils.js +210 -0
- package/dist/src/react-router/utils.js.map +1 -0
- package/dist/src/run.d.ts +24 -0
- package/dist/src/run.js +48 -0
- package/dist/src/run.js.map +1 -0
- package/dist/src/steps/add-or-update-environment-variables.d.ts +10 -0
- package/dist/src/steps/add-or-update-environment-variables.js +155 -0
- package/dist/src/steps/add-or-update-environment-variables.js.map +1 -0
- package/dist/src/steps/index.d.ts +3 -0
- package/dist/src/steps/index.js +4 -0
- package/dist/src/steps/index.js.map +1 -0
- package/dist/src/steps/run-prettier.d.ts +5 -0
- package/dist/src/steps/run-prettier.js +54 -0
- package/dist/src/steps/run-prettier.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +8 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js +7 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/index.d.ts +6 -0
- package/dist/src/steps/upload-environment-variables/index.js +57 -0
- package/dist/src/steps/upload-environment-variables/index.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +14 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js +104 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js.map +1 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.d.ts +2 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js +49 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js.map +1 -0
- package/dist/src/telemetry.d.ts +2 -0
- package/dist/src/telemetry.js +29 -0
- package/dist/src/telemetry.js.map +1 -0
- package/dist/src/utils/analytics.d.ts +24 -0
- package/dist/src/utils/analytics.js +139 -0
- package/dist/src/utils/analytics.js.map +1 -0
- package/dist/src/utils/bash.d.ts +2 -0
- package/dist/src/utils/bash.js +17 -0
- package/dist/src/utils/bash.js.map +1 -0
- package/dist/src/utils/clack-utils.d.ts +93 -0
- package/dist/src/utils/clack-utils.js +397 -0
- package/dist/src/utils/clack-utils.js.map +1 -0
- package/dist/src/utils/clack.d.ts +5 -0
- package/dist/src/utils/clack.js +34 -0
- package/dist/src/utils/clack.js.map +1 -0
- package/dist/src/utils/cli-symbols.d.ts +32 -0
- package/dist/src/utils/cli-symbols.js +46 -0
- package/dist/src/utils/cli-symbols.js.map +1 -0
- package/dist/src/utils/debug.d.ts +7 -0
- package/dist/src/utils/debug.js +88 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/env-parser.d.ts +5 -0
- package/dist/src/utils/env-parser.js +18 -0
- package/dist/src/utils/env-parser.js.map +1 -0
- package/dist/src/utils/environment.d.ts +4 -0
- package/dist/src/utils/environment.js +69 -0
- package/dist/src/utils/environment.js.map +1 -0
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +7 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/logging.d.ts +9 -0
- package/dist/src/utils/logging.js +36 -0
- package/dist/src/utils/logging.js.map +1 -0
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +21 -0
- package/dist/src/utils/package-json.js.map +1 -0
- package/dist/src/utils/package-manager.d.ts +21 -0
- package/dist/src/utils/package-manager.js +167 -0
- package/dist/src/utils/package-manager.js.map +1 -0
- package/dist/src/utils/redact.d.ts +5 -0
- package/dist/src/utils/redact.js +29 -0
- package/dist/src/utils/redact.js.map +1 -0
- package/dist/src/utils/semver.d.ts +10 -0
- package/dist/src/utils/semver.js +43 -0
- package/dist/src/utils/semver.js.map +1 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/dist/src/utils/string.js +6 -0
- package/dist/src/utils/string.js.map +1 -0
- package/dist/src/utils/telemetry-client.d.ts +15 -0
- package/dist/src/utils/telemetry-client.js +57 -0
- package/dist/src/utils/telemetry-client.js.map +1 -0
- package/dist/src/utils/telemetry-types.d.ts +51 -0
- package/dist/src/utils/telemetry-types.js +6 -0
- package/dist/src/utils/telemetry-types.js.map +1 -0
- package/dist/src/utils/types.d.ts +80 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/src/utils/types.js.map +1 -0
- package/dist/src/utils/urls.d.ts +7 -0
- package/dist/src/utils/urls.js +8 -0
- package/dist/src/utils/urls.js.map +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.d.ts +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js +21 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js.map +1 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.d.ts +2 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.js +47 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.js.map +1 -0
- package/package.json +76 -84
- package/skills/workos-authkit-base/SKILL.md +113 -0
- package/skills/workos-authkit-nextjs/SKILL.md +115 -0
- package/skills/workos-authkit-react/SKILL.md +91 -0
- package/skills/workos-authkit-react-router/SKILL.md +106 -0
- package/skills/workos-authkit-tanstack-start/SKILL.md +104 -0
- package/skills/workos-authkit-vanilla-js/SKILL.md +81 -0
- package/build/apps/index.js +0 -50
- package/build/apps/slack.js +0 -151
- package/build/cli.js +0 -42
- package/build/config.js +0 -34
- package/build/dev.js +0 -5
- package/build/enable-api-access.png +0 -0
- package/build/groups.js +0 -480
- package/build/index.js +0 -3
- package/build/info.js +0 -69
- package/build/login.js +0 -161
- package/build/main.js +0 -214
- package/build/users.js +0 -402
- package/build/util.js +0 -157
- package/coverage/clover.xml +0 -66
- package/coverage/coverage-final.json +0 -4
- package/coverage/lcov-report/base.css +0 -212
- package/coverage/lcov-report/cli.ts.html +0 -329
- package/coverage/lcov-report/config.ts.html +0 -152
- package/coverage/lcov-report/index.html +0 -119
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -158
- package/coverage/lcov-report/util.ts.html +0 -350
- package/coverage/lcov.info +0 -121
- package/package-lock.json +0 -7617
- package/tests/util.test.ts +0 -35
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getConfig } from './settings.js';
|
|
2
|
+
export var Integration;
|
|
3
|
+
(function (Integration) {
|
|
4
|
+
Integration["nextjs"] = "nextjs";
|
|
5
|
+
Integration["react"] = "react";
|
|
6
|
+
Integration["tanstackStart"] = "tanstack-start";
|
|
7
|
+
Integration["reactRouter"] = "react-router";
|
|
8
|
+
Integration["vanillaJs"] = "vanilla-js";
|
|
9
|
+
})(Integration || (Integration = {}));
|
|
10
|
+
export function getIntegrationDescription(type) {
|
|
11
|
+
switch (type) {
|
|
12
|
+
case Integration.nextjs:
|
|
13
|
+
return 'Next.js';
|
|
14
|
+
case Integration.react:
|
|
15
|
+
return 'React (SPA)';
|
|
16
|
+
case Integration.tanstackStart:
|
|
17
|
+
return 'TanStack Start';
|
|
18
|
+
case Integration.reactRouter:
|
|
19
|
+
return 'React Router';
|
|
20
|
+
case Integration.vanillaJs:
|
|
21
|
+
return 'Vanilla JavaScript';
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(`Unknown integration ${type}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function getIntegrationChoices() {
|
|
27
|
+
return Object.keys(Integration).map((type) => ({
|
|
28
|
+
name: getIntegrationDescription(type),
|
|
29
|
+
value: type,
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
export const IS_DEV = ['test', 'development'].includes(process.env.NODE_ENV ?? '');
|
|
33
|
+
const settings = getConfig();
|
|
34
|
+
export const DEBUG = settings.logging.debugMode;
|
|
35
|
+
export const WORKOS_DOCS_URL = settings.documentation.workosDocsUrl;
|
|
36
|
+
export const WORKOS_DASHBOARD_URL = settings.documentation.dashboardUrl;
|
|
37
|
+
export const ISSUES_URL = settings.documentation.issuesUrl;
|
|
38
|
+
export const ANALYTICS_ENABLED = settings.telemetry.enabled;
|
|
39
|
+
export const WIZARD_INTERACTION_EVENT_NAME = settings.telemetry.eventName;
|
|
40
|
+
export const WORKOS_TELEMETRY_ENABLED = process.env.WORKOS_TELEMETRY !== 'false';
|
|
41
|
+
export const OAUTH_PORT = settings.legacy.oauthPort;
|
|
42
|
+
/**
|
|
43
|
+
* Common glob patterns to ignore when searching for files.
|
|
44
|
+
* Used by both Next.js and React Router integrations.
|
|
45
|
+
*/
|
|
46
|
+
export const IGNORE_PATTERNS = [
|
|
47
|
+
'**/node_modules/**',
|
|
48
|
+
'**/dist/**',
|
|
49
|
+
'**/build/**',
|
|
50
|
+
'**/public/**',
|
|
51
|
+
'**/.next/**',
|
|
52
|
+
];
|
|
53
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,8BAAe,CAAA;IACf,+CAAgC,CAAA;IAChC,2CAA4B,CAAA;IAC5B,uCAAwB,CAAA;AAC1B,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,WAAW,CAAC,MAAM;YACrB,OAAO,SAAS,CAAC;QACnB,KAAK,WAAW,CAAC,KAAK;YACpB,OAAO,aAAa,CAAC;QACvB,KAAK,WAAW,CAAC,aAAa;YAC5B,OAAO,gBAAgB,CAAC;QAC1B,KAAK,WAAW,CAAC,WAAW;YAC1B,OAAO,cAAc,CAAC;QACxB,KAAK,WAAW,CAAC,SAAS;YACxB,OAAO,oBAAoB,CAAC;QAC9B;YACE,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAOD,MAAM,UAAU,qBAAqB;IACnC,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;QACrD,IAAI,EAAE,yBAAyB,CAAC,IAAI,CAAC;QACrC,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC,CAAC;AACN,CAAC;AAOD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;AAEnF,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;AAE7B,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC;AAC3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC;AAC5D,MAAM,CAAC,MAAM,6BAA6B,GAAG,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,OAAO,CAAC;AACjF,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAa;IACvC,oBAAoB;IACpB,YAAY;IACZ,aAAa;IACb,cAAc;IACd,aAAa;CACd,CAAC","sourcesContent":["import { getConfig } from './settings.js';\n\nexport enum Integration {\n nextjs = 'nextjs',\n react = 'react',\n tanstackStart = 'tanstack-start',\n reactRouter = 'react-router',\n vanillaJs = 'vanilla-js',\n}\n\nexport function getIntegrationDescription(type: string): string {\n switch (type) {\n case Integration.nextjs:\n return 'Next.js';\n case Integration.react:\n return 'React (SPA)';\n case Integration.tanstackStart:\n return 'TanStack Start';\n case Integration.reactRouter:\n return 'React Router';\n case Integration.vanillaJs:\n return 'Vanilla JavaScript';\n default:\n throw new Error(`Unknown integration ${type}`);\n }\n}\n\ntype IntegrationChoice = {\n name: string;\n value: string;\n};\n\nexport function getIntegrationChoices(): IntegrationChoice[] {\n return Object.keys(Integration).map((type: string) => ({\n name: getIntegrationDescription(type),\n value: type,\n }));\n}\n\nexport interface Args {\n debug: boolean;\n integration: Integration;\n}\n\nexport const IS_DEV = ['test', 'development'].includes(process.env.NODE_ENV ?? '');\n\nconst settings = getConfig();\n\nexport const DEBUG = settings.logging.debugMode;\nexport const WORKOS_DOCS_URL = settings.documentation.workosDocsUrl;\nexport const WORKOS_DASHBOARD_URL = settings.documentation.dashboardUrl;\nexport const ISSUES_URL = settings.documentation.issuesUrl;\nexport const ANALYTICS_ENABLED = settings.telemetry.enabled;\nexport const WIZARD_INTERACTION_EVENT_NAME = settings.telemetry.eventName;\nexport const WORKOS_TELEMETRY_ENABLED = process.env.WORKOS_TELEMETRY !== 'false';\nexport const OAUTH_PORT = settings.legacy.oauthPort;\n\n/**\n * Common glob patterns to ignore when searching for files.\n * Used by both Next.js and React Router integrations.\n */\nexport const IGNORE_PATTERNS: string[] = [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/public/**',\n '**/.next/**',\n];\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Credentials {
|
|
2
|
+
accessToken: string;
|
|
3
|
+
expiresAt: number;
|
|
4
|
+
userId: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function getCredentialsPath(): string;
|
|
8
|
+
export declare function hasCredentials(): boolean;
|
|
9
|
+
export declare function getCredentials(): Credentials | null;
|
|
10
|
+
export declare function saveCredentials(creds: Credentials): void;
|
|
11
|
+
export declare function clearCredentials(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Check if token is actually expired (hard expiry check).
|
|
14
|
+
*/
|
|
15
|
+
export declare function isTokenExpired(creds: Credentials): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Get access token if available and not expired.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getAccessToken(): string | null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
function getCredentialsDir() {
|
|
5
|
+
return path.join(os.homedir(), '.workos');
|
|
6
|
+
}
|
|
7
|
+
export function getCredentialsPath() {
|
|
8
|
+
return path.join(getCredentialsDir(), 'credentials.json');
|
|
9
|
+
}
|
|
10
|
+
export function hasCredentials() {
|
|
11
|
+
return fs.existsSync(getCredentialsPath());
|
|
12
|
+
}
|
|
13
|
+
export function getCredentials() {
|
|
14
|
+
if (!hasCredentials())
|
|
15
|
+
return null;
|
|
16
|
+
try {
|
|
17
|
+
const content = fs.readFileSync(getCredentialsPath(), 'utf-8');
|
|
18
|
+
return JSON.parse(content);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function saveCredentials(creds) {
|
|
25
|
+
const dir = getCredentialsDir();
|
|
26
|
+
if (!fs.existsSync(dir)) {
|
|
27
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
28
|
+
}
|
|
29
|
+
fs.writeFileSync(getCredentialsPath(), JSON.stringify(creds, null, 2), {
|
|
30
|
+
mode: 0o600,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function clearCredentials() {
|
|
34
|
+
if (hasCredentials()) {
|
|
35
|
+
fs.unlinkSync(getCredentialsPath());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check if token is actually expired (hard expiry check).
|
|
40
|
+
*/
|
|
41
|
+
export function isTokenExpired(creds) {
|
|
42
|
+
return Date.now() >= creds.expiresAt;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get access token if available and not expired.
|
|
46
|
+
*/
|
|
47
|
+
export function getAccessToken() {
|
|
48
|
+
const creds = getCredentials();
|
|
49
|
+
if (!creds)
|
|
50
|
+
return null;
|
|
51
|
+
if (isTokenExpired(creds))
|
|
52
|
+
return null;
|
|
53
|
+
return creds.accessToken;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/lib/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AASzB,SAAS,iBAAiB;IACxB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,kBAAkB,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC,cAAc,EAAE;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,MAAM,GAAG,GAAG,iBAAiB,EAAE,CAAC;IAChC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,EAAE,CAAC,aAAa,CAAC,kBAAkB,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;QACrE,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,cAAc,EAAE,EAAE,CAAC;QACrB,EAAE,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAkB;IAC/C,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,SAAS,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,cAAc,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,KAAK,CAAC,WAAW,CAAC;AAC3B,CAAC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\n\nexport interface Credentials {\n accessToken: string;\n expiresAt: number;\n userId: string;\n email?: string;\n}\n\nfunction getCredentialsDir(): string {\n return path.join(os.homedir(), '.workos');\n}\n\nexport function getCredentialsPath(): string {\n return path.join(getCredentialsDir(), 'credentials.json');\n}\n\nexport function hasCredentials(): boolean {\n return fs.existsSync(getCredentialsPath());\n}\n\nexport function getCredentials(): Credentials | null {\n if (!hasCredentials()) return null;\n try {\n const content = fs.readFileSync(getCredentialsPath(), 'utf-8');\n return JSON.parse(content);\n } catch {\n return null;\n }\n}\n\nexport function saveCredentials(creds: Credentials): void {\n const dir = getCredentialsDir();\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n fs.writeFileSync(getCredentialsPath(), JSON.stringify(creds, null, 2), {\n mode: 0o600,\n });\n}\n\nexport function clearCredentials(): void {\n if (hasCredentials()) {\n fs.unlinkSync(getCredentialsPath());\n }\n}\n\n/**\n * Check if token is actually expired (hard expiry check).\n */\nexport function isTokenExpired(creds: Credentials): boolean {\n return Date.now() >= creds.expiresAt;\n}\n\n/**\n * Get access token if available and not expired.\n */\nexport function getAccessToken(): string | null {\n const creds = getCredentials();\n if (!creds) return null;\n if (isTokenExpired(creds)) return null;\n return creds.accessToken;\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface EnvVars {
|
|
2
|
+
WORKOS_API_KEY?: string;
|
|
3
|
+
WORKOS_CLIENT_ID: string;
|
|
4
|
+
WORKOS_REDIRECT_URI?: string;
|
|
5
|
+
NEXT_PUBLIC_WORKOS_REDIRECT_URI?: string;
|
|
6
|
+
WORKOS_COOKIE_PASSWORD?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Write environment variables to .env.local before agent runs.
|
|
10
|
+
* Merges with existing .env.local if present (new vars take precedence).
|
|
11
|
+
* Auto-generates WORKOS_COOKIE_PASSWORD if not provided.
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeEnvLocal(installDir: string, envVars: Partial<EnvVars>): void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { parseEnvFile } from '../utils/env-parser.js';
|
|
4
|
+
/**
|
|
5
|
+
* Generate a cryptographically secure cookie password.
|
|
6
|
+
* Returns 32-char hex string (16 random bytes).
|
|
7
|
+
* Uses Web Crypto API available in Node.js 20+
|
|
8
|
+
*/
|
|
9
|
+
function generateCookiePassword() {
|
|
10
|
+
const array = new Uint8Array(16);
|
|
11
|
+
crypto.getRandomValues(array);
|
|
12
|
+
return Array.from(array, (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Write environment variables to .env.local before agent runs.
|
|
16
|
+
* Merges with existing .env.local if present (new vars take precedence).
|
|
17
|
+
* Auto-generates WORKOS_COOKIE_PASSWORD if not provided.
|
|
18
|
+
*/
|
|
19
|
+
export function writeEnvLocal(installDir, envVars) {
|
|
20
|
+
const envPath = join(installDir, '.env.local');
|
|
21
|
+
// Read existing env if present
|
|
22
|
+
let existingEnv = {};
|
|
23
|
+
if (existsSync(envPath)) {
|
|
24
|
+
const content = readFileSync(envPath, 'utf-8');
|
|
25
|
+
existingEnv = parseEnvFile(content);
|
|
26
|
+
}
|
|
27
|
+
// Merge with new vars (new vars take precedence)
|
|
28
|
+
const merged = { ...existingEnv, ...envVars };
|
|
29
|
+
// Generate cookie password if not provided
|
|
30
|
+
if (!merged.WORKOS_COOKIE_PASSWORD) {
|
|
31
|
+
merged.WORKOS_COOKIE_PASSWORD = generateCookiePassword();
|
|
32
|
+
}
|
|
33
|
+
// Write back
|
|
34
|
+
const content = Object.entries(merged)
|
|
35
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
36
|
+
.join('\n');
|
|
37
|
+
writeFileSync(envPath, content + '\n');
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=env-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-writer.js","sourceRoot":"","sources":["../../../src/lib/env-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAUtD;;;;GAIG;AACH,SAAS,sBAAsB;IAC7B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAClF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkB,EAAE,OAAyB;IACzE,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAE/C,+BAA+B;IAC/B,IAAI,WAAW,GAA2B,EAAE,CAAC;IAC7C,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,iDAAiD;IACjD,MAAM,MAAM,GAAG,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC;IAE9C,2CAA2C;IAC3C,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,MAAM,CAAC,sBAAsB,GAAG,sBAAsB,EAAE,CAAC;IAC3D,CAAC;IAED,aAAa;IACb,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SACnC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;SACxC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { parseEnvFile } from '../utils/env-parser.js';\n\ninterface EnvVars {\n WORKOS_API_KEY?: string;\n WORKOS_CLIENT_ID: string;\n WORKOS_REDIRECT_URI?: string;\n NEXT_PUBLIC_WORKOS_REDIRECT_URI?: string;\n WORKOS_COOKIE_PASSWORD?: string;\n}\n\n/**\n * Generate a cryptographically secure cookie password.\n * Returns 32-char hex string (16 random bytes).\n * Uses Web Crypto API available in Node.js 20+\n */\nfunction generateCookiePassword(): string {\n const array = new Uint8Array(16);\n crypto.getRandomValues(array);\n return Array.from(array, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/**\n * Write environment variables to .env.local before agent runs.\n * Merges with existing .env.local if present (new vars take precedence).\n * Auto-generates WORKOS_COOKIE_PASSWORD if not provided.\n */\nexport function writeEnvLocal(installDir: string, envVars: Partial<EnvVars>): void {\n const envPath = join(installDir, '.env.local');\n\n // Read existing env if present\n let existingEnv: Record<string, string> = {};\n if (existsSync(envPath)) {\n const content = readFileSync(envPath, 'utf-8');\n existingEnv = parseEnvFile(content);\n }\n\n // Merge with new vars (new vars take precedence)\n const merged = { ...existingEnv, ...envVars };\n\n // Generate cookie password if not provided\n if (!merged.WORKOS_COOKIE_PASSWORD) {\n merged.WORKOS_COOKIE_PASSWORD = generateCookiePassword();\n }\n\n // Write back\n const content = Object.entries(merged)\n .map(([key, value]) => `${key}=${value}`)\n .join('\\n');\n\n writeFileSync(envPath, content + '\\n');\n}\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
export interface WizardEvents {
|
|
3
|
+
status: {
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
output: {
|
|
7
|
+
text: string;
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
};
|
|
10
|
+
'file:write': {
|
|
11
|
+
path: string;
|
|
12
|
+
content: string;
|
|
13
|
+
};
|
|
14
|
+
'file:edit': {
|
|
15
|
+
path: string;
|
|
16
|
+
oldContent: string;
|
|
17
|
+
newContent: string;
|
|
18
|
+
};
|
|
19
|
+
'prompt:request': {
|
|
20
|
+
id: string;
|
|
21
|
+
message: string;
|
|
22
|
+
options?: string[];
|
|
23
|
+
};
|
|
24
|
+
'prompt:response': {
|
|
25
|
+
id: string;
|
|
26
|
+
value: string;
|
|
27
|
+
};
|
|
28
|
+
'confirm:request': {
|
|
29
|
+
id: string;
|
|
30
|
+
message: string;
|
|
31
|
+
warning?: string;
|
|
32
|
+
files?: string[];
|
|
33
|
+
};
|
|
34
|
+
'confirm:response': {
|
|
35
|
+
id: string;
|
|
36
|
+
confirmed: boolean;
|
|
37
|
+
};
|
|
38
|
+
'credentials:request': {
|
|
39
|
+
requiresApiKey: boolean;
|
|
40
|
+
};
|
|
41
|
+
'credentials:response': {
|
|
42
|
+
apiKey: string;
|
|
43
|
+
clientId: string;
|
|
44
|
+
};
|
|
45
|
+
complete: {
|
|
46
|
+
success: boolean;
|
|
47
|
+
summary?: string;
|
|
48
|
+
};
|
|
49
|
+
error: {
|
|
50
|
+
message: string;
|
|
51
|
+
stack?: string;
|
|
52
|
+
};
|
|
53
|
+
'state:enter': {
|
|
54
|
+
state: string;
|
|
55
|
+
};
|
|
56
|
+
'state:exit': {
|
|
57
|
+
state: string;
|
|
58
|
+
};
|
|
59
|
+
'auth:checking': Record<string, never>;
|
|
60
|
+
'auth:required': Record<string, never>;
|
|
61
|
+
'auth:success': Record<string, never>;
|
|
62
|
+
'auth:failure': {
|
|
63
|
+
message: string;
|
|
64
|
+
};
|
|
65
|
+
'detection:start': Record<string, never>;
|
|
66
|
+
'detection:complete': {
|
|
67
|
+
integration: string;
|
|
68
|
+
};
|
|
69
|
+
'detection:none': Record<string, never>;
|
|
70
|
+
'git:checking': Record<string, never>;
|
|
71
|
+
'git:clean': Record<string, never>;
|
|
72
|
+
'git:dirty': {
|
|
73
|
+
files: string[];
|
|
74
|
+
};
|
|
75
|
+
'git:dirty:confirmed': Record<string, never>;
|
|
76
|
+
'git:dirty:cancelled': Record<string, never>;
|
|
77
|
+
'credentials:gathering': {
|
|
78
|
+
requiresApiKey: boolean;
|
|
79
|
+
};
|
|
80
|
+
'credentials:found': Record<string, never>;
|
|
81
|
+
'config:start': Record<string, never>;
|
|
82
|
+
'config:complete': Record<string, never>;
|
|
83
|
+
'agent:start': Record<string, never>;
|
|
84
|
+
'agent:progress': {
|
|
85
|
+
step: string;
|
|
86
|
+
detail?: string;
|
|
87
|
+
};
|
|
88
|
+
'agent:success': {
|
|
89
|
+
summary?: string;
|
|
90
|
+
};
|
|
91
|
+
'agent:failure': {
|
|
92
|
+
message: string;
|
|
93
|
+
stack?: string;
|
|
94
|
+
};
|
|
95
|
+
'validation:start': {
|
|
96
|
+
framework: string;
|
|
97
|
+
};
|
|
98
|
+
'validation:issues': {
|
|
99
|
+
issues: import('./validation/types.js').ValidationIssue[];
|
|
100
|
+
};
|
|
101
|
+
'validation:complete': {
|
|
102
|
+
passed: boolean;
|
|
103
|
+
issueCount: number;
|
|
104
|
+
durationMs: number;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export type WizardEventName = keyof WizardEvents;
|
|
108
|
+
export declare class WizardEventEmitter extends EventEmitter {
|
|
109
|
+
emit<K extends WizardEventName>(event: K, payload: WizardEvents[K]): boolean;
|
|
110
|
+
on<K extends WizardEventName>(event: K, listener: (payload: WizardEvents[K]) => void): this;
|
|
111
|
+
off<K extends WizardEventName>(event: K, listener: (payload: WizardEvents[K]) => void): this;
|
|
112
|
+
once<K extends WizardEventName>(event: K, listener: (payload: WizardEvents[K]) => void): this;
|
|
113
|
+
}
|
|
114
|
+
export declare function createWizardEventEmitter(): WizardEventEmitter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
export class WizardEventEmitter extends EventEmitter {
|
|
3
|
+
emit(event, payload) {
|
|
4
|
+
return super.emit(event, payload);
|
|
5
|
+
}
|
|
6
|
+
on(event, listener) {
|
|
7
|
+
return super.on(event, listener);
|
|
8
|
+
}
|
|
9
|
+
off(event, listener) {
|
|
10
|
+
return super.off(event, listener);
|
|
11
|
+
}
|
|
12
|
+
once(event, listener) {
|
|
13
|
+
return super.once(event, listener);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function createWizardEventEmitter() {
|
|
17
|
+
return new WizardEventEmitter();
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/lib/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AA8CtC,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAClD,IAAI,CAA4B,KAAQ,EAAE,OAAwB;QAChE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,EAAE,CAA4B,KAAQ,EAAE,QAA4C;QAClF,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAA4B,KAAQ,EAAE,QAA4C;QACnF,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAA4B,KAAQ,EAAE,QAA4C;QACpF,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;CACF;AAED,MAAM,UAAU,wBAAwB;IACtC,OAAO,IAAI,kBAAkB,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { EventEmitter } from 'events';\n\nexport interface WizardEvents {\n status: { message: string };\n output: { text: string; isError?: boolean };\n 'file:write': { path: string; content: string };\n 'file:edit': { path: string; oldContent: string; newContent: string };\n 'prompt:request': { id: string; message: string; options?: string[] };\n 'prompt:response': { id: string; value: string };\n 'confirm:request': { id: string; message: string; warning?: string; files?: string[] };\n 'confirm:response': { id: string; confirmed: boolean };\n 'credentials:request': { requiresApiKey: boolean };\n 'credentials:response': { apiKey: string; clientId: string };\n complete: { success: boolean; summary?: string };\n error: { message: string; stack?: string };\n\n 'state:enter': { state: string };\n 'state:exit': { state: string };\n 'auth:checking': Record<string, never>;\n 'auth:required': Record<string, never>;\n 'auth:success': Record<string, never>;\n 'auth:failure': { message: string };\n 'detection:start': Record<string, never>;\n 'detection:complete': { integration: string };\n 'detection:none': Record<string, never>;\n 'git:checking': Record<string, never>;\n 'git:clean': Record<string, never>;\n 'git:dirty': { files: string[] };\n 'git:dirty:confirmed': Record<string, never>;\n 'git:dirty:cancelled': Record<string, never>;\n 'credentials:gathering': { requiresApiKey: boolean };\n 'credentials:found': Record<string, never>;\n 'config:start': Record<string, never>;\n 'config:complete': Record<string, never>;\n 'agent:start': Record<string, never>;\n 'agent:progress': { step: string; detail?: string };\n 'agent:success': { summary?: string };\n 'agent:failure': { message: string; stack?: string };\n\n 'validation:start': { framework: string };\n 'validation:issues': { issues: import('./validation/types.js').ValidationIssue[] };\n 'validation:complete': { passed: boolean; issueCount: number; durationMs: number };\n}\n\nexport type WizardEventName = keyof WizardEvents;\n\nexport class WizardEventEmitter extends EventEmitter {\n emit<K extends WizardEventName>(event: K, payload: WizardEvents[K]): boolean {\n return super.emit(event, payload);\n }\n\n on<K extends WizardEventName>(event: K, listener: (payload: WizardEvents[K]) => void): this {\n return super.on(event, listener);\n }\n\n off<K extends WizardEventName>(event: K, listener: (payload: WizardEvents[K]) => void): this {\n return super.off(event, listener);\n }\n\n once<K extends WizardEventName>(event: K, listener: (payload: WizardEvents[K]) => void): this {\n return super.once(event, listener);\n }\n}\n\nexport function createWizardEventEmitter(): WizardEventEmitter {\n return new WizardEventEmitter();\n}\n"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Integration } from './constants.js';
|
|
2
|
+
import type { WizardOptions } from '../utils/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration interface for framework-specific agent integrations.
|
|
5
|
+
* Each framework exports a FrameworkConfig that the universal runner uses.
|
|
6
|
+
*/
|
|
7
|
+
export interface FrameworkConfig {
|
|
8
|
+
metadata: FrameworkMetadata;
|
|
9
|
+
detection: FrameworkDetection;
|
|
10
|
+
environment: EnvironmentConfig;
|
|
11
|
+
analytics: AnalyticsConfig;
|
|
12
|
+
prompts: PromptConfig;
|
|
13
|
+
ui: UIConfig;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Basic framework information and documentation
|
|
17
|
+
*/
|
|
18
|
+
export interface FrameworkMetadata {
|
|
19
|
+
/** Display name (e.g., "Next.js", "React") */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Integration type from constants */
|
|
22
|
+
integration: Integration;
|
|
23
|
+
/** URL to framework-specific WorkOS AuthKit docs */
|
|
24
|
+
docsUrl: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional URL to docs for users with unsupported framework versions.
|
|
27
|
+
* If not provided, defaults to docsUrl.
|
|
28
|
+
*/
|
|
29
|
+
unsupportedVersionDocsUrl?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional function to gather framework-specific context before agent runs.
|
|
32
|
+
* For Next.js: detects router type
|
|
33
|
+
* For React Native: detects Expo vs bare
|
|
34
|
+
*/
|
|
35
|
+
gatherContext?: (options: WizardOptions) => Promise<Record<string, any>>;
|
|
36
|
+
/**
|
|
37
|
+
* Name of the framework-specific skill for agent integration.
|
|
38
|
+
* Skills are located in .claude/skills/{skillName}/SKILL.md
|
|
39
|
+
* Will be populated per-framework in Phase 3.
|
|
40
|
+
*/
|
|
41
|
+
skillName?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Framework detection and version handling
|
|
45
|
+
*/
|
|
46
|
+
export interface FrameworkDetection {
|
|
47
|
+
/** Package name to check in package.json (e.g., "next", "react") */
|
|
48
|
+
packageName: string;
|
|
49
|
+
/** Human-readable name for error messages (e.g., "Next.js") */
|
|
50
|
+
packageDisplayName: string;
|
|
51
|
+
/** Extract version from package.json */
|
|
52
|
+
getVersion: (packageJson: any) => string | undefined;
|
|
53
|
+
/** Optional: Convert version to analytics bucket (e.g., "15.x") */
|
|
54
|
+
getVersionBucket?: (version: string) => string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Environment variable configuration
|
|
58
|
+
*/
|
|
59
|
+
export interface EnvironmentConfig {
|
|
60
|
+
/** Whether to upload env vars to hosting providers post-agent */
|
|
61
|
+
uploadToHosting: boolean;
|
|
62
|
+
/** Whether this framework requires API key (false for client-only SDKs) */
|
|
63
|
+
requiresApiKey: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Build the environment variables object for this framework.
|
|
66
|
+
* Returns the exact variable names and values to upload to hosting providers.
|
|
67
|
+
*/
|
|
68
|
+
getEnvVars: (apiKey: string, clientId: string) => Record<string, string>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Analytics configuration
|
|
72
|
+
*/
|
|
73
|
+
export interface AnalyticsConfig {
|
|
74
|
+
/** Generate tags from context (e.g., { 'nextjs-version': '15.x', 'router': 'app' }) */
|
|
75
|
+
getTags: (context: any) => Record<string, any>;
|
|
76
|
+
/** Optional: Additional event properties */
|
|
77
|
+
getEventProperties?: (context: any) => Record<string, any>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Prompt configuration
|
|
81
|
+
*/
|
|
82
|
+
export interface PromptConfig {
|
|
83
|
+
/**
|
|
84
|
+
* Optional: Additional context lines to append to base prompt
|
|
85
|
+
* For Next.js: "- Router: app"
|
|
86
|
+
* For React Native: "- Platform: Expo"
|
|
87
|
+
*/
|
|
88
|
+
getAdditionalContextLines?: (context: any) => string[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* UI messaging configuration
|
|
92
|
+
*/
|
|
93
|
+
export interface UIConfig {
|
|
94
|
+
/** Success message when agent completes */
|
|
95
|
+
successMessage: string;
|
|
96
|
+
/** Generate "What the agent did" bullets from context */
|
|
97
|
+
getOutroChanges: (context: any) => string[];
|
|
98
|
+
/** Generate "Next steps" bullets from context */
|
|
99
|
+
getOutroNextSteps: (context: any) => string[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Generate welcome message from framework name
|
|
103
|
+
*/
|
|
104
|
+
export declare function getWelcomeMessage(frameworkName: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Shared spinner message for all frameworks
|
|
107
|
+
*/
|
|
108
|
+
export declare const SPINNER_MESSAGE = "Setting up WorkOS AuthKit with login, authentication, and session management...";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate welcome message from framework name
|
|
3
|
+
*/
|
|
4
|
+
export function getWelcomeMessage(frameworkName) {
|
|
5
|
+
return `WorkOS AuthKit ${frameworkName} wizard (agent-powered)`;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Shared spinner message for all frameworks
|
|
9
|
+
*/
|
|
10
|
+
export const SPINNER_MESSAGE = 'Setting up WorkOS AuthKit with login, authentication, and session management...';
|
|
11
|
+
//# sourceMappingURL=framework-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-config.js","sourceRoot":"","sources":["../../../src/lib/framework-config.ts"],"names":[],"mappings":"AAyHA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAqB;IACrD,OAAO,kBAAkB,aAAa,yBAAyB,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,iFAAiF,CAAC","sourcesContent":["import type { Integration } from './constants.js';\nimport type { WizardOptions } from '../utils/types.js';\n\n/**\n * Configuration interface for framework-specific agent integrations.\n * Each framework exports a FrameworkConfig that the universal runner uses.\n */\nexport interface FrameworkConfig {\n metadata: FrameworkMetadata;\n detection: FrameworkDetection;\n environment: EnvironmentConfig;\n analytics: AnalyticsConfig;\n prompts: PromptConfig;\n ui: UIConfig;\n}\n\n/**\n * Basic framework information and documentation\n */\nexport interface FrameworkMetadata {\n /** Display name (e.g., \"Next.js\", \"React\") */\n name: string;\n\n /** Integration type from constants */\n integration: Integration;\n\n /** URL to framework-specific WorkOS AuthKit docs */\n docsUrl: string;\n\n /**\n * Optional URL to docs for users with unsupported framework versions.\n * If not provided, defaults to docsUrl.\n */\n unsupportedVersionDocsUrl?: string;\n\n /**\n * Optional function to gather framework-specific context before agent runs.\n * For Next.js: detects router type\n * For React Native: detects Expo vs bare\n */\n gatherContext?: (options: WizardOptions) => Promise<Record<string, any>>;\n\n /**\n * Name of the framework-specific skill for agent integration.\n * Skills are located in .claude/skills/{skillName}/SKILL.md\n * Will be populated per-framework in Phase 3.\n */\n skillName?: string;\n}\n\n/**\n * Framework detection and version handling\n */\nexport interface FrameworkDetection {\n /** Package name to check in package.json (e.g., \"next\", \"react\") */\n packageName: string;\n\n /** Human-readable name for error messages (e.g., \"Next.js\") */\n packageDisplayName: string;\n\n /** Extract version from package.json */\n getVersion: (packageJson: any) => string | undefined;\n\n /** Optional: Convert version to analytics bucket (e.g., \"15.x\") */\n getVersionBucket?: (version: string) => string;\n}\n\n/**\n * Environment variable configuration\n */\nexport interface EnvironmentConfig {\n /** Whether to upload env vars to hosting providers post-agent */\n uploadToHosting: boolean;\n\n /** Whether this framework requires API key (false for client-only SDKs) */\n requiresApiKey: boolean;\n\n /**\n * Build the environment variables object for this framework.\n * Returns the exact variable names and values to upload to hosting providers.\n */\n getEnvVars: (apiKey: string, clientId: string) => Record<string, string>;\n}\n\n/**\n * Analytics configuration\n */\nexport interface AnalyticsConfig {\n /** Generate tags from context (e.g., { 'nextjs-version': '15.x', 'router': 'app' }) */\n getTags: (context: any) => Record<string, any>;\n\n /** Optional: Additional event properties */\n getEventProperties?: (context: any) => Record<string, any>;\n}\n\n/**\n * Prompt configuration\n */\nexport interface PromptConfig {\n /**\n * Optional: Additional context lines to append to base prompt\n * For Next.js: \"- Router: app\"\n * For React Native: \"- Platform: Expo\"\n */\n getAdditionalContextLines?: (context: any) => string[];\n}\n\n/**\n * UI messaging configuration\n */\nexport interface UIConfig {\n /** Success message when agent completes */\n successMessage: string;\n\n /** Generate \"What the agent did\" bullets from context */\n getOutroChanges: (context: any) => string[];\n\n /** Generate \"Next steps\" bullets from context */\n getOutroNextSteps: (context: any) => string[];\n}\n\n/**\n * Generate welcome message from framework name\n */\nexport function getWelcomeMessage(frameworkName: string): string {\n return `WorkOS AuthKit ${frameworkName} wizard (agent-powered)`;\n}\n\n/**\n * Shared spinner message for all frameworks\n */\nexport const SPINNER_MESSAGE = 'Setting up WorkOS AuthKit with login, authentication, and session management...';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper-functions.js","sourceRoot":"","sources":["../../../src/lib/helper-functions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC","sourcesContent":["export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Integration } from './constants.js';
|
|
2
|
+
export declare function getCallbackPath(integration: Integration): string;
|
|
3
|
+
/**
|
|
4
|
+
* Detect the dev server port for a framework.
|
|
5
|
+
* Checks config files first, falls back to framework default.
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectPort(integration: Integration, installDir: string): number;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { getConfig } from './settings.js';
|
|
4
|
+
const settings = getConfig();
|
|
5
|
+
const INTEGRATION_TO_SETTINGS_KEY = {
|
|
6
|
+
nextjs: 'nextjs',
|
|
7
|
+
react: 'react',
|
|
8
|
+
'tanstack-start': 'tanstackStart',
|
|
9
|
+
'react-router': 'reactRouter',
|
|
10
|
+
'vanilla-js': 'vanillaJs',
|
|
11
|
+
};
|
|
12
|
+
function getDefaultPort(integration) {
|
|
13
|
+
const settingsKey = INTEGRATION_TO_SETTINGS_KEY[integration];
|
|
14
|
+
return settings.frameworks[settingsKey].port;
|
|
15
|
+
}
|
|
16
|
+
export function getCallbackPath(integration) {
|
|
17
|
+
const settingsKey = INTEGRATION_TO_SETTINGS_KEY[integration];
|
|
18
|
+
return settings.frameworks[settingsKey].callbackPath;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parse port from Vite config file.
|
|
22
|
+
* Looks for server.port in vite.config.{ts,js,mjs}
|
|
23
|
+
*/
|
|
24
|
+
function parseViteConfigPort(configPath) {
|
|
25
|
+
try {
|
|
26
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
27
|
+
// Match: port: 3000 or port: "3000" or port: '3000'
|
|
28
|
+
const portMatch = content.match(/port\s*:\s*['"]?(\d+)['"]?/);
|
|
29
|
+
if (portMatch) {
|
|
30
|
+
return parseInt(portMatch[1], 10);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// File doesn't exist or can't be read
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parse port from Next.js package.json scripts.
|
|
40
|
+
* Next.js uses: "dev": "next dev -p 4000" or --port 4000
|
|
41
|
+
*/
|
|
42
|
+
function parseNextConfigPort(installDir) {
|
|
43
|
+
try {
|
|
44
|
+
const packageJsonPath = join(installDir, 'package.json');
|
|
45
|
+
const content = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
46
|
+
const packageJson = JSON.parse(content);
|
|
47
|
+
const devScript = packageJson.scripts?.dev || '';
|
|
48
|
+
// Match: -p 4000, --port 4000, --port=4000
|
|
49
|
+
const portMatch = devScript.match(/-p\s+(\d+)|--port[=\s]+(\d+)/);
|
|
50
|
+
if (portMatch) {
|
|
51
|
+
return parseInt(portMatch[1] || portMatch[2], 10);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Can't read package.json
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parse port from TanStack Start app.config.ts.
|
|
61
|
+
* Uses Vinxi: server: { port: N }
|
|
62
|
+
*/
|
|
63
|
+
function parseTanStackPort(installDir) {
|
|
64
|
+
const configPaths = [join(installDir, 'app.config.ts'), join(installDir, 'app.config.js')];
|
|
65
|
+
for (const configPath of configPaths) {
|
|
66
|
+
try {
|
|
67
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
68
|
+
// Match server config with port
|
|
69
|
+
const portMatch = content.match(/server\s*:\s*\{[^}]*port\s*:\s*(\d+)/);
|
|
70
|
+
if (portMatch) {
|
|
71
|
+
return parseInt(portMatch[1], 10);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Config file doesn't exist
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Detect the dev server port for a framework.
|
|
82
|
+
* Checks config files first, falls back to framework default.
|
|
83
|
+
*/
|
|
84
|
+
export function detectPort(integration, installDir) {
|
|
85
|
+
let detectedPort = null;
|
|
86
|
+
switch (integration) {
|
|
87
|
+
case 'nextjs':
|
|
88
|
+
detectedPort = parseNextConfigPort(installDir);
|
|
89
|
+
break;
|
|
90
|
+
case 'tanstack-start':
|
|
91
|
+
detectedPort = parseTanStackPort(installDir);
|
|
92
|
+
break;
|
|
93
|
+
case 'react':
|
|
94
|
+
case 'react-router':
|
|
95
|
+
case 'vanilla-js': {
|
|
96
|
+
// Vite-based frameworks
|
|
97
|
+
const viteConfigs = [
|
|
98
|
+
join(installDir, 'vite.config.ts'),
|
|
99
|
+
join(installDir, 'vite.config.js'),
|
|
100
|
+
join(installDir, 'vite.config.mjs'),
|
|
101
|
+
];
|
|
102
|
+
for (const configPath of viteConfigs) {
|
|
103
|
+
detectedPort = parseViteConfigPort(configPath);
|
|
104
|
+
if (detectedPort)
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return detectedPort ?? getDefaultPort(integration);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=port-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port-detection.js","sourceRoot":"","sources":["../../../src/lib/port-detection.ts"],"names":[],"mappings":"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","sourcesContent":["import * as fs from 'node:fs';\nimport { join } from 'node:path';\nimport type { Integration } from './constants.js';\nimport { getConfig } from './settings.js';\n\nconst settings = getConfig();\n\nconst INTEGRATION_TO_SETTINGS_KEY: Record<Integration, string> = {\n nextjs: 'nextjs',\n react: 'react',\n 'tanstack-start': 'tanstackStart',\n 'react-router': 'reactRouter',\n 'vanilla-js': 'vanillaJs',\n};\n\nfunction getDefaultPort(integration: Integration): number {\n const settingsKey = INTEGRATION_TO_SETTINGS_KEY[integration];\n return settings.frameworks[settingsKey].port;\n}\n\nexport function getCallbackPath(integration: Integration): string {\n const settingsKey = INTEGRATION_TO_SETTINGS_KEY[integration];\n return settings.frameworks[settingsKey].callbackPath;\n}\n\n/**\n * Parse port from Vite config file.\n * Looks for server.port in vite.config.{ts,js,mjs}\n */\nfunction parseViteConfigPort(configPath: string): number | null {\n try {\n const content = fs.readFileSync(configPath, 'utf-8');\n // Match: port: 3000 or port: \"3000\" or port: '3000'\n const portMatch = content.match(/port\\s*:\\s*['\"]?(\\d+)['\"]?/);\n if (portMatch) {\n return parseInt(portMatch[1], 10);\n }\n } catch {\n // File doesn't exist or can't be read\n }\n return null;\n}\n\n/**\n * Parse port from Next.js package.json scripts.\n * Next.js uses: \"dev\": \"next dev -p 4000\" or --port 4000\n */\nfunction parseNextConfigPort(installDir: string): number | null {\n try {\n const packageJsonPath = join(installDir, 'package.json');\n const content = fs.readFileSync(packageJsonPath, 'utf-8');\n const packageJson = JSON.parse(content);\n\n const devScript = packageJson.scripts?.dev || '';\n // Match: -p 4000, --port 4000, --port=4000\n const portMatch = devScript.match(/-p\\s+(\\d+)|--port[=\\s]+(\\d+)/);\n if (portMatch) {\n return parseInt(portMatch[1] || portMatch[2], 10);\n }\n } catch {\n // Can't read package.json\n }\n return null;\n}\n\n/**\n * Parse port from TanStack Start app.config.ts.\n * Uses Vinxi: server: { port: N }\n */\nfunction parseTanStackPort(installDir: string): number | null {\n const configPaths = [join(installDir, 'app.config.ts'), join(installDir, 'app.config.js')];\n\n for (const configPath of configPaths) {\n try {\n const content = fs.readFileSync(configPath, 'utf-8');\n // Match server config with port\n const portMatch = content.match(/server\\s*:\\s*\\{[^}]*port\\s*:\\s*(\\d+)/);\n if (portMatch) {\n return parseInt(portMatch[1], 10);\n }\n } catch {\n // Config file doesn't exist\n }\n }\n return null;\n}\n\n/**\n * Detect the dev server port for a framework.\n * Checks config files first, falls back to framework default.\n */\nexport function detectPort(integration: Integration, installDir: string): number {\n let detectedPort: number | null = null;\n\n switch (integration) {\n case 'nextjs':\n detectedPort = parseNextConfigPort(installDir);\n break;\n\n case 'tanstack-start':\n detectedPort = parseTanStackPort(installDir);\n break;\n\n case 'react':\n case 'react-router':\n case 'vanilla-js': {\n // Vite-based frameworks\n const viteConfigs = [\n join(installDir, 'vite.config.ts'),\n join(installDir, 'vite.config.js'),\n join(installDir, 'vite.config.mjs'),\n ];\n for (const configPath of viteConfigs) {\n detectedPort = parseViteConfigPort(configPath);\n if (detectedPort) break;\n }\n break;\n }\n }\n\n return detectedPort ?? getDefaultPort(integration);\n}\n"]}
|