@sentry/wizard 3.9.2 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -6
- package/dist/lib/Constants.d.ts +2 -0
- package/dist/lib/Constants.js +10 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +15 -4
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Android.d.ts +9 -0
- package/dist/lib/Steps/Integrations/Android.js +86 -0
- package/dist/lib/Steps/Integrations/Android.js.map +1 -0
- package/dist/lib/Steps/Integrations/Cordova.js +5 -1
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/ReactNative.js +3 -3
- package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
- package/dist/lib/Steps/Integrations/Remix.d.ts +12 -0
- package/dist/lib/Steps/Integrations/Remix.js +98 -0
- package/dist/lib/Steps/Integrations/Remix.js.map +1 -0
- package/dist/lib/Steps/PromptForParameters.js +36 -3
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/package.json +4 -3
- package/dist/src/android/android-wizard.d.ts +2 -0
- package/dist/src/android/android-wizard.js +217 -0
- package/dist/src/android/android-wizard.js.map +1 -0
- package/dist/src/android/code-tools.d.ts +39 -0
- package/dist/src/android/code-tools.js +161 -0
- package/dist/src/android/code-tools.js.map +1 -0
- package/dist/src/android/gradle.d.ts +62 -0
- package/dist/src/android/gradle.js +281 -0
- package/dist/src/android/gradle.js.map +1 -0
- package/dist/src/android/manifest.d.ts +57 -0
- package/dist/src/android/manifest.js +183 -0
- package/dist/src/android/manifest.js.map +1 -0
- package/dist/src/android/templates.d.ts +11 -0
- package/dist/src/android/templates.js +34 -0
- package/dist/src/android/templates.js.map +1 -0
- package/dist/src/apple/apple-wizard.js +123 -64
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/cocoapod.js +4 -3
- package/dist/src/apple/cocoapod.js.map +1 -1
- package/dist/src/apple/code-tools.d.ts +1 -1
- package/dist/src/apple/code-tools.js +43 -19
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/fastlane.d.ts +1 -1
- package/dist/src/apple/fastlane.js +12 -6
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/templates.d.ts +2 -2
- package/dist/src/apple/templates.js +4 -4
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +19 -3
- package/dist/src/apple/xcode-manager.js +126 -24
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +49 -11
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +2 -0
- package/dist/src/nextjs/templates.js +6 -2
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/remix/codemods/handle-error.d.ts +2 -0
- package/dist/src/remix/codemods/handle-error.js +70 -0
- package/dist/src/remix/codemods/handle-error.js.map +1 -0
- package/dist/src/remix/codemods/root-v1.d.ts +1 -0
- package/dist/src/remix/codemods/root-v1.js +133 -0
- package/dist/src/remix/codemods/root-v1.js.map +1 -0
- package/dist/src/remix/codemods/root-v2.d.ts +1 -0
- package/dist/src/remix/codemods/root-v2.js +134 -0
- package/dist/src/remix/codemods/root-v2.js.map +1 -0
- package/dist/src/remix/remix-wizard.d.ts +2 -0
- package/dist/src/remix/remix-wizard.js +196 -0
- package/dist/src/remix/remix-wizard.js.map +1 -0
- package/dist/src/remix/sdk-setup.d.ts +18 -0
- package/dist/src/remix/sdk-setup.js +293 -0
- package/dist/src/remix/sdk-setup.js.map +1 -0
- package/dist/src/remix/templates.d.ts +2 -0
- package/dist/src/remix/templates.js +6 -0
- package/dist/src/remix/templates.js.map +1 -0
- package/dist/src/remix/utils.d.ts +6 -0
- package/dist/src/remix/utils.js +55 -0
- package/dist/src/remix/utils.js.map +1 -0
- package/dist/src/sourcemaps/sourcemaps-wizard.js +49 -25
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.js +1 -1
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
- package/dist/src/sourcemaps/tools/remix.d.ts +3 -0
- package/dist/src/sourcemaps/tools/remix.js +125 -0
- package/dist/src/sourcemaps/tools/remix.js.map +1 -0
- package/dist/src/sourcemaps/tools/sentry-cli.js +19 -16
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.d.ts +2 -1
- package/dist/src/sourcemaps/tools/vite.js +99 -12
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.d.ts +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js +1 -0
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +3 -3
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +34 -44
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/telemetry.js +1 -0
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/ast-utils.d.ts +2 -2
- package/dist/src/utils/ast-utils.js +7 -7
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +23 -28
- package/dist/src/utils/clack-utils.js +287 -244
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +10 -0
- package/dist/{lib/Helper/PackageManager.js → src/utils/package-manager.js} +42 -74
- package/dist/src/utils/package-manager.js.map +1 -0
- package/dist/src/utils/release-registry.d.ts +1 -0
- package/dist/src/utils/release-registry.js +68 -0
- package/dist/src/utils/release-registry.js.map +1 -0
- package/dist/src/utils/sentrycli-utils.d.ts +4 -0
- package/dist/src/utils/sentrycli-utils.js +41 -0
- package/dist/src/utils/sentrycli-utils.js.map +1 -0
- package/dist/test/sourcemaps/tools/vite.test.d.ts +1 -0
- package/dist/test/sourcemaps/tools/vite.test.js +132 -0
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -0
- package/lib/Constants.ts +10 -0
- package/lib/Steps/ChooseIntegration.ts +14 -3
- package/lib/Steps/Integrations/Android.ts +23 -0
- package/lib/Steps/Integrations/Cordova.ts +5 -1
- package/lib/Steps/Integrations/ReactNative.ts +9 -3
- package/lib/Steps/Integrations/Remix.ts +32 -0
- package/lib/Steps/PromptForParameters.ts +48 -3
- package/lib/Steps/SentryProjectSelector.ts +3 -1
- package/package.json +4 -3
- package/src/android/android-wizard.ts +196 -0
- package/src/android/code-tools.ts +156 -0
- package/src/android/gradle.ts +245 -0
- package/src/android/manifest.ts +180 -0
- package/src/android/templates.ts +88 -0
- package/src/apple/apple-wizard.ts +113 -35
- package/src/apple/cocoapod.ts +6 -3
- package/src/apple/code-tools.ts +46 -18
- package/src/apple/fastlane.ts +6 -12
- package/src/apple/templates.ts +2 -8
- package/src/apple/xcode-manager.ts +167 -25
- package/src/nextjs/nextjs-wizard.ts +72 -8
- package/src/nextjs/templates.ts +16 -2
- package/src/remix/codemods/handle-error.ts +67 -0
- package/src/remix/codemods/root-v1.ts +91 -0
- package/src/remix/codemods/root-v2.ts +84 -0
- package/src/remix/remix-wizard.ts +132 -0
- package/src/remix/sdk-setup.ts +300 -0
- package/src/remix/templates.ts +15 -0
- package/src/remix/utils.ts +41 -0
- package/src/sourcemaps/sourcemaps-wizard.ts +28 -5
- package/src/sourcemaps/tools/nextjs.ts +2 -2
- package/src/sourcemaps/tools/remix.ts +90 -0
- package/src/sourcemaps/tools/sentry-cli.ts +8 -7
- package/src/sourcemaps/tools/vite.ts +136 -6
- package/src/sourcemaps/utils/detect-tool.ts +4 -1
- package/src/sveltekit/sdk-setup.ts +4 -4
- package/src/sveltekit/sveltekit-wizard.ts +5 -14
- package/src/telemetry.ts +2 -0
- package/src/utils/ast-utils.ts +7 -5
- package/src/utils/clack-utils.ts +366 -258
- package/src/utils/package-manager.ts +61 -0
- package/src/utils/release-registry.ts +19 -0
- package/src/utils/sentrycli-utils.ts +22 -0
- package/test/sourcemaps/tools/vite.test.ts +149 -0
- package/dist/lib/Helper/PackageManager.d.ts +0 -22
- package/dist/lib/Helper/PackageManager.js.map +0 -1
- package/dist/src/utils/vendor/clack-custom-select.d.ts +0 -21
- package/dist/src/utils/vendor/clack-custom-select.js +0 -137
- package/dist/src/utils/vendor/clack-custom-select.js.map +0 -1
- package/lib/Helper/PackageManager.ts +0 -59
- package/src/utils/vendor/clack-custom-select.ts +0 -160
|
@@ -72,9 +72,10 @@ exports.runAppleWizard = void 0;
|
|
|
72
72
|
var prompts_1 = __importDefault(require("@clack/prompts"));
|
|
73
73
|
var fs = __importStar(require("fs"));
|
|
74
74
|
var path = __importStar(require("path"));
|
|
75
|
-
var
|
|
75
|
+
var xcode_manager_1 = require("./xcode-manager");
|
|
76
76
|
var codeTools = __importStar(require("./code-tools"));
|
|
77
77
|
var bash = __importStar(require("../utils/bash"));
|
|
78
|
+
var SentryUtils = __importStar(require("../utils/sentrycli-utils"));
|
|
78
79
|
var Sentry = __importStar(require("@sentry/node"));
|
|
79
80
|
var telemetry_1 = require("../telemetry");
|
|
80
81
|
var cocoapod = __importStar(require("./cocoapod"));
|
|
@@ -95,129 +96,187 @@ function runAppleWizard(options) {
|
|
|
95
96
|
exports.runAppleWizard = runAppleWizard;
|
|
96
97
|
function runAppleWizardWithTelementry(options) {
|
|
97
98
|
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
-
var hasCli, projectDir, xcodeProjFiles, xcodeProjFile, pbxproj, _a, project, apiKey, hasCocoa,
|
|
99
|
-
return __generator(this, function (
|
|
100
|
-
switch (
|
|
99
|
+
var hasCli, projectDir, xcodeProjFiles, xcodeProjFile, pbxproj, _a, project, apiKey, xcProject, availableTargets, target, _b, hasCocoa, pm, podAdded, codeAdded, addLane, added;
|
|
100
|
+
return __generator(this, function (_c) {
|
|
101
|
+
switch (_c.label) {
|
|
101
102
|
case 0:
|
|
102
103
|
(0, clack_utils_1.printWelcome)({
|
|
103
104
|
wizardName: 'Sentry Apple Wizard',
|
|
104
105
|
promoCode: options.promoCode,
|
|
105
106
|
});
|
|
107
|
+
return [4 /*yield*/, (0, clack_utils_1.confirmContinueEvenThoughNoGitRepo)()];
|
|
108
|
+
case 1:
|
|
109
|
+
_c.sent();
|
|
106
110
|
hasCli = bash.hasSentryCLI();
|
|
107
111
|
Sentry.setTag('has-cli', hasCli);
|
|
108
|
-
if (!!hasCli) return [3 /*break*/,
|
|
112
|
+
if (!!hasCli) return [3 /*break*/, 5];
|
|
109
113
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('Ask for SentryCLI', function () { return (0, clack_utils_1.askToInstallSentryCLI)(); })];
|
|
110
|
-
case
|
|
111
|
-
if (!!(
|
|
114
|
+
case 2:
|
|
115
|
+
if (!!(_c.sent())) return [3 /*break*/, 3];
|
|
112
116
|
prompts_1.default.log.warn("Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/");
|
|
113
117
|
Sentry.setTag('CLI-Installed', false);
|
|
114
|
-
return [3 /*break*/,
|
|
115
|
-
case
|
|
116
|
-
case 3:
|
|
117
|
-
_b.sent();
|
|
118
|
-
Sentry.setTag('CLI-Installed', true);
|
|
119
|
-
_b.label = 4;
|
|
118
|
+
return [3 /*break*/, 5];
|
|
119
|
+
case 3: return [4 /*yield*/, bash.installSentryCLI()];
|
|
120
120
|
case 4:
|
|
121
|
+
_c.sent();
|
|
122
|
+
Sentry.setTag('CLI-Installed', true);
|
|
123
|
+
_c.label = 5;
|
|
124
|
+
case 5:
|
|
121
125
|
projectDir = process.cwd();
|
|
122
|
-
xcodeProjFiles =
|
|
123
|
-
if (!(!xcodeProjFiles || xcodeProjFiles.length === 0)) return [3 /*break*/,
|
|
126
|
+
xcodeProjFiles = searchXcodeProject(projectDir);
|
|
127
|
+
if (!(!xcodeProjFiles || xcodeProjFiles.length === 0)) return [3 /*break*/, 7];
|
|
124
128
|
prompts_1.default.log.error('No Xcode project found. Please run this command from the root of your project.');
|
|
125
129
|
return [4 /*yield*/, (0, clack_utils_1.abort)()];
|
|
126
|
-
case 5:
|
|
127
|
-
_b.sent();
|
|
128
|
-
return [2 /*return*/];
|
|
129
130
|
case 6:
|
|
130
|
-
|
|
131
|
+
_c.sent();
|
|
132
|
+
return [2 /*return*/];
|
|
133
|
+
case 7:
|
|
134
|
+
if (!(xcodeProjFiles.length === 1)) return [3 /*break*/, 8];
|
|
131
135
|
xcodeProjFile = xcodeProjFiles[0];
|
|
132
136
|
Sentry.setTag('multiple-projects', false);
|
|
133
|
-
return [3 /*break*/,
|
|
134
|
-
case
|
|
137
|
+
return [3 /*break*/, 10];
|
|
138
|
+
case 8:
|
|
135
139
|
Sentry.setTag('multiple-projects', true);
|
|
136
140
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('Choose Xcode project', function () {
|
|
137
141
|
return (0, clack_utils_1.askForItemSelection)(xcodeProjFiles, 'Which project do you want to add Sentry to?');
|
|
138
142
|
})];
|
|
139
|
-
case 8:
|
|
140
|
-
xcodeProjFile = (_b.sent()).value;
|
|
141
|
-
_b.label = 9;
|
|
142
143
|
case 9:
|
|
144
|
+
xcodeProjFile = (_c.sent()).value;
|
|
145
|
+
_c.label = 10;
|
|
146
|
+
case 10:
|
|
143
147
|
pbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');
|
|
144
|
-
if (!!fs.existsSync(pbxproj)) return [3 /*break*/,
|
|
145
|
-
prompts_1.default.log.error("No pbxproj found at ".concat(
|
|
148
|
+
if (!!fs.existsSync(pbxproj)) return [3 /*break*/, 12];
|
|
149
|
+
prompts_1.default.log.error("No pbxproj found at ".concat(xcodeProjFile));
|
|
146
150
|
return [4 /*yield*/, (0, clack_utils_1.abort)()];
|
|
147
|
-
case
|
|
148
|
-
|
|
151
|
+
case 11:
|
|
152
|
+
_c.sent();
|
|
149
153
|
return [2 /*return*/];
|
|
150
|
-
case
|
|
151
|
-
case
|
|
152
|
-
_a =
|
|
154
|
+
case 12: return [4 /*yield*/, getSentryProjectAndApiKey(options)];
|
|
155
|
+
case 13:
|
|
156
|
+
_a = _c.sent(), project = _a.project, apiKey = _a.apiKey;
|
|
157
|
+
xcProject = new xcode_manager_1.XcodeProject(pbxproj);
|
|
158
|
+
availableTargets = xcProject.getAllTargets();
|
|
159
|
+
if (!(availableTargets.length == 0)) return [3 /*break*/, 15];
|
|
160
|
+
prompts_1.default.log.error("No suttable target found in ".concat(xcodeProjFile));
|
|
161
|
+
return [4 /*yield*/, (0, clack_utils_1.abort)()];
|
|
162
|
+
case 14:
|
|
163
|
+
_c.sent();
|
|
164
|
+
return [2 /*return*/];
|
|
165
|
+
case 15:
|
|
166
|
+
if (!(availableTargets.length == 1)) return [3 /*break*/, 16];
|
|
167
|
+
_b = availableTargets[0];
|
|
168
|
+
return [3 /*break*/, 18];
|
|
169
|
+
case 16: return [4 /*yield*/, (0, telemetry_1.traceStep)('Choose target', function () {
|
|
170
|
+
return (0, clack_utils_1.askForItemSelection)(availableTargets, 'Which target do you want to add Sentry to?');
|
|
171
|
+
})];
|
|
172
|
+
case 17:
|
|
173
|
+
_b = (_c.sent()).value;
|
|
174
|
+
_c.label = 18;
|
|
175
|
+
case 18:
|
|
176
|
+
target = _b;
|
|
177
|
+
SentryUtils.createSentryCLIRC(projectDir, { auth_token: apiKey.token });
|
|
178
|
+
prompts_1.default.log.info('We created a ".sentryclirc" file in your project directory in order to provide an auth token for Sentry CLI.\nIt was also added to your ".gitignore" file.\nAt your CI enviroment, you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information.');
|
|
153
179
|
hasCocoa = cocoapod.usesCocoaPod(projectDir);
|
|
154
|
-
if (!hasCocoa) return [3 /*break*/,
|
|
180
|
+
if (!hasCocoa) return [3 /*break*/, 21];
|
|
181
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('Choose a package manager', function () {
|
|
182
|
+
return (0, clack_utils_1.askForItemSelection)(['Swift Package Manager', 'CocoaPods'], 'Which package manager would you like to use to add Sentry?');
|
|
183
|
+
})];
|
|
184
|
+
case 19:
|
|
185
|
+
pm = (_c.sent()).value;
|
|
186
|
+
hasCocoa = pm === 'CocoaPods';
|
|
187
|
+
if (!hasCocoa) return [3 /*break*/, 21];
|
|
155
188
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('Add CocoaPods reference', function () {
|
|
156
189
|
return cocoapod.addCocoaPods(projectDir);
|
|
157
190
|
})];
|
|
158
|
-
case
|
|
159
|
-
podAdded =
|
|
191
|
+
case 20:
|
|
192
|
+
podAdded = _c.sent();
|
|
160
193
|
if (!podAdded) {
|
|
161
194
|
prompts_1.default.log.warn("Could not add Sentry pod to your Podfile. You'll have to add it manually.\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install");
|
|
162
195
|
}
|
|
163
|
-
|
|
164
|
-
case
|
|
196
|
+
_c.label = 21;
|
|
197
|
+
case 21:
|
|
165
198
|
(0, telemetry_1.traceStep)('Update Xcode project', function () {
|
|
166
|
-
|
|
199
|
+
xcProject.updateXcodeProject(project, target, apiKey, !hasCocoa, true);
|
|
167
200
|
});
|
|
168
201
|
Sentry.setTag('package-manager', hasCocoa ? 'cocoapods' : 'SPM');
|
|
169
|
-
projSource = path.join(projectDir, xcodeProjFile.replace('.xcodeproj', ''));
|
|
170
202
|
codeAdded = (0, telemetry_1.traceStep)('Add code snippet', function () {
|
|
171
|
-
|
|
203
|
+
var files = xcProject.filesForTarget(target);
|
|
204
|
+
if (files === undefined || files.length == 0)
|
|
205
|
+
return false;
|
|
206
|
+
return codeTools.addCodeSnippetToProject(projectDir, files, project.keys[0].dsn.public);
|
|
172
207
|
});
|
|
173
208
|
if (!codeAdded) {
|
|
174
209
|
prompts_1.default.log.warn('Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snipped manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure');
|
|
175
210
|
return [2 /*return*/];
|
|
176
211
|
}
|
|
177
|
-
if (!fastlane.fastFile(projectDir)) return [3 /*break*/,
|
|
212
|
+
if (!fastlane.fastFile(projectDir)) return [3 /*break*/, 24];
|
|
178
213
|
return [4 /*yield*/, prompts_1.default.confirm({
|
|
179
214
|
message: 'Found a Fastfile in your project. Do you want to configure a lane to upload debug symbols to Sentry?',
|
|
180
215
|
})];
|
|
181
|
-
case
|
|
182
|
-
addLane =
|
|
183
|
-
if (!addLane) return [3 /*break*/,
|
|
216
|
+
case 22:
|
|
217
|
+
addLane = _c.sent();
|
|
218
|
+
if (!addLane) return [3 /*break*/, 24];
|
|
184
219
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('Configure fastlane', function () {
|
|
185
|
-
return fastlane.addSentryToFastlane(projectDir, project.organization.slug, project.slug
|
|
220
|
+
return fastlane.addSentryToFastlane(projectDir, project.organization.slug, project.slug);
|
|
186
221
|
})];
|
|
187
|
-
case
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
222
|
+
case 23:
|
|
223
|
+
added = _c.sent();
|
|
224
|
+
if (added) {
|
|
225
|
+
prompts_1.default.log.step('A new step was added to your fastlane file. Now and you build your project with fastlane, debug symbols and source context will be uploaded to Sentry.');
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
prompts_1.default.log.warn('Could not edit your fastlane file to upload debug symbols to Sentry. Please follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/dsym/#fastlane');
|
|
229
|
+
}
|
|
230
|
+
_c.label = 24;
|
|
231
|
+
case 24:
|
|
232
|
+
prompts_1.default.log.success('Sentry was successfully added to your project! Run your project to send your first event to Sentry. Go to Sentry.io to see whether everything is working fine.');
|
|
192
233
|
return [2 /*return*/];
|
|
193
234
|
}
|
|
194
235
|
});
|
|
195
236
|
});
|
|
196
237
|
}
|
|
197
238
|
//Prompt for Sentry project and API key
|
|
198
|
-
function getSentryProjectAndApiKey(
|
|
239
|
+
function getSentryProjectAndApiKey(options) {
|
|
199
240
|
return __awaiter(this, void 0, void 0, function () {
|
|
200
|
-
var
|
|
241
|
+
var _a, selectedProject, authToken;
|
|
201
242
|
return __generator(this, function (_b) {
|
|
202
243
|
switch (_b.label) {
|
|
203
|
-
case 0: return [4 /*yield*/, (0, clack_utils_1.
|
|
244
|
+
case 0: return [4 /*yield*/, (0, clack_utils_1.getOrAskForProjectData)(options)];
|
|
204
245
|
case 1:
|
|
205
|
-
|
|
206
|
-
return [
|
|
207
|
-
promoCode: promoCode,
|
|
208
|
-
url: sentryUrl,
|
|
209
|
-
platform: 'apple-ios',
|
|
210
|
-
})];
|
|
211
|
-
case 2:
|
|
212
|
-
_a = _b.sent(), projects = _a.projects, apiKeys = _a.apiKeys;
|
|
213
|
-
return [4 /*yield*/, (0, clack_utils_1.askForProjectSelection)(projects)];
|
|
214
|
-
case 3:
|
|
215
|
-
selectedProject = _b.sent();
|
|
216
|
-
return [2 /*return*/, { project: selectedProject, apiKey: apiKeys }];
|
|
246
|
+
_a = _b.sent(), selectedProject = _a.selectedProject, authToken = _a.authToken;
|
|
247
|
+
return [2 /*return*/, { project: selectedProject, apiKey: { token: authToken } }];
|
|
217
248
|
}
|
|
218
249
|
});
|
|
219
250
|
});
|
|
220
251
|
}
|
|
252
|
+
function searchXcodeProject(at) {
|
|
253
|
+
var projs = findFilesWithExtension(at, '.xcodeproj');
|
|
254
|
+
if (projs.length > 0) {
|
|
255
|
+
return projs;
|
|
256
|
+
}
|
|
257
|
+
var workspace = findFilesWithExtension(at, '.xcworkspace');
|
|
258
|
+
if (workspace.length == 0) {
|
|
259
|
+
return [];
|
|
260
|
+
}
|
|
261
|
+
var xsworkspacedata = path.join(at, workspace[0], 'contents.xcworkspacedata');
|
|
262
|
+
if (!fs.existsSync(xsworkspacedata)) {
|
|
263
|
+
return [];
|
|
264
|
+
}
|
|
265
|
+
var groupRegex = /location *= *"group:([^"]+)"/gim;
|
|
266
|
+
var content = fs.readFileSync(xsworkspacedata, 'utf8');
|
|
267
|
+
var matches = groupRegex.exec(content);
|
|
268
|
+
while (matches) {
|
|
269
|
+
var group = matches[1];
|
|
270
|
+
var groupPath = path.join(at, group);
|
|
271
|
+
if (!group.endsWith('Pods.xcodeproj') &&
|
|
272
|
+
group.endsWith('.xcodeproj') &&
|
|
273
|
+
fs.existsSync(groupPath)) {
|
|
274
|
+
projs.push(group);
|
|
275
|
+
}
|
|
276
|
+
matches = groupRegex.exec(content);
|
|
277
|
+
}
|
|
278
|
+
return projs;
|
|
279
|
+
}
|
|
221
280
|
//find files with the given extension
|
|
222
281
|
function findFilesWithExtension(dir, extension) {
|
|
223
282
|
var files = fs.readdirSync(dir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apple-wizard.js","sourceRoot":"","sources":["../../../src/apple/apple-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,sDAAsD;AACtD,yEAAyE;AACzE,2DAAmC;AACnC,qCAAyB;AACzB,yCAA6B;AAC7B,yDAA6C;AAC7C,sDAA0C;AAC1C,kDAAsC;AAEtC,mDAAuC;AACvC,0CAAwD;AACxD,mDAAuC;AACvC,mDAAuC;AAEvC,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,qDAAqD;AAErD,oDAQ8B;AAE9B,SAAsB,cAAc,CAAC,OAAsB;;;YACzD,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;oBACjC,WAAW,EAAE,KAAK;iBACnB,EACD,cAAM,OAAA,4BAA4B,CAAC,OA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,GAAK,CAAA,SAA2B,CAAA,IAAhC;oBAEQ,qBAAM,IAAA,+BAAiB,EAAC;4BACpD,SAAS,EAAE,SAAS;4BACpB,GAAG,EAAE,SAAS;4BACd,QAAQ,EAAE,WAAW;yBACtB,CAAC,EAAA;;oBAJI,KAAwB,SAI5B,EAJM,QAAQ,cAAA,EAAE,OAAO,aAAA;oBAMD,qBAAM,IAAA,oCAAsB,EAAC,QAAQ,CAAC,EAAA;;oBAAxD,eAAe,GAAG,SAAsC;oBAC9D,sBAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,EAAC;;;;CACtD;AAED,qCAAqC;AACrC,SAAS,sBAAsB,CAAC,GAAW,EAAE,SAAiB;IAC5D,IAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAxB,CAAwB,CAAC,CAAC;AAC1D,CAAC","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 */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as xcManager from './xcode-manager';\nimport * as codeTools from './code-tools';\nimport * as bash from '../utils/bash';\nimport { SentryProjectData, WizardOptions } from '../utils/types';\nimport * as Sentry from '@sentry/node';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport * as cocoapod from './cocoapod';\nimport * as fastlane from './fastlane';\n\nconst xcode = require('xcode');\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nimport {\n askForProjectSelection,\n askForSelfHosted,\n askForWizardLogin,\n askToInstallSentryCLI,\n printWelcome,\n abort,\n askForItemSelection,\n} from '../utils/clack-utils';\n\nexport async function runAppleWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'ios',\n },\n () => runAppleWizardWithTelementry(options),\n );\n}\n\nasync function runAppleWizardWithTelementry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Apple Wizard',\n promoCode: options.promoCode,\n });\n\n const hasCli = bash.hasSentryCLI();\n Sentry.setTag('has-cli', hasCli);\n if (!hasCli) {\n if (\n !(await traceStep('Ask for SentryCLI', () => askToInstallSentryCLI()))\n ) {\n clack.log.warn(\n \"Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/\",\n );\n Sentry.setTag('CLI-Installed', false);\n } else {\n await bash.installSentryCLI();\n Sentry.setTag('CLI-Installed', true);\n }\n }\n\n const projectDir = process.cwd();\n const xcodeProjFiles = findFilesWithExtension(projectDir, '.xcodeproj');\n\n if (!xcodeProjFiles || xcodeProjFiles.length === 0) {\n clack.log.error(\n 'No Xcode project found. Please run this command from the root of your project.',\n );\n await abort();\n return;\n }\n\n let xcodeProjFile;\n\n if (xcodeProjFiles.length === 1) {\n xcodeProjFile = xcodeProjFiles[0];\n Sentry.setTag('multiple-projects', false);\n } else {\n Sentry.setTag('multiple-projects', true);\n xcodeProjFile = (\n await traceStep('Choose Xcode project', () =>\n askForItemSelection(\n xcodeProjFiles,\n 'Which project do you want to add Sentry to?',\n ),\n )\n ).value;\n }\n\n const pbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');\n if (!fs.existsSync(pbxproj)) {\n clack.log.error(`No pbxproj found at ${pbxproj}`);\n await abort();\n return;\n }\n\n const { project, apiKey } = await getSentryProjectAndApiKey(\n options.promoCode,\n options.url,\n );\n\n const hasCocoa = cocoapod.usesCocoaPod(projectDir);\n\n if (hasCocoa) {\n const podAdded = await traceStep('Add CocoaPods reference', () =>\n cocoapod.addCocoaPods(projectDir),\n );\n if (!podAdded) {\n clack.log.warn(\n \"Could not add Sentry pod to your Podfile. You'll have to add it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install\",\n );\n }\n }\n\n traceStep('Update Xcode project', () => {\n xcManager.updateXcodeProject(pbxproj, project, apiKey, !hasCocoa, true);\n });\n\n Sentry.setTag('package-manager', hasCocoa ? 'cocoapods' : 'SPM');\n const projSource = path.join(\n projectDir,\n xcodeProjFile.replace('.xcodeproj', ''),\n );\n const codeAdded = traceStep('Add code snippet', () => {\n return codeTools.addCodeSnippetToProject(\n projSource,\n project.keys[0].dsn.public,\n );\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 snipped manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',\n );\n return;\n }\n\n if (fastlane.fastFile(projectDir)) {\n const addLane = await clack.confirm({\n message:\n 'Found a Fastfile in your project. Do you want to configure a lane to upload debug symbols to Sentry?',\n });\n if (addLane) {\n await traceStep('Configure fastlane', () =>\n fastlane.addSentryToFastlane(\n projectDir,\n project.organization.slug,\n project.slug,\n apiKey.token,\n ),\n );\n }\n }\n\n clack.log.success('Sentry was successfully added to your project!');\n}\n\n//Prompt for Sentry project and API key\nasync function getSentryProjectAndApiKey(\n promoCode?: string,\n url?: string,\n): Promise<{ project: SentryProjectData; apiKey: { token: string } }> {\n const { url: sentryUrl } = await askForSelfHosted(url);\n\n const { projects, apiKeys } = await askForWizardLogin({\n promoCode: promoCode,\n url: sentryUrl,\n platform: 'apple-ios',\n });\n\n const selectedProject = await askForProjectSelection(projects);\n return { project: selectedProject, apiKey: apiKeys };\n}\n\n//find files with the given extension\nfunction findFilesWithExtension(dir: string, extension: string): string[] {\n const files = fs.readdirSync(dir);\n return files.filter((file) => file.endsWith(extension));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"apple-wizard.js","sourceRoot":"","sources":["../../../src/apple/apple-wizard.ts"],"names":[],"mappings":";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EACZ,0BAA0B,CAC3B,CAAC;IACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QACnC,OAAO,EAAE,CAAC;KACX;IACD,IAAM,UAAU,GAAG,iCAAiC,CAAC;IACrD,IAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACzD,IAAI,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEvC,OAAO,OAAO,EAAE;QACd,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACvC,IACE,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YACjC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC5B,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EACxB;YACA,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACnB;QACD,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACpC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,qCAAqC;AACrC,SAAS,sBAAsB,CAAC,GAAW,EAAE,SAAiB;IAC5D,IAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAxB,CAAwB,CAAC,CAAC;AAC1D,CAAC","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 */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { XcodeProject } from './xcode-manager';\nimport * as codeTools from './code-tools';\nimport * as bash from '../utils/bash';\nimport * as SentryUtils from '../utils/sentrycli-utils';\nimport { SentryProjectData, WizardOptions } from '../utils/types';\nimport * as Sentry from '@sentry/node';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport * as cocoapod from './cocoapod';\nimport * as fastlane from './fastlane';\n\nconst xcode = require('xcode');\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nimport {\n askToInstallSentryCLI,\n printWelcome,\n abort,\n askForItemSelection,\n confirmContinueEvenThoughNoGitRepo,\n getOrAskForProjectData,\n} from '../utils/clack-utils';\n\nexport async function runAppleWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'ios',\n },\n () => runAppleWizardWithTelementry(options),\n );\n}\n\nasync function runAppleWizardWithTelementry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Apple Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueEvenThoughNoGitRepo();\n\n const hasCli = bash.hasSentryCLI();\n Sentry.setTag('has-cli', hasCli);\n if (!hasCli) {\n if (\n !(await traceStep('Ask for SentryCLI', () => askToInstallSentryCLI()))\n ) {\n clack.log.warn(\n \"Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/\",\n );\n Sentry.setTag('CLI-Installed', false);\n } else {\n await bash.installSentryCLI();\n Sentry.setTag('CLI-Installed', true);\n }\n }\n\n const projectDir = process.cwd();\n const xcodeProjFiles = searchXcodeProject(projectDir);\n\n if (!xcodeProjFiles || xcodeProjFiles.length === 0) {\n clack.log.error(\n 'No Xcode project found. Please run this command from the root of your project.',\n );\n await abort();\n return;\n }\n\n let xcodeProjFile;\n\n if (xcodeProjFiles.length === 1) {\n xcodeProjFile = xcodeProjFiles[0];\n Sentry.setTag('multiple-projects', false);\n } else {\n Sentry.setTag('multiple-projects', true);\n xcodeProjFile = (\n await traceStep('Choose Xcode project', () =>\n askForItemSelection(\n xcodeProjFiles,\n 'Which project do you want to add Sentry to?',\n ),\n )\n ).value;\n }\n\n const pbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');\n\n if (!fs.existsSync(pbxproj)) {\n clack.log.error(`No pbxproj found at ${xcodeProjFile}`);\n await abort();\n return;\n }\n\n const { project, apiKey } = await getSentryProjectAndApiKey(options);\n\n const xcProject = new XcodeProject(pbxproj);\n\n const availableTargets = xcProject.getAllTargets();\n\n if (availableTargets.length == 0) {\n clack.log.error(`No suttable target found in ${xcodeProjFile}`);\n await abort();\n return;\n }\n\n const target =\n availableTargets.length == 1\n ? availableTargets[0]\n : (\n await traceStep('Choose target', () =>\n askForItemSelection(\n availableTargets,\n 'Which target do you want to add Sentry to?',\n ),\n )\n ).value;\n\n SentryUtils.createSentryCLIRC(projectDir, { auth_token: apiKey.token });\n clack.log.info(\n 'We created a \".sentryclirc\" file in your project directory in order to provide an auth token for Sentry CLI.\\nIt was also added to your \".gitignore\" file.\\nAt your CI enviroment, you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information.',\n );\n\n let hasCocoa = cocoapod.usesCocoaPod(projectDir);\n\n if (hasCocoa) {\n const pm = (\n await traceStep('Choose a package manager', () =>\n askForItemSelection(\n ['Swift Package Manager', 'CocoaPods'],\n 'Which package manager would you like to use to add Sentry?',\n ),\n )\n ).value;\n\n hasCocoa = pm === 'CocoaPods';\n if (hasCocoa) {\n const podAdded = await traceStep('Add CocoaPods reference', () =>\n cocoapod.addCocoaPods(projectDir),\n );\n if (!podAdded) {\n clack.log.warn(\n \"Could not add Sentry pod to your Podfile. You'll have to add it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install\",\n );\n }\n }\n }\n\n traceStep('Update Xcode project', () => {\n xcProject.updateXcodeProject(project, target, apiKey, !hasCocoa, true);\n });\n\n Sentry.setTag('package-manager', hasCocoa ? 'cocoapods' : 'SPM');\n const codeAdded = traceStep('Add code snippet', () => {\n const files = xcProject.filesForTarget(target);\n if (files === undefined || files.length == 0) return false;\n\n return codeTools.addCodeSnippetToProject(\n projectDir,\n files,\n project.keys[0].dsn.public,\n );\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 snipped manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',\n );\n return;\n }\n\n if (fastlane.fastFile(projectDir)) {\n const addLane = await clack.confirm({\n message:\n 'Found a Fastfile in your project. Do you want to configure a lane to upload debug symbols to Sentry?',\n });\n if (addLane) {\n const added = await traceStep('Configure fastlane', () =>\n fastlane.addSentryToFastlane(\n projectDir,\n project.organization.slug,\n project.slug,\n ),\n );\n if (added) {\n clack.log.step(\n 'A new step was added to your fastlane file. Now and you build your project with fastlane, debug symbols and source context will be uploaded to Sentry.',\n );\n } else {\n clack.log.warn(\n 'Could not edit your fastlane file to upload debug symbols to Sentry. Please follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/dsym/#fastlane',\n );\n }\n }\n }\n\n clack.log.success(\n 'Sentry was successfully added to your project! Run your project to send your first event to Sentry. Go to Sentry.io to see whether everything is working fine.',\n );\n}\n\n//Prompt for Sentry project and API key\nasync function getSentryProjectAndApiKey(\n options: WizardOptions,\n): Promise<{ project: SentryProjectData; apiKey: { token: string } }> {\n const { selectedProject, authToken } = await getOrAskForProjectData(options);\n return { project: selectedProject, apiKey: { token: authToken } };\n}\n\nfunction searchXcodeProject(at: string): string[] {\n const projs = findFilesWithExtension(at, '.xcodeproj');\n if (projs.length > 0) {\n return projs;\n }\n\n const workspace = findFilesWithExtension(at, '.xcworkspace');\n if (workspace.length == 0) {\n return [];\n }\n\n const xsworkspacedata = path.join(\n at,\n workspace[0],\n 'contents.xcworkspacedata',\n );\n if (!fs.existsSync(xsworkspacedata)) {\n return [];\n }\n const groupRegex = /location *= *\"group:([^\"]+)\"/gim;\n const content = fs.readFileSync(xsworkspacedata, 'utf8');\n let matches = groupRegex.exec(content);\n\n while (matches) {\n const group = matches[1];\n const groupPath = path.join(at, group);\n if (\n !group.endsWith('Pods.xcodeproj') &&\n group.endsWith('.xcodeproj') &&\n fs.existsSync(groupPath)\n ) {\n projs.push(group);\n }\n matches = groupRegex.exec(content);\n }\n return projs;\n}\n\n//find files with the given extension\nfunction findFilesWithExtension(dir: string, extension: string): string[] {\n const files = fs.readdirSync(dir);\n return files.filter((file) => file.endsWith(extension));\n}\n"]}
|
|
@@ -98,6 +98,7 @@ function addCocoaPods(projPath) {
|
|
|
98
98
|
podContent.slice(insertIndex);
|
|
99
99
|
fs.writeFileSync(podfile, newFileContent, 'utf8');
|
|
100
100
|
loginSpinner = clack.spinner();
|
|
101
|
+
clack.log.step('Sentry pod added to the project podFile.');
|
|
101
102
|
loginSpinner.start("Running 'pod install'. This may take a few minutes...");
|
|
102
103
|
_a.label = 1;
|
|
103
104
|
case 1:
|
|
@@ -105,12 +106,12 @@ function addCocoaPods(projPath) {
|
|
|
105
106
|
return [4 /*yield*/, bash.execute('pod install --silent')];
|
|
106
107
|
case 2:
|
|
107
108
|
_a.sent();
|
|
108
|
-
loginSpinner.stop('
|
|
109
|
+
loginSpinner.stop('Running "pod install"');
|
|
109
110
|
return [3 /*break*/, 4];
|
|
110
111
|
case 3:
|
|
111
112
|
e_1 = _a.sent();
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
loginSpinner.stop('Running "pod install"');
|
|
114
|
+
clack.log.error('Failed to run "pod install". You can run it manually for more details.');
|
|
114
115
|
Sentry.captureException('Sentry pod install failed.');
|
|
115
116
|
return [3 /*break*/, 4];
|
|
116
117
|
case 4: return [2 /*return*/, true];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cocoapod.js","sourceRoot":"","sources":["../../../src/apple/cocoapod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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GAClB,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;wBAChC,IAAI;wBACJ,QAAQ,CAAC,CAAC,CAAC;wBACX,gBAAgB;wBAChB,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;oBAChC,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;oBAE5C,YAAY,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;oBAErC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;oBAC3D,YAAY,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAC;;;;oBAG1E,qBAAM,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAA;;oBAA1C,SAA0C,CAAC;oBAC3C,YAAY,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;;;;oBAE3C,YAAY,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;oBAC3C,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,wEAAwE,CACzE,CAAC;oBACF,MAAM,CAAC,gBAAgB,CAAC,4BAA4B,CAAC,CAAC;;wBAGxD,sBAAO,IAAI,EAAC;;;;CACb;AAhDD,oCAgDC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as bash from '../utils/bash';\nimport * as Sentry from '@sentry/node';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n\nexport function usesCocoaPod(projPath: string): boolean {\n return fs.existsSync(path.join(projPath, 'Podfile'));\n}\n\nexport async function addCocoaPods(projPath: string): Promise<boolean> {\n const podfile = path.join(projPath, 'Podfile');\n\n const podContent = fs.readFileSync(podfile, 'utf8');\n\n if (\n /^\\s*pod\\s+(['\"]Sentry['\"]|['\"]SentrySwiftUI['\"])\\s*$/im.test(podContent)\n ) {\n // Already have Sentry pod\n return true;\n }\n\n let podMatch = /^( *)pod\\s+['\"](\\w+)['\"] *$/im.exec(podContent);\n if (!podMatch) {\n // No Podfile is empty, will try to add Sentry pod after \"use_frameworks!\"\n const frameworkMatch = /^( *)use_frameworks![^\\n]* *$/im.exec(podContent);\n if (!frameworkMatch) {\n return false;\n }\n podMatch = frameworkMatch;\n }\n\n const insertIndex = podMatch.index + podMatch[0].length;\n const newFileContent =\n podContent.slice(0, insertIndex) +\n '\\n' +\n podMatch[1] +\n \"pod 'Sentry'\\n\" +\n podContent.slice(insertIndex);\n fs.writeFileSync(podfile, newFileContent, 'utf8');\n\n const loginSpinner = clack.spinner();\n\n clack.log.step('Sentry pod added to the project podFile.');\n loginSpinner.start(\"Running 'pod install'. This may take a few minutes...\");\n\n try {\n await bash.execute('pod install --silent');\n loginSpinner.stop('Running \"pod install\"');\n } catch (e) {\n loginSpinner.stop('Running \"pod install\"');\n clack.log.error(\n 'Failed to run \"pod install\". You can run it manually for more details.',\n );\n Sentry.captureException('Sentry pod install failed.');\n }\n\n return true;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function addCodeSnippetToProject(projPath: string, dsn: string): boolean;
|
|
1
|
+
export declare function addCodeSnippetToProject(projPath: string, files: string[], dsn: string): boolean;
|
|
@@ -22,15 +22,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.addCodeSnippetToProject = void 0;
|
|
27
30
|
var fs = __importStar(require("fs"));
|
|
28
31
|
var path = __importStar(require("path"));
|
|
29
32
|
var templates = __importStar(require("./templates"));
|
|
30
33
|
var Sentry = __importStar(require("@sentry/node"));
|
|
31
|
-
|
|
34
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
35
|
+
var prompts_1 = __importDefault(require("@clack/prompts"));
|
|
36
|
+
var swiftAppLaunchRegex = /(func\s+application\s*\(_\sapplication:[^,]+,\s*didFinishLaunchingWithOptions[^,]+:[^)]+\)\s+->\s+Bool\s+{)|func\s+applicationDidFinishLaunching\(_\s+aNotification:\s+Notification\)\s+{/im;
|
|
32
37
|
var objcAppLaunchRegex = /-\s*\(BOOL\)\s*application:\s*\(UIApplication\s*\*\)\s*application\s+didFinishLaunchingWithOptions:\s*\(NSDictionary\s*\*\)\s*launchOptions\s*{/im;
|
|
33
|
-
var swiftUIRegex =
|
|
38
|
+
var swiftUIRegex = /@main\s+struct[^:]+:\s*App\s*{/im;
|
|
34
39
|
function isAppDelegateFile(filePath) {
|
|
35
40
|
var appLaunchRegex = filePath.toLowerCase().endsWith('.swift')
|
|
36
41
|
? swiftAppLaunchRegex
|
|
@@ -38,38 +43,42 @@ function isAppDelegateFile(filePath) {
|
|
|
38
43
|
var fileContent = fs.readFileSync(filePath, 'utf8');
|
|
39
44
|
return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);
|
|
40
45
|
}
|
|
41
|
-
function findAppDidFinishLaunchingWithOptions(dir) {
|
|
42
|
-
|
|
46
|
+
function findAppDidFinishLaunchingWithOptions(dir, files) {
|
|
47
|
+
if (files === void 0) { files = undefined; }
|
|
48
|
+
if (!files) {
|
|
49
|
+
files = fs.readdirSync(dir);
|
|
50
|
+
files = files.map(function (f) { return path.join(dir, f); });
|
|
51
|
+
}
|
|
43
52
|
//iterate over subdirectories later,
|
|
44
53
|
//the appdelegate usually is in the top level
|
|
45
54
|
var dirs = [];
|
|
46
55
|
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (isAppDelegateFile(filePath)) {
|
|
56
|
+
var filePath = files_1[_i];
|
|
57
|
+
if (filePath.endsWith('.swift') ||
|
|
58
|
+
filePath.endsWith('.m') ||
|
|
59
|
+
filePath.endsWith('.mm')) {
|
|
60
|
+
if (fs.existsSync(filePath) && isAppDelegateFile(filePath)) {
|
|
53
61
|
return filePath;
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
|
-
else if (!
|
|
57
|
-
!
|
|
58
|
-
!
|
|
64
|
+
else if (!filePath.startsWith('.') &&
|
|
65
|
+
!filePath.endsWith('.xcodeproj') &&
|
|
66
|
+
!filePath.endsWith('.xcassets') &&
|
|
67
|
+
fs.existsSync(filePath) &&
|
|
59
68
|
fs.lstatSync(filePath).isDirectory()) {
|
|
60
|
-
dirs.push(
|
|
69
|
+
dirs.push(filePath);
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
for (var _a = 0, dirs_1 = dirs; _a < dirs_1.length; _a++) {
|
|
64
73
|
var dr = dirs_1[_a];
|
|
65
|
-
var result = findAppDidFinishLaunchingWithOptions(
|
|
74
|
+
var result = findAppDidFinishLaunchingWithOptions(dr);
|
|
66
75
|
if (result)
|
|
67
76
|
return result;
|
|
68
77
|
}
|
|
69
78
|
return null;
|
|
70
79
|
}
|
|
71
|
-
function addCodeSnippetToProject(projPath, dsn) {
|
|
72
|
-
var appDelegate = findAppDidFinishLaunchingWithOptions(projPath);
|
|
80
|
+
function addCodeSnippetToProject(projPath, files, dsn) {
|
|
81
|
+
var appDelegate = findAppDidFinishLaunchingWithOptions(projPath, files);
|
|
73
82
|
if (!appDelegate) {
|
|
74
83
|
return false;
|
|
75
84
|
}
|
|
@@ -85,6 +94,7 @@ function addCodeSnippetToProject(projPath, dsn) {
|
|
|
85
94
|
Sentry.setTag('ui-engine', swiftUIRegex.test(fileContent) ? 'swiftui' : 'uikit');
|
|
86
95
|
if (fileContent.includes(checkForSentryInit)) {
|
|
87
96
|
//already initialized
|
|
97
|
+
prompts_1.default.log.info('Sentry is already initialized in your AppDelegate. Skipping adding the code snippet.');
|
|
88
98
|
return true;
|
|
89
99
|
}
|
|
90
100
|
var match = appLaunchRegex.exec(fileContent);
|
|
@@ -98,12 +108,26 @@ function addCodeSnippetToProject(projPath, dsn) {
|
|
|
98
108
|
codeSnippet = " init() {\n".concat(codeSnippet, " }");
|
|
99
109
|
}
|
|
100
110
|
var insertIndex = match.index + match[0].length;
|
|
101
|
-
var newFileContent =
|
|
102
|
-
fileContent.slice(0, insertIndex) +
|
|
111
|
+
var newFileContent = fileContent.slice(0, insertIndex) +
|
|
103
112
|
'\n' +
|
|
104
113
|
codeSnippet +
|
|
105
114
|
fileContent.slice(insertIndex);
|
|
115
|
+
if (newFileContent.indexOf(importStatement) < 0) {
|
|
116
|
+
var firstImport = /^[ \t]*import +\w+.*$/m.exec(newFileContent);
|
|
117
|
+
if (firstImport) {
|
|
118
|
+
var importIndex = firstImport.index + firstImport[0].length;
|
|
119
|
+
newFileContent =
|
|
120
|
+
newFileContent.slice(0, importIndex) +
|
|
121
|
+
'\n' +
|
|
122
|
+
importStatement +
|
|
123
|
+
newFileContent.slice(importIndex);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
newFileContent = importStatement + newFileContent;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
106
129
|
fs.writeFileSync(appDelegate, newFileContent, 'utf8');
|
|
130
|
+
prompts_1.default.log.step('Added Sentry initialization code snippet to ' + appDelegate);
|
|
107
131
|
return true;
|
|
108
132
|
}
|
|
109
133
|
exports.addCodeSnippetToProject = addCodeSnippetToProject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/apple/code-tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/apple/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,qDAAyC;AACzC,mDAAuC;AACvC,yEAAyE;AACzE,2DAAmC;AAEnC,IAAM,mBAAmB,GACvB,6LAA6L,CAAC;AAChM,IAAM,kBAAkB,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C;YAC9D,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,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,8CAA8C,GAAG,WAAW,CAAC,CAAC;IAC7E,OAAO,IAAI,CAAC;AACd,CAAC;AArED,0DAqEC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\nimport * as Sentry from '@sentry/node';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\nconst swiftAppLaunchRegex =\n /(func\\s+application\\s*\\(_\\sapplication:[^,]+,\\s*didFinishLaunchingWithOptions[^,]+:[^)]+\\)\\s+->\\s+Bool\\s+{)|func\\s+applicationDidFinishLaunching\\(_\\s+aNotification:\\s+Notification\\)\\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 = /@main\\s+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(\n dir: string,\n files: string[] | undefined = undefined,\n): string | null {\n if (!files) {\n files = fs.readdirSync(dir);\n files = files.map((f) => path.join(dir, f));\n }\n\n //iterate over subdirectories later,\n //the appdelegate usually is in the top level\n const dirs: string[] = [];\n\n for (const filePath of files) {\n if (\n filePath.endsWith('.swift') ||\n filePath.endsWith('.m') ||\n filePath.endsWith('.mm')\n ) {\n if (fs.existsSync(filePath) && isAppDelegateFile(filePath)) {\n return filePath;\n }\n } else if (\n !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 = findAppDidFinishLaunchingWithOptions(dr);\n if (result) return result;\n }\n return null;\n}\n\nexport function addCodeSnippetToProject(\n projPath: string,\n files: string[],\n dsn: string,\n): boolean {\n const appDelegate = findAppDidFinishLaunchingWithOptions(projPath, 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 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"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function fastFile(projectPath: string): string | null;
|
|
2
|
-
export declare function addSentryToFastlane(projectPath: string, org: string, project: string
|
|
2
|
+
export declare function addSentryToFastlane(projectPath: string, org: string, project: string): Promise<boolean>;
|
|
@@ -58,12 +58,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
58
58
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
61
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
65
|
exports.addSentryToFastlane = exports.fastFile = void 0;
|
|
63
66
|
var fs = __importStar(require("fs"));
|
|
64
67
|
var path = __importStar(require("path"));
|
|
65
68
|
var templates = __importStar(require("./templates"));
|
|
66
69
|
var clack_utils_1 = require("../utils/clack-utils");
|
|
70
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
71
|
+
var prompts_1 = __importDefault(require("@clack/prompts"));
|
|
67
72
|
function fastFile(projectPath) {
|
|
68
73
|
var fastlanePath = path.join(projectPath, 'fastlane', 'Fastfile');
|
|
69
74
|
return fs.existsSync(fastlanePath) ? fastlanePath : null;
|
|
@@ -118,23 +123,23 @@ function findLanes(content) {
|
|
|
118
123
|
}
|
|
119
124
|
return lanes;
|
|
120
125
|
}
|
|
121
|
-
function addSentryToLane(content, lane, org, project
|
|
126
|
+
function addSentryToLane(content, lane, org, project) {
|
|
122
127
|
var laneContent = content.slice(lane.index, lane.index + lane.length);
|
|
123
128
|
var sentryCLIMatch = /sentry_cli\s*\([^)]+\)/gim.exec(laneContent);
|
|
124
129
|
if (sentryCLIMatch) {
|
|
125
130
|
// Sentry already added to lane. Update it.
|
|
126
131
|
return (content.slice(0, sentryCLIMatch.index + lane.index) +
|
|
127
|
-
templates.getFastlaneSnippet(org, project
|
|
132
|
+
templates.getFastlaneSnippet(org, project).trim() +
|
|
128
133
|
content.slice(sentryCLIMatch.index + sentryCLIMatch[0].length + lane.index));
|
|
129
134
|
}
|
|
130
135
|
// Sentry not added to lane. Add it.
|
|
131
136
|
return (content.slice(0, lane.index + lane.length) +
|
|
132
137
|
'\n' +
|
|
133
|
-
templates.getFastlaneSnippet(org, project
|
|
138
|
+
templates.getFastlaneSnippet(org, project) +
|
|
134
139
|
'\n' +
|
|
135
140
|
content.slice(lane.index + lane.length));
|
|
136
141
|
}
|
|
137
|
-
function addSentryToFastlane(projectPath, org, project
|
|
142
|
+
function addSentryToFastlane(projectPath, org, project) {
|
|
138
143
|
return __awaiter(this, void 0, void 0, function () {
|
|
139
144
|
var fastFilePath, fileContent, platform, platformContent, lanes, newFileContent, laneNames, selectedLane;
|
|
140
145
|
return __generator(this, function (_a) {
|
|
@@ -153,10 +158,11 @@ function addSentryToFastlane(projectPath, org, project, token) {
|
|
|
153
158
|
lanes = findLanes(platformContent);
|
|
154
159
|
lanes === null || lanes === void 0 ? void 0 : lanes.forEach(function (l) { return (l.index += platform.index); });
|
|
155
160
|
if (!lanes || lanes.length === 0) {
|
|
161
|
+
prompts_1.default.log.warn('No suitable lanes in your Fastfile.');
|
|
156
162
|
return [2 /*return*/, false];
|
|
157
163
|
}
|
|
158
164
|
if (!(lanes.length === 1)) return [3 /*break*/, 1];
|
|
159
|
-
newFileContent = addSentryToLane(fileContent, lanes[0], org, project
|
|
165
|
+
newFileContent = addSentryToLane(fileContent, lanes[0], org, project);
|
|
160
166
|
return [3 /*break*/, 3];
|
|
161
167
|
case 1:
|
|
162
168
|
laneNames = lanes.map(function (l) { return l.name; });
|
|
@@ -166,7 +172,7 @@ function addSentryToFastlane(projectPath, org, project, token) {
|
|
|
166
172
|
if (selectedLane === undefined) {
|
|
167
173
|
return [2 /*return*/, false];
|
|
168
174
|
}
|
|
169
|
-
newFileContent = addSentryToLane(fileContent, lanes[selectedLane.index], org, project
|
|
175
|
+
newFileContent = addSentryToLane(fileContent, lanes[selectedLane.index], org, project);
|
|
170
176
|
_a.label = 3;
|
|
171
177
|
case 3:
|
|
172
178
|
fs.writeFileSync(fastFilePath, newFileContent, 'utf8');
|