@sentry/wizard 3.13.0 → 3.14.1
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 +11 -1
- package/dist/package.json +2 -2
- package/dist/src/android/android-wizard.js +2 -4
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +1 -1
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.d.ts +1 -0
- package/dist/src/nextjs/nextjs-wizard.js +252 -161
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/utils.d.ts +1 -0
- package/dist/src/nextjs/utils.js +25 -0
- package/dist/src/nextjs/utils.js.map +1 -0
- package/dist/src/remix/remix-wizard.js +5 -7
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +10 -4
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +7 -3
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +6 -10
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/telemetry.d.ts +1 -0
- package/dist/src/telemetry.js +27 -12
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +11 -1
- package/dist/src/utils/clack-utils.js +190 -126
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-manager.js +12 -7
- package/dist/src/utils/package-manager.js.map +1 -1
- package/package.json +2 -2
- package/src/android/android-wizard.ts +4 -5
- package/src/apple/apple-wizard.ts +2 -2
- package/src/nextjs/nextjs-wizard.ts +262 -195
- package/src/nextjs/utils.ts +21 -0
- package/src/remix/remix-wizard.ts +7 -9
- package/src/remix/sdk-setup.ts +12 -3
- package/src/sourcemaps/sourcemaps-wizard.ts +2 -2
- package/src/sveltekit/sdk-setup.ts +6 -3
- package/src/sveltekit/sveltekit-wizard.ts +9 -12
- package/src/telemetry.ts +22 -11
- package/src/utils/clack-utils.ts +177 -107
- package/src/utils/package-manager.ts +12 -6
|
@@ -71,7 +71,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
71
71
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
72
72
|
};
|
|
73
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
-
exports.createNewConfigFile = exports.makeCodeSnippet = exports.showCopyPasteInstructions = exports.askForToolConfigPath = exports.getOrAskForProjectData = exports.isUsingTypeScript = exports.getPackageDotJson = exports.ensurePackageIsInstalled = exports.addDotEnvSentryBuildPluginFile = exports.addSentryCliConfig = exports.installPackage = exports.askForItemSelection = exports.askToInstallSentryCLI = exports.
|
|
74
|
+
exports.createNewConfigFile = exports.makeCodeSnippet = exports.showCopyPasteInstructions = exports.askForToolConfigPath = exports.getOrAskForProjectData = exports.isUsingTypeScript = exports.getPackageDotJson = exports.ensurePackageIsInstalled = exports.addDotEnvSentryBuildPluginFile = exports.addSentryCliConfig = exports.installPackage = exports.askForItemSelection = exports.askToInstallSentryCLI = exports.confirmContinueIfNoOrDirtyGitRepo = exports.printWelcome = exports.abortIfCancelled = exports.abort = exports.sourceMapsCliSetupConfig = exports.SENTRY_PROPERTIES_FILE = exports.SENTRY_CLI_RC_FILE = exports.SENTRY_DOT_ENV_FILE = void 0;
|
|
75
75
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
76
76
|
var clack = __importStar(require("@clack/prompts"));
|
|
77
77
|
var axios_1 = __importDefault(require("axios"));
|
|
@@ -79,6 +79,7 @@ var chalk_1 = __importDefault(require("chalk"));
|
|
|
79
79
|
var childProcess = __importStar(require("child_process"));
|
|
80
80
|
var fs = __importStar(require("fs"));
|
|
81
81
|
var path = __importStar(require("path"));
|
|
82
|
+
var os = __importStar(require("os"));
|
|
82
83
|
var timers_1 = require("timers");
|
|
83
84
|
var url_1 = require("url");
|
|
84
85
|
var Sentry = __importStar(require("@sentry/node"));
|
|
@@ -188,37 +189,77 @@ function printWelcome(options) {
|
|
|
188
189
|
clack.note(welcomeText);
|
|
189
190
|
}
|
|
190
191
|
exports.printWelcome = printWelcome;
|
|
191
|
-
function
|
|
192
|
+
function confirmContinueIfNoOrDirtyGitRepo() {
|
|
192
193
|
return __awaiter(this, void 0, void 0, function () {
|
|
193
|
-
var
|
|
194
|
-
return __generator(this, function (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
var _this = this;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
return [2 /*return*/, (0, telemetry_1.traceStep)('check-git-status', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
197
|
+
var continueWithoutGit, uncommittedOrUntrackedFiles, continueWithDirtyRepo;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
if (!!isInGitRepo()) return [3 /*break*/, 3];
|
|
202
|
+
return [4 /*yield*/, abortIfCancelled(clack.confirm({
|
|
203
|
+
message: 'You are not inside a git repository. The wizard will create and update files. Do you want to continue anyway?',
|
|
204
|
+
}))];
|
|
205
|
+
case 1:
|
|
206
|
+
continueWithoutGit = _a.sent();
|
|
207
|
+
Sentry.setTag('continue-without-git', continueWithoutGit);
|
|
208
|
+
if (!!continueWithoutGit) return [3 /*break*/, 3];
|
|
209
|
+
return [4 /*yield*/, abort(undefined, 0)];
|
|
210
|
+
case 2:
|
|
211
|
+
_a.sent();
|
|
212
|
+
_a.label = 3;
|
|
213
|
+
case 3:
|
|
214
|
+
uncommittedOrUntrackedFiles = getUncommittedOrUntrackedFiles();
|
|
215
|
+
if (!uncommittedOrUntrackedFiles.length) return [3 /*break*/, 6];
|
|
216
|
+
clack.log.warn("You have uncommitted or untracked files in your repo:\n\n".concat(uncommittedOrUntrackedFiles.join('\n'), "\n\nThe wizard will create and update files."));
|
|
217
|
+
return [4 /*yield*/, abortIfCancelled(clack.confirm({
|
|
218
|
+
message: 'Do you want to continue anyway?',
|
|
219
|
+
}))];
|
|
220
|
+
case 4:
|
|
221
|
+
continueWithDirtyRepo = _a.sent();
|
|
222
|
+
Sentry.setTag('continue-with-dirty-repo', continueWithDirtyRepo);
|
|
223
|
+
if (!!continueWithDirtyRepo) return [3 /*break*/, 6];
|
|
224
|
+
return [4 /*yield*/, abort(undefined, 0)];
|
|
225
|
+
case 5:
|
|
226
|
+
_a.sent();
|
|
227
|
+
_a.label = 6;
|
|
228
|
+
case 6: return [2 /*return*/];
|
|
229
|
+
}
|
|
200
230
|
});
|
|
201
|
-
|
|
202
|
-
case 1:
|
|
203
|
-
_a = _b.sent();
|
|
204
|
-
return [4 /*yield*/, abortIfCancelled(clack.confirm({
|
|
205
|
-
message: 'You are not inside a git repository. The wizard will create and update files. Do you still want to continue?',
|
|
206
|
-
}))];
|
|
207
|
-
case 2:
|
|
208
|
-
continueWithoutGit = _b.sent();
|
|
209
|
-
Sentry.setTag('continue-without-git', continueWithoutGit);
|
|
210
|
-
if (!!continueWithoutGit) return [3 /*break*/, 4];
|
|
211
|
-
return [4 /*yield*/, abort(undefined, 0)];
|
|
212
|
-
case 3:
|
|
213
|
-
_b.sent();
|
|
214
|
-
_b.label = 4;
|
|
215
|
-
case 4: return [3 /*break*/, 5];
|
|
216
|
-
case 5: return [2 /*return*/];
|
|
217
|
-
}
|
|
231
|
+
}); })];
|
|
218
232
|
});
|
|
219
233
|
});
|
|
220
234
|
}
|
|
221
|
-
exports.
|
|
235
|
+
exports.confirmContinueIfNoOrDirtyGitRepo = confirmContinueIfNoOrDirtyGitRepo;
|
|
236
|
+
function isInGitRepo() {
|
|
237
|
+
try {
|
|
238
|
+
childProcess.execSync('git rev-parse --is-inside-work-tree', {
|
|
239
|
+
stdio: 'ignore',
|
|
240
|
+
});
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
catch (_a) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function getUncommittedOrUntrackedFiles() {
|
|
248
|
+
try {
|
|
249
|
+
var gitStatus = childProcess
|
|
250
|
+
.execSync('git status --porcelain=v1')
|
|
251
|
+
.toString();
|
|
252
|
+
var files = gitStatus
|
|
253
|
+
.split(os.EOL)
|
|
254
|
+
.map(function (line) { return line.trim(); })
|
|
255
|
+
.filter(Boolean)
|
|
256
|
+
.map(function (f) { return "- ".concat(f.split(/\s+/)[1]); });
|
|
257
|
+
return files;
|
|
258
|
+
}
|
|
259
|
+
catch (_a) {
|
|
260
|
+
return [];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
222
263
|
function askToInstallSentryCLI() {
|
|
223
264
|
return __awaiter(this, void 0, void 0, function () {
|
|
224
265
|
return __generator(this, function (_a) {
|
|
@@ -258,45 +299,50 @@ exports.askForItemSelection = askForItemSelection;
|
|
|
258
299
|
function installPackage(_a) {
|
|
259
300
|
var packageName = _a.packageName, alreadyInstalled = _a.alreadyInstalled, _b = _a.askBeforeUpdating, askBeforeUpdating = _b === void 0 ? true : _b;
|
|
260
301
|
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
-
var
|
|
302
|
+
var _this = this;
|
|
262
303
|
return __generator(this, function (_c) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
304
|
+
return [2 /*return*/, (0, telemetry_1.traceStep)('install-package', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
305
|
+
var shouldUpdatePackage, sdkInstallSpinner, packageManager, e_1;
|
|
306
|
+
return __generator(this, function (_a) {
|
|
307
|
+
switch (_a.label) {
|
|
308
|
+
case 0:
|
|
309
|
+
if (!(alreadyInstalled && askBeforeUpdating)) return [3 /*break*/, 2];
|
|
310
|
+
return [4 /*yield*/, abortIfCancelled(clack.confirm({
|
|
311
|
+
message: "The ".concat(chalk_1.default.bold.cyan(packageName), " package is already installed. Do you want to update it to the latest version?"),
|
|
312
|
+
}))];
|
|
313
|
+
case 1:
|
|
314
|
+
shouldUpdatePackage = _a.sent();
|
|
315
|
+
if (!shouldUpdatePackage) {
|
|
316
|
+
return [2 /*return*/];
|
|
317
|
+
}
|
|
318
|
+
_a.label = 2;
|
|
319
|
+
case 2:
|
|
320
|
+
sdkInstallSpinner = clack.spinner();
|
|
321
|
+
return [4 /*yield*/, getPackageManager()];
|
|
322
|
+
case 3:
|
|
323
|
+
packageManager = _a.sent();
|
|
324
|
+
sdkInstallSpinner.start("".concat(alreadyInstalled ? 'Updating' : 'Installing', " ").concat(chalk_1.default.bold.cyan(packageName), " with ").concat(chalk_1.default.bold(packageManager.label), "."));
|
|
325
|
+
_a.label = 4;
|
|
326
|
+
case 4:
|
|
327
|
+
_a.trys.push([4, 6, , 8]);
|
|
328
|
+
return [4 /*yield*/, (0, package_manager_1.installPackageWithPackageManager)(packageManager, packageName)];
|
|
329
|
+
case 5:
|
|
330
|
+
_a.sent();
|
|
331
|
+
return [3 /*break*/, 8];
|
|
332
|
+
case 6:
|
|
333
|
+
e_1 = _a.sent();
|
|
334
|
+
sdkInstallSpinner.stop('Installation failed.');
|
|
335
|
+
clack.log.error("".concat(chalk_1.default.red('Encountered the following error during installation:'), "\n\n").concat(e_1, "\n\n").concat(chalk_1.default.dim('If you think this issue is caused by the Sentry wizard, let us know here:\nhttps://github.com/getsentry/sentry-wizard/issues')));
|
|
336
|
+
return [4 /*yield*/, abort()];
|
|
337
|
+
case 7:
|
|
338
|
+
_a.sent();
|
|
339
|
+
return [3 /*break*/, 8];
|
|
340
|
+
case 8:
|
|
341
|
+
sdkInstallSpinner.stop("".concat(alreadyInstalled ? 'Updated' : 'Installed', " ").concat(chalk_1.default.bold.cyan(packageName), " with ").concat(chalk_1.default.bold(packageManager.label), "."));
|
|
342
|
+
return [2 /*return*/];
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}); })];
|
|
300
346
|
});
|
|
301
347
|
});
|
|
302
348
|
}
|
|
@@ -304,44 +350,49 @@ exports.installPackage = installPackage;
|
|
|
304
350
|
function addSentryCliConfig(authToken, setupConfig) {
|
|
305
351
|
if (setupConfig === void 0) { setupConfig = exports.sourceMapsCliSetupConfig; }
|
|
306
352
|
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
-
var
|
|
308
|
-
return __generator(this, function (
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
353
|
+
var _this = this;
|
|
354
|
+
return __generator(this, function (_a) {
|
|
355
|
+
return [2 /*return*/, (0, telemetry_1.traceStep)('add-sentry-cli-config', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
356
|
+
var configExists, configContents, _a, _b;
|
|
357
|
+
return __generator(this, function (_c) {
|
|
358
|
+
switch (_c.label) {
|
|
359
|
+
case 0:
|
|
360
|
+
configExists = fs.existsSync(path.join(process.cwd(), setupConfig.filename));
|
|
361
|
+
if (!configExists) return [3 /*break*/, 5];
|
|
362
|
+
configContents = fs.readFileSync(path.join(process.cwd(), setupConfig.filename), 'utf8');
|
|
363
|
+
if (!setupConfig.likelyAlreadyHasAuthToken(configContents)) return [3 /*break*/, 1];
|
|
364
|
+
clack.log.warn("".concat(chalk_1.default.bold(setupConfig.filename), " already has auth token. Will not add one."));
|
|
365
|
+
return [3 /*break*/, 4];
|
|
366
|
+
case 1:
|
|
367
|
+
_c.trys.push([1, 3, , 4]);
|
|
368
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), setupConfig.filename), "".concat(configContents, "\n").concat(setupConfig.tokenContent(authToken), "\n"), { encoding: 'utf8', flag: 'w' })];
|
|
369
|
+
case 2:
|
|
370
|
+
_c.sent();
|
|
371
|
+
clack.log.success(chalk_1.default.greenBright("Added auth token to ".concat(chalk_1.default.bold(setupConfig.filename), " for you to test uploading ").concat(setupConfig.name, " locally.")));
|
|
372
|
+
return [3 /*break*/, 4];
|
|
373
|
+
case 3:
|
|
374
|
+
_a = _c.sent();
|
|
375
|
+
clack.log.warning("Failed to add auth token to ".concat(chalk_1.default.bold(setupConfig.filename), ". Uploading ").concat(setupConfig.name, " during build will likely not work locally."));
|
|
376
|
+
return [3 /*break*/, 4];
|
|
377
|
+
case 4: return [3 /*break*/, 8];
|
|
378
|
+
case 5:
|
|
379
|
+
_c.trys.push([5, 7, , 8]);
|
|
380
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), setupConfig.filename), "".concat(setupConfig.tokenContent(authToken), "\n"), { encoding: 'utf8', flag: 'w' })];
|
|
381
|
+
case 6:
|
|
382
|
+
_c.sent();
|
|
383
|
+
clack.log.success(chalk_1.default.greenBright("Created ".concat(chalk_1.default.bold(setupConfig.filename), " with auth token for you to test uploading ").concat(setupConfig.name, " locally.")));
|
|
384
|
+
return [3 /*break*/, 8];
|
|
385
|
+
case 7:
|
|
386
|
+
_b = _c.sent();
|
|
387
|
+
clack.log.warning("Failed to create ".concat(chalk_1.default.bold(setupConfig.filename), " with auth token. Uploading ").concat(setupConfig.name, " during build will likely not work locally."));
|
|
388
|
+
return [3 /*break*/, 8];
|
|
389
|
+
case 8: return [4 /*yield*/, addAuthTokenFileToGitIgnore(setupConfig.filename)];
|
|
390
|
+
case 9:
|
|
391
|
+
_c.sent();
|
|
392
|
+
return [2 /*return*/];
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}); })];
|
|
345
396
|
});
|
|
346
397
|
});
|
|
347
398
|
}
|
|
@@ -420,31 +471,44 @@ function addAuthTokenFileToGitIgnore(filename) {
|
|
|
420
471
|
});
|
|
421
472
|
});
|
|
422
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Checks if @param packageId is listed as a dependency in @param packageJson.
|
|
476
|
+
* If not, it will ask users if they want to continue without the package.
|
|
477
|
+
*
|
|
478
|
+
* Use this function to check if e.g. a the framework of the SDK is installed
|
|
479
|
+
*
|
|
480
|
+
* @param packageJson the package.json object
|
|
481
|
+
* @param packageId the npm name of the package
|
|
482
|
+
* @param packageName a human readable name of the package
|
|
483
|
+
*/
|
|
423
484
|
function ensurePackageIsInstalled(packageJson, packageId, packageName) {
|
|
424
485
|
return __awaiter(this, void 0, void 0, function () {
|
|
425
|
-
var
|
|
486
|
+
var _this = this;
|
|
426
487
|
return __generator(this, function (_a) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
488
|
+
return [2 /*return*/, (0, telemetry_1.traceStep)('ensure-package-installed', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
489
|
+
var installed, continueWithoutPackage;
|
|
490
|
+
return __generator(this, function (_a) {
|
|
491
|
+
switch (_a.label) {
|
|
492
|
+
case 0:
|
|
493
|
+
installed = (0, package_json_1.hasPackageInstalled)(packageId, packageJson);
|
|
494
|
+
Sentry.setTag("".concat(packageName.toLowerCase(), "-installed"), installed);
|
|
495
|
+
if (!!installed) return [3 /*break*/, 3];
|
|
496
|
+
Sentry.setTag("".concat(packageName.toLowerCase(), "-installed"), false);
|
|
497
|
+
return [4 /*yield*/, abortIfCancelled(clack.confirm({
|
|
498
|
+
message: "".concat(packageName, " does not seem to be installed. Do you still want to continue?"),
|
|
499
|
+
initialValue: false,
|
|
500
|
+
}))];
|
|
501
|
+
case 1:
|
|
502
|
+
continueWithoutPackage = _a.sent();
|
|
503
|
+
if (!!continueWithoutPackage) return [3 /*break*/, 3];
|
|
504
|
+
return [4 /*yield*/, abort(undefined, 0)];
|
|
505
|
+
case 2:
|
|
506
|
+
_a.sent();
|
|
507
|
+
_a.label = 3;
|
|
508
|
+
case 3: return [2 /*return*/];
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}); })];
|
|
448
512
|
});
|
|
449
513
|
});
|
|
450
514
|
}
|
|
@@ -471,7 +535,7 @@ function getPackageDotJson() {
|
|
|
471
535
|
return [3 /*break*/, 5];
|
|
472
536
|
case 3:
|
|
473
537
|
_a = _b.sent();
|
|
474
|
-
clack.log.error(
|
|
538
|
+
clack.log.error("Unable to parse your ".concat(chalk_1.default.cyan('package.json'), ". Make sure it has a valid format!"));
|
|
475
539
|
return [4 /*yield*/, abort()];
|
|
476
540
|
case 4:
|
|
477
541
|
_b.sent();
|