@sentry/wizard 3.34.2 → 3.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/e2e-tests/jest.config.d.ts +1 -0
  3. package/dist/e2e-tests/jest.config.js +5 -0
  4. package/dist/e2e-tests/jest.config.js.map +1 -1
  5. package/dist/e2e-tests/tests/nextjs.test.d.ts +1 -0
  6. package/dist/e2e-tests/tests/nextjs.test.js +221 -0
  7. package/dist/e2e-tests/tests/nextjs.test.js.map +1 -0
  8. package/dist/e2e-tests/tests/remix.test.js +47 -43
  9. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  10. package/dist/e2e-tests/tests/sveltekit.test.d.ts +1 -0
  11. package/dist/e2e-tests/tests/sveltekit.test.js +186 -0
  12. package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -0
  13. package/dist/e2e-tests/utils/index.d.ts +13 -2
  14. package/dist/e2e-tests/utils/index.js +45 -13
  15. package/dist/e2e-tests/utils/index.js.map +1 -1
  16. package/dist/package.json +3 -5
  17. package/dist/src/apple/templates.d.ts +1 -1
  18. package/dist/src/apple/templates.js +6 -2
  19. package/dist/src/apple/templates.js.map +1 -1
  20. package/dist/src/apple/xcode-manager.js +2 -1
  21. package/dist/src/apple/xcode-manager.js.map +1 -1
  22. package/dist/src/nextjs/nextjs-wizard.js +68 -47
  23. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  24. package/dist/src/nextjs/templates.d.ts +1 -0
  25. package/dist/src/nextjs/templates.js +5 -1
  26. package/dist/src/nextjs/templates.js.map +1 -1
  27. package/e2e-tests/.env.example +11 -0
  28. package/e2e-tests/jest.config.ts +8 -1
  29. package/e2e-tests/package.json +14 -0
  30. package/e2e-tests/run.sh +15 -0
  31. package/e2e-tests/test-applications/nextjs-test-app/next.config.mjs +4 -0
  32. package/e2e-tests/test-applications/nextjs-test-app/package.json +22 -0
  33. package/e2e-tests/test-applications/nextjs-test-app/src/app/layout.tsx +20 -0
  34. package/e2e-tests/test-applications/nextjs-test-app/src/app/page.tsx +90 -0
  35. package/e2e-tests/test-applications/sveltekit-test-app/package.json +21 -0
  36. package/e2e-tests/test-applications/sveltekit-test-app/src/app.d.ts +13 -0
  37. package/e2e-tests/test-applications/sveltekit-test-app/src/app.html +11 -0
  38. package/e2e-tests/test-applications/sveltekit-test-app/src/lib/index.ts +1 -0
  39. package/e2e-tests/test-applications/sveltekit-test-app/src/routes/+page.svelte +2 -0
  40. package/e2e-tests/test-applications/sveltekit-test-app/svelte.config.js +18 -0
  41. package/e2e-tests/test-applications/sveltekit-test-app/vite.config.ts +6 -0
  42. package/e2e-tests/tests/nextjs.test.ts +161 -0
  43. package/e2e-tests/tests/remix.test.ts +35 -44
  44. package/e2e-tests/tests/sveltekit.test.ts +154 -0
  45. package/e2e-tests/utils/index.ts +54 -11
  46. package/package.json +3 -5
  47. package/src/apple/templates.ts +5 -1
  48. package/src/apple/xcode-manager.ts +2 -0
  49. package/src/nextjs/nextjs-wizard.ts +31 -6
  50. package/src/nextjs/templates.ts +15 -0
@@ -0,0 +1,186 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ /* eslint-disable jest/expect-expect */
63
+ var Constants_1 = require("../../lib/Constants");
64
+ var utils_1 = require("../utils");
65
+ var path = __importStar(require("path"));
66
+ describe('Sveltekit', function () {
67
+ var integration = Constants_1.Integration.sveltekit;
68
+ var projectDir = path.resolve(__dirname, '../test-applications/sveltekit-test-app');
69
+ beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
70
+ var wizardInstance, packageManagerPrompted, tracingOptionPrompted, _a, replayOptionPrompted, _b, _c;
71
+ return __generator(this, function (_d) {
72
+ switch (_d.label) {
73
+ case 0:
74
+ wizardInstance = (0, utils_1.startWizardInstance)(integration, projectDir);
75
+ return [4 /*yield*/, wizardInstance.waitForOutput('Please select your package manager.', {
76
+ optional: true,
77
+ })];
78
+ case 1:
79
+ packageManagerPrompted = _d.sent();
80
+ _a = packageManagerPrompted;
81
+ if (!_a) return [3 /*break*/, 3];
82
+ return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput(
83
+ // Selecting `yarn` as the package manager
84
+ [utils_1.KEYS.DOWN, utils_1.KEYS.ENTER],
85
+ // "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
86
+ 'to track the performance of your application?', {
87
+ timeout: 240000,
88
+ })];
89
+ case 2:
90
+ _a = (_d.sent());
91
+ _d.label = 3;
92
+ case 3:
93
+ tracingOptionPrompted = _a;
94
+ _b = tracingOptionPrompted;
95
+ if (!_b) return [3 /*break*/, 5];
96
+ return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER],
97
+ // "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
98
+ 'to get a video-like reproduction of errors during a user session?')];
99
+ case 4:
100
+ _b = (_d.sent());
101
+ _d.label = 5;
102
+ case 5:
103
+ replayOptionPrompted = _b;
104
+ _c = replayOptionPrompted;
105
+ if (!_c) return [3 /*break*/, 7];
106
+ return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Do you want to create an example page', {
107
+ optional: true,
108
+ })];
109
+ case 6:
110
+ _c = (_d.sent());
111
+ _d.label = 7;
112
+ case 7:
113
+ _c;
114
+ return [4 /*yield*/, wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER, utils_1.KEYS.ENTER], 'Successfully installed the Sentry SvelteKit SDK!')];
115
+ case 8:
116
+ _d.sent();
117
+ wizardInstance.kill();
118
+ return [2 /*return*/];
119
+ }
120
+ });
121
+ }); });
122
+ afterAll(function () {
123
+ (0, utils_1.revertLocalChanges)(projectDir);
124
+ (0, utils_1.cleanupGit)(projectDir);
125
+ });
126
+ test('should have the correct package.json', function () {
127
+ (0, utils_1.checkPackageJson)(projectDir, integration);
128
+ });
129
+ test('should have the correct .env.sentry-build-plugin', function () {
130
+ (0, utils_1.checkEnvBuildPlugin)(projectDir);
131
+ });
132
+ test('example page exists', function () {
133
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example/+page.svelte'));
134
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example/+server.js'));
135
+ });
136
+ test('vite.config contains sentry plugin', function () {
137
+ (0, utils_1.checkFileContents)(path.resolve(projectDir, 'vite.config.ts'), "plugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n");
138
+ });
139
+ test('hook files created', function () {
140
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.server.ts'));
141
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.client.ts'));
142
+ });
143
+ test('hooks.client.ts contains sentry import', function () {
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 () {
153
+ return __generator(this, function (_a) {
154
+ switch (_a.label) {
155
+ case 0: return [4 /*yield*/, (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'ready in')];
156
+ case 1:
157
+ _a.sent();
158
+ return [2 /*return*/];
159
+ }
160
+ });
161
+ }); });
162
+ test('should build successfully', function () { return __awaiter(void 0, void 0, void 0, function () {
163
+ return __generator(this, function (_a) {
164
+ switch (_a.label) {
165
+ case 0: return [4 /*yield*/, (0, utils_1.checkIfBuilds)(projectDir, 'Successfully uploaded source maps to Sentry')];
166
+ case 1:
167
+ _a.sent();
168
+ return [2 /*return*/];
169
+ }
170
+ });
171
+ }); });
172
+ test('runs on prod mode correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
173
+ return __generator(this, function (_a) {
174
+ 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")];
178
+ case 1:
179
+ // We can't use the full prompt `Network: use--host to expose` as `--host` can be printed in bold.
180
+ _a.sent();
181
+ return [2 /*return*/];
182
+ }
183
+ });
184
+ }); });
185
+ });
186
+ //# sourceMappingURL=sveltekit.test.js.map
@@ -0,0 +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,qBAAq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,SAAS,CAAC,EAAA;;oBAD/D,kGAAkG;oBAClG,SAA+D,CAAC;;;;SACjE,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('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"]}
@@ -12,6 +12,8 @@ export declare const KEYS: {
12
12
  export declare const TEST_ARGS: {
13
13
  AUTH_TOKEN: string;
14
14
  PROJECT_DSN: string;
15
+ ORG_SLUG: string;
16
+ PROJECT_SLUG: string;
15
17
  };
16
18
  export declare const log: {
17
19
  success: (message: string) => void;
@@ -25,6 +27,15 @@ export declare class WizardTestEnv {
25
27
  debug?: boolean;
26
28
  });
27
29
  sendStdin(input: string): void;
30
+ /**
31
+ * Sends the input and waits for the output.
32
+ * @returns a promise that resolves when the output was found
33
+ * @throws an error when the output was not found within the timeout
34
+ */
35
+ sendStdinAndWaitForOutput(input: string | string[], output: string, options?: {
36
+ timeout?: number;
37
+ optional?: boolean;
38
+ }): Promise<boolean>;
28
39
  /**
29
40
  * Waits for the provided output with `.includes()` logic.
30
41
  *
@@ -68,7 +79,7 @@ export declare function revertLocalChanges(projectDir: string): void;
68
79
  *
69
80
  * @returns WizardTestEnv
70
81
  */
71
- export declare function startWizardInstance(integration: Integration, projectDir: string): WizardTestEnv;
82
+ export declare function startWizardInstance(integration: Integration, projectDir: string, debug?: boolean): WizardTestEnv;
72
83
  /**
73
84
  * Read the file contents and check if it contains the given content
74
85
  *
@@ -114,4 +125,4 @@ export declare function checkIfRunsOnDevMode(projectDir: string, expectedOutput:
114
125
  * @param projectDir
115
126
  * @param expectedOutput
116
127
  */
117
- export declare function checkIfRunsOnProdMode(projectDir: string, expectedOutput: string): Promise<void>;
128
+ export declare function checkIfRunsOnProdMode(projectDir: string, expectedOutput: string, startCommand?: string): Promise<void>;
@@ -84,8 +84,10 @@ exports.KEYS = {
84
84
  SPACE: ' ',
85
85
  };
86
86
  exports.TEST_ARGS = {
87
- AUTH_TOKEN: 'TEST_AUTH_TOKEN',
88
- PROJECT_DSN: 'https://public@dsn.ingest.sentry.io/1337',
87
+ AUTH_TOKEN: process.env.SENTRY_TEST_AUTH_TOKEN || 'TEST_AUTH_TOKEN',
88
+ PROJECT_DSN: process.env.SENTRY_TEST_DSN || 'https://public@dsn.ingest.sentry.io/1337',
89
+ ORG_SLUG: process.env.SENTRY_TEST_ORG || 'TEST_ORG_SLUG',
90
+ PROJECT_SLUG: process.env.SENTRY_TEST_PROJECT || 'TEST_PROJECT_SLUG',
89
91
  };
90
92
  exports.log = {
91
93
  success: function (message) {
@@ -109,6 +111,24 @@ var WizardTestEnv = /** @class */ (function () {
109
111
  WizardTestEnv.prototype.sendStdin = function (input) {
110
112
  this.taskHandle.stdin.write(input);
111
113
  };
114
+ /**
115
+ * Sends the input and waits for the output.
116
+ * @returns a promise that resolves when the output was found
117
+ * @throws an error when the output was not found within the timeout
118
+ */
119
+ WizardTestEnv.prototype.sendStdinAndWaitForOutput = function (input, output, options) {
120
+ var outputPromise = this.waitForOutput(output, options);
121
+ if (Array.isArray(input)) {
122
+ for (var _i = 0, input_1 = input; _i < input_1.length; _i++) {
123
+ var i = input_1[_i];
124
+ this.sendStdin(i);
125
+ }
126
+ }
127
+ else {
128
+ this.sendStdin(input);
129
+ }
130
+ return outputPromise;
131
+ };
112
132
  /**
113
133
  * Waits for the provided output with `.includes()` logic.
114
134
  *
@@ -118,7 +138,7 @@ var WizardTestEnv = /** @class */ (function () {
118
138
  WizardTestEnv.prototype.waitForOutput = function (output, options) {
119
139
  var _this = this;
120
140
  if (options === void 0) { options = {}; }
121
- var _a = __assign({ timeout: 30000, optional: false }, options), timeout = _a.timeout, optional = _a.optional;
141
+ var _a = __assign({ timeout: 60000, optional: false }, options), timeout = _a.timeout, optional = _a.optional;
122
142
  return new Promise(function (resolve, reject) {
123
143
  var outputBuffer = '';
124
144
  var timeoutId = setTimeout(function () {
@@ -166,7 +186,7 @@ function initGit(projectDir) {
166
186
  }
167
187
  catch (e) {
168
188
  exports.log.error('Error initializing git');
169
- throw e;
189
+ exports.log.error(e);
170
190
  }
171
191
  }
172
192
  exports.initGit = initGit;
@@ -184,7 +204,7 @@ function cleanupGit(projectDir) {
184
204
  }
185
205
  catch (e) {
186
206
  exports.log.error('Error cleaning up git');
187
- throw e;
207
+ exports.log.error(e);
188
208
  }
189
209
  }
190
210
  exports.cleanupGit = cleanupGit;
@@ -205,7 +225,7 @@ function revertLocalChanges(projectDir) {
205
225
  }
206
226
  catch (e) {
207
227
  exports.log.error('Error reverting local changes');
208
- throw e;
228
+ exports.log.error(e);
209
229
  }
210
230
  }
211
231
  exports.revertLocalChanges = revertLocalChanges;
@@ -216,7 +236,8 @@ exports.revertLocalChanges = revertLocalChanges;
216
236
  *
217
237
  * @returns WizardTestEnv
218
238
  */
219
- function startWizardInstance(integration, projectDir) {
239
+ function startWizardInstance(integration, projectDir, debug) {
240
+ if (debug === void 0) { debug = false; }
220
241
  var binPath = path.join(__dirname, '../../dist/bin.js');
221
242
  revertLocalChanges(projectDir);
222
243
  cleanupGit(projectDir);
@@ -230,7 +251,11 @@ function startWizardInstance(integration, projectDir) {
230
251
  exports.TEST_ARGS.AUTH_TOKEN,
231
252
  '--preSelectedProject.dsn',
232
253
  exports.TEST_ARGS.PROJECT_DSN,
233
- ], { cwd: projectDir });
254
+ '--preSelectedProject.orgSlug',
255
+ exports.TEST_ARGS.ORG_SLUG,
256
+ '--preSelectedProject.projectSlug',
257
+ exports.TEST_ARGS.PROJECT_SLUG,
258
+ ], { cwd: projectDir, debug: debug });
234
259
  }
235
260
  exports.startWizardInstance = startWizardInstance;
236
261
  /**
@@ -295,7 +320,9 @@ function checkIfBuilds(projectDir, expectedOutput) {
295
320
  testEnv = new WizardTestEnv('npm', ['run', 'build'], {
296
321
  cwd: projectDir,
297
322
  });
298
- return [4 /*yield*/, expect(testEnv.waitForOutput(expectedOutput)).resolves.toBe(true)];
323
+ return [4 /*yield*/, expect(testEnv.waitForOutput(expectedOutput, {
324
+ timeout: 120000,
325
+ })).resolves.toBe(true)];
299
326
  case 1:
300
327
  _a.sent();
301
328
  return [2 /*return*/];
@@ -316,7 +343,9 @@ function checkIfRunsOnDevMode(projectDir, expectedOutput) {
316
343
  switch (_a.label) {
317
344
  case 0:
318
345
  testEnv = new WizardTestEnv('npm', ['run', 'dev'], { cwd: projectDir });
319
- return [4 /*yield*/, expect(testEnv.waitForOutput(expectedOutput)).resolves.toBe(true)];
346
+ return [4 /*yield*/, expect(testEnv.waitForOutput(expectedOutput, {
347
+ timeout: 120000,
348
+ })).resolves.toBe(true)];
320
349
  case 1:
321
350
  _a.sent();
322
351
  testEnv.kill();
@@ -331,16 +360,19 @@ exports.checkIfRunsOnDevMode = checkIfRunsOnDevMode;
331
360
  * @param projectDir
332
361
  * @param expectedOutput
333
362
  */
334
- function checkIfRunsOnProdMode(projectDir, expectedOutput) {
363
+ function checkIfRunsOnProdMode(projectDir, expectedOutput, startCommand) {
364
+ if (startCommand === void 0) { startCommand = 'start'; }
335
365
  return __awaiter(this, void 0, void 0, function () {
336
366
  var testEnv;
337
367
  return __generator(this, function (_a) {
338
368
  switch (_a.label) {
339
369
  case 0:
340
- testEnv = new WizardTestEnv('npm', ['run', 'start'], {
370
+ testEnv = new WizardTestEnv('npm', ['run', startCommand], {
341
371
  cwd: projectDir,
342
372
  });
343
- return [4 /*yield*/, expect(testEnv.waitForOutput(expectedOutput)).resolves.toBe(true)];
373
+ return [4 /*yield*/, expect(testEnv.waitForOutput(expectedOutput, {
374
+ timeout: 120000,
375
+ })).resolves.toBe(true)];
344
376
  case 1:
345
377
  _a.sent();
346
378
  testEnv.kill();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../e2e-tests/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAG7B,+CAAgD;AAEhD,oDAA2D;AAE9C,QAAA,IAAI,GAAG;IAClB,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAA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,CAAC,EAAE;wBACzD,GAAG,EAAE,UAAU;qBAChB,CAAC,CAAC;oBAEH,qBAAM,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;oBAAvE,SAAuE,CAAC;oBACxE,OAAO,CAAC,IAAI,EAAE,CAAC;;;;;CAChB;AAVD,sDAUC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport type { Integration } from '../../lib/Constants';\nimport { spawn, execSync } from 'child_process';\nimport type { ChildProcess } from 'child_process';\nimport { dim, green, red } from '../../lib/Helper/Logging';\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: 'TEST_AUTH_TOKEN',\n PROJECT_DSN: 'https://public@dsn.ingest.sentry.io/1337',\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: string) => {\n red(`[ERROR] ${message}`);\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 * 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: 30_000,\n optional: false,\n ...options,\n };\n\n return new Promise<boolean>((resolve, reject) => {\n let outputBuffer = '';\n const timeoutId = setTimeout(() => {\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(new Error(`Timeout waiting for output: ${output}`));\n }\n }, timeout);\n\n this.taskHandle.stdout.on('data', (data) => {\n outputBuffer += data;\n if (outputBuffer.includes(output)) {\n clearTimeout(timeoutId);\n // The output is found so we can resolve the promise with true\n resolve(true);\n }\n });\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 throw 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 throw 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 checkout .', { cwd: projectDir });\n // Revert untracked files\n execSync('git clean -fd .', { cwd: projectDir });\n } catch (e) {\n log.error('Error reverting local changes');\n throw e;\n }\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): WizardTestEnv {\n const binPath = path.join(__dirname, '../../dist/bin.js');\n\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n initGit(projectDir);\n\n return new WizardTestEnv(\n 'node',\n [\n binPath,\n '--debug',\n '-i',\n integration,\n '--preSelectedProject.authToken',\n TEST_ARGS.AUTH_TOKEN,\n '--preSelectedProject.dsn',\n TEST_ARGS.PROJECT_DSN,\n ],\n { cwd: projectDir },\n );\n}\n\n/**\n * Read the file contents and check if it contains the given content\n *\n * @param filePath\n * @param 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 * @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 * @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 project builds\n * @param projectDir\n */\nexport async function checkIfBuilds(\n projectDir: string,\n expectedOutput: string,\n) {\n const testEnv = new WizardTestEnv('npm', ['run', 'build'], {\n cwd: projectDir,\n });\n\n await expect(testEnv.waitForOutput(expectedOutput)).resolves.toBe(true);\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 await expect(testEnv.waitForOutput(expectedOutput)).resolves.toBe(true);\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) {\n const testEnv = new WizardTestEnv('npm', ['run', 'start'], {\n cwd: projectDir,\n });\n\n await expect(testEnv.waitForOutput(expectedOutput)).resolves.toBe(true);\n testEnv.kill();\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../e2e-tests/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAG7B,+CAAgD;AAEhD,oDAA2D;AAE9C,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,m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C;AAED;;;;GAIG;AACH,SAAsB,oBAAoB,CACxC,UAAkB,EAClB,cAAsB;;;;;;oBAEhB,OAAO,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;oBAE9E,qBAAM,MAAM,CACV,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE;4BACpC,OAAO,EAAE,MAAO;yBACjB,CAAC,CACH,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;oBAJrB,SAIqB,CAAC;oBACtB,OAAO,CAAC,IAAI,EAAE,CAAC;;;;;CAChB;AAZD,oDAYC;AAED;;;;GAIG;AACH,SAAsB,qBAAqB,CACzC,UAAkB,EAClB,cAAsB,EACtB,YAAsB;IAAtB,6BAAA,EAAA,sBAAsB;;;;;;oBAEhB,OAAO,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE;wBAC9D,GAAG,EAAE,UAAU;qBAChB,CAAC,CAAC;oBAEH,qBAAM,MAAM,CACV,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE;4BACpC,OAAO,EAAE,MAAO;yBACjB,CAAC,CACH,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;oBAJrB,SAIqB,CAAC;oBACtB,OAAO,CAAC,IAAI,EAAE,CAAC;;;;;CAChB;AAfD,sDAeC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport type { Integration } from '../../lib/Constants';\nimport { spawn, execSync } from 'child_process';\nimport type { ChildProcess } from 'child_process';\nimport { dim, green, red } from '../../lib/Helper/Logging';\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: string) => {\n red(`[ERROR] ${message}`);\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 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 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(new Error(`Timeout waiting for output: ${output}`));\n }\n }, timeout);\n\n this.taskHandle.stdout.on('data', (data) => {\n outputBuffer += data;\n if (outputBuffer.includes(output)) {\n clearTimeout(timeoutId);\n // The output is found so we can resolve the promise with true\n resolve(true);\n }\n });\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 checkout .', { cwd: projectDir });\n // Revert untracked files\n execSync('git clean -fd .', { cwd: projectDir });\n } catch (e) {\n log.error('Error reverting local changes');\n log.error(e);\n }\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 binPath = path.join(__dirname, '../../dist/bin.js');\n\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n initGit(projectDir);\n\n return new WizardTestEnv(\n 'node',\n [\n binPath,\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 ],\n { cwd: projectDir, debug },\n );\n}\n\n/**\n * Read the file contents and check if it contains the given content\n *\n * @param filePath\n * @param 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 * @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 * @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 project builds\n * @param projectDir\n */\nexport async function checkIfBuilds(\n projectDir: string,\n expectedOutput: string,\n) {\n const testEnv = new WizardTestEnv('npm', ['run', 'build'], {\n cwd: projectDir,\n });\n\n await expect(\n testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n }),\n ).resolves.toBe(true);\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 await expect(\n testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n }),\n ).resolves.toBe(true);\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 await expect(\n testEnv.waitForOutput(expectedOutput, {\n timeout: 120_000,\n }),\n ).resolves.toBe(true);\n testEnv.kill();\n}\n"]}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "3.34.2",
3
+ "version": "3.34.3",
4
4
  "homepage": "https://github.com/getsentry/sentry-wizard",
5
5
  "repository": "https://github.com/getsentry/sentry-wizard",
6
6
  "description": "Sentry wizard helping you to configure your project",
@@ -55,6 +55,7 @@
55
55
  "@types/yargs": "^16.0.9",
56
56
  "@typescript-eslint/eslint-plugin": "^5.13.0",
57
57
  "@typescript-eslint/parser": "^5.13.0",
58
+ "dotenv": "^16.4.5",
58
59
  "eslint": "^8.18.0",
59
60
  "eslint-config-prettier": "^8.3.0",
60
61
  "eslint-plugin-jest": "^25.3.0",
@@ -66,9 +67,6 @@
66
67
  "tsx": "^3.14.0",
67
68
  "typescript": "^5.0.4"
68
69
  },
69
- "resolutions": {
70
- "**/xmldom": "^0.6.0"
71
- },
72
70
  "engines": {
73
71
  "node": ">=14.18.0",
74
72
  "npm": ">=3.10.7",
@@ -87,7 +85,7 @@
87
85
  "fix:prettier": "prettier --write \"{lib,src,test}/**/*.ts\"",
88
86
  "fix:eslint": "eslint . --format stylish --fix",
89
87
  "test": "yarn build && jest",
90
- "test:e2e": "yarn build && jest -c=\"./e2e-tests/jest.config.ts\" ./e2e-tests/",
88
+ "test:e2e": "yarn build && ./e2e-tests/run.sh",
91
89
  "try": "ts-node bin.ts",
92
90
  "try:uninstall": "ts-node bin.ts --uninstall",
93
91
  "test:watch": "jest --watch"
@@ -1,4 +1,4 @@
1
- export declare function getRunScriptTemplate(orgSlug: string, projectSlug: string, uploadSource?: boolean): string;
1
+ export declare function getRunScriptTemplate(orgSlug: string, projectSlug: string, uploadSource?: boolean, includeHomebrewPath?: boolean): string;
2
2
  export declare const scriptInputPath = "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"";
3
3
  export declare function getSwiftSnippet(dsn: string): string;
4
4
  export declare function getObjcSnippet(dsn: string): string;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFastlaneSnippet = exports.getObjcSnippet = exports.getSwiftSnippet = exports.scriptInputPath = exports.getRunScriptTemplate = void 0;
4
- function getRunScriptTemplate(orgSlug, projectSlug, uploadSource) {
4
+ function getRunScriptTemplate(orgSlug, projectSlug, uploadSource, includeHomebrewPath) {
5
5
  if (uploadSource === void 0) { uploadSource = true; }
6
+ if (includeHomebrewPath === void 0) { includeHomebrewPath = false; }
6
7
  // eslint-disable-next-line no-useless-escape
7
- return "# This script is responsable to upload debug symbols and source context for Sentry.\\nif which sentry-cli >/dev/null; then\\nexport SENTRY_ORG=".concat(orgSlug, "\\nexport SENTRY_PROJECT=").concat(projectSlug, "\\nERROR=$(sentry-cli debug-files upload ").concat(uploadSource ? '--include-sources ' : '', "\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\nif [ ! $? -eq 0 ]; then\\necho \"warning: sentry-cli - $ERROR\"\\nfi\\nelse\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\nfi\\n");
8
+ var includeHomebrew = includeHomebrewPath
9
+ ? '\\nif [[ "$(uname -m)" == arm64 ]]; then\\nexport PATH="/opt/homebrew/bin:$PATH"\\nfi'
10
+ : '';
11
+ return "# This script is responsable to upload debug symbols and source context for Sentry.".concat(includeHomebrew, "\\nif which sentry-cli >/dev/null; then\\nexport SENTRY_ORG=").concat(orgSlug, "\\nexport SENTRY_PROJECT=").concat(projectSlug, "\\nERROR=$(sentry-cli debug-files upload ").concat(uploadSource ? '--include-sources ' : '', "\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\nif [ ! $? -eq 0 ]; then\\necho \"warning: sentry-cli - $ERROR\"\\nfi\\nelse\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\nfi\\n");
8
12
  }
9
13
  exports.getRunScriptTemplate = getRunScriptTemplate;
10
14
  exports.scriptInputPath = '"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}"';
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAmB;IAAnB,6BAAA,EAAA,mBAAmB;IAEnB,6CAA6C;IAC7C,OAAO,yJAAkJ,OAAO,sCAA4B,WAAW,sDACrM,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oPACiM,CAAC;AAC9O,CAAC;AATD,oDASC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,4EACoB,GAAG,4kBASiC,CAAC;AAClE,CAAC;AAZD,0CAYC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO,0GACiB,GAAG,8iBAS8B,CAAC;AAC5D,CAAC;AAZD,wCAYC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO,4CACU,GAAG,sCACC,OAAO,2CAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource = true,\n): string {\n // eslint-disable-next-line no-useless-escape\n return `# This script is responsable to upload debug symbols and source context for Sentry.\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\nERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\\\nif [ ! $? -eq 0 ]; then\\\\necho \"warning: sentry-cli - $ERROR\"\\\\nfi\\\\nelse\\\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\\\nfi\\\\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n options.enableTracing = true \n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n options.enableTracing = YES;\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAmB,EACnB,mBAA2B;IAD3B,6BAAA,EAAA,mBAAmB;IACnB,oCAAA,EAAA,2BAA2B;IAE3B,6CAA6C;IAC7C,IAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC,uFAAuF;QACzF,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,6FAAsF,eAAe,yEAA+D,OAAO,sCAA4B,WAAW,sDACvN,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oPACiM,CAAC;AAC9O,CAAC;AAbD,oDAaC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,4EACoB,GAAG,4kBASiC,CAAC;AAClE,CAAC;AAZD,0CAYC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO,0GACiB,GAAG,8iBAS8B,CAAC;AAC5D,CAAC;AAZD,wCAYC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO,4CACU,GAAG,sCACC,OAAO,2CAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource = true,\n includeHomebrewPath = false,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? '\\\\nif [[ \"$(uname -m)\" == arm64 ]]; then\\\\nexport PATH=\"/opt/homebrew/bin:$PATH\"\\\\nfi'\n : '';\n return `# This script is responsable to upload debug symbols and source context for Sentry.${includeHomebrew}\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\nERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\\\nif [ ! $? -eq 0 ]; then\\\\necho \"warning: sentry-cli - $ERROR\"\\\\nfi\\\\nelse\\\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\\\nfi\\\\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n options.enableTracing = true \n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n options.enableTracing = YES;\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
@@ -149,12 +149,13 @@ function addUploadSymbolsScript(xcodeProject, sentryProject, targetName, uploadS
149
149
  }
150
150
  }
151
151
  }
152
+ var isHomebrewInstalled = fs.existsSync('/opt/homebrew/bin/sentry-cli');
152
153
  xcodeProject.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Upload Debug Symbols to Sentry', targetKey, {
153
154
  inputFileListPaths: [],
154
155
  outputFileListPaths: [],
155
156
  inputPaths: [templates.scriptInputPath],
156
157
  shellPath: '/bin/sh',
157
- shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, uploadSource),
158
+ shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, uploadSource, isHomebrewInstalled),
158
159
  });
159
160
  prompts_1.default.log.step("Added Sentry upload script to \"".concat(targetName, "\" build phase"));
160
161
  }