@sentry/wizard 6.10.0 → 6.11.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.
Files changed (144) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/ci-ensure-runtime-loaded.sh +82 -0
  3. package/dist/e2e-tests/tests/angular-17.test.js +72 -82
  4. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  5. package/dist/e2e-tests/tests/angular-19.test.js +71 -80
  6. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  7. package/dist/e2e-tests/tests/cloudflare-worker.test.d.ts +1 -0
  8. package/dist/e2e-tests/tests/cloudflare-worker.test.js +64 -0
  9. package/dist/e2e-tests/tests/cloudflare-worker.test.js.map +1 -0
  10. package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js +2 -5
  11. package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js.map +1 -1
  12. package/dist/e2e-tests/tests/expo.test.js +36 -61
  13. package/dist/e2e-tests/tests/expo.test.js.map +1 -1
  14. package/dist/e2e-tests/tests/flutter.test.js +63 -70
  15. package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
  16. package/dist/e2e-tests/tests/help-message.test.js +2 -2
  17. package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
  18. package/dist/e2e-tests/tests/nextjs-14.test.js +48 -76
  19. package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
  20. package/dist/e2e-tests/tests/nextjs-15.test.js +89 -99
  21. package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
  22. package/dist/e2e-tests/tests/nextjs-16.test.js +48 -45
  23. package/dist/e2e-tests/tests/nextjs-16.test.js.map +1 -1
  24. package/dist/e2e-tests/tests/nuxt-3.test.js +45 -58
  25. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  26. package/dist/e2e-tests/tests/nuxt-4.test.js +59 -73
  27. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  28. package/dist/e2e-tests/tests/pnpm-workspace.test.js +4 -7
  29. package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
  30. package/dist/e2e-tests/tests/react-native.test.js +44 -80
  31. package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
  32. package/dist/e2e-tests/tests/react-router.test.js +163 -145
  33. package/dist/e2e-tests/tests/react-router.test.js.map +1 -1
  34. package/dist/e2e-tests/tests/remix.test.js +162 -132
  35. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  36. package/dist/e2e-tests/tests/sveltekit-hooks.test.js +48 -36
  37. package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
  38. package/dist/e2e-tests/tests/sveltekit-tracing.test.js +3 -6
  39. package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
  40. package/dist/e2e-tests/utils/index.d.ts +15 -43
  41. package/dist/e2e-tests/utils/index.js +95 -185
  42. package/dist/e2e-tests/utils/index.js.map +1 -1
  43. package/dist/get-e2e-test-matrix.mjs +11 -0
  44. package/dist/lib/Constants.d.ts +1 -0
  45. package/dist/lib/Constants.js +5 -0
  46. package/dist/lib/Constants.js.map +1 -1
  47. package/dist/src/android/android-wizard.js +2 -4
  48. package/dist/src/android/android-wizard.js.map +1 -1
  49. package/dist/src/angular/angular-wizard.js +4 -6
  50. package/dist/src/angular/angular-wizard.js.map +1 -1
  51. package/dist/src/angular/sdk-setup.js +1 -1
  52. package/dist/src/angular/sdk-setup.js.map +1 -1
  53. package/dist/src/apple/apple-wizard.js +2 -4
  54. package/dist/src/apple/apple-wizard.js.map +1 -1
  55. package/dist/src/cloudflare/cloudflare-wizard.d.ts +3 -0
  56. package/dist/src/cloudflare/cloudflare-wizard.js +99 -0
  57. package/dist/src/cloudflare/cloudflare-wizard.js.map +1 -0
  58. package/dist/src/cloudflare/sdk-setup.d.ts +7 -0
  59. package/dist/src/cloudflare/sdk-setup.js +47 -0
  60. package/dist/src/cloudflare/sdk-setup.js.map +1 -0
  61. package/dist/src/cloudflare/templates.d.ts +4 -0
  62. package/dist/src/cloudflare/templates.js +44 -0
  63. package/dist/src/cloudflare/templates.js.map +1 -0
  64. package/dist/src/cloudflare/wrangler/create-wrangler-config.d.ts +4 -0
  65. package/dist/src/cloudflare/wrangler/create-wrangler-config.js +27 -0
  66. package/dist/src/cloudflare/wrangler/create-wrangler-config.js.map +1 -0
  67. package/dist/src/cloudflare/wrangler/ensure-wrangler-config.d.ts +4 -0
  68. package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js +25 -0
  69. package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js.map +1 -0
  70. package/dist/src/cloudflare/wrangler/find-wrangler-config.d.ts +4 -0
  71. package/dist/src/cloudflare/wrangler/find-wrangler-config.js +23 -0
  72. package/dist/src/cloudflare/wrangler/find-wrangler-config.js.map +1 -0
  73. package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.d.ts +6 -0
  74. package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js +52 -0
  75. package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js.map +1 -0
  76. package/dist/src/cloudflare/wrangler/update-wrangler-config.d.ts +17 -0
  77. package/dist/src/cloudflare/wrangler/update-wrangler-config.js +173 -0
  78. package/dist/src/cloudflare/wrangler/update-wrangler-config.js.map +1 -0
  79. package/dist/src/cloudflare/wrap-worker.d.ts +32 -0
  80. package/dist/src/cloudflare/wrap-worker.js +109 -0
  81. package/dist/src/cloudflare/wrap-worker.js.map +1 -0
  82. package/dist/src/flutter/flutter-wizard.js +3 -6
  83. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  84. package/dist/src/nextjs/nextjs-wizard.js +0 -2
  85. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  86. package/dist/src/nuxt/nuxt-wizard.js +3 -5
  87. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  88. package/dist/src/react-native/react-native-wizard.js +2 -4
  89. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  90. package/dist/src/react-router/react-router-wizard.js +3 -5
  91. package/dist/src/react-router/react-router-wizard.js.map +1 -1
  92. package/dist/src/react-router/sdk-setup.d.ts +1 -1
  93. package/dist/src/react-router/sdk-setup.js +3 -4
  94. package/dist/src/react-router/sdk-setup.js.map +1 -1
  95. package/dist/src/remix/remix-wizard.js +2 -4
  96. package/dist/src/remix/remix-wizard.js.map +1 -1
  97. package/dist/src/run.d.ts +1 -1
  98. package/dist/src/run.js +5 -0
  99. package/dist/src/run.js.map +1 -1
  100. package/dist/src/sveltekit/sveltekit-wizard.js +2 -4
  101. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  102. package/dist/src/utils/abort-if-sportlight-not-supported.d.ts +5 -0
  103. package/dist/src/utils/abort-if-sportlight-not-supported.js +40 -0
  104. package/dist/src/utils/abort-if-sportlight-not-supported.js.map +1 -0
  105. package/dist/src/utils/ast-utils.d.ts +1 -1
  106. package/dist/src/utils/ast-utils.js.map +1 -1
  107. package/dist/src/utils/clack/index.d.ts +2 -2
  108. package/dist/src/utils/clack/index.js.map +1 -1
  109. package/dist/src/utils/clack/mcp-config.js +117 -59
  110. package/dist/src/utils/clack/mcp-config.js.map +1 -1
  111. package/dist/src/version.d.ts +1 -1
  112. package/dist/src/version.js +1 -1
  113. package/dist/src/version.js.map +1 -1
  114. package/dist/test/angular/angular-wizard.test.js +2 -4
  115. package/dist/test/angular/angular-wizard.test.js.map +1 -1
  116. package/dist/test/cloudflare/create-wrangler-config.test.d.ts +1 -0
  117. package/dist/test/cloudflare/create-wrangler-config.test.js +48 -0
  118. package/dist/test/cloudflare/create-wrangler-config.test.js.map +1 -0
  119. package/dist/test/cloudflare/ensure-wrangler-config.test.d.ts +1 -0
  120. package/dist/test/cloudflare/ensure-wrangler-config.test.js +61 -0
  121. package/dist/test/cloudflare/ensure-wrangler-config.test.js.map +1 -0
  122. package/dist/test/cloudflare/find-wrangler-config.test.d.ts +1 -0
  123. package/dist/test/cloudflare/find-wrangler-config.test.js +77 -0
  124. package/dist/test/cloudflare/find-wrangler-config.test.js.map +1 -0
  125. package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.d.ts +1 -0
  126. package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js +81 -0
  127. package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js.map +1 -0
  128. package/dist/test/cloudflare/sdk-setup.test.d.ts +1 -0
  129. package/dist/test/cloudflare/sdk-setup.test.js +152 -0
  130. package/dist/test/cloudflare/sdk-setup.test.js.map +1 -0
  131. package/dist/test/cloudflare/templates.test.d.ts +1 -0
  132. package/dist/test/cloudflare/templates.test.js +68 -0
  133. package/dist/test/cloudflare/templates.test.js.map +1 -0
  134. package/dist/test/cloudflare/update-wrangler-config.test.d.ts +1 -0
  135. package/dist/test/cloudflare/update-wrangler-config.test.js +216 -0
  136. package/dist/test/cloudflare/update-wrangler-config.test.js.map +1 -0
  137. package/dist/test/cloudflare/wrap-worker.test.d.ts +1 -0
  138. package/dist/test/cloudflare/wrap-worker.test.js +143 -0
  139. package/dist/test/cloudflare/wrap-worker.test.js.map +1 -0
  140. package/dist/test/react-router/sdk-setup.test.js +2 -2
  141. package/dist/test/react-router/sdk-setup.test.js.map +1 -1
  142. package/dist/test/utils/clack/mcp-config.test.js +176 -51
  143. package/dist/test/utils/clack/mcp-config.test.js.map +1 -1
  144. package/package.json +5 -4
@@ -40,7 +40,7 @@ export declare function getOrSetObjectProperty(object: t.ObjectExpression, name:
40
40
  * @param value the value of the property to set
41
41
  * @param comment (optional) a comment to add to the property
42
42
  */
43
- export declare function setOrUpdateObjectProperty(object: t.ObjectExpression, name: string, value: t.Literal | t.BooleanLiteral | t.StringLiteral | t.ObjectExpression, comment?: string): void;
43
+ export declare function setOrUpdateObjectProperty(object: t.ObjectExpression, name: string, value: t.Literal | t.BooleanLiteral | t.StringLiteral | t.ObjectExpression | t.ArrayExpression, comment?: string): void;
44
44
  type JsonCParseResult = {
45
45
  jsonObject: t.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AsB,CACpC,IAAmB,EACnB,SAAsB;IAEtB,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACtD,OAAO,KAAK,CAAC;KACd;IAED,kEAAkE;IAClE,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC;AAZD,wDAYC;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,SAA6B,EAC7B,IAAY;IAEZ,OAAO,SAAS,CAAC,UAAU,CAAC,IAAI,CAC9B,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,IAAI,KAAK,gBAAgB;QAC3B,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;QAC3B,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CACU,CAAC,CAAC,kCAAkC;AACvE,CAAC;AAVD,oCAUC","sourcesContent":["import * as fs from 'fs';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\n/**\n * Checks if a file where we don't know its concrete file type yet exists\n * and returns the full path to the file with the correct file type.\n */\nexport function findFile(\n filePath: string,\n fileTypes: string[] = ['.js', '.ts', '.mjs', '.cjs'],\n): string | undefined {\n return fileTypes\n .map((type) => `${filePath}${type}`)\n .find((file) => fs.existsSync(file));\n}\n\n/**\n * checks for require('@sentry/*') syntax\n */\nexport function hasSentryContent(program: t.Program): boolean {\n let foundSentry: boolean | undefined = false;\n recast.visit(program, {\n visitStringLiteral(path) {\n foundSentry = foundSentry || path.node.value.startsWith('@sentry/');\n this.traverse(path);\n },\n visitLiteral(path) {\n foundSentry =\n foundSentry || path.node.value?.toString().startsWith('@sentry/');\n this.traverse(path);\n },\n });\n\n return !!foundSentry;\n}\n\n/**\n * Searches for a property of an ObjectExpression by name\n *\n * @param object the ObjectExpression to search in\n * @param name the name of the property to search for\n *\n * @returns the property if it exists\n */\nexport function getObjectProperty(\n object: t.ObjectExpression,\n name: string,\n): t.Property | undefined {\n return object.properties.find((p): p is t.Property => {\n const isObjectProp = p.type === 'Property' || p.type === 'ObjectProperty';\n\n if (!isObjectProp) {\n return false;\n }\n\n const hasMatchingLiteralKey =\n isObjectProp &&\n (p.key.type === 'Literal' || p.key.type === 'StringLiteral') &&\n p.key.value === name;\n\n if (hasMatchingLiteralKey) {\n return true;\n }\n\n // has matching identifier key\n return isObjectProp && p.key.type === 'Identifier' && p.key.name === name;\n });\n}\n\n/**\n * Attempts to find a property of an ObjectExpression by name. If it doesn't exist,\n * the property will be added to the ObjectExpression with the provided default value.\n *\n * @param object the parent object expression to search in\n * @param name the name of the property to search for\n * @param defaultValue the default value to set if the property doesn't exist\n *\n * @returns the\n */\nexport function getOrSetObjectProperty(\n object: t.ObjectExpression,\n name: string,\n defaultValue:\n | t.Literal\n | t.BooleanLiteral\n | t.StringLiteral\n | t.ObjectExpression,\n): t.Property {\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n return existingProperty;\n }\n\n const newProperty = b.property.from({\n kind: 'init',\n key: b.stringLiteral(name),\n value: defaultValue,\n });\n\n object.properties.push(newProperty);\n\n return newProperty;\n}\n\n/**\n * Sets a property of an ObjectExpression if it exists, otherwise adds it\n * to the ObjectExpression. Optionally, a comment can be added to the\n * property.\n *\n * @param object the ObjectExpression to set the property on\n * @param name the name of the property to set\n * @param value the value of the property to set\n * @param comment (optional) a comment to add to the property\n */\nexport function setOrUpdateObjectProperty(\n object: t.ObjectExpression,\n name: string,\n value: t.Literal | t.BooleanLiteral | t.StringLiteral | t.ObjectExpression,\n comment?: string,\n) {\n const newComments =\n comment &&\n comment.split('\\n').map((c) => b.commentLine(` ${c}`, true, false));\n\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n existingProperty.value = value;\n if (newComments) {\n existingProperty.comments = [\n ...(existingProperty?.comments || []),\n ...newComments,\n ];\n }\n } else {\n object.properties.push(\n b.objectProperty.from({\n key: b.stringLiteral(name),\n value,\n ...(newComments && {\n comments: newComments,\n }),\n }),\n );\n }\n}\n\ntype JsonCParseResult =\n | {\n jsonObject: t.ObjectExpression;\n ast: t.Program;\n }\n | {\n jsonObject: undefined;\n ast: undefined;\n };\n\n/**\n * Parses a JSON string with (potential) comments (JSON-C) and returns the JS AST\n * that can be walked and modified with recast like a normal JS AST.\n *\n * This is done by wrapping the JSON-C string in parentheses, thereby making it\n * a JS `Program` with an `ExpressionStatement` as its body. The expression is then\n * extracted from the AST and returned alongside the AST.\n *\n * To preserve as much original formatting as possible, the returned `ast`\n * property should be passed to {@link `printJsonC`} to get the JSON-C string back.\n *\n * If the input is not valid JSON-C, the result will be undefined.\n *\n * @see {@link JsonCParseResult}\n *\n * @param jsonString a JSON-C string\n *\n * @returns a {@link JsonCParseResult}, containing either the JSON-C object and the AST or undefined in both cases\n */\nexport function parseJsonC(jsonString: string): JsonCParseResult {\n try {\n const jsTsConfig = `(${jsonString})`;\n // no idea why recast returns any here, this is dumb :/\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const ast = recast.parse(jsTsConfig.toString()).program as t.Program;\n\n const jsonObject =\n (ast.body[0].type === 'ExpressionStatement' &&\n ast.body[0].expression.type === 'ObjectExpression' &&\n ast.body[0].expression) ||\n undefined;\n\n if (jsonObject) {\n return { jsonObject, ast };\n }\n } catch {\n /* empty */\n }\n return { jsonObject: undefined, ast: undefined };\n}\n\n/**\n * Takes the AST of a parsed JSON-C \"program\" and returns the JSON-C string without\n * any of the temporary JS wrapper code that was previously applied.\n *\n * Only use this in conjunction with {@link `parseJsonC`}\n *\n * @param ast the `ast` returned from {@link `parseJsonC`}\n *\n * @returns the JSON-C string\n */\nexport function printJsonC(ast: t.Program): string {\n const js = recast.print(ast).code;\n return js.substring(1, js.length - 1);\n}\n\n/**\n * Walks the program body and returns index of the last variable assignment initialized by require statement.\n * Only counts top level require statements.\n *\n * @returns index of the last `const foo = require('bar');` statement or -1 if none was found.\n */\nexport function getLastRequireIndex(program: t.Program): number {\n let lastRequireIdex = -1;\n program.body.forEach((s, i) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].init !== null &&\n typeof s.declarations[0].init !== 'undefined' &&\n s.declarations[0].init.type === 'CallExpression' &&\n s.declarations[0].init.callee.type === 'Identifier' &&\n s.declarations[0].init.callee.name === 'require'\n ) {\n lastRequireIdex = i;\n }\n });\n return lastRequireIdex;\n}\n\n/**\n * Safely checks if a callee is an identifier with the given name\n * Prevents crashes when accessing callee.name on non-identifier nodes\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function safeCalleeIdentifierMatch(callee: any, name: string): boolean {\n return Boolean(\n callee &&\n typeof callee === 'object' &&\n 'type' in callee &&\n (callee as { type: string }).type === 'Identifier' &&\n 'name' in callee &&\n (callee as { name: string }).name === name,\n );\n}\n\n/**\n * Safely gets the name of an identifier node\n * Returns null if the node is not an identifier or is undefined\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function safeGetIdentifierName(node: any): string | null {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return node && node.type === 'Identifier' ? String(node.name) : null;\n}\n\n/**\n * Safely access function body array with proper validation\n * Prevents crashes when accessing body.body on nodes that don't have a body\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function safeGetFunctionBody(node: any): t.Statement[] | null {\n if (!node || typeof node !== 'object' || !('body' in node)) {\n return null;\n }\n\n const nodeBody = (node as { body: unknown }).body;\n if (!nodeBody || typeof nodeBody !== 'object' || !('body' in nodeBody)) {\n return null;\n }\n\n const bodyArray = (nodeBody as { body: unknown }).body;\n return Array.isArray(bodyArray) ? (bodyArray as t.Statement[]) : null;\n}\n\n/**\n * Safely insert statement before last statement in function body\n * Typically used to insert code before a return statement\n * Returns true if insertion was successful, false otherwise\n */\nexport function safeInsertBeforeReturn(\n body: t.Statement[],\n statement: t.Statement,\n): boolean {\n if (!body || !Array.isArray(body) || body.length === 0) {\n return false;\n }\n\n // Insert before the last statement (typically a return statement)\n const insertIndex = Math.max(0, body.length - 1);\n body.splice(insertIndex, 0, statement);\n return true;\n}\n\n/**\n * Finds a property in an ObjectExpression by name.\n * Commonly used for traversing Vite/React Router config objects.\n *\n * @param configObj - The ObjectExpression to search\n * @param name - The property name to find\n * @returns The matching ObjectProperty, or undefined if not found\n */\nexport function findProperty(\n configObj: t.ObjectExpression,\n name: string,\n): t.ObjectProperty | undefined {\n return configObj.properties.find(\n (p) =>\n p.type === 'ObjectProperty' &&\n p.key.type === 'Identifier' &&\n p.key.name === name,\n ) as t.ObjectProperty | undefined; // Safe: predicate guarantees type\n}\n"]}
1
+ {"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../../../src/utils/ast-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,+CAAiC;AAIjC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC;;;GAGG;AACH,SAAgB,QAAQ,CACtB,QAAgB,EAChB,YAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;IAEpD,OAAO,SAAS;SACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,QAAQ,GAAG,IAAI,EAAE,CAAC;SACnC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC;AAPD,4BAOC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAAkB;IACjD,IAAI,WAAW,GAAwB,KAAK,CAAC;IAC7C,MAAM,CAAC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I,CACU,CAAC,CAAC,kCAAkC;AACvE,CAAC;AAVD,oCAUC","sourcesContent":["import * as fs from 'fs';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\n/**\n * Checks if a file where we don't know its concrete file type yet exists\n * and returns the full path to the file with the correct file type.\n */\nexport function findFile(\n filePath: string,\n fileTypes: string[] = ['.js', '.ts', '.mjs', '.cjs'],\n): string | undefined {\n return fileTypes\n .map((type) => `${filePath}${type}`)\n .find((file) => fs.existsSync(file));\n}\n\n/**\n * checks for require('@sentry/*') syntax\n */\nexport function hasSentryContent(program: t.Program): boolean {\n let foundSentry: boolean | undefined = false;\n recast.visit(program, {\n visitStringLiteral(path) {\n foundSentry = foundSentry || path.node.value.startsWith('@sentry/');\n this.traverse(path);\n },\n visitLiteral(path) {\n foundSentry =\n foundSentry || path.node.value?.toString().startsWith('@sentry/');\n this.traverse(path);\n },\n });\n\n return !!foundSentry;\n}\n\n/**\n * Searches for a property of an ObjectExpression by name\n *\n * @param object the ObjectExpression to search in\n * @param name the name of the property to search for\n *\n * @returns the property if it exists\n */\nexport function getObjectProperty(\n object: t.ObjectExpression,\n name: string,\n): t.Property | undefined {\n return object.properties.find((p): p is t.Property => {\n const isObjectProp = p.type === 'Property' || p.type === 'ObjectProperty';\n\n if (!isObjectProp) {\n return false;\n }\n\n const hasMatchingLiteralKey =\n isObjectProp &&\n (p.key.type === 'Literal' || p.key.type === 'StringLiteral') &&\n p.key.value === name;\n\n if (hasMatchingLiteralKey) {\n return true;\n }\n\n // has matching identifier key\n return isObjectProp && p.key.type === 'Identifier' && p.key.name === name;\n });\n}\n\n/**\n * Attempts to find a property of an ObjectExpression by name. If it doesn't exist,\n * the property will be added to the ObjectExpression with the provided default value.\n *\n * @param object the parent object expression to search in\n * @param name the name of the property to search for\n * @param defaultValue the default value to set if the property doesn't exist\n *\n * @returns the\n */\nexport function getOrSetObjectProperty(\n object: t.ObjectExpression,\n name: string,\n defaultValue:\n | t.Literal\n | t.BooleanLiteral\n | t.StringLiteral\n | t.ObjectExpression,\n): t.Property {\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n return existingProperty;\n }\n\n const newProperty = b.property.from({\n kind: 'init',\n key: b.stringLiteral(name),\n value: defaultValue,\n });\n\n object.properties.push(newProperty);\n\n return newProperty;\n}\n\n/**\n * Sets a property of an ObjectExpression if it exists, otherwise adds it\n * to the ObjectExpression. Optionally, a comment can be added to the\n * property.\n *\n * @param object the ObjectExpression to set the property on\n * @param name the name of the property to set\n * @param value the value of the property to set\n * @param comment (optional) a comment to add to the property\n */\nexport function setOrUpdateObjectProperty(\n object: t.ObjectExpression,\n name: string,\n value:\n | t.Literal\n | t.BooleanLiteral\n | t.StringLiteral\n | t.ObjectExpression\n | t.ArrayExpression,\n comment?: string,\n): void {\n const newComments =\n comment &&\n comment.split('\\n').map((c) => b.commentLine(` ${c}`, true, false));\n\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n existingProperty.value = value;\n if (newComments) {\n existingProperty.comments = [\n ...(existingProperty?.comments || []),\n ...newComments,\n ];\n }\n } else {\n object.properties.push(\n b.objectProperty.from({\n key: b.stringLiteral(name),\n value,\n ...(newComments && {\n comments: newComments,\n }),\n }),\n );\n }\n}\n\ntype JsonCParseResult =\n | {\n jsonObject: t.ObjectExpression;\n ast: t.Program;\n }\n | {\n jsonObject: undefined;\n ast: undefined;\n };\n\n/**\n * Parses a JSON string with (potential) comments (JSON-C) and returns the JS AST\n * that can be walked and modified with recast like a normal JS AST.\n *\n * This is done by wrapping the JSON-C string in parentheses, thereby making it\n * a JS `Program` with an `ExpressionStatement` as its body. The expression is then\n * extracted from the AST and returned alongside the AST.\n *\n * To preserve as much original formatting as possible, the returned `ast`\n * property should be passed to {@link `printJsonC`} to get the JSON-C string back.\n *\n * If the input is not valid JSON-C, the result will be undefined.\n *\n * @see {@link JsonCParseResult}\n *\n * @param jsonString a JSON-C string\n *\n * @returns a {@link JsonCParseResult}, containing either the JSON-C object and the AST or undefined in both cases\n */\nexport function parseJsonC(jsonString: string): JsonCParseResult {\n try {\n const jsTsConfig = `(${jsonString})`;\n // no idea why recast returns any here, this is dumb :/\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const ast = recast.parse(jsTsConfig.toString()).program as t.Program;\n\n const jsonObject =\n (ast.body[0].type === 'ExpressionStatement' &&\n ast.body[0].expression.type === 'ObjectExpression' &&\n ast.body[0].expression) ||\n undefined;\n\n if (jsonObject) {\n return { jsonObject, ast };\n }\n } catch {\n /* empty */\n }\n return { jsonObject: undefined, ast: undefined };\n}\n\n/**\n * Takes the AST of a parsed JSON-C \"program\" and returns the JSON-C string without\n * any of the temporary JS wrapper code that was previously applied.\n *\n * Only use this in conjunction with {@link `parseJsonC`}\n *\n * @param ast the `ast` returned from {@link `parseJsonC`}\n *\n * @returns the JSON-C string\n */\nexport function printJsonC(ast: t.Program): string {\n const js = recast.print(ast).code;\n return js.substring(1, js.length - 1);\n}\n\n/**\n * Walks the program body and returns index of the last variable assignment initialized by require statement.\n * Only counts top level require statements.\n *\n * @returns index of the last `const foo = require('bar');` statement or -1 if none was found.\n */\nexport function getLastRequireIndex(program: t.Program): number {\n let lastRequireIdex = -1;\n program.body.forEach((s, i) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].init !== null &&\n typeof s.declarations[0].init !== 'undefined' &&\n s.declarations[0].init.type === 'CallExpression' &&\n s.declarations[0].init.callee.type === 'Identifier' &&\n s.declarations[0].init.callee.name === 'require'\n ) {\n lastRequireIdex = i;\n }\n });\n return lastRequireIdex;\n}\n\n/**\n * Safely checks if a callee is an identifier with the given name\n * Prevents crashes when accessing callee.name on non-identifier nodes\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function safeCalleeIdentifierMatch(callee: any, name: string): boolean {\n return Boolean(\n callee &&\n typeof callee === 'object' &&\n 'type' in callee &&\n (callee as { type: string }).type === 'Identifier' &&\n 'name' in callee &&\n (callee as { name: string }).name === name,\n );\n}\n\n/**\n * Safely gets the name of an identifier node\n * Returns null if the node is not an identifier or is undefined\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function safeGetIdentifierName(node: any): string | null {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return node && node.type === 'Identifier' ? String(node.name) : null;\n}\n\n/**\n * Safely access function body array with proper validation\n * Prevents crashes when accessing body.body on nodes that don't have a body\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function safeGetFunctionBody(node: any): t.Statement[] | null {\n if (!node || typeof node !== 'object' || !('body' in node)) {\n return null;\n }\n\n const nodeBody = (node as { body: unknown }).body;\n if (!nodeBody || typeof nodeBody !== 'object' || !('body' in nodeBody)) {\n return null;\n }\n\n const bodyArray = (nodeBody as { body: unknown }).body;\n return Array.isArray(bodyArray) ? (bodyArray as t.Statement[]) : null;\n}\n\n/**\n * Safely insert statement before last statement in function body\n * Typically used to insert code before a return statement\n * Returns true if insertion was successful, false otherwise\n */\nexport function safeInsertBeforeReturn(\n body: t.Statement[],\n statement: t.Statement,\n): boolean {\n if (!body || !Array.isArray(body) || body.length === 0) {\n return false;\n }\n\n // Insert before the last statement (typically a return statement)\n const insertIndex = Math.max(0, body.length - 1);\n body.splice(insertIndex, 0, statement);\n return true;\n}\n\n/**\n * Finds a property in an ObjectExpression by name.\n * Commonly used for traversing Vite/React Router config objects.\n *\n * @param configObj - The ObjectExpression to search\n * @param name - The property name to find\n * @returns The matching ObjectProperty, or undefined if not found\n */\nexport function findProperty(\n configObj: t.ObjectExpression,\n name: string,\n): t.ObjectProperty | undefined {\n return configObj.properties.find(\n (p) =>\n p.type === 'ObjectProperty' &&\n p.key.type === 'Identifier' &&\n p.key.name === name,\n ) as t.ObjectProperty | undefined; // Safe: predicate guarantees type\n}\n"]}
@@ -154,7 +154,7 @@ export declare function isUsingTypeScript(): boolean;
154
154
  * @param platform the platform of the wizard
155
155
  * @returns project data (org, project, token, url)
156
156
  */
157
- export declare function getOrAskForProjectData(options: WizardOptions, platform?: 'javascript-angular' | 'javascript-nextjs' | 'javascript-nuxt' | 'javascript-react-router' | 'javascript-remix' | 'javascript-sveltekit' | 'apple-ios' | 'android' | 'react-native' | 'flutter'): Promise<{
157
+ export declare function getOrAskForProjectData(options: WizardOptions, platform?: 'javascript-angular' | 'javascript-nextjs' | 'javascript-nuxt' | 'javascript-react-router' | 'javascript-remix' | 'javascript-sveltekit' | 'node-cloudflare-workers' | 'apple-ios' | 'android' | 'react-native' | 'flutter'): Promise<{
158
158
  sentryUrl: string;
159
159
  selfHosted: boolean;
160
160
  selectedProject: SentryProjectData;
@@ -169,7 +169,7 @@ export declare function getOrAskForProjectData(options: WizardOptions, platform?
169
169
  export declare function askForWizardLogin(options: {
170
170
  url: string;
171
171
  promoCode?: string;
172
- platform?: 'javascript-angular' | 'javascript-nextjs' | 'javascript-nuxt' | 'javascript-react-router' | 'javascript-remix' | 'javascript-sveltekit' | 'apple-ios' | 'android' | 'react-native' | 'flutter';
172
+ platform?: 'javascript-angular' | 'javascript-nextjs' | 'javascript-nuxt' | 'javascript-react-router' | 'javascript-remix' | 'javascript-sveltekit' | 'node-cloudflare-workers' | 'apple-ios' | 'android' | 'react-native' | 'flutter';
173
173
  orgSlug?: string;
174
174
  projectSlug?: string;
175
175
  comingFrom?: string;