@sentry/wizard 3.1.0 → 3.2.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.
Files changed (106) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/bin.ts +5 -1
  3. package/dist/bin.js +6 -1
  4. package/dist/bin.js.map +1 -1
  5. package/dist/lib/Constants.d.ts +2 -1
  6. package/dist/lib/Constants.js +5 -0
  7. package/dist/lib/Constants.js.map +1 -1
  8. package/dist/lib/Helper/File.js +25 -2
  9. package/dist/lib/Helper/File.js.map +1 -1
  10. package/dist/lib/Helper/Git.d.ts +7 -0
  11. package/dist/lib/Helper/Git.js +94 -0
  12. package/dist/lib/Helper/Git.js.map +1 -0
  13. package/dist/lib/Helper/Logging.d.ts +1 -0
  14. package/dist/lib/Helper/Logging.js +9 -2
  15. package/dist/lib/Helper/Logging.js.map +1 -1
  16. package/dist/lib/Helper/MergeConfig.js +24 -1
  17. package/dist/lib/Helper/MergeConfig.js.map +1 -1
  18. package/dist/lib/Helper/Package.d.ts +9 -0
  19. package/dist/lib/Helper/Package.js +39 -2
  20. package/dist/lib/Helper/Package.js.map +1 -1
  21. package/dist/lib/Helper/PackageManager.d.ts +1 -1
  22. package/dist/lib/Helper/PackageManager.js +32 -11
  23. package/dist/lib/Helper/PackageManager.js.map +1 -1
  24. package/dist/lib/Helper/SentryCli.d.ts +11 -0
  25. package/dist/lib/Helper/SentryCli.js +141 -2
  26. package/dist/lib/Helper/SentryCli.js.map +1 -1
  27. package/dist/lib/Helper/Wizard.js +24 -1
  28. package/dist/lib/Helper/Wizard.js.map +1 -1
  29. package/dist/lib/Helper/__tests__/MergeConfig.js +25 -2
  30. package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
  31. package/dist/lib/Setup.js +25 -2
  32. package/dist/lib/Setup.js.map +1 -1
  33. package/dist/lib/Steps/ChooseIntegration.js +28 -1
  34. package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
  35. package/dist/lib/Steps/Initial.js +25 -2
  36. package/dist/lib/Steps/Initial.js.map +1 -1
  37. package/dist/lib/Steps/Integrations/BaseIntegration.js +24 -1
  38. package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
  39. package/dist/lib/Steps/Integrations/Cordova.js +25 -2
  40. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  41. package/dist/lib/Steps/Integrations/Electron.js +26 -3
  42. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  43. package/dist/lib/Steps/Integrations/MobileProject.js +24 -1
  44. package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
  45. package/dist/lib/Steps/Integrations/NextJs.d.ts +5 -11
  46. package/dist/lib/Steps/Integrations/NextJs.js +14 -343
  47. package/dist/lib/Steps/Integrations/NextJs.js.map +1 -1
  48. package/dist/lib/Steps/Integrations/ReactNative.d.ts +1 -0
  49. package/dist/lib/Steps/Integrations/ReactNative.js +67 -6
  50. package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
  51. package/dist/lib/Steps/Integrations/SvelteKit.d.ts +13 -0
  52. package/dist/lib/Steps/Integrations/SvelteKit.js +95 -0
  53. package/dist/lib/Steps/Integrations/SvelteKit.js.map +1 -0
  54. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +28 -5
  55. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +1 -1
  56. package/dist/lib/Steps/PromptForParameters.js +24 -1
  57. package/dist/lib/Steps/PromptForParameters.js.map +1 -1
  58. package/dist/lib/Steps/SentryProjectSelector.js +25 -1
  59. package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
  60. package/dist/lib/__tests__/Setup.js +24 -1
  61. package/dist/lib/__tests__/Setup.js.map +1 -1
  62. package/dist/src/{nextjs-wizard.js → nextjs/nextjs-wizard.js} +113 -108
  63. package/dist/src/nextjs/nextjs-wizard.js.map +1 -0
  64. package/dist/src/sveltekit/sdk-example.d.ts +10 -0
  65. package/dist/src/sveltekit/sdk-example.js +106 -0
  66. package/dist/src/sveltekit/sdk-example.js.map +1 -0
  67. package/dist/src/sveltekit/sdk-setup.d.ts +13 -0
  68. package/dist/src/sveltekit/sdk-setup.js +452 -0
  69. package/dist/src/sveltekit/sdk-setup.js.map +1 -0
  70. package/dist/src/sveltekit/sentry-cli-setup.d.ts +2 -0
  71. package/dist/src/sveltekit/sentry-cli-setup.js +71 -0
  72. package/dist/src/sveltekit/sentry-cli-setup.js.map +1 -0
  73. package/dist/src/sveltekit/sveltekit-wizard.d.ts +5 -0
  74. package/dist/src/sveltekit/sveltekit-wizard.js +147 -0
  75. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -0
  76. package/dist/src/templates/nextjs-templates.js +2 -2
  77. package/dist/src/templates/nextjs-templates.js.map +1 -1
  78. package/dist/src/templates/sveltekit-templates.d.ts +12 -0
  79. package/dist/src/templates/sveltekit-templates.js +26 -0
  80. package/dist/src/templates/sveltekit-templates.js.map +1 -0
  81. package/dist/src/{clack-utils.d.ts → utils/clack-utils.d.ts} +7 -0
  82. package/dist/src/{clack-utils.js → utils/clack-utils.js} +127 -42
  83. package/dist/src/utils/clack-utils.js.map +1 -0
  84. package/lib/Constants.ts +5 -0
  85. package/lib/Helper/Git.ts +39 -0
  86. package/lib/Helper/Logging.ts +4 -0
  87. package/lib/Helper/Package.ts +17 -0
  88. package/lib/Helper/PackageManager.ts +4 -9
  89. package/lib/Helper/SentryCli.ts +74 -0
  90. package/lib/Steps/ChooseIntegration.ts +4 -0
  91. package/lib/Steps/Integrations/NextJs.ts +7 -397
  92. package/lib/Steps/Integrations/ReactNative.ts +49 -3
  93. package/lib/Steps/Integrations/SvelteKit.ts +29 -0
  94. package/lib/Steps/SentryProjectSelector.ts +1 -0
  95. package/package.json +2 -2
  96. package/src/{nextjs-wizard.ts → nextjs/nextjs-wizard.ts} +13 -44
  97. package/src/sveltekit/sdk-example.ts +56 -0
  98. package/src/sveltekit/sdk-setup.ts +431 -0
  99. package/src/sveltekit/sentry-cli-setup.ts +27 -0
  100. package/src/sveltekit/sveltekit-wizard.ts +116 -0
  101. package/src/templates/nextjs-templates.ts +2 -2
  102. package/src/templates/sveltekit-templates.ts +172 -0
  103. package/src/{clack-utils.ts → utils/clack-utils.ts} +73 -11
  104. package/dist/src/clack-utils.js.map +0 -1
  105. package/dist/src/nextjs-wizard.js.map +0 -1
  106. /package/dist/src/{nextjs-wizard.d.ts → nextjs/nextjs-wizard.d.ts} +0 -0
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.runSvelteKitWizard = void 0;
43
+ // @ts-ignore - clack is ESM and TS complains about that. It works though
44
+ var prompts_1 = __importDefault(require("@clack/prompts"));
45
+ var chalk_1 = __importDefault(require("chalk"));
46
+ var clack_utils_1 = require("../utils/clack-utils");
47
+ var sdk_example_1 = require("./sdk-example");
48
+ var sdk_setup_1 = require("./sdk-setup");
49
+ var sentry_cli_setup_1 = require("./sentry-cli-setup");
50
+ function runSvelteKitWizard(options) {
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ var packageJson, _a, sentryUrl, selfHosted, _b, projects, apiKeys, selectedProject, dsn, svelteConfig, e_1, e_2;
53
+ return __generator(this, function (_c) {
54
+ switch (_c.label) {
55
+ case 0:
56
+ (0, clack_utils_1.printWelcome)({
57
+ wizardName: 'Sentry SvelteKit Wizard',
58
+ promoCode: options.promoCode,
59
+ });
60
+ return [4 /*yield*/, (0, clack_utils_1.confirmContinueEvenThoughNoGitRepo)()];
61
+ case 1:
62
+ _c.sent();
63
+ return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
64
+ case 2:
65
+ packageJson = _c.sent();
66
+ return [4 /*yield*/, (0, clack_utils_1.ensurePackageIsInstalled)(packageJson, '@sveltejs/kit', 'Sveltekit')];
67
+ case 3:
68
+ _c.sent();
69
+ return [4 /*yield*/, (0, clack_utils_1.askForSelfHosted)()];
70
+ case 4:
71
+ _a = _c.sent(), sentryUrl = _a.url, selfHosted = _a.selfHosted;
72
+ return [4 /*yield*/, (0, clack_utils_1.askForWizardLogin)({
73
+ promoCode: options.promoCode,
74
+ url: sentryUrl,
75
+ })];
76
+ case 5:
77
+ _b = _c.sent(), projects = _b.projects, apiKeys = _b.apiKeys;
78
+ return [4 /*yield*/, prompts_1.default.select({
79
+ message: 'Select your Sentry project.',
80
+ options: projects.map(function (project) {
81
+ return {
82
+ value: project,
83
+ label: "".concat(project.organization.slug, "/").concat(project.slug),
84
+ };
85
+ }),
86
+ })];
87
+ case 6:
88
+ selectedProject = _c.sent();
89
+ (0, clack_utils_1.abortIfCancelled)(selectedProject);
90
+ return [4 /*yield*/, (0, clack_utils_1.installPackage)({
91
+ packageName: '@sentry/sveltekit',
92
+ alreadyInstalled: (0, clack_utils_1.hasPackageInstalled)('@sentry/sveltekit', packageJson),
93
+ })];
94
+ case 7:
95
+ _c.sent();
96
+ return [4 /*yield*/, (0, sentry_cli_setup_1.setupCLIConfig)(apiKeys.token, selectedProject, sentryUrl)];
97
+ case 8:
98
+ _c.sent();
99
+ dsn = selectedProject.keys[0].dsn.public;
100
+ return [4 /*yield*/, (0, sdk_setup_1.loadSvelteConfig)()];
101
+ case 9:
102
+ svelteConfig = _c.sent();
103
+ _c.label = 10;
104
+ case 10:
105
+ _c.trys.push([10, 12, , 13]);
106
+ return [4 /*yield*/, (0, sdk_setup_1.createOrMergeSvelteKitFiles)(dsn, svelteConfig)];
107
+ case 11:
108
+ _c.sent();
109
+ return [3 /*break*/, 13];
110
+ case 12:
111
+ e_1 = _c.sent();
112
+ prompts_1.default.log.error('Error while setting up the SvelteKit SDK:');
113
+ prompts_1.default.log.info(chalk_1.default.dim(typeof e_1 === 'object' && e_1 != null && 'toString' in e_1
114
+ ? e_1.toString()
115
+ : typeof e_1 === 'string'
116
+ ? e_1
117
+ : 'Unknown error'));
118
+ return [2 /*return*/];
119
+ case 13:
120
+ _c.trys.push([13, 15, , 16]);
121
+ return [4 /*yield*/, (0, sdk_example_1.createExamplePage)(svelteConfig, {
122
+ selfHosted: selfHosted,
123
+ url: sentryUrl,
124
+ orgSlug: selectedProject.organization.slug,
125
+ projectId: selectedProject.id,
126
+ })];
127
+ case 14:
128
+ _c.sent();
129
+ return [3 /*break*/, 16];
130
+ case 15:
131
+ e_2 = _c.sent();
132
+ prompts_1.default.log.error('Error while creating an example page to test Sentry:');
133
+ prompts_1.default.log.info(chalk_1.default.dim(typeof e_2 === 'object' && e_2 != null && 'toString' in e_2
134
+ ? e_2.toString()
135
+ : typeof e_2 === 'string'
136
+ ? e_2
137
+ : 'Unknown error'));
138
+ return [2 /*return*/];
139
+ case 16:
140
+ prompts_1.default.outro("\n".concat(chalk_1.default.green('Successfully installed the Sentry SvelteKit SDK!'), "\n\n").concat(chalk_1.default.cyan('You can validate your setup by starting your dev environment (`npm run dev`) and visiting "/sentry-example".'), "\n\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/sveltekit/\n "));
141
+ return [2 /*return*/];
142
+ }
143
+ });
144
+ });
145
+ }
146
+ exports.runSvelteKitWizard = runSvelteKitWizard;
147
+ //# sourceMappingURL=sveltekit-wizard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sveltekit-wizard.js","sourceRoot":"","sources":["../../../src/sveltekit/sveltekit-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAE1B,oDAW8B;AAC9B,6CAAkD;AAClD,yCAA4E;AAE5E,uDAAoD;AAMpD,SAAsB,kBAAkB,CACtC,OAA+B;;;;;;oBAE/B,IAAA,0BAAY,EAAC;wBACX,UAAU,EAAE,yBAAyB;wBACrC,SAAS,EAAE,OAAO,CAAC,SAAS;qBAC7B,CAAC,CAAC;oBAEH,qBAAM,IAAA,gDAAkC,GAAE,EAAA;;oBAA1C,SAA0C,CAAC;oBAEvB,qBAAM,IAAA,+BAAiB,GAAE,EAAA;;oBAAvC,WAAW,GAAG,SAAyB;oBAC7C,qBAAM,IAAA,sCAAwB,EAAC,WAAW,EAAE,eAAe,EAAE,WAAW,CAAC,EAAA;;oBAAzE,SAAyE,CAAC;oBAEnC,qBAAM,IAAA,8BAAgB,GAAE,EAAA;;oBAAzD,KAAiC,SAAwB,EAAlD,SAAS,SAAA,EAAE,UAAU,gBAAA;oBAEJ,qBAAM,IAAA,+BAAiB,EAAC;4BACpD,SAAS,EAAE,OAAO,CAAC,SAAS;4BAC5B,GAAG,EAAE,SAAS;yBACf,CAAC,EAAA;;oBAHI,KAAwB,SAG5B,EAHM,QAAQ,cAAA,EAAE,OAAO,aAAA;oBAK2B,qBAAM,iBAAK,CAAC,MAAM,CAAC;4BACrE,OAAO,EAAE,6BAA6B;4BACtC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAC,OAAO;gCAC5B,OAAO;oCACL,KAAK,EAAE,OAAO;oCACd,KAAK,EAAE,UAAG,OAAO,CAAC,YAAY,CAAC,IAAI,cAAI,OAAO,CAAC,IAAI,CAAE;iCACtD,CAAC;4BACJ,CAAC,CAAC;yBACH,CAAC,EAAA;;oBARI,eAAe,GAA+B,SAQlD;oBAEF,IAAA,8BAAgB,EAAC,eAAe,CAAC,CAAC;oBAElC,qBAAM,IAAA,4BAAc,EAAC;4BACnB,WAAW,EAAE,mBAAmB;4BAChC,gBAAgB,EAAE,IAAA,iCAAmB,EAAC,mBAAmB,EAAE,WAAW,CAAC;yBACxE,CAAC,EAAA;;oBAHF,SAGE,CAAC;oBAEH,qBAAM,IAAA,iCAAc,EAAC,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,SAAS,CAAC,EAAA;;oBAA/D,SAA+D,CAAC;oBAE1D,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;oBAE1B,qBAAM,IAAA,4BAAgB,GAAE,EAAA;;oBAAvC,YAAY,GAAG,SAAwB;;;;oBAG3C,qBAAM,IAAA,uCAA2B,EAAC,GAAG,EAAE,YAAY,CAAC,EAAA;;oBAApD,SAAoD,CAAC;;;;oBAErD,iBAAK,CAAC,GAAG,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;oBAC7D,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAK,CAAC,GAAG,CACP,OAAO,GAAC,KAAK,QAAQ,IAAI,GAAC,IAAI,IAAI,IAAI,UAAU,IAAI,GAAC;wBACnD,CAAC,CAAC,GAAC,CAAC,QAAQ,EAAE;wBACd,CAAC,CAAC,OAAO,GAAC,KAAK,QAAQ;4BACvB,CAAC,CAAC,GAAC;4BACH,CAAC,CAAC,eAAe,CACpB,CACF,CAAC;oBACF,sBAAO;;;oBAIP,qBAAM,IAAA,+BAAiB,EAAC,YAAY,EAAE;4BACpC,UAAU,YAAA;4BACV,GAAG,EAAE,SAAS;4BACd,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;4BAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;yBAC9B,CAAC,EAAA;;oBALF,SAKE,CAAC;;;;oBAEH,iBAAK,CAAC,GAAG,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;oBACxE,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAK,CAAC,GAAG,CACP,OAAO,GAAC,KAAK,QAAQ,IAAI,GAAC,IAAI,IAAI,IAAI,UAAU,IAAI,GAAC;wBACnD,CAAC,CAAC,GAAC,CAAC,QAAQ,EAAE;wBACd,CAAC,CAAC,OAAO,GAAC,KAAK,QAAQ;4BACvB,CAAC,CAAC,GAAC;4BACH,CAAC,CAAC,eAAe,CACpB,CACF,CAAC;oBACF,sBAAO;;oBAGT,iBAAK,CAAC,KAAK,CAAC,YACZ,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,iBAE/D,eAAK,CAAC,IAAI,CACV,8GAA8G,CAC/G,sIAIE,CAAC,CAAC;;;;;CACJ;AA1FD,gDA0FC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n abortIfCancelled,\n askForSelfHosted,\n askForWizardLogin,\n confirmContinueEvenThoughNoGitRepo,\n ensurePackageIsInstalled,\n getPackageDotJson,\n hasPackageInstalled,\n installPackage,\n printWelcome,\n SentryProjectData,\n} from '../utils/clack-utils';\nimport { createExamplePage } from './sdk-example';\nimport { createOrMergeSvelteKitFiles, loadSvelteConfig } from './sdk-setup';\n\nimport { setupCLIConfig } from './sentry-cli-setup';\n\ninterface SvelteKitWizardOptions {\n promoCode?: string;\n}\n\nexport async function runSvelteKitWizard(\n options: SvelteKitWizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry SvelteKit Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueEvenThoughNoGitRepo();\n\n const packageJson = await getPackageDotJson();\n await ensurePackageIsInstalled(packageJson, '@sveltejs/kit', 'Sveltekit');\n\n const { url: sentryUrl, selfHosted } = await askForSelfHosted();\n\n const { projects, apiKeys } = await askForWizardLogin({\n promoCode: options.promoCode,\n url: sentryUrl,\n });\n\n const selectedProject: SentryProjectData | symbol = await clack.select({\n message: 'Select your Sentry project.',\n options: projects.map((project) => {\n return {\n value: project,\n label: `${project.organization.slug}/${project.slug}`,\n };\n }),\n });\n\n abortIfCancelled(selectedProject);\n\n await installPackage({\n packageName: '@sentry/sveltekit',\n alreadyInstalled: hasPackageInstalled('@sentry/sveltekit', packageJson),\n });\n\n await setupCLIConfig(apiKeys.token, selectedProject, sentryUrl);\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const svelteConfig = await loadSvelteConfig();\n\n try {\n await createOrMergeSvelteKitFiles(dsn, svelteConfig);\n } catch (e: unknown) {\n clack.log.error('Error while setting up the SvelteKit SDK:');\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n return;\n }\n\n try {\n await createExamplePage(svelteConfig, {\n selfHosted,\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n });\n } catch (e: unknown) {\n clack.log.error('Error while creating an example page to test Sentry:');\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n return;\n }\n\n clack.outro(`\n${chalk.green('Successfully installed the Sentry SvelteKit SDK!')}\n\n${chalk.cyan(\n 'You can validate your setup by starting your dev environment (`npm run dev`) and visiting \"/sentry-example\".',\n)}\n\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/sveltekit/\n `);\n}\n"]}
@@ -14,7 +14,7 @@ function getNextjsConfigCjsTemplate(sentryWebpackPluginOptionsTemplate, sentryBu
14
14
  }
15
15
  exports.getNextjsConfigCjsTemplate = getNextjsConfigCjsTemplate;
16
16
  function getNextjsConfigCjsAppendix(sentryWebpackPluginOptionsTemplate, sentryBuildOptionsTemplate) {
17
- return "\n\n// Inected Content via Sentry Wizard Below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ".concat(sentryWebpackPluginOptionsTemplate, ",\n ").concat(sentryBuildOptionsTemplate, "\n);\n");
17
+ return "\n\n// Injected content via Sentry wizard below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ".concat(sentryWebpackPluginOptionsTemplate, ",\n ").concat(sentryBuildOptionsTemplate, "\n);\n");
18
18
  }
19
19
  exports.getNextjsConfigCjsAppendix = getNextjsConfigCjsAppendix;
20
20
  function getNextjsConfigEsmCopyPasteSnippet(sentryWebpackPluginOptionsTemplate, sentryBuildOptionsTemplate) {
@@ -30,7 +30,7 @@ function getSentryConfigContents(dsn, config) {
30
30
  primer = "// This file configures the initialization of Sentry on the client.\n// The config you add here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/";
31
31
  }
32
32
  else if (config === 'edge') {
33
- primer = "// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n// The config you add here will be used whenever one of the edge features is loaded.\n// Note that this config is unrelated to the Verel Edge Runtime and is also required when running locally.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/";
33
+ primer = "// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n// The config you add here will be used whenever one of the edge features is loaded.\n// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/";
34
34
  }
35
35
  var additionalOptions = '';
36
36
  if (config === 'client') {
@@ -1 +1 @@
1
- {"version":3,"file":"nextjs-templates.js","sourceRoot":"","sources":["../../../src/templates/nextjs-templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,qCAAqC,CACnD,OAAe,EACf,WAAmB;IAEnB,OAAO,oNAOG,OAAO,iCACH,WAAW,aACvB,CAAC;AACL,CAAC;AAdD,sFAcC;AAED,SAAgB,mCAAmC;IACjD,OAAO,usBAkBL,CAAC;AACL,CAAC;AApBD,kFAoBC;AAED,SAAgB,0BAA0B,CACxC,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,gMAOL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAfD,gEAeC;AAED,SAAgB,0BAA0B,CACxC,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,kLAQL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAhBD,gEAgBC;AAED,SAAgB,kCAAkC,CAChD,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,iJAOL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAfD,gFAeC;AAED,SAAgB,uBAAuB,CACrC,GAAW,EACX,MAAoC;IAEpC,IAAI,MAAM,CAAC;IACX,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,MAAM,GAAG,oNAEiD,CAAC;KAC5D;SAAM,IAAI,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,6NAEiD,CAAC;KAC5D;SAAM,IAAI,MAAM,KAAK,MAAM,EAAE;QAC5B,MAAM,GAAG,+WAGiD,CAAC;KAC5D;IAED,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,iBAAiB,GAAG,gfAenB,CAAC;KACH;IAED,4EAA4E;IAC5E,OAAO,UAAG,MAAM,wFAKR,GAAG,4PAMI,iBAAiB,YAEjC,CAAC;AACF,CAAC;AAvDD,0DAuDC;AAED,SAAgB,4BAA4B,CAAC,OAK5C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,uxGAwEY,cAAc,8VAYlC,CAAC;AACF,CAAC;AA/FD,oEA+FC;AAED,SAAgB,wBAAwB;IACtC,OAAO,qNAKR,CAAC;AACF,CAAC;AAPD,4DAOC","sourcesContent":["export function getNextjsWebpackPluginOptionsTemplate(\n orgSlug: string,\n projectSlug: string,\n): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n // Suppresses source map uploading logs during build\n silent: true,\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",\n }`;\n}\n\nexport function getNextjsSentryBuildOptionsTemplate(): string {\n return `{\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Transpiles SDK to be compatible with IE11 (increases bundle size)\n transpileClientSDK: true,\n\n // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)\n tunnelRoute: \"/monitoring\",\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n }`;\n}\n\nexport function getNextjsConfigCjsTemplate(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `const { withSentryConfig } = require(\"@sentry/nextjs\");\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nmodule.exports = withSentryConfig(\n nextConfig,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `\n\n// Inected Content via Sentry Wizard Below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'server' | 'client' | 'edge',\n): string {\n let primer;\n if (config === 'server') {\n primer = `// This file configures the initialization of Sentry on the server.\n// The config you add here will be used whenever the server handles a request.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'client') {\n primer = `// This file configures the initialization of Sentry on the client.\n// The config you add here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'edge') {\n primer = `// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n// The config you add here will be used whenever one of the edge features is loaded.\n// Note that this config is unrelated to the Verel Edge Runtime and is also required when running locally.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n }\n\n let additionalOptions = '';\n if (config === 'client') {\n additionalOptions = `\n\n replaysOnErrorSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // You can remove this option if you're not planning to use the Sentry Session Replay feature:\n integrations: [\n new Sentry.Replay({\n // Additional Replay configuration goes in here, for example:\n maskAllText: true,\n blockAllMedia: true,\n }),\n ],`;\n }\n\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `${primer}\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"${dsn}\",\n\n // Adjust this value in production, or use tracesSampler for greater control\n tracesSampleRate: 1,\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,${additionalOptions}\n});\n`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Home() {\n return (\n <div>\n <Head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n ></path>\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={async () => {\n const transaction = Sentry.startTransaction({\n name: \"Example Frontend Transaction\",\n });\n\n Sentry.configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n try {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n } finally {\n transaction.finish();\n }\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">\n https://docs.sentry.io/platforms/javascript/guides/nextjs/\n </a>\n </p>\n </main>\n </div>\n );\n}\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// A faulty API route to test Sentry's error monitoring\nexport default function handler(_req, res) {\n throw new Error(\"Sentry Example API Route Error\");\n res.status(200).json({ name: \"John Doe\" });\n}\n`;\n}\n"]}
1
+ {"version":3,"file":"nextjs-templates.js","sourceRoot":"","sources":["../../../src/templates/nextjs-templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,qCAAqC,CACnD,OAAe,EACf,WAAmB;IAEnB,OAAO,oNAOG,OAAO,iCACH,WAAW,aACvB,CAAC;AACL,CAAC;AAdD,sFAcC;AAED,SAAgB,mCAAmC;IACjD,OAAO,usBAkBL,CAAC;AACL,CAAC;AApBD,kFAoBC;AAED,SAAgB,0BAA0B,CACxC,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,gMAOL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAfD,gEAeC;AAED,SAAgB,0BAA0B,CACxC,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,mLAQL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAhBD,gEAgBC;AAED,SAAgB,kCAAkC,CAChD,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,iJAOL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAfD,gFAeC;AAED,SAAgB,uBAAuB,CACrC,GAAW,EACX,MAAoC;IAEpC,IAAI,MAAM,CAAC;IACX,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,MAAM,GAAG,oNAEiD,CAAC;KAC5D;SAAM,IAAI,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,6NAEiD,CAAC;KAC5D;SAAM,IAAI,MAAM,KAAK,MAAM,EAAE;QAC5B,MAAM,GAAG,gXAGiD,CAAC;KAC5D;IAED,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,iBAAiB,GAAG,gfAenB,CAAC;KACH;IAED,4EAA4E;IAC5E,OAAO,UAAG,MAAM,wFAKR,GAAG,4PAMI,iBAAiB,YAEjC,CAAC;AACF,CAAC;AAvDD,0DAuDC;AAED,SAAgB,4BAA4B,CAAC,OAK5C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,uxGAwEY,cAAc,8VAYlC,CAAC;AACF,CAAC;AA/FD,oEA+FC;AAED,SAAgB,wBAAwB;IACtC,OAAO,qNAKR,CAAC;AACF,CAAC;AAPD,4DAOC","sourcesContent":["export function getNextjsWebpackPluginOptionsTemplate(\n orgSlug: string,\n projectSlug: string,\n): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n // Suppresses source map uploading logs during build\n silent: true,\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",\n }`;\n}\n\nexport function getNextjsSentryBuildOptionsTemplate(): string {\n return `{\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Transpiles SDK to be compatible with IE11 (increases bundle size)\n transpileClientSDK: true,\n\n // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)\n tunnelRoute: \"/monitoring\",\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n }`;\n}\n\nexport function getNextjsConfigCjsTemplate(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `const { withSentryConfig } = require(\"@sentry/nextjs\");\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nmodule.exports = withSentryConfig(\n nextConfig,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `\n\n// Injected content via Sentry wizard below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'server' | 'client' | 'edge',\n): string {\n let primer;\n if (config === 'server') {\n primer = `// This file configures the initialization of Sentry on the server.\n// The config you add here will be used whenever the server handles a request.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'client') {\n primer = `// This file configures the initialization of Sentry on the client.\n// The config you add here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'edge') {\n primer = `// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n// The config you add here will be used whenever one of the edge features is loaded.\n// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n }\n\n let additionalOptions = '';\n if (config === 'client') {\n additionalOptions = `\n\n replaysOnErrorSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // You can remove this option if you're not planning to use the Sentry Session Replay feature:\n integrations: [\n new Sentry.Replay({\n // Additional Replay configuration goes in here, for example:\n maskAllText: true,\n blockAllMedia: true,\n }),\n ],`;\n }\n\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `${primer}\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"${dsn}\",\n\n // Adjust this value in production, or use tracesSampler for greater control\n tracesSampleRate: 1,\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,${additionalOptions}\n});\n`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Home() {\n return (\n <div>\n <Head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n ></path>\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={async () => {\n const transaction = Sentry.startTransaction({\n name: \"Example Frontend Transaction\",\n });\n\n Sentry.configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n try {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n } finally {\n transaction.finish();\n }\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">\n https://docs.sentry.io/platforms/javascript/guides/nextjs/\n </a>\n </p>\n </main>\n </div>\n );\n}\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// A faulty API route to test Sentry's error monitoring\nexport default function handler(_req, res) {\n throw new Error(\"Sentry Example API Route Error\");\n res.status(200).json({ name: \"John Doe\" });\n}\n`;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ export declare function getClientHooksTemplate(dsn: string): string;
2
+ export declare function getServerHooksTemplate(dsn: string): string;
3
+ /**
4
+ * +page.svelte with Sentry example
5
+ */
6
+ export declare function getSentryExampleSveltePage(options: {
7
+ selfHosted: boolean;
8
+ url: string;
9
+ orgSlug: string;
10
+ projectId: string;
11
+ }): string;
12
+ export declare function getSentryExampleApiRoute(): string;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSentryExampleApiRoute = exports.getSentryExampleSveltePage = exports.getServerHooksTemplate = exports.getClientHooksTemplate = void 0;
4
+ function getClientHooksTemplate(dsn) {
5
+ return "import { handleErrorWithSentry, Replay } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n tracesSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [new Replay()],\n});\n\n// If you have a custom error handler, pass it to `handleErrorWithSentry`\nexport const handleError = handleErrorWithSentry();\n");
6
+ }
7
+ exports.getClientHooksTemplate = getClientHooksTemplate;
8
+ function getServerHooksTemplate(dsn) {
9
+ return "import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n tracesSampleRate: 1.0,\n});\n\n// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to `handleErrorWithSentry`\nexport const handleError = handleErrorWithSentry();\n");
10
+ }
11
+ exports.getServerHooksTemplate = getServerHooksTemplate;
12
+ /**
13
+ * +page.svelte with Sentry example
14
+ */
15
+ function getSentryExampleSveltePage(options) {
16
+ var issuesPageLink = options.selfHosted
17
+ ? "".concat(options.url, "organizations/").concat(options.orgSlug, "/issues/?project=").concat(options.projectId)
18
+ : "https://".concat(options.orgSlug, ".sentry.io/issues/?project=").concat(options.projectId);
19
+ return "<!-- \nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file and the entire sentry route. \n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n async function getSentryData() {\n const transaction = Sentry.startTransaction({\n name: 'Example Frontend Transaction'\n });\n\n Sentry.configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n try {\n const res = await fetch('/test-sentry');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n } finally {\n transaction.finish();\n }\n }\n</script>\n\n<div>\n <head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your SvelteKit app!\" />\n </head>\n\n <main>\n <h1>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n </h1>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button\n type=\"button\"\n on:click={getSentryData}>\n Throw error!\n </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"".concat(issuesPageLink, "\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n h1 {\n font-size: 4rem;\n margin: 14px 0;\n }\n\n svg {\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n");
20
+ }
21
+ exports.getSentryExampleSveltePage = getSentryExampleSveltePage;
22
+ function getSentryExampleApiRoute() {
23
+ return "// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n";
24
+ }
25
+ exports.getSentryExampleApiRoute = getSentryExampleApiRoute;
26
+ //# sourceMappingURL=sveltekit-templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sveltekit-templates.js","sourceRoot":"","sources":["../../../src/templates/sveltekit-templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,uJAIC,GAAG,mmBAiBZ,CAAC;AACF,CAAC;AAvBD,wDAuBC;AAED,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,gNAKC,GAAG,yUASZ,CAAC;AACF,CAAC;AAhBD,wDAgBC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CAAC,OAK1C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,4jFAwDQ,cAAc,w7BAgD9B,CAAC;AACF,CAAC;AAnHD,gEAmHC;AAED,SAAgB,wBAAwB;IACtC,OAAO,wOAMR,CAAC;AACF,CAAC;AARD,4DAQC","sourcesContent":["export function getClientHooksTemplate(dsn: string) {\n return `import { handleErrorWithSentry, Replay } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n tracesSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [new Replay()],\n});\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\nexport function getServerHooksTemplate(dsn: string) {\n return `import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n tracesSampleRate: 1.0,\n});\n\n// If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\n/**\n * +page.svelte with Sentry example\n */\nexport function getSentryExampleSveltePage(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}) {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `<!-- \nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file and the entire sentry route. \n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n async function getSentryData() {\n const transaction = Sentry.startTransaction({\n name: 'Example Frontend Transaction'\n });\n\n Sentry.configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n try {\n const res = await fetch('/test-sentry');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n } finally {\n transaction.finish();\n }\n }\n</script>\n\n<div>\n <head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your SvelteKit app!\" />\n </head>\n\n <main>\n <h1>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n </h1>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button\n type=\"button\"\n on:click={getSentryData}>\n Throw error!\n </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n h1 {\n font-size: 4rem;\n margin: 14px 0;\n }\n\n svg {\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n`;\n}\n"]}
@@ -4,6 +4,10 @@ interface WizardProjectData {
4
4
  };
5
5
  projects: SentryProjectData[];
6
6
  }
7
+ export type PackageDotJson = {
8
+ dependencies?: Record<string, string>;
9
+ devDependencies?: Record<string, string>;
10
+ };
7
11
  export interface SentryProjectData {
8
12
  id: string;
9
13
  slug: string;
@@ -37,4 +41,7 @@ export declare function askForSelfHosted(): Promise<{
37
41
  selfHosted: boolean;
38
42
  }>;
39
43
  export declare function addSentryCliRc(authToken: string): Promise<void>;
44
+ export declare function ensurePackageIsInstalled(packageJson: PackageDotJson, packageId: string, packageName: string): Promise<void>;
45
+ export declare function getPackageDotJson(): Promise<PackageDotJson>;
46
+ export declare function hasPackageInstalled(packageName: string, packageJson: PackageDotJson): boolean;
40
47
  export {};
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,14 +58,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
58
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
59
  }
37
60
  };
61
+ var __importDefault = (this && this.__importDefault) || function (mod) {
62
+ return (mod && mod.__esModule) ? mod : { "default": mod };
63
+ };
38
64
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.addSentryCliRc = exports.askForSelfHosted = exports.installPackage = exports.askForWizardLogin = exports.confirmContinueEvenThoughNoGitRepo = exports.printWelcome = exports.abortIfCancelled = exports.abort = void 0;
40
- var clack = require("@clack/prompts");
41
- var axios_1 = require("axios");
42
- var chalk_1 = require("chalk");
43
- var childProcess = require("child_process");
44
- var fs = require("fs");
45
- var path = require("path");
65
+ exports.hasPackageInstalled = exports.getPackageDotJson = exports.ensurePackageIsInstalled = exports.addSentryCliRc = exports.askForSelfHosted = exports.installPackage = exports.askForWizardLogin = exports.confirmContinueEvenThoughNoGitRepo = exports.printWelcome = exports.abortIfCancelled = exports.abort = void 0;
66
+ // @ts-ignore - clack is ESM and TS complains about that. It works though
67
+ var clack = __importStar(require("@clack/prompts"));
68
+ var axios_1 = __importDefault(require("axios"));
69
+ var chalk_1 = __importDefault(require("chalk"));
70
+ var childProcess = __importStar(require("child_process"));
71
+ var fs = __importStar(require("fs"));
72
+ var path = __importStar(require("path"));
46
73
  var timers_1 = require("timers");
47
74
  var url_1 = require("url");
48
75
  var util_1 = require("util");
@@ -54,10 +81,7 @@ exports.abort = abort;
54
81
  function abortIfCancelled(input) {
55
82
  if (clack.isCancel(input)) {
56
83
  clack.cancel('Wizard setup cancelled.');
57
- return process.exit(0);
58
- }
59
- else {
60
- return;
84
+ process.exit(0);
61
85
  }
62
86
  }
63
87
  exports.abortIfCancelled = abortIfCancelled;
@@ -85,22 +109,22 @@ function printWelcome(options) {
85
109
  exports.printWelcome = printWelcome;
86
110
  function confirmContinueEvenThoughNoGitRepo() {
87
111
  return __awaiter(this, void 0, void 0, function () {
88
- var e_1, continueWithoutGit;
89
- return __generator(this, function (_a) {
90
- switch (_a.label) {
112
+ var _a, continueWithoutGit;
113
+ return __generator(this, function (_b) {
114
+ switch (_b.label) {
91
115
  case 0:
92
- _a.trys.push([0, 1, , 3]);
116
+ _b.trys.push([0, 1, , 3]);
93
117
  childProcess.execSync('git rev-parse --is-inside-work-tree', {
94
118
  stdio: 'ignore',
95
119
  });
96
120
  return [3 /*break*/, 3];
97
121
  case 1:
98
- e_1 = _a.sent();
122
+ _a = _b.sent();
99
123
  return [4 /*yield*/, clack.confirm({
100
124
  message: 'You are not inside a git repository. The wizard will create and update files. Do you still want to continue?',
101
125
  })];
102
126
  case 2:
103
- continueWithoutGit = _a.sent();
127
+ continueWithoutGit = _b.sent();
104
128
  abortIfCancelled(continueWithoutGit);
105
129
  if (!continueWithoutGit) {
106
130
  abort();
@@ -114,24 +138,24 @@ function confirmContinueEvenThoughNoGitRepo() {
114
138
  exports.confirmContinueEvenThoughNoGitRepo = confirmContinueEvenThoughNoGitRepo;
115
139
  function askForWizardLogin(options) {
116
140
  return __awaiter(this, void 0, void 0, function () {
117
- var hasSentryAccount, wizardHash, e_2, loginUrl, loginSpinner, data;
118
- return __generator(this, function (_a) {
119
- switch (_a.label) {
141
+ var hasSentryAccount, wizardHash, _a, loginUrl, loginSpinner, data;
142
+ return __generator(this, function (_b) {
143
+ switch (_b.label) {
120
144
  case 0: return [4 /*yield*/, clack.confirm({
121
145
  message: 'Do you already have a Sentry account?',
122
146
  })];
123
147
  case 1:
124
- hasSentryAccount = _a.sent();
148
+ hasSentryAccount = _b.sent();
125
149
  abortIfCancelled(hasSentryAccount);
126
- _a.label = 2;
150
+ _b.label = 2;
127
151
  case 2:
128
- _a.trys.push([2, 4, , 5]);
152
+ _b.trys.push([2, 4, , 5]);
129
153
  return [4 /*yield*/, axios_1.default.get("".concat(options.url, "api/0/wizard/"))];
130
154
  case 3:
131
- wizardHash = (_a.sent()).data.hash;
155
+ wizardHash = (_b.sent()).data.hash;
132
156
  return [3 /*break*/, 5];
133
157
  case 4:
134
- e_2 = _a.sent();
158
+ _a = _b.sent();
135
159
  clack.log.error('Loading Wizard failed.');
136
160
  clack.outro(chalk_1.default.red('Please try again in a few minutes and let us know if this issue persists: https://github.com/getsentry/sentry-wizard/issues'));
137
161
  return [2 /*return*/, process.exit(1)];
@@ -169,7 +193,7 @@ function askForWizardLogin(options) {
169
193
  }, 180000);
170
194
  })];
171
195
  case 6:
172
- data = _a.sent();
196
+ data = _b.sent();
173
197
  loginSpinner.stop('Login complete.');
174
198
  return [2 /*return*/, data];
175
199
  }
@@ -180,7 +204,7 @@ exports.askForWizardLogin = askForWizardLogin;
180
204
  function installPackage(_a) {
181
205
  var packageName = _a.packageName, alreadyInstalled = _a.alreadyInstalled;
182
206
  return __awaiter(this, void 0, void 0, function () {
183
- var shouldUpdatePackage, sdkInstallSpinner, detectedPackageManager, e_3;
207
+ var shouldUpdatePackage, sdkInstallSpinner, detectedPackageManager, e_1;
184
208
  return __generator(this, function (_b) {
185
209
  switch (_b.label) {
186
210
  case 0:
@@ -191,7 +215,10 @@ function installPackage(_a) {
191
215
  case 1:
192
216
  shouldUpdatePackage = _b.sent();
193
217
  abortIfCancelled(shouldUpdatePackage);
194
- return [2 /*return*/];
218
+ if (!shouldUpdatePackage) {
219
+ return [2 /*return*/];
220
+ }
221
+ _b.label = 2;
195
222
  case 2:
196
223
  sdkInstallSpinner = clack.spinner();
197
224
  if (fs.existsSync(path.join(process.cwd(), 'yarn.lock'))) {
@@ -229,9 +256,9 @@ function installPackage(_a) {
229
256
  _b.label = 9;
230
257
  case 9: return [3 /*break*/, 11];
231
258
  case 10:
232
- e_3 = _b.sent();
259
+ e_1 = _b.sent();
233
260
  sdkInstallSpinner.stop('Installation failed.');
234
- clack.log.error("".concat(chalk_1.default.red('Encountered the following error during installation:'), "\n\n").concat(e_3, "\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')));
261
+ 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')));
235
262
  clack.outro('Wizard setup cancelled.');
236
263
  return [2 /*return*/, process.exit(1)];
237
264
  case 11:
@@ -275,9 +302,9 @@ function askForSelfHosted() {
275
302
  exports.askForSelfHosted = askForSelfHosted;
276
303
  function addSentryCliRc(authToken) {
277
304
  return __awaiter(this, void 0, void 0, function () {
278
- var clircExists, clircContents, likelyAlreadyHasAuthToken, e_4, e_5, e_6;
279
- return __generator(this, function (_a) {
280
- switch (_a.label) {
305
+ var clircExists, clircContents, likelyAlreadyHasAuthToken, _a, _b, _c;
306
+ return __generator(this, function (_d) {
307
+ switch (_d.label) {
281
308
  case 0:
282
309
  clircExists = fs.existsSync(path.join(process.cwd(), '.sentryclirc'));
283
310
  if (!clircExists) return [3 /*break*/, 5];
@@ -287,37 +314,37 @@ function addSentryCliRc(authToken) {
287
314
  clack.log.warn("".concat(chalk_1.default.bold('.sentryclirc'), " already has auth token. Will not add one."));
288
315
  return [3 /*break*/, 4];
289
316
  case 1:
290
- _a.trys.push([1, 3, , 4]);
317
+ _d.trys.push([1, 3, , 4]);
291
318
  return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), '.sentryclirc'), "".concat(clircContents, "\n[auth]\ntoken=").concat(authToken, "\n"), { encoding: 'utf8', flag: 'w' })];
292
319
  case 2:
293
- _a.sent();
320
+ _d.sent();
294
321
  clack.log.success("Added auth token to ".concat(chalk_1.default.bold('.sentryclirc')));
295
322
  return [3 /*break*/, 4];
296
323
  case 3:
297
- e_4 = _a.sent();
324
+ _a = _d.sent();
298
325
  clack.log.warning("Failed to add auth token to ".concat(chalk_1.default.bold('.sentryclirc'), ". Uploading source maps during build will likely not work."));
299
326
  return [3 /*break*/, 4];
300
327
  case 4: return [3 /*break*/, 8];
301
328
  case 5:
302
- _a.trys.push([5, 7, , 8]);
329
+ _d.trys.push([5, 7, , 8]);
303
330
  return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), '.sentryclirc'), "[auth]\ntoken=".concat(authToken, "\n"), { encoding: 'utf8', flag: 'w' })];
304
331
  case 6:
305
- _a.sent();
332
+ _d.sent();
306
333
  clack.log.success("Created ".concat(chalk_1.default.bold('.sentryclirc'), " with auth token."));
307
334
  return [3 /*break*/, 8];
308
335
  case 7:
309
- e_5 = _a.sent();
336
+ _b = _d.sent();
310
337
  clack.log.warning("Failed to create ".concat(chalk_1.default.bold('.sentryclirc'), " with auth token. Uploading source maps during build will likely not work."));
311
338
  return [3 /*break*/, 8];
312
339
  case 8:
313
- _a.trys.push([8, 10, , 11]);
340
+ _d.trys.push([8, 10, , 11]);
314
341
  return [4 /*yield*/, fs.promises.appendFile(path.join(process.cwd(), '.gitignore'), '\n# Sentry Auth Token\n.sentryclirc\n', { encoding: 'utf8' })];
315
342
  case 9:
316
- _a.sent();
343
+ _d.sent();
317
344
  clack.log.success("Added ".concat(chalk_1.default.bold('.sentryclirc'), " to ").concat(chalk_1.default.bold('.gitignore'), "."));
318
345
  return [3 /*break*/, 11];
319
346
  case 10:
320
- e_6 = _a.sent();
347
+ _c = _d.sent();
321
348
  clack.log.error("Failed adding ".concat(chalk_1.default.bold('.sentryclirc'), " to ").concat(chalk_1.default.bold('.gitignore'), ". Please add it manually!"));
322
349
  return [3 /*break*/, 11];
323
350
  case 11: return [2 /*return*/];
@@ -326,4 +353,62 @@ function addSentryCliRc(authToken) {
326
353
  });
327
354
  }
328
355
  exports.addSentryCliRc = addSentryCliRc;
356
+ function ensurePackageIsInstalled(packageJson, packageId, packageName) {
357
+ return __awaiter(this, void 0, void 0, function () {
358
+ var continueWithoutPackage;
359
+ return __generator(this, function (_a) {
360
+ switch (_a.label) {
361
+ case 0:
362
+ if (!!hasPackageInstalled(packageId, packageJson)) return [3 /*break*/, 2];
363
+ return [4 /*yield*/, clack.confirm({
364
+ message: "".concat(packageName, " does not seem to be installed. Do you still want to continue?"),
365
+ initialValue: false,
366
+ })];
367
+ case 1:
368
+ continueWithoutPackage = _a.sent();
369
+ abortIfCancelled(continueWithoutPackage);
370
+ if (!continueWithoutPackage) {
371
+ abort();
372
+ }
373
+ _a.label = 2;
374
+ case 2: return [2 /*return*/];
375
+ }
376
+ });
377
+ });
378
+ }
379
+ exports.ensurePackageIsInstalled = ensurePackageIsInstalled;
380
+ function getPackageDotJson() {
381
+ return __awaiter(this, void 0, void 0, function () {
382
+ var packageJsonFileContents, packageJson;
383
+ return __generator(this, function (_a) {
384
+ switch (_a.label) {
385
+ case 0: return [4 /*yield*/, fs.promises
386
+ .readFile(path.join(process.cwd(), 'package.json'), 'utf8')
387
+ .catch(function () {
388
+ clack.log.error('Could not find package.json. Make sure to run the wizard in the root of your app!');
389
+ abort();
390
+ })];
391
+ case 1:
392
+ packageJsonFileContents = _a.sent();
393
+ packageJson = undefined;
394
+ try {
395
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
396
+ packageJson = JSON.parse(packageJsonFileContents);
397
+ }
398
+ catch (_b) {
399
+ clack.log.error('Unable to parse your package.json. Make sure it has a valid format!');
400
+ abort();
401
+ }
402
+ return [2 /*return*/, packageJson || {}];
403
+ }
404
+ });
405
+ });
406
+ }
407
+ exports.getPackageDotJson = getPackageDotJson;
408
+ function hasPackageInstalled(packageName, packageJson) {
409
+ var _a, _b;
410
+ return (!!((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.dependencies) === null || _a === void 0 ? void 0 : _a[packageName]) ||
411
+ !!((_b = packageJson === null || packageJson === void 0 ? void 0 : packageJson.devDependencies) === null || _b === void 0 ? void 0 : _b[packageName]));
412
+ }
413
+ exports.hasPackageInstalled = hasPackageInstalled;
329
414
  //# sourceMappingURL=clack-utils.js.map