@sentry/wizard 6.10.0 → 6.12.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/CHANGELOG.md +69 -0
- package/dist/ci-ensure-runtime-loaded.sh +82 -0
- package/dist/e2e-tests/tests/angular-17.test.js +72 -82
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
- package/dist/e2e-tests/tests/angular-19.test.js +71 -80
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
- package/dist/e2e-tests/tests/cloudflare-worker.test.d.ts +1 -0
- package/dist/e2e-tests/tests/cloudflare-worker.test.js +69 -0
- package/dist/e2e-tests/tests/cloudflare-worker.test.js.map +1 -0
- package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js +2 -5
- package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js.map +1 -1
- package/dist/e2e-tests/tests/expo.test.js +36 -61
- package/dist/e2e-tests/tests/expo.test.js.map +1 -1
- package/dist/e2e-tests/tests/flutter.test.js +63 -70
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/help-message.test.js +2 -2
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +48 -76
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +89 -99
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-16.test.js +48 -45
- package/dist/e2e-tests/tests/nextjs-16.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +45 -58
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +59 -73
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/pnpm-workspace.test.js +6 -8
- package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.js +44 -80
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-router-instrumentation-api.test.d.ts +1 -0
- package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js +96 -0
- package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js.map +1 -0
- package/dist/e2e-tests/tests/react-router.test.js +165 -145
- package/dist/e2e-tests/tests/react-router.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +162 -132
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js +48 -36
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js +5 -7
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +15 -43
- package/dist/e2e-tests/utils/index.js +95 -185
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/get-e2e-test-matrix.mjs +11 -0
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/src/android/android-wizard.js +2 -4
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/angular/angular-wizard.js +4 -6
- package/dist/src/angular/angular-wizard.js.map +1 -1
- package/dist/src/angular/sdk-setup.js +1 -1
- package/dist/src/angular/sdk-setup.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +2 -4
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/code-tools.js +17 -3
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/configure-package-manager.js +18 -5
- package/dist/src/apple/configure-package-manager.js.map +1 -1
- package/dist/src/cloudflare/cloudflare-wizard.d.ts +3 -0
- package/dist/src/cloudflare/cloudflare-wizard.js +104 -0
- package/dist/src/cloudflare/cloudflare-wizard.js.map +1 -0
- package/dist/src/cloudflare/sdk-setup.d.ts +8 -0
- package/dist/src/cloudflare/sdk-setup.js +47 -0
- package/dist/src/cloudflare/sdk-setup.js.map +1 -0
- package/dist/src/cloudflare/templates.d.ts +5 -0
- package/dist/src/cloudflare/templates.js +50 -0
- package/dist/src/cloudflare/templates.js.map +1 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.js +27 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js +25 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.js +23 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.d.ts +6 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js +52 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.d.ts +17 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.js +173 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrap-worker.d.ts +33 -0
- package/dist/src/cloudflare/wrap-worker.js +116 -0
- package/dist/src/cloudflare/wrap-worker.js.map +1 -0
- package/dist/src/flutter/flutter-wizard.js +3 -6
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +0 -2
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +3 -5
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/react-native/expo.d.ts +6 -0
- package/dist/src/react-native/expo.js +27 -1
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/git.d.ts +5 -0
- package/dist/src/react-native/git.js +32 -1
- package/dist/src/react-native/git.js.map +1 -1
- package/dist/src/react-native/javascript.js +3 -1
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +14 -10
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-router/codemods/client.entry.d.ts +1 -1
- package/dist/src/react-router/codemods/client.entry.js +69 -12
- package/dist/src/react-router/codemods/client.entry.js.map +1 -1
- package/dist/src/react-router/codemods/react-router-config.js +1 -1
- package/dist/src/react-router/codemods/react-router-config.js.map +1 -1
- package/dist/src/react-router/codemods/root.js +1 -2
- package/dist/src/react-router/codemods/root.js.map +1 -1
- package/dist/src/react-router/codemods/server-entry.d.ts +1 -1
- package/dist/src/react-router/codemods/server-entry.js +39 -4
- package/dist/src/react-router/codemods/server-entry.js.map +1 -1
- package/dist/src/react-router/codemods/vite.js +46 -1
- package/dist/src/react-router/codemods/vite.js.map +1 -1
- package/dist/src/react-router/react-router-wizard.js +55 -10
- package/dist/src/react-router/react-router-wizard.js.map +1 -1
- package/dist/src/react-router/sdk-setup.d.ts +5 -3
- package/dist/src/react-router/sdk-setup.js +35 -9
- package/dist/src/react-router/sdk-setup.js.map +1 -1
- package/dist/src/react-router/templates.d.ts +2 -2
- package/dist/src/react-router/templates.js +72 -2
- package/dist/src/react-router/templates.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +2 -4
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/run.d.ts +1 -1
- package/dist/src/run.js +5 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +1 -1
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup/vite.js +1 -1
- package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +2 -4
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/abort-if-sportlight-not-supported.d.ts +5 -0
- package/dist/src/utils/abort-if-sportlight-not-supported.js +40 -0
- package/dist/src/utils/abort-if-sportlight-not-supported.js.map +1 -0
- package/dist/src/utils/ast-utils.d.ts +11 -1
- package/dist/src/utils/ast-utils.js +19 -1
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack/index.d.ts +2 -2
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/utils/clack/mcp-config.js +117 -59
- package/dist/src/utils/clack/mcp-config.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/angular/angular-wizard.test.js +2 -4
- package/dist/test/angular/angular-wizard.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +78 -0
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/configure-package-manager.test.d.ts +1 -0
- package/dist/test/apple/configure-package-manager.test.js +161 -0
- package/dist/test/apple/configure-package-manager.test.js.map +1 -0
- package/dist/test/cloudflare/create-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/create-wrangler-config.test.js +48 -0
- package/dist/test/cloudflare/create-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.js +61 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/find-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/find-wrangler-config.test.js +77 -0
- package/dist/test/cloudflare/find-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js +81 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/sdk-setup.test.d.ts +1 -0
- package/dist/test/cloudflare/sdk-setup.test.js +170 -0
- package/dist/test/cloudflare/sdk-setup.test.js.map +1 -0
- package/dist/test/cloudflare/templates.test.d.ts +1 -0
- package/dist/test/cloudflare/templates.test.js +122 -0
- package/dist/test/cloudflare/templates.test.js.map +1 -0
- package/dist/test/cloudflare/update-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/update-wrangler-config.test.js +216 -0
- package/dist/test/cloudflare/update-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/wrap-worker.test.d.ts +1 -0
- package/dist/test/cloudflare/wrap-worker.test.js +206 -0
- package/dist/test/cloudflare/wrap-worker.test.js.map +1 -0
- package/dist/test/react-native/expo.test.js +140 -0
- package/dist/test/react-native/expo.test.js.map +1 -1
- package/dist/test/react-native/git.test.d.ts +1 -0
- package/dist/test/react-native/git.test.js +160 -0
- package/dist/test/react-native/git.test.js.map +1 -0
- package/dist/test/react-router/codemods/client-entry.test.js +29 -0
- package/dist/test/react-router/codemods/client-entry.test.js.map +1 -1
- package/dist/test/react-router/codemods/root.test.js +4 -0
- package/dist/test/react-router/codemods/root.test.js.map +1 -1
- package/dist/test/react-router/codemods/server-entry.test.js +70 -0
- package/dist/test/react-router/codemods/server-entry.test.js.map +1 -1
- package/dist/test/react-router/codemods/vite.test.js +89 -0
- package/dist/test/react-router/codemods/vite.test.js.map +1 -1
- package/dist/test/react-router/sdk-setup.test.js +64 -8
- package/dist/test/react-router/sdk-setup.test.js.map +1 -1
- package/dist/test/react-router/templates.test.js +50 -0
- package/dist/test/react-router/templates.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/vite.test.js +12 -8
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
- package/dist/test/utils/ast-utils.test.js +22 -0
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/dist/test/utils/clack/mcp-config.test.js +176 -51
- package/dist/test/utils/clack/mcp-config.test.js.map +1 -1
- package/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ry from '@sentry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { debug } from '../utils/debug';\n\nconst swiftAppLaunchRegex =\n /(func\\s+application\\s*\\(\\s*_\\s+application:\\s*[^,]+,\\s*didFinishLaunchingWithOptions[^,]+:\\s*[^)]+\\s*\\)\\s+->\\s+Bool\\s+{)|func\\s+applicationDidFinishLaunching\\s*\\(\\s*_\\s+aNotification:\\s+Notification\\s*\\)\\s*{/im;\nconst objcAppLaunchRegex =\n /-\\s*\\(\\s*BOOL\\s*\\)\\s*application:\\s*\\(\\s*UIApplication\\s*\\*\\s*\\)\\s*application\\s+didFinishLaunchingWithOptions:\\s*\\(\\s*NSDictionary\\s*\\*\\s*\\)\\s*launchOptions\\s*{/im;\nconst swiftUIRegex = /@main\\s+struct[^:]+:\\s*(SwiftUI\\.)?App\\s*{/im;\n\nfunction isAppDelegateFile(filePath: string): boolean {\n debug('Checking if ' + filePath + ' is an AppDelegate file');\n const appLaunchRegex = filePath.toLowerCase().endsWith('.swift')\n ? swiftAppLaunchRegex\n : objcAppLaunchRegex;\n\n const fileContent = fs.readFileSync(filePath, 'utf8');\n return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);\n}\n\nfunction findAppDidFinishLaunchingWithOptionsInDirectory(\n dir: string,\n): string | null {\n debug('Searching for AppDelegate in directory: ' + dir);\n const files = fs.readdirSync(dir);\n const filePaths = files.map((f) => path.join(dir, f));\n return findAppDidFinishLaunchingWithOptions(filePaths);\n}\n\nfunction findAppDidFinishLaunchingWithOptions(files: string[]): string | null {\n debug(`Searching for AppDelegate in ${files.length} files`);\n\n // Iterate over subdirectories after iterating over files,\n // because the AppDelegate is usually in the top level\n const dirs: string[] = [];\n for (const filePath of files) {\n debug('Checking file: ' + filePath);\n if (\n filePath.endsWith('.swift') ||\n filePath.endsWith('.m') ||\n filePath.endsWith('.mm')\n ) {\n if (fs.existsSync(filePath) && isAppDelegateFile(filePath)) {\n debug('Found AppDelegate in ' + filePath);\n return filePath;\n }\n } else if (\n !path.basename(filePath).startsWith('.') &&\n !filePath.endsWith('.xcodeproj') &&\n !filePath.endsWith('.xcassets') &&\n fs.existsSync(filePath) &&\n fs.lstatSync(filePath).isDirectory()\n ) {\n dirs.push(filePath);\n }\n }\n\n for (const dr of dirs) {\n const result = findAppDidFinishLaunchingWithOptionsInDirectory(dr);\n if (result) {\n debug('Found AppDelegate in ' + dr);\n return result;\n }\n }\n return null;\n}\n\nexport function addCodeSnippetToProject(\n files: string[],\n dsn: string,\n enableLogs: boolean,\n): boolean {\n const appDelegate = findAppDidFinishLaunchingWithOptions(files);\n if (!appDelegate) {\n return false;\n }\n\n const fileContent = fs.readFileSync(appDelegate, 'utf8');\n const isSwift = appDelegate.toLowerCase().endsWith('.swift');\n const appLaunchRegex = isSwift ? swiftAppLaunchRegex : objcAppLaunchRegex;\n const importStatement = isSwift ? 'import Sentry\\n' : '@import Sentry;\\n';\n const checkForSentryInit = isSwift ? 'SentrySDK.start' : '[SentrySDK start';\n let codeSnippet = isSwift\n ? templates.getSwiftSnippet(dsn, enableLogs)\n : templates.getObjcSnippet(dsn, enableLogs);\n\n Sentry.setTag('code-language', isSwift ? 'swift' : 'objc');\n Sentry.setTag(\n 'ui-engine',\n swiftUIRegex.test(fileContent) ? 'swiftui' : 'uikit',\n );\n\n if (fileContent.includes(checkForSentryInit)) {\n //already initialized\n clack.log.info(\n 'Sentry is already initialized in your AppDelegate. Skipping adding the code snippet.',\n );\n return true;\n }\n\n let match = appLaunchRegex.exec(fileContent);\n if (!match) {\n const swiftUIMatch = swiftUIRegex.exec(fileContent);\n if (!swiftUIMatch) {\n // This branch is not reached, because we already checked for SwiftUI in isAppDelegateFile\n return false;\n }\n //Is SwiftUI with no init\n match = swiftUIMatch;\n codeSnippet = ` init() {\\n${codeSnippet} }`;\n }\n\n const insertIndex = match.index + match[0].length;\n let newFileContent =\n fileContent.slice(0, insertIndex) +\n '\\n' +\n codeSnippet +\n fileContent.slice(insertIndex);\n\n if (newFileContent.indexOf(importStatement) < 0) {\n const firstImport = /^[ \\t]*import +\\w+.*$/m.exec(newFileContent);\n if (firstImport) {\n const importIndex = firstImport.index + firstImport[0].length;\n newFileContent =\n newFileContent.slice(0, importIndex) +\n '\\n' +\n importStatement +\n newFileContent.slice(importIndex);\n } else {\n newFileContent = importStatement + newFileContent;\n }\n }\n\n fs.writeFileSync(appDelegate, newFileContent, 'utf8');\n\n clack.log.step('Added Sentry initialization code snippet to ' + appDelegate);\n return true;\n}\n\n/**\n * Exported for testing purposes, but should not be used in other modules.\n */\nexport let exportForTesting: {\n isAppDelegateFile: typeof isAppDelegateFile;\n findAppDidFinishLaunchingWithOptionsInDirectory: typeof findAppDidFinishLaunchingWithOptionsInDirectory;\n findAppDidFinishLaunchingWithOptions: typeof findAppDidFinishLaunchingWithOptions;\n};\nif (process.env.NODE_ENV === 'test') {\n exportForTesting = {\n isAppDelegateFile,\n findAppDidFinishLaunchingWithOptionsInDirectory,\n findAppDidFinishLaunchingWithOptions,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/apple/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAAyB;AACzB,2CAA6B;AAC7B,uDAAyC;AACzC,+EAA+E;AAC/E,sDAAwC;AACxC,0CAAuC;AAEvC,MAAM,mBAAmB,GACvB,mNAAmN,CAAC;AACtN,MAAM,kBAAkB,GACtB,qKAAqK,CAAC;AACxK,MAAM,YAAY,GAAG,8CAA8C,CAAC;AACpE,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAElD,SAAS,iBAAiB,CAAC,QAAgB;IACzC,IAAA,aAAK,EAAC,cAAc,GAAG,QAAQ,GAAG,yBAAyB,CAAC,CAAC;IAC7D,MAAM,cAAc,GAAG,QAAQ,CAAC,WAAW,EAAE,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Sentry from '@sentry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { debug } from '../utils/debug';\n\nconst swiftAppLaunchRegex =\n /(func\\s+application\\s*\\(\\s*_\\s+application:\\s*[^,]+,\\s*didFinishLaunchingWithOptions[^,]+:\\s*[^)]+\\s*\\)\\s+->\\s+Bool\\s+{)|func\\s+applicationDidFinishLaunching\\s*\\(\\s*_\\s+aNotification:\\s+Notification\\s*\\)\\s*{/im;\nconst objcAppLaunchRegex =\n /-\\s*\\(\\s*BOOL\\s*\\)\\s*application:\\s*\\(\\s*UIApplication\\s*\\*\\s*\\)\\s*application\\s+didFinishLaunchingWithOptions:\\s*\\(\\s*NSDictionary\\s*\\*\\s*\\)\\s*launchOptions\\s*{/im;\nconst swiftUIRegex = /@main\\s+struct[^:]+:\\s*(SwiftUI\\.)?App\\s*{/im;\nconst swiftUIInitRegex = /\\binit\\s*\\(\\s*\\)\\s*\\{/m;\n\nfunction isAppDelegateFile(filePath: string): boolean {\n debug('Checking if ' + filePath + ' is an AppDelegate file');\n const appLaunchRegex = filePath.toLowerCase().endsWith('.swift')\n ? swiftAppLaunchRegex\n : objcAppLaunchRegex;\n\n const fileContent = fs.readFileSync(filePath, 'utf8');\n return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);\n}\n\nfunction findAppDidFinishLaunchingWithOptionsInDirectory(\n dir: string,\n): string | null {\n debug('Searching for AppDelegate in directory: ' + dir);\n const files = fs.readdirSync(dir);\n const filePaths = files.map((f) => path.join(dir, f));\n return findAppDidFinishLaunchingWithOptions(filePaths);\n}\n\nfunction findAppDidFinishLaunchingWithOptions(files: string[]): string | null {\n debug(`Searching for AppDelegate in ${files.length} files`);\n\n // Iterate over subdirectories after iterating over files,\n // because the AppDelegate is usually in the top level\n const dirs: string[] = [];\n for (const filePath of files) {\n debug('Checking file: ' + filePath);\n if (\n filePath.endsWith('.swift') ||\n filePath.endsWith('.m') ||\n filePath.endsWith('.mm')\n ) {\n if (fs.existsSync(filePath) && isAppDelegateFile(filePath)) {\n debug('Found AppDelegate in ' + filePath);\n return filePath;\n }\n } else if (\n !path.basename(filePath).startsWith('.') &&\n !filePath.endsWith('.xcodeproj') &&\n !filePath.endsWith('.xcassets') &&\n fs.existsSync(filePath) &&\n fs.lstatSync(filePath).isDirectory()\n ) {\n dirs.push(filePath);\n }\n }\n\n for (const dr of dirs) {\n const result = findAppDidFinishLaunchingWithOptionsInDirectory(dr);\n if (result) {\n debug('Found AppDelegate in ' + dr);\n return result;\n }\n }\n return null;\n}\n\nexport function addCodeSnippetToProject(\n files: string[],\n dsn: string,\n enableLogs: boolean,\n): boolean {\n const appDelegate = findAppDidFinishLaunchingWithOptions(files);\n if (!appDelegate) {\n return false;\n }\n\n const fileContent = fs.readFileSync(appDelegate, 'utf8');\n const isSwift = appDelegate.toLowerCase().endsWith('.swift');\n const appLaunchRegex = isSwift ? swiftAppLaunchRegex : objcAppLaunchRegex;\n const importStatement = isSwift ? 'import Sentry\\n' : '@import Sentry;\\n';\n const checkForSentryInit = isSwift ? 'SentrySDK.start' : '[SentrySDK start';\n let codeSnippet = isSwift\n ? templates.getSwiftSnippet(dsn, enableLogs)\n : templates.getObjcSnippet(dsn, enableLogs);\n\n Sentry.setTag('code-language', isSwift ? 'swift' : 'objc');\n Sentry.setTag(\n 'ui-engine',\n swiftUIRegex.test(fileContent) ? 'swiftui' : 'uikit',\n );\n\n if (fileContent.includes(checkForSentryInit)) {\n //already initialized\n clack.log.info(\n 'Sentry is already initialized in your AppDelegate. Skipping adding the code snippet.',\n );\n return true;\n }\n\n let match = appLaunchRegex.exec(fileContent);\n if (!match) {\n const swiftUIMatch = swiftUIRegex.exec(fileContent);\n if (!swiftUIMatch) {\n // This branch is not reached, because we already checked for SwiftUI in isAppDelegateFile\n return false;\n }\n\n const afterStructContent = fileContent.slice(swiftUIMatch.index);\n const bodyMatch = /var\\s+body\\s*:/m.exec(afterStructContent);\n const searchRange = bodyMatch\n ? afterStructContent.slice(0, bodyMatch.index)\n : afterStructContent;\n\n const initMatch = swiftUIInitRegex.exec(searchRange);\n\n if (initMatch) {\n match = {\n index: swiftUIMatch.index + initMatch.index,\n 0: initMatch[0],\n } as RegExpExecArray;\n } else {\n match = swiftUIMatch;\n codeSnippet = ` init() {\\n${codeSnippet} }`;\n }\n }\n\n const insertIndex = match.index + match[0].length;\n let newFileContent =\n fileContent.slice(0, insertIndex) +\n '\\n' +\n codeSnippet +\n fileContent.slice(insertIndex);\n\n if (newFileContent.indexOf(importStatement) < 0) {\n const firstImport = /^[ \\t]*import +\\w+.*$/m.exec(newFileContent);\n if (firstImport) {\n const importIndex = firstImport.index + firstImport[0].length;\n newFileContent =\n newFileContent.slice(0, importIndex) +\n '\\n' +\n importStatement +\n newFileContent.slice(importIndex);\n } else {\n newFileContent = importStatement + newFileContent;\n }\n }\n\n fs.writeFileSync(appDelegate, newFileContent, 'utf8');\n\n clack.log.step('Added Sentry initialization code snippet to ' + appDelegate);\n return true;\n}\n\n/**\n * Exported for testing purposes, but should not be used in other modules.\n */\nexport let exportForTesting: {\n isAppDelegateFile: typeof isAppDelegateFile;\n findAppDidFinishLaunchingWithOptionsInDirectory: typeof findAppDidFinishLaunchingWithOptionsInDirectory;\n findAppDidFinishLaunchingWithOptions: typeof findAppDidFinishLaunchingWithOptions;\n};\nif (process.env.NODE_ENV === 'test') {\n exportForTesting = {\n isAppDelegateFile,\n findAppDidFinishLaunchingWithOptionsInDirectory,\n findAppDidFinishLaunchingWithOptions,\n };\n}\n"]}
|
|
@@ -44,12 +44,25 @@ async function configurePackageManager({ projectDir, }) {
|
|
|
44
44
|
Sentry.setTag('cocoapod-exists', isCocoaPodsAvailable);
|
|
45
45
|
(0, debug_1.debug)(`CocoaPods is ${isCocoaPodsAvailable ? 'installed' : 'not installed'}`);
|
|
46
46
|
if (isCocoaPodsAvailable) {
|
|
47
|
-
|
|
48
|
-
// Otherwise, we can just use the Swift Package Manager.
|
|
47
|
+
prompts_1.default.log.warn('CocoaPods is being deprecated. No new updates will be released after June 2026.\nWe recommend migrating to Swift Package Manager (SPM).');
|
|
49
48
|
(0, debug_1.debug)('Asking user to choose a package manager');
|
|
50
|
-
const pm =
|
|
49
|
+
const pm = await (0, telemetry_1.traceStep)('Choose a package manager', () => (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
50
|
+
message: 'Which package manager would you like to use to add Sentry?',
|
|
51
|
+
options: [
|
|
52
|
+
{
|
|
53
|
+
value: 'SPM',
|
|
54
|
+
label: 'Swift Package Manager',
|
|
55
|
+
hint: 'Recommended',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: 'CocoaPods',
|
|
59
|
+
label: 'CocoaPods',
|
|
60
|
+
hint: 'Deprecated - no updates after June 2026',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
})));
|
|
51
64
|
(0, debug_1.debug)(`User chose package manager: ${chalk_1.default.cyan(pm)}`);
|
|
52
|
-
shouldUseSPM = pm === '
|
|
65
|
+
shouldUseSPM = pm === 'SPM';
|
|
53
66
|
if (!shouldUseSPM) {
|
|
54
67
|
(0, debug_1.debug)('Adding CocoaPods reference');
|
|
55
68
|
const podAdded = await (0, telemetry_1.traceStep)('Add CocoaPods reference', () => cocoapod.addCocoaPods(projectDir));
|
|
@@ -61,7 +74,7 @@ async function configurePackageManager({ projectDir, }) {
|
|
|
61
74
|
}
|
|
62
75
|
}
|
|
63
76
|
(0, debug_1.debug)(`Should use SPM: ${chalk_1.default.cyan(shouldUseSPM.toString())}`);
|
|
64
|
-
Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : '
|
|
77
|
+
Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : 'CocoaPods');
|
|
65
78
|
return { shouldUseSPM };
|
|
66
79
|
}
|
|
67
80
|
exports.configurePackageManager = configurePackageManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure-package-manager.js","sourceRoot":"","sources":["../../../src/apple/configure-package-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAE1B,4CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"configure-package-manager.js","sourceRoot":"","sources":["../../../src/apple/configure-package-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAE1B,4CAAyC;AACzC,0CAAkD;AAClD,0CAAuC;AACvC,qDAAuC;AAEhC,KAAK,UAAU,uBAAuB,CAAC,EAC5C,UAAU,GAGX;IACC,IAAA,aAAK,EACH,+CAA+C,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CACxE,CAAC;IAEF,8EAA8E;IAC9E,qDAAqD;IACrD,IAAI,YAAY,GAAG,IAAI,CAAC;IAExB,MAAM,oBAAoB,GAAG,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC/D,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;IACvD,IAAA,aAAK,EAAC,gBAAgB,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;IAE9E,IAAI,oBAAoB,EAAE;QACxB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,yIAAyI,CAC1I,CAAC;QAEF,IAAA,aAAK,EAAC,yCAAyC,CAAC,CAAC;QACjD,MAAM,EAAE,GAAwB,MAAM,IAAA,qBAAS,EAC7C,0BAA0B,EAC1B,GAAG,EAAE,CACH,IAAA,wBAAgB,EACd,iBAAK,CAAC,MAAM,CAAC;YACX,OAAO,EACL,4DAA4D;YAC9D,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,uBAAuB;oBAC9B,IAAI,EAAE,aAAa;iBACpB;gBACD;oBACE,KAAK,EAAE,WAAW;oBAClB,KAAK,EAAE,WAAW;oBAClB,IAAI,EAAE,yCAAyC;iBAChD;aACF;SACF,CAAC,CACH,CACJ,CAAC;QACF,IAAA,aAAK,EAAC,+BAA+B,eAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAEvD,YAAY,GAAG,EAAE,KAAK,KAAK,CAAC;QAE5B,IAAI,CAAC,YAAY,EAAE;YACjB,IAAA,aAAK,EAAC,4BAA4B,CAAC,CAAC;YACpC,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAS,EAAC,yBAAyB,EAAE,GAAG,EAAE,CAC/D,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,CAClC,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;YAC1C,IAAA,aAAK,EAAC,8BAA8B,eAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;YAEvE,IAAI,CAAC,QAAQ,EAAE;gBACb,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,yKAAyK,CAC1K,CAAC;aACH;SACF;KACF;IACD,IAAA,aAAK,EAAC,mBAAmB,eAAK,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAChE,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAErE,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AApED,0DAoEC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\n\nimport { traceStep } from '../telemetry';\nimport { abortIfCancelled } from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport * as cocoapod from './cocoapod';\n\nexport async function configurePackageManager({\n projectDir,\n}: {\n projectDir: string;\n}) {\n debug(\n `Checking if CocoaPods is installed at path: ${chalk.cyan(projectDir)}`,\n );\n\n // Xcode ships with the Swift Package Manager and potentially using CocoaPods.\n // We need to check if the user has CocoaPods set up.\n let shouldUseSPM = true;\n\n const isCocoaPodsAvailable = cocoapod.usesCocoaPod(projectDir);\n Sentry.setTag('cocoapod-exists', isCocoaPodsAvailable);\n debug(`CocoaPods is ${isCocoaPodsAvailable ? 'installed' : 'not installed'}`);\n\n if (isCocoaPodsAvailable) {\n clack.log.warn(\n 'CocoaPods is being deprecated. No new updates will be released after June 2026.\\nWe recommend migrating to Swift Package Manager (SPM).',\n );\n\n debug('Asking user to choose a package manager');\n const pm: 'SPM' | 'CocoaPods' = await traceStep(\n 'Choose a package manager',\n () =>\n abortIfCancelled(\n clack.select({\n message:\n 'Which package manager would you like to use to add Sentry?',\n options: [\n {\n value: 'SPM',\n label: 'Swift Package Manager',\n hint: 'Recommended',\n },\n {\n value: 'CocoaPods',\n label: 'CocoaPods',\n hint: 'Deprecated - no updates after June 2026',\n },\n ],\n }),\n ),\n );\n debug(`User chose package manager: ${chalk.cyan(pm)}`);\n\n shouldUseSPM = pm === 'SPM';\n\n if (!shouldUseSPM) {\n debug('Adding CocoaPods reference');\n const podAdded = await traceStep('Add CocoaPods reference', () =>\n cocoapod.addCocoaPods(projectDir),\n );\n Sentry.setTag('cocoapod-added', podAdded);\n debug(`CocoaPods reference added: ${chalk.cyan(podAdded.toString())}`);\n\n if (!podAdded) {\n clack.log.warn(\n \"Could not add Sentry pod to your Podfile. You'll have to add it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install\",\n );\n }\n }\n }\n debug(`Should use SPM: ${chalk.cyan(shouldUseSPM.toString())}`);\n Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : 'CocoaPods');\n\n return { shouldUseSPM };\n}\n"]}
|
|
@@ -0,0 +1,104 @@
|
|
|
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.buildOutroMessage = exports.runCloudflareWizard = void 0;
|
|
7
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
8
|
+
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const telemetry_1 = require("../telemetry");
|
|
11
|
+
const clack_1 = require("../utils/clack");
|
|
12
|
+
const mcp_config_1 = require("../utils/clack/mcp-config");
|
|
13
|
+
const package_json_1 = require("../utils/package-json");
|
|
14
|
+
const sdk_setup_1 = require("./sdk-setup");
|
|
15
|
+
const abort_if_sportlight_not_supported_1 = require("../utils/abort-if-sportlight-not-supported");
|
|
16
|
+
const ensure_wrangler_config_1 = require("./wrangler/ensure-wrangler-config");
|
|
17
|
+
const update_wrangler_config_1 = require("./wrangler/update-wrangler-config");
|
|
18
|
+
const debug_1 = require("../utils/debug");
|
|
19
|
+
const get_entry_point_from_wrangler_config_1 = require("./wrangler/get-entry-point-from-wrangler-config");
|
|
20
|
+
async function runCloudflareWizard(options) {
|
|
21
|
+
return (0, telemetry_1.withTelemetry)({
|
|
22
|
+
enabled: options.telemetryEnabled,
|
|
23
|
+
integration: 'cloudflare',
|
|
24
|
+
wizardOptions: options,
|
|
25
|
+
}, () => runCloudflareWizardWithTelemetry(options));
|
|
26
|
+
}
|
|
27
|
+
exports.runCloudflareWizard = runCloudflareWizard;
|
|
28
|
+
async function runCloudflareWizardWithTelemetry(options) {
|
|
29
|
+
const { promoCode, telemetryEnabled, forceInstall } = options;
|
|
30
|
+
(0, clack_1.printWelcome)({
|
|
31
|
+
wizardName: 'Sentry Cloudflare Wizard',
|
|
32
|
+
promoCode,
|
|
33
|
+
telemetryEnabled,
|
|
34
|
+
});
|
|
35
|
+
await (0, clack_1.confirmContinueIfNoOrDirtyGitRepo)({
|
|
36
|
+
ignoreGitChanges: options.ignoreGitChanges,
|
|
37
|
+
cwd: undefined,
|
|
38
|
+
});
|
|
39
|
+
const packageJson = await (0, clack_1.getPackageDotJson)();
|
|
40
|
+
await (0, clack_1.ensurePackageIsInstalled)(packageJson, 'wrangler', 'Cloudflare');
|
|
41
|
+
(0, telemetry_1.traceStep)('Ensure Wrangler config', () => {
|
|
42
|
+
(0, ensure_wrangler_config_1.ensureWranglerConfig)();
|
|
43
|
+
});
|
|
44
|
+
const projectData = await (0, clack_1.getOrAskForProjectData)(options, 'node-cloudflare-workers');
|
|
45
|
+
if (projectData.spotlight) {
|
|
46
|
+
return (0, abort_if_sportlight_not_supported_1.abortIfSpotlightNotSupported)('Cloudflare');
|
|
47
|
+
}
|
|
48
|
+
const { selectedProject } = projectData;
|
|
49
|
+
await (0, clack_1.installPackage)({
|
|
50
|
+
packageName: '@sentry/cloudflare@^10',
|
|
51
|
+
packageNameDisplayLabel: '@sentry/cloudflare',
|
|
52
|
+
alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/cloudflare', packageJson),
|
|
53
|
+
forceInstall,
|
|
54
|
+
});
|
|
55
|
+
const selectedFeatures = await (0, clack_1.featureSelectionPrompt)([
|
|
56
|
+
{
|
|
57
|
+
id: 'performance',
|
|
58
|
+
prompt: `Do you want to enable ${chalk_1.default.bold('Tracing')} to track the performance of your application?`,
|
|
59
|
+
enabledHint: 'recommended',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'logs',
|
|
63
|
+
prompt: `Do you want to enable ${chalk_1.default.bold('Logs')} to send your application logs to Sentry?`,
|
|
64
|
+
enabledHint: 'recommended',
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
67
|
+
await (0, telemetry_1.traceStep)('Create Sentry initialization', async () => {
|
|
68
|
+
try {
|
|
69
|
+
await (0, sdk_setup_1.createSentryInitFile)(selectedProject.keys[0].dsn.public, selectedFeatures);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
prompts_1.default.log.warn('Could not automatically set up Sentry initialization. Please set it up manually using instructions from https://docs.sentry.io/platforms/javascript/guides/cloudflare/');
|
|
73
|
+
(0, debug_1.debug)(e);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const mainFile = (0, get_entry_point_from_wrangler_config_1.getEntryPointFromWranglerConfig)();
|
|
77
|
+
await (0, telemetry_1.traceStep)('Update Wrangler config with Sentry requirements', () => (0, update_wrangler_config_1.updateWranglerConfig)({
|
|
78
|
+
...(mainFile ? {} : { main: get_entry_point_from_wrangler_config_1.defaultEntryPoint }),
|
|
79
|
+
compatibility_flags: ['nodejs_als'],
|
|
80
|
+
compatibility_date: new Date().toISOString().slice(0, 10),
|
|
81
|
+
version_metadata: {
|
|
82
|
+
binding: 'CF_VERSION_METADATA',
|
|
83
|
+
},
|
|
84
|
+
}));
|
|
85
|
+
await (0, clack_1.runPrettierIfInstalled)({ cwd: undefined });
|
|
86
|
+
// Offer optional project-scoped MCP config for Sentry with org and project scope
|
|
87
|
+
await (0, mcp_config_1.offerProjectScopedMcpConfig)(selectedProject.organization.slug, selectedProject.slug);
|
|
88
|
+
prompts_1.default.outro(buildOutroMessage());
|
|
89
|
+
}
|
|
90
|
+
function buildOutroMessage() {
|
|
91
|
+
return `
|
|
92
|
+
${chalk_1.default.green('Sentry has been successfully configured for your Cloudflare project.')}
|
|
93
|
+
|
|
94
|
+
${chalk_1.default.dim('Next steps:')}
|
|
95
|
+
${chalk_1.default.dim('1. Wrap your worker with Sentry as instructed above')}
|
|
96
|
+
${chalk_1.default.dim('2. Deploy your application with:')} ${chalk_1.default.cyan('wrangler deploy')}
|
|
97
|
+
${chalk_1.default.dim('3. Trigger an error to test Sentry integration')}
|
|
98
|
+
|
|
99
|
+
${chalk_1.default.cyan(`To learn more about using Sentry with Cloudflare, visit:
|
|
100
|
+
https://docs.sentry.io/platforms/javascript/guides/cloudflare/`)}
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
exports.buildOutroMessage = buildOutroMessage;
|
|
104
|
+
//# sourceMappingURL=cloudflare-wizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare-wizard.js","sourceRoot":"","sources":["../../../src/cloudflare/cloudflare-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,4CAAwD;AACxD,0CASwB;AACxB,0DAAwE;AACxE,wDAA4D;AAE5D,2CAAmD;AACnD,kGAA0F;AAC1F,8EAAyE;AACzE,8EAAyE;AACzE,0CAAuC;AACvC,0GAGyD;AAElD,KAAK,UAAU,mBAAmB,CACvC,OAAsB;IAEtB,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,YAAY;QACzB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAChD,CAAC;AACJ,CAAC;AAXD,kDAWC;AAED,KAAK,UAAU,gCAAgC,CAC7C,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,0BAA0B;QACtC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,MAAM,IAAA,gCAAwB,EAAC,WAAW,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAEtE,IAAA,qBAAS,EAAC,wBAAwB,EAAE,GAAG,EAAE;QACvC,I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,EAAE,GAAG,EAAE,CACtE,IAAA,6CAAoB,EAAC;QACnB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,wDAAiB,EAAE,CAAC;QAChD,mBAAmB,EAAE,CAAC,YAAY,CAAC;QACnC,kBAAkB,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QACzD,gBAAgB,EAAE;YAChB,OAAO,EAAE,qBAAqB;SAC/B;KACF,CAAC,CACH,CAAC;IAEF,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iFAAiF;IACjF,MAAM,IAAA,wCAA2B,EAC/B,eAAe,CAAC,YAAY,CAAC,IAAI,EACjC,eAAe,CAAC,IAAI,CACrB,CAAC;IAEF,iBAAK,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,iBAAiB;IAC/B,OAAO;IACL,eAAK,CAAC,KAAK,CACX,sEAAsE,CACvE;;IAEC,eAAK,CAAC,GAAG,CAAC,aAAa,CAAC;IACxB,eAAK,CAAC,GAAG,CAAC,qDAAqD,CAAC;IAChE,eAAK,CAAC,GAAG,CAAC,kCAAkC,CAAC,IAAI,eAAK,CAAC,IAAI,CAC3D,iBAAiB,CAClB;IACC,eAAK,CAAC,GAAG,CAAC,gDAAgD,CAAC;;IAE3D,eAAK,CAAC,IAAI,CACV;iEAC6D,CAC9D;GACA,CAAC;AACJ,CAAC;AAlBD,8CAkBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { createSentryInitFile } from './sdk-setup';\nimport { abortIfSpotlightNotSupported } from '../utils/abort-if-sportlight-not-supported';\nimport { ensureWranglerConfig } from './wrangler/ensure-wrangler-config';\nimport { updateWranglerConfig } from './wrangler/update-wrangler-config';\nimport { debug } from '../utils/debug';\nimport {\n defaultEntryPoint,\n getEntryPointFromWranglerConfig,\n} from './wrangler/get-entry-point-from-wrangler-config';\n\nexport async function runCloudflareWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'cloudflare',\n wizardOptions: options,\n },\n () => runCloudflareWizardWithTelemetry(options),\n );\n}\n\nasync function runCloudflareWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Cloudflare Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, 'wrangler', 'Cloudflare');\n\n traceStep('Ensure Wrangler config', () => {\n ensureWranglerConfig();\n });\n\n const projectData = await getOrAskForProjectData(\n options,\n 'node-cloudflare-workers',\n );\n\n if (projectData.spotlight) {\n return abortIfSpotlightNotSupported('Cloudflare');\n }\n\n const { selectedProject } = projectData;\n\n await installPackage({\n packageName: '@sentry/cloudflare@^10',\n packageNameDisplayLabel: '@sentry/cloudflare',\n alreadyInstalled: hasPackageInstalled('@sentry/cloudflare', packageJson),\n forceInstall,\n });\n\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'recommended',\n },\n ] as const);\n\n await traceStep('Create Sentry initialization', async () => {\n try {\n await createSentryInitFile(\n selectedProject.keys[0].dsn.public,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not automatically set up Sentry initialization. Please set it up manually using instructions from https://docs.sentry.io/platforms/javascript/guides/cloudflare/',\n );\n debug(e);\n }\n });\n\n const mainFile = getEntryPointFromWranglerConfig();\n\n await traceStep('Update Wrangler config with Sentry requirements', () =>\n updateWranglerConfig({\n ...(mainFile ? {} : { main: defaultEntryPoint }),\n compatibility_flags: ['nodejs_als'],\n compatibility_date: new Date().toISOString().slice(0, 10),\n version_metadata: {\n binding: 'CF_VERSION_METADATA',\n },\n }),\n );\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.outro(buildOutroMessage());\n}\n\nexport function buildOutroMessage(): string {\n return `\n ${chalk.green(\n 'Sentry has been successfully configured for your Cloudflare project.',\n )}\n\n ${chalk.dim('Next steps:')}\n ${chalk.dim('1. Wrap your worker with Sentry as instructed above')}\n ${chalk.dim('2. Deploy your application with:')} ${chalk.cyan(\n 'wrangler deploy',\n )}\n ${chalk.dim('3. Trigger an error to test Sentry integration')}\n\n ${chalk.cyan(\n `To learn more about using Sentry with Cloudflare, visit:\n https://docs.sentry.io/platforms/javascript/guides/cloudflare/`,\n )}\n `;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates or updates the main worker file with Sentry initialization.
|
|
3
|
+
* Currently focused on Cloudflare Workers
|
|
4
|
+
*/
|
|
5
|
+
export declare function createSentryInitFile(dsn: string, selectedFeatures: {
|
|
6
|
+
performance: boolean;
|
|
7
|
+
logs: boolean;
|
|
8
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,47 @@
|
|
|
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.createSentryInitFile = void 0;
|
|
7
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
8
|
+
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const templates_1 = require("./templates");
|
|
13
|
+
const get_entry_point_from_wrangler_config_1 = require("./wrangler/get-entry-point-from-wrangler-config");
|
|
14
|
+
const wrap_worker_1 = require("./wrap-worker");
|
|
15
|
+
/**
|
|
16
|
+
* Creates or updates the main worker file with Sentry initialization.
|
|
17
|
+
* Currently focused on Cloudflare Workers
|
|
18
|
+
*/
|
|
19
|
+
async function createSentryInitFile(dsn, selectedFeatures) {
|
|
20
|
+
const entryPointFromConfig = (0, get_entry_point_from_wrangler_config_1.getEntryPointFromWranglerConfig)();
|
|
21
|
+
if (!entryPointFromConfig) {
|
|
22
|
+
prompts_1.default.log.info('No entry point found in wrangler config, creating a new one.');
|
|
23
|
+
const cloudflareWorkerTemplate = (0, templates_1.getCloudflareWorkerTemplateWithHandler)();
|
|
24
|
+
await node_fs_1.default.promises.mkdir(node_path_1.default.join(process.cwd(), node_path_1.default.dirname(get_entry_point_from_wrangler_config_1.defaultEntryPoint)), {
|
|
25
|
+
recursive: true,
|
|
26
|
+
});
|
|
27
|
+
await node_fs_1.default.promises.writeFile(node_path_1.default.join(process.cwd(), get_entry_point_from_wrangler_config_1.defaultEntryPoint), cloudflareWorkerTemplate, { encoding: 'utf-8', flag: 'w' });
|
|
28
|
+
prompts_1.default.log.success(`Created ${chalk_1.default.cyan(get_entry_point_from_wrangler_config_1.defaultEntryPoint)}.`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const entryPointPath = node_path_1.default.join(process.cwd(), entryPointFromConfig);
|
|
32
|
+
if (node_fs_1.default.existsSync(entryPointPath)) {
|
|
33
|
+
prompts_1.default.log.info(`Found existing entry point: ${chalk_1.default.cyan(entryPointFromConfig)}`);
|
|
34
|
+
try {
|
|
35
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(entryPointPath, dsn, selectedFeatures);
|
|
36
|
+
prompts_1.default.log.success(`Wrapped ${chalk_1.default.cyan(entryPointFromConfig)} with Sentry initialization.`);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
prompts_1.default.log.warn('Failed to wrap worker automatically.');
|
|
40
|
+
prompts_1.default.log.step('Please wrap your handler with Sentry initialization:');
|
|
41
|
+
prompts_1.default.note(chalk_1.default.cyan((0, templates_1.getCloudflareWorkerTemplate)(dsn, selectedFeatures)));
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.createSentryInitFile = createSentryInitFile;
|
|
47
|
+
//# sourceMappingURL=sdk-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/cloudflare/sdk-setup.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,sDAAyB;AACzB,0DAA6B;AAC7B,2CAGqB;AACrB,0GAGyD;AACzD,+CAAqD;AAErD;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CACxC,GAAW,EACX,gBAGC;IAED,MAAM,oBAAoB,GAAG,IAAA,sEAA+B,GAAE,CAAC;IAE/D,IAAI,CAAC,oBAAoB,EAAE;QACzB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,8D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AAC,IAAI,CACR,eAAK,CAAC,IAAI,CAAC,IAAA,uCAA2B,EAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAC/D,CAAC;SACH;QACD,OAAO;KACR;AACH,CAAC;AAzDD,oDAyDC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport {\n getCloudflareWorkerTemplate,\n getCloudflareWorkerTemplateWithHandler,\n} from './templates';\nimport {\n defaultEntryPoint,\n getEntryPointFromWranglerConfig,\n} from './wrangler/get-entry-point-from-wrangler-config';\nimport { wrapWorkerWithSentry } from './wrap-worker';\n\n/**\n * Creates or updates the main worker file with Sentry initialization.\n * Currently focused on Cloudflare Workers\n */\nexport async function createSentryInitFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n logs: boolean;\n },\n): Promise<void> {\n const entryPointFromConfig = getEntryPointFromWranglerConfig();\n\n if (!entryPointFromConfig) {\n clack.log.info(\n 'No entry point found in wrangler config, creating a new one.',\n );\n\n const cloudflareWorkerTemplate = getCloudflareWorkerTemplateWithHandler();\n\n await fs.promises.mkdir(\n path.join(process.cwd(), path.dirname(defaultEntryPoint)),\n {\n recursive: true,\n },\n );\n await fs.promises.writeFile(\n path.join(process.cwd(), defaultEntryPoint),\n cloudflareWorkerTemplate,\n { encoding: 'utf-8', flag: 'w' },\n );\n\n clack.log.success(`Created ${chalk.cyan(defaultEntryPoint)}.`);\n\n return;\n }\n\n const entryPointPath = path.join(process.cwd(), entryPointFromConfig);\n\n if (fs.existsSync(entryPointPath)) {\n clack.log.info(\n `Found existing entry point: ${chalk.cyan(entryPointFromConfig)}`,\n );\n\n try {\n await wrapWorkerWithSentry(entryPointPath, dsn, selectedFeatures);\n clack.log.success(\n `Wrapped ${chalk.cyan(\n entryPointFromConfig,\n )} with Sentry initialization.`,\n );\n } catch (error) {\n clack.log.warn('Failed to wrap worker automatically.');\n clack.log.step('Please wrap your handler with Sentry initialization:');\n\n clack.note(\n chalk.cyan(getCloudflareWorkerTemplate(dsn, selectedFeatures)),\n );\n }\n return;\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCloudflareWorkerTemplateWithHandler = exports.getCloudflareWorkerTemplate = void 0;
|
|
4
|
+
function getCloudflareWorkerTemplate(dsn, selectedFeatures) {
|
|
5
|
+
let performanceOptions = '';
|
|
6
|
+
if (selectedFeatures.performance) {
|
|
7
|
+
performanceOptions = `
|
|
8
|
+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
|
|
9
|
+
tracesSampleRate: 1,`;
|
|
10
|
+
}
|
|
11
|
+
let logsOptions = '';
|
|
12
|
+
if (selectedFeatures.logs) {
|
|
13
|
+
logsOptions = `
|
|
14
|
+
// Enable logs to be sent to Sentry
|
|
15
|
+
enableLogs: true,`;
|
|
16
|
+
}
|
|
17
|
+
return `import * as Sentry from '@sentry/cloudflare';
|
|
18
|
+
|
|
19
|
+
export default Sentry.withSentry(
|
|
20
|
+
(env) => ({
|
|
21
|
+
dsn: '${dsn}',${performanceOptions}${logsOptions}
|
|
22
|
+
}),
|
|
23
|
+
{
|
|
24
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
25
|
+
// Your worker logic here
|
|
26
|
+
return new Response('Hello World!');
|
|
27
|
+
},
|
|
28
|
+
} satisfies ExportedHandler<Env>,
|
|
29
|
+
);
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
exports.getCloudflareWorkerTemplate = getCloudflareWorkerTemplate;
|
|
33
|
+
function getCloudflareWorkerTemplateWithHandler() {
|
|
34
|
+
return `export default {
|
|
35
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
36
|
+
const url = new URL(request.url);
|
|
37
|
+
switch (url.pathname) {
|
|
38
|
+
case '/message':
|
|
39
|
+
return new Response('Hello, World!');
|
|
40
|
+
case '/random':
|
|
41
|
+
return new Response(crypto.randomUUID());
|
|
42
|
+
default:
|
|
43
|
+
return new Response('Not Found', { status: 404 });
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
} satisfies ExportedHandler<Env>;
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
exports.getCloudflareWorkerTemplateWithHandler = getCloudflareWorkerTemplateWithHandler;
|
|
50
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/cloudflare/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,2BAA2B,CACzC,GAAW,EACX,gBAGC;IAED,IAAI,kBAAkB,GAAG,EAAE,CAAC;IAC5B,IAAI,gBAAgB,CAAC,WAAW,EAAE;QAChC,kBAAkB,GAAG;;uBAEF,CAAC;KACrB;IAED,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,gBAAgB,CAAC,IAAI,EAAE;QACzB,WAAW,GAAG;;oBAEE,CAAC;KAClB;IAED,OAAO;;;;UAIC,GAAG,KAAK,kBAAkB,GAAG,WAAW;;;;;;;;;CASjD,CAAC;AACF,CAAC;AAnCD,kEAmCC;AAED,SAAgB,sCAAsC;IACpD,OAAO;;;;;;;;;;;;;CAaR,CAAC;AACF,CAAC;AAfD,wFAeC","sourcesContent":["export function getCloudflareWorkerTemplate(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n logs: boolean;\n },\n): string {\n let performanceOptions = '';\n if (selectedFeatures.performance) {\n performanceOptions = `\n\t\t// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n\t\ttracesSampleRate: 1,`;\n }\n\n let logsOptions = '';\n if (selectedFeatures.logs) {\n logsOptions = `\n\t\t// Enable logs to be sent to Sentry\n\t\tenableLogs: true,`;\n }\n\n return `import * as Sentry from '@sentry/cloudflare';\n\nexport default Sentry.withSentry(\n\t(env) => ({\n\t\tdsn: '${dsn}',${performanceOptions}${logsOptions}\n\t}),\n\t{\n\t\tasync fetch(request, env, ctx): Promise<Response> {\n\t\t\t// Your worker logic here\n\t\t\treturn new Response('Hello World!');\n\t\t},\n\t} satisfies ExportedHandler<Env>,\n);\n`;\n}\n\nexport function getCloudflareWorkerTemplateWithHandler(): string {\n return `export default {\n\tasync fetch(request, env, ctx): Promise<Response> {\n\t\tconst url = new URL(request.url);\n\t\tswitch (url.pathname) {\n\t\t\tcase '/message':\n\t\t\t\treturn new Response('Hello, World!');\n\t\t\tcase '/random':\n\t\t\t\treturn new Response(crypto.randomUUID());\n\t\t\tdefault:\n\t\t\t\treturn new Response('Not Found', { status: 404 });\n\t\t}\n\t},\n} satisfies ExportedHandler<Env>;\n`;\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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.createWranglerConfig = void 0;
|
|
7
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
8
|
+
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
/**
|
|
13
|
+
* Creates a basic wrangler.jsonc config file for a Cloudflare Worker
|
|
14
|
+
*/
|
|
15
|
+
function createWranglerConfig() {
|
|
16
|
+
const configPath = node_path_1.default.join(process.cwd(), 'wrangler.jsonc');
|
|
17
|
+
const config = {
|
|
18
|
+
$schema: 'node_modules/wrangler/config-schema.json',
|
|
19
|
+
name: 'my-worker',
|
|
20
|
+
main: 'src/index.ts',
|
|
21
|
+
};
|
|
22
|
+
node_fs_1.default.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
23
|
+
prompts_1.default.log.success(`Created ${chalk_1.default.cyan('wrangler.jsonc')} configuration file.`);
|
|
24
|
+
prompts_1.default.log.info(`Please update the ${chalk_1.default.cyan('name')} and ${chalk_1.default.cyan('main')} fields in ${chalk_1.default.cyan('wrangler.jsonc')} to match your worker name and entry point.`);
|
|
25
|
+
}
|
|
26
|
+
exports.createWranglerConfig = createWranglerConfig;
|
|
27
|
+
//# sourceMappingURL=create-wrangler-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-wrangler-config.js","sourceRoot":"","sources":["../../../../src/cloudflare/wrangler/create-wrangler-config.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,sDAAyB;AACzB,0DAA6B;AAE7B;;GAEG;AACH,SAAgB,oBAAoB;IAClC,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG;QACb,OAAO,EAAE,0CAA0C;QACnD,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,cAAc;KACrB,CAAC;IAEF,iBAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAEvE,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,WAAW,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,CAC9D,CAAC;IACF,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,qBAAqB,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,eAAK,CAAC,IAAI,CACvD,MAAM,CACP,cAAc,eAAK,CAAC,IAAI,CACvB,gBAAgB,CACjB,6CAA6C,CAC/C,CAAC;AACJ,CAAC;AArBD,oDAqBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * Creates a basic wrangler.jsonc config file for a Cloudflare Worker\n */\nexport function createWranglerConfig(): void {\n const configPath = path.join(process.cwd(), 'wrangler.jsonc');\n\n const config = {\n $schema: 'node_modules/wrangler/config-schema.json',\n name: 'my-worker',\n main: 'src/index.ts',\n };\n\n fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');\n\n clack.log.success(\n `Created ${chalk.cyan('wrangler.jsonc')} configuration file.`,\n );\n clack.log.info(\n `Please update the ${chalk.cyan('name')} and ${chalk.cyan(\n 'main',\n )} fields in ${chalk.cyan(\n 'wrangler.jsonc',\n )} to match your worker name and entry point.`,\n );\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
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.ensureWranglerConfig = void 0;
|
|
7
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
8
|
+
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const find_wrangler_config_1 = require("./find-wrangler-config");
|
|
11
|
+
const create_wrangler_config_1 = require("./create-wrangler-config");
|
|
12
|
+
/**
|
|
13
|
+
* Ensures a wrangler config exists, creating one if necessary
|
|
14
|
+
*/
|
|
15
|
+
function ensureWranglerConfig() {
|
|
16
|
+
const existingConfig = (0, find_wrangler_config_1.findWranglerConfig)();
|
|
17
|
+
if (existingConfig) {
|
|
18
|
+
prompts_1.default.log.info(`Found existing Wrangler config: ${chalk_1.default.cyan(existingConfig)}`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
prompts_1.default.log.step('No Wrangler configuration file found.');
|
|
22
|
+
(0, create_wrangler_config_1.createWranglerConfig)();
|
|
23
|
+
}
|
|
24
|
+
exports.ensureWranglerConfig = ensureWranglerConfig;
|
|
25
|
+
//# sourceMappingURL=ensure-wrangler-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-wrangler-config.js","sourceRoot":"","sources":["../../../../src/cloudflare/wrangler/ensure-wrangler-config.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,iEAA4D;AAC5D,qEAAgE;AAEhE;;GAEG;AACH,SAAgB,oBAAoB;IAClC,MAAM,cAAc,GAAG,IAAA,yCAAkB,GAAE,CAAC;IAE5C,IAAI,cAAc,EAAE;QAClB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,mCAAmC,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAChE,CAAC;QACF,OAAO;KACR;IAED,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACxD,IAAA,6CAAoB,GAAE,CAAC;AACzB,CAAC;AAZD,oDAYC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { findWranglerConfig } from './find-wrangler-config';\nimport { createWranglerConfig } from './create-wrangler-config';\n\n/**\n * Ensures a wrangler config exists, creating one if necessary\n */\nexport function ensureWranglerConfig(): void {\n const existingConfig = findWranglerConfig();\n\n if (existingConfig) {\n clack.log.info(\n `Found existing Wrangler config: ${chalk.cyan(existingConfig)}`,\n );\n return;\n }\n\n clack.log.step('No Wrangler configuration file found.');\n createWranglerConfig();\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
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.findWranglerConfig = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a wrangler config file exists in the project
|
|
11
|
+
*/
|
|
12
|
+
function findWranglerConfig() {
|
|
13
|
+
const possibleConfigs = ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml'];
|
|
14
|
+
for (const configFile of possibleConfigs) {
|
|
15
|
+
const configPath = node_path_1.default.join(process.cwd(), configFile);
|
|
16
|
+
if (node_fs_1.default.existsSync(configPath)) {
|
|
17
|
+
return configFile;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
exports.findWranglerConfig = findWranglerConfig;
|
|
23
|
+
//# sourceMappingURL=find-wrangler-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-wrangler-config.js","sourceRoot":"","sources":["../../../../src/cloudflare/wrangler/find-wrangler-config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B;;GAEG;AACH,SAAgB,kBAAkB;IAChC,MAAM,eAAe,GAAG,CAAC,gBAAgB,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;IAE7E,KAAK,MAAM,UAAU,IAAI,eAAe,EAAE;QACxC,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QACxD,IAAI,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;YAC7B,OAAO,UAAU,CAAC;SACnB;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,gDAWC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * Checks if a wrangler config file exists in the project\n */\nexport function findWranglerConfig(): string | undefined {\n const possibleConfigs = ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml'];\n\n for (const configFile of possibleConfigs) {\n const configPath = path.join(process.cwd(), configFile);\n if (fs.existsSync(configPath)) {\n return configFile;\n }\n }\n\n return undefined;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const defaultEntryPoint = "src/index.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Reads the main entry point from the wrangler config file
|
|
4
|
+
* Returns undefined if no config exists or if main field is not specified
|
|
5
|
+
*/
|
|
6
|
+
export declare function getEntryPointFromWranglerConfig(): string | undefined;
|
|
@@ -0,0 +1,52 @@
|
|
|
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.getEntryPointFromWranglerConfig = exports.defaultEntryPoint = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const find_wrangler_config_1 = require("./find-wrangler-config");
|
|
10
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
|
11
|
+
exports.defaultEntryPoint = 'src/index.ts';
|
|
12
|
+
/**
|
|
13
|
+
* Reads the main entry point from the wrangler config file
|
|
14
|
+
* Returns undefined if no config exists or if main field is not specified
|
|
15
|
+
*/
|
|
16
|
+
function getEntryPointFromWranglerConfig() {
|
|
17
|
+
const configFile = (0, find_wrangler_config_1.findWranglerConfig)();
|
|
18
|
+
if (!configFile) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const configPath = node_path_1.default.join(process.cwd(), configFile);
|
|
22
|
+
const configContent = node_fs_1.default.readFileSync(configPath, 'utf-8');
|
|
23
|
+
const extname = node_path_1.default.extname(configFile);
|
|
24
|
+
switch (extname) {
|
|
25
|
+
case '.toml': {
|
|
26
|
+
const mainMatch = configContent.match(/^main\s*=\s*["'](.+)["']/m);
|
|
27
|
+
return mainMatch ? mainMatch[1] : undefined;
|
|
28
|
+
}
|
|
29
|
+
case '.json':
|
|
30
|
+
case '.jsonc':
|
|
31
|
+
try {
|
|
32
|
+
const { jsonObject } = (0, ast_utils_1.parseJsonC)(configContent);
|
|
33
|
+
if (!jsonObject) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const mainProperty = (0, ast_utils_1.getObjectProperty)(jsonObject, 'main');
|
|
37
|
+
if ((mainProperty?.value.type === 'StringLiteral' ||
|
|
38
|
+
mainProperty?.value.type === 'Literal') &&
|
|
39
|
+
typeof mainProperty.value.value === 'string') {
|
|
40
|
+
return mainProperty.value.value;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
default:
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.getEntryPointFromWranglerConfig = getEntryPointFromWranglerConfig;
|
|
52
|
+
//# sourceMappingURL=get-entry-point-from-wrangler-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-entry-point-from-wrangler-config.js","sourceRoot":"","sources":["../../../../src/cloudflare/wrangler/get-entry-point-from-wrangler-config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,iEAA4D;AAC5D,qDAAsE;AAEzD,QAAA,iBAAiB,GAAG,cAAc,CAAC;AAEhD;;;GAGG;AACH,SAAgB,+BAA+B;IAC7C,MAAM,UAAU,GAAG,IAAA,yCAAkB,GAAE,CAAC;IAExC,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;IACxD,MAAM,aAAa,GAAG,iBAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzC,QAAQ,OAAO,EAAE;QACf,KAAK,OAAO,CAAC,CAAC;YACZ,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAEnE,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7C;QAED,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ;YACX,IAAI;gBACF,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,sBAAU,EAAC,aAAa,CAAC,CAAC;gBAEjD,IAAI,CAAC,UAAU,EAAE;oBACf,OAAO,SAAS,CAAC;iBAClB;gBAED,MAAM,YAAY,GAAG,IAAA,6BAAiB,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;gBAE3D,IACE,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,KAAK,eAAe;oBAC3C,YAAY,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;oBACzC,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,EAC5C;oBACA,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC;iBACjC;gBAED,OAAO,SAAS,CAAC;aAClB;YAAC,MAAM;gBACN,OAAO,SAAS,CAAC;aAClB;QAEH;YACE,OAAO,SAAS,CAAC;KACpB;AACH,CAAC;AA7CD,0EA6CC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { findWranglerConfig } from './find-wrangler-config';\nimport { parseJsonC, getObjectProperty } from '../../utils/ast-utils';\n\nexport const defaultEntryPoint = 'src/index.ts';\n\n/**\n * Reads the main entry point from the wrangler config file\n * Returns undefined if no config exists or if main field is not specified\n */\nexport function getEntryPointFromWranglerConfig(): string | undefined {\n const configFile = findWranglerConfig();\n\n if (!configFile) {\n return undefined;\n }\n\n const configPath = path.join(process.cwd(), configFile);\n const configContent = fs.readFileSync(configPath, 'utf-8');\n const extname = path.extname(configFile);\n\n switch (extname) {\n case '.toml': {\n const mainMatch = configContent.match(/^main\\s*=\\s*[\"'](.+)[\"']/m);\n\n return mainMatch ? mainMatch[1] : undefined;\n }\n\n case '.json':\n case '.jsonc':\n try {\n const { jsonObject } = parseJsonC(configContent);\n\n if (!jsonObject) {\n return undefined;\n }\n\n const mainProperty = getObjectProperty(jsonObject, 'main');\n\n if (\n (mainProperty?.value.type === 'StringLiteral' ||\n mainProperty?.value.type === 'Literal') &&\n typeof mainProperty.value.value === 'string'\n ) {\n return mainProperty.value.value;\n }\n\n return undefined;\n } catch {\n return undefined;\n }\n\n default:\n return undefined;\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type WranglerConfigUpdates = {
|
|
2
|
+
compatibility_date?: string;
|
|
3
|
+
compatibility_flags?: string[];
|
|
4
|
+
version_metadata?: {
|
|
5
|
+
binding: string;
|
|
6
|
+
};
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Updates the wrangler config file with the provided configuration
|
|
11
|
+
* Handles .toml (instructions only), .json, and .jsonc formats
|
|
12
|
+
* For arrays: merges and deduplicates values
|
|
13
|
+
* For objects: deep merges
|
|
14
|
+
* For other types: overwrites
|
|
15
|
+
*/
|
|
16
|
+
export declare function updateWranglerConfig(updates: WranglerConfigUpdates): Promise<boolean>;
|
|
17
|
+
export {};
|