@sentry/wizard 3.7.1 → 3.9.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 (113) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/bin.ts +14 -0
  3. package/dist/bin.js +9 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/lib/Helper/Logging.d.ts +1 -0
  6. package/dist/lib/Helper/Logging.js +2 -1
  7. package/dist/lib/Helper/Logging.js.map +1 -1
  8. package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
  9. package/dist/lib/Setup.js +4 -0
  10. package/dist/lib/Setup.js.map +1 -1
  11. package/dist/lib/Steps/ChooseIntegration.js +12 -26
  12. package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
  13. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  14. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  15. package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
  16. package/dist/lib/Steps/Integrations/ReactNative.js +5 -5
  17. package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
  18. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +5 -6
  19. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +1 -1
  20. package/dist/package.json +11 -7
  21. package/dist/src/apple/apple-wizard.js +31 -2
  22. package/dist/src/apple/apple-wizard.js.map +1 -1
  23. package/dist/src/apple/cocoapod.d.ts +2 -0
  24. package/dist/src/apple/cocoapod.js +122 -0
  25. package/dist/src/apple/cocoapod.js.map +1 -0
  26. package/dist/src/apple/code-tools.js +22 -12
  27. package/dist/src/apple/code-tools.js.map +1 -1
  28. package/dist/src/apple/fastlane.d.ts +2 -0
  29. package/dist/src/apple/fastlane.js +179 -0
  30. package/dist/src/apple/fastlane.js.map +1 -0
  31. package/dist/src/apple/templates.d.ts +1 -0
  32. package/dist/src/apple/templates.js +7 -3
  33. package/dist/src/apple/templates.js.map +1 -1
  34. package/dist/src/apple/xcode-manager.d.ts +1 -1
  35. package/dist/src/apple/xcode-manager.js +35 -28
  36. package/dist/src/apple/xcode-manager.js.map +1 -1
  37. package/dist/src/nextjs/nextjs-wizard.js +71 -81
  38. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  39. package/dist/src/sourcemaps/sourcemaps-wizard.js +61 -46
  40. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  41. package/dist/src/sourcemaps/tools/nextjs.d.ts +3 -0
  42. package/dist/src/sourcemaps/tools/nextjs.js +135 -0
  43. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -0
  44. package/dist/src/sourcemaps/tools/sentry-cli.js +120 -16
  45. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  46. package/dist/src/sourcemaps/tools/vite.js +102 -12
  47. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  48. package/dist/src/sourcemaps/utils/detect-tool.d.ts +1 -1
  49. package/dist/src/sourcemaps/utils/detect-tool.js +1 -0
  50. package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
  51. package/dist/src/sourcemaps/utils/other-wizards.js +35 -12
  52. package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
  53. package/dist/src/sveltekit/sdk-setup.d.ts +9 -1
  54. package/dist/src/sveltekit/sdk-setup.js +73 -29
  55. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  56. package/dist/src/sveltekit/sveltekit-wizard.js +23 -13
  57. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  58. package/dist/src/utils/ast-utils.d.ts +8 -0
  59. package/dist/src/utils/ast-utils.js +45 -0
  60. package/dist/src/utils/ast-utils.js.map +1 -0
  61. package/dist/src/utils/bash.d.ts +2 -1
  62. package/dist/src/utils/bash.js +14 -2
  63. package/dist/src/utils/bash.js.map +1 -1
  64. package/dist/src/utils/clack-utils.d.ts +7 -14
  65. package/dist/src/utils/clack-utils.js +46 -2
  66. package/dist/src/utils/clack-utils.js.map +1 -1
  67. package/dist/src/utils/debug.d.ts +2 -0
  68. package/dist/src/utils/debug.js +51 -0
  69. package/dist/src/utils/debug.js.map +1 -0
  70. package/dist/src/utils/package-json.d.ts +1 -1
  71. package/dist/src/utils/package-json.js.map +1 -1
  72. package/dist/src/utils/types.d.ts +24 -0
  73. package/dist/src/utils/types.js.map +1 -1
  74. package/dist/test/utils/ast-utils.test.d.ts +1 -0
  75. package/dist/test/utils/ast-utils.test.js +21 -0
  76. package/dist/test/utils/ast-utils.test.js.map +1 -0
  77. package/lib/Helper/Logging.ts +1 -1
  78. package/lib/Helper/__tests__/MergeConfig.ts +9 -4
  79. package/lib/Setup.ts +5 -0
  80. package/lib/Steps/ChooseIntegration.ts +13 -3
  81. package/lib/Steps/Integrations/Cordova.ts +3 -3
  82. package/lib/Steps/Integrations/Electron.ts +1 -2
  83. package/lib/Steps/Integrations/MobileProject.ts +1 -1
  84. package/lib/Steps/Integrations/ReactNative.ts +23 -17
  85. package/lib/Steps/Integrations/__tests__/ReactNative.ts +24 -15
  86. package/package.json +11 -7
  87. package/src/apple/apple-wizard.ts +35 -3
  88. package/src/apple/cocoapod.ts +57 -0
  89. package/src/apple/code-tools.ts +80 -57
  90. package/src/apple/fastlane.ts +160 -0
  91. package/src/apple/templates.ts +26 -10
  92. package/src/apple/xcode-manager.ts +137 -120
  93. package/src/nextjs/nextjs-wizard.ts +4 -13
  94. package/src/sourcemaps/sourcemaps-wizard.ts +40 -28
  95. package/src/sourcemaps/tools/nextjs.ts +114 -0
  96. package/src/sourcemaps/tools/sentry-cli.ts +134 -8
  97. package/src/sourcemaps/tools/vite.ts +101 -12
  98. package/src/sourcemaps/utils/detect-tool.ts +3 -1
  99. package/src/sourcemaps/utils/other-wizards.ts +32 -13
  100. package/src/sveltekit/sdk-setup.ts +122 -43
  101. package/src/sveltekit/sveltekit-wizard.ts +15 -6
  102. package/src/utils/ast-utils.ts +20 -0
  103. package/src/utils/bash.ts +43 -30
  104. package/src/utils/clack-utils.ts +42 -14
  105. package/src/utils/debug.ts +20 -0
  106. package/src/utils/package-json.ts +1 -1
  107. package/src/utils/types.ts +22 -0
  108. package/test/utils/ast-utils.test.ts +44 -0
  109. package/dist/src/sveltekit/sentry-cli-setup.d.ts +0 -2
  110. package/dist/src/sveltekit/sentry-cli-setup.js +0 -71
  111. package/dist/src/sveltekit/sentry-cli-setup.js.map +0 -1
  112. package/package-lock.json +0 -8910
  113. package/src/sveltekit/sentry-cli-setup.ts +0 -27
@@ -1 +1 @@
1
- {"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/apple/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,qDAAyC;AACzC,mDAAuC;AAEvC,IAAM,mBAAmB,GAAG,sIAAsI,CAAC;AACnK,IAAM,kBAAkB,GAAG,mJAAmJ,CAAC;AAC/K,IAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD,SAAS,iBAAiB,CAAC,QAAgB;IACvC,IAAM,cAAc,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC;IAE5G,IAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACtD,OAAO,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,oCAAoC,CAAC,GAAW;IACrD,IAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,qCAAqC;IACrC,6CAA6C;IAC7C,IAAM,IAAI,GAAa,EAAE,CAAC;IAE1B,KAAmB,UAAK,EAAL,eAAK,EAAL,mBAAK,EAAL,IAAK,EAAE;QAArB,IAAM,IAAI,cAAA;QACX,IAAM,QAAQ,GAAG,I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C;QACrF,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,IAAI;QACxC,WAAW;QACX,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAEtD,OAAO,IAAI,CAAC;AAChB,CAAC;AAxCD,0DAwCC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\nimport * as Sentry from '@sentry/node';\n\nconst swiftAppLaunchRegex = /(func\\s+application\\s*\\(_\\sapplication:[^,]+,\\s*didFinishLaunchingWithOptions[^,]+:[^)]+\\)\\s+->\\s+Bool\\s+{)|(init\\s*\\([^)]*\\)\\s*{)/im;\nconst objcAppLaunchRegex = /-\\s*\\(BOOL\\)\\s*application:\\s*\\(UIApplication\\s*\\*\\)\\s*application\\s+didFinishLaunchingWithOptions:\\s*\\(NSDictionary\\s*\\*\\)\\s*launchOptions\\s*{/im;\nconst swiftUIRegex = /struct[^:]+:\\s*App\\s*{/im;\n\nfunction isAppDelegateFile(filePath: string): boolean {\n const appLaunchRegex = filePath.toLowerCase().endsWith(\".swift\") ? swiftAppLaunchRegex : objcAppLaunchRegex;\n\n const fileContent = fs.readFileSync(filePath, 'utf8');\n return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);\n}\n\nfunction findAppDidFinishLaunchingWithOptions(dir: string): string | null {\n const files = fs.readdirSync(dir);\n //iterate over subdirectories later, \n //the appdelegate usually is in the top level\n const dirs: string[] = [];\n\n for (const file of files) {\n const filePath = path.join(dir, file);\n if (file.endsWith(\".swift\") || file.endsWith(\".m\") || file.endsWith(\".mm\")) {\n if (isAppDelegateFile(filePath)) {\n return filePath;\n }\n } else if (!file.startsWith(\".\") && !file.endsWith(\".xcodeproj\") && !file.endsWith(\".xcassets\") && fs.lstatSync(filePath).isDirectory()) {\n dirs.push(file);\n }\n }\n\n for (const dr of dirs) {\n const result = findAppDidFinishLaunchingWithOptions(path.join(dir, dr));\n if (result) return result;\n }\n return null;\n}\n\nexport function addCodeSnippetToProject(projPath: string, dsn: string): boolean {\n const appDelegate = findAppDidFinishLaunchingWithOptions(projPath);\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 ? templates.getSwiftSnippet(dsn) : templates.getObjcSnippet(dsn);\n\n Sentry.setTag(\"code-language\", isSwift ? \"swift\" : \"objc\");\n Sentry.setTag(\"ui-engine\", swiftUIRegex.test(fileContent) ? \"swiftui\" : \"uikit\");\n\n if (fileContent.includes(checkForSentryInit)) {\n //already initialized\n return true;\n }\n\n let match = appLaunchRegex.exec(fileContent);\n if (!match) {\n const swiftUIMatch = swiftUIRegex.exec(fileContent)\n if (!swiftUIMatch) {\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 const newFileContent = (fileContent.indexOf(importStatement) >= 0 ? \"\" : importStatement) +\n fileContent.slice(0, insertIndex) + \"\\n\" +\n codeSnippet +\n fileContent.slice(insertIndex);\n fs.writeFileSync(appDelegate, newFileContent, 'utf8');\n\n return true;\n}"]}
1
+ {"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/apple/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,qDAAyC;AACzC,mDAAuC;AAEvC,IAAM,mBAAmB,GACvB,sIAAsI,CAAC;AACzI,IAAM,kBAAkB,GACtB,mJAAmJ,CAAC;AACtJ,IA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AC,CAAC,OAAO,CACrD,CAAC;IAEF,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;QAC5C,qBAAqB;QACrB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK,EAAE;QACV,IAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;QACD,yBAAyB;QACzB,KAAK,GAAG,YAAY,CAAC;QACrB,WAAW,GAAG,wBAAiB,WAAW,UAAO,CAAC;KACnD;IAED,IAAM,WAAW,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAClD,IAAM,cAAc,GAClB,CAAC,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;QAClE,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;QACjC,IAAI;QACJ,WAAW;QACX,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACjC,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAEtD,OAAO,IAAI,CAAC;AACd,CAAC;AAlDD,0DAkDC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\nimport * as Sentry from '@sentry/node';\n\nconst swiftAppLaunchRegex =\n /(func\\s+application\\s*\\(_\\sapplication:[^,]+,\\s*didFinishLaunchingWithOptions[^,]+:[^)]+\\)\\s+->\\s+Bool\\s+{)|(init\\s*\\([^)]*\\)\\s*{)/im;\nconst objcAppLaunchRegex =\n /-\\s*\\(BOOL\\)\\s*application:\\s*\\(UIApplication\\s*\\*\\)\\s*application\\s+didFinishLaunchingWithOptions:\\s*\\(NSDictionary\\s*\\*\\)\\s*launchOptions\\s*{/im;\nconst swiftUIRegex = /struct[^:]+:\\s*App\\s*{/im;\n\nfunction isAppDelegateFile(filePath: string): boolean {\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 findAppDidFinishLaunchingWithOptions(dir: string): string | null {\n const files = fs.readdirSync(dir);\n //iterate over subdirectories later,\n //the appdelegate usually is in the top level\n const dirs: string[] = [];\n\n for (const file of files) {\n const filePath = path.join(dir, file);\n if (\n file.endsWith('.swift') ||\n file.endsWith('.m') ||\n file.endsWith('.mm')\n ) {\n if (isAppDelegateFile(filePath)) {\n return filePath;\n }\n } else if (\n !file.startsWith('.') &&\n !file.endsWith('.xcodeproj') &&\n !file.endsWith('.xcassets') &&\n fs.lstatSync(filePath).isDirectory()\n ) {\n dirs.push(file);\n }\n }\n\n for (const dr of dirs) {\n const result = findAppDidFinishLaunchingWithOptions(path.join(dir, dr));\n if (result) return result;\n }\n return null;\n}\n\nexport function addCodeSnippetToProject(\n projPath: string,\n dsn: string,\n): boolean {\n const appDelegate = findAppDidFinishLaunchingWithOptions(projPath);\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)\n : templates.getObjcSnippet(dsn);\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 return true;\n }\n\n let match = appLaunchRegex.exec(fileContent);\n if (!match) {\n const swiftUIMatch = swiftUIRegex.exec(fileContent);\n if (!swiftUIMatch) {\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 const newFileContent =\n (fileContent.indexOf(importStatement) >= 0 ? '' : importStatement) +\n fileContent.slice(0, insertIndex) +\n '\\n' +\n codeSnippet +\n fileContent.slice(insertIndex);\n fs.writeFileSync(appDelegate, newFileContent, 'utf8');\n\n return true;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function fastFile(projectPath: string): string | null;
2
+ export declare function addSentryToFastlane(projectPath: string, org: string, project: string, token: string): Promise<boolean>;
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.addSentryToFastlane = exports.fastFile = void 0;
63
+ var fs = __importStar(require("fs"));
64
+ var path = __importStar(require("path"));
65
+ var templates = __importStar(require("./templates"));
66
+ var clack_utils_1 = require("../utils/clack-utils");
67
+ function fastFile(projectPath) {
68
+ var fastlanePath = path.join(projectPath, 'fastlane', 'Fastfile');
69
+ return fs.existsSync(fastlanePath) ? fastlanePath : null;
70
+ }
71
+ exports.fastFile = fastFile;
72
+ function findIOSPlatform(content) {
73
+ var platformRegex = /^ *platform\s+:([^ ]+)[^\n]*\n/gim;
74
+ var match = platformRegex.exec(content);
75
+ if (!match) {
76
+ // No platform found, treat whole file as one platform.
77
+ return { index: 0, length: content.length };
78
+ }
79
+ var index = -1;
80
+ while (match) {
81
+ if (match[1] === 'ios') {
82
+ index = match.index + match[0].length;
83
+ break;
84
+ }
85
+ match = platformRegex.exec(content);
86
+ }
87
+ if (index === -1) {
88
+ return null;
89
+ }
90
+ //After finding the platform, we need to find the end of the platform block.
91
+ //This solution has the assumption that the file is well formed,
92
+ //which is not a perfect solution, but it's good enough assumption.
93
+ var platformEndRegex = /^end[^\n]*/gim;
94
+ match = platformEndRegex.exec(content.slice(index));
95
+ if (!match) {
96
+ return null;
97
+ }
98
+ return { index: index, length: match.index };
99
+ }
100
+ function findLanes(content) {
101
+ var laneRegex = /^ {2}lane\s+:([^ ]+)[^\n]*\n/gim;
102
+ var match = laneRegex.exec(content);
103
+ if (!match) {
104
+ return null;
105
+ }
106
+ var lanes = [];
107
+ while (match) {
108
+ var laneEnd = /^ {2}end/m.exec(content.slice(match.index + match[0].length));
109
+ if (laneEnd === null) {
110
+ return null;
111
+ }
112
+ lanes.push({
113
+ index: match.index + match[0].length,
114
+ length: laneEnd.index,
115
+ name: match[1],
116
+ });
117
+ match = laneRegex.exec(content);
118
+ }
119
+ return lanes;
120
+ }
121
+ function addSentryToLane(content, lane, org, project, token) {
122
+ var laneContent = content.slice(lane.index, lane.index + lane.length);
123
+ var sentryCLIMatch = /sentry_cli\s*\([^)]+\)/gim.exec(laneContent);
124
+ if (sentryCLIMatch) {
125
+ // Sentry already added to lane. Update it.
126
+ return (content.slice(0, sentryCLIMatch.index + lane.index) +
127
+ templates.getFastlaneSnippet(org, project, token).trim() +
128
+ content.slice(sentryCLIMatch.index + sentryCLIMatch[0].length + lane.index));
129
+ }
130
+ // Sentry not added to lane. Add it.
131
+ return (content.slice(0, lane.index + lane.length) +
132
+ '\n' +
133
+ templates.getFastlaneSnippet(org, project, token) +
134
+ '\n' +
135
+ content.slice(lane.index + lane.length));
136
+ }
137
+ function addSentryToFastlane(projectPath, org, project, token) {
138
+ return __awaiter(this, void 0, void 0, function () {
139
+ var fastFilePath, fileContent, platform, platformContent, lanes, newFileContent, laneNames, selectedLane;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0:
143
+ fastFilePath = fastFile(projectPath);
144
+ if (!fastFilePath) {
145
+ return [2 /*return*/, false];
146
+ }
147
+ fileContent = fs.readFileSync(fastFilePath, 'utf8');
148
+ platform = findIOSPlatform(fileContent);
149
+ if (!platform) {
150
+ return [2 /*return*/, false];
151
+ }
152
+ platformContent = fileContent.slice(platform.index, platform.index + platform.length);
153
+ lanes = findLanes(platformContent);
154
+ lanes === null || lanes === void 0 ? void 0 : lanes.forEach(function (l) { return (l.index += platform.index); });
155
+ if (!lanes || lanes.length === 0) {
156
+ return [2 /*return*/, false];
157
+ }
158
+ if (!(lanes.length === 1)) return [3 /*break*/, 1];
159
+ newFileContent = addSentryToLane(fileContent, lanes[0], org, project, token);
160
+ return [3 /*break*/, 3];
161
+ case 1:
162
+ laneNames = lanes.map(function (l) { return l.name; });
163
+ return [4 /*yield*/, (0, clack_utils_1.askForItemSelection)(laneNames, 'Select lane to add Sentry to:')];
164
+ case 2:
165
+ selectedLane = _a.sent();
166
+ if (selectedLane === undefined) {
167
+ return [2 /*return*/, false];
168
+ }
169
+ newFileContent = addSentryToLane(fileContent, lanes[selectedLane.index], org, project, token);
170
+ _a.label = 3;
171
+ case 3:
172
+ fs.writeFileSync(fastFilePath, newFileContent, 'utf8');
173
+ return [2 /*return*/, true];
174
+ }
175
+ });
176
+ });
177
+ }
178
+ exports.addSentryToFastlane = addSentryToFastlane;
179
+ //# sourceMappingURL=fastlane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fastlane.js","sourceRoot":"","sources":["../../../src/apple/fastlane.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,qDAAyC;AACzC,oDAA2D;AAE3D,SAAgB,QAAQ,CAAC,WAAmB;IAC1C,IAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACpE,OAAO,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAHD,4BAGC;AAED,SAAS,eAAe,CACtB,OAAe;IAEf,IAAM,aAAa,GAAG,mCAAmC,CAAC;IAC1D,IAAI,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK,EAAE;QACV,uDAAuD;QACvD,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;KAC7C;IAED,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,OAAO,KAAK,EAAE;QACZ,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;YACtB,KAAK,GAAG,KAAK,CAAC,KA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AAC;oBACvD,sBAAO,IAAI,EAAC;;;;CACb;AAzDD,kDAyDC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\nimport { askForItemSelection } from '../utils/clack-utils';\n\nexport function fastFile(projectPath: string): string | null {\n const fastlanePath = path.join(projectPath, 'fastlane', 'Fastfile');\n return fs.existsSync(fastlanePath) ? fastlanePath : null;\n}\n\nfunction findIOSPlatform(\n content: string,\n): { index: number; length: number } | null {\n const platformRegex = /^ *platform\\s+:([^ ]+)[^\\n]*\\n/gim;\n let match = platformRegex.exec(content);\n if (!match) {\n // No platform found, treat whole file as one platform.\n return { index: 0, length: content.length };\n }\n\n let index = -1;\n while (match) {\n if (match[1] === 'ios') {\n index = match.index + match[0].length;\n break;\n }\n match = platformRegex.exec(content);\n }\n\n if (index === -1) {\n return null;\n }\n\n //After finding the platform, we need to find the end of the platform block.\n //This solution has the assumption that the file is well formed,\n //which is not a perfect solution, but it's good enough assumption.\n const platformEndRegex = /^end[^\\n]*/gim;\n match = platformEndRegex.exec(content.slice(index));\n if (!match) {\n return null;\n }\n\n return { index, length: match.index };\n}\n\nfunction findLanes(\n content: string,\n): { index: number; length: number; name: string }[] | null {\n const laneRegex = /^ {2}lane\\s+:([^ ]+)[^\\n]*\\n/gim;\n let match = laneRegex.exec(content);\n if (!match) {\n return null;\n }\n\n const lanes: { index: number; length: number; name: string }[] = [];\n while (match) {\n const laneEnd = /^ {2}end/m.exec(\n content.slice(match.index + match[0].length),\n );\n if (laneEnd === null) {\n return null;\n }\n lanes.push({\n index: match.index + match[0].length,\n length: laneEnd.index,\n name: match[1],\n });\n match = laneRegex.exec(content);\n }\n return lanes;\n}\n\nfunction addSentryToLane(\n content: string,\n lane: { index: number; length: number; name: string },\n org: string,\n project: string,\n token: string,\n): string {\n const laneContent = content.slice(lane.index, lane.index + lane.length);\n const sentryCLIMatch = /sentry_cli\\s*\\([^)]+\\)/gim.exec(laneContent);\n if (sentryCLIMatch) {\n // Sentry already added to lane. Update it.\n return (\n content.slice(0, sentryCLIMatch.index + lane.index) +\n templates.getFastlaneSnippet(org, project, token).trim() +\n content.slice(\n sentryCLIMatch.index + sentryCLIMatch[0].length + lane.index,\n )\n );\n }\n\n // Sentry not added to lane. Add it.\n return (\n content.slice(0, lane.index + lane.length) +\n '\\n' +\n templates.getFastlaneSnippet(org, project, token) +\n '\\n' +\n content.slice(lane.index + lane.length)\n );\n}\n\nexport async function addSentryToFastlane(\n projectPath: string,\n org: string,\n project: string,\n token: string,\n): Promise<boolean> {\n const fastFilePath = fastFile(projectPath);\n if (!fastFilePath) {\n return false;\n }\n\n const fileContent = fs.readFileSync(fastFilePath, 'utf8');\n const platform = findIOSPlatform(fileContent);\n if (!platform) {\n return false;\n }\n\n const platformContent = fileContent.slice(\n platform.index,\n platform.index + platform.length,\n );\n const lanes = findLanes(platformContent);\n lanes?.forEach((l) => (l.index += platform.index));\n\n if (!lanes || lanes.length === 0) {\n return false;\n }\n\n let newFileContent: string | undefined;\n if (lanes.length === 1) {\n newFileContent = addSentryToLane(\n fileContent,\n lanes[0],\n org,\n project,\n token,\n );\n } else {\n const laneNames = lanes.map((l) => l.name);\n const selectedLane = await askForItemSelection(\n laneNames,\n 'Select lane to add Sentry to:',\n );\n if (selectedLane === undefined) {\n return false;\n }\n newFileContent = addSentryToLane(\n fileContent,\n lanes[selectedLane.index],\n org,\n project,\n token,\n );\n }\n\n fs.writeFileSync(fastFilePath, newFileContent, 'utf8');\n return true;\n}\n"]}
@@ -2,3 +2,4 @@ export declare function getRunScriptTemplate(orgSlug: string, projectSlug: strin
2
2
  export declare const scriptInputPath = "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"";
3
3
  export declare function getSwiftSnippet(dsn: string): string;
4
4
  export declare function getObjcSnippet(dsn: string): string;
5
+ export declare function getFastlaneSnippet(org: string, project: string, token: string): string;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getObjcSnippet = exports.getSwiftSnippet = exports.scriptInputPath = exports.getRunScriptTemplate = void 0;
3
+ exports.getFastlaneSnippet = exports.getObjcSnippet = exports.getSwiftSnippet = exports.scriptInputPath = exports.getRunScriptTemplate = void 0;
4
4
  function getRunScriptTemplate(orgSlug, projectSlug, apiKey, uploadSource) {
5
5
  if (uploadSource === void 0) { uploadSource = true; }
6
6
  // eslint-disable-next-line no-useless-escape
7
- return "# This script is responsable to upload debug symbols and source context for Sentry.\\nif which sentry-cli >/dev/null; then\\nexport SENTRY_ORG=".concat(orgSlug, "\\nexport SENTRY_PROJECT=").concat(projectSlug, "\\nexport SENTRY_AUTH_TOKEN=").concat(apiKey, "\\nERROR=$(sentry-cli debug-files upload ").concat(uploadSource ? "--include-sources " : "", "\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\nif [ ! $? -eq 0 ]; then\\necho \"warning: sentry-cli - $ERROR\"\\nfi\\nelse\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\nfi\\n");
7
+ return "# This script is responsable to upload debug symbols and source context for Sentry.\\nif which sentry-cli >/dev/null; then\\nexport SENTRY_ORG=".concat(orgSlug, "\\nexport SENTRY_PROJECT=").concat(projectSlug, "\\nexport SENTRY_AUTH_TOKEN=").concat(apiKey, "\\nERROR=$(sentry-cli debug-files upload ").concat(uploadSource ? '--include-sources ' : '', "\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\nif [ ! $? -eq 0 ]; then\\necho \"warning: sentry-cli - $ERROR\"\\nfi\\nelse\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\nfi\\n");
8
8
  }
9
9
  exports.getRunScriptTemplate = getRunScriptTemplate;
10
- exports.scriptInputPath = "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"";
10
+ exports.scriptInputPath = '"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}"';
11
11
  function getSwiftSnippet(dsn) {
12
12
  return " SentrySDK.start { options in\n options.dsn = \"".concat(dsn, "\"\n options.debug = true // Enabled debug when first installing is always helpful\n options.enableTracing = true \n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\n");
13
13
  }
@@ -16,4 +16,8 @@ function getObjcSnippet(dsn) {
16
16
  return " [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"".concat(dsn, "\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n options.enableTracing = YES;\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\n");
17
17
  }
18
18
  exports.getObjcSnippet = getObjcSnippet;
19
+ function getFastlaneSnippet(org, project, token) {
20
+ return " sentry_cli(\n auth_token: '".concat(token, "',\n org_slug: '").concat(org, "',\n project_slug: '").concat(project, "',\n include_sources: true\n )");
21
+ }
22
+ exports.getFastlaneSnippet = getFastlaneSnippet;
19
23
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAChC,OAAe,EACf,WAAmB,EACnB,MAAc,EACd,YAAmB;IAAnB,6BAAA,EAAA,mBAAmB;IAEnB,6CAA6C;IAC7C,OAAO,yJAAkJ,OAAO,sCAA4B,WAAW,yCAA+B,MAAM,sDAA4C,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oPAAiP,CAAC;AACtjB,CAAC;AARD,oDAQC;AAEY,QAAA,eAAe,GAAG,+FAA+F,CAAC;AAE/H,SAAgB,eAAe,CAAC,GAAW;IACvC,OAAO,4EACkB,GAAG,4kBASiC,CAAC;AAClE,CAAC;AAZD,0CAYC;AAED,SAAgB,cAAc,CAAC,GAAW;IACtC,OAAO,0GACe,GAAG,8iBAS8B,CAAC;AAC5D,CAAC;AAZD,wCAYC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n apiKey: string,\n uploadSource = true,\n): string {\n // eslint-disable-next-line no-useless-escape\n return `# This script is responsable to upload debug symbols and source context for Sentry.\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\nexport SENTRY_AUTH_TOKEN=${apiKey}\\\\nERROR=$(sentry-cli debug-files upload ${uploadSource ? \"--include-sources \" : \"\"}\\\"$DWARF_DSYM_FOLDER_PATH\\\" 2>&1 >/dev/null)\\\\nif [ ! $? -eq 0 ]; then\\\\necho \\\"warning: sentry-cli - $ERROR\\\"\\\\nfi\\\\nelse\\\\necho \\\"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\\\"\\\\nfi\\\\n`;\n}\n\nexport const scriptInputPath = \"\\\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\\\"\";\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n options.enableTracing = true \n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n options.enableTracing = YES;\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,MAAc,EACd,YAAmB;IAAnB,6BAAA,EAAA,mBAAmB;IAEnB,6CAA6C;IAC7C,OAAO,yJAAkJ,OAAO,sCAA4B,WAAW,yCAA+B,MAAM,sDAC1O,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oPACiM,CAAC;AAC9O,CAAC;AAVD,oDAUC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,4EACoB,GAAG,4kBASiC,CAAC;AAClE,CAAC;AAZD,0CAYC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO,0GACiB,GAAG,8iBAS8B,CAAC;AAC5D,CAAC;AAZD,wCAYC;AAED,SAAgB,kBAAkB,CAChC,GAAW,EACX,OAAe,EACf,KAAa;IAEb,OAAO,8CACY,KAAK,kCACP,GAAG,sCACC,OAAO,2CAExB,CAAC;AACP,CAAC;AAXD,gDAWC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n apiKey: string,\n uploadSource = true,\n): string {\n // eslint-disable-next-line no-useless-escape\n return `# This script is responsable to upload debug symbols and source context for Sentry.\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\nexport SENTRY_AUTH_TOKEN=${apiKey}\\\\nERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\\\nif [ ! $? -eq 0 ]; then\\\\necho \"warning: sentry-cli - $ERROR\"\\\\nfi\\\\nelse\\\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\\\nfi\\\\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n options.enableTracing = true \n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n options.enableTracing = YES;\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}\n\nexport function getFastlaneSnippet(\n org: string,\n project: string,\n token: string,\n): string {\n return ` sentry_cli(\n auth_token: '${token}',\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { SentryProjectData } from '../utils/clack-utils';
1
+ import { SentryProjectData } from '../utils/types';
2
2
  export declare function updateXcodeProject(projectPath: string, sentryProject: SentryProjectData, apiKeys: {
3
3
  token: string;
4
4
  }, addSPMReference: boolean, uploadSource?: boolean): void;
@@ -24,6 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.updateXcodeProject = void 0;
27
+ /* eslint-disable max-lines */
28
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
29
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
30
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
31
+ /* eslint-disable @typescript-eslint/no-unused-vars */
27
32
  var fs = __importStar(require("fs"));
28
33
  var templates = __importStar(require("./templates"));
29
34
  var xcode = require('xcode');
@@ -32,7 +37,7 @@ function setDebugInformationFormat(proj) {
32
37
  var xcObjects = proj.hash.project.objects;
33
38
  var target = proj.getFirstTarget().firstTarget;
34
39
  xcObjects.XCConfigurationList[target.buildConfigurationList].buildConfigurations.forEach(function (buildConfig) {
35
- xcObjects.XCBuildConfiguration[buildConfig.value].buildSettings.DEBUG_INFORMATION_FORMAT = "\"dwarf-with-dsym\"";
40
+ xcObjects.XCBuildConfiguration[buildConfig.value].buildSettings.DEBUG_INFORMATION_FORMAT = '"dwarf-with-dsym"';
36
41
  });
37
42
  }
38
43
  function addSentrySPM(proj) {
@@ -42,11 +47,11 @@ function addSentrySPM(proj) {
42
47
  //Check whether xcObjects already have sentry framework
43
48
  if (xcObjects.PBXFrameworksBuildPhase) {
44
49
  for (var key in xcObjects.PBXFrameworksBuildPhase || {}) {
45
- if (!key.endsWith("_comment")) {
50
+ if (!key.endsWith('_comment')) {
46
51
  var frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;
47
52
  for (var _i = 0, frameworks_1 = frameworks; _i < frameworks_1.length; _i++) {
48
53
  var framework = frameworks_1[_i];
49
- if (framework.comment === "Sentry in Frameworks") {
54
+ if (framework.comment === 'Sentry in Frameworks') {
50
55
  return;
51
56
  }
52
57
  }
@@ -54,17 +59,18 @@ function addSentrySPM(proj) {
54
59
  }
55
60
  }
56
61
  xcObjects.PBXBuildFile[sentryFrameworkUUID] = {
57
- isa: "PBXBuildFile",
62
+ isa: 'PBXBuildFile',
58
63
  productRef: sentrySPMUUID,
59
- productRef_comment: "Sentry",
64
+ productRef_comment: 'Sentry',
60
65
  };
61
- xcObjects.PBXBuildFile[sentryFrameworkUUID + "_comment"] = "Sentry in Frameworks";
66
+ xcObjects.PBXBuildFile[sentryFrameworkUUID + '_comment'] =
67
+ 'Sentry in Frameworks';
62
68
  for (var key in xcObjects.PBXFrameworksBuildPhase || {}) {
63
- if (!key.endsWith("_comment")) {
69
+ if (!key.endsWith('_comment')) {
64
70
  var frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;
65
71
  frameworks.push({
66
72
  value: sentryFrameworkUUID,
67
- comment: "Sentry in Frameworks",
73
+ comment: 'Sentry in Frameworks',
68
74
  });
69
75
  }
70
76
  }
@@ -74,7 +80,7 @@ function addSentrySPM(proj) {
74
80
  }
75
81
  target.packageProductDependencies.push({
76
82
  value: sentrySPMUUID,
77
- comment: "Sentry",
83
+ comment: 'Sentry',
78
84
  });
79
85
  var sentrySwiftPackageUUID = proj.generateUuid();
80
86
  var xcProject = proj.getFirstProject().firstProject;
@@ -83,38 +89,39 @@ function addSentrySPM(proj) {
83
89
  }
84
90
  xcProject.packageReferences.push({
85
91
  value: sentrySwiftPackageUUID,
86
- comment: "XCRemoteSwiftPackageReference \"sentry-cocoa\"",
92
+ comment: 'XCRemoteSwiftPackageReference "sentry-cocoa"',
87
93
  });
88
94
  xcObjects.XCRemoteSwiftPackageReference = {};
89
95
  xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {
90
- isa: "XCRemoteSwiftPackageReference",
91
- repositoryURL: "\"https://github.com/getsentry/sentry-cocoa/\"",
96
+ isa: 'XCRemoteSwiftPackageReference',
97
+ repositoryURL: '"https://github.com/getsentry/sentry-cocoa/"',
92
98
  requirement: {
93
- kind: "upToNextMajorVersion",
94
- minimumVersion: "8.0.0",
95
- }
99
+ kind: 'upToNextMajorVersion',
100
+ minimumVersion: '8.0.0',
101
+ },
96
102
  };
97
- xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID + "_comment"] = "XCRemoteSwiftPackageReference \"sentry-cocoa\"";
103
+ xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID + '_comment'] =
104
+ 'XCRemoteSwiftPackageReference "sentry-cocoa"';
98
105
  xcObjects.XCSwiftPackageProductDependency = {};
99
- xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] =
100
- {
101
- isa: "XCSwiftPackageProductDependency",
102
- package: sentrySwiftPackageUUID,
103
- package_comment: "XCRemoteSwiftPackageReference \"sentry-cocoa\"",
104
- productName: "Sentry",
105
- };
106
- xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID + "_comment"] = "Sentry";
106
+ xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {
107
+ isa: 'XCSwiftPackageProductDependency',
108
+ package: sentrySwiftPackageUUID,
109
+ package_comment: 'XCRemoteSwiftPackageReference "sentry-cocoa"',
110
+ productName: 'Sentry',
111
+ };
112
+ xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID + '_comment'] =
113
+ 'Sentry';
107
114
  }
108
115
  function addUploadSymbolsScript(xcodeProject, sentryProject, apiKeys, uploadSource) {
109
116
  if (uploadSource === void 0) { uploadSource = true; }
110
117
  var xcObjects = xcodeProject.hash.project.objects;
111
118
  for (var scriptKey in xcObjects.PBXShellScriptBuildPhase || {}) {
112
- if (!scriptKey.endsWith("_comment")) {
119
+ if (!scriptKey.endsWith('_comment')) {
113
120
  var script = xcObjects.PBXShellScriptBuildPhase[scriptKey].shellScript;
114
121
  //Sentry script already exists, update it
115
- if (script.includes("sentry-cli")) {
122
+ if (script.includes('sentry-cli')) {
116
123
  delete xcObjects.PBXShellScriptBuildPhase[scriptKey];
117
- delete xcObjects.PBXShellScriptBuildPhase[scriptKey + "_comment"];
124
+ delete xcObjects.PBXShellScriptBuildPhase[scriptKey + '_comment'];
118
125
  break;
119
126
  }
120
127
  }
@@ -124,7 +131,7 @@ function addUploadSymbolsScript(xcodeProject, sentryProject, apiKeys, uploadSour
124
131
  outputFileListPaths: [],
125
132
  inputPaths: [templates.scriptInputPath],
126
133
  shellPath: '/bin/sh',
127
- shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, apiKeys.token, uploadSource)
134
+ shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, apiKeys.token, uploadSource),
128
135
  });
129
136
  }
130
137
  function updateXcodeProject(projectPath, sentryProject, apiKeys, addSPMReference, uploadSource) {
@@ -1 +1 @@
1
- {"version":3,"file":"xcode-manager.js","sourceRoot":"","sources":["../../../src/apple/xcode-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASA,qCAAyB;AAEzB,qDAAyC;AACzC,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAG/B,qDAAqD;AAErD,SAAS,yBAAyB,CAAC,IAAS;IACxC,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC5C,IAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,WAAW,CAAC;IAEjD,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,UAAC,WAA8B;QACpH,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,wBAAwB,GAAG,qBAAqB,CAAC;IACrH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,YAAY,CAAC,IAAS;IAC3B,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAE5C,IAAM,mBAAmB,GAAG,IA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AY,CAAC,IAAI,CAAC,CAAC;KACtB;IACD,IAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IACpC,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC9C,CAAC;AAZD,gDAYC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { SentryCli } from '../../lib/Helper/SentryCli';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\nconst xcode = require('xcode');\n\nimport { SentryProjectData } from '../utils/clack-utils';\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nfunction setDebugInformationFormat(proj: any): void {\n const xcObjects = proj.hash.project.objects;\n const target = proj.getFirstTarget().firstTarget;\n\n xcObjects.XCConfigurationList[target.buildConfigurationList].buildConfigurations.forEach((buildConfig: { value: string }) => {\n xcObjects.XCBuildConfiguration[buildConfig.value].buildSettings.DEBUG_INFORMATION_FORMAT = \"\\\"dwarf-with-dsym\\\"\";\n });\n}\n\nfunction addSentrySPM(proj: any): void {\n const xcObjects = proj.hash.project.objects;\n\n const sentryFrameworkUUID = proj.generateUuid() as string;\n const sentrySPMUUID = proj.generateUuid() as string;\n\n //Check whether xcObjects already have sentry framework\n if (xcObjects.PBXFrameworksBuildPhase) {\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n if (!key.endsWith(\"_comment\")) {\n const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;\n for (const framework of frameworks) {\n if (framework.comment === \"Sentry in Frameworks\") {\n return;\n }\n }\n }\n }\n }\n\n xcObjects.PBXBuildFile[sentryFrameworkUUID] = {\n isa: \"PBXBuildFile\",\n productRef: sentrySPMUUID,\n productRef_comment: \"Sentry\",\n };\n xcObjects.PBXBuildFile[sentryFrameworkUUID + \"_comment\"] = \"Sentry in Frameworks\";\n\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n if (!key.endsWith(\"_comment\")) {\n const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;\n frameworks.push({\n value: sentryFrameworkUUID,\n comment: \"Sentry in Frameworks\",\n });\n }\n }\n\n const target = proj.getFirstTarget().firstTarget;\n if (!target.packageProductDependencies) {\n target.packageProductDependencies = [];\n }\n target.packageProductDependencies.push({\n value: sentrySPMUUID,\n comment: \"Sentry\",\n });\n\n const sentrySwiftPackageUUID = proj.generateUuid() as string;\n const xcProject = proj.getFirstProject().firstProject;\n if (!xcProject.packageReferences) {\n xcProject.packageReferences = [];\n }\n xcProject.packageReferences.push({\n value: sentrySwiftPackageUUID,\n comment: \"XCRemoteSwiftPackageReference \\\"sentry-cocoa\\\"\",\n });\n\n xcObjects.XCRemoteSwiftPackageReference = {};\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {\n isa: \"XCRemoteSwiftPackageReference\",\n repositoryURL: \"\\\"https://github.com/getsentry/sentry-cocoa/\\\"\",\n requirement: {\n kind: \"upToNextMajorVersion\",\n minimumVersion: \"8.0.0\",\n }\n };\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID + \"_comment\"] = \"XCRemoteSwiftPackageReference \\\"sentry-cocoa\\\"\";\n\n xcObjects.XCSwiftPackageProductDependency = {};\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] =\n {\n isa: \"XCSwiftPackageProductDependency\",\n package: sentrySwiftPackageUUID,\n package_comment: \"XCRemoteSwiftPackageReference \\\"sentry-cocoa\\\"\",\n productName: \"Sentry\",\n };\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID + \"_comment\"] = \"Sentry\";\n}\n\nfunction addUploadSymbolsScript(xcodeProject: any, sentryProject: SentryProjectData, apiKeys: { token: string }, uploadSource = true): void {\n const xcObjects = xcodeProject.hash.project.objects;\n\n for (const scriptKey in xcObjects.PBXShellScriptBuildPhase || {}) {\n if (!scriptKey.endsWith(\"_comment\")) {\n const script = xcObjects.PBXShellScriptBuildPhase[scriptKey].shellScript;\n //Sentry script already exists, update it\n if (script.includes(\"sentry-cli\")) {\n delete xcObjects.PBXShellScriptBuildPhase[scriptKey];\n delete xcObjects.PBXShellScriptBuildPhase[scriptKey + \"_comment\"];\n break;\n }\n }\n }\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n inputFileListPaths: [],\n outputFileListPaths: [],\n inputPaths: [templates.scriptInputPath],\n shellPath: '/bin/sh',\n shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, apiKeys.token, uploadSource)\n },\n );\n}\n\nexport function updateXcodeProject(projectPath: string, sentryProject: SentryProjectData, apiKeys: { token: string }, addSPMReference: boolean, uploadSource = true): void {\n const proj = xcode.project(projectPath);\n proj.parseSync();\n addUploadSymbolsScript(proj, sentryProject, apiKeys, uploadSource);\n if (uploadSource) {\n setDebugInformationFormat(proj);\n }\n if (addSPMReference) {\n addSentrySPM(proj);\n }\n const newContent = proj.writeSync();\n fs.writeFileSync(projectPath, newContent);\n}"]}
1
+ {"version":3,"file":"xcode-manager.js","sourceRoot":"","sources":["../../../src/apple/xcode-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,sDAAsD;AACtD,qCAAyB;AAEzB,qDAAyC;AACzC,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B,qDAAqD;AAErD,SAAS,yBAAyB,CAAC,IAAS;IAC1C,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC5C,IAAM,MAAM,GAAG,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AAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAChC,WAAmB,EACnB,aAAgC,EAChC,OAA0B,EAC1B,eAAwB,EACxB,YAAmB;IAAnB,6BAAA,EAAA,mBAAmB;IAEnB,IAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,CAAC,SAAS,EAAE,CAAC;IACjB,sBAAsB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IACnE,IAAI,YAAY,EAAE;QAChB,yBAAyB,CAAC,IAAI,CAAC,CAAC;KACjC;IACD,IAAI,eAAe,EAAE;QACnB,YAAY,CAAC,IAAI,CAAC,CAAC;KACpB;IACD,IAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IACpC,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC5C,CAAC;AAlBD,gDAkBC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport * as fs from 'fs';\nimport { SentryProjectData } from '../utils/types';\nimport * as templates from './templates';\nconst xcode = require('xcode');\n\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nfunction setDebugInformationFormat(proj: any): void {\n const xcObjects = proj.hash.project.objects;\n const target = proj.getFirstTarget().firstTarget;\n\n xcObjects.XCConfigurationList[\n target.buildConfigurationList\n ].buildConfigurations.forEach((buildConfig: { value: string }) => {\n xcObjects.XCBuildConfiguration[\n buildConfig.value\n ].buildSettings.DEBUG_INFORMATION_FORMAT = '\"dwarf-with-dsym\"';\n });\n}\n\nfunction addSentrySPM(proj: any): void {\n const xcObjects = proj.hash.project.objects;\n\n const sentryFrameworkUUID = proj.generateUuid() as string;\n const sentrySPMUUID = proj.generateUuid() as string;\n\n //Check whether xcObjects already have sentry framework\n if (xcObjects.PBXFrameworksBuildPhase) {\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n if (!key.endsWith('_comment')) {\n const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;\n for (const framework of frameworks) {\n if (framework.comment === 'Sentry in Frameworks') {\n return;\n }\n }\n }\n }\n }\n\n xcObjects.PBXBuildFile[sentryFrameworkUUID] = {\n isa: 'PBXBuildFile',\n productRef: sentrySPMUUID,\n productRef_comment: 'Sentry',\n };\n xcObjects.PBXBuildFile[sentryFrameworkUUID + '_comment'] =\n 'Sentry in Frameworks';\n\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n if (!key.endsWith('_comment')) {\n const frameworks = xcObjects.PBXFrameworksBuildPhase[key].files;\n frameworks.push({\n value: sentryFrameworkUUID,\n comment: 'Sentry in Frameworks',\n });\n }\n }\n\n const target = proj.getFirstTarget().firstTarget;\n if (!target.packageProductDependencies) {\n target.packageProductDependencies = [];\n }\n target.packageProductDependencies.push({\n value: sentrySPMUUID,\n comment: 'Sentry',\n });\n\n const sentrySwiftPackageUUID = proj.generateUuid() as string;\n const xcProject = proj.getFirstProject().firstProject;\n if (!xcProject.packageReferences) {\n xcProject.packageReferences = [];\n }\n xcProject.packageReferences.push({\n value: sentrySwiftPackageUUID,\n comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n });\n\n xcObjects.XCRemoteSwiftPackageReference = {};\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {\n isa: 'XCRemoteSwiftPackageReference',\n repositoryURL: '\"https://github.com/getsentry/sentry-cocoa/\"',\n requirement: {\n kind: 'upToNextMajorVersion',\n minimumVersion: '8.0.0',\n },\n };\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID + '_comment'] =\n 'XCRemoteSwiftPackageReference \"sentry-cocoa\"';\n\n xcObjects.XCSwiftPackageProductDependency = {};\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {\n isa: 'XCSwiftPackageProductDependency',\n package: sentrySwiftPackageUUID,\n package_comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n productName: 'Sentry',\n };\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID + '_comment'] =\n 'Sentry';\n}\n\nfunction addUploadSymbolsScript(\n xcodeProject: any,\n sentryProject: SentryProjectData,\n apiKeys: { token: string },\n uploadSource = true,\n): void {\n const xcObjects = xcodeProject.hash.project.objects;\n\n for (const scriptKey in xcObjects.PBXShellScriptBuildPhase || {}) {\n if (!scriptKey.endsWith('_comment')) {\n const script = xcObjects.PBXShellScriptBuildPhase[scriptKey].shellScript;\n //Sentry script already exists, update it\n if (script.includes('sentry-cli')) {\n delete xcObjects.PBXShellScriptBuildPhase[scriptKey];\n delete xcObjects.PBXShellScriptBuildPhase[scriptKey + '_comment'];\n break;\n }\n }\n }\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n inputFileListPaths: [],\n outputFileListPaths: [],\n inputPaths: [templates.scriptInputPath],\n shellPath: '/bin/sh',\n shellScript: templates.getRunScriptTemplate(\n sentryProject.organization.slug,\n sentryProject.slug,\n apiKeys.token,\n uploadSource,\n ),\n },\n );\n}\n\nexport function updateXcodeProject(\n projectPath: string,\n sentryProject: SentryProjectData,\n apiKeys: { token: string },\n addSPMReference: boolean,\n uploadSource = true,\n): void {\n const proj = xcode.project(projectPath);\n proj.parseSync();\n addUploadSymbolsScript(proj, sentryProject, apiKeys, uploadSource);\n if (uploadSource) {\n setDebugInformationFormat(proj);\n }\n if (addSPMReference) {\n addSentrySPM(proj);\n }\n const newContent = proj.writeSync();\n fs.writeFileSync(projectPath, newContent);\n}\n"]}