@sentry/wizard 3.34.4 → 3.35.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 +13 -1
- package/dist/e2e-tests/tests/nuxt-3.test.d.ts +1 -0
- package/dist/e2e-tests/tests/nuxt-3.test.js +231 -0
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -0
- package/dist/e2e-tests/tests/nuxt-4.test.d.ts +1 -0
- package/dist/e2e-tests/tests/nuxt-4.test.js +232 -0
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -0
- package/dist/e2e-tests/tests/remix.test.js +92 -27
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +102 -42
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +18 -1
- package/dist/e2e-tests/utils/index.js +31 -2
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +1 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/apple/templates.js +2 -2
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +1 -0
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.d.ts +3 -0
- package/dist/src/nuxt/nuxt-wizard.js +220 -0
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -0
- package/dist/src/nuxt/sdk-example.d.ts +8 -0
- package/dist/src/nuxt/sdk-example.js +179 -0
- package/dist/src/nuxt/sdk-example.js.map +1 -0
- package/dist/src/nuxt/sdk-setup.d.ts +8 -0
- package/dist/src/nuxt/sdk-setup.js +275 -0
- package/dist/src/nuxt/sdk-setup.js.map +1 -0
- package/dist/src/nuxt/templates.d.ts +22 -0
- package/dist/src/nuxt/templates.js +84 -0
- package/dist/src/nuxt/templates.js.map +1 -0
- package/dist/src/nuxt/utils.d.ts +1 -0
- package/dist/src/nuxt/utils.js +71 -0
- package/dist/src/nuxt/utils.js.map +1 -0
- package/dist/src/remix/remix-wizard.js +2 -1
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/run.d.ts +1 -1
- package/dist/src/run.js +30 -23
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +1 -1
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +2 -1
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +6 -2
- package/dist/src/utils/clack-utils.js +30 -10
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/test/nuxt/templates.test.d.ts +1 -0
- package/dist/test/nuxt/templates.test.js +70 -0
- package/dist/test/nuxt/templates.test.js.map +1 -0
- package/e2e-tests/README.md +59 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/README.md +75 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/nuxt.config.ts +5 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/package.json +18 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/public/favicon.ico +0 -0
- package/e2e-tests/test-applications/nuxt-3-test-app/public/robots.txt +1 -0
- package/e2e-tests/tests/nuxt-3.test.ts +169 -0
- package/e2e-tests/tests/nuxt-4.test.ts +168 -0
- package/e2e-tests/tests/remix.test.ts +163 -50
- package/e2e-tests/tests/sveltekit.test.ts +180 -79
- package/e2e-tests/utils/index.ts +31 -1
- package/lib/Constants.ts +1 -0
- package/package.json +1 -1
- package/src/apple/templates.ts +14 -2
- package/src/nextjs/nextjs-wizard.ts +1 -0
- package/src/nuxt/nuxt-wizard.ts +166 -0
- package/src/nuxt/sdk-example.ts +135 -0
- package/src/nuxt/sdk-setup.ts +209 -0
- package/src/nuxt/templates.ts +296 -0
- package/src/nuxt/utils.ts +32 -0
- package/src/remix/remix-wizard.ts +2 -1
- package/src/run.ts +7 -0
- package/src/sourcemaps/tools/rollup.ts +1 -1
- package/src/sveltekit/sveltekit-wizard.ts +2 -1
- package/src/utils/clack-utils.ts +32 -8
- package/test/nuxt/templates.test.ts +228 -0
|
@@ -63,20 +63,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
63
63
|
var Constants_1 = require("../../lib/Constants");
|
|
64
64
|
var utils_1 = require("../utils");
|
|
65
65
|
var path = __importStar(require("path"));
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
+
var SERVER_TEMPLATE = "import { createRequestHandler } from '@remix-run/express';\nimport { installGlobals } from '@remix-run/node';\nimport compression from 'compression';\nimport express from 'express';\nimport morgan from 'morgan';\n\ninstallGlobals();\n\nconst viteDevServer =\n process.env.NODE_ENV === 'production'\n ? undefined\n : await import('vite').then(vite =>\n vite.createServer({\n server: { middlewareMode: true },\n }),\n );\n\nconst app = express();\n\napp.use(compression());\napp.disable('x-powered-by');\n\nif (viteDevServer) {\n app.use(viteDevServer.middlewares);\n} else {\n app.use('/assets', express.static('build/client/assets', { immutable: true, maxAge: '1y' }));\n}\n\napp.use(express.static('build/client', { maxAge: '1h' }));\napp.use(morgan('tiny'));\n\napp.all(\n '*',\n createRequestHandler({\n build: viteDevServer\n ? () => viteDevServer.ssrLoadModule('virtual:remix/server-build')\n : await import('./build/server/index.js'),\n }),\n);\n\napp.listen(0, () => console.log('Express server listening'));\n";
|
|
67
|
+
function runWizardOnRemixProject(projectDir, integration, fileModificationFn) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
69
|
var wizardInstance, packageManagerPrompted, tracingOptionPrompted, _a, replayOptionPrompted, _b, _c;
|
|
71
70
|
return __generator(this, function (_d) {
|
|
72
71
|
switch (_d.label) {
|
|
73
72
|
case 0:
|
|
74
73
|
wizardInstance = (0, utils_1.startWizardInstance)(integration, projectDir);
|
|
75
|
-
|
|
74
|
+
packageManagerPrompted = false;
|
|
75
|
+
if (!fileModificationFn) return [3 /*break*/, 3];
|
|
76
|
+
fileModificationFn(projectDir, integration);
|
|
77
|
+
return [4 /*yield*/, wizardInstance.waitForOutput('Do you want to continue anyway?')];
|
|
76
78
|
case 1:
|
|
79
|
+
_d.sent();
|
|
80
|
+
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Please select your package manager.')];
|
|
81
|
+
case 2:
|
|
77
82
|
packageManagerPrompted = _d.sent();
|
|
83
|
+
return [3 /*break*/, 5];
|
|
84
|
+
case 3: return [4 /*yield*/, wizardInstance.waitForOutput('Please select your package manager.')];
|
|
85
|
+
case 4:
|
|
86
|
+
packageManagerPrompted = _d.sent();
|
|
87
|
+
_d.label = 5;
|
|
88
|
+
case 5:
|
|
78
89
|
_a = packageManagerPrompted;
|
|
79
|
-
if (!_a) return [3 /*break*/,
|
|
90
|
+
if (!_a) return [3 /*break*/, 7];
|
|
80
91
|
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput(
|
|
81
92
|
// Selecting `yarn` as the package manager
|
|
82
93
|
[utils_1.KEYS.DOWN, utils_1.KEYS.ENTER],
|
|
@@ -84,43 +95,43 @@ describe('Remix', function () {
|
|
|
84
95
|
'to track the performance of your application?', {
|
|
85
96
|
timeout: 240000,
|
|
86
97
|
})];
|
|
87
|
-
case
|
|
98
|
+
case 6:
|
|
88
99
|
_a = (_d.sent());
|
|
89
|
-
_d.label =
|
|
90
|
-
case
|
|
100
|
+
_d.label = 7;
|
|
101
|
+
case 7:
|
|
91
102
|
tracingOptionPrompted = _a;
|
|
92
103
|
_b = tracingOptionPrompted;
|
|
93
|
-
if (!_b) return [3 /*break*/,
|
|
104
|
+
if (!_b) return [3 /*break*/, 9];
|
|
94
105
|
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER],
|
|
95
106
|
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
96
107
|
'to get a video-like reproduction of errors during a user session?')];
|
|
97
|
-
case
|
|
108
|
+
case 8:
|
|
98
109
|
_b = (_d.sent());
|
|
99
|
-
_d.label =
|
|
100
|
-
case
|
|
110
|
+
_d.label = 9;
|
|
111
|
+
case 9:
|
|
101
112
|
replayOptionPrompted = _b;
|
|
102
113
|
_c = replayOptionPrompted;
|
|
103
|
-
if (!_c) return [3 /*break*/,
|
|
114
|
+
if (!_c) return [3 /*break*/, 11];
|
|
104
115
|
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Do you want to create an example page', {
|
|
105
116
|
optional: true,
|
|
106
117
|
})];
|
|
107
|
-
case
|
|
118
|
+
case 10:
|
|
108
119
|
_c = (_d.sent());
|
|
109
|
-
_d.label =
|
|
110
|
-
case
|
|
120
|
+
_d.label = 11;
|
|
121
|
+
case 11:
|
|
111
122
|
_c;
|
|
112
123
|
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER, utils_1.KEYS.ENTER], 'Sentry has been successfully configured for your Remix project')];
|
|
113
|
-
case
|
|
124
|
+
case 12:
|
|
114
125
|
_d.sent();
|
|
115
126
|
wizardInstance.kill();
|
|
116
127
|
return [2 /*return*/];
|
|
117
128
|
}
|
|
118
129
|
});
|
|
119
|
-
}); });
|
|
120
|
-
afterAll(function () {
|
|
121
|
-
(0, utils_1.revertLocalChanges)(projectDir);
|
|
122
|
-
(0, utils_1.cleanupGit)(projectDir);
|
|
123
130
|
});
|
|
131
|
+
}
|
|
132
|
+
;
|
|
133
|
+
function checkRemixProject(projectDir, integration, options) {
|
|
134
|
+
var _this = this;
|
|
124
135
|
test('package.json is updated correctly', function () {
|
|
125
136
|
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
126
137
|
});
|
|
@@ -157,7 +168,7 @@ describe('Remix', function () {
|
|
|
157
168
|
"export const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};",
|
|
158
169
|
]);
|
|
159
170
|
});
|
|
160
|
-
test('builds
|
|
171
|
+
test('builds successfully', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
161
172
|
return __generator(this, function (_a) {
|
|
162
173
|
switch (_a.label) {
|
|
163
174
|
case 0: return [4 /*yield*/, (0, utils_1.checkIfBuilds)(projectDir, 'built')];
|
|
@@ -167,25 +178,79 @@ describe('Remix', function () {
|
|
|
167
178
|
}
|
|
168
179
|
});
|
|
169
180
|
}); });
|
|
170
|
-
test('runs on dev mode correctly', function () { return __awaiter(
|
|
181
|
+
test('runs on dev mode correctly', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
171
182
|
return __generator(this, function (_a) {
|
|
172
183
|
switch (_a.label) {
|
|
173
|
-
case 0: return [4 /*yield*/, (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'to expose')];
|
|
184
|
+
case 0: return [4 /*yield*/, (0, utils_1.checkIfRunsOnDevMode)(projectDir, (options === null || options === void 0 ? void 0 : options.devModeExpectedOutput) || 'to expose')];
|
|
174
185
|
case 1:
|
|
175
186
|
_a.sent();
|
|
176
187
|
return [2 /*return*/];
|
|
177
188
|
}
|
|
178
189
|
});
|
|
179
190
|
}); });
|
|
180
|
-
test('runs on prod mode correctly', function () { return __awaiter(
|
|
191
|
+
test('runs on prod mode correctly', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
181
192
|
return __generator(this, function (_a) {
|
|
182
193
|
switch (_a.label) {
|
|
183
|
-
case 0: return [4 /*yield*/, (0, utils_1.checkIfRunsOnProdMode)(projectDir, '[remix-serve]')];
|
|
194
|
+
case 0: return [4 /*yield*/, (0, utils_1.checkIfRunsOnProdMode)(projectDir, (options === null || options === void 0 ? void 0 : options.prodModeExpectedOutput) || '[remix-serve]')];
|
|
184
195
|
case 1:
|
|
185
196
|
_a.sent();
|
|
186
197
|
return [2 /*return*/];
|
|
187
198
|
}
|
|
188
199
|
});
|
|
189
200
|
}); });
|
|
201
|
+
}
|
|
202
|
+
describe('Remix', function () {
|
|
203
|
+
describe('with empty project', function () {
|
|
204
|
+
var integration = Constants_1.Integration.remix;
|
|
205
|
+
var projectDir = path.resolve(__dirname, '../test-applications/remix-test-app');
|
|
206
|
+
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
207
|
+
return __generator(this, function (_a) {
|
|
208
|
+
switch (_a.label) {
|
|
209
|
+
case 0: return [4 /*yield*/, runWizardOnRemixProject(projectDir, integration)];
|
|
210
|
+
case 1:
|
|
211
|
+
_a.sent();
|
|
212
|
+
return [2 /*return*/];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}); });
|
|
216
|
+
afterAll(function () {
|
|
217
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
218
|
+
(0, utils_1.cleanupGit)(projectDir);
|
|
219
|
+
});
|
|
220
|
+
checkRemixProject(projectDir, integration);
|
|
221
|
+
});
|
|
222
|
+
describe('with existing custom Express server', function () {
|
|
223
|
+
var integration = Constants_1.Integration.remix;
|
|
224
|
+
var projectDir = path.resolve(__dirname, '../test-applications/remix-test-app');
|
|
225
|
+
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0: return [4 /*yield*/, runWizardOnRemixProject(projectDir, integration, function (projectDir) {
|
|
229
|
+
(0, utils_1.createFile)("".concat(projectDir, "/server.mjs"), SERVER_TEMPLATE);
|
|
230
|
+
(0, utils_1.modifyFile)("".concat(projectDir, "/package.json"), {
|
|
231
|
+
'"start": "remix-serve ./build/server/index.js"': '"start": "node ./server.mjs"',
|
|
232
|
+
'"dev": "remix vite:dev"': '"dev": "node ./server.mjs"',
|
|
233
|
+
});
|
|
234
|
+
})];
|
|
235
|
+
case 1:
|
|
236
|
+
_a.sent();
|
|
237
|
+
return [2 /*return*/];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}); });
|
|
241
|
+
afterAll(function () {
|
|
242
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
243
|
+
(0, utils_1.cleanupGit)(projectDir);
|
|
244
|
+
});
|
|
245
|
+
checkRemixProject(projectDir, integration, {
|
|
246
|
+
devModeExpectedOutput: 'Express server listening',
|
|
247
|
+
prodModeExpectedOutput: 'Express server listening',
|
|
248
|
+
});
|
|
249
|
+
test('server.mjs contains instrumentation file import', function () {
|
|
250
|
+
(0, utils_1.checkFileContents)("".concat(projectDir, "/server.mjs"), [
|
|
251
|
+
"import './instrumentation.server.mjs';",
|
|
252
|
+
]);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
190
255
|
});
|
|
191
256
|
//# sourceMappingURL=remix.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remix.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/remix.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,iDAAkD;AAClD,kCAakB;AAClB,yCAA6B;AAE7B,QAAQ,CAAC,OAAO,EAAE;IAChB,IAAM,WAAW,GAAG,uBAAW,CAAC,KAAK,CAAC;IACtC,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,qCAAqC,CACtC,CAAC;IAEF,SAAS,CAAC;;;;;oBACF,cAAc,GAAG,IAAA,2BAAmB,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;oBACrC,qBAAM,cAAc,CAAC,aAAa,CAC/D,qCAAqC,CACtC,EAAA;;oBAFK,sBAAsB,GAAG,SAE9B;oBAGC,KAAA,sBAAsB,CAAA;6BAAtB,wBAAsB;oBACrB,qBAAM,cAAc,CAAC,yBAAyB;wBAC7C,0CAA0C;wBAC1C,CAAC,YAAI,CAAC,IAAI,EAAE,YAAI,CAAC,KAAK,CAA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;;;;SAC1D,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable jest/expect-expect */\nimport { Integration } from '../../lib/Constants';\nimport {\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n KEYS,\n revertLocalChanges,\n startWizardInstance,\n TEST_ARGS,\n} from '../utils';\nimport * as path from 'path';\n\ndescribe('Remix', () => {\n const integration = Integration.remix;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/remix-test-app',\n );\n\n beforeAll(async () => {\n const wizardInstance = startWizardInstance(integration, projectDir);\n const packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager.',\n );\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n },\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n ));\n\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page',\n {\n optional: true,\n },\n ));\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER, KEYS.ENTER],\n 'Sentry has been successfully configured for your Remix project',\n );\n\n wizardInstance.kill();\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('.env-sentry-build-plugin is created and contains the auth token', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(`${projectDir}/app/routes/sentry-example-page.tsx`);\n });\n\n test('instrumentation.server file exists', () => {\n checkFileExists(`${projectDir}/instrumentation.server.mjs`);\n });\n\n test('entry.client file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/app/entry.client.tsx`, [\n 'import * as Sentry from \"@sentry/remix\";',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n\n integrations: [Sentry.browserTracingIntegration({\n useEffect,\n useLocation,\n useMatches\n }), Sentry.replayIntegration({\n maskAllText: true,\n blockAllMedia: true\n })],\n\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1\n})`,\n ]);\n });\n\n test('entry.server file contains Sentry code', () => {\n checkFileContents(`${projectDir}/app/entry.server.tsx`, [\n 'import * as Sentry from \"@sentry/remix\";',\n `export const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {\n // Custom handleError implementation\n});`,\n ]);\n });\n\n test('instrumentation.server file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/instrumentation.server.mjs`, [\n 'import * as Sentry from \"@sentry/remix\";',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n autoInstrumentRemix: true\n})`,\n ]);\n });\n\n test('root file contains Sentry ErrorBoundary', () => {\n checkFileContents(`${projectDir}/app/root.tsx`, [\n 'import { captureRemixErrorBoundaryError } from \"@sentry/remix\";',\n `export const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};`,\n ]);\n });\n\n test('builds correctly', async () => {\n await checkIfBuilds(projectDir, 'built');\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'to expose');\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, '[remix-serve]');\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"remix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C;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable jest/expect-expect */\nimport { Integration } from '../../lib/Constants';\nimport {\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n createFile,\n KEYS,\n modifyFile,\n revertLocalChanges,\n startWizardInstance,\n TEST_ARGS,\n} from '../utils';\nimport * as path from 'path';\n\nconst SERVER_TEMPLATE = `import { createRequestHandler } from '@remix-run/express';\nimport { installGlobals } from '@remix-run/node';\nimport compression from 'compression';\nimport express from 'express';\nimport morgan from 'morgan';\n\ninstallGlobals();\n\nconst viteDevServer =\n process.env.NODE_ENV === 'production'\n ? undefined\n : await import('vite').then(vite =>\n vite.createServer({\n server: { middlewareMode: true },\n }),\n );\n\nconst app = express();\n\napp.use(compression());\napp.disable('x-powered-by');\n\nif (viteDevServer) {\n app.use(viteDevServer.middlewares);\n} else {\n app.use('/assets', express.static('build/client/assets', { immutable: true, maxAge: '1y' }));\n}\n\napp.use(express.static('build/client', { maxAge: '1h' }));\napp.use(morgan('tiny'));\n\napp.all(\n '*',\n createRequestHandler({\n build: viteDevServer\n ? () => viteDevServer.ssrLoadModule('virtual:remix/server-build')\n : await import('./build/server/index.js'),\n }),\n);\n\napp.listen(0, () => console.log('Express server listening'));\n`;\n\n\nasync function runWizardOnRemixProject(projectDir: string, integration: Integration, fileModificationFn?: (projectDir: string, integration: Integration) => unknown) {\n const wizardInstance = startWizardInstance(integration, projectDir);\n let packageManagerPrompted = false;\n\n if (fileModificationFn) {\n fileModificationFn(projectDir, integration);\n\n await wizardInstance.waitForOutput(\n 'Do you want to continue anyway?',\n );\n\n packageManagerPrompted = await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Please select your package manager.',\n );\n } else {\n\n packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager.',\n );\n }\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n },\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n ));\n\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page',\n {\n optional: true,\n },\n ));\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER, KEYS.ENTER],\n 'Sentry has been successfully configured for your Remix project',\n );\n\n wizardInstance.kill();\n};\n\nfunction checkRemixProject(projectDir: string, integration: Integration, options?: {\n devModeExpectedOutput?: string;\n prodModeExpectedOutput?: string;\n}) {\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('.env-sentry-build-plugin is created and contains the auth token', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(`${projectDir}/app/routes/sentry-example-page.tsx`);\n });\n\n test('instrumentation.server file exists', () => {\n checkFileExists(`${projectDir}/instrumentation.server.mjs`);\n });\n\n test('entry.client file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/app/entry.client.tsx`, [\n 'import * as Sentry from \"@sentry/remix\";',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n\n integrations: [Sentry.browserTracingIntegration({\n useEffect,\n useLocation,\n useMatches\n }), Sentry.replayIntegration({\n maskAllText: true,\n blockAllMedia: true\n })],\n\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1\n})`,\n ]);\n });\n\n test('entry.server file contains Sentry code', () => {\n checkFileContents(`${projectDir}/app/entry.server.tsx`, [\n 'import * as Sentry from \"@sentry/remix\";',\n `export const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {\n // Custom handleError implementation\n});`,\n ]);\n });\n\n test('instrumentation.server file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/instrumentation.server.mjs`, [\n 'import * as Sentry from \"@sentry/remix\";',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n autoInstrumentRemix: true\n})`,\n ]);\n });\n\n test('root file contains Sentry ErrorBoundary', () => {\n checkFileContents(`${projectDir}/app/root.tsx`, [\n 'import { captureRemixErrorBoundaryError } from \"@sentry/remix\";',\n `export const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};`,\n ]);\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir, 'built');\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, options?.devModeExpectedOutput || 'to expose');\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, options?.prodModeExpectedOutput || '[remix-serve]');\n });\n}\n\ndescribe('Remix', () => {\n describe('with empty project', () => {\n const integration = Integration.remix;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/remix-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnRemixProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkRemixProject(projectDir, integration);\n });\n\n describe('with existing custom Express server', () => {\n const integration = Integration.remix;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/remix-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnRemixProject(projectDir, integration, (projectDir) => {\n createFile(\n `${projectDir}/server.mjs`,\n SERVER_TEMPLATE,\n );\n\n modifyFile(`${projectDir}/package.json`, {\n '\"start\": \"remix-serve ./build/server/index.js\"': '\"start\": \"node ./server.mjs\"',\n '\"dev\": \"remix vite:dev\"': '\"dev\": \"node ./server.mjs\"',\n });\n });\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkRemixProject(projectDir, integration, {\n devModeExpectedOutput: 'Express server listening',\n prodModeExpectedOutput: 'Express server listening',\n });\n\n test('server.mjs contains instrumentation file import', () => {\n checkFileContents(`${projectDir}/server.mjs`, [\n \"import './instrumentation.server.mjs';\",\n ]);\n });\n });\n});\n"]}
|
|
@@ -63,22 +63,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
63
63
|
var Constants_1 = require("../../lib/Constants");
|
|
64
64
|
var utils_1 = require("../utils");
|
|
65
65
|
var path = __importStar(require("path"));
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
var SERVER_HOOK_TEMPLATE = "import type { Handle } from '@sveltejs/kit';\n\nexport const handle: Handle = async ({ event, resolve }) => {\n\tif (event.url.pathname.startsWith('/custom')) {\n\t\treturn new Response('custom response');\n\t}\n\n\tconst response = await resolve(event);\n\treturn response;\n};\n";
|
|
67
|
+
var CLIENT_HOOK_TEMPLATE = "\nexport async function handleError({ error, event }) {\n // you can capture the `error` and `event` from the client\n // but it only runs if the unexpected error comes from `+ page.ts`\n console.log(error)\n\n return {\n // don't show sensitive data to the user\n message: 'Yikes! \uD83D\uDCA9',\n }\n}\n";
|
|
68
|
+
function runWizardOnSvelteKitProject(projectDir, integration, fileModificationFn) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
70
|
var wizardInstance, packageManagerPrompted, tracingOptionPrompted, _a, replayOptionPrompted, _b, _c;
|
|
71
71
|
return __generator(this, function (_d) {
|
|
72
72
|
switch (_d.label) {
|
|
73
73
|
case 0:
|
|
74
74
|
wizardInstance = (0, utils_1.startWizardInstance)(integration, projectDir);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
packageManagerPrompted = false;
|
|
76
|
+
if (!fileModificationFn) return [3 /*break*/, 3];
|
|
77
|
+
fileModificationFn(projectDir, integration);
|
|
78
|
+
// As we modified project, we have a warning prompt before we get the package manager prompt
|
|
79
|
+
return [4 /*yield*/, wizardInstance.waitForOutput('Do you want to continue anyway?')];
|
|
78
80
|
case 1:
|
|
81
|
+
// As we modified project, we have a warning prompt before we get the package manager prompt
|
|
82
|
+
_d.sent();
|
|
83
|
+
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Please select your package manager.')];
|
|
84
|
+
case 2:
|
|
79
85
|
packageManagerPrompted = _d.sent();
|
|
86
|
+
return [3 /*break*/, 5];
|
|
87
|
+
case 3: return [4 /*yield*/, wizardInstance.waitForOutput('Please select your package manager')];
|
|
88
|
+
case 4:
|
|
89
|
+
packageManagerPrompted = _d.sent();
|
|
90
|
+
_d.label = 5;
|
|
91
|
+
case 5:
|
|
80
92
|
_a = packageManagerPrompted;
|
|
81
|
-
if (!_a) return [3 /*break*/,
|
|
93
|
+
if (!_a) return [3 /*break*/, 7];
|
|
82
94
|
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput(
|
|
83
95
|
// Selecting `yarn` as the package manager
|
|
84
96
|
[utils_1.KEYS.DOWN, utils_1.KEYS.ENTER],
|
|
@@ -86,43 +98,42 @@ describe('Sveltekit', function () {
|
|
|
86
98
|
'to track the performance of your application?', {
|
|
87
99
|
timeout: 240000,
|
|
88
100
|
})];
|
|
89
|
-
case
|
|
101
|
+
case 6:
|
|
90
102
|
_a = (_d.sent());
|
|
91
|
-
_d.label =
|
|
92
|
-
case
|
|
103
|
+
_d.label = 7;
|
|
104
|
+
case 7:
|
|
93
105
|
tracingOptionPrompted = _a;
|
|
94
106
|
_b = tracingOptionPrompted;
|
|
95
|
-
if (!_b) return [3 /*break*/,
|
|
107
|
+
if (!_b) return [3 /*break*/, 9];
|
|
96
108
|
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER],
|
|
97
109
|
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
98
110
|
'to get a video-like reproduction of errors during a user session?')];
|
|
99
|
-
case
|
|
111
|
+
case 8:
|
|
100
112
|
_b = (_d.sent());
|
|
101
|
-
_d.label =
|
|
102
|
-
case
|
|
113
|
+
_d.label = 9;
|
|
114
|
+
case 9:
|
|
103
115
|
replayOptionPrompted = _b;
|
|
104
116
|
_c = replayOptionPrompted;
|
|
105
|
-
if (!_c) return [3 /*break*/,
|
|
117
|
+
if (!_c) return [3 /*break*/, 11];
|
|
106
118
|
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Do you want to create an example page', {
|
|
107
119
|
optional: true,
|
|
108
120
|
})];
|
|
109
|
-
case
|
|
121
|
+
case 10:
|
|
110
122
|
_c = (_d.sent());
|
|
111
|
-
_d.label =
|
|
112
|
-
case
|
|
123
|
+
_d.label = 11;
|
|
124
|
+
case 11:
|
|
113
125
|
_c;
|
|
114
126
|
return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER, utils_1.KEYS.ENTER], 'Successfully installed the Sentry SvelteKit SDK!')];
|
|
115
|
-
case
|
|
127
|
+
case 12:
|
|
116
128
|
_d.sent();
|
|
117
129
|
wizardInstance.kill();
|
|
118
130
|
return [2 /*return*/];
|
|
119
131
|
}
|
|
120
132
|
});
|
|
121
|
-
}); });
|
|
122
|
-
afterAll(function () {
|
|
123
|
-
(0, utils_1.revertLocalChanges)(projectDir);
|
|
124
|
-
(0, utils_1.cleanupGit)(projectDir);
|
|
125
133
|
});
|
|
134
|
+
}
|
|
135
|
+
function checkSvelteKitProject(projectDir, integration, options) {
|
|
136
|
+
var _this = this;
|
|
126
137
|
test('should have the correct package.json', function () {
|
|
127
138
|
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
128
139
|
});
|
|
@@ -140,47 +151,96 @@ describe('Sveltekit', function () {
|
|
|
140
151
|
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.server.ts'));
|
|
141
152
|
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.client.ts'));
|
|
142
153
|
});
|
|
143
|
-
test('
|
|
144
|
-
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/hooks.client.ts'), ["import * as Sentry from '@sentry/sveltekit';", "Sentry.init({\n dsn: '".concat(utils_1.TEST_ARGS.PROJECT_DSN, "',\n\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: [replayIntegration()],\n});")]);
|
|
145
|
-
});
|
|
146
|
-
test('hooks.server.ts contains sentry import', function () {
|
|
147
|
-
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/hooks.server.ts'), [
|
|
148
|
-
"import * as Sentry from '@sentry/sveltekit';",
|
|
149
|
-
"Sentry.init({\n dsn: '".concat(utils_1.TEST_ARGS.PROJECT_DSN, "',\n\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});")
|
|
150
|
-
]);
|
|
151
|
-
});
|
|
152
|
-
test('runs on dev mode correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
154
|
+
test('builds successfully', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
153
155
|
return __generator(this, function (_a) {
|
|
154
156
|
switch (_a.label) {
|
|
155
|
-
case 0: return [4 /*yield*/, (0, utils_1.
|
|
157
|
+
case 0: return [4 /*yield*/, (0, utils_1.checkIfBuilds)(projectDir, 'Successfully uploaded source maps to Sentry')];
|
|
156
158
|
case 1:
|
|
157
159
|
_a.sent();
|
|
158
160
|
return [2 /*return*/];
|
|
159
161
|
}
|
|
160
162
|
});
|
|
161
163
|
}); });
|
|
162
|
-
test('
|
|
164
|
+
test('runs on dev mode correctly', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
163
165
|
return __generator(this, function (_a) {
|
|
164
166
|
switch (_a.label) {
|
|
165
|
-
case 0: return [4 /*yield*/, (0, utils_1.
|
|
167
|
+
case 0: return [4 /*yield*/, (0, utils_1.checkIfRunsOnDevMode)(projectDir, (options === null || options === void 0 ? void 0 : options.devModeExpectedOutput) || 'ready in')];
|
|
166
168
|
case 1:
|
|
167
169
|
_a.sent();
|
|
168
170
|
return [2 /*return*/];
|
|
169
171
|
}
|
|
170
172
|
});
|
|
171
173
|
}); });
|
|
172
|
-
test('runs on prod mode correctly', function () { return __awaiter(
|
|
174
|
+
test('runs on prod mode correctly', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
173
175
|
return __generator(this, function (_a) {
|
|
174
176
|
switch (_a.label) {
|
|
175
|
-
case 0:
|
|
176
|
-
// We can't use the full prompt `Network: use--host to expose` as `--host` can be printed in bold.
|
|
177
|
-
return [4 /*yield*/, (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'to expose', "preview")];
|
|
177
|
+
case 0: return [4 /*yield*/, (0, utils_1.checkIfRunsOnProdMode)(projectDir, (options === null || options === void 0 ? void 0 : options.prodModeExpectedOutput) || 'to expose', 'preview')];
|
|
178
178
|
case 1:
|
|
179
|
-
// We can't use the full prompt `Network: use--host to expose` as `--host` can be printed in bold.
|
|
180
179
|
_a.sent();
|
|
181
180
|
return [2 /*return*/];
|
|
182
181
|
}
|
|
183
182
|
});
|
|
184
183
|
}); });
|
|
184
|
+
}
|
|
185
|
+
describe('Sveltekit', function () {
|
|
186
|
+
describe('without existing hooks', function () {
|
|
187
|
+
var integration = Constants_1.Integration.sveltekit;
|
|
188
|
+
var projectDir = path.resolve(__dirname, '../test-applications/sveltekit-test-app');
|
|
189
|
+
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0: return [4 /*yield*/, runWizardOnSvelteKitProject(projectDir, integration)];
|
|
193
|
+
case 1:
|
|
194
|
+
_a.sent();
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}); });
|
|
199
|
+
afterAll(function () {
|
|
200
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
201
|
+
(0, utils_1.cleanupGit)(projectDir);
|
|
202
|
+
});
|
|
203
|
+
checkSvelteKitProject(projectDir, integration);
|
|
204
|
+
test('hooks.client.ts contains sentry', function () {
|
|
205
|
+
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/hooks.client.ts'), ["import * as Sentry from '@sentry/sveltekit';", "Sentry.init({\n dsn: '".concat(utils_1.TEST_ARGS.PROJECT_DSN, "',\n\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: [replayIntegration()],\n});"), 'export const handleError = handleErrorWithSentry(']);
|
|
206
|
+
});
|
|
207
|
+
test('hooks.server.ts contains sentry', function () {
|
|
208
|
+
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/hooks.server.ts'), [
|
|
209
|
+
"import * as Sentry from '@sentry/sveltekit';",
|
|
210
|
+
"Sentry.init({\n dsn: '".concat(utils_1.TEST_ARGS.PROJECT_DSN, "',\n\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});"),
|
|
211
|
+
'export const handleError = handleErrorWithSentry();'
|
|
212
|
+
]);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
describe('with existing hooks', function () {
|
|
216
|
+
var integration = Constants_1.Integration.sveltekit;
|
|
217
|
+
var projectDir = path.resolve(__dirname, '../test-applications/sveltekit-test-app');
|
|
218
|
+
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
219
|
+
return __generator(this, function (_a) {
|
|
220
|
+
switch (_a.label) {
|
|
221
|
+
case 0: return [4 /*yield*/, runWizardOnSvelteKitProject(projectDir, integration, function (projectDir) {
|
|
222
|
+
(0, utils_1.createFile)(path.resolve(projectDir, 'src/hooks.server.ts'), SERVER_HOOK_TEMPLATE);
|
|
223
|
+
(0, utils_1.createFile)(path.resolve(projectDir, 'src/hooks.client.ts'), CLIENT_HOOK_TEMPLATE);
|
|
224
|
+
})];
|
|
225
|
+
case 1:
|
|
226
|
+
_a.sent();
|
|
227
|
+
return [2 /*return*/];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}); });
|
|
231
|
+
afterAll(function () {
|
|
232
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
233
|
+
(0, utils_1.cleanupGit)(projectDir);
|
|
234
|
+
});
|
|
235
|
+
checkSvelteKitProject(projectDir, integration);
|
|
236
|
+
// These are removed from the common tests as the content is different
|
|
237
|
+
// when the hooks are merged instead of created from the template
|
|
238
|
+
test('hooks.client.ts contains sentry instrumentation', function () {
|
|
239
|
+
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/hooks.client.ts'), ["import * as Sentry from '@sentry/sveltekit';", "Sentry.init({\n dsn: \"".concat(utils_1.TEST_ARGS.PROJECT_DSN, "\",\n tracesSampleRate: 1,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.replayIntegration()]\n})"), 'export const handleError = Sentry.handleErrorWithSentry(']);
|
|
240
|
+
});
|
|
241
|
+
test('hooks.server.ts contains sentry init', function () {
|
|
242
|
+
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/hooks.server.ts'), ["import * as Sentry from '@sentry/sveltekit';", "Sentry.init({\n dsn: \"".concat(utils_1.TEST_ARGS.PROJECT_DSN, "\",\n tracesSampleRate: 1\n})"), 'export const handleError = Sentry.handleErrorWithSentry();']);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
185
245
|
});
|
|
186
246
|
//# sourceMappingURL=sveltekit.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,iDAAkD;AAClD,kCAakB;AAClB,yCAA6B;AAE7B,QAAQ,CAAC,WAAW,EAAE;IACpB,IAAM,WAAW,GAAG,uBAAW,CAAC,SAAS,CAAC;IAC1C,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,yCAAyC,CAC1C,CAAC;IAEF,SAAS,CAAC;;;;;oBACF,cAAc,GAAG,IAAA,2BAAmB,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;oBAErC,qBAAM,cAAc,CAAC,aAAa,CAC/D,qCAAqC,EACrC;4BACE,QAAQ,EAAE,IAAI;yBACf,CACF,EAAA;;oBALK,sBAAsB,GAAG,SAK9B;oBAGC,KAAA,sBAAsB,CAAA;6BAAtB,wBAAsB;oBACrB,qBAAM,cAAc,CAAC,yBAAyB;wBAC7C,0CAA0C;wBAC1C,CAAC,YAAI,CAAC,IAAI,EAAE,YAAI,CAAC,KAAK,CAAC;wBACvB,+FAA+F;wBAC/F,+CAA+C,EAC/C;4BACE,OAAO,EAAE,MAAO;yBACjB,CACF,EAAA;;oBARD,KAAA,CAAC,SAQA,CAAC,CAAA;;;oBAVE,qBAAqB,KAUvB;oBAGF,KAAA,qBAAqB,CAAA;6BAArB,wBAAqB;oBACpB,qBAAM,cAAc,CAAC,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AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable jest/expect-expect */\nimport { Integration } from '../../lib/Constants';\nimport {\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n KEYS,\n revertLocalChanges,\n startWizardInstance,\n TEST_ARGS,\n} from '../utils';\nimport * as path from 'path';\n\ndescribe('Sveltekit', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-test-app',\n );\n\n beforeAll(async () => {\n const wizardInstance = startWizardInstance(integration, projectDir);\n\n const packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager.',\n {\n optional: true,\n }\n );\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n }\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n ));\n\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page',\n {\n optional: true,\n },\n ));\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER, KEYS.ENTER],\n 'Successfully installed the Sentry SvelteKit SDK!',\n );\n\n wizardInstance.kill();\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n test('should have the correct package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('should have the correct .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(path.resolve(projectDir, 'src/routes/sentry-example/+page.svelte'));\n checkFileExists(path.resolve(projectDir, 'src/routes/sentry-example/+server.js'));\n });\n\n test('vite.config contains sentry plugin', () => {\n checkFileContents(path.resolve(projectDir, 'vite.config.ts'), `plugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n`);\n });\n\n test('hook files created', () => {\n checkFileExists(path.resolve(projectDir, 'src/hooks.server.ts'));\n checkFileExists(path.resolve(projectDir, 'src/hooks.client.ts'));\n });\n\n test('hooks.client.ts contains sentry import', () => {\n checkFileContents(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n [`import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\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: [replayIntegration()],\n});`]);\n });\n\n\n test('hooks.server.ts contains sentry import', () => {\n checkFileContents(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});`])\n });\n\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'ready in');\n });\n\n test('should build successfully', async () => {\n await checkIfBuilds(projectDir, 'Successfully uploaded source maps to Sentry');\n });\n\n test('runs on prod mode correctly', async () => {\n // We can't use the full prompt `Network: use--host to expose` as `--host` can be printed in bold.\n await checkIfRunsOnProdMode(projectDir, 'to expose', \"preview\");\n });\n});\n\n"]}
|
|
1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AU,EAAC,UAAU,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAE/C,sEAAsE;QACtE,iEAAiE;QACjE,IAAI,CAAC,iDAAiD,EAAE;YACtD,IAAA,yBAAiB,EACf,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC/C,CAAC,8CAA8C,EAC7C,oCACE,iBAAS,CAAC,WAAW,4JAK9B,EAAE,0DAA0D,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,sCAAsC,EAAE;YAC3C,IAAA,yBAAiB,EACf,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC/C,CAAC,8CAA8C,EAC7C,oCACE,iBAAS,CAAC,WAAW,qCAE9B,EAAE,4DAA4D,CAAC,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable jest/expect-expect */\nimport { Integration } from '../../lib/Constants';\nimport {\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n createFile,\n KEYS,\n revertLocalChanges,\n startWizardInstance,\n TEST_ARGS,\n} from '../utils';\nimport * as path from 'path';\n\nconst SERVER_HOOK_TEMPLATE = `import type { Handle } from '@sveltejs/kit';\n\nexport const handle: Handle = async ({ event, resolve }) => {\n\tif (event.url.pathname.startsWith('/custom')) {\n\t\treturn new Response('custom response');\n\t}\n\n\tconst response = await resolve(event);\n\treturn response;\n};\n`;\nconst CLIENT_HOOK_TEMPLATE = `\nexport async function handleError({ error, event }) {\n // you can capture the \\`error\\` and \\`event\\` from the client\n // but it only runs if the unexpected error comes from \\`+ page.ts\\`\n console.log(error)\n\n return {\n // don't show sensitive data to the user\n message: 'Yikes! 💩',\n }\n}\n`;\n\nasync function runWizardOnSvelteKitProject(projectDir: string, integration: Integration, fileModificationFn?: (projectDir: string, integration: Integration) => unknown) {\n const wizardInstance = startWizardInstance(integration, projectDir);\n let packageManagerPrompted = false;\n\n if (fileModificationFn) {\n fileModificationFn(projectDir, integration);\n\n // As we modified project, we have a warning prompt before we get the package manager prompt\n await wizardInstance.waitForOutput(\n 'Do you want to continue anyway?',\n );\n\n packageManagerPrompted = await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Please select your package manager.',\n );\n } else {\n packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager'\n );\n }\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n }\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n ));\n\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page',\n {\n optional: true,\n },\n ));\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER, KEYS.ENTER],\n 'Successfully installed the Sentry SvelteKit SDK!',\n );\n\n wizardInstance.kill();\n}\n\nfunction checkSvelteKitProject(projectDir: string, integration: Integration, options?: {\n devModeExpectedOutput: string;\n prodModeExpectedOutput: string;\n}) {\n test('should have the correct package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('should have the correct .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(path.resolve(projectDir, 'src/routes/sentry-example/+page.svelte'));\n checkFileExists(path.resolve(projectDir, 'src/routes/sentry-example/+server.js'));\n });\n\n test('vite.config contains sentry plugin', () => {\n checkFileContents(path.resolve(projectDir, 'vite.config.ts'), `plugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n`);\n });\n\n test('hook files created', () => {\n checkFileExists(path.resolve(projectDir, 'src/hooks.server.ts'));\n checkFileExists(path.resolve(projectDir, 'src/hooks.client.ts'));\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir, 'Successfully uploaded source maps to Sentry');\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, options?.devModeExpectedOutput || 'ready in');\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, options?.prodModeExpectedOutput || 'to expose', 'preview');\n });\n}\n\ndescribe('Sveltekit', () => {\n describe('without existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n test('hooks.client.ts contains sentry', () => {\n checkFileContents(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n [`import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\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: [replayIntegration()],\n});`, 'export const handleError = handleErrorWithSentry(']);\n });\n\n test('hooks.server.ts contains sentry', () => {\n checkFileContents(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});`, 'export const handleError = handleErrorWithSentry();']);\n });\n });\n\n describe('with existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(projectDir, integration, (projectDir) => {\n createFile(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n SERVER_HOOK_TEMPLATE,\n )\n\n createFile(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n CLIENT_HOOK_TEMPLATE,\n )\n });\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n // These are removed from the common tests as the content is different\n // when the hooks are merged instead of created from the template\n test('hooks.client.ts contains sentry instrumentation', () => {\n checkFileContents(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n [`import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.replayIntegration()]\n})`, 'export const handleError = Sentry.handleErrorWithSentry(']);\n });\n\n test('hooks.server.ts contains sentry init', () => {\n checkFileContents(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n [`import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1\n})`, 'export const handleError = Sentry.handleErrorWithSentry();']);\n });\n });\n});\n\n"]}
|
|
@@ -81,11 +81,26 @@ export declare function revertLocalChanges(projectDir: string): void;
|
|
|
81
81
|
*/
|
|
82
82
|
export declare function startWizardInstance(integration: Integration, projectDir: string, debug?: boolean): WizardTestEnv;
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
84
|
+
* Create a file with the given content
|
|
85
85
|
*
|
|
86
86
|
* @param filePath
|
|
87
87
|
* @param content
|
|
88
88
|
*/
|
|
89
|
+
export declare function createFile(filePath: string, content?: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* Modify the file with the new content
|
|
92
|
+
*
|
|
93
|
+
* @param filePath
|
|
94
|
+
* @param oldContent
|
|
95
|
+
* @param newContent
|
|
96
|
+
*/
|
|
97
|
+
export declare function modifyFile(filePath: string, replaceMap: Record<string, string>): void;
|
|
98
|
+
/**
|
|
99
|
+
* Read the file contents and check if it contains the given content
|
|
100
|
+
*
|
|
101
|
+
* @param {string} filePath
|
|
102
|
+
* @param {(string | string[])} content
|
|
103
|
+
*/
|
|
89
104
|
export declare function checkFileContents(filePath: string, content: string | string[]): void;
|
|
90
105
|
/**
|
|
91
106
|
* Check if the file exists
|
|
@@ -95,12 +110,14 @@ export declare function checkFileContents(filePath: string, content: string | st
|
|
|
95
110
|
export declare function checkFileExists(filePath: string): void;
|
|
96
111
|
/**
|
|
97
112
|
* Check if the package.json contains the given integration
|
|
113
|
+
*
|
|
98
114
|
* @param projectDir
|
|
99
115
|
* @param integration
|
|
100
116
|
*/
|
|
101
117
|
export declare function checkPackageJson(projectDir: string, integration: Integration): void;
|
|
102
118
|
/**
|
|
103
119
|
* Check if the .sentryclirc contains the auth token
|
|
120
|
+
*
|
|
104
121
|
* @param projectDir
|
|
105
122
|
*/
|
|
106
123
|
export declare function checkSentryCliRc(projectDir: string): void;
|
|
@@ -70,7 +70,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
-
exports.checkIfRunsOnProdMode = exports.checkIfRunsOnDevMode = exports.checkIfBuilds = exports.checkEnvBuildPlugin = exports.checkSentryCliRc = exports.checkPackageJson = exports.checkFileExists = exports.checkFileContents = exports.startWizardInstance = exports.revertLocalChanges = exports.cleanupGit = exports.initGit = exports.WizardTestEnv = exports.log = exports.TEST_ARGS = exports.KEYS = void 0;
|
|
73
|
+
exports.checkIfRunsOnProdMode = exports.checkIfRunsOnDevMode = exports.checkIfBuilds = exports.checkEnvBuildPlugin = exports.checkSentryCliRc = exports.checkPackageJson = exports.checkFileExists = exports.checkFileContents = exports.modifyFile = exports.createFile = exports.startWizardInstance = exports.revertLocalChanges = exports.cleanupGit = exports.initGit = exports.WizardTestEnv = exports.log = exports.TEST_ARGS = exports.KEYS = void 0;
|
|
74
74
|
var fs = __importStar(require("fs"));
|
|
75
75
|
var path = __importStar(require("path"));
|
|
76
76
|
var child_process_1 = require("child_process");
|
|
@@ -259,11 +259,38 @@ function startWizardInstance(integration, projectDir, debug) {
|
|
|
259
259
|
}
|
|
260
260
|
exports.startWizardInstance = startWizardInstance;
|
|
261
261
|
/**
|
|
262
|
-
*
|
|
262
|
+
* Create a file with the given content
|
|
263
263
|
*
|
|
264
264
|
* @param filePath
|
|
265
265
|
* @param content
|
|
266
266
|
*/
|
|
267
|
+
function createFile(filePath, content) {
|
|
268
|
+
return fs.writeFileSync(filePath, content || '');
|
|
269
|
+
}
|
|
270
|
+
exports.createFile = createFile;
|
|
271
|
+
/**
|
|
272
|
+
* Modify the file with the new content
|
|
273
|
+
*
|
|
274
|
+
* @param filePath
|
|
275
|
+
* @param oldContent
|
|
276
|
+
* @param newContent
|
|
277
|
+
*/
|
|
278
|
+
function modifyFile(filePath, replaceMap) {
|
|
279
|
+
var fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
280
|
+
var newFileContent = fileContent;
|
|
281
|
+
for (var _i = 0, _a = Object.entries(replaceMap); _i < _a.length; _i++) {
|
|
282
|
+
var _b = _a[_i], oldContent = _b[0], newContent = _b[1];
|
|
283
|
+
newFileContent = newFileContent.replace(oldContent, newContent);
|
|
284
|
+
}
|
|
285
|
+
fs.writeFileSync(filePath, newFileContent);
|
|
286
|
+
}
|
|
287
|
+
exports.modifyFile = modifyFile;
|
|
288
|
+
/**
|
|
289
|
+
* Read the file contents and check if it contains the given content
|
|
290
|
+
*
|
|
291
|
+
* @param {string} filePath
|
|
292
|
+
* @param {(string | string[])} content
|
|
293
|
+
*/
|
|
267
294
|
function checkFileContents(filePath, content) {
|
|
268
295
|
var fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
269
296
|
var contentArray = Array.isArray(content) ? content : [content];
|
|
@@ -284,6 +311,7 @@ function checkFileExists(filePath) {
|
|
|
284
311
|
exports.checkFileExists = checkFileExists;
|
|
285
312
|
/**
|
|
286
313
|
* Check if the package.json contains the given integration
|
|
314
|
+
*
|
|
287
315
|
* @param projectDir
|
|
288
316
|
* @param integration
|
|
289
317
|
*/
|
|
@@ -293,6 +321,7 @@ function checkPackageJson(projectDir, integration) {
|
|
|
293
321
|
exports.checkPackageJson = checkPackageJson;
|
|
294
322
|
/**
|
|
295
323
|
* Check if the .sentryclirc contains the auth token
|
|
324
|
+
*
|
|
296
325
|
* @param projectDir
|
|
297
326
|
*/
|
|
298
327
|
function checkSentryCliRc(projectDir) {
|