@sentry/wizard 2.7.0 → 3.1.0-beta.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 +16 -3
- package/bin.ts +9 -2
- package/dist/NextJs/configs/next.config.template.js +1 -1
- package/dist/bin.js +16 -4
- 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/MergeConfig.js +1 -0
- package/dist/lib/Helper/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/Package.js +10 -10
- package/dist/lib/Helper/Package.js.map +1 -1
- package/dist/lib/Helper/PackageManager.js +6 -9
- package/dist/lib/Helper/PackageManager.js.map +1 -1
- 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 +11 -11
- 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 +9 -9
- 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 +7 -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 +7 -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 +13 -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 +25 -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 +8 -5
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/Integrations/NextJs.d.ts +2 -2
- package/dist/lib/Steps/Integrations/NextJs.js +57 -52
- package/dist/lib/Steps/Integrations/NextJs.js.map +1 -1
- package/dist/lib/Steps/Integrations/ReactNative.d.ts +2 -2
- package/dist/lib/Steps/Integrations/ReactNative.js +54 -52
- package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +1 -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 +8 -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 +47 -50
- package/dist/lib/Steps/WaitForSentry.js.map +1 -1
- package/dist/lib/Steps/Welcome.d.ts +1 -1
- package/dist/lib/Steps/Welcome.js +8 -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 +1 -1
- package/dist/lib/__tests__/Setup.js.map +1 -1
- package/dist/src/clack-utils.d.ts +40 -0
- package/dist/src/clack-utils.js +329 -0
- package/dist/src/clack-utils.js.map +1 -0
- package/dist/src/nextjs-wizard.d.ts +5 -0
- package/dist/src/nextjs-wizard.js +346 -0
- package/dist/src/nextjs-wizard.js.map +1 -0
- package/lib/Helper/File.ts +2 -8
- package/lib/Helper/MergeConfig.ts +1 -0
- package/lib/Helper/SentryCli.ts +3 -3
- package/lib/Helper/Wizard.ts +6 -5
- package/lib/Helper/__tests__/File.ts +5 -5
- 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 +4 -4
- package/lib/Steps/ChooseIntegration.ts +2 -1
- package/lib/Steps/ConfigureProject.ts +1 -1
- package/lib/Steps/Initial.ts +2 -1
- package/lib/Steps/Integrations/BaseIntegration.ts +5 -3
- package/lib/Steps/Integrations/Cordova.ts +7 -6
- package/lib/Steps/Integrations/Electron.ts +10 -7
- package/lib/Steps/Integrations/MobileProject.ts +3 -1
- package/lib/Steps/Integrations/NextJs.ts +8 -6
- package/lib/Steps/Integrations/ReactNative.ts +47 -26
- package/lib/Steps/Integrations/__tests__/ReactNative.ts +3 -2
- package/lib/Steps/OpenSentry.ts +1 -1
- package/lib/Steps/PromptForParameters.ts +3 -2
- package/lib/Steps/Result.ts +2 -1
- package/lib/Steps/SentryProjectSelector.ts +3 -2
- package/lib/Steps/ShouldConfigure.ts +1 -1
- package/lib/Steps/WaitForSentry.ts +4 -4
- package/lib/Steps/Welcome.ts +3 -2
- package/lib/__tests__/Setup.ts +1 -1
- package/package.json +17 -14
- package/scripts/NextJs/configs/next.config.template.js +1 -1
- package/src/clack-utils.ts +346 -0
- package/src/nextjs-wizard.ts +619 -0
|
@@ -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,12 +61,14 @@ 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;
|
|
@@ -119,7 +123,7 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
119
123
|
switch (_g.label) {
|
|
120
124
|
case 0:
|
|
121
125
|
dsn = _.get(answers, ['config', 'dsn', 'public'], null);
|
|
122
|
-
Logging_1.nl();
|
|
126
|
+
(0, Logging_1.nl)();
|
|
123
127
|
sentryCliProps = this._sentryCli.convertAnswersToProperties(answers);
|
|
124
128
|
return [4 /*yield*/, this._createSentryCliConfig(sentryCliProps)];
|
|
125
129
|
case 1:
|
|
@@ -132,8 +136,8 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
132
136
|
_g.sent();
|
|
133
137
|
return [3 /*break*/, 4];
|
|
134
138
|
case 3:
|
|
135
|
-
Logging_1.debug("Couldn't find "
|
|
136
|
-
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)();
|
|
137
141
|
_g.label = 4;
|
|
138
142
|
case 4:
|
|
139
143
|
selectedProjectSlug = (_b = (_a = answers.config) === null || _a === void 0 ? void 0 : _a.project) === null || _b === void 0 ? void 0 : _b.slug;
|
|
@@ -143,11 +147,11 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
143
147
|
return [4 /*yield*/, this._setTemplate(templateDirectory, 'sentry_sample_error.js', ['pages', 'src/pages'], dsn)];
|
|
144
148
|
case 5:
|
|
145
149
|
_g.sent();
|
|
146
|
-
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"));
|
|
147
151
|
_g.label = 6;
|
|
148
152
|
case 6:
|
|
149
|
-
Logging_1.l('For more information, see https://docs.sentry.io/platforms/javascript/guides/nextjs/');
|
|
150
|
-
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)();
|
|
151
155
|
return [2 /*return*/, {}];
|
|
152
156
|
}
|
|
153
157
|
});
|
|
@@ -159,13 +163,14 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
159
163
|
return __generator(this, function (_a) {
|
|
160
164
|
switch (_a.label) {
|
|
161
165
|
case 0:
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
162
167
|
if (this._shouldConfigure) {
|
|
163
168
|
return [2 /*return*/, this._shouldConfigure];
|
|
164
169
|
}
|
|
165
|
-
Logging_1.nl();
|
|
170
|
+
(0, Logging_1.nl)();
|
|
166
171
|
userAnswers = { continue: true };
|
|
167
|
-
hasCompatibleNextjsVersion = Package_1.checkPackageVersion(appPackage, 'next', COMPATIBLE_NEXTJS_VERSIONS, true);
|
|
168
|
-
packageManager = PackageManager_1.getPackageMangerChoice();
|
|
172
|
+
hasCompatibleNextjsVersion = (0, Package_1.checkPackageVersion)(appPackage, 'next', COMPATIBLE_NEXTJS_VERSIONS, true);
|
|
173
|
+
packageManager = (0, PackageManager_1.getPackageMangerChoice)();
|
|
169
174
|
hasSdkInstalled = this._hasPackageInstalled('@sentry/nextjs');
|
|
170
175
|
hasCompatibleSdkVersion = false;
|
|
171
176
|
if (!(!hasSdkInstalled && packageManager && hasCompatibleNextjsVersion)) return [3 /*break*/, 2];
|
|
@@ -177,12 +182,12 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
177
182
|
return [3 /*break*/, 3];
|
|
178
183
|
case 2:
|
|
179
184
|
// otherwise, let's check the version and spit out the appropriate error
|
|
180
|
-
hasCompatibleSdkVersion = Package_1.checkPackageVersion(appPackage, '@sentry/nextjs', COMPATIBLE_SDK_VERSIONS, true);
|
|
185
|
+
hasCompatibleSdkVersion = (0, Package_1.checkPackageVersion)(appPackage, '@sentry/nextjs', COMPATIBLE_SDK_VERSIONS, true);
|
|
181
186
|
_a.label = 3;
|
|
182
187
|
case 3:
|
|
183
188
|
hasAllPackagesCompatible = hasCompatibleNextjsVersion && hasCompatibleSdkVersion;
|
|
184
189
|
if (!(!hasAllPackagesCompatible && !this._argv.quiet)) return [3 /*break*/, 5];
|
|
185
|
-
return [4 /*yield*/, inquirer_1.prompt({
|
|
190
|
+
return [4 /*yield*/, (0, inquirer_1.prompt)({
|
|
186
191
|
message: 'There were errors during your project checkup, do you still want to continue?',
|
|
187
192
|
name: 'continue',
|
|
188
193
|
default: false,
|
|
@@ -192,7 +197,7 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
192
197
|
userAnswers = _a.sent();
|
|
193
198
|
_a.label = 5;
|
|
194
199
|
case 5:
|
|
195
|
-
Logging_1.nl();
|
|
200
|
+
(0, Logging_1.nl)();
|
|
196
201
|
if (!userAnswers['continue']) {
|
|
197
202
|
throw new Error('Please install the required dependencies to continue.');
|
|
198
203
|
}
|
|
@@ -217,40 +222,40 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
217
222
|
return [4 /*yield*/, fs.promises.appendFile(SENTRYCLIRC_FILENAME, this._sentryCli.dumpConfig({ auth: { token: authToken } }))];
|
|
218
223
|
case 2:
|
|
219
224
|
_c.sent();
|
|
220
|
-
Logging_1.green("\u2713 Successfully added the auth token to "
|
|
225
|
+
(0, Logging_1.green)("\u2713 Successfully added the auth token to ".concat(SENTRYCLIRC_FILENAME));
|
|
221
226
|
return [3 /*break*/, 4];
|
|
222
227
|
case 3:
|
|
223
228
|
_a = _c.sent();
|
|
224
|
-
Logging_1.red("\u26A0 Could not add the auth token to "
|
|
225
|
-
|
|
226
|
-
Logging_1.nl();
|
|
229
|
+
(0, Logging_1.red)("\u26A0 Could not add the auth token to ".concat(SENTRYCLIRC_FILENAME, ", ") +
|
|
230
|
+
"please add it to identify your user account:\n".concat(authToken));
|
|
231
|
+
(0, Logging_1.nl)();
|
|
227
232
|
return [3 /*break*/, 4];
|
|
228
233
|
case 4: return [3 /*break*/, 6];
|
|
229
234
|
case 5:
|
|
230
|
-
Logging_1.red("\u26A0 Did not find an auth token, please add your token to "
|
|
231
|
-
Logging_1.l('To generate an auth token, visit https://sentry.io/settings/account/api/auth-tokens/');
|
|
232
|
-
Logging_1.l('To learn how to configure Sentry CLI, visit ' +
|
|
235
|
+
(0, Logging_1.red)("\u26A0 Did not find an auth token, please add your token to ".concat(SENTRYCLIRC_FILENAME));
|
|
236
|
+
(0, Logging_1.l)('To generate an auth token, visit https://sentry.io/settings/account/api/auth-tokens/');
|
|
237
|
+
(0, Logging_1.l)('To learn how to configure Sentry CLI, visit ' +
|
|
233
238
|
'https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli');
|
|
234
239
|
_c.label = 6;
|
|
235
|
-
case 6: return [4 /*yield*/, this._addToGitignore(SENTRYCLIRC_FILENAME, "\u26A0 Could not add "
|
|
240
|
+
case 6: return [4 /*yield*/, this._addToGitignore(SENTRYCLIRC_FILENAME, "\u26A0 Could not add ".concat(SENTRYCLIRC_FILENAME, " to ").concat(GITIGNORE_FILENAME, ", ") +
|
|
236
241
|
'please add it to not commit your auth key.')];
|
|
237
242
|
case 7:
|
|
238
243
|
_c.sent();
|
|
239
244
|
_c.label = 8;
|
|
240
245
|
case 8:
|
|
241
246
|
_c.trys.push([8, 10, , 11]);
|
|
242
|
-
return [4 /*yield*/, fs.promises.writeFile("./"
|
|
247
|
+
return [4 /*yield*/, fs.promises.writeFile("./".concat(PROPERTIES_FILENAME), this._sentryCli.dumpProperties(cliPropsToWrite))];
|
|
243
248
|
case 9:
|
|
244
249
|
_c.sent();
|
|
245
|
-
Logging_1.green(
|
|
250
|
+
(0, Logging_1.green)('✓ Successfully created sentry.properties');
|
|
246
251
|
return [3 /*break*/, 11];
|
|
247
252
|
case 10:
|
|
248
253
|
_b = _c.sent();
|
|
249
|
-
Logging_1.red("\u26A0 Could not add org and project data to "
|
|
250
|
-
Logging_1.l('See docs for a manual setup: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli');
|
|
254
|
+
(0, Logging_1.red)("\u26A0 Could not add org and project data to ".concat(PROPERTIES_FILENAME));
|
|
255
|
+
(0, Logging_1.l)('See docs for a manual setup: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-sentry-cli');
|
|
251
256
|
return [3 /*break*/, 11];
|
|
252
257
|
case 11:
|
|
253
|
-
Logging_1.nl();
|
|
258
|
+
(0, Logging_1.nl)();
|
|
254
259
|
return [2 /*return*/];
|
|
255
260
|
}
|
|
256
261
|
});
|
|
@@ -263,14 +268,14 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
263
268
|
switch (_b.label) {
|
|
264
269
|
case 0:
|
|
265
270
|
_b.trys.push([0, 2, , 3]);
|
|
266
|
-
return [4 /*yield*/, fs.promises.appendFile(GITIGNORE_FILENAME, "\n# Sentry\n"
|
|
271
|
+
return [4 /*yield*/, fs.promises.appendFile(GITIGNORE_FILENAME, "\n# Sentry\n".concat(filepath, "\n"))];
|
|
267
272
|
case 1:
|
|
268
273
|
_b.sent();
|
|
269
|
-
Logging_1.green("\u2713 "
|
|
274
|
+
(0, Logging_1.green)("\u2713 ".concat(filepath, " added to ").concat(GITIGNORE_FILENAME));
|
|
270
275
|
return [3 /*break*/, 3];
|
|
271
276
|
case 2:
|
|
272
277
|
_a = _b.sent();
|
|
273
|
-
Logging_1.red(errorMsg);
|
|
278
|
+
(0, Logging_1.red)(errorMsg);
|
|
274
279
|
return [3 /*break*/, 3];
|
|
275
280
|
case 3: return [2 /*return*/];
|
|
276
281
|
}
|
|
@@ -298,9 +303,9 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
298
303
|
_i++;
|
|
299
304
|
return [3 /*break*/, 1];
|
|
300
305
|
case 4:
|
|
301
|
-
Logging_1.red('⚠ Performance monitoring is enabled capturing 100% of transactions.\n' +
|
|
306
|
+
(0, Logging_1.red)('⚠ Performance monitoring is enabled capturing 100% of transactions.\n' +
|
|
302
307
|
' Learn more in https://docs.sentry.io/product/performance/');
|
|
303
|
-
Logging_1.nl();
|
|
308
|
+
(0, Logging_1.nl)();
|
|
304
309
|
return [2 /*return*/];
|
|
305
310
|
}
|
|
306
311
|
});
|
|
@@ -334,22 +339,22 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
334
339
|
}
|
|
335
340
|
else if (!fs.existsSync(mergeableFilePath)) {
|
|
336
341
|
this._fillAndCopyTemplate(templatePath, mergeableFilePath, dsn);
|
|
337
|
-
Logging_1.red("File `"
|
|
342
|
+
(0, Logging_1.red)("File `".concat(templateFile, "` already exists, so created `").concat(mergeableFilePath, "`.\n") +
|
|
338
343
|
'Please merge those files.');
|
|
339
|
-
Logging_1.nl();
|
|
344
|
+
(0, Logging_1.nl)();
|
|
340
345
|
}
|
|
341
346
|
else {
|
|
342
|
-
Logging_1.red("Both `"
|
|
347
|
+
(0, Logging_1.red)("Both `".concat(templateFile, "` and `").concat(mergeableFilePath, "` already exist.\n") +
|
|
343
348
|
'Please merge those files.');
|
|
344
|
-
Logging_1.nl();
|
|
349
|
+
(0, Logging_1.nl)();
|
|
345
350
|
}
|
|
346
351
|
return [2 /*return*/];
|
|
347
352
|
case 4:
|
|
348
353
|
_i++;
|
|
349
354
|
return [3 /*break*/, 1];
|
|
350
355
|
case 5:
|
|
351
|
-
Logging_1.red("Could not find appropriate destination for `"
|
|
352
|
-
Logging_1.nl();
|
|
356
|
+
(0, Logging_1.red)("Could not find appropriate destination for `".concat(templateFile, "`. Tried: ").concat(destinationOptions, "."));
|
|
357
|
+
(0, Logging_1.nl)();
|
|
353
358
|
return [2 /*return*/];
|
|
354
359
|
}
|
|
355
360
|
});
|
|
@@ -370,7 +375,7 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
370
375
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
371
376
|
inserts[_i - 3] = arguments[_i];
|
|
372
377
|
}
|
|
373
|
-
arr.splice.apply(arr,
|
|
378
|
+
arr.splice.apply(arr, __spreadArray([start, deleteCount], inserts, false));
|
|
374
379
|
return arr;
|
|
375
380
|
};
|
|
376
381
|
NextJs.prototype._mergeNextConfig = function (destinationPath, templatePath, destinationDir, templateFile, configDirectory, mergeableFilePath) {
|
|
@@ -381,8 +386,8 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
381
386
|
case 0:
|
|
382
387
|
if (!!fs.existsSync(destinationPath)) return [3 /*break*/, 1];
|
|
383
388
|
fs.copyFileSync(templatePath, destinationPath);
|
|
384
|
-
Logging_1.green('Created File `next.config.js`');
|
|
385
|
-
Logging_1.nl();
|
|
389
|
+
(0, Logging_1.green)('Created File `next.config.js`');
|
|
390
|
+
(0, Logging_1.nl)();
|
|
386
391
|
return [3 /*break*/, 5];
|
|
387
392
|
case 1:
|
|
388
393
|
originalFileName = this._spliceInPlace(templateFile.split('.'), -1, 0, 'original').join('.');
|
|
@@ -393,10 +398,10 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
393
398
|
case 2:
|
|
394
399
|
_a.sent();
|
|
395
400
|
mergedTemplatePath = path.join(configDirectory, 'next.config.template.js');
|
|
396
|
-
if (!MergeConfig_1.mergeConfigFile(destinationPath, mergedTemplatePath)) return [3 /*break*/, 3];
|
|
397
|
-
Logging_1.green("Updated `"
|
|
401
|
+
if (!(0, MergeConfig_1.mergeConfigFile)(destinationPath, mergedTemplatePath)) return [3 /*break*/, 3];
|
|
402
|
+
(0, Logging_1.green)("Updated `".concat(templateFile, "` with Sentry. The original ").concat(templateFile, " was saved as `next.config.original.js`.\n") +
|
|
398
403
|
'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/');
|
|
399
|
-
Logging_1.nl();
|
|
404
|
+
(0, Logging_1.nl)();
|
|
400
405
|
return [3 /*break*/, 5];
|
|
401
406
|
case 3:
|
|
402
407
|
// if merge fails, we'll create a copy of the `next.config.js` template and ask them to merge
|
|
@@ -404,9 +409,9 @@ var NextJs = /** @class */ (function (_super) {
|
|
|
404
409
|
return [4 /*yield*/, this._addToGitignore(mergeableFilePath, 'Unable to add next.config.wizard.js template to gitignore')];
|
|
405
410
|
case 4:
|
|
406
411
|
_a.sent();
|
|
407
|
-
Logging_1.red("Unable to merge `"
|
|
412
|
+
(0, Logging_1.red)("Unable to merge `".concat(templateFile, "`, so created `").concat(mergeableFilePath, "`.\n") +
|
|
408
413
|
'Please integrate next.config.wizardcopy.js into your next.config.js or next.config.ts file');
|
|
409
|
-
Logging_1.nl();
|
|
414
|
+
(0, Logging_1.nl)();
|
|
410
415
|
_a.label = 5;
|
|
411
416
|
case 5: return [2 /*return*/];
|
|
412
417
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextJs.js","sourceRoot":"","sources":["../../../../lib/Steps/Integrations/NextJs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+BAA0B;AAC1B,uBAAyB;AACzB,qCAA2C;AAC3C,0BAA4B;AAC5B,2BAA6B;AAI7B,gDAAgE;AAChE,wDAA2D;AAC3D,gDAA2D;AAC3D,8DAAqE;AACrE,oDAAmE;AACnE,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,G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ACD,uBAAsB,YAAY,uBAAoB,iBAAiB,SAAO;4BAC5E,4FAA4F,CAC/F,CAAC;wBACF,YAAE,EAAE,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 { Answers, prompt } from 'inquirer';\nimport * as _ from 'lodash';\nimport * as path from 'path';\nimport { satisfies, subset, valid, validRange } from 'semver';\n\nimport { 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 { SentryCli, SentryCliProps } 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 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
|
+
{"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,g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AAC;wBACvC,IAAA,YAAE,GAAE,CAAC;;;wBAIC,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAC1C,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,EACvB,CAAC,CAAC,EACF,CAAC,EACD,UAAU,CACX,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;wBACN,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;wBACrE,wCAAwC;wBACxC,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC;wBACrE,qBAAM,IAAI,CAAC,eAAe,CACxB,gBAAgB,EAChB,oDAAoD,CACrD,EAAA;;wBAHD,SAGC,CAAC;wBAEI,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAClC,eAAe,EACf,yBAAyB,CAC1B,CAAC;6BAEE,IAAA,6BAAe,EAAC,eAAe,EAAE,kBAAkB,CAAC,EAApD,wBAAoD;wBACtD,IAAA,eAAK,EACH,mBAAa,YAAY,yCAAgC,YAAY,+CAA8C;4BACjH,0JAA0J,CAC7J,CAAC;wBACF,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,AAvXD,CAA4B,iCAAe,GAuX1C;AAvXY,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 // eslint-disable-next-line @typescript-eslint/no-misused-promises\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,5 +1,5 @@
|
|
|
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
5
|
export declare const COMPATIBLE_REACT_NATIVE_VERSIONS = ">=0.69.0";
|