@sentry/wizard 4.8.0 → 5.0.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 +20 -0
- package/dist/e2e-tests/tests/angular-17.test.js +41 -41
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
- package/dist/e2e-tests/tests/angular-19.test.js +39 -39
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
- package/dist/e2e-tests/tests/expo.test.js +10 -2
- package/dist/e2e-tests/tests/expo.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.js +38 -3
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.js +14 -6
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Helper/SentryCli.d.ts +0 -11
- package/dist/lib/Helper/SentryCli.js +0 -52
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js +13 -30
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/src/android/templates.js +2 -0
- package/dist/src/android/templates.js.map +1 -1
- package/dist/src/angular/angular-wizard.js +1 -1
- package/dist/src/angular/angular-wizard.js.map +1 -1
- package/dist/src/angular/sdk-setup.d.ts +1 -1
- package/dist/src/angular/sdk-setup.js +3 -3
- package/dist/src/angular/sdk-setup.js.map +1 -1
- package/dist/src/apple/code-tools.d.ts +4 -2
- package/dist/src/apple/code-tools.js +21 -11
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/inject-code-snippet.js +5 -3
- package/dist/src/apple/inject-code-snippet.js.map +1 -1
- package/dist/src/apple/macos-system-helper.d.ts +5 -0
- package/dist/src/apple/macos-system-helper.js +86 -0
- package/dist/src/apple/macos-system-helper.js.map +1 -0
- package/dist/src/apple/templates.js +10 -0
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +237 -11
- package/dist/src/apple/xcode-manager.js +736 -65
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/apple/xcode-project-object-with-id.d.ts +5 -0
- package/dist/src/apple/xcode-project-object-with-id.js +3 -0
- package/dist/src/apple/xcode-project-object-with-id.js.map +1 -0
- package/dist/src/flutter/templates.js +7 -1
- package/dist/src/flutter/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +1 -3
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +1 -3
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/react-native/expo-env-file.js +5 -0
- package/dist/src/react-native/expo-env-file.js.map +1 -1
- package/dist/src/react-native/expo-metro.js +18 -5
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +6 -0
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/glob.js +14 -4
- package/dist/src/react-native/glob.js.map +1 -1
- package/dist/src/react-native/gradle.d.ts +0 -1
- package/dist/src/react-native/gradle.js +15 -9
- package/dist/src/react-native/gradle.js.map +1 -1
- package/dist/src/react-native/javascript.d.ts +9 -4
- package/dist/src/react-native/javascript.js +44 -22
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.d.ts +1 -5
- package/dist/src/react-native/metro.js +18 -120
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/options.d.ts +1 -3
- package/dist/src/react-native/options.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +1 -19
- package/dist/src/react-native/react-native-wizard.js +27 -101
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +0 -7
- package/dist/src/react-native/xcode.js +15 -108
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +1 -3
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/run.js +1 -4
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/utils/sdk-version.js +3 -0
- package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +1 -3
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/ast-utils.d.ts +0 -7
- package/dist/src/utils/ast-utils.js +1 -27
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack/index.d.ts +2 -12
- package/dist/src/utils/clack/index.js +8 -47
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/utils/git.d.ts +11 -0
- package/dist/src/utils/git.js +69 -0
- package/dist/src/utils/git.js.map +1 -0
- package/dist/src/utils/sentrycli-utils.js +13 -4
- package/dist/src/utils/sentrycli-utils.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/apple/code-tools.test.js +54 -35
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/configure-sentry-cli.test.d.ts +1 -0
- package/dist/test/apple/configure-sentry-cli.test.js +131 -0
- package/dist/test/apple/configure-sentry-cli.test.js.map +1 -0
- package/dist/test/apple/macos-system-helper-mocked.test.d.ts +1 -0
- package/dist/test/apple/macos-system-helper-mocked.test.js +46 -0
- package/dist/test/apple/macos-system-helper-mocked.test.js.map +1 -0
- package/dist/test/apple/macos-system-helper.test.d.ts +1 -0
- package/dist/test/apple/macos-system-helper.test.js +88 -0
- package/dist/test/apple/macos-system-helper.test.js.map +1 -0
- package/dist/test/apple/templates.test.js +10 -0
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +745 -379
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +9 -0
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/react-native/gradle.test.js +0 -119
- package/dist/test/react-native/gradle.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +119 -0
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +0 -90
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/react-native/xcode.test.js +0 -81
- package/dist/test/react-native/xcode.test.js.map +1 -1
- package/dist/test/utils/git.test.d.ts +1 -0
- package/dist/test/utils/git.test.js +70 -0
- package/dist/test/utils/git.test.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/react-native/uninstall.d.ts +0 -2
- package/dist/src/react-native/uninstall.js +0 -94
- package/dist/src/react-native/uninstall.js.map +0 -1
|
@@ -30,29 +30,36 @@ const path = __importStar(require("path"));
|
|
|
30
30
|
const templates = __importStar(require("./templates"));
|
|
31
31
|
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
32
32
|
const clack = __importStar(require("@clack/prompts"));
|
|
33
|
+
const debug_1 = require("../utils/debug");
|
|
33
34
|
const swiftAppLaunchRegex = /(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;
|
|
34
35
|
const objcAppLaunchRegex = /-\s*\(\s*BOOL\s*\)\s*application:\s*\(\s*UIApplication\s*\*\s*\)\s*application\s+didFinishLaunchingWithOptions:\s*\(\s*NSDictionary\s*\*\s*\)\s*launchOptions\s*{/im;
|
|
35
36
|
const swiftUIRegex = /@main\s+struct[^:]+:\s*(SwiftUI\.)?App\s*{/im;
|
|
36
37
|
function isAppDelegateFile(filePath) {
|
|
38
|
+
(0, debug_1.debug)('Checking if ' + filePath + ' is an AppDelegate file');
|
|
37
39
|
const appLaunchRegex = filePath.toLowerCase().endsWith('.swift')
|
|
38
40
|
? swiftAppLaunchRegex
|
|
39
41
|
: objcAppLaunchRegex;
|
|
40
42
|
const fileContent = fs.readFileSync(filePath, 'utf8');
|
|
41
43
|
return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);
|
|
42
44
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
function findAppDidFinishLaunchingWithOptionsInDirectory(dir) {
|
|
46
|
+
(0, debug_1.debug)('Searching for AppDelegate in directory: ' + dir);
|
|
47
|
+
const files = fs.readdirSync(dir);
|
|
48
|
+
const filePaths = files.map((f) => path.join(dir, f));
|
|
49
|
+
return findAppDidFinishLaunchingWithOptions(filePaths);
|
|
50
|
+
}
|
|
51
|
+
function findAppDidFinishLaunchingWithOptions(files) {
|
|
52
|
+
(0, debug_1.debug)(`Searching for AppDelegate in ${files.length} files`);
|
|
53
|
+
// Iterate over subdirectories after iterating over files,
|
|
54
|
+
// because the AppDelegate is usually in the top level
|
|
50
55
|
const dirs = [];
|
|
51
56
|
for (const filePath of files) {
|
|
57
|
+
(0, debug_1.debug)('Checking file: ' + filePath);
|
|
52
58
|
if (filePath.endsWith('.swift') ||
|
|
53
59
|
filePath.endsWith('.m') ||
|
|
54
60
|
filePath.endsWith('.mm')) {
|
|
55
61
|
if (fs.existsSync(filePath) && isAppDelegateFile(filePath)) {
|
|
62
|
+
(0, debug_1.debug)('Found AppDelegate in ' + filePath);
|
|
56
63
|
return filePath;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
@@ -65,14 +72,16 @@ function findAppDidFinishLaunchingWithOptions(dir, files = undefined) {
|
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
for (const dr of dirs) {
|
|
68
|
-
const result =
|
|
69
|
-
if (result)
|
|
75
|
+
const result = findAppDidFinishLaunchingWithOptionsInDirectory(dr);
|
|
76
|
+
if (result) {
|
|
77
|
+
(0, debug_1.debug)('Found AppDelegate in ' + dr);
|
|
70
78
|
return result;
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
return null;
|
|
73
82
|
}
|
|
74
|
-
function addCodeSnippetToProject(
|
|
75
|
-
const appDelegate = findAppDidFinishLaunchingWithOptions(
|
|
83
|
+
function addCodeSnippetToProject(files, dsn) {
|
|
84
|
+
const appDelegate = findAppDidFinishLaunchingWithOptions(files);
|
|
76
85
|
if (!appDelegate) {
|
|
77
86
|
return false;
|
|
78
87
|
}
|
|
@@ -129,6 +138,7 @@ exports.addCodeSnippetToProject = addCodeSnippetToProject;
|
|
|
129
138
|
if (process.env.NODE_ENV === 'test') {
|
|
130
139
|
exports.exportForTesting = {
|
|
131
140
|
isAppDelegateFile,
|
|
141
|
+
findAppDidFinishLaunchingWithOptionsInDirectory,
|
|
132
142
|
findAppDidFinishLaunchingWithOptions,
|
|
133
143
|
};
|
|
134
144
|
}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAEpE,SAAS,iBAAiB,CAAC,QAAgB;IACzC,IAAA,aAAK,EAAC,cAAc,GAAG,QAAQ,GAAG,yBAAyB,CAAC,CAAC;IAC7D,MAAM,cAAc,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC9D,CAAC,CAAC,mBAAmB;QACrB,CAAC,CAAC,kBAAkB,CAAC;IAEvB,MAAM,WAAW,G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,cAAc;gBACZ,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;oBACpC,IAAI;oBACJ,eAAe;oBACf,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;SACrC;aAAM;YACL,cAAc,GAAG,eAAe,GAAG,cAAc,CAAC;SACnD;KACF;IAED,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAEtD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,8CAA8C,GAAG,WAAW,CAAC,CAAC;IAC7E,OAAO,IAAI,CAAC;AACd,CAAC;AAlED,0DAkEC;AAUD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;IACnC,wBAAgB,GAAG;QACjB,iBAAiB;QACjB,+CAA+C;QAC/C,oCAAoC;KACrC,CAAC;CACH","sourcesContent":["import * as 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;\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(files: string[], dsn: string): 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)\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 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"]}
|
|
@@ -35,14 +35,16 @@ const telemetry_1 = require("../telemetry");
|
|
|
35
35
|
const debug_1 = require("../utils/debug");
|
|
36
36
|
const codeTools = __importStar(require("./code-tools"));
|
|
37
37
|
function injectCodeSnippet({ project, target, dsn, }) {
|
|
38
|
-
(0, debug_1.debug)(`Injecting code snippet into project at path: ${chalk_1.default.cyan(project.
|
|
38
|
+
(0, debug_1.debug)(`Injecting code snippet into project at path: ${chalk_1.default.cyan(project.baseDir)}`);
|
|
39
39
|
const codeAdded = (0, telemetry_1.traceStep)('Add code snippet', () => {
|
|
40
|
-
const files = project.
|
|
40
|
+
const files = project.getSourceFilesForTarget(target);
|
|
41
41
|
if (files === undefined || files.length == 0) {
|
|
42
|
+
(0, debug_1.debug)('No files found for target: ' + target);
|
|
42
43
|
Sentry.setTag('snippet-candidate-files-not-found', true);
|
|
43
44
|
return false;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
(0, debug_1.debug)(`Adding code snippet to ${files.length} candidate files`);
|
|
47
|
+
return codeTools.addCodeSnippetToProject(files, dsn);
|
|
46
48
|
});
|
|
47
49
|
Sentry.setTag('Snippet-Added', codeAdded);
|
|
48
50
|
(0, debug_1.debug)(`Snippet added: ${chalk_1.default.cyan(codeAdded.toString())}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-code-snippet.js","sourceRoot":"","sources":["../../../src/apple/inject-code-snippet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAC1B,4CAAyC;AACzC,0CAAuC;AACvC,wDAA0C;AAG1C,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,GAAG,GAKJ;IACC,IAAA,aAAK,EACH,gDAAgD,eAAK,CAAC,IAAI,CACxD,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"inject-code-snippet.js","sourceRoot":"","sources":["../../../src/apple/inject-code-snippet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAC1B,4CAAyC;AACzC,0CAAuC;AACvC,wDAA0C;AAG1C,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,GAAG,GAKJ;IACC,IAAA,aAAK,EACH,gDAAgD,eAAK,CAAC,IAAI,CACxD,OAAO,CAAC,OAAO,CAChB,EAAE,CACJ,CAAC;IACF,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,kBAAkB,EAAE,GAAG,EAAE;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;YAC5C,IAAA,aAAK,EAAC,6BAA6B,GAAG,MAAM,CAAC,CAAC;YAC9C,MAAM,CAAC,MAAM,CAAC,mCAAmC,EAAE,IAAI,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC;SACd;QAED,IAAA,aAAK,EAAC,0BAA0B,KAAK,CAAC,MAAM,kBAAkB,CAAC,CAAC;QAChE,OAAO,SAAS,CAAC,uBAAuB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAA,aAAK,EAAC,kBAAkB,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAE5D,IAAI,CAAC,SAAS,EAAE;QACd,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,iNAAiN,CAClN,CAAC;KACH;AACH,CAAC;AAjCD,8CAiCC","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';\nimport { traceStep } from '../telemetry';\nimport { debug } from '../utils/debug';\nimport * as codeTools from './code-tools';\nimport { XcodeProject } from './xcode-manager';\n\nexport function injectCodeSnippet({\n project,\n target,\n dsn,\n}: {\n project: XcodeProject;\n target: string;\n dsn: string;\n}) {\n debug(\n `Injecting code snippet into project at path: ${chalk.cyan(\n project.baseDir,\n )}`,\n );\n const codeAdded = traceStep('Add code snippet', () => {\n const files = project.getSourceFilesForTarget(target);\n if (files === undefined || files.length == 0) {\n debug('No files found for target: ' + target);\n Sentry.setTag('snippet-candidate-files-not-found', true);\n return false;\n }\n\n debug(`Adding code snippet to ${files.length} candidate files`);\n return codeTools.addCodeSnippetToProject(files, dsn);\n });\n Sentry.setTag('Snippet-Added', codeAdded);\n debug(`Snippet added: ${chalk.cyan(codeAdded.toString())}`);\n\n if (!codeAdded) {\n clack.log.warn(\n 'Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snippet manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MacOSSystemHelpers = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const debug_1 = require("../utils/debug");
|
|
6
|
+
class MacOSSystemHelpers {
|
|
7
|
+
static findSDKRootDirectoryPath() {
|
|
8
|
+
try {
|
|
9
|
+
// Some Candidates:
|
|
10
|
+
// - /Applications/Xcode-16.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
|
|
11
|
+
// - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
|
|
12
|
+
const sdkPath = (0, child_process_1.execSync)('xcrun --show-sdk-path', {
|
|
13
|
+
encoding: 'utf8',
|
|
14
|
+
}).trim();
|
|
15
|
+
return sdkPath;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
(0, debug_1.debug)(`Failed to find SDK root directory path: ${error}`);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
static findDeveloperDirectoryPath() {
|
|
23
|
+
try {
|
|
24
|
+
// Some Candidates:
|
|
25
|
+
// - /Applications/Xcode.app/Contents/Developer
|
|
26
|
+
// - /Applications/Xcode-16.3.0.app/Contents/Developer
|
|
27
|
+
const developerPath = (0, child_process_1.execSync)('xcode-select --print-path', {
|
|
28
|
+
encoding: 'utf8',
|
|
29
|
+
}).trim();
|
|
30
|
+
return developerPath;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
(0, debug_1.debug)(`Failed to find developer directory path: ${error}`);
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
static readXcodeBuildSettings(projectPath) {
|
|
38
|
+
try {
|
|
39
|
+
// The child_process.execSync() method is generally identical to exec with the exception that the method will not return until the child process has fully closed.
|
|
40
|
+
// When a timeout has been encountered and killSignal is sent, the method won't return until the process has completely exited.
|
|
41
|
+
// If the child process intercepts and handles the SIGTERMsignal and doesn't exit, the parent process will wait until the child process has exited.
|
|
42
|
+
//
|
|
43
|
+
// If the process times out or has a non-zero exit code, this method will throw.
|
|
44
|
+
// The Error object will contain the entire result from spawnSync.
|
|
45
|
+
//
|
|
46
|
+
// IMPORTANT:
|
|
47
|
+
// Never pass unsanitized user input to this function.
|
|
48
|
+
// Any input containing shell metacharacters may be used to trigger arbitrary command execution.
|
|
49
|
+
const output = (0, child_process_1.execSync)([
|
|
50
|
+
`xcodebuild`,
|
|
51
|
+
`-project`,
|
|
52
|
+
projectPath.replace(/\\/g, '\\\\').replace(/"/g, '\\"'),
|
|
53
|
+
`-showBuildSettings`,
|
|
54
|
+
]
|
|
55
|
+
.map((arg) => `"${arg.trim()}"`)
|
|
56
|
+
.join(' '), {
|
|
57
|
+
encoding: 'utf8',
|
|
58
|
+
}).trim();
|
|
59
|
+
// --- Example Output: ---
|
|
60
|
+
// Command line invocation:
|
|
61
|
+
// /Applications/Xcode-16.3.0.app/Contents/Developer/usr/bin/xcodebuild -project ./fixtures/test-applications/apple/project-with-synchronized-folders/Project.xcodeproj -showBuildSettings
|
|
62
|
+
//
|
|
63
|
+
// Build settings for action build and target Project:
|
|
64
|
+
// ACTION = build
|
|
65
|
+
// ALLOW_BUILD_REQUEST_OVERRIDES = NO
|
|
66
|
+
// ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES
|
|
67
|
+
// ALTERNATE_GROUP = staff
|
|
68
|
+
// ...
|
|
69
|
+
const lines = output.split('\n');
|
|
70
|
+
const settings = {};
|
|
71
|
+
lines.forEach((line) => {
|
|
72
|
+
const match = line.match(/^\s*(\w+)\s+=\s+(.*)$/);
|
|
73
|
+
if (match) {
|
|
74
|
+
settings[match[1]] = match[2];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return settings;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
(0, debug_1.debug)(`Failed to read Xcode build settings: ${error}`);
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.MacOSSystemHelpers = MacOSSystemHelpers;
|
|
86
|
+
//# sourceMappingURL=macos-system-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macos-system-helper.js","sourceRoot":"","sources":["../../../src/apple/macos-system-helper.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AACzC,0CAAuC;AAEvC,MAAa,kBAAkB;IAC7B,MAAM,CAAC,wBAAwB;QAC7B,IAAI;YACF,mBAAmB;YACnB,0GAA0G;YAC1G,wDAAwD;YACxD,MAAM,OAAO,GAAG,IAAA,wBAAQ,EAAC,uBAAuB,EAAE;gBAChD,QAAQ,EAAE,MAAM;aACjB,CAAC,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,OAAO,CAAC;SAChB;QAAC,OAAO,KAAK,EAA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MAAM,QAAQ,GAA2B,EAAE,CAAC;YAC5C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;gBAClD,IAAI,KAAK,EAAE;oBACT,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;iBAC/B;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;SACjB;QAAC,OAAO,KAAK,EAAE;YACd,IAAA,aAAK,EAAC,wCAAwC,KAAe,EAAE,CAAC,CAAC;YACjE,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF;AAnFD,gDAmFC","sourcesContent":["import { execSync } from 'child_process';\nimport { debug } from '../utils/debug';\n\nexport class MacOSSystemHelpers {\n static findSDKRootDirectoryPath(): string | undefined {\n try {\n // Some Candidates:\n // - /Applications/Xcode-16.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk\n // - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk\n const sdkPath = execSync('xcrun --show-sdk-path', {\n encoding: 'utf8',\n }).trim();\n return sdkPath;\n } catch (error) {\n debug(`Failed to find SDK root directory path: ${error as string}`);\n return undefined;\n }\n }\n\n static findDeveloperDirectoryPath(): string | undefined {\n try {\n // Some Candidates:\n // - /Applications/Xcode.app/Contents/Developer\n // - /Applications/Xcode-16.3.0.app/Contents/Developer\n const developerPath = execSync('xcode-select --print-path', {\n encoding: 'utf8',\n }).trim();\n return developerPath;\n } catch (error) {\n debug(`Failed to find developer directory path: ${error as string}`);\n return undefined;\n }\n }\n\n static readXcodeBuildSettings(\n projectPath: string,\n ): Record<string, string> | undefined {\n try {\n // The child_process.execSync() method is generally identical to exec with the exception that the method will not return until the child process has fully closed.\n // When a timeout has been encountered and killSignal is sent, the method won't return until the process has completely exited.\n // If the child process intercepts and handles the SIGTERMsignal and doesn't exit, the parent process will wait until the child process has exited.\n //\n // If the process times out or has a non-zero exit code, this method will throw.\n // The Error object will contain the entire result from spawnSync.\n //\n // IMPORTANT:\n // Never pass unsanitized user input to this function.\n // Any input containing shell metacharacters may be used to trigger arbitrary command execution.\n const output = execSync(\n [\n `xcodebuild`,\n `-project`,\n projectPath.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"'),\n `-showBuildSettings`,\n ]\n .map((arg) => `\"${arg.trim()}\"`)\n .join(' '),\n {\n encoding: 'utf8',\n },\n ).trim();\n // --- Example Output: ---\n // Command line invocation:\n // /Applications/Xcode-16.3.0.app/Contents/Developer/usr/bin/xcodebuild -project ./fixtures/test-applications/apple/project-with-synchronized-folders/Project.xcodeproj -showBuildSettings\n //\n // Build settings for action build and target Project:\n // ACTION = build\n // ALLOW_BUILD_REQUEST_OVERRIDES = NO\n // ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES\n // ALTERNATE_GROUP = staff\n // ...\n const lines = output.split('\\n');\n const settings: Record<string, string> = {};\n lines.forEach((line) => {\n const match = line.match(/^\\s*(\\w+)\\s+=\\s+(.*)$/);\n if (match) {\n settings[match[1]] = match[2];\n }\n });\n\n return settings;\n } catch (error) {\n debug(`Failed to read Xcode build settings: ${error as string}`);\n return undefined;\n }\n }\n}\n"]}
|
|
@@ -14,6 +14,11 @@ function getSwiftSnippet(dsn) {
|
|
|
14
14
|
return ` SentrySDK.start { options in
|
|
15
15
|
options.dsn = "${dsn}"
|
|
16
16
|
options.debug = true // Enabled debug when first installing is always helpful
|
|
17
|
+
|
|
18
|
+
// Adds IP for users.
|
|
19
|
+
// For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/
|
|
20
|
+
options.sendDefaultPii = true
|
|
21
|
+
|
|
17
22
|
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
|
|
18
23
|
// We recommend adjusting this value in production.
|
|
19
24
|
options.tracesSampleRate = 1.0
|
|
@@ -36,6 +41,11 @@ function getObjcSnippet(dsn) {
|
|
|
36
41
|
return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {
|
|
37
42
|
options.dsn = @"${dsn}";
|
|
38
43
|
options.debug = YES; // Enabled debug when first installing is always helpful
|
|
44
|
+
|
|
45
|
+
// Adds IP for users.
|
|
46
|
+
// For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/
|
|
47
|
+
options.sendDefaultPii = YES;
|
|
48
|
+
|
|
39
49
|
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
|
|
40
50
|
// We recommend adjusting this value in production.
|
|
41
51
|
options.tracesSampleRate = @1.0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC,uFAAuF;QACzF,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe,+DAA+D,OAAO,4BAA4B,WAAW,4CAC3N,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC,2OAA2O,CAAC;AAC9O,CAAC;AAbD,oDAaC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO;6BACoB,GAAG
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC,uFAAuF;QACzF,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe,+DAA+D,OAAO,4BAA4B,WAAW,4CAC3N,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC,2OAA2O,CAAC;AAC9O,CAAC;AAbD,oDAaC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO;6BACoB,GAAG;;;;;;;;;;;;;;;;;;;;;;iEAsBiC,CAAC;AAClE,CAAC;AAzBD,0CAyBC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO;0BACiB,GAAG;;;;;;;;;;;;;;;;;;;;;;2DAsB8B,CAAC;AAC5D,CAAC;AAzBD,wCAyBC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? '\\\\nif [[ \"$(uname -m)\" == arm64 ]]; then\\\\nexport PATH=\"/opt/homebrew/bin:$PATH\"\\\\nfi'\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\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\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\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\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\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(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import type { SentryProjectData } from '../utils/types';
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
key: string;
|
|
5
|
-
path: string;
|
|
6
|
-
}
|
|
2
|
+
import { PBXSourcesBuildPhase, type PBXNativeTarget, type PBXObjects, type Project } from 'xcode';
|
|
3
|
+
import { XcodeProjectObjectWithId } from './xcode-project-object-with-id';
|
|
7
4
|
export declare class XcodeProject {
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The directory where the Xcode project is located.
|
|
7
|
+
*/
|
|
8
|
+
baseDir: string;
|
|
9
|
+
/**
|
|
10
|
+
* The path to the `<PROJECT>.xcodeproj` directory.
|
|
11
|
+
*/
|
|
12
|
+
xcodeprojPath: string;
|
|
13
|
+
/**
|
|
14
|
+
* The path to the `project.pbxproj` file.
|
|
15
|
+
*/
|
|
16
|
+
pbxprojPath: string;
|
|
17
|
+
/**
|
|
18
|
+
* The Xcode project object.
|
|
19
|
+
*/
|
|
9
20
|
project: Project;
|
|
10
21
|
objects: PBXObjects;
|
|
11
|
-
files: ProjectFile[] | undefined;
|
|
12
22
|
/**
|
|
13
23
|
* Creates a new XcodeProject instance, a wrapper around the Xcode project file `<PROJECT>.xcodeproj/project.pbxproj`.
|
|
14
24
|
*
|
|
@@ -17,8 +27,224 @@ export declare class XcodeProject {
|
|
|
17
27
|
constructor(projectPath: string);
|
|
18
28
|
getAllTargets(): string[];
|
|
19
29
|
updateXcodeProject(sentryProject: SentryProjectData, target: string, addSPMReference: boolean, uploadSource?: boolean): void;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves all source files associated with a specific target in the Xcode project.
|
|
32
|
+
* This is used to find files where we can inject Sentry initialization code.
|
|
33
|
+
*
|
|
34
|
+
* @param targetName - The name of the target to get files for
|
|
35
|
+
* @returns An array of absolute file paths for the target's source files, or undefined if target not found
|
|
36
|
+
*/
|
|
37
|
+
getSourceFilesForTarget(targetName: string): string[] | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Finds a native target by name.
|
|
40
|
+
*
|
|
41
|
+
* @param targetName - The name of the target to find
|
|
42
|
+
* @returns The native target, or undefined if the target is not found
|
|
43
|
+
*/
|
|
44
|
+
private findNativeTargetByName;
|
|
45
|
+
/**
|
|
46
|
+
* Finds the source build phase in a target.
|
|
47
|
+
*
|
|
48
|
+
* @param target - The target to find the source build phase in
|
|
49
|
+
* @returns The source build phase, or undefined if the target is not found or has no source build phase
|
|
50
|
+
*/
|
|
51
|
+
findSourceBuildPhaseInTarget(target: PBXNativeTarget): XcodeProjectObjectWithId<PBXSourcesBuildPhase> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Finds all files in the source build phase of a target.
|
|
54
|
+
*
|
|
55
|
+
* @param nativeTarget - The target to find the files in
|
|
56
|
+
* @returns The files in the source build phase of the target, or an empty array if the target is not found or has no source build phase
|
|
57
|
+
*/
|
|
58
|
+
findFilesInSourceBuildPhase(nativeTarget: XcodeProjectObjectWithId<PBXNativeTarget>): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Resolves the absolute path of a file reference.
|
|
61
|
+
*
|
|
62
|
+
* @param fileRef - The file reference to resolve the path of
|
|
63
|
+
* @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
|
|
64
|
+
*/
|
|
65
|
+
private resolveAbsolutePathOfFileReference;
|
|
66
|
+
/**
|
|
67
|
+
* Resolves the absolute path of a file reference relative to the parent group.
|
|
68
|
+
*
|
|
69
|
+
* @param fileRef - The file reference to resolve the path of
|
|
70
|
+
* @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
|
|
71
|
+
*/
|
|
72
|
+
private resolveAbsoluteFilePathRelativeToGroup;
|
|
73
|
+
/**
|
|
74
|
+
* Resolves the absolute path of a file reference relative to the built products directory.
|
|
75
|
+
*
|
|
76
|
+
* @param buildFile - The file reference to resolve the path of
|
|
77
|
+
* @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
|
|
78
|
+
*/
|
|
79
|
+
private resolveAbsoluteFilePathRelativeToBuiltProductsDir;
|
|
80
|
+
/**
|
|
81
|
+
* Resolves the absolute path of a file reference relative to the source root.
|
|
82
|
+
*
|
|
83
|
+
* The source root is the directory where the `.xcodeproj` file is located.
|
|
84
|
+
*
|
|
85
|
+
* @param buildFile - The file reference to resolve the path of
|
|
86
|
+
* @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
|
|
87
|
+
*/
|
|
88
|
+
private resolveAbsoluteFilePathRelativeToSourceRoot;
|
|
89
|
+
/**
|
|
90
|
+
* Resolves the absolute path of a file reference relative to the SDK root.
|
|
91
|
+
*
|
|
92
|
+
* @param buildFile - The file reference to resolve the path of
|
|
93
|
+
* @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
|
|
94
|
+
*/
|
|
95
|
+
private resolveAbsoluteFilePathRelativeToSdkRoot;
|
|
96
|
+
/**
|
|
97
|
+
* Resolves the absolute path of a file reference relative to the developer directory.
|
|
98
|
+
*
|
|
99
|
+
* @param buildFile - The file reference to resolve the path of
|
|
100
|
+
* @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
|
|
101
|
+
*/
|
|
102
|
+
private resolveAbsoluteFilePathRelativeToDeveloperDir;
|
|
103
|
+
/**
|
|
104
|
+
* Resolves the absolute path of a group.
|
|
105
|
+
*
|
|
106
|
+
* @param group - The group to resolve the path of
|
|
107
|
+
* @returns The absolute path of the group, or undefined if the group is not found or has no path
|
|
108
|
+
*/
|
|
109
|
+
private resolveAbsolutePathOfGroup;
|
|
110
|
+
/**
|
|
111
|
+
* Resolves the path of a group relative to the parent group.
|
|
112
|
+
*
|
|
113
|
+
* @param group - The group to resolve the path of
|
|
114
|
+
* @returns The path of the group relative to the parent group, or undefined if the group is not found or has no path
|
|
115
|
+
*/
|
|
116
|
+
private resolvePathOfGroupRelativeToGroup;
|
|
117
|
+
/**
|
|
118
|
+
* Resolves the path of a group relative to the source root.
|
|
119
|
+
*
|
|
120
|
+
* The source root is the directory where the `.xcodeproj` file is located.
|
|
121
|
+
*
|
|
122
|
+
* @param group - The group to resolve the path of
|
|
123
|
+
* @returns The path of the group relative to the source root, or undefined if the group is not found or has no path
|
|
124
|
+
*/
|
|
125
|
+
private resolvePathOfGroupRelativeToSourceRoot;
|
|
126
|
+
/**
|
|
127
|
+
* Resolves the path of a group relative to the built products directory.
|
|
128
|
+
*
|
|
129
|
+
* @param group - The group to resolve the path of
|
|
130
|
+
* @returns The path of the group relative to the built products directory, or undefined if the group is not found or has no path
|
|
131
|
+
*/
|
|
132
|
+
private resolvePathOfGroupRelativeToBuiltProductsDir;
|
|
133
|
+
/**
|
|
134
|
+
* Resolves the path of a group relative to the SDK root.
|
|
135
|
+
*
|
|
136
|
+
* The SDK root is the directory where the SDK is installed.
|
|
137
|
+
*
|
|
138
|
+
* @param group - The group to resolve the path of
|
|
139
|
+
* @returns The path of the group relative to the SDK root, or undefined if the group is not found or has no path
|
|
140
|
+
*/
|
|
141
|
+
private resolvePathOfGroupRelativeToSdkRoot;
|
|
142
|
+
/**
|
|
143
|
+
* Resolves the path of a group relative to the developer directory.
|
|
144
|
+
*
|
|
145
|
+
* The developer directory is the directory where the Xcode command line tools are installed.
|
|
146
|
+
*
|
|
147
|
+
* @param group - The group to resolve the path of
|
|
148
|
+
* @returns The path of the group relative to the developer directory, or undefined if the group is not found or has no path
|
|
149
|
+
*/
|
|
150
|
+
private resolvePathOfGroupRelativeToDeveloperDir;
|
|
151
|
+
/**
|
|
152
|
+
* Resolves the absolute path of a group.
|
|
153
|
+
*
|
|
154
|
+
* @param group - The group to resolve the path of
|
|
155
|
+
* @returns The absolute path of the group, or undefined if the group is not found or has no path
|
|
156
|
+
*/
|
|
157
|
+
private resolveAbsolutePathOfSynchronizedRootGroup;
|
|
158
|
+
/**
|
|
159
|
+
* Resolves the path of a group relative to the parent group.
|
|
160
|
+
*
|
|
161
|
+
* @param group - The group to resolve the path of
|
|
162
|
+
* @returns The path of the group relative to the parent group, or undefined if the group is not found or has no path
|
|
163
|
+
*/
|
|
164
|
+
private resolvePathOfSynchronizedRootGroupRelativeToGroup;
|
|
165
|
+
/**
|
|
166
|
+
* Resolves the path of a group relative to the source root.
|
|
167
|
+
*
|
|
168
|
+
* The source root is the directory where the `.xcodeproj` file is located.
|
|
169
|
+
*
|
|
170
|
+
* @param group - The group to resolve the path of
|
|
171
|
+
* @returns The path of the group relative to the source root, or undefined if the group is not found or has no path
|
|
172
|
+
*/
|
|
173
|
+
private resolvePathOfSynchronizedRootGroupRelativeToSourceRoot;
|
|
174
|
+
/**
|
|
175
|
+
* Resolves the path of a group relative to the built products directory.
|
|
176
|
+
*
|
|
177
|
+
* @param group - The group to resolve the path of
|
|
178
|
+
* @returns The path of the group relative to the built products directory, or undefined if the group is not found or has no path
|
|
179
|
+
*/
|
|
180
|
+
private resolvePathOfSynchronizedRootGroupRelativeToBuiltProductsDir;
|
|
181
|
+
/**
|
|
182
|
+
* Resolves the path of a group relative to the SDK root.
|
|
183
|
+
*
|
|
184
|
+
* The SDK root is the directory where the SDK is installed.
|
|
185
|
+
*
|
|
186
|
+
* @param group - The group to resolve the path of
|
|
187
|
+
* @returns The path of the group relative to the SDK root, or undefined if the group is not found or has no path
|
|
188
|
+
*/
|
|
189
|
+
private resolvePathOfSynchronizedRootGroupRelativeToSdkRoot;
|
|
190
|
+
/**
|
|
191
|
+
* Resolves the path of a group relative to the developer directory.
|
|
192
|
+
*
|
|
193
|
+
* The developer directory is the directory where the Xcode command line tools are installed.
|
|
194
|
+
*
|
|
195
|
+
* @param group - The group to resolve the path of
|
|
196
|
+
* @returns The path of the group relative to the developer directory, or undefined if the group is not found or has no path
|
|
197
|
+
*/
|
|
198
|
+
private resolvePathOfSynchronizedRootGroupRelativeToDeveloperDir;
|
|
199
|
+
/**
|
|
200
|
+
* Finds all files in the synchronized root groups of a target.
|
|
201
|
+
*
|
|
202
|
+
* @param nativeTarget - The target to find the files in
|
|
203
|
+
* @returns The files in the synchronized root groups of the target, or an empty array if the target is not found or has no synchronized root groups
|
|
204
|
+
*/
|
|
205
|
+
findFilesInSynchronizedRootGroups(nativeTarget: XcodeProjectObjectWithId<PBXNativeTarget>): string[];
|
|
206
|
+
private getFilesInSynchronizedRootGroup;
|
|
207
|
+
/**
|
|
208
|
+
* Returns all files in a directory tree.
|
|
209
|
+
*
|
|
210
|
+
* @param dirPath - The path of the directory to get the files in
|
|
211
|
+
* @returns All files in the directory tree, or an empty array if the directory does not exist
|
|
212
|
+
*/
|
|
213
|
+
private getAbsoluteFilePathsInDirectoryTree;
|
|
214
|
+
private filterFilesByExceptionSets;
|
|
215
|
+
/**
|
|
216
|
+
* Returns all groups that are PBXGroup.
|
|
217
|
+
*
|
|
218
|
+
* This is a helper method to avoid having to map and filter the groups manually.
|
|
219
|
+
*
|
|
220
|
+
* @returns All groups that are PBXGroup, excluding comments and non-object values.
|
|
221
|
+
*/
|
|
222
|
+
private get groups();
|
|
223
|
+
/**
|
|
224
|
+
* Finds the parent group of a child group or file reference.
|
|
225
|
+
*
|
|
226
|
+
* @param childId - The ID of the child group or file reference
|
|
227
|
+
* @returns The parent group of the child group or file reference, or undefined if the child group or file reference is not found or has no parent group
|
|
228
|
+
*/
|
|
229
|
+
private findParentGroupByChildId;
|
|
230
|
+
/**
|
|
231
|
+
* Checks if a group is the main group of any project.
|
|
232
|
+
*
|
|
233
|
+
* @param groupId - The ID of the group to check
|
|
234
|
+
* @returns True if the group is the main group, false otherwise
|
|
235
|
+
*/
|
|
236
|
+
private isMainGroup;
|
|
237
|
+
private getExceptionSetsForGroup;
|
|
238
|
+
/**
|
|
239
|
+
* The path to the build products directory for the project.
|
|
240
|
+
*
|
|
241
|
+
* This is cached to avoid having to read the build settings from Xcode for each call to `getBuildProductsDirectoryPath`.
|
|
242
|
+
*/
|
|
243
|
+
private buildProductsDir;
|
|
244
|
+
/**
|
|
245
|
+
* Returns the path to the build products directory for the project.
|
|
246
|
+
*
|
|
247
|
+
* @returns The path to the build products directory for the project, or undefined if the path is not found
|
|
248
|
+
*/
|
|
249
|
+
private getBuildProductsDirectoryPath;
|
|
23
250
|
}
|
|
24
|
-
export {};
|