@sentry/wizard 2.6.1 → 3.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 +19 -2
- package/dist/NextJs/configs/next.config.template.js +1 -1
- package/dist/bin.js +7 -3
- package/dist/bin.js.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/Constants.js +1 -1
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/BottomBar.js +2 -2
- package/dist/lib/Helper/BottomBar.js.map +1 -1
- package/dist/lib/Helper/File.js +10 -12
- package/dist/lib/Helper/File.js.map +1 -1
- package/dist/lib/Helper/Logging.js +1 -1
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/Package.d.ts +1 -0
- package/dist/lib/Helper/Package.js +46 -0
- package/dist/lib/Helper/Package.js.map +1 -0
- package/dist/lib/Helper/PackageManager.d.ts +22 -0
- package/dist/lib/Helper/PackageManager.js +132 -0
- package/dist/lib/Helper/PackageManager.js.map +1 -0
- package/dist/lib/Helper/SentryCli.d.ts +3 -3
- package/dist/lib/Helper/SentryCli.js +3 -3
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Helper/Wizard.d.ts +4 -4
- package/dist/lib/Helper/Wizard.js +13 -12
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/File.js +5 -5
- package/dist/lib/Helper/__tests__/File.js.map +1 -1
- package/dist/lib/Helper/__tests__/MergeConfig.js +29 -18
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.js +11 -9
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/BaseStep.d.ts +2 -2
- package/dist/lib/Steps/BaseStep.js +3 -3
- package/dist/lib/Steps/BaseStep.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.d.ts +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +7 -5
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/ConfigureProject.d.ts +1 -1
- package/dist/lib/Steps/ConfigureProject.js +5 -3
- package/dist/lib/Steps/ConfigureProject.js.map +1 -1
- package/dist/lib/Steps/Initial.d.ts +1 -1
- package/dist/lib/Steps/Initial.js +6 -4
- package/dist/lib/Steps/Initial.js.map +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.d.ts +2 -2
- package/dist/lib/Steps/Integrations/BaseIntegration.js +5 -4
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.d.ts +2 -2
- package/dist/lib/Steps/Integrations/Cordova.js +12 -10
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.d.ts +2 -2
- package/dist/lib/Steps/Integrations/Electron.js +23 -21
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.d.ts +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js +7 -5
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/Integrations/NextJs.d.ts +2 -7
- package/dist/lib/Steps/Integrations/NextJs.js +59 -134
- package/dist/lib/Steps/Integrations/NextJs.js.map +1 -1
- package/dist/lib/Steps/Integrations/ReactNative.d.ts +9 -2
- package/dist/lib/Steps/Integrations/ReactNative.js +148 -78
- package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +43 -1
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +1 -1
- package/dist/lib/Steps/OpenSentry.d.ts +1 -1
- package/dist/lib/Steps/OpenSentry.js +19 -17
- package/dist/lib/Steps/OpenSentry.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.d.ts +1 -1
- package/dist/lib/Steps/PromptForParameters.js +21 -19
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/Result.d.ts +1 -1
- package/dist/lib/Steps/Result.js +7 -5
- package/dist/lib/Steps/Result.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.d.ts +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js +6 -4
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/lib/Steps/ShouldConfigure.d.ts +1 -1
- package/dist/lib/Steps/ShouldConfigure.js +5 -3
- package/dist/lib/Steps/ShouldConfigure.js.map +1 -1
- package/dist/lib/Steps/WaitForSentry.d.ts +1 -1
- package/dist/lib/Steps/WaitForSentry.js +11 -9
- package/dist/lib/Steps/WaitForSentry.js.map +1 -1
- package/dist/lib/Steps/Welcome.d.ts +1 -1
- package/dist/lib/Steps/Welcome.js +7 -6
- package/dist/lib/Steps/Welcome.js.map +1 -1
- package/dist/lib/Steps/index.js +1 -0
- package/dist/lib/Steps/index.js.map +1 -1
- package/dist/lib/__tests__/Env.js +1 -1
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/lib/__tests__/Setup.js +16 -1
- package/dist/lib/__tests__/Setup.js.map +1 -1
- package/lib/Helper/File.ts +2 -8
- package/lib/Helper/Package.ts +61 -0
- package/lib/Helper/PackageManager.ts +64 -0
- package/lib/Helper/SentryCli.ts +3 -3
- package/lib/Helper/Wizard.ts +7 -6
- package/lib/Helper/__tests__/File.ts +5 -5
- package/lib/Helper/__tests__/MergeConfig.ts +36 -20
- package/lib/Helper/__tests__/SentryCli.ts +3 -2
- package/lib/Helper/test-fixtures/next.config.1-merged.js +1 -1
- package/lib/Helper/test-fixtures/next.config.3-merged.js +1 -1
- package/lib/Helper/test-fixtures/next.config.4-merged.js +1 -1
- package/lib/Steps/BaseStep.ts +3 -3
- package/lib/Steps/ChooseIntegration.ts +2 -1
- package/lib/Steps/ConfigureProject.ts +1 -1
- package/lib/Steps/Initial.ts +1 -1
- package/lib/Steps/Integrations/BaseIntegration.ts +3 -3
- package/lib/Steps/Integrations/Cordova.ts +5 -5
- package/lib/Steps/Integrations/Electron.ts +7 -6
- package/lib/Steps/Integrations/MobileProject.ts +2 -1
- package/lib/Steps/Integrations/NextJs.ts +15 -114
- package/lib/Steps/Integrations/ReactNative.ts +143 -52
- package/lib/Steps/Integrations/__tests__/ReactNative.ts +37 -2
- package/lib/Steps/OpenSentry.ts +1 -1
- package/lib/Steps/PromptForParameters.ts +3 -2
- package/lib/Steps/Result.ts +1 -1
- package/lib/Steps/SentryProjectSelector.ts +3 -2
- package/lib/Steps/ShouldConfigure.ts +1 -1
- package/lib/Steps/WaitForSentry.ts +3 -3
- package/lib/Steps/Welcome.ts +1 -1
- package/lib/__tests__/Setup.ts +23 -0
- package/package.json +9 -13
- package/scripts/NextJs/configs/next.config.template.js +1 -1
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -27,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
27
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
30
|
function step(op) {
|
|
29
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
31
33
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
35
|
switch (op[0]) {
|
|
@@ -59,26 +61,27 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
59
61
|
}
|
|
60
62
|
return t;
|
|
61
63
|
};
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
68
72
|
};
|
|
69
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
74
|
exports.NextJs = void 0;
|
|
71
75
|
/* eslint-disable max-lines */
|
|
72
76
|
var chalk_1 = require("chalk");
|
|
73
|
-
var child_process_1 = require("child_process");
|
|
74
77
|
var fs = require("fs");
|
|
75
78
|
var inquirer_1 = require("inquirer");
|
|
76
79
|
var _ = require("lodash");
|
|
77
80
|
var path = require("path");
|
|
78
|
-
var semver_1 = require("semver");
|
|
79
|
-
var util_1 = require("util");
|
|
80
81
|
var Logging_1 = require("../../Helper/Logging");
|
|
81
82
|
var MergeConfig_1 = require("../../Helper/MergeConfig");
|
|
83
|
+
var Package_1 = require("../../Helper/Package");
|
|
84
|
+
var PackageManager_1 = require("../../Helper/PackageManager");
|
|
82
85
|
var SentryCli_1 = require("../../Helper/SentryCli");
|
|
83
86
|
var BaseIntegration_1 = require("./BaseIntegration");
|
|
84
87
|
var COMPATIBLE_NEXTJS_VERSIONS = '>=10.0.8 <14.0.0';
|
|
@@ -120,7 +123,7 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
120
123
|
switch (_g.label) {
|
|
121
124
|
case 0:
|
|
122
125
|
dsn = _.get(answers, ['config', 'dsn', 'public'], null);
|
|
123
|
-
Logging_1.nl();
|
|
126
|
+
(0, Logging_1.nl)();
|
|
124
127
|
sentryCliProps = this._sentryCli.convertAnswersToProperties(answers);
|
|
125
128
|
return [4 /*yield*/, this._createSentryCliConfig(sentryCliProps)];
|
|
126
129
|
case 1:
|
|
@@ -133,8 +136,8 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
133
136
|
_g.sent();
|
|
134
137
|
return [3 /*break*/, 4];
|
|
135
138
|
case 3:
|
|
136
|
-
Logging_1.debug("Couldn't find "
|
|
137
|
-
Logging_1.nl();
|
|
139
|
+
(0, Logging_1.debug)("Couldn't find ".concat(configDirectory, ", probably because you ran this from inside of `/lib` rather than `/dist`"));
|
|
140
|
+
(0, Logging_1.nl)();
|
|
138
141
|
_g.label = 4;
|
|
139
142
|
case 4:
|
|
140
143
|
selectedProjectSlug = (_b = (_a = answers.config) === null || _a === void 0 ? void 0 : _a.project) === null || _b === void 0 ? void 0 : _b.slug;
|
|
@@ -144,11 +147,11 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
144
147
|
return [4 /*yield*/, this._setTemplate(templateDirectory, 'sentry_sample_error.js', ['pages', 'src/pages'], dsn)];
|
|
145
148
|
case 5:
|
|
146
149
|
_g.sent();
|
|
147
|
-
Logging_1.l(chalk_1.default.bgYellowBright("\n|------------------------------------------------------------------------|\n| Installation Complete |\n| To verify your installation and finish onboarding, launch your Next.js |\n| application, navigate to http://localhost:3000/sentry_sample_error |\n| and send us a sample error. |\n|------------------------------------------------------------------------|\n"));
|
|
150
|
+
(0, Logging_1.l)(chalk_1.default.bgYellowBright("\n|------------------------------------------------------------------------|\n| Installation Complete |\n| To verify your installation and finish onboarding, launch your Next.js |\n| application, navigate to http://localhost:3000/sentry_sample_error |\n| and send us a sample error. |\n|------------------------------------------------------------------------|\n"));
|
|
148
151
|
_g.label = 6;
|
|
149
152
|
case 6:
|
|
150
|
-
Logging_1.l('For more information, see https://docs.sentry.io/platforms/javascript/guides/nextjs/');
|
|
151
|
-
Logging_1.nl();
|
|
153
|
+
(0, Logging_1.l)('For more information, see https://docs.sentry.io/platforms/javascript/guides/nextjs/');
|
|
154
|
+
(0, Logging_1.nl)();
|
|
152
155
|
return [2 /*return*/, {}];
|
|
153
156
|
}
|
|
154
157
|
});
|
|
@@ -163,14 +166,14 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
163
166
|
if (this._shouldConfigure) {
|
|
164
167
|
return [2 /*return*/, this._shouldConfigure];
|
|
165
168
|
}
|
|
166
|
-
Logging_1.nl();
|
|
169
|
+
(0, Logging_1.nl)();
|
|
167
170
|
userAnswers = { continue: true };
|
|
168
|
-
hasCompatibleNextjsVersion =
|
|
169
|
-
packageManager =
|
|
171
|
+
hasCompatibleNextjsVersion = (0, Package_1.checkPackageVersion)(appPackage, 'next', COMPATIBLE_NEXTJS_VERSIONS, true);
|
|
172
|
+
packageManager = (0, PackageManager_1.getPackageMangerChoice)();
|
|
170
173
|
hasSdkInstalled = this._hasPackageInstalled('@sentry/nextjs');
|
|
171
174
|
hasCompatibleSdkVersion = false;
|
|
172
175
|
if (!(!hasSdkInstalled && packageManager && hasCompatibleNextjsVersion)) return [3 /*break*/, 2];
|
|
173
|
-
return [4 /*yield*/,
|
|
176
|
+
return [4 /*yield*/, packageManager.installPackage('@sentry/nextjs')];
|
|
174
177
|
case 1:
|
|
175
178
|
_a.sent();
|
|
176
179
|
// can assume it's compatible since we just installed it
|
|
@@ -178,12 +181,12 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
178
181
|
return [3 /*break*/, 3];
|
|
179
182
|
case 2:
|
|
180
183
|
// otherwise, let's check the version and spit out the appropriate error
|
|
181
|
-
hasCompatibleSdkVersion =
|
|
184
|
+
hasCompatibleSdkVersion = (0, Package_1.checkPackageVersion)(appPackage, '@sentry/nextjs', COMPATIBLE_SDK_VERSIONS, true);
|
|
182
185
|
_a.label = 3;
|
|
183
186
|
case 3:
|
|
184
187
|
hasAllPackagesCompatible = hasCompatibleNextjsVersion && hasCompatibleSdkVersion;
|
|
185
188
|
if (!(!hasAllPackagesCompatible && !this._argv.quiet)) return [3 /*break*/, 5];
|
|
186
|
-
return [4 /*yield*/, inquirer_1.prompt({
|
|
189
|
+
return [4 /*yield*/, (0, inquirer_1.prompt)({
|
|
187
190
|
message: 'There were errors during your project checkup, do you still want to continue?',
|
|
188
191
|
name: 'continue',
|
|
189
192
|
default: false,
|
|
@@ -193,7 +196,7 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
193
196
|
userAnswers = _a.sent();
|
|
194
197
|
_a.label = 5;
|
|
195
198
|
case 5:
|
|
196
|
-
Logging_1.nl();
|
|
199
|
+
(0, Logging_1.nl)();
|
|
197
200
|
if (!userAnswers['continue']) {
|
|
198
201
|
throw new Error('Please install the required dependencies to continue.');
|
|
199
202
|
}
|
|
@@ -218,40 +221,40 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
218
221
|
return [4 /*yield*/, fs.promises.appendFile(SENTRYCLIRC_FILENAME, this._sentryCli.dumpConfig({ auth: { token: authToken } }))];
|
|
219
222
|
case 2:
|
|
220
223
|
_c.sent();
|
|
221
|
-
Logging_1.green("\u2713 Successfully added the auth token to "
|
|
224
|
+
(0, Logging_1.green)("\u2713 Successfully added the auth token to ".concat(SENTRYCLIRC_FILENAME));
|
|
222
225
|
return [3 /*break*/, 4];
|
|
223
226
|
case 3:
|
|
224
227
|
_a = _c.sent();
|
|
225
|
-
Logging_1.red("\u26A0 Could not add the auth token to "
|
|
226
|
-
|
|
227
|
-
Logging_1.nl();
|
|
228
|
+
(0, Logging_1.red)("\u26A0 Could not add the auth token to ".concat(SENTRYCLIRC_FILENAME, ", ") +
|
|
229
|
+
"please add it to identify your user account:\n".concat(authToken));
|
|
230
|
+
(0, Logging_1.nl)();
|
|
228
231
|
return [3 /*break*/, 4];
|
|
229
232
|
case 4: return [3 /*break*/, 6];
|
|
230
233
|
case 5:
|
|
231
|
-
Logging_1.red("\u26A0 Did not find an auth token, please add your token to "
|
|
232
|
-
Logging_1.l('To generate an auth token, visit https://sentry.io/settings/account/api/auth-tokens/');
|
|
233
|
-
Logging_1.l('To learn how to configure Sentry CLI, visit ' +
|
|
234
|
+
(0, Logging_1.red)("\u26A0 Did not find an auth token, please add your token to ".concat(SENTRYCLIRC_FILENAME));
|
|
235
|
+
(0, Logging_1.l)('To generate an auth token, visit https://sentry.io/settings/account/api/auth-tokens/');
|
|
236
|
+
(0, Logging_1.l)('To learn how to configure Sentry CLI, visit ' +
|
|
234
237
|
'https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli');
|
|
235
238
|
_c.label = 6;
|
|
236
|
-
case 6: return [4 /*yield*/, this._addToGitignore(SENTRYCLIRC_FILENAME, "\u26A0 Could not add "
|
|
239
|
+
case 6: return [4 /*yield*/, this._addToGitignore(SENTRYCLIRC_FILENAME, "\u26A0 Could not add ".concat(SENTRYCLIRC_FILENAME, " to ").concat(GITIGNORE_FILENAME, ", ") +
|
|
237
240
|
'please add it to not commit your auth key.')];
|
|
238
241
|
case 7:
|
|
239
242
|
_c.sent();
|
|
240
243
|
_c.label = 8;
|
|
241
244
|
case 8:
|
|
242
245
|
_c.trys.push([8, 10, , 11]);
|
|
243
|
-
return [4 /*yield*/, fs.promises.writeFile("./"
|
|
246
|
+
return [4 /*yield*/, fs.promises.writeFile("./".concat(PROPERTIES_FILENAME), this._sentryCli.dumpProperties(cliPropsToWrite))];
|
|
244
247
|
case 9:
|
|
245
248
|
_c.sent();
|
|
246
|
-
Logging_1.green(
|
|
249
|
+
(0, Logging_1.green)('✓ Successfully created sentry.properties');
|
|
247
250
|
return [3 /*break*/, 11];
|
|
248
251
|
case 10:
|
|
249
252
|
_b = _c.sent();
|
|
250
|
-
Logging_1.red("\u26A0 Could not add org and project data to "
|
|
251
|
-
Logging_1.l('See docs for a manual setup: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli');
|
|
253
|
+
(0, Logging_1.red)("\u26A0 Could not add org and project data to ".concat(PROPERTIES_FILENAME));
|
|
254
|
+
(0, Logging_1.l)('See docs for a manual setup: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli');
|
|
252
255
|
return [3 /*break*/, 11];
|
|
253
256
|
case 11:
|
|
254
|
-
Logging_1.nl();
|
|
257
|
+
(0, Logging_1.nl)();
|
|
255
258
|
return [2 /*return*/];
|
|
256
259
|
}
|
|
257
260
|
});
|
|
@@ -264,14 +267,14 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
264
267
|
switch (_b.label) {
|
|
265
268
|
case 0:
|
|
266
269
|
_b.trys.push([0, 2, , 3]);
|
|
267
|
-
return [4 /*yield*/, fs.promises.appendFile(GITIGNORE_FILENAME, "\n# Sentry\n"
|
|
270
|
+
return [4 /*yield*/, fs.promises.appendFile(GITIGNORE_FILENAME, "\n# Sentry\n".concat(filepath, "\n"))];
|
|
268
271
|
case 1:
|
|
269
272
|
_b.sent();
|
|
270
|
-
Logging_1.green("\u2713 "
|
|
273
|
+
(0, Logging_1.green)("\u2713 ".concat(filepath, " added to ").concat(GITIGNORE_FILENAME));
|
|
271
274
|
return [3 /*break*/, 3];
|
|
272
275
|
case 2:
|
|
273
276
|
_a = _b.sent();
|
|
274
|
-
Logging_1.red(errorMsg);
|
|
277
|
+
(0, Logging_1.red)(errorMsg);
|
|
275
278
|
return [3 /*break*/, 3];
|
|
276
279
|
case 3: return [2 /*return*/];
|
|
277
280
|
}
|
|
@@ -299,9 +302,9 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
299
302
|
_i++;
|
|
300
303
|
return [3 /*break*/, 1];
|
|
301
304
|
case 4:
|
|
302
|
-
Logging_1.red('⚠ Performance monitoring is enabled capturing 100% of transactions.\n' +
|
|
305
|
+
(0, Logging_1.red)('⚠ Performance monitoring is enabled capturing 100% of transactions.\n' +
|
|
303
306
|
' Learn more in https://docs.sentry.io/product/performance/');
|
|
304
|
-
Logging_1.nl();
|
|
307
|
+
(0, Logging_1.nl)();
|
|
305
308
|
return [2 /*return*/];
|
|
306
309
|
}
|
|
307
310
|
});
|
|
@@ -335,22 +338,22 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
335
338
|
}
|
|
336
339
|
else if (!fs.existsSync(mergeableFilePath)) {
|
|
337
340
|
this._fillAndCopyTemplate(templatePath, mergeableFilePath, dsn);
|
|
338
|
-
Logging_1.red("File `"
|
|
341
|
+
(0, Logging_1.red)("File `".concat(templateFile, "` already exists, so created `").concat(mergeableFilePath, "`.\n") +
|
|
339
342
|
'Please merge those files.');
|
|
340
|
-
Logging_1.nl();
|
|
343
|
+
(0, Logging_1.nl)();
|
|
341
344
|
}
|
|
342
345
|
else {
|
|
343
|
-
Logging_1.red("Both `"
|
|
346
|
+
(0, Logging_1.red)("Both `".concat(templateFile, "` and `").concat(mergeableFilePath, "` already exist.\n") +
|
|
344
347
|
'Please merge those files.');
|
|
345
|
-
Logging_1.nl();
|
|
348
|
+
(0, Logging_1.nl)();
|
|
346
349
|
}
|
|
347
350
|
return [2 /*return*/];
|
|
348
351
|
case 4:
|
|
349
352
|
_i++;
|
|
350
353
|
return [3 /*break*/, 1];
|
|
351
354
|
case 5:
|
|
352
|
-
Logging_1.red("Could not find appropriate destination for `"
|
|
353
|
-
Logging_1.nl();
|
|
355
|
+
(0, Logging_1.red)("Could not find appropriate destination for `".concat(templateFile, "`. Tried: ").concat(destinationOptions, "."));
|
|
356
|
+
(0, Logging_1.nl)();
|
|
354
357
|
return [2 /*return*/];
|
|
355
358
|
}
|
|
356
359
|
});
|
|
@@ -366,90 +369,12 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
366
369
|
var devDepsVersion = _.get(appPackage, ['devDependencies', packageName]);
|
|
367
370
|
return !!depsVersion || !!devDepsVersion;
|
|
368
371
|
};
|
|
369
|
-
NextJs.prototype._getPackageMangerChoice = function () {
|
|
370
|
-
if (fs.existsSync(path.join(process.cwd(), 'yarn.lock'))) {
|
|
371
|
-
return 'yarn';
|
|
372
|
-
}
|
|
373
|
-
if (fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'))) {
|
|
374
|
-
return 'pnpm';
|
|
375
|
-
}
|
|
376
|
-
if (fs.existsSync(path.join(process.cwd(), 'package-lock.json'))) {
|
|
377
|
-
return 'npm';
|
|
378
|
-
}
|
|
379
|
-
return null;
|
|
380
|
-
};
|
|
381
|
-
NextJs.prototype._getInstallCommand = function (packageManager) {
|
|
382
|
-
switch (packageManager) {
|
|
383
|
-
case 'yarn':
|
|
384
|
-
return 'yarn add';
|
|
385
|
-
case 'pnpm':
|
|
386
|
-
return 'pnpm add';
|
|
387
|
-
case 'npm':
|
|
388
|
-
return 'npm install';
|
|
389
|
-
default:
|
|
390
|
-
throw new Error("Unknown package manager: " + packageManager);
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
NextJs.prototype._installPackage = function (packageName, packageManager) {
|
|
394
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
395
|
-
var command;
|
|
396
|
-
return __generator(this, function (_a) {
|
|
397
|
-
switch (_a.label) {
|
|
398
|
-
case 0:
|
|
399
|
-
command = this._getInstallCommand(packageManager);
|
|
400
|
-
return [4 /*yield*/, util_1.promisify(child_process_1.exec)(command + " " + packageName)];
|
|
401
|
-
case 1:
|
|
402
|
-
_a.sent();
|
|
403
|
-
Logging_1.green("\u2713 Added `" + packageName + "` using `" + command + "`.");
|
|
404
|
-
return [2 /*return*/];
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
};
|
|
409
|
-
NextJs.prototype._checkPackageVersion = function (packageName, acceptableVersions, canBeLatest) {
|
|
410
|
-
var depsVersion = _.get(appPackage, ['dependencies', packageName]);
|
|
411
|
-
var devDepsVersion = _.get(appPackage, ['devDependencies', packageName]);
|
|
412
|
-
if (!depsVersion && !devDepsVersion) {
|
|
413
|
-
Logging_1.red("\u2717 " + packageName + " isn't in your dependencies.");
|
|
414
|
-
Logging_1.red(' Please install it with yarn/npm.');
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
else if (!this._fulfillsVersionRange(depsVersion, acceptableVersions, canBeLatest) &&
|
|
418
|
-
!this._fulfillsVersionRange(devDepsVersion, acceptableVersions, canBeLatest)) {
|
|
419
|
-
Logging_1.red("\u2717 Your `package.json` specifies a version of `" + packageName + "` outside of the compatible version range " + acceptableVersions + ".\n");
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
Logging_1.green("\u2713 A compatible version of `" + packageName + "` is specified in `package.json`.");
|
|
424
|
-
return true;
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
NextJs.prototype._fulfillsVersionRange = function (version, acceptableVersions, canBeLatest) {
|
|
428
|
-
if (version === 'latest') {
|
|
429
|
-
return canBeLatest;
|
|
430
|
-
}
|
|
431
|
-
var cleanedUserVersion, isRange;
|
|
432
|
-
if (semver_1.valid(version)) {
|
|
433
|
-
cleanedUserVersion = semver_1.valid(version);
|
|
434
|
-
isRange = false;
|
|
435
|
-
}
|
|
436
|
-
else if (semver_1.validRange(version)) {
|
|
437
|
-
cleanedUserVersion = semver_1.validRange(version);
|
|
438
|
-
isRange = true;
|
|
439
|
-
}
|
|
440
|
-
return (
|
|
441
|
-
// If the given version is a bogus format, this will still be undefined and we'll automatically reject it
|
|
442
|
-
!!cleanedUserVersion &&
|
|
443
|
-
(isRange
|
|
444
|
-
? semver_1.subset(cleanedUserVersion, acceptableVersions)
|
|
445
|
-
: semver_1.satisfies(cleanedUserVersion, acceptableVersions)));
|
|
446
|
-
};
|
|
447
372
|
NextJs.prototype._spliceInPlace = function (arr, start, deleteCount) {
|
|
448
373
|
var inserts = [];
|
|
449
374
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
450
375
|
inserts[_i - 3] = arguments[_i];
|
|
451
376
|
}
|
|
452
|
-
arr.splice.apply(arr,
|
|
377
|
+
arr.splice.apply(arr, __spreadArray([start, deleteCount], inserts, false));
|
|
453
378
|
return arr;
|
|
454
379
|
};
|
|
455
380
|
NextJs.prototype._mergeNextConfig = function (destinationPath, templatePath, destinationDir, templateFile, configDirectory, mergeableFilePath) {
|
|
@@ -460,8 +385,8 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
460
385
|
case 0:
|
|
461
386
|
if (!!fs.existsSync(destinationPath)) return [3 /*break*/, 1];
|
|
462
387
|
fs.copyFileSync(templatePath, destinationPath);
|
|
463
|
-
Logging_1.green('Created File `next.config.js`');
|
|
464
|
-
Logging_1.nl();
|
|
388
|
+
(0, Logging_1.green)('Created File `next.config.js`');
|
|
389
|
+
(0, Logging_1.nl)();
|
|
465
390
|
return [3 /*break*/, 5];
|
|
466
391
|
case 1:
|
|
467
392
|
originalFileName = this._spliceInPlace(templateFile.split('.'), -1, 0, 'original').join('.');
|
|
@@ -472,10 +397,10 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
472
397
|
case 2:
|
|
473
398
|
_a.sent();
|
|
474
399
|
mergedTemplatePath = path.join(configDirectory, 'next.config.template.js');
|
|
475
|
-
if (!MergeConfig_1.mergeConfigFile(destinationPath, mergedTemplatePath)) return [3 /*break*/, 3];
|
|
476
|
-
Logging_1.green("Updated `"
|
|
400
|
+
if (!(0, MergeConfig_1.mergeConfigFile)(destinationPath, mergedTemplatePath)) return [3 /*break*/, 3];
|
|
401
|
+
(0, Logging_1.green)("Updated `".concat(templateFile, "` with Sentry. The original ").concat(templateFile, " was saved as `next.config.original.js`.\n") +
|
|
477
402
|
'Information on the changes made to the Next.js configuration file an be found at https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/');
|
|
478
|
-
Logging_1.nl();
|
|
403
|
+
(0, Logging_1.nl)();
|
|
479
404
|
return [3 /*break*/, 5];
|
|
480
405
|
case 3:
|
|
481
406
|
// if merge fails, we'll create a copy of the `next.config.js` template and ask them to merge
|
|
@@ -483,9 +408,9 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
483
408
|
return [4 /*yield*/, this._addToGitignore(mergeableFilePath, 'Unable to add next.config.wizard.js template to gitignore')];
|
|
484
409
|
case 4:
|
|
485
410
|
_a.sent();
|
|
486
|
-
Logging_1.red("Unable to merge `"
|
|
411
|
+
(0, Logging_1.red)("Unable to merge `".concat(templateFile, "`, so created `").concat(mergeableFilePath, "`.\n") +
|
|
487
412
|
'Please integrate next.config.wizardcopy.js into your next.config.js or next.config.ts file');
|
|
488
|
-
Logging_1.nl();
|
|
413
|
+
(0, Logging_1.nl)();
|
|
489
414
|
_a.label = 5;
|
|
490
415
|
case 5: return [2 /*return*/];
|
|
491
416
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextJs.js","sourceRoot":"","sources":["../../../../lib/Steps/Integrations/NextJs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+BAA0B;AAC1B,+CAAqC;AACrC,uBAAyB;AACzB,qCAA2C;AAC3C,0BAA4B;AAC5B,2BAA6B;AAC7B,iCAA8D;AAC9D,6BAAiC;AAGjC,gDAAgE;AAChE,wDAA2D;AAC3D,oDAAmE;AACnE,qDAAoD;AAIpD,IAAM,0BAA0B,GAAG,kBAAkB,CAAC;AACtD,IAAM,uBAAuB,GAAG,SAAS,CAAC;AAC1C,IAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAChD,IAAM,oBAAoB,GAAG,cAAc,CAAC;AAC5C,IAAM,kBAAkB,GAAG,YAAY,CAAC;AACxC,IAAM,UAAU,GAAG,UAAU,CAAC;AAC9B,IAAM,sBAAsB,GAAG,YAAY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BAEE,6BAAe,CAAC,eAAe,EAAE,kBAAkB,CAAC,EAApD,wBAAoD;wBACtD,eAAK,CACH,cAAa,YAAY,oCAAgC,YAAY,+CAA8C;4BACjH,0JAA0J,CAC7J,CAAC;wBACF,YAAE,EAAE,CAAC;;;wBAEL,6FAA6F;wBAC7F,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;wBACjD,qBAAM,IAAI,CAAC,eAAe,CACxB,iBAAiB,EACjB,2DAA2D,CAC5D,EAAA;;wBAHD,SAGC,CAAC;wBACF,aAAG,CACD,uBAAsB,YAAY,uBAAoB,iBAAiB,SAAO;4BAC5E,4FAA4F,CAC/F,CAAC;wBACF,YAAE,EAAE,CAAC;;;;;;KAGV;IACH,aAAC;AAAD,CAAC,AAxdD,CAA4B,iCAAe,GAwd1C;AAxdY,wBAAM","sourcesContent":["/* eslint-disable max-lines */\nimport Chalk from 'chalk';\nimport { exec } from 'child_process';\nimport * as fs from 'fs';\nimport { Answers, prompt } from 'inquirer';\nimport * as _ from 'lodash';\nimport * as path from 'path';\nimport { satisfies, subset, valid, validRange } from 'semver';\nimport { promisify } from 'util';\n\nimport { Args } from '../../Constants';\nimport { debug, green, l, nl, red } from '../../Helper/Logging';\nimport { mergeConfigFile } from '../../Helper/MergeConfig';\nimport { SentryCli, SentryCliProps } from '../../Helper/SentryCli';\nimport { BaseIntegration } from './BaseIntegration';\n\ntype PackageManager = 'yarn' | 'npm' | 'pnpm';\n\nconst COMPATIBLE_NEXTJS_VERSIONS = '>=10.0.8 <14.0.0';\nconst COMPATIBLE_SDK_VERSIONS = '>=7.3.0';\nconst PROPERTIES_FILENAME = 'sentry.properties';\nconst SENTRYCLIRC_FILENAME = '.sentryclirc';\nconst GITIGNORE_FILENAME = '.gitignore';\nconst CONFIG_DIR = 'configs/';\nconst MERGEABLE_CONFIG_INFIX = 'wizardcopy';\n\n// for those files which can go in more than one place, the list of places they\n// could go (the first one which works will be used)\nconst TEMPLATE_DESTINATIONS: { [key: string]: string[] } = {\n '_error.js': ['pages', 'src/pages'],\n 'next.config.js': ['.'],\n 'sentry.server.config.js': ['.'],\n 'sentry.client.config.js': ['.'],\n 'sentry.edge.config.js': ['.'],\n};\n\nlet appPackage: any = {};\n\ntry {\n appPackage = require(path.join(process.cwd(), 'package.json'));\n} catch {\n // We don't need to have this\n}\n\nexport class NextJs extends BaseIntegration {\n protected _sentryCli: SentryCli;\n\n constructor(protected _argv: Args) {\n super(_argv);\n this._sentryCli = new SentryCli(this._argv);\n }\n\n public async emit(answers: Answers): Promise<Answers> {\n const dsn = _.get(answers, ['config', 'dsn', 'public'], null);\n nl();\n\n const sentryCliProps = this._sentryCli.convertAnswersToProperties(answers);\n await this._createSentryCliConfig(sentryCliProps);\n\n const templateDirectory = path.join(__dirname, '..', '..', '..', 'NextJs');\n const configDirectory = path.join(templateDirectory, CONFIG_DIR);\n\n if (fs.existsSync(configDirectory)) {\n await this._createNextConfig(configDirectory, dsn);\n } else {\n debug(\n `Couldn't find ${configDirectory}, probably because you ran this from inside of \\`/lib\\` rather than \\`/dist\\``,\n );\n nl();\n }\n\n const selectedProjectSlug: string | null = answers.config?.project?.slug;\n if (selectedProjectSlug) {\n const hasFirstEvent = answers.wizard?.projects?.find?.(\n (p: { slug: string }) => p.slug === selectedProjectSlug,\n )?.firstEvent;\n if (!hasFirstEvent) {\n await this._setTemplate(\n templateDirectory,\n 'sentry_sample_error.js',\n ['pages', 'src/pages'],\n dsn,\n );\n l(\n Chalk.bgYellowBright(`\n|------------------------------------------------------------------------|\n| Installation Complete |\n| To verify your installation and finish onboarding, launch your Next.js |\n| application, navigate to http://localhost:3000/sentry_sample_error |\n| and send us a sample error. |\n|------------------------------------------------------------------------|\n`),\n );\n }\n }\n\n l(\n 'For more information, see https://docs.sentry.io/platforms/javascript/guides/nextjs/',\n );\n nl();\n\n return {};\n }\n\n public async shouldConfigure(_answers: Answers): Promise<Answers> {\n if (this._shouldConfigure) {\n return this._shouldConfigure;\n }\n\n nl();\n\n let userAnswers: Answers = { continue: true };\n const hasCompatibleNextjsVersion = this._checkPackageVersion(\n 'next',\n COMPATIBLE_NEXTJS_VERSIONS,\n true,\n );\n\n const packageManager = this._getPackageMangerChoice();\n const hasSdkInstalled = this._hasPackageInstalled('@sentry/nextjs');\n\n let hasCompatibleSdkVersion = false;\n // if no package but we have nextjs, let's add it if we can\n if (!hasSdkInstalled && packageManager && hasCompatibleNextjsVersion) {\n await this._installPackage('@sentry/nextjs', packageManager);\n // can assume it's compatible since we just installed it\n hasCompatibleSdkVersion = true;\n } else {\n // otherwise, let's check the version and spit out the appropriate error\n hasCompatibleSdkVersion = this._checkPackageVersion(\n '@sentry/nextjs',\n COMPATIBLE_SDK_VERSIONS,\n true,\n );\n }\n const hasAllPackagesCompatible =\n hasCompatibleNextjsVersion && hasCompatibleSdkVersion;\n\n if (!hasAllPackagesCompatible && !this._argv.quiet) {\n userAnswers = await prompt({\n message:\n 'There were errors during your project checkup, do you still want to continue?',\n name: 'continue',\n default: false,\n type: 'confirm',\n });\n }\n\n nl();\n\n if (!userAnswers['continue']) {\n throw new Error('Please install the required dependencies to continue.');\n }\n\n this._shouldConfigure = Promise.resolve({ nextjs: true });\n // eslint-disable-next-line @typescript-eslint/unbound-method\n return this.shouldConfigure;\n }\n\n private async _createSentryCliConfig(\n cliProps: SentryCliProps,\n ): Promise<void> {\n const { 'auth/token': authToken, ...cliPropsToWrite } = cliProps;\n\n /**\n * To not commit the auth token to the VCS, instead of adding it to the\n * properties file (like the rest of props), it's added to the Sentry CLI\n * config, which is added to the gitignore. This way makes the properties\n * file safe to commit without exposing any auth tokens.\n */\n if (authToken) {\n try {\n await fs.promises.appendFile(\n SENTRYCLIRC_FILENAME,\n this._sentryCli.dumpConfig({ auth: { token: authToken } }),\n );\n green(`✓ Successfully added the auth token to ${SENTRYCLIRC_FILENAME}`);\n } catch {\n red(\n `⚠ Could not add the auth token to ${SENTRYCLIRC_FILENAME}, ` +\n `please add it to identify your user account:\\n${authToken}`,\n );\n nl();\n }\n } else {\n red(\n `⚠ Did not find an auth token, please add your token to ${SENTRYCLIRC_FILENAME}`,\n );\n l(\n 'To generate an auth token, visit https://sentry.io/settings/account/api/auth-tokens/',\n );\n l(\n 'To learn how to configure Sentry CLI, visit ' +\n 'https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli',\n );\n }\n\n await this._addToGitignore(\n SENTRYCLIRC_FILENAME,\n `⚠ Could not add ${SENTRYCLIRC_FILENAME} to ${GITIGNORE_FILENAME}, ` +\n 'please add it to not commit your auth key.',\n );\n\n try {\n await fs.promises.writeFile(\n `./${PROPERTIES_FILENAME}`,\n this._sentryCli.dumpProperties(cliPropsToWrite),\n );\n green(`✓ Successfully created sentry.properties`);\n } catch {\n red(`⚠ Could not add org and project data to ${PROPERTIES_FILENAME}`);\n l(\n 'See docs for a manual setup: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli',\n );\n }\n nl();\n }\n\n private async _addToGitignore(\n filepath: string,\n errorMsg: string,\n ): Promise<void> {\n /**\n * Don't check whether the given file is ignored because:\n * 1. It's tricky to check it without git.\n * 2. Git might not be installed or accessible.\n * 3. It's convenient to use a module to interact with git, but it would\n * increase the size x2 approximately. Docs say to run the Wizard without\n * installing it, and duplicating the size would slow the set-up down.\n * 4. The Wizard is meant to be run once.\n * 5. A message is logged informing users it's been added to the gitignore.\n * 6. It will be added to the gitignore as many times as it runs - not a big\n * deal.\n * 7. It's straightforward to remove it from the gitignore.\n */\n try {\n await fs.promises.appendFile(\n GITIGNORE_FILENAME,\n `\\n# Sentry\\n${filepath}\\n`,\n );\n green(`✓ ${filepath} added to ${GITIGNORE_FILENAME}`);\n } catch {\n red(errorMsg);\n }\n }\n\n private async _createNextConfig(\n configDirectory: string,\n dsn: any,\n ): Promise<void> {\n const templates = fs.readdirSync(configDirectory);\n // next.config.template.js used for merging next.config.js , not its own template,\n // so it shouldn't have a setTemplate call\n const filteredTemplates = templates.filter(\n (template) => template !== 'next.config.template.js',\n );\n for (const template of filteredTemplates) {\n await this._setTemplate(\n configDirectory,\n template,\n TEMPLATE_DESTINATIONS[template],\n dsn,\n );\n }\n red(\n '⚠ Performance monitoring is enabled capturing 100% of transactions.\\n' +\n ' Learn more in https://docs.sentry.io/product/performance/',\n );\n nl();\n }\n\n private async _setTemplate(\n configDirectory: string,\n templateFile: string,\n destinationOptions: string[],\n dsn: string,\n ): Promise<void> {\n const templatePath = path.join(configDirectory, templateFile);\n\n for (const destinationDir of destinationOptions) {\n if (!fs.existsSync(destinationDir)) {\n continue;\n }\n const destinationPath = path.join(destinationDir, templateFile);\n // in case the file in question already exists, we'll make a copy with\n // `MERGEABLE_CONFIG_INFIX` inserted just before the extension, so as not\n // to overwrite the existing file\n const mergeableFilePath = path.join(\n destinationDir,\n this._spliceInPlace(\n templateFile.split('.'),\n -1,\n 0,\n MERGEABLE_CONFIG_INFIX,\n ).join('.'),\n );\n\n if (templateFile === 'next.config.js') {\n await this._mergeNextConfig(\n destinationPath,\n templatePath,\n destinationDir,\n templateFile,\n configDirectory,\n mergeableFilePath,\n );\n return;\n } else {\n if (!fs.existsSync(destinationPath)) {\n this._fillAndCopyTemplate(templatePath, destinationPath, dsn);\n } else if (!fs.existsSync(mergeableFilePath)) {\n this._fillAndCopyTemplate(templatePath, mergeableFilePath, dsn);\n red(\n `File \\`${templateFile}\\` already exists, so created \\`${mergeableFilePath}\\`.\\n` +\n 'Please merge those files.',\n );\n nl();\n } else {\n red(\n `Both \\`${templateFile}\\` and \\`${mergeableFilePath}\\` already exist.\\n` +\n 'Please merge those files.',\n );\n nl();\n }\n return;\n }\n }\n\n red(\n `Could not find appropriate destination for \\`${templateFile}\\`. Tried: ${destinationOptions}.`,\n );\n nl();\n }\n\n private _fillAndCopyTemplate(\n sourcePath: string,\n targetPath: string,\n dsn: string,\n ): void {\n const templateContent = fs.readFileSync(sourcePath).toString();\n const filledTemplate = templateContent.replace('___DSN___', dsn);\n fs.writeFileSync(targetPath, filledTemplate);\n }\n\n private _hasPackageInstalled(packageName: string): boolean {\n const depsVersion = _.get(appPackage, ['dependencies', packageName]);\n const devDepsVersion = _.get(appPackage, ['devDependencies', packageName]);\n return !!depsVersion || !!devDepsVersion;\n }\n\n private _getPackageMangerChoice(): PackageManager | null {\n if (fs.existsSync(path.join(process.cwd(), 'yarn.lock'))) {\n return 'yarn';\n }\n if (fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'))) {\n return 'pnpm';\n }\n if (fs.existsSync(path.join(process.cwd(), 'package-lock.json'))) {\n return 'npm';\n }\n return null;\n }\n\n private _getInstallCommand(packageManager: PackageManager): string {\n switch (packageManager) {\n case 'yarn':\n return 'yarn add';\n case 'pnpm':\n return 'pnpm add';\n case 'npm':\n return 'npm install';\n default:\n throw new Error(`Unknown package manager: ${packageManager}`);\n }\n }\n\n private async _installPackage(\n packageName: string,\n packageManager: PackageManager,\n ): Promise<void> {\n const command = this._getInstallCommand(packageManager);\n await promisify(exec)(`${command} ${packageName}`);\n green(`✓ Added \\`${packageName}\\` using \\`${command}\\`.`);\n return;\n }\n\n private _checkPackageVersion(\n packageName: string,\n acceptableVersions: string,\n canBeLatest: boolean,\n ): boolean {\n const depsVersion = _.get(appPackage, ['dependencies', packageName]);\n const devDepsVersion = _.get(appPackage, ['devDependencies', packageName]);\n\n if (!depsVersion && !devDepsVersion) {\n red(`✗ ${packageName} isn't in your dependencies.`);\n red(' Please install it with yarn/npm.');\n return false;\n } else if (\n !this._fulfillsVersionRange(\n depsVersion,\n acceptableVersions,\n canBeLatest,\n ) &&\n !this._fulfillsVersionRange(\n devDepsVersion,\n acceptableVersions,\n canBeLatest,\n )\n ) {\n red(\n `✗ Your \\`package.json\\` specifies a version of \\`${packageName}\\` outside of the compatible version range ${acceptableVersions}.\\n`,\n );\n return false;\n } else {\n green(\n `✓ A compatible version of \\`${packageName}\\` is specified in \\`package.json\\`.`,\n );\n return true;\n }\n }\n\n private _fulfillsVersionRange(\n version: string,\n acceptableVersions: string,\n canBeLatest: boolean,\n ): boolean {\n if (version === 'latest') {\n return canBeLatest;\n }\n\n let cleanedUserVersion, isRange;\n\n if (valid(version)) {\n cleanedUserVersion = valid(version);\n isRange = false;\n } else if (validRange(version)) {\n cleanedUserVersion = validRange(version);\n isRange = true;\n }\n\n return (\n // If the given version is a bogus format, this will still be undefined and we'll automatically reject it\n !!cleanedUserVersion &&\n (isRange\n ? subset(cleanedUserVersion, acceptableVersions)\n : satisfies(cleanedUserVersion, acceptableVersions))\n );\n }\n\n private _spliceInPlace(\n arr: Array<any>,\n start: number,\n deleteCount: number,\n ...inserts: any[]\n ): Array<any> {\n arr.splice(start, deleteCount, ...inserts);\n return arr;\n }\n\n private async _mergeNextConfig(\n destinationPath: string,\n templatePath: string,\n destinationDir: string,\n templateFile: string,\n configDirectory: string,\n mergeableFilePath: string,\n ): Promise<void> {\n // if no next.config.js exists, we'll create one\n if (!fs.existsSync(destinationPath)) {\n fs.copyFileSync(templatePath, destinationPath);\n green('Created File `next.config.js`');\n nl();\n } else {\n // creates a file name for the copy of the original next.config.js file\n // with the name `next.config.original.js`\n const originalFileName = this._spliceInPlace(\n templateFile.split('.'),\n -1,\n 0,\n 'original',\n ).join('.');\n const originalFilePath = path.join(destinationDir, originalFileName);\n // makes copy of original next.config.js\n fs.writeFileSync(originalFilePath, fs.readFileSync(destinationPath));\n await this._addToGitignore(\n originalFilePath,\n 'Unable to add next.config.original.js to gitignore',\n );\n\n const mergedTemplatePath = path.join(\n configDirectory,\n 'next.config.template.js',\n );\n // attempts to merge with existing next.config.js, if true -> success\n if (mergeConfigFile(destinationPath, mergedTemplatePath)) {\n green(\n `Updated \\`${templateFile}\\` with Sentry. The original ${templateFile} was saved as \\`next.config.original.js\\`.\\n` +\n 'Information on the changes made to the Next.js configuration file an be found at https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/',\n );\n nl();\n } else {\n // if merge fails, we'll create a copy of the `next.config.js` template and ask them to merge\n fs.copyFileSync(templatePath, mergeableFilePath);\n await this._addToGitignore(\n mergeableFilePath,\n 'Unable to add next.config.wizard.js template to gitignore',\n );\n red(\n `Unable to merge \\`${templateFile}\\`, so created \\`${mergeableFilePath}\\`.\\n` +\n 'Please integrate next.config.wizardcopy.js into your next.config.js or next.config.ts file',\n );\n nl();\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NextJs.js","sourceRoot":"","sources":["../../../../lib/Steps/Integrations/NextJs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+BAA0B;AAC1B,uBAAyB;AAEzB,qCAAkC;AAClC,0BAA4B;AAC5B,2BAA6B;AAG7B,gDAAgE;AAChE,wDAA2D;AAC3D,gDAA2D;AAC3D,8DAAqE;AAErE,oDAAmD;AACnD,qDAAoD;AAEpD,IAAM,0BAA0B,GAAG,kBAAkB,CAAC;AACtD,IAAM,uBAAuB,GAAG,SAAS,CAAC;AAC1C,IAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAChD,IAAM,oBAAoB,GAAG,cAAc,CAAC;AAC5C,IAAM,kBAAkB,GAAG,YAAY,CAAC;AACxC,IAAM,UAAU,GAAG,UAAU,CAAC;AAC9B,IAAM,sBAAsB,GAAG,YAAY,CAAC;AAE5C,+EAA+E;AAC/E,oDAAoD;AACpD,IAAM,qBAAqB,GAAgC;IACzD,WAAW,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC;IACnC,gBAAgB,EAAE,CAAC,GAAG,CAAC;IACvB,yBAAyB,EAAE,CAAC,GAAG,CAAC;IAChC,yBAAyB,EAAE,CAAC,GAAG,CAAC;IAChC,uBAAuB,EAAE,CAAC,GAAG,CAAC;CAC/B,CAAC;AAEF,IAAI,UAAU,GAAQ,EAAE,CAAC;AAEzB,IAAI;IACF,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CA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BACF,IAAA,YAAE,GAAE,CAAC;;;wBAEL,6FAA6F;wBAC7F,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;wBACjD,qBAAM,IAAI,CAAC,eAAe,CACxB,iBAAiB,EACjB,2DAA2D,CAC5D,EAAA;;wBAHD,SAGC,CAAC;wBACF,IAAA,aAAG,EACD,4BAAsB,YAAY,4BAAoB,iBAAiB,SAAO;4BAC5E,4FAA4F,CAC/F,CAAC;wBACF,IAAA,YAAE,GAAE,CAAC;;;;;;KAGV;IACH,aAAC;AAAD,CAAC,AAtXD,CAA4B,iCAAe,GAsX1C;AAtXY,wBAAM","sourcesContent":["/* eslint-disable max-lines */\nimport Chalk from 'chalk';\nimport * as fs from 'fs';\nimport type { Answers } from 'inquirer';\nimport { prompt } from 'inquirer';\nimport * as _ from 'lodash';\nimport * as path from 'path';\n\nimport type { Args } from '../../Constants';\nimport { debug, green, l, nl, red } from '../../Helper/Logging';\nimport { mergeConfigFile } from '../../Helper/MergeConfig';\nimport { checkPackageVersion } from '../../Helper/Package';\nimport { getPackageMangerChoice } from '../../Helper/PackageManager';\nimport type { SentryCliProps } from '../../Helper/SentryCli';\nimport { SentryCli } from '../../Helper/SentryCli';\nimport { BaseIntegration } from './BaseIntegration';\n\nconst COMPATIBLE_NEXTJS_VERSIONS = '>=10.0.8 <14.0.0';\nconst COMPATIBLE_SDK_VERSIONS = '>=7.3.0';\nconst PROPERTIES_FILENAME = 'sentry.properties';\nconst SENTRYCLIRC_FILENAME = '.sentryclirc';\nconst GITIGNORE_FILENAME = '.gitignore';\nconst CONFIG_DIR = 'configs/';\nconst MERGEABLE_CONFIG_INFIX = 'wizardcopy';\n\n// for those files which can go in more than one place, the list of places they\n// could go (the first one which works will be used)\nconst TEMPLATE_DESTINATIONS: { [key: string]: string[] } = {\n '_error.js': ['pages', 'src/pages'],\n 'next.config.js': ['.'],\n 'sentry.server.config.js': ['.'],\n 'sentry.client.config.js': ['.'],\n 'sentry.edge.config.js': ['.'],\n};\n\nlet appPackage: any = {};\n\ntry {\n appPackage = require(path.join(process.cwd(), 'package.json'));\n} catch {\n // We don't need to have this\n}\n\nexport class NextJs extends BaseIntegration {\n protected _sentryCli: SentryCli;\n\n public constructor(protected _argv: Args) {\n super(_argv);\n this._sentryCli = new SentryCli(this._argv);\n }\n\n public async emit(answers: Answers): Promise<Answers> {\n const dsn = _.get(answers, ['config', 'dsn', 'public'], null);\n nl();\n\n const sentryCliProps = this._sentryCli.convertAnswersToProperties(answers);\n await this._createSentryCliConfig(sentryCliProps);\n\n const templateDirectory = path.join(__dirname, '..', '..', '..', 'NextJs');\n const configDirectory = path.join(templateDirectory, CONFIG_DIR);\n\n if (fs.existsSync(configDirectory)) {\n await this._createNextConfig(configDirectory, dsn);\n } else {\n debug(\n `Couldn't find ${configDirectory}, probably because you ran this from inside of \\`/lib\\` rather than \\`/dist\\``,\n );\n nl();\n }\n\n const selectedProjectSlug: string | null = answers.config?.project?.slug;\n if (selectedProjectSlug) {\n const hasFirstEvent = answers.wizard?.projects?.find?.(\n (p: { slug: string }) => p.slug === selectedProjectSlug,\n )?.firstEvent;\n if (!hasFirstEvent) {\n await this._setTemplate(\n templateDirectory,\n 'sentry_sample_error.js',\n ['pages', 'src/pages'],\n dsn,\n );\n l(\n Chalk.bgYellowBright(`\n|------------------------------------------------------------------------|\n| Installation Complete |\n| To verify your installation and finish onboarding, launch your Next.js |\n| application, navigate to http://localhost:3000/sentry_sample_error |\n| and send us a sample error. |\n|------------------------------------------------------------------------|\n`),\n );\n }\n }\n\n l(\n 'For more information, see https://docs.sentry.io/platforms/javascript/guides/nextjs/',\n );\n nl();\n\n return {};\n }\n\n public async shouldConfigure(_answers: Answers): Promise<Answers> {\n if (this._shouldConfigure) {\n return this._shouldConfigure;\n }\n\n nl();\n\n let userAnswers: Answers = { continue: true };\n const hasCompatibleNextjsVersion = checkPackageVersion(\n appPackage,\n 'next',\n COMPATIBLE_NEXTJS_VERSIONS,\n true,\n );\n\n const packageManager = getPackageMangerChoice();\n const hasSdkInstalled = this._hasPackageInstalled('@sentry/nextjs');\n\n let hasCompatibleSdkVersion = false;\n // if no package but we have nextjs, let's add it if we can\n if (!hasSdkInstalled && packageManager && hasCompatibleNextjsVersion) {\n await packageManager.installPackage('@sentry/nextjs');\n // can assume it's compatible since we just installed it\n hasCompatibleSdkVersion = true;\n } else {\n // otherwise, let's check the version and spit out the appropriate error\n hasCompatibleSdkVersion = checkPackageVersion(\n appPackage,\n '@sentry/nextjs',\n COMPATIBLE_SDK_VERSIONS,\n true,\n );\n }\n const hasAllPackagesCompatible =\n hasCompatibleNextjsVersion && hasCompatibleSdkVersion;\n\n if (!hasAllPackagesCompatible && !this._argv.quiet) {\n userAnswers = await prompt({\n message:\n 'There were errors during your project checkup, do you still want to continue?',\n name: 'continue',\n default: false,\n type: 'confirm',\n });\n }\n\n nl();\n\n if (!userAnswers['continue']) {\n throw new Error('Please install the required dependencies to continue.');\n }\n\n this._shouldConfigure = Promise.resolve({ nextjs: true });\n // eslint-disable-next-line @typescript-eslint/unbound-method\n return this.shouldConfigure;\n }\n\n private async _createSentryCliConfig(\n cliProps: SentryCliProps,\n ): Promise<void> {\n const { 'auth/token': authToken, ...cliPropsToWrite } = cliProps;\n\n /**\n * To not commit the auth token to the VCS, instead of adding it to the\n * properties file (like the rest of props), it's added to the Sentry CLI\n * config, which is added to the gitignore. This way makes the properties\n * file safe to commit without exposing any auth tokens.\n */\n if (authToken) {\n try {\n await fs.promises.appendFile(\n SENTRYCLIRC_FILENAME,\n this._sentryCli.dumpConfig({ auth: { token: authToken } }),\n );\n green(`✓ Successfully added the auth token to ${SENTRYCLIRC_FILENAME}`);\n } catch {\n red(\n `⚠ Could not add the auth token to ${SENTRYCLIRC_FILENAME}, ` +\n `please add it to identify your user account:\\n${authToken}`,\n );\n nl();\n }\n } else {\n red(\n `⚠ Did not find an auth token, please add your token to ${SENTRYCLIRC_FILENAME}`,\n );\n l(\n 'To generate an auth token, visit https://sentry.io/settings/account/api/auth-tokens/',\n );\n l(\n 'To learn how to configure Sentry CLI, visit ' +\n 'https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli',\n );\n }\n\n await this._addToGitignore(\n SENTRYCLIRC_FILENAME,\n `⚠ Could not add ${SENTRYCLIRC_FILENAME} to ${GITIGNORE_FILENAME}, ` +\n 'please add it to not commit your auth key.',\n );\n\n try {\n await fs.promises.writeFile(\n `./${PROPERTIES_FILENAME}`,\n this._sentryCli.dumpProperties(cliPropsToWrite),\n );\n green('✓ Successfully created sentry.properties');\n } catch {\n red(`⚠ Could not add org and project data to ${PROPERTIES_FILENAME}`);\n l(\n 'See docs for a manual setup: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli',\n );\n }\n nl();\n }\n\n private async _addToGitignore(\n filepath: string,\n errorMsg: string,\n ): Promise<void> {\n /**\n * Don't check whether the given file is ignored because:\n * 1. It's tricky to check it without git.\n * 2. Git might not be installed or accessible.\n * 3. It's convenient to use a module to interact with git, but it would\n * increase the size x2 approximately. Docs say to run the Wizard without\n * installing it, and duplicating the size would slow the set-up down.\n * 4. The Wizard is meant to be run once.\n * 5. A message is logged informing users it's been added to the gitignore.\n * 6. It will be added to the gitignore as many times as it runs - not a big\n * deal.\n * 7. It's straightforward to remove it from the gitignore.\n */\n try {\n await fs.promises.appendFile(\n GITIGNORE_FILENAME,\n `\\n# Sentry\\n${filepath}\\n`,\n );\n green(`✓ ${filepath} added to ${GITIGNORE_FILENAME}`);\n } catch {\n red(errorMsg);\n }\n }\n\n private async _createNextConfig(\n configDirectory: string,\n dsn: any,\n ): Promise<void> {\n const templates = fs.readdirSync(configDirectory);\n // next.config.template.js used for merging next.config.js , not its own template,\n // so it shouldn't have a setTemplate call\n const filteredTemplates = templates.filter(\n (template) => template !== 'next.config.template.js',\n );\n for (const template of filteredTemplates) {\n await this._setTemplate(\n configDirectory,\n template,\n TEMPLATE_DESTINATIONS[template],\n dsn,\n );\n }\n red(\n '⚠ Performance monitoring is enabled capturing 100% of transactions.\\n' +\n ' Learn more in https://docs.sentry.io/product/performance/',\n );\n nl();\n }\n\n private async _setTemplate(\n configDirectory: string,\n templateFile: string,\n destinationOptions: string[],\n dsn: string,\n ): Promise<void> {\n const templatePath = path.join(configDirectory, templateFile);\n\n for (const destinationDir of destinationOptions) {\n if (!fs.existsSync(destinationDir)) {\n continue;\n }\n const destinationPath = path.join(destinationDir, templateFile);\n // in case the file in question already exists, we'll make a copy with\n // `MERGEABLE_CONFIG_INFIX` inserted just before the extension, so as not\n // to overwrite the existing file\n const mergeableFilePath = path.join(\n destinationDir,\n this._spliceInPlace(\n templateFile.split('.'),\n -1,\n 0,\n MERGEABLE_CONFIG_INFIX,\n ).join('.'),\n );\n\n if (templateFile === 'next.config.js') {\n await this._mergeNextConfig(\n destinationPath,\n templatePath,\n destinationDir,\n templateFile,\n configDirectory,\n mergeableFilePath,\n );\n return;\n } else {\n if (!fs.existsSync(destinationPath)) {\n this._fillAndCopyTemplate(templatePath, destinationPath, dsn);\n } else if (!fs.existsSync(mergeableFilePath)) {\n this._fillAndCopyTemplate(templatePath, mergeableFilePath, dsn);\n red(\n `File \\`${templateFile}\\` already exists, so created \\`${mergeableFilePath}\\`.\\n` +\n 'Please merge those files.',\n );\n nl();\n } else {\n red(\n `Both \\`${templateFile}\\` and \\`${mergeableFilePath}\\` already exist.\\n` +\n 'Please merge those files.',\n );\n nl();\n }\n return;\n }\n }\n\n red(\n `Could not find appropriate destination for \\`${templateFile}\\`. Tried: ${destinationOptions}.`,\n );\n nl();\n }\n\n private _fillAndCopyTemplate(\n sourcePath: string,\n targetPath: string,\n dsn: string,\n ): void {\n const templateContent = fs.readFileSync(sourcePath).toString();\n const filledTemplate = templateContent.replace('___DSN___', dsn);\n fs.writeFileSync(targetPath, filledTemplate);\n }\n\n private _hasPackageInstalled(packageName: string): boolean {\n const depsVersion = _.get(appPackage, ['dependencies', packageName]);\n const devDepsVersion = _.get(appPackage, ['devDependencies', packageName]);\n return !!depsVersion || !!devDepsVersion;\n }\n\n private _spliceInPlace(\n arr: Array<any>,\n start: number,\n deleteCount: number,\n ...inserts: any[]\n ): Array<any> {\n arr.splice(start, deleteCount, ...inserts);\n return arr;\n }\n\n private async _mergeNextConfig(\n destinationPath: string,\n templatePath: string,\n destinationDir: string,\n templateFile: string,\n configDirectory: string,\n mergeableFilePath: string,\n ): Promise<void> {\n // if no next.config.js exists, we'll create one\n if (!fs.existsSync(destinationPath)) {\n fs.copyFileSync(templatePath, destinationPath);\n green('Created File `next.config.js`');\n nl();\n } else {\n // creates a file name for the copy of the original next.config.js file\n // with the name `next.config.original.js`\n const originalFileName = this._spliceInPlace(\n templateFile.split('.'),\n -1,\n 0,\n 'original',\n ).join('.');\n const originalFilePath = path.join(destinationDir, originalFileName);\n // makes copy of original next.config.js\n fs.writeFileSync(originalFilePath, fs.readFileSync(destinationPath));\n await this._addToGitignore(\n originalFilePath,\n 'Unable to add next.config.original.js to gitignore',\n );\n\n const mergedTemplatePath = path.join(\n configDirectory,\n 'next.config.template.js',\n );\n // attempts to merge with existing next.config.js, if true -> success\n if (mergeConfigFile(destinationPath, mergedTemplatePath)) {\n green(\n `Updated \\`${templateFile}\\` with Sentry. The original ${templateFile} was saved as \\`next.config.original.js\\`.\\n` +\n 'Information on the changes made to the Next.js configuration file an be found at https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/',\n );\n nl();\n } else {\n // if merge fails, we'll create a copy of the `next.config.js` template and ask them to merge\n fs.copyFileSync(templatePath, mergeableFilePath);\n await this._addToGitignore(\n mergeableFilePath,\n 'Unable to add next.config.wizard.js template to gitignore',\n );\n red(\n `Unable to merge \\`${templateFile}\\`, so created \\`${mergeableFilePath}\\`.\\n` +\n 'Please integrate next.config.wizardcopy.js into your next.config.js or next.config.ts file',\n );\n nl();\n }\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { Answers } from 'inquirer';
|
|
2
|
-
import { Args } from '../../Constants';
|
|
1
|
+
import type { Answers } from 'inquirer';
|
|
2
|
+
import type { Args } from '../../Constants';
|
|
3
3
|
import { SentryCli } from '../../Helper/SentryCli';
|
|
4
4
|
import { MobileProject } from './MobileProject';
|
|
5
|
+
export declare const COMPATIBLE_REACT_NATIVE_VERSIONS = ">=0.69.0";
|
|
6
|
+
export declare const COMPATIBLE_SDK_VERSION = ">= 5.0.0";
|
|
7
|
+
export declare const SENTRY_REACT_NATIVE_PACKAGE = "@sentry/react-native";
|
|
8
|
+
export declare const REACT_NATIVE_PACKAGE = "react-native";
|
|
9
|
+
export declare const DOCS_MANUAL_STEPS = "https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/";
|
|
5
10
|
export declare class ReactNative extends MobileProject {
|
|
6
11
|
protected _argv: Args;
|
|
7
12
|
/**
|
|
@@ -14,6 +19,8 @@ export declare class ReactNative extends MobileProject {
|
|
|
14
19
|
emit(answers: Answers): Promise<Answers>;
|
|
15
20
|
uninstall(_answers: Answers): Promise<Answers>;
|
|
16
21
|
protected _shouldConfigurePlatform(platform: string): Promise<boolean>;
|
|
22
|
+
private _readAppPackage;
|
|
23
|
+
private _podInstall;
|
|
17
24
|
private _patchJsSentryInit;
|
|
18
25
|
private _addSentryProperties;
|
|
19
26
|
private _patchJs;
|