@sentry/wizard 6.6.1 → 6.7.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 +22 -0
- package/LICENSE +97 -8
- package/dist/bin.js +5 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/help-message.test.js +5 -1
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +79 -0
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-router.test.d.ts +1 -0
- package/dist/e2e-tests/tests/react-router.test.js +255 -0
- package/dist/e2e-tests/tests/react-router.test.js.map +1 -0
- package/dist/e2e-tests/utils/index.d.ts +8 -2
- package/dist/e2e-tests/utils/index.js +72 -21
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/src/android/android-wizard.js +8 -1
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/angular/angular-wizard.js +8 -1
- package/dist/src/angular/angular-wizard.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +8 -1
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +8 -1
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +35 -9
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +3 -3
- package/dist/src/nextjs/templates.js +18 -7
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +8 -1
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +8 -1
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-router/codemods/client.entry.d.ts +1 -0
- package/dist/src/react-router/codemods/client.entry.js +73 -0
- package/dist/src/react-router/codemods/client.entry.js.map +1 -0
- package/dist/src/react-router/codemods/react-router-config.d.ts +9 -0
- package/dist/src/react-router/codemods/react-router-config.js +178 -0
- package/dist/src/react-router/codemods/react-router-config.js.map +1 -0
- package/dist/src/react-router/codemods/root.d.ts +1 -0
- package/dist/src/react-router/codemods/root.js +171 -0
- package/dist/src/react-router/codemods/root.js.map +1 -0
- package/dist/src/react-router/codemods/routes-config.d.ts +1 -0
- package/dist/src/react-router/codemods/routes-config.js +106 -0
- package/dist/src/react-router/codemods/routes-config.js.map +1 -0
- package/dist/src/react-router/codemods/server-entry.d.ts +4 -0
- package/dist/src/react-router/codemods/server-entry.js +275 -0
- package/dist/src/react-router/codemods/server-entry.js.map +1 -0
- package/dist/src/react-router/codemods/utils.d.ts +2 -0
- package/dist/src/react-router/codemods/utils.js +13 -0
- package/dist/src/react-router/codemods/utils.js.map +1 -0
- package/dist/src/react-router/codemods/vite.d.ts +8 -0
- package/dist/src/react-router/codemods/vite.js +169 -0
- package/dist/src/react-router/codemods/vite.js.map +1 -0
- package/dist/src/react-router/react-router-wizard.d.ts +2 -0
- package/dist/src/react-router/react-router-wizard.js +254 -0
- package/dist/src/react-router/react-router-wizard.js.map +1 -0
- package/dist/src/react-router/sdk-example.d.ts +18 -0
- package/dist/src/react-router/sdk-example.js +306 -0
- package/dist/src/react-router/sdk-example.js.map +1 -0
- package/dist/src/react-router/sdk-setup.d.ts +17 -0
- package/dist/src/react-router/sdk-setup.js +250 -0
- package/dist/src/react-router/sdk-setup.js.map +1 -0
- package/dist/src/react-router/templates.d.ts +11 -0
- package/dist/src/react-router/templates.js +273 -0
- package/dist/src/react-router/templates.js.map +1 -0
- package/dist/src/remix/remix-wizard.js +8 -1
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/run.d.ts +2 -1
- package/dist/src/run.js +6 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +8 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +8 -1
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/ast-utils.d.ts +30 -0
- package/dist/src/utils/ast-utils.js +71 -1
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack/index.d.ts +5 -2
- package/dist/src/utils/clack/index.js +8 -0
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/utils/types.d.ts +9 -0
- package/dist/src/utils/types.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +20 -0
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/react-router/codemods/client-entry.test.d.ts +1 -0
- package/dist/test/react-router/codemods/client-entry.test.js +168 -0
- package/dist/test/react-router/codemods/client-entry.test.js.map +1 -0
- package/dist/test/react-router/codemods/react-router-config.test.d.ts +1 -0
- package/dist/test/react-router/codemods/react-router-config.test.js +168 -0
- package/dist/test/react-router/codemods/react-router-config.test.js.map +1 -0
- package/dist/test/react-router/codemods/root.test.d.ts +1 -0
- package/dist/test/react-router/codemods/root.test.js +178 -0
- package/dist/test/react-router/codemods/root.test.js.map +1 -0
- package/dist/test/react-router/codemods/server-entry.test.d.ts +1 -0
- package/dist/test/react-router/codemods/server-entry.test.js +415 -0
- package/dist/test/react-router/codemods/server-entry.test.js.map +1 -0
- package/dist/test/react-router/codemods/vite.test.d.ts +1 -0
- package/dist/test/react-router/codemods/vite.test.js +158 -0
- package/dist/test/react-router/codemods/vite.test.js.map +1 -0
- package/dist/test/react-router/routes-config.test.d.ts +1 -0
- package/dist/test/react-router/routes-config.test.js +156 -0
- package/dist/test/react-router/routes-config.test.js.map +1 -0
- package/dist/test/react-router/sdk-setup.test.d.ts +1 -0
- package/dist/test/react-router/sdk-setup.test.js +411 -0
- package/dist/test/react-router/sdk-setup.test.js.map +1 -0
- package/dist/test/react-router/templates.test.d.ts +1 -0
- package/dist/test/react-router/templates.test.js +220 -0
- package/dist/test/react-router/templates.test.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,255 @@
|
|
|
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
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const path = __importStar(require("node:path"));
|
|
27
|
+
const fs = __importStar(require("node:fs"));
|
|
28
|
+
const Constants_1 = require("../../lib/Constants");
|
|
29
|
+
const utils_1 = require("../utils");
|
|
30
|
+
const vitest_1 = require("vitest");
|
|
31
|
+
async function runWizardOnReactRouterProject(projectDir, integration) {
|
|
32
|
+
const wizardInstance = (0, utils_1.startWizardInstance)(integration, projectDir);
|
|
33
|
+
const packageManagerPrompted = await wizardInstance.waitForOutput('Please select your package manager.');
|
|
34
|
+
const tracingOptionPrompted = packageManagerPrompted &&
|
|
35
|
+
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.DOWN, utils_1.KEYS.ENTER], 'to track the performance of your application?', { timeout: 240000 }));
|
|
36
|
+
const replayOptionPrompted = tracingOptionPrompted &&
|
|
37
|
+
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'to get a video-like reproduction of errors during a user session?'));
|
|
38
|
+
const logOptionPrompted = replayOptionPrompted &&
|
|
39
|
+
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'to send your application logs to Sentry?'));
|
|
40
|
+
const profilingOptionPrompted = logOptionPrompted &&
|
|
41
|
+
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'to track application performance in detail?'));
|
|
42
|
+
const examplePagePrompted = profilingOptionPrompted &&
|
|
43
|
+
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Do you want to create an example page'));
|
|
44
|
+
const mcpPrompted = examplePagePrompted &&
|
|
45
|
+
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?', { optional: true }));
|
|
46
|
+
mcpPrompted &&
|
|
47
|
+
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.DOWN, utils_1.KEYS.ENTER], 'Successfully installed the Sentry React Router SDK!'));
|
|
48
|
+
wizardInstance.kill();
|
|
49
|
+
}
|
|
50
|
+
function checkReactRouterProject(projectDir, integration) {
|
|
51
|
+
(0, vitest_1.test)('package.json is updated correctly', () => {
|
|
52
|
+
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
53
|
+
});
|
|
54
|
+
(0, vitest_1.test)('.env.sentry-build-plugin is created and contains the auth token', () => {
|
|
55
|
+
(0, utils_1.checkEnvBuildPlugin)(projectDir);
|
|
56
|
+
});
|
|
57
|
+
(0, vitest_1.test)('example page exists', () => {
|
|
58
|
+
(0, utils_1.checkFileExists)(`${projectDir}/app/routes/sentry-example-page.tsx`);
|
|
59
|
+
});
|
|
60
|
+
(0, vitest_1.test)('example API route exists', () => {
|
|
61
|
+
(0, utils_1.checkFileExists)(`${projectDir}/app/routes/api.sentry-example-api.ts`);
|
|
62
|
+
});
|
|
63
|
+
(0, vitest_1.test)('example page is added to routes configuration', () => {
|
|
64
|
+
(0, utils_1.checkFileContents)(`${projectDir}/app/routes.ts`, [
|
|
65
|
+
'route("/sentry-example-page", "routes/sentry-example-page.tsx")',
|
|
66
|
+
'route("/api/sentry-example-api", "routes/api.sentry-example-api.ts")',
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.test)('instrument.server file exists', () => {
|
|
70
|
+
(0, utils_1.checkFileExists)(`${projectDir}/instrument.server.mjs`);
|
|
71
|
+
});
|
|
72
|
+
(0, vitest_1.test)('entry.client file contains Sentry initialization', () => {
|
|
73
|
+
(0, utils_1.checkFileContents)(`${projectDir}/app/entry.client.tsx`, [
|
|
74
|
+
'import * as Sentry from',
|
|
75
|
+
'@sentry/react-router',
|
|
76
|
+
`Sentry.init({
|
|
77
|
+
dsn: "${utils_1.TEST_ARGS.PROJECT_DSN}",`,
|
|
78
|
+
'integrations: [Sentry.reactRouterTracingIntegration(), Sentry.replayIntegration()]',
|
|
79
|
+
'enableLogs: true,',
|
|
80
|
+
'tracesSampleRate: 1.0,',
|
|
81
|
+
]);
|
|
82
|
+
});
|
|
83
|
+
(0, vitest_1.test)('package.json scripts are updated correctly', () => {
|
|
84
|
+
(0, utils_1.checkFileContents)(`${projectDir}/package.json`, [
|
|
85
|
+
`"start": "NODE_OPTIONS='--import ./instrument.server.mjs' react-router-serve ./build/server/index.js"`,
|
|
86
|
+
`"dev": "NODE_OPTIONS='--import ./instrument.server.mjs' react-router dev"`,
|
|
87
|
+
]);
|
|
88
|
+
});
|
|
89
|
+
(0, vitest_1.test)('entry.server file contains Sentry instrumentation', () => {
|
|
90
|
+
(0, utils_1.checkFileContents)(`${projectDir}/app/entry.server.tsx`, [
|
|
91
|
+
'import * as Sentry from',
|
|
92
|
+
'@sentry/react-router',
|
|
93
|
+
'export const handleError = Sentry.createSentryHandleError(',
|
|
94
|
+
'export default Sentry.wrapSentryHandleRequest(handleRequest);'
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
(0, vitest_1.test)('instrument.server file contains Sentry initialization', () => {
|
|
98
|
+
(0, utils_1.checkFileContents)(`${projectDir}/instrument.server.mjs`, [
|
|
99
|
+
'import * as Sentry from \'@sentry/react-router\';',
|
|
100
|
+
`Sentry.init({
|
|
101
|
+
dsn: "${utils_1.TEST_ARGS.PROJECT_DSN}",`,
|
|
102
|
+
'enableLogs: true,',
|
|
103
|
+
]);
|
|
104
|
+
});
|
|
105
|
+
(0, vitest_1.test)('root file contains Sentry ErrorBoundary', () => {
|
|
106
|
+
(0, utils_1.checkFileContents)(`${projectDir}/app/root.tsx`, [
|
|
107
|
+
'import * as Sentry from',
|
|
108
|
+
'@sentry/react-router',
|
|
109
|
+
'export function ErrorBoundary',
|
|
110
|
+
'Sentry.captureException(error)',
|
|
111
|
+
]);
|
|
112
|
+
});
|
|
113
|
+
(0, vitest_1.test)('vite.config file contains sentryReactRouter plugin', () => {
|
|
114
|
+
(0, utils_1.checkFileContents)(`${projectDir}/vite.config.ts`, [
|
|
115
|
+
'import { sentryReactRouter } from',
|
|
116
|
+
'@sentry/react-router',
|
|
117
|
+
'sentryReactRouter(',
|
|
118
|
+
'authToken: process.env.SENTRY_AUTH_TOKEN',
|
|
119
|
+
]);
|
|
120
|
+
});
|
|
121
|
+
(0, vitest_1.test)('react-router.config file contains buildEnd hook with sentryOnBuildEnd', () => {
|
|
122
|
+
(0, utils_1.checkFileContents)(`${projectDir}/react-router.config.ts`, [
|
|
123
|
+
'import { sentryOnBuildEnd } from',
|
|
124
|
+
'@sentry/react-router',
|
|
125
|
+
'ssr: true,',
|
|
126
|
+
'buildEnd: async',
|
|
127
|
+
'await sentryOnBuildEnd({',
|
|
128
|
+
]);
|
|
129
|
+
});
|
|
130
|
+
(0, vitest_1.test)('builds successfully', async () => {
|
|
131
|
+
await (0, utils_1.checkIfBuilds)(projectDir);
|
|
132
|
+
}, 60000); // 1 minute timeout
|
|
133
|
+
(0, vitest_1.test)('runs on dev mode correctly', async () => {
|
|
134
|
+
await (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'to expose');
|
|
135
|
+
}, 30000); // 30 second timeout
|
|
136
|
+
(0, vitest_1.test)('runs on prod mode correctly', async () => {
|
|
137
|
+
await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'react-router-serve');
|
|
138
|
+
}, 30000); // 30 second timeout
|
|
139
|
+
}
|
|
140
|
+
(0, vitest_1.describe)('React Router', () => {
|
|
141
|
+
(0, vitest_1.describe)('with empty project', () => {
|
|
142
|
+
const integration = Constants_1.Integration.reactRouter;
|
|
143
|
+
const projectDir = path.resolve(__dirname, '../test-applications/react-router-test-app');
|
|
144
|
+
(0, vitest_1.beforeAll)(async () => {
|
|
145
|
+
await runWizardOnReactRouterProject(projectDir, integration);
|
|
146
|
+
});
|
|
147
|
+
(0, vitest_1.afterAll)(() => {
|
|
148
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
149
|
+
(0, utils_1.cleanupGit)(projectDir);
|
|
150
|
+
});
|
|
151
|
+
checkReactRouterProject(projectDir, integration);
|
|
152
|
+
});
|
|
153
|
+
(0, vitest_1.describe)('edge cases', () => {
|
|
154
|
+
const baseProjectDir = path.resolve(__dirname, '../test-applications/react-router-test-app');
|
|
155
|
+
(0, vitest_1.describe)('existing Sentry setup', () => {
|
|
156
|
+
const integration = Constants_1.Integration.reactRouter;
|
|
157
|
+
const projectDir = path.resolve(__dirname, '../test-applications/react-router-test-app-existing');
|
|
158
|
+
(0, vitest_1.beforeAll)(async () => {
|
|
159
|
+
// Copy project and add existing Sentry setup
|
|
160
|
+
fs.cpSync(baseProjectDir, projectDir, { recursive: true });
|
|
161
|
+
const clientEntryPath = path.join(projectDir, 'app', 'entry.client.tsx');
|
|
162
|
+
const existingContent = `import * as Sentry from "@sentry/react-router";
|
|
163
|
+
import { startTransition, StrictMode } from "react";
|
|
164
|
+
import { hydrateRoot } from "react-dom/client";
|
|
165
|
+
import { HydratedRouter } from "react-router/dom";
|
|
166
|
+
|
|
167
|
+
Sentry.init({
|
|
168
|
+
dsn: "https://existing@dsn.ingest.sentry.io/1337",
|
|
169
|
+
tracesSampleRate: 1.0,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
startTransition(() => {
|
|
173
|
+
hydrateRoot(
|
|
174
|
+
document,
|
|
175
|
+
<StrictMode>
|
|
176
|
+
<HydratedRouter />
|
|
177
|
+
</StrictMode>
|
|
178
|
+
);
|
|
179
|
+
});`;
|
|
180
|
+
fs.writeFileSync(clientEntryPath, existingContent);
|
|
181
|
+
await runWizardOnReactRouterProject(projectDir, integration);
|
|
182
|
+
});
|
|
183
|
+
(0, vitest_1.afterAll)(() => {
|
|
184
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
185
|
+
(0, utils_1.cleanupGit)(projectDir);
|
|
186
|
+
try {
|
|
187
|
+
fs.rmSync(projectDir, { recursive: true, force: true });
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
// Ignore cleanup errors
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
(0, vitest_1.test)('wizard handles existing Sentry without duplication', () => {
|
|
194
|
+
const clientContent = fs.readFileSync(`${projectDir}/app/entry.client.tsx`, 'utf8');
|
|
195
|
+
const sentryImportCount = (clientContent.match(/import \* as Sentry from "@sentry\/react-router"/g) || []).length;
|
|
196
|
+
const sentryInitCount = (clientContent.match(/Sentry\.init\(/g) || []).length;
|
|
197
|
+
(0, vitest_1.expect)(sentryImportCount).toBe(1);
|
|
198
|
+
(0, vitest_1.expect)(sentryInitCount).toBe(1);
|
|
199
|
+
});
|
|
200
|
+
// Only test the essential checks for this edge case
|
|
201
|
+
(0, vitest_1.test)('package.json is updated correctly', () => {
|
|
202
|
+
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
203
|
+
});
|
|
204
|
+
(0, vitest_1.test)('essential files exist or wizard completes gracefully', () => {
|
|
205
|
+
// Check if key directories exist
|
|
206
|
+
(0, vitest_1.expect)(fs.existsSync(`${projectDir}/app`)).toBe(true);
|
|
207
|
+
// When there's existing Sentry setup, the wizard may skip some file creation
|
|
208
|
+
// to avoid conflicts. This is acceptable behavior.
|
|
209
|
+
// Let's check if the wizard at least completed by verifying package.json was updated
|
|
210
|
+
const packageJsonPath = `${projectDir}/package.json`;
|
|
211
|
+
(0, vitest_1.expect)(fs.existsSync(packageJsonPath)).toBe(true);
|
|
212
|
+
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');
|
|
213
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
214
|
+
const hasSentryPackage = (packageJson.dependencies?.['@sentry/react-router']) ||
|
|
215
|
+
(packageJson.devDependencies?.['@sentry/react-router']);
|
|
216
|
+
// The wizard should have at least installed the Sentry package
|
|
217
|
+
(0, vitest_1.expect)(hasSentryPackage).toBeTruthy();
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
(0, vitest_1.describe)('missing entry files', () => {
|
|
221
|
+
const integration = Constants_1.Integration.reactRouter;
|
|
222
|
+
const projectDir = path.resolve(__dirname, '../test-applications/react-router-test-app-missing-entries');
|
|
223
|
+
(0, vitest_1.beforeAll)(async () => {
|
|
224
|
+
// Copy project and remove entry files
|
|
225
|
+
fs.cpSync(baseProjectDir, projectDir, { recursive: true });
|
|
226
|
+
const entryClientPath = path.join(projectDir, 'app', 'entry.client.tsx');
|
|
227
|
+
const entryServerPath = path.join(projectDir, 'app', 'entry.server.tsx');
|
|
228
|
+
if (fs.existsSync(entryClientPath))
|
|
229
|
+
fs.unlinkSync(entryClientPath);
|
|
230
|
+
if (fs.existsSync(entryServerPath))
|
|
231
|
+
fs.unlinkSync(entryServerPath);
|
|
232
|
+
await runWizardOnReactRouterProject(projectDir, integration);
|
|
233
|
+
});
|
|
234
|
+
(0, vitest_1.afterAll)(() => {
|
|
235
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
236
|
+
(0, utils_1.cleanupGit)(projectDir);
|
|
237
|
+
try {
|
|
238
|
+
fs.rmSync(projectDir, { recursive: true, force: true });
|
|
239
|
+
}
|
|
240
|
+
catch (e) {
|
|
241
|
+
// Ignore cleanup errors
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
(0, vitest_1.test)('wizard creates missing entry files', () => {
|
|
245
|
+
(0, utils_1.checkFileExists)(`${projectDir}/app/entry.client.tsx`);
|
|
246
|
+
(0, utils_1.checkFileExists)(`${projectDir}/app/entry.server.tsx`);
|
|
247
|
+
});
|
|
248
|
+
(0, vitest_1.test)('basic configuration still works', () => {
|
|
249
|
+
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
250
|
+
(0, utils_1.checkFileExists)(`${projectDir}/instrument.server.mjs`);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
//# sourceMappingURL=react-router.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-router.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/react-router.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAC9B,mDAAkD;AAClD,oCAakB;AAClB,mCAAqE;AAErE,KAAK,UAAU,6BAA6B,CAC1C,UAAkB,EAClB,WAAwB;IAExB,MAAM,cAAc,GAAG,IAAA,2BAAmB,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAEpE,MAAM,sBAAsB,GAAG,MAAM,cAAc,CAAC,aAAa,CAC/D,qCAAqC,CACtC,CA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,WAAW,CAAC,CAAC;gBAC1C,IAAA,uBAAe,EAAC,GAAG,UAAU,wBAAwB,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { Integration } from '../../lib/Constants';\nimport {\n KEYS,\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test, expect } from 'vitest';\n\nasync function runWizardOnReactRouterProject(\n projectDir: string,\n integration: Integration,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir);\n\n const packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager.',\n );\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER],\n 'to track the performance of your application?',\n { timeout: 240_000 }\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'to get a video-like reproduction of errors during a user session?'\n ));\n\n const logOptionPrompted =\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'to send your application logs to Sentry?'\n ));\n\n const profilingOptionPrompted =\n logOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'to track application performance in detail?'\n ));\n\n const examplePagePrompted =\n profilingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page'\n ));\n\n const mcpPrompted =\n examplePagePrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n { optional: true }\n ));\n\n mcpPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER],\n 'Successfully installed the Sentry React Router SDK!'\n ));\n\n wizardInstance.kill();\n}\n\nfunction checkReactRouterProject(projectDir: string, integration: Integration) {\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('example API route exists', () => {\n checkFileExists(`${projectDir}/app/routes/api.sentry-example-api.ts`);\n });\n\n test('example page is added to routes configuration', () => {\n checkFileContents(`${projectDir}/app/routes.ts`, [\n 'route(\"/sentry-example-page\", \"routes/sentry-example-page.tsx\")',\n 'route(\"/api/sentry-example-api\", \"routes/api.sentry-example-api.ts\")',\n ]);\n });\n\n test('instrument.server file exists', () => {\n checkFileExists(`${projectDir}/instrument.server.mjs`);\n });\n\n test('entry.client file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/app/entry.client.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",`,\n 'integrations: [Sentry.reactRouterTracingIntegration(), Sentry.replayIntegration()]',\n 'enableLogs: true,',\n 'tracesSampleRate: 1.0,',\n ]);\n });\n\n test('package.json scripts are updated correctly', () => {\n checkFileContents(`${projectDir}/package.json`, [\n `\"start\": \"NODE_OPTIONS='--import ./instrument.server.mjs' react-router-serve ./build/server/index.js\"`,\n `\"dev\": \"NODE_OPTIONS='--import ./instrument.server.mjs' react-router dev\"`,\n ]);\n });\n\n test('entry.server file contains Sentry instrumentation', () => {\n checkFileContents(`${projectDir}/app/entry.server.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n 'export const handleError = Sentry.createSentryHandleError(',\n 'export default Sentry.wrapSentryHandleRequest(handleRequest);'\n ]);\n });\n\n test('instrument.server file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/instrument.server.mjs`, [\n 'import * as Sentry from \\'@sentry/react-router\\';',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",`,\n 'enableLogs: true,',\n ]);\n });\n\n test('root file contains Sentry ErrorBoundary', () => {\n checkFileContents(`${projectDir}/app/root.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n 'export function ErrorBoundary',\n 'Sentry.captureException(error)',\n ]);\n });\n\n test('vite.config file contains sentryReactRouter plugin', () => {\n checkFileContents(`${projectDir}/vite.config.ts`, [\n 'import { sentryReactRouter } from',\n '@sentry/react-router',\n 'sentryReactRouter(',\n 'authToken: process.env.SENTRY_AUTH_TOKEN',\n ]);\n });\n\n test('react-router.config file contains buildEnd hook with sentryOnBuildEnd', () => {\n checkFileContents(`${projectDir}/react-router.config.ts`, [\n 'import { sentryOnBuildEnd } from',\n '@sentry/react-router',\n 'ssr: true,',\n 'buildEnd: async',\n 'await sentryOnBuildEnd({',\n ]);\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n }, 60000); // 1 minute timeout\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'to expose');\n }, 30000); // 30 second timeout\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'react-router-serve');\n }, 30000); // 30 second timeout\n}\n\ndescribe('React Router', () => {\n describe('with empty project', () => {\n const integration = Integration.reactRouter;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-router-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnReactRouterProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkReactRouterProject(projectDir, integration);\n });\n\n describe('edge cases', () => {\n const baseProjectDir = path.resolve(\n __dirname,\n '../test-applications/react-router-test-app',\n );\n\n describe('existing Sentry setup', () => {\n const integration = Integration.reactRouter;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-router-test-app-existing',\n );\n\n beforeAll(async () => {\n // Copy project and add existing Sentry setup\n fs.cpSync(baseProjectDir, projectDir, { recursive: true });\n\n const clientEntryPath = path.join(projectDir, 'app', 'entry.client.tsx');\n const existingContent = `import * as Sentry from \"@sentry/react-router\";\nimport { startTransition, StrictMode } from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport { HydratedRouter } from \"react-router/dom\";\n\nSentry.init({\n dsn: \"https://existing@dsn.ingest.sentry.io/1337\",\n tracesSampleRate: 1.0,\n});\n\nstartTransition(() => {\n hydrateRoot(\n document,\n <StrictMode>\n <HydratedRouter />\n </StrictMode>\n );\n});`;\n fs.writeFileSync(clientEntryPath, existingContent);\n\n await runWizardOnReactRouterProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n try {\n fs.rmSync(projectDir, { recursive: true, force: true });\n } catch (e) {\n // Ignore cleanup errors\n }\n });\n\n test('wizard handles existing Sentry without duplication', () => {\n const clientContent = fs.readFileSync(`${projectDir}/app/entry.client.tsx`, 'utf8');\n const sentryImportCount = (clientContent.match(/import \\* as Sentry from \"@sentry\\/react-router\"/g) || []).length;\n const sentryInitCount = (clientContent.match(/Sentry\\.init\\(/g) || []).length;\n\n expect(sentryImportCount).toBe(1);\n expect(sentryInitCount).toBe(1);\n });\n\n // Only test the essential checks for this edge case\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('essential files exist or wizard completes gracefully', () => {\n // Check if key directories exist\n expect(fs.existsSync(`${projectDir}/app`)).toBe(true);\n\n // When there's existing Sentry setup, the wizard may skip some file creation\n // to avoid conflicts. This is acceptable behavior.\n // Let's check if the wizard at least completed by verifying package.json was updated\n const packageJsonPath = `${projectDir}/package.json`;\n expect(fs.existsSync(packageJsonPath)).toBe(true);\n\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(packageJsonContent) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n\n const hasSentryPackage =\n (packageJson.dependencies?.['@sentry/react-router']) ||\n (packageJson.devDependencies?.['@sentry/react-router']);\n\n // The wizard should have at least installed the Sentry package\n expect(hasSentryPackage).toBeTruthy();\n });\n });\n\n describe('missing entry files', () => {\n const integration = Integration.reactRouter;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-router-test-app-missing-entries',\n );\n\n beforeAll(async () => {\n // Copy project and remove entry files\n fs.cpSync(baseProjectDir, projectDir, { recursive: true });\n\n const entryClientPath = path.join(projectDir, 'app', 'entry.client.tsx');\n const entryServerPath = path.join(projectDir, 'app', 'entry.server.tsx');\n\n if (fs.existsSync(entryClientPath)) fs.unlinkSync(entryClientPath);\n if (fs.existsSync(entryServerPath)) fs.unlinkSync(entryServerPath);\n\n await runWizardOnReactRouterProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n try {\n fs.rmSync(projectDir, { recursive: true, force: true });\n } catch (e) {\n // Ignore cleanup errors\n }\n });\n\n test('wizard creates missing entry files', () => {\n checkFileExists(`${projectDir}/app/entry.client.tsx`);\n checkFileExists(`${projectDir}/app/entry.server.tsx`);\n });\n\n test('basic configuration still works', () => {\n checkPackageJson(projectDir, integration);\n checkFileExists(`${projectDir}/instrument.server.mjs`);\n });\n });\n });\n});\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
2
|
+
import { Integration } from '../../lib/Constants';
|
|
3
3
|
import type { ChildProcess } from 'node:child_process';
|
|
4
4
|
export declare const KEYS: {
|
|
5
5
|
UP: string;
|
|
@@ -90,7 +90,7 @@ export declare function getWizardCommand(integration: Integration): string;
|
|
|
90
90
|
*
|
|
91
91
|
* @returns WizardTestEnv
|
|
92
92
|
*/
|
|
93
|
-
export declare function startWizardInstance(integration: Integration, projectDir: string, debug?: boolean): WizardTestEnv;
|
|
93
|
+
export declare function startWizardInstance(integration: Integration, projectDir: string, debug?: boolean, spotlight?: boolean): WizardTestEnv;
|
|
94
94
|
/**
|
|
95
95
|
* Create a file with the given content
|
|
96
96
|
*
|
|
@@ -126,6 +126,12 @@ export declare function checkFileContents(filePath: string, content: string | st
|
|
|
126
126
|
* @param filePath
|
|
127
127
|
*/
|
|
128
128
|
export declare function checkFileExists(filePath: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* Check if the file does not exist
|
|
131
|
+
*
|
|
132
|
+
* @param filePath
|
|
133
|
+
*/
|
|
134
|
+
export declare function checkFileDoesNotExist(filePath: string): void;
|
|
129
135
|
/**
|
|
130
136
|
* Check if the package.json contains the given integration
|
|
131
137
|
*
|
|
@@ -23,9 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.checkIfRunsOnProdMode = exports.checkIfRunsOnDevMode = exports.checkIfExpoBundles = exports.checkIfReactNativeBundles = exports.checkIfFlutterBuilds = exports.checkIfBuilds = exports.checkSentryProperties = exports.checkEnvBuildPlugin = exports.checkSentryCliRc = exports.checkPackageJson = exports.checkFileExists = exports.checkFileContents = exports.checkFileDoesNotContain = exports.modifyFile = exports.createFile = exports.startWizardInstance = exports.getWizardCommand = exports.revertLocalChanges = exports.cleanupGit = exports.initGit = exports.WizardTestEnv = exports.log = exports.TEST_ARGS = exports.KEYS = void 0;
|
|
26
|
+
exports.checkIfRunsOnProdMode = exports.checkIfRunsOnDevMode = exports.checkIfExpoBundles = exports.checkIfReactNativeBundles = exports.checkIfFlutterBuilds = exports.checkIfBuilds = exports.checkSentryProperties = exports.checkEnvBuildPlugin = exports.checkSentryCliRc = exports.checkPackageJson = exports.checkFileDoesNotExist = exports.checkFileExists = exports.checkFileContents = exports.checkFileDoesNotContain = exports.modifyFile = exports.createFile = exports.startWizardInstance = exports.getWizardCommand = exports.revertLocalChanges = exports.cleanupGit = exports.initGit = exports.WizardTestEnv = exports.log = exports.TEST_ARGS = exports.KEYS = void 0;
|
|
27
27
|
const fs = __importStar(require("node:fs"));
|
|
28
28
|
const path = __importStar(require("node:path"));
|
|
29
|
+
const Constants_1 = require("../../lib/Constants");
|
|
29
30
|
const node_child_process_1 = require("node:child_process");
|
|
30
31
|
const Logging_1 = require("../../lib/Helper/Logging");
|
|
31
32
|
const vitest_1 = require("vitest");
|
|
@@ -230,10 +231,14 @@ exports.cleanupGit = cleanupGit;
|
|
|
230
231
|
*/
|
|
231
232
|
function revertLocalChanges(projectDir) {
|
|
232
233
|
try {
|
|
233
|
-
//
|
|
234
|
-
(
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
// Check if this is a git repository first
|
|
235
|
+
const isGitRepo = fs.existsSync(path.join(projectDir, '.git'));
|
|
236
|
+
if (isGitRepo) {
|
|
237
|
+
// Revert tracked files
|
|
238
|
+
(0, node_child_process_1.execSync)('git restore .', { cwd: projectDir });
|
|
239
|
+
// Revert untracked files
|
|
240
|
+
(0, node_child_process_1.execSync)('git clean -fd .', { cwd: projectDir });
|
|
241
|
+
}
|
|
237
242
|
// Remove node_modules and dist (.gitignore'd and therefore not removed via git clean)
|
|
238
243
|
(0, node_child_process_1.execSync)('rm -rf node_modules', { cwd: projectDir });
|
|
239
244
|
(0, node_child_process_1.execSync)('rm -rf dist', { cwd: projectDir });
|
|
@@ -273,7 +278,7 @@ exports.getWizardCommand = getWizardCommand;
|
|
|
273
278
|
*
|
|
274
279
|
* @returns WizardTestEnv
|
|
275
280
|
*/
|
|
276
|
-
function startWizardInstance(integration, projectDir, debug = false) {
|
|
281
|
+
function startWizardInstance(integration, projectDir, debug = false, spotlight = false) {
|
|
277
282
|
const binName = process.env.SENTRY_WIZARD_E2E_TEST_BIN
|
|
278
283
|
? ['dist-bin', `sentry-wizard-${process.platform}-${process.arch}`]
|
|
279
284
|
: ['dist', 'bin.js'];
|
|
@@ -281,20 +286,16 @@ function startWizardInstance(integration, projectDir, debug = false) {
|
|
|
281
286
|
revertLocalChanges(projectDir);
|
|
282
287
|
cleanupGit(projectDir);
|
|
283
288
|
initGit(projectDir);
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
'--preSelectedProject.dsn',
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
'--preSelectedProject.projectSlug',
|
|
295
|
-
exports.TEST_ARGS.PROJECT_SLUG,
|
|
296
|
-
'--disable-telemetry',
|
|
297
|
-
], { cwd: projectDir, debug });
|
|
289
|
+
const args = ['--debug', '-i', integration];
|
|
290
|
+
if (spotlight) {
|
|
291
|
+
// Spotlight mode: skip authentication
|
|
292
|
+
args.push('--spotlight');
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
args.push('--preSelectedProject.authToken', exports.TEST_ARGS.AUTH_TOKEN, '--preSelectedProject.dsn', exports.TEST_ARGS.PROJECT_DSN, '--preSelectedProject.orgSlug', exports.TEST_ARGS.ORG_SLUG, '--preSelectedProject.projectSlug', exports.TEST_ARGS.PROJECT_SLUG);
|
|
296
|
+
}
|
|
297
|
+
args.push('--disable-telemetry');
|
|
298
|
+
return new WizardTestEnv(binPath, args, { cwd: projectDir, debug });
|
|
298
299
|
}
|
|
299
300
|
exports.startWizardInstance = startWizardInstance;
|
|
300
301
|
/**
|
|
@@ -360,6 +361,52 @@ function checkFileExists(filePath) {
|
|
|
360
361
|
(0, vitest_1.expect)(fs.existsSync(filePath)).toBe(true);
|
|
361
362
|
}
|
|
362
363
|
exports.checkFileExists = checkFileExists;
|
|
364
|
+
/**
|
|
365
|
+
* Check if the file does not exist
|
|
366
|
+
*
|
|
367
|
+
* @param filePath
|
|
368
|
+
*/
|
|
369
|
+
function checkFileDoesNotExist(filePath) {
|
|
370
|
+
(0, vitest_1.expect)(fs.existsSync(filePath)).toBe(false);
|
|
371
|
+
}
|
|
372
|
+
exports.checkFileDoesNotExist = checkFileDoesNotExist;
|
|
373
|
+
/**
|
|
374
|
+
* Map integration to its corresponding Sentry package name
|
|
375
|
+
* @param type Integration type
|
|
376
|
+
* @returns Package name or undefined if no package exists
|
|
377
|
+
*/
|
|
378
|
+
function mapIntegrationToPackageName(type) {
|
|
379
|
+
switch (type) {
|
|
380
|
+
case Constants_1.Integration.android:
|
|
381
|
+
return undefined; // Android doesn't have a JavaScript package
|
|
382
|
+
case Constants_1.Integration.reactNative:
|
|
383
|
+
return '@sentry/react-native';
|
|
384
|
+
case Constants_1.Integration.flutter:
|
|
385
|
+
return undefined; // Flutter doesn't have a JavaScript package
|
|
386
|
+
case Constants_1.Integration.cordova:
|
|
387
|
+
return '@sentry/cordova';
|
|
388
|
+
case Constants_1.Integration.angular:
|
|
389
|
+
return '@sentry/angular';
|
|
390
|
+
case Constants_1.Integration.electron:
|
|
391
|
+
return '@sentry/electron';
|
|
392
|
+
case Constants_1.Integration.nextjs:
|
|
393
|
+
return '@sentry/nextjs';
|
|
394
|
+
case Constants_1.Integration.nuxt:
|
|
395
|
+
return '@sentry/nuxt';
|
|
396
|
+
case Constants_1.Integration.remix:
|
|
397
|
+
return '@sentry/remix';
|
|
398
|
+
case Constants_1.Integration.reactRouter:
|
|
399
|
+
return '@sentry/react-router';
|
|
400
|
+
case Constants_1.Integration.sveltekit:
|
|
401
|
+
return '@sentry/sveltekit';
|
|
402
|
+
case Constants_1.Integration.sourcemaps:
|
|
403
|
+
return undefined; // Sourcemaps doesn't install a package
|
|
404
|
+
case Constants_1.Integration.ios:
|
|
405
|
+
return undefined; // iOS doesn't have a JavaScript package
|
|
406
|
+
default:
|
|
407
|
+
return undefined;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
363
410
|
/**
|
|
364
411
|
* Check if the package.json contains the given integration
|
|
365
412
|
*
|
|
@@ -367,7 +414,11 @@ exports.checkFileExists = checkFileExists;
|
|
|
367
414
|
* @param integration
|
|
368
415
|
*/
|
|
369
416
|
function checkPackageJson(projectDir, integration) {
|
|
370
|
-
|
|
417
|
+
const packageName = mapIntegrationToPackageName(integration);
|
|
418
|
+
if (!packageName) {
|
|
419
|
+
throw new Error(`No package name found for integration: ${integration}`);
|
|
420
|
+
}
|
|
421
|
+
checkFileContents(`${projectDir}/package.json`, packageName);
|
|
371
422
|
}
|
|
372
423
|
exports.checkPackageJson = checkPackageJson;
|
|
373
424
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../e2e-tests/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAGlC,2DAAqD;AAErD,sDAA2D;AAC3D,mCAAgC;AAEnB,QAAA,IAAI,GAAG;IAClB,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,GAAG;CACX,CAAC;AAEW,QAAA,SAAS,GAAG;IACvB,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,iBAAiB;IACnE,WAAW,EACT,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,0CAA0C;IAC3E,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,eAAe;IACxD,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,mBAAmB;CACrE,CAAC;AAEW,QAAA,GAAG,GAAG;IACjB,OAAO,EAAE,CAAC,OAAe,EAAE,EAAE;QAC3B,IAAA,eAAK,EAAC,aAAa,OAAO,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,EAAE;QACxB,IAAA,aAAG,EAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,EAAE,C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EAAE,UAAU,EAAE,CAAC,CAAC;IAE9E,IAAA,eAAM,EACJ,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE;QAC1C,OAAO,EAAE,MAAO;KACjB,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC;AAbD,oDAaC;AAED;;;;GAIG;AACI,KAAK,UAAU,qBAAqB,CACzC,UAAkB,EAClB,cAAsB,EACtB,YAAY,GAAG,OAAO;IAEtB,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE;QAC9D,GAAG,EAAE,UAAU;KAChB,CAAC,CAAC;IAEH,IAAA,eAAM,EACJ,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE;QAC1C,OAAO,EAAE,MAAO;KACjB,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC;AAhBD,sDAgBC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { Integration } from '../../lib/Constants';\nimport { spawn, execSync } from 'node:child_process';\nimport type { ChildProcess } from 'node:child_process';\nimport { dim, green, red } from '../../lib/Helper/Logging';\nimport { expect } from 'vitest';\n\nexport const KEYS = {\n UP: '\\u001b[A',\n DOWN: '\\u001b[B',\n LEFT: '\\u001b[D',\n RIGHT: '\\u001b[C',\n ENTER: '\\r',\n SPACE: ' ',\n};\n\nexport const TEST_ARGS = {\n AUTH_TOKEN: process.env.SENTRY_TEST_AUTH_TOKEN || 'TEST_AUTH_TOKEN',\n PROJECT_DSN:\n process.env.SENTRY_TEST_DSN || 'https://public@dsn.ingest.sentry.io/1337',\n ORG_SLUG: process.env.SENTRY_TEST_ORG || 'TEST_ORG_SLUG',\n PROJECT_SLUG: process.env.SENTRY_TEST_PROJECT || 'TEST_PROJECT_SLUG',\n};\n\nexport const log = {\n success: (message: string) => {\n green(`[SUCCESS] ${message}`);\n },\n info: (message: string) => {\n dim(`[INFO] ${message}`);\n },\n error: (message: unknown) => {\n function formatMessage(message: unknown, depth: number): string {\n if (depth > 3) {\n return '...';\n }\n\n if (message instanceof Error) {\n return JSON.stringify(\n {\n name: message.name,\n message: message.message,\n stack: message.stack,\n ...(message.cause\n ? {\n cause: formatMessage(message.cause, depth + 1),\n }\n : {}),\n },\n null,\n 2,\n );\n }\n return String(message);\n }\n red(`[ERROR] ${formatMessage(message, 0)}`);\n },\n};\n\nexport class WizardTestEnv {\n taskHandle: ChildProcess;\n\n constructor(\n cmd: string,\n args: string[],\n opts?: {\n cwd?: string;\n debug?: boolean;\n },\n ) {\n this.taskHandle = spawn(cmd, args, { cwd: opts?.cwd, stdio: 'pipe' });\n\n if (opts?.debug) {\n this.taskHandle.stdout?.pipe(process.stdout);\n this.taskHandle.stderr?.pipe(process.stderr);\n }\n }\n\n sendStdin(input: string) {\n this.taskHandle.stdin?.write(input);\n }\n\n /**\n * Sends the input and waits for the output.\n * @returns a promise that resolves when the output was found\n * @throws an error when the output was not found within the timeout\n */\n sendStdinAndWaitForOutput(\n input: string | string[],\n output: string,\n options?: { timeout?: number; optional?: boolean },\n ) {\n const outputPromise = this.waitForOutput(output, options);\n\n if (Array.isArray(input)) {\n for (const i of input) {\n this.sendStdin(i);\n }\n } else {\n this.sendStdin(input);\n }\n return outputPromise;\n }\n\n /**\n * Waits for the task to exit with a given `statusCode`.\n *\n * @returns a promise that resolves to `true` if the run ends with the status\n * code, or it rejects when the `timeout` was reached.\n */\n waitForStatusCode(\n statusCode: number | null,\n options: {\n /** Timeout in ms */\n timeout?: number;\n } = {},\n ) {\n const { timeout } = {\n timeout: 60_000,\n ...options,\n };\n\n return new Promise<boolean>((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n this.kill();\n reject(\n new Error(`Timeout waiting for status code: ${statusCode ?? 'null'}`),\n );\n }, timeout);\n\n this.taskHandle.on('error', (err: Error) => {\n clearTimeout(timeoutId);\n reject(err);\n });\n\n this.taskHandle.on('exit', (code: number | null) => {\n clearTimeout(timeoutId);\n resolve(code === statusCode);\n });\n });\n }\n\n /**\n * Waits for the provided output with `.includes()` logic.\n *\n * @returns a promise that resolves to `true` if the output was found, `false` if the output was not found within the\n * timeout and `optional: true` is set, or it rejects when the timeout was reached with `optional: false`\n */\n waitForOutput(\n output: string,\n options: {\n /** Timeout in ms */\n timeout?: number;\n /** Whether to always resolve after the timeout, no matter whether the input was actually found or not. */\n optional?: boolean;\n } = {},\n ) {\n const { timeout, optional } = {\n timeout: 60_000,\n optional: false,\n ...options,\n };\n\n return new Promise<boolean>((resolve, reject) => {\n let outputBuffer = '';\n const timeoutId = setTimeout(() => {\n this.taskHandle.off('error', errorListener);\n this.taskHandle.stdout?.off('data', dataListener);\n\n this.kill();\n if (optional) {\n // The output is not found but it's optional so we can resolve the promise with false\n resolve(false);\n } else {\n reject(\n new Error(\n `Timeout waiting for output: ${output}. Got the following instead: ${outputBuffer}`,\n ),\n );\n }\n }, timeout);\n\n const dataListener = (data: string) => {\n outputBuffer += data;\n if (outputBuffer.includes(output)) {\n clearTimeout(timeoutId);\n this.taskHandle.off('error', errorListener);\n this.taskHandle.stdout?.off('data', dataListener);\n // The output is found so we can resolve the promise with true\n resolve(true);\n }\n };\n\n const errorListener = (err: Error) => {\n this.taskHandle.off('error', errorListener);\n this.taskHandle.stdout?.off('data', dataListener);\n clearTimeout(timeoutId);\n reject(err);\n };\n\n this.taskHandle.on('error', errorListener);\n this.taskHandle.stdout?.on('data', dataListener);\n });\n }\n\n kill() {\n this.taskHandle.stdin?.destroy();\n this.taskHandle.stderr?.destroy();\n this.taskHandle.stdout?.destroy();\n this.taskHandle.kill('SIGINT');\n this.taskHandle.unref();\n }\n}\n\n/**\n * Initialize a git repository in the given directory\n * @param projectDir\n */\nexport function initGit(projectDir: string): void {\n try {\n execSync('git init', { cwd: projectDir });\n // Add all files to the git repo\n execSync('git add -A', { cwd: projectDir });\n // Add author info to avoid git commit error\n execSync('git config user.email test@test.sentry.io', { cwd: projectDir });\n execSync('git config user.name Test', { cwd: projectDir });\n execSync('git commit -m init', { cwd: projectDir });\n } catch (e) {\n log.error('Error initializing git');\n log.error(e);\n }\n}\n\n/**\n * Cleanup the git repository in the given directory\n *\n * Caution! Make sure `projectDir` is a test project directory,\n * if in doubt, please commit your local non-test changes first!\n * @param projectDir\n */\nexport function cleanupGit(projectDir: string): void {\n try {\n // Remove the .git directory\n execSync(`rm -rf ${projectDir}/.git`);\n } catch (e) {\n log.error('Error cleaning up git');\n log.error(e);\n }\n}\n\n/**\n * Revert local changes in the given directory\n *\n * Caution! Make sure `projectDir` is a test project directory,\n * if in doubt, please commit your local non-test changes first!\n *\n * @param projectDir\n */\nexport function revertLocalChanges(projectDir: string): void {\n try {\n // Revert tracked files\n execSync('git restore .', { cwd: projectDir });\n // Revert untracked files\n execSync('git clean -fd .', { cwd: projectDir });\n // Remove node_modules and dist (.gitignore'd and therefore not removed via git clean)\n execSync('rm -rf node_modules', { cwd: projectDir });\n execSync('rm -rf dist', { cwd: projectDir });\n } catch (e) {\n log.error('Error reverting local changes');\n log.error(e);\n }\n}\n\nexport function getWizardCommand(integration: Integration): string {\n const binName = process.env.SENTRY_WIZARD_E2E_TEST_BIN\n ? ['dist-bin', `sentry-wizard-${process.platform}-${process.arch}`]\n : ['dist', 'bin.js'];\n const binPath = path.join(__dirname, '..', '..', ...binName);\n\n const args = [\n '--debug',\n '-i',\n integration,\n '--preSelectedProject.authToken',\n TEST_ARGS.AUTH_TOKEN,\n '--preSelectedProject.dsn',\n TEST_ARGS.PROJECT_DSN,\n '--preSelectedProject.orgSlug',\n TEST_ARGS.ORG_SLUG,\n '--preSelectedProject.projectSlug',\n TEST_ARGS.PROJECT_SLUG,\n '--disable-telemetry',\n ];\n\n return `${binPath} ${args.join(' ')}`;\n}\n\n/**\n * Start the wizard instance with the given integration and project directory\n * @param integration\n * @param projectDir\n *\n * @returns WizardTestEnv\n */\nexport function startWizardInstance(\n integration: Integration,\n projectDir: string,\n debug = false,\n): WizardTestEnv {\n const binName = process.env.SENTRY_WIZARD_E2E_TEST_BIN\n ? ['dist-bin', `sentry-wizard-${process.platform}-${process.arch}`]\n : ['dist', 'bin.js'];\n const binPath = path.join(__dirname, '..', '..', ...binName);\n\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n initGit(projectDir);\n\n return new WizardTestEnv(\n binPath,\n [\n '--debug',\n '-i',\n integration,\n '--preSelectedProject.authToken',\n TEST_ARGS.AUTH_TOKEN,\n '--preSelectedProject.dsn',\n TEST_ARGS.PROJECT_DSN,\n '--preSelectedProject.orgSlug',\n TEST_ARGS.ORG_SLUG,\n '--preSelectedProject.projectSlug',\n TEST_ARGS.PROJECT_SLUG,\n '--disable-telemetry',\n ],\n { cwd: projectDir, debug },\n );\n}\n\n/**\n * Create a file with the given content\n *\n * @param filePath\n * @param content\n */\nexport function createFile(filePath: string, content?: string) {\n return fs.writeFileSync(filePath, content || '');\n}\n\n/**\n * Modify the file with the new content\n *\n * @param filePath\n * @param oldContent\n * @param newContent\n */\nexport function modifyFile(\n filePath: string,\n replaceMap: Record<string, string>,\n) {\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n let newFileContent = fileContent;\n\n for (const [oldContent, newContent] of Object.entries(replaceMap)) {\n newFileContent = newFileContent.replace(oldContent, newContent);\n }\n\n fs.writeFileSync(filePath, newFileContent);\n}\n\n/**\n * Read the file contents and check if it does not contain the given content\n *\n * @param {string} filePath\n * @param {(string | string[])} content\n */\nexport function checkFileDoesNotContain(\n filePath: string,\n content: string | string[],\n) {\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n const contentArray = Array.isArray(content) ? content : [content];\n\n for (const c of contentArray) {\n expect(fileContent).not.toContain(c);\n }\n}\n\n/**\n * Read the file contents and check if it contains the given content\n *\n * @param {string} filePath\n * @param {(string | string[])} content\n */\nexport function checkFileContents(\n filePath: string,\n content: string | string[],\n) {\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n const contentArray = Array.isArray(content) ? content : [content];\n\n for (const c of contentArray) {\n expect(fileContent).toContain(c);\n }\n}\n\n/**\n * Check if the file exists\n *\n * @param filePath\n */\nexport function checkFileExists(filePath: string) {\n expect(fs.existsSync(filePath)).toBe(true);\n}\n\n/**\n * Check if the package.json contains the given integration\n *\n * @param projectDir\n * @param integration\n */\nexport function checkPackageJson(projectDir: string, integration: Integration) {\n checkFileContents(`${projectDir}/package.json`, `@sentry/${integration}`);\n}\n\n/**\n * Check if the .sentryclirc contains the auth token\n *\n * @param projectDir\n */\nexport function checkSentryCliRc(projectDir: string) {\n checkFileContents(\n `${projectDir}/.sentryclirc`,\n `token=${TEST_ARGS.AUTH_TOKEN}`,\n );\n}\n\n/**\n * Check if the .env.sentry-build-plugin contains the auth token\n * @param projectDir\n */\nexport function checkEnvBuildPlugin(projectDir: string) {\n checkFileContents(\n `${projectDir}/.env.sentry-build-plugin`,\n `SENTRY_AUTH_TOKEN=${TEST_ARGS.AUTH_TOKEN}`,\n );\n}\n\n/**\n * Check if the sentry.properties contains the auth token\n * @param projectDir\n */\nexport function checkSentryProperties(projectDir: string) {\n checkFileContents(\n `${projectDir}/sentry.properties`,\n `auth_token=${TEST_ARGS.AUTH_TOKEN}`,\n );\n}\n\n/**\n * Check if the project builds\n * Check if the project builds and ends with status code 0.\n * @param projectDir\n */\nexport async function checkIfBuilds(projectDir: string) {\n const testEnv = new WizardTestEnv('npm', ['run', 'build'], {\n cwd: projectDir,\n });\n\n const builtSuccessfully = await testEnv.waitForStatusCode(0, {\n timeout: 120_000,\n });\n\n expect(builtSuccessfully).toBe(true);\n}\n\n/**\n * Check if the flutter project builds\n * @param projectDir\n */\nexport async function checkIfFlutterBuilds(\n projectDir: string,\n expectedOutput: string,\n debug = false,\n) {\n const testEnv = new WizardTestEnv('flutter', ['build', 'web'], {\n cwd: projectDir,\n debug: debug,\n });\n\n const outputReceived = await testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n });\n\n expect(outputReceived).toBe(true);\n}\n\n/**\n * Check if the React Native project bundles successfully for the specified platform.\n * Returns a boolean indicating if the process exits with status code 0.\n * @param projectDir The root directory of the React Native project.\n * @param platform The platform to bundle for ('ios' or 'android').\n * @param debug runs the command in debug mode if true\n */\nexport async function checkIfReactNativeBundles(\n projectDir: string,\n platform: 'ios' | 'android',\n debug = false,\n): Promise<boolean> {\n const entryFile = 'index.js';\n const dev = 'false'; // Test a production-like bundle\n let bundleOutput: string;\n let assetsDest: string;\n\n if (platform === 'ios') {\n bundleOutput = './ios/main.jsbundle';\n assetsDest = './ios';\n } else {\n // android\n bundleOutput = './android/app/src/main/assets/index.android.bundle';\n assetsDest = './android/app/src/main/res';\n }\n\n const bundleCommandArgs = [\n 'react-native',\n 'bundle',\n '--entry-file',\n entryFile,\n '--platform',\n platform,\n '--dev',\n dev,\n '--bundle-output',\n bundleOutput,\n '--assets-dest',\n assetsDest,\n ];\n\n const testEnv = new WizardTestEnv('npx', bundleCommandArgs, {\n cwd: projectDir,\n debug: debug,\n });\n\n const builtSuccessfully = await testEnv.waitForStatusCode(0, {\n timeout: 300_000,\n });\n\n testEnv.kill();\n\n return builtSuccessfully;\n}\n\n/**\n * Check if the Expo project exports successfully for the specified platform.\n * Returns a boolean indicating if the process exits with status code 0.\n * @param projectDir The root directory of the Expo project.\n * @param platform The platform to export for ('ios', 'android', or 'web').\n * @param debug runs the command in debug mode if true\n */\nexport async function checkIfExpoBundles(\n projectDir: string,\n platform: 'ios' | 'android' | 'web',\n debug = false,\n): Promise<boolean> {\n const exportCommandArgs = [\n 'expo',\n 'export',\n '--platform',\n platform,\n ];\n\n const testEnv = new WizardTestEnv('npx', exportCommandArgs, {\n cwd: projectDir,\n debug: debug,\n });\n\n const builtSuccessfully = await testEnv.waitForStatusCode(0, {\n timeout: 300_000,\n });\n\n testEnv.kill();\n return builtSuccessfully;\n}\n\n/**\n * Check if the project runs on dev mode\n * @param projectDir\n * @param expectedOutput\n */\nexport async function checkIfRunsOnDevMode(\n projectDir: string,\n expectedOutput: string,\n) {\n const testEnv = new WizardTestEnv('npm', ['run', 'dev'], { cwd: projectDir });\n\n expect(\n await testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n }),\n ).toBe(true);\n\n testEnv.kill();\n}\n\n/**\n * Check if the project runs on prod mode\n * @param projectDir\n * @param expectedOutput\n */\nexport async function checkIfRunsOnProdMode(\n projectDir: string,\n expectedOutput: string,\n startCommand = 'start',\n) {\n const testEnv = new WizardTestEnv('npm', ['run', startCommand], {\n cwd: projectDir,\n });\n\n expect(\n await testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n }),\n ).toBe(true);\n\n testEnv.kill();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../e2e-tests/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAElC,mDAAkD;AAClD,2DAAqD;AAErD,sDAA2D;AAC3D,mCAAgC;AAEnB,QAAA,IAAI,GAAG;IAClB,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,GAAG;CACX,CAAC;AAEW,QAAA,SAAS,GAAG;IACvB,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,iBAAiB;IACnE,WAAW,EACT,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,0CAA0C;IAC3E,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,eAAe;IACxD,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,mBAAmB;CACrE,CAAC;AAEW,QAAA,GAAG,GAAG;IACjB,OAAO,EAAE,CAAC,OAAe,EAAE,EAAE;QAC3B,IAAA,eAAK,EAAC,aAAa,O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AgBC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { Integration } from '../../lib/Constants';\nimport { spawn, execSync } from 'node:child_process';\nimport type { ChildProcess } from 'node:child_process';\nimport { dim, green, red } from '../../lib/Helper/Logging';\nimport { expect } from 'vitest';\n\nexport const KEYS = {\n UP: '\\u001b[A',\n DOWN: '\\u001b[B',\n LEFT: '\\u001b[D',\n RIGHT: '\\u001b[C',\n ENTER: '\\r',\n SPACE: ' ',\n};\n\nexport const TEST_ARGS = {\n AUTH_TOKEN: process.env.SENTRY_TEST_AUTH_TOKEN || 'TEST_AUTH_TOKEN',\n PROJECT_DSN:\n process.env.SENTRY_TEST_DSN || 'https://public@dsn.ingest.sentry.io/1337',\n ORG_SLUG: process.env.SENTRY_TEST_ORG || 'TEST_ORG_SLUG',\n PROJECT_SLUG: process.env.SENTRY_TEST_PROJECT || 'TEST_PROJECT_SLUG',\n};\n\nexport const log = {\n success: (message: string) => {\n green(`[SUCCESS] ${message}`);\n },\n info: (message: string) => {\n dim(`[INFO] ${message}`);\n },\n error: (message: unknown) => {\n function formatMessage(message: unknown, depth: number): string {\n if (depth > 3) {\n return '...';\n }\n\n if (message instanceof Error) {\n return JSON.stringify(\n {\n name: message.name,\n message: message.message,\n stack: message.stack,\n ...(message.cause\n ? {\n cause: formatMessage(message.cause, depth + 1),\n }\n : {}),\n },\n null,\n 2,\n );\n }\n return String(message);\n }\n red(`[ERROR] ${formatMessage(message, 0)}`);\n },\n};\n\nexport class WizardTestEnv {\n taskHandle: ChildProcess;\n\n constructor(\n cmd: string,\n args: string[],\n opts?: {\n cwd?: string;\n debug?: boolean;\n },\n ) {\n this.taskHandle = spawn(cmd, args, { cwd: opts?.cwd, stdio: 'pipe' });\n\n if (opts?.debug) {\n this.taskHandle.stdout?.pipe(process.stdout);\n this.taskHandle.stderr?.pipe(process.stderr);\n }\n }\n\n sendStdin(input: string) {\n this.taskHandle.stdin?.write(input);\n }\n\n /**\n * Sends the input and waits for the output.\n * @returns a promise that resolves when the output was found\n * @throws an error when the output was not found within the timeout\n */\n sendStdinAndWaitForOutput(\n input: string | string[],\n output: string,\n options?: { timeout?: number; optional?: boolean },\n ) {\n const outputPromise = this.waitForOutput(output, options);\n\n if (Array.isArray(input)) {\n for (const i of input) {\n this.sendStdin(i);\n }\n } else {\n this.sendStdin(input);\n }\n return outputPromise;\n }\n\n /**\n * Waits for the task to exit with a given `statusCode`.\n *\n * @returns a promise that resolves to `true` if the run ends with the status\n * code, or it rejects when the `timeout` was reached.\n */\n waitForStatusCode(\n statusCode: number | null,\n options: {\n /** Timeout in ms */\n timeout?: number;\n } = {},\n ) {\n const { timeout } = {\n timeout: 60_000,\n ...options,\n };\n\n return new Promise<boolean>((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n this.kill();\n reject(\n new Error(`Timeout waiting for status code: ${statusCode ?? 'null'}`),\n );\n }, timeout);\n\n this.taskHandle.on('error', (err: Error) => {\n clearTimeout(timeoutId);\n reject(err);\n });\n\n this.taskHandle.on('exit', (code: number | null) => {\n clearTimeout(timeoutId);\n resolve(code === statusCode);\n });\n });\n }\n\n /**\n * Waits for the provided output with `.includes()` logic.\n *\n * @returns a promise that resolves to `true` if the output was found, `false` if the output was not found within the\n * timeout and `optional: true` is set, or it rejects when the timeout was reached with `optional: false`\n */\n waitForOutput(\n output: string,\n options: {\n /** Timeout in ms */\n timeout?: number;\n /** Whether to always resolve after the timeout, no matter whether the input was actually found or not. */\n optional?: boolean;\n } = {},\n ) {\n const { timeout, optional } = {\n timeout: 60_000,\n optional: false,\n ...options,\n };\n\n return new Promise<boolean>((resolve, reject) => {\n let outputBuffer = '';\n const timeoutId = setTimeout(() => {\n this.taskHandle.off('error', errorListener);\n this.taskHandle.stdout?.off('data', dataListener);\n\n this.kill();\n if (optional) {\n // The output is not found but it's optional so we can resolve the promise with false\n resolve(false);\n } else {\n reject(\n new Error(\n `Timeout waiting for output: ${output}. Got the following instead: ${outputBuffer}`,\n ),\n );\n }\n }, timeout);\n\n const dataListener = (data: string) => {\n outputBuffer += data;\n if (outputBuffer.includes(output)) {\n clearTimeout(timeoutId);\n this.taskHandle.off('error', errorListener);\n this.taskHandle.stdout?.off('data', dataListener);\n // The output is found so we can resolve the promise with true\n resolve(true);\n }\n };\n\n const errorListener = (err: Error) => {\n this.taskHandle.off('error', errorListener);\n this.taskHandle.stdout?.off('data', dataListener);\n clearTimeout(timeoutId);\n reject(err);\n };\n\n this.taskHandle.on('error', errorListener);\n this.taskHandle.stdout?.on('data', dataListener);\n });\n }\n\n kill() {\n this.taskHandle.stdin?.destroy();\n this.taskHandle.stderr?.destroy();\n this.taskHandle.stdout?.destroy();\n this.taskHandle.kill('SIGINT');\n this.taskHandle.unref();\n }\n}\n\n/**\n * Initialize a git repository in the given directory\n * @param projectDir\n */\nexport function initGit(projectDir: string): void {\n try {\n execSync('git init', { cwd: projectDir });\n // Add all files to the git repo\n execSync('git add -A', { cwd: projectDir });\n // Add author info to avoid git commit error\n execSync('git config user.email test@test.sentry.io', { cwd: projectDir });\n execSync('git config user.name Test', { cwd: projectDir });\n execSync('git commit -m init', { cwd: projectDir });\n } catch (e) {\n log.error('Error initializing git');\n log.error(e);\n }\n}\n\n/**\n * Cleanup the git repository in the given directory\n *\n * Caution! Make sure `projectDir` is a test project directory,\n * if in doubt, please commit your local non-test changes first!\n * @param projectDir\n */\nexport function cleanupGit(projectDir: string): void {\n try {\n // Remove the .git directory\n execSync(`rm -rf ${projectDir}/.git`);\n } catch (e) {\n log.error('Error cleaning up git');\n log.error(e);\n }\n}\n\n/**\n * Revert local changes in the given directory\n *\n * Caution! Make sure `projectDir` is a test project directory,\n * if in doubt, please commit your local non-test changes first!\n *\n * @param projectDir\n */\nexport function revertLocalChanges(projectDir: string): void {\n try {\n // Check if this is a git repository first\n const isGitRepo = fs.existsSync(path.join(projectDir, '.git'));\n\n if (isGitRepo) {\n // Revert tracked files\n execSync('git restore .', { cwd: projectDir });\n // Revert untracked files\n execSync('git clean -fd .', { cwd: projectDir });\n }\n\n // Remove node_modules and dist (.gitignore'd and therefore not removed via git clean)\n execSync('rm -rf node_modules', { cwd: projectDir });\n execSync('rm -rf dist', { cwd: projectDir });\n } catch (e) {\n log.error('Error reverting local changes');\n log.error(e);\n }\n}\n\nexport function getWizardCommand(integration: Integration): string {\n const binName = process.env.SENTRY_WIZARD_E2E_TEST_BIN\n ? ['dist-bin', `sentry-wizard-${process.platform}-${process.arch}`]\n : ['dist', 'bin.js'];\n const binPath = path.join(__dirname, '..', '..', ...binName);\n\n const args = [\n '--debug',\n '-i',\n integration,\n '--preSelectedProject.authToken',\n TEST_ARGS.AUTH_TOKEN,\n '--preSelectedProject.dsn',\n TEST_ARGS.PROJECT_DSN,\n '--preSelectedProject.orgSlug',\n TEST_ARGS.ORG_SLUG,\n '--preSelectedProject.projectSlug',\n TEST_ARGS.PROJECT_SLUG,\n '--disable-telemetry',\n ];\n\n return `${binPath} ${args.join(' ')}`;\n}\n\n/**\n * Start the wizard instance with the given integration and project directory\n * @param integration\n * @param projectDir\n *\n * @returns WizardTestEnv\n */\nexport function startWizardInstance(\n integration: Integration,\n projectDir: string,\n debug = false,\n spotlight = false,\n): WizardTestEnv {\n const binName = process.env.SENTRY_WIZARD_E2E_TEST_BIN\n ? ['dist-bin', `sentry-wizard-${process.platform}-${process.arch}`]\n : ['dist', 'bin.js'];\n const binPath = path.join(__dirname, '..', '..', ...binName);\n\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n initGit(projectDir);\n\n const args = ['--debug', '-i', integration];\n\n if (spotlight) {\n // Spotlight mode: skip authentication\n args.push('--spotlight');\n } else {\n args.push(\n '--preSelectedProject.authToken',\n TEST_ARGS.AUTH_TOKEN,\n '--preSelectedProject.dsn',\n TEST_ARGS.PROJECT_DSN,\n '--preSelectedProject.orgSlug',\n TEST_ARGS.ORG_SLUG,\n '--preSelectedProject.projectSlug',\n TEST_ARGS.PROJECT_SLUG,\n );\n }\n\n args.push('--disable-telemetry');\n\n return new WizardTestEnv(binPath, args, { cwd: projectDir, debug });\n}\n\n/**\n * Create a file with the given content\n *\n * @param filePath\n * @param content\n */\nexport function createFile(filePath: string, content?: string) {\n return fs.writeFileSync(filePath, content || '');\n}\n\n/**\n * Modify the file with the new content\n *\n * @param filePath\n * @param oldContent\n * @param newContent\n */\nexport function modifyFile(\n filePath: string,\n replaceMap: Record<string, string>,\n) {\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n let newFileContent = fileContent;\n\n for (const [oldContent, newContent] of Object.entries(replaceMap)) {\n newFileContent = newFileContent.replace(oldContent, newContent);\n }\n\n fs.writeFileSync(filePath, newFileContent);\n}\n\n/**\n * Read the file contents and check if it does not contain the given content\n *\n * @param {string} filePath\n * @param {(string | string[])} content\n */\nexport function checkFileDoesNotContain(\n filePath: string,\n content: string | string[],\n) {\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n const contentArray = Array.isArray(content) ? content : [content];\n\n for (const c of contentArray) {\n expect(fileContent).not.toContain(c);\n }\n}\n\n/**\n * Read the file contents and check if it contains the given content\n *\n * @param {string} filePath\n * @param {(string | string[])} content\n */\nexport function checkFileContents(\n filePath: string,\n content: string | string[],\n) {\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n const contentArray = Array.isArray(content) ? content : [content];\n\n for (const c of contentArray) {\n expect(fileContent).toContain(c);\n }\n}\n\n/**\n * Check if the file exists\n *\n * @param filePath\n */\nexport function checkFileExists(filePath: string) {\n expect(fs.existsSync(filePath)).toBe(true);\n}\n\n/**\n * Check if the file does not exist\n *\n * @param filePath\n */\nexport function checkFileDoesNotExist(filePath: string) {\n expect(fs.existsSync(filePath)).toBe(false);\n}\n\n/**\n * Map integration to its corresponding Sentry package name\n * @param type Integration type\n * @returns Package name or undefined if no package exists\n */\nfunction mapIntegrationToPackageName(type: string): string | undefined {\n switch (type) {\n case Integration.android:\n return undefined; // Android doesn't have a JavaScript package\n case Integration.reactNative:\n return '@sentry/react-native';\n case Integration.flutter:\n return undefined; // Flutter doesn't have a JavaScript package\n case Integration.cordova:\n return '@sentry/cordova';\n case Integration.angular:\n return '@sentry/angular';\n case Integration.electron:\n return '@sentry/electron';\n case Integration.nextjs:\n return '@sentry/nextjs';\n case Integration.nuxt:\n return '@sentry/nuxt';\n case Integration.remix:\n return '@sentry/remix';\n case Integration.reactRouter:\n return '@sentry/react-router';\n case Integration.sveltekit:\n return '@sentry/sveltekit';\n case Integration.sourcemaps:\n return undefined; // Sourcemaps doesn't install a package\n case Integration.ios:\n return undefined; // iOS doesn't have a JavaScript package\n default:\n return undefined;\n }\n}\n\n/**\n * Check if the package.json contains the given integration\n *\n * @param projectDir\n * @param integration\n */\nexport function checkPackageJson(projectDir: string, integration: Integration) {\n const packageName = mapIntegrationToPackageName(integration);\n if (!packageName) {\n throw new Error(`No package name found for integration: ${integration}`);\n }\n checkFileContents(`${projectDir}/package.json`, packageName);\n}\n\n/**\n * Check if the .sentryclirc contains the auth token\n *\n * @param projectDir\n */\nexport function checkSentryCliRc(projectDir: string) {\n checkFileContents(\n `${projectDir}/.sentryclirc`,\n `token=${TEST_ARGS.AUTH_TOKEN}`,\n );\n}\n\n/**\n * Check if the .env.sentry-build-plugin contains the auth token\n * @param projectDir\n */\nexport function checkEnvBuildPlugin(projectDir: string) {\n checkFileContents(\n `${projectDir}/.env.sentry-build-plugin`,\n `SENTRY_AUTH_TOKEN=${TEST_ARGS.AUTH_TOKEN}`,\n );\n}\n\n/**\n * Check if the sentry.properties contains the auth token\n * @param projectDir\n */\nexport function checkSentryProperties(projectDir: string) {\n checkFileContents(\n `${projectDir}/sentry.properties`,\n `auth_token=${TEST_ARGS.AUTH_TOKEN}`,\n );\n}\n\n/**\n * Check if the project builds\n * Check if the project builds and ends with status code 0.\n * @param projectDir\n */\nexport async function checkIfBuilds(projectDir: string) {\n const testEnv = new WizardTestEnv('npm', ['run', 'build'], {\n cwd: projectDir,\n });\n\n const builtSuccessfully = await testEnv.waitForStatusCode(0, {\n timeout: 120_000,\n });\n\n expect(builtSuccessfully).toBe(true);\n}\n\n/**\n * Check if the flutter project builds\n * @param projectDir\n */\nexport async function checkIfFlutterBuilds(\n projectDir: string,\n expectedOutput: string,\n debug = false,\n) {\n const testEnv = new WizardTestEnv('flutter', ['build', 'web'], {\n cwd: projectDir,\n debug: debug,\n });\n\n const outputReceived = await testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n });\n\n expect(outputReceived).toBe(true);\n}\n\n/**\n * Check if the React Native project bundles successfully for the specified platform.\n * Returns a boolean indicating if the process exits with status code 0.\n * @param projectDir The root directory of the React Native project.\n * @param platform The platform to bundle for ('ios' or 'android').\n * @param debug runs the command in debug mode if true\n */\nexport async function checkIfReactNativeBundles(\n projectDir: string,\n platform: 'ios' | 'android',\n debug = false,\n): Promise<boolean> {\n const entryFile = 'index.js';\n const dev = 'false'; // Test a production-like bundle\n let bundleOutput: string;\n let assetsDest: string;\n\n if (platform === 'ios') {\n bundleOutput = './ios/main.jsbundle';\n assetsDest = './ios';\n } else {\n // android\n bundleOutput = './android/app/src/main/assets/index.android.bundle';\n assetsDest = './android/app/src/main/res';\n }\n\n const bundleCommandArgs = [\n 'react-native',\n 'bundle',\n '--entry-file',\n entryFile,\n '--platform',\n platform,\n '--dev',\n dev,\n '--bundle-output',\n bundleOutput,\n '--assets-dest',\n assetsDest,\n ];\n\n const testEnv = new WizardTestEnv('npx', bundleCommandArgs, {\n cwd: projectDir,\n debug: debug,\n });\n\n const builtSuccessfully = await testEnv.waitForStatusCode(0, {\n timeout: 300_000,\n });\n\n testEnv.kill();\n\n return builtSuccessfully;\n}\n\n/**\n * Check if the Expo project exports successfully for the specified platform.\n * Returns a boolean indicating if the process exits with status code 0.\n * @param projectDir The root directory of the Expo project.\n * @param platform The platform to export for ('ios', 'android', or 'web').\n * @param debug runs the command in debug mode if true\n */\nexport async function checkIfExpoBundles(\n projectDir: string,\n platform: 'ios' | 'android' | 'web',\n debug = false,\n): Promise<boolean> {\n const exportCommandArgs = [\n 'expo',\n 'export',\n '--platform',\n platform,\n ];\n\n const testEnv = new WizardTestEnv('npx', exportCommandArgs, {\n cwd: projectDir,\n debug: debug,\n });\n\n const builtSuccessfully = await testEnv.waitForStatusCode(0, {\n timeout: 300_000,\n });\n\n testEnv.kill();\n return builtSuccessfully;\n}\n\n/**\n * Check if the project runs on dev mode\n * @param projectDir\n * @param expectedOutput\n */\nexport async function checkIfRunsOnDevMode(\n projectDir: string,\n expectedOutput: string,\n) {\n const testEnv = new WizardTestEnv('npm', ['run', 'dev'], { cwd: projectDir });\n\n expect(\n await testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n }),\n ).toBe(true);\n\n testEnv.kill();\n}\n\n/**\n * Check if the project runs on prod mode\n * @param projectDir\n * @param expectedOutput\n */\nexport async function checkIfRunsOnProdMode(\n projectDir: string,\n expectedOutput: string,\n startCommand = 'start',\n) {\n const testEnv = new WizardTestEnv('npm', ['run', startCommand], {\n cwd: projectDir,\n });\n\n expect(\n await testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n }),\n ).toBe(true);\n\n testEnv.kill();\n}\n"]}
|