@sentry/wizard 3.12.0 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/lib/Steps/ChooseIntegration.js +1 -0
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/android/android-wizard.js +6 -4
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +5 -2
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +1 -1
- package/dist/src/nextjs/templates.js +2 -2
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +8 -4
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-setup.d.ts +5 -1
- package/dist/src/remix/sdk-setup.js +3 -2
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.d.ts +9 -0
- package/dist/src/sourcemaps/tools/sentry-cli.js +26 -22
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.d.ts +6 -0
- package/dist/src/sourcemaps/tools/tsc.js +98 -17
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +3 -13
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +3 -13
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +122 -48
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.d.ts +1 -0
- package/dist/src/sveltekit/sveltekit-wizard.js +119 -44
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/utils.d.ts +2 -0
- package/dist/src/sveltekit/utils.js +48 -0
- package/dist/src/sveltekit/utils.js.map +1 -0
- package/dist/src/utils/ast-utils.d.ts +70 -0
- package/dist/src/utils/ast-utils.js +152 -1
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +38 -6
- package/dist/src/utils/clack-utils.js +57 -51
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +5 -0
- package/dist/src/utils/package-manager.js +11 -7
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.d.ts +1 -0
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +112 -0
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -0
- package/dist/test/sourcemaps/tools/tsc.test.d.ts +1 -0
- package/dist/test/sourcemaps/tools/tsc.test.js +121 -0
- package/dist/test/sourcemaps/tools/tsc.test.js.map +1 -0
- package/dist/test/utils/ast-utils.test.js +157 -26
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/lib/Steps/ChooseIntegration.ts +1 -0
- package/package.json +1 -1
- package/src/android/android-wizard.ts +8 -5
- package/src/nextjs/nextjs-wizard.ts +15 -3
- package/src/nextjs/templates.ts +3 -2
- package/src/remix/remix-wizard.ts +8 -11
- package/src/remix/sdk-setup.ts +8 -2
- package/src/sourcemaps/tools/sentry-cli.ts +16 -9
- package/src/sourcemaps/tools/tsc.ts +133 -28
- package/src/sourcemaps/tools/vite.ts +15 -39
- package/src/sourcemaps/tools/webpack.ts +16 -39
- package/src/sveltekit/sdk-setup.ts +109 -37
- package/src/sveltekit/sveltekit-wizard.ts +93 -25
- package/src/sveltekit/utils.ts +50 -0
- package/src/utils/ast-utils.ts +180 -0
- package/src/utils/clack-utils.ts +68 -49
- package/src/utils/package-manager.ts +12 -6
- package/test/sourcemaps/tools/sentry-cli.test.ts +51 -0
- package/test/sourcemaps/tools/tsc.test.ts +181 -0
- package/test/utils/ast-utils.test.ts +233 -32
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
var fs = __importStar(require("fs"));
|
|
63
|
+
var sentry_cli_1 = require("../../../src/sourcemaps/tools/sentry-cli");
|
|
64
|
+
var packageManagerHelpers = __importStar(require("../../../src/utils/package-manager"));
|
|
65
|
+
var writeFileSpy = jest
|
|
66
|
+
.spyOn(fs.promises, 'writeFile')
|
|
67
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
68
|
+
jest.mock('@clack/prompts', function () {
|
|
69
|
+
return {
|
|
70
|
+
log: {
|
|
71
|
+
info: jest.fn(),
|
|
72
|
+
success: jest.fn(),
|
|
73
|
+
},
|
|
74
|
+
confirm: jest.fn().mockResolvedValue(true),
|
|
75
|
+
isCancel: jest.fn().mockReturnValue(false),
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
describe('addSentryCommandToBuildCommand', function () {
|
|
79
|
+
afterEach(function () {
|
|
80
|
+
jest.clearAllMocks();
|
|
81
|
+
});
|
|
82
|
+
it.each([
|
|
83
|
+
[
|
|
84
|
+
packageManagerHelpers.NPM,
|
|
85
|
+
packageManagerHelpers.PNPM,
|
|
86
|
+
packageManagerHelpers.YARN,
|
|
87
|
+
packageManagerHelpers.BUN,
|
|
88
|
+
],
|
|
89
|
+
])('adds the cli command to the script command (%s)', function (_, pacMan) { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
+
var packageJson;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
jest
|
|
95
|
+
.spyOn(packageManagerHelpers, 'detectPackageManger')
|
|
96
|
+
.mockReturnValue(pacMan);
|
|
97
|
+
packageJson = {
|
|
98
|
+
scripts: {
|
|
99
|
+
build: 'tsc',
|
|
100
|
+
},
|
|
101
|
+
version: '1.0.0',
|
|
102
|
+
};
|
|
103
|
+
return [4 /*yield*/, (0, sentry_cli_1.addSentryCommandToBuildCommand)(packageJson)];
|
|
104
|
+
case 1:
|
|
105
|
+
_a.sent();
|
|
106
|
+
expect(writeFileSpy).toHaveBeenCalledWith(expect.stringContaining('package.json'), expect.stringContaining("tsc && ".concat(pacMan.runScriptCommand, " sentry:sourcemaps")));
|
|
107
|
+
return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); });
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=sentry-cli.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-cli.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/sentry-cli.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AAEzB,uEAA0F;AAE1F,wFAA4E;AAE5E,IAAM,YAAY,GAAG,IAAI;KACtB,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;KAC/B,kBAAkB,CAAC,cAAM,OAAA,OAAO,CAAC,OAAO,EAAE,EAAjB,CAAiB,CAAC,CAAC;AAE/C,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;IAC1B,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;YACf,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;SACnB;QACD,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC;QAC1C,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;KAC3C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,gCAAgC,EAAE;IACzC,SAAS,CAAC;QACR,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,IAAI,CAAC;QACN;YACE,qBAAqB,CAAC,GAAG;YACzB,qBAAqB,CAAC,IAAI;YAC1B,qBAAqB,CAAC,IAAI;YAC1B,qBAAqB,CAAC,GAAG;SAC1B;KACF,CAAC,CAAC,iDAAiD,EAAE,UAAO,CAAC,EAAE,MAAM;;;;;oBACpE,IAAI;yBACD,KAAK,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;yBACnD,eAAe,CAAC,MAAM,CAAC,CAAC;oBACrB,WAAW,GAAG;wBAClB,OAAO,EAAE;4BACP,KAAK,EAAE,KAAK;yBACb;wBACD,OAAO,EAAE,OAAO;qBACjB,CAAC;oBACF,qBAAM,IAAA,2CAA8B,EAAC,WAAW,CAAC,EAAA;;oBAAjD,SAAiD,CAAC;oBAClD,MAAM,CAAC,YAAY,CAAC,CAAC,oBAAoB,CACvC,MAAM,CAAC,gBAAgB,CAAC,cAAc,CAAC,EACvC,MAAM,CAAC,gBAAgB,CACrB,iBAAU,MAAM,CAAC,gBAAgB,uBAAoB,CACtD,CACF,CAAC;;;;SACH,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'fs';\n\nimport { addSentryCommandToBuildCommand } from '../../../src/sourcemaps/tools/sentry-cli';\n\nimport * as packageManagerHelpers from '../../../src/utils/package-manager';\n\nconst writeFileSpy = jest\n .spyOn(fs.promises, 'writeFile')\n .mockImplementation(() => Promise.resolve());\n\njest.mock('@clack/prompts', () => {\n return {\n log: {\n info: jest.fn(),\n success: jest.fn(),\n },\n confirm: jest.fn().mockResolvedValue(true),\n isCancel: jest.fn().mockReturnValue(false),\n };\n});\n\ndescribe('addSentryCommandToBuildCommand', () => {\n afterEach(() => {\n jest.clearAllMocks();\n });\n it.each([\n [\n packageManagerHelpers.NPM,\n packageManagerHelpers.PNPM,\n packageManagerHelpers.YARN,\n packageManagerHelpers.BUN,\n ],\n ])('adds the cli command to the script command (%s)', async (_, pacMan) => {\n jest\n .spyOn(packageManagerHelpers, 'detectPackageManger')\n .mockReturnValue(pacMan);\n const packageJson = {\n scripts: {\n build: 'tsc',\n },\n version: '1.0.0',\n };\n await addSentryCommandToBuildCommand(packageJson);\n expect(writeFileSpy).toHaveBeenCalledWith(\n expect.stringContaining('package.json'),\n expect.stringContaining(\n `tsc && ${pacMan.runScriptCommand} sentry:sourcemaps`,\n ),\n );\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
var fs = __importStar(require("fs"));
|
|
63
|
+
var tsc_1 = require("../../../src/sourcemaps/tools/tsc");
|
|
64
|
+
function updateFileContent(content) {
|
|
65
|
+
fileContent = content;
|
|
66
|
+
}
|
|
67
|
+
var fileContent = '';
|
|
68
|
+
jest.mock('@clack/prompts', function () {
|
|
69
|
+
return {
|
|
70
|
+
log: {
|
|
71
|
+
info: jest.fn(),
|
|
72
|
+
success: jest.fn(),
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
jest
|
|
77
|
+
.spyOn(fs.promises, 'readFile')
|
|
78
|
+
.mockImplementation(function () { return Promise.resolve(fileContent); });
|
|
79
|
+
var writeFileSpy = jest
|
|
80
|
+
.spyOn(fs.promises, 'writeFile')
|
|
81
|
+
.mockImplementation(function () { return Promise.resolve(void 0); });
|
|
82
|
+
describe('enableSourcemaps', function () {
|
|
83
|
+
afterEach(function () {
|
|
84
|
+
fileContent = '';
|
|
85
|
+
jest.clearAllMocks();
|
|
86
|
+
});
|
|
87
|
+
it.each([
|
|
88
|
+
[
|
|
89
|
+
'no sourcemaps options',
|
|
90
|
+
"\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n \"outDir\": \"dist\" // another inline comment\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n",
|
|
91
|
+
"\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n\n // another inline comment\n \"outDir\": \"dist\",\n\n \"sourceMap\": true,\n \"inlineSources\": true,\n\n // Set `sourceRoot` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\"\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n",
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
'a few sourcemaps options',
|
|
95
|
+
"\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n \"outDir\": \"dist\", // another inline comment\n \"sourceMap\": false,\n \"sourceRoot\": \"/src\"\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n",
|
|
96
|
+
"\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n\n // another inline comment\n \"outDir\": \"dist\",\n\n \"sourceMap\": true,\n\n // Set `sourceRoot` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\",\n\n \"inlineSources\": true\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n",
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
'no compiler options',
|
|
100
|
+
"\n{\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n",
|
|
101
|
+
"\n{\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ],\n\n \"compilerOptions\": {\n \"sourceMap\": true,\n \"inlineSources\": true,\n\n // Set `sourceRoot` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\"\n }\n}\n",
|
|
102
|
+
],
|
|
103
|
+
])('adds the plugin and enables source maps generation (%s)', function (_, originalCode, expectedCode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
|
+
var addedCode, _a, fileContent;
|
|
105
|
+
return __generator(this, function (_b) {
|
|
106
|
+
switch (_b.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
updateFileContent(originalCode);
|
|
109
|
+
return [4 /*yield*/, (0, tsc_1.enableSourcemaps)('')];
|
|
110
|
+
case 1:
|
|
111
|
+
addedCode = _b.sent();
|
|
112
|
+
expect(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
113
|
+
_a = writeFileSpy.mock.calls[0], fileContent = _a[1];
|
|
114
|
+
expect(fileContent).toBe(expectedCode);
|
|
115
|
+
expect(addedCode).toBe(true);
|
|
116
|
+
return [2 /*return*/];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}); });
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=tsc.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/tsc.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yDAAqE;AAErE,SAAS,iBAAiB,CAAC,OAAe;IACxC,WAAW,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,IAAI,WAAW,GAAG,EAAE,CAAC;AAErB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;IAC1B,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;YACf,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;SACnB;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI;KACD,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;KAC9B,kBAAkB,CAAC,cAAM,OAAA,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAA5B,CAA4B,CAAC,CAAC;AAE1D,IAAM,YAAY,GAAG,IAAI;KACtB,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;KAC/B,kBAAkB,CAAC,cAAM,OAAA,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAvB,CAAuB,CAAC,CAAC;AAErD,QAAQ,CAAC,kBAAkB,EAAE;IAC3B,SAAS,CAAC;QACR,WAAW,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,IAAI,CAAC;QACN;YACE,uBAAuB;YACvB,iUAkBL;YACK,ikBA4BL;SACI;QACD;YACE,0BAA0B;YAC1B,2XAoBL;YACK,mkBA6BL;SACI;QACD;YACE,qBAAqB;YACrB,mFAOL;YACK,uYAiBL;SACI;KACF,CAAC,CACA,yDAAyD,EACzD,UAAO,CAAC,EAAE,YAAY,EAAE,YAAY;;;;;oBAClC,iBAAiB,CAAC,YAAY,CAAC,CAAC;oBAEd,qBAAM,IAAA,sBAAgB,EAAC,EAAE,CAAC,EAAA;;oBAAtC,SAAS,GAAG,SAA0B;oBAE5C,MAAM,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;oBACvC,KAAmB,YAAY,CAAC,IAAI,CAAC,KAAK,GAA3B,EAAZ,WAAW,QAAA,CAA6B;oBAClD,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;oBACvC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;SAC9B,CACF,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'fs';\nimport { enableSourcemaps } from '../../../src/sourcemaps/tools/tsc';\n\nfunction updateFileContent(content: string): void {\n fileContent = content;\n}\n\nlet fileContent = '';\n\njest.mock('@clack/prompts', () => {\n return {\n log: {\n info: jest.fn(),\n success: jest.fn(),\n },\n };\n});\n\njest\n .spyOn(fs.promises, 'readFile')\n .mockImplementation(() => Promise.resolve(fileContent));\n\nconst writeFileSpy = jest\n .spyOn(fs.promises, 'writeFile')\n .mockImplementation(() => Promise.resolve(void 0));\n\ndescribe('enableSourcemaps', () => {\n afterEach(() => {\n fileContent = '';\n jest.clearAllMocks();\n });\n\n it.each([\n [\n 'no sourcemaps options',\n `\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n \"outDir\": \"dist\" // another inline comment\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n `\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n\n // another inline comment\n \"outDir\": \"dist\",\n\n \"sourceMap\": true,\n \"inlineSources\": true,\n\n // Set \\`sourceRoot\\` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\"\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n ],\n [\n 'a few sourcemaps options',\n `\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n \"outDir\": \"dist\", // another inline comment\n \"sourceMap\": false,\n \"sourceRoot\": \"/src\"\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n `\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n\n // another inline comment\n \"outDir\": \"dist\",\n\n \"sourceMap\": true,\n\n // Set \\`sourceRoot\\` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\",\n\n \"inlineSources\": true\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n ],\n [\n 'no compiler options',\n `\n{\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n `\n{\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ],\n\n \"compilerOptions\": {\n \"sourceMap\": true,\n \"inlineSources\": true,\n\n // Set \\`sourceRoot\\` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\"\n }\n}\n`,\n ],\n ])(\n 'adds the plugin and enables source maps generation (%s)',\n async (_, originalCode, expectedCode) => {\n updateFileContent(originalCode);\n\n const addedCode = await enableSourcemaps('');\n\n expect(writeFileSpy).toHaveBeenCalledTimes(1);\n const [[, fileContent]] = writeFileSpy.mock.calls;\n expect(fileContent).toBe(expectedCode);\n expect(addedCode).toBe(true);\n },\n );\n});\n"]}
|
|
@@ -25,32 +25,163 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
var ast_utils_1 = require("../../src/utils/ast-utils");
|
|
27
27
|
var recast = __importStar(require("recast"));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
28
|
+
var b = recast.types.builders;
|
|
29
|
+
describe('hasSentryContent', function () {
|
|
30
|
+
it.each([
|
|
31
|
+
"\n const { sentryVitePlugin } = require(\"@sentry/vite-plugin\");\n const somethingelse = require('gs');\n ",
|
|
32
|
+
"\n import { sentryVitePlugin } from \"@sentry/vite-plugin\";\n import * as somethingelse from 'gs';\n\n export default {\n plugins: [sentryVitePlugin()]\n }\n ",
|
|
33
|
+
])("returns true if a require('@sentry/') call was found in the parsed module", function (code) {
|
|
34
|
+
// recast.parse returns a Program node (or fails) but it's badly typed as any
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
36
|
+
var program = recast.parse(code)
|
|
37
|
+
.program;
|
|
38
|
+
expect((0, ast_utils_1.hasSentryContent)(program)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
it.each([
|
|
41
|
+
"const whatever = require('something')",
|
|
42
|
+
"// const {sentryWebpackPlugin} = require('@sentry/webpack-plugin')",
|
|
43
|
+
"const {sAntryWebpackPlugin} = require('webpack-plugin-@sentry')",
|
|
44
|
+
"\n import * as somethingelse from 'gs';\n export default {\n plugins: []\n }\n ",
|
|
45
|
+
"import * as somethingelse from 'gs';\n // import { sentryVitePlugin } from \"@sentry/vite-plugin\"\n export default {\n plugins: []\n }\n ",
|
|
46
|
+
"import * as thirdPartyVitePlugin from \"vite-plugin-@sentry\"\n export default {\n plugins: [thirdPartyVitePlugin()]\n }\n ",
|
|
47
|
+
])("returns false if the file doesn't contain any require('@sentry/') calls", function (code) {
|
|
48
|
+
// recast.parse returns a Program node (or fails) but it's badly typed as any
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
50
|
+
var program = recast.parse(code)
|
|
51
|
+
.program;
|
|
52
|
+
expect((0, ast_utils_1.hasSentryContent)(program)).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('getObjectProperty', function () {
|
|
56
|
+
it.each([
|
|
57
|
+
[
|
|
58
|
+
'literal',
|
|
59
|
+
b.objectExpression([
|
|
60
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
61
|
+
b.objectProperty(b.stringLiteral('needle'), b.stringLiteral('haystack')),
|
|
62
|
+
]),
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
'stringLiteral',
|
|
66
|
+
b.objectExpression([
|
|
67
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
68
|
+
b.objectProperty(b.literal('needle'), b.stringLiteral('haystack')),
|
|
69
|
+
]),
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
'identifier',
|
|
73
|
+
b.objectExpression([
|
|
74
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
75
|
+
b.objectProperty(b.identifier('needle'), b.stringLiteral('haystack')),
|
|
76
|
+
]),
|
|
77
|
+
],
|
|
78
|
+
])('returns the poperty (%s) if it exists', function (_, object) {
|
|
79
|
+
var property = (0, ast_utils_1.getObjectProperty)(object, 'needle');
|
|
80
|
+
expect(property).toBeDefined();
|
|
81
|
+
// @ts-expect-error we know it's defined due to the expect above
|
|
82
|
+
expect(recast.print(property).code).toEqual(expect.stringContaining('needle'));
|
|
83
|
+
});
|
|
84
|
+
it('returns undefined if the property does not exist', function () {
|
|
85
|
+
var object = b.objectExpression([
|
|
86
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
87
|
+
]);
|
|
88
|
+
var property = (0, ast_utils_1.getObjectProperty)(object, 'needle');
|
|
89
|
+
expect(property).toBeUndefined();
|
|
90
|
+
});
|
|
91
|
+
it('handles objects without simple properties', function () {
|
|
92
|
+
var object = b.objectExpression([b.spreadElement(b.identifier('foo'))]);
|
|
93
|
+
var property = (0, ast_utils_1.getObjectProperty)(object, 'needle');
|
|
94
|
+
expect(property).toBeUndefined();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe('getOrSetObjectProperty', function () {
|
|
98
|
+
it('returns the property if it exists', function () {
|
|
99
|
+
var object = b.objectExpression([
|
|
100
|
+
b.objectProperty(b.identifier('needle'), b.stringLiteral('haystack')),
|
|
101
|
+
]);
|
|
102
|
+
var property = (0, ast_utils_1.getOrSetObjectProperty)(object, 'needle', b.stringLiteral('nope'));
|
|
103
|
+
expect(property).toBeDefined();
|
|
104
|
+
expect(property.type).toBe('ObjectProperty');
|
|
105
|
+
// @ts-expect-error we know its type
|
|
106
|
+
expect(property.key.name).toBe('needle');
|
|
107
|
+
// @ts-expect-error we know its type
|
|
108
|
+
expect(property.value.value).toBe('haystack');
|
|
109
|
+
});
|
|
110
|
+
it('adds the property if it does not exist', function () {
|
|
111
|
+
var object = b.objectExpression([
|
|
112
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
113
|
+
]);
|
|
114
|
+
var property = (0, ast_utils_1.getOrSetObjectProperty)(object, 'needle', b.stringLiteral('haystack'));
|
|
115
|
+
expect(property).toBeDefined();
|
|
116
|
+
expect(property.type).toBe('Property');
|
|
117
|
+
// @ts-expect-error we know its type
|
|
118
|
+
expect(property.key.value).toBe('needle');
|
|
119
|
+
// @ts-expect-error we know its type
|
|
120
|
+
expect(property.value.value).toBe('haystack');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('setOrUpdateObjectProperty', function () {
|
|
124
|
+
it('sets a new property if it does not exist yet', function () {
|
|
125
|
+
var object = b.objectExpression([
|
|
126
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
127
|
+
]);
|
|
128
|
+
(0, ast_utils_1.setOrUpdateObjectProperty)(object, 'needle', b.stringLiteral('haystack'));
|
|
129
|
+
expect((0, ast_utils_1.getObjectProperty)(object, 'needle')).toBeDefined();
|
|
130
|
+
});
|
|
131
|
+
it('updates an existing property if it exists', function () {
|
|
132
|
+
var object = b.objectExpression([
|
|
133
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
134
|
+
b.objectProperty(b.identifier('needle'), b.stringLiteral('haystack')),
|
|
135
|
+
]);
|
|
136
|
+
(0, ast_utils_1.setOrUpdateObjectProperty)(object, 'needle', b.stringLiteral('haystack2'));
|
|
137
|
+
var property = (0, ast_utils_1.getObjectProperty)(object, 'needle');
|
|
138
|
+
// @ts-expect-error it must be defiend, otherwise we fail anyway
|
|
139
|
+
expect(property === null || property === void 0 ? void 0 : property.value.value).toBe('haystack2');
|
|
140
|
+
});
|
|
141
|
+
it('adds a comment to the existing property if provided', function () {
|
|
142
|
+
var object = b.objectExpression([
|
|
143
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
144
|
+
]);
|
|
145
|
+
(0, ast_utils_1.setOrUpdateObjectProperty)(object, 'needle', b.stringLiteral('haystack'), 'This is a comment');
|
|
146
|
+
var property = (0, ast_utils_1.getObjectProperty)(object, 'needle');
|
|
147
|
+
expect(property === null || property === void 0 ? void 0 : property.comments).toHaveLength(1);
|
|
148
|
+
// @ts-expect-error it must be defiend, otherwise we fail anyway
|
|
149
|
+
expect(property === null || property === void 0 ? void 0 : property.comments[0].value).toBe(' This is a comment');
|
|
150
|
+
});
|
|
151
|
+
it('adds a comment to the new property if provided', function () {
|
|
152
|
+
var object = b.objectExpression([
|
|
153
|
+
b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),
|
|
154
|
+
]);
|
|
155
|
+
(0, ast_utils_1.setOrUpdateObjectProperty)(object, 'needle', b.stringLiteral('haystack'), 'This is a comment');
|
|
156
|
+
var property = (0, ast_utils_1.getObjectProperty)(object, 'needle');
|
|
157
|
+
expect(property === null || property === void 0 ? void 0 : property.comments).toHaveLength(1);
|
|
158
|
+
// @ts-expect-error it must be defiend, otherwise we fail anyway
|
|
159
|
+
expect(property === null || property === void 0 ? void 0 : property.comments[0].value).toBe(' This is a comment');
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
describe('parse and print JSON-C', function () {
|
|
163
|
+
it.each([
|
|
164
|
+
['simple JSON', "{'foo': 'bar'}"],
|
|
165
|
+
[
|
|
166
|
+
'JSON-C with inline comment',
|
|
167
|
+
"\n {\n \"foo\": \"bar\" // with an inline comment\n }\n ",
|
|
168
|
+
],
|
|
169
|
+
[
|
|
170
|
+
'JSON-C with multiple comments',
|
|
171
|
+
"\n /*\n * let's throw in a block comment for good measure\n */ \n {\n // one line comment\n \"foo\": \"bar\", // another inline comment\n /* one more here */\n \"dogs\": /* and here */ \"awesome\",\n }\n /* and here */\n ",
|
|
172
|
+
],
|
|
173
|
+
])("parses and prints JSON-C (%s)", function (_, json) {
|
|
174
|
+
var _a = (0, ast_utils_1.parseJsonC)(json), ast = _a.ast, jsonObject = _a.jsonObject;
|
|
175
|
+
expect(ast === null || ast === void 0 ? void 0 : ast.type).toBe('Program');
|
|
176
|
+
expect(jsonObject).toBeDefined();
|
|
177
|
+
expect(jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.type).toBe('ObjectExpression');
|
|
178
|
+
// @ts-expect-error we know it's defined due to the expect above
|
|
179
|
+
expect((0, ast_utils_1.printJsonC)(ast)).toEqual(json);
|
|
180
|
+
});
|
|
181
|
+
it('returns undefined if the input is not valid JSON-C', function () {
|
|
182
|
+
var _a = (0, ast_utils_1.parseJsonC)("{\n \"invalid\": // \"json\"\n }"), ast = _a.ast, jsonObject = _a.jsonObject;
|
|
183
|
+
expect(ast).toBeUndefined();
|
|
184
|
+
expect(jsonObject).toBeUndefined();
|
|
54
185
|
});
|
|
55
186
|
});
|
|
56
187
|
//# sourceMappingURL=ast-utils.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.test.js","sourceRoot":"","sources":["../../../test/utils/ast-utils.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA6D;AAE7D,6CAAiC;AAEjC,QAAQ,CAAC,WAAW,EAAE;IACpB,QAAQ,CAAC,kBAAkB,EAAE;QAC3B,EAAE,CAAC,IAAI,CAAC;YACN,0HAGD;YACC,6MAOC;SACF,CAAC,CACA,2EAA2E,EAC3E,UAAC,IAAI;YACH,6EAA6E;YAC7E,sEAAsE;YACtE,IAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;iBAC/B,OAA0C,CAAC;YAC9C,MAAM,CAAC,IAAA,4BAAgB,EAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC,CACF,CAAC;QAEF,EAAE,CAAC,IAAI,CAAC;YACN,uCAAuC;YACvC,oEAAoE;YACpE,iEAAiE;YACjE,8GAKC;YACD,0KAKC;YACD,mJAIC;SACF,CAAC,CACA,yEAAyE,EACzE,UAAC,IAAI;YACH,6EAA6E;YAC7E,sEAAsE;YACtE,IAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;iBAC/B,OAA0C,CAAC;YAC9C,MAAM,CAAC,IAAA,4BAAgB,EAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { hasSentryContent } from '../../src/utils/ast-utils';\n\nimport * as recast from 'recast';\n\ndescribe('AST utils', () => {\n describe('hasSentryContent', () => {\n it.each([\n `\n const { sentryVitePlugin } = require(\"@sentry/vite-plugin\");\n const somethingelse = require('gs');\n `,\n `\n import { sentryVitePlugin } from \"@sentry/vite-plugin\";\n import * as somethingelse from 'gs';\n\n export default {\n plugins: [sentryVitePlugin()]\n }\n `,\n ])(\n \"returns true if a require('@sentry/') call was found in the parsed module\",\n (code) => {\n // recast.parse returns a Program node (or fails) but it's badly typed as any\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const program = recast.parse(code)\n .program as recast.types.namedTypes.Program;\n expect(hasSentryContent(program)).toBe(true);\n },\n );\n\n it.each([\n `const whatever = require('something')`,\n `// const {sentryWebpackPlugin} = require('@sentry/webpack-plugin')`,\n `const {sAntryWebpackPlugin} = require('webpack-plugin-@sentry')`,\n `\n import * as somethingelse from 'gs';\n export default {\n plugins: []\n }\n `,\n `import * as somethingelse from 'gs';\n // import { sentryVitePlugin } from \"@sentry/vite-plugin\"\n export default {\n plugins: []\n }\n `,\n `import * as thirdPartyVitePlugin from \"vite-plugin-@sentry\"\n export default {\n plugins: [thirdPartyVitePlugin()]\n }\n `,\n ])(\n \"returns false if the file doesn't contain any require('@sentry/') calls\",\n (code) => {\n // recast.parse returns a Program node (or fails) but it's badly typed as any\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const program = recast.parse(code)\n .program as recast.types.namedTypes.Program;\n expect(hasSentryContent(program)).toBe(false);\n },\n );\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"ast-utils.test.js","sourceRoot":"","sources":["../../../test/utils/ast-utils.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAOmC;AAEnC,6CAAiC;AACjC,IAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC,QAAQ,CAAC,kBAAkB,EAAE;IAC3B,EAAE,CAAC,IAAI,CAAC;QACN,0HAGC;QACD,6MAOG;KACJ,CAAC,CACA,2EAA2E,EAC3E,UAAC,IAAI;QACH,6EAA6E;QAC7E,sEAAsE;QACtE,IAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;aAC/B,OAA0C,CAAC;QAC9C,MAAM,CAAC,IAAA,4BAAgB,EAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC,CACF,CAAC;IAEF,EAAE,CAAC,IAAI,CAAC;QACN,uCAAuC;QACvC,oEAAoE;QACpE,iEAAiE;QACjE,8GAKG;QACH,0KAKG;QACH,mJAIG;KACJ,CAAC,CACA,yEAAyE,EACzE,UAAC,IAAI;QACH,6EAA6E;QAC7E,sEAAsE;QACtE,IAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;aAC/B,OAA0C,CAAC;QAC9C,MAAM,CAAC,IAAA,4BAAgB,EAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC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AwB,EAAE;IACjC,EAAE,CAAC,IAAI,CAAC;QACN,CAAC,aAAa,EAAE,gBAAgB,CAAC;QACjC;YACE,4BAA4B;YAC5B,wEAID;SACA;QACD;YACE,+BAA+B;YAC/B,2QAWD;SACA;KACF,CAAC,CAAC,+BAA+B,EAAE,UAAC,CAAC,EAAE,IAAI;QACpC,IAAA,KAAsB,IAAA,sBAAU,EAAC,IAAI,CAAC,EAApC,GAAG,SAAA,EAAE,UAAU,gBAAqB,CAAC;QAC7C,MAAM,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAClC,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;QACjC,MAAM,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClD,gEAAgE;QAChE,MAAM,CAAC,IAAA,sBAAU,EAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE;QACjD,IAAA,KAAsB,IAAA,sBAAU,EAAC,0CAErC,CAAC,EAFK,GAAG,SAAA,EAAE,UAAU,gBAEpB,CAAC;QACJ,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,CAAC;QAC5B,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n getObjectProperty,\n getOrSetObjectProperty,\n hasSentryContent,\n parseJsonC,\n printJsonC,\n setOrUpdateObjectProperty,\n} from '../../src/utils/ast-utils';\n\nimport * as recast from 'recast';\nconst b = recast.types.builders;\n\ndescribe('hasSentryContent', () => {\n it.each([\n `\n const { sentryVitePlugin } = require(\"@sentry/vite-plugin\");\n const somethingelse = require('gs');\n `,\n `\n import { sentryVitePlugin } from \"@sentry/vite-plugin\";\n import * as somethingelse from 'gs';\n\n export default {\n plugins: [sentryVitePlugin()]\n }\n `,\n ])(\n \"returns true if a require('@sentry/') call was found in the parsed module\",\n (code) => {\n // recast.parse returns a Program node (or fails) but it's badly typed as any\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const program = recast.parse(code)\n .program as recast.types.namedTypes.Program;\n expect(hasSentryContent(program)).toBe(true);\n },\n );\n\n it.each([\n `const whatever = require('something')`,\n `// const {sentryWebpackPlugin} = require('@sentry/webpack-plugin')`,\n `const {sAntryWebpackPlugin} = require('webpack-plugin-@sentry')`,\n `\n import * as somethingelse from 'gs';\n export default {\n plugins: []\n }\n `,\n `import * as somethingelse from 'gs';\n // import { sentryVitePlugin } from \"@sentry/vite-plugin\"\n export default {\n plugins: []\n }\n `,\n `import * as thirdPartyVitePlugin from \"vite-plugin-@sentry\"\n export default {\n plugins: [thirdPartyVitePlugin()]\n }\n `,\n ])(\n \"returns false if the file doesn't contain any require('@sentry/') calls\",\n (code) => {\n // recast.parse returns a Program node (or fails) but it's badly typed as any\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const program = recast.parse(code)\n .program as recast.types.namedTypes.Program;\n expect(hasSentryContent(program)).toBe(false);\n },\n );\n});\n\ndescribe('getObjectProperty', () => {\n it.each([\n [\n 'literal',\n b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n b.objectProperty(\n b.stringLiteral('needle'),\n b.stringLiteral('haystack'),\n ),\n ]),\n ],\n [\n 'stringLiteral',\n b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n b.objectProperty(b.literal('needle'), b.stringLiteral('haystack')),\n ]),\n ],\n [\n 'identifier',\n b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n b.objectProperty(b.identifier('needle'), b.stringLiteral('haystack')),\n ]),\n ],\n ])('returns the poperty (%s) if it exists', (_, object) => {\n const property = getObjectProperty(object, 'needle');\n expect(property).toBeDefined();\n // @ts-expect-error we know it's defined due to the expect above\n expect(recast.print(property).code).toEqual(\n expect.stringContaining('needle'),\n );\n });\n\n it('returns undefined if the property does not exist', () => {\n const object = b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n ]);\n const property = getObjectProperty(object, 'needle');\n expect(property).toBeUndefined();\n });\n\n it('handles objects without simple properties', () => {\n const object = b.objectExpression([b.spreadElement(b.identifier('foo'))]);\n const property = getObjectProperty(object, 'needle');\n expect(property).toBeUndefined();\n });\n});\n\ndescribe('getOrSetObjectProperty', () => {\n it('returns the property if it exists', () => {\n const object = b.objectExpression([\n b.objectProperty(b.identifier('needle'), b.stringLiteral('haystack')),\n ]);\n\n const property = getOrSetObjectProperty(\n object,\n 'needle',\n b.stringLiteral('nope'),\n );\n\n expect(property).toBeDefined();\n expect(property.type).toBe('ObjectProperty');\n // @ts-expect-error we know its type\n expect(property.key.name).toBe('needle');\n // @ts-expect-error we know its type\n expect(property.value.value).toBe('haystack');\n });\n\n it('adds the property if it does not exist', () => {\n const object = b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n ]);\n\n const property = getOrSetObjectProperty(\n object,\n 'needle',\n b.stringLiteral('haystack'),\n );\n\n expect(property).toBeDefined();\n expect(property.type).toBe('Property');\n // @ts-expect-error we know its type\n expect(property.key.value).toBe('needle');\n // @ts-expect-error we know its type\n expect(property.value.value).toBe('haystack');\n });\n});\n\ndescribe('setOrUpdateObjectProperty', () => {\n it('sets a new property if it does not exist yet', () => {\n const object = b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n ]);\n\n setOrUpdateObjectProperty(object, 'needle', b.stringLiteral('haystack'));\n\n expect(getObjectProperty(object, 'needle')).toBeDefined();\n });\n\n it('updates an existing property if it exists', () => {\n const object = b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n b.objectProperty(b.identifier('needle'), b.stringLiteral('haystack')),\n ]);\n\n setOrUpdateObjectProperty(object, 'needle', b.stringLiteral('haystack2'));\n\n const property = getObjectProperty(object, 'needle');\n // @ts-expect-error it must be defiend, otherwise we fail anyway\n expect(property?.value.value).toBe('haystack2');\n });\n\n it('adds a comment to the existing property if provided', () => {\n const object = b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n ]);\n\n setOrUpdateObjectProperty(\n object,\n 'needle',\n b.stringLiteral('haystack'),\n 'This is a comment',\n );\n\n const property = getObjectProperty(object, 'needle');\n expect(property?.comments).toHaveLength(1);\n // @ts-expect-error it must be defiend, otherwise we fail anyway\n expect(property?.comments[0].value).toBe(' This is a comment');\n });\n\n it('adds a comment to the new property if provided', () => {\n const object = b.objectExpression([\n b.objectProperty(b.identifier('foo'), b.stringLiteral('bar')),\n ]);\n\n setOrUpdateObjectProperty(\n object,\n 'needle',\n b.stringLiteral('haystack'),\n 'This is a comment',\n );\n\n const property = getObjectProperty(object, 'needle');\n expect(property?.comments).toHaveLength(1);\n // @ts-expect-error it must be defiend, otherwise we fail anyway\n expect(property?.comments[0].value).toBe(' This is a comment');\n });\n});\n\ndescribe('parse and print JSON-C', () => {\n it.each([\n ['simple JSON', \"{'foo': 'bar'}\"],\n [\n 'JSON-C with inline comment',\n `\n {\n \"foo\": \"bar\" // with an inline comment\n }\n `,\n ],\n [\n 'JSON-C with multiple comments',\n `\n /*\n * let's throw in a block comment for good measure\n */ \n {\n // one line comment\n \"foo\": \"bar\", // another inline comment\n /* one more here */\n \"dogs\": /* and here */ \"awesome\",\n }\n /* and here */\n `,\n ],\n ])(`parses and prints JSON-C (%s)`, (_, json) => {\n const { ast, jsonObject } = parseJsonC(json);\n expect(ast?.type).toBe('Program');\n expect(jsonObject).toBeDefined();\n expect(jsonObject?.type).toBe('ObjectExpression');\n // @ts-expect-error we know it's defined due to the expect above\n expect(printJsonC(ast)).toEqual(json);\n });\n\n it('returns undefined if the input is not valid JSON-C', () => {\n const { ast, jsonObject } = parseJsonC(`{\n \"invalid\": // \"json\"\n }`);\n expect(ast).toBeUndefined();\n expect(jsonObject).toBeUndefined();\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/wizard",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
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",
|
|
@@ -79,10 +79,8 @@ async function runAndroidWizardWithTelemetry(
|
|
|
79
79
|
gradle.selectAppFile(buildGradleFiles),
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
-
const { selectedProject, authToken } =
|
|
83
|
-
options,
|
|
84
|
-
'android',
|
|
85
|
-
);
|
|
82
|
+
const { selectedProject, selfHosted, sentryUrl, authToken } =
|
|
83
|
+
await getOrAskForProjectData(options, 'android');
|
|
86
84
|
|
|
87
85
|
// ======== STEP 1. Add Sentry Gradle Plugin to build.gradle(.kts) ============
|
|
88
86
|
clack.log.step(
|
|
@@ -172,11 +170,16 @@ async function runAndroidWizardWithTelemetry(
|
|
|
172
170
|
);
|
|
173
171
|
|
|
174
172
|
// ======== OUTRO ========
|
|
173
|
+
const issuesPageLink = selfHosted
|
|
174
|
+
? `${sentryUrl}organizations/${selectedProject.organization.slug}/issues/?project=${selectedProject.id}`
|
|
175
|
+
: `https://${selectedProject.organization.slug}.sentry.io/issues/?project=${selectedProject.id}`;
|
|
176
|
+
|
|
175
177
|
clack.outro(`
|
|
176
178
|
${chalk.greenBright('Successfully installed the Sentry Android SDK!')}
|
|
177
179
|
|
|
178
180
|
${chalk.cyan(
|
|
179
|
-
|
|
181
|
+
`You can validate your setup by launching your application and checking Sentry issues page afterwards
|
|
182
|
+
${issuesPageLink}`,
|
|
180
183
|
)}
|
|
181
184
|
|
|
182
185
|
Check out the SDK documentation for further configuration:
|
|
@@ -118,6 +118,8 @@ export async function runNextjsWizard(options: WizardOptions): Promise<void> {
|
|
|
118
118
|
const sentryWebpackOptionsTemplate = getNextjsWebpackPluginOptionsTemplate(
|
|
119
119
|
selectedProject.organization.slug,
|
|
120
120
|
selectedProject.slug,
|
|
121
|
+
selfHosted,
|
|
122
|
+
sentryUrl,
|
|
121
123
|
);
|
|
122
124
|
const sentryBuildOptionsTemplate = getNextjsSentryBuildOptionsTemplate();
|
|
123
125
|
|
|
@@ -323,6 +325,13 @@ export async function runNextjsWizard(options: WizardOptions): Promise<void> {
|
|
|
323
325
|
useClient: true,
|
|
324
326
|
});
|
|
325
327
|
|
|
328
|
+
fs.mkdirSync(
|
|
329
|
+
path.join(process.cwd(), ...appLocation, 'sentry-example-page'),
|
|
330
|
+
{
|
|
331
|
+
recursive: true,
|
|
332
|
+
},
|
|
333
|
+
);
|
|
334
|
+
|
|
326
335
|
await fs.promises.writeFile(
|
|
327
336
|
path.join(
|
|
328
337
|
process.cwd(),
|
|
@@ -340,9 +349,12 @@ export async function runNextjsWizard(options: WizardOptions): Promise<void> {
|
|
|
340
349
|
)}.`,
|
|
341
350
|
);
|
|
342
351
|
|
|
343
|
-
fs.mkdirSync(
|
|
344
|
-
|
|
345
|
-
|
|
352
|
+
fs.mkdirSync(
|
|
353
|
+
path.join(process.cwd(), ...appLocation, 'api', 'sentry-example-api'),
|
|
354
|
+
{
|
|
355
|
+
recursive: true,
|
|
356
|
+
},
|
|
357
|
+
);
|
|
346
358
|
|
|
347
359
|
await fs.promises.writeFile(
|
|
348
360
|
path.join(
|
package/src/nextjs/templates.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export function getNextjsWebpackPluginOptionsTemplate(
|
|
2
2
|
orgSlug: string,
|
|
3
3
|
projectSlug: string,
|
|
4
|
+
selfHosted: boolean,
|
|
5
|
+
url: string,
|
|
4
6
|
): string {
|
|
5
7
|
return `{
|
|
6
8
|
// For all available options, see:
|
|
@@ -8,9 +10,8 @@ export function getNextjsWebpackPluginOptionsTemplate(
|
|
|
8
10
|
|
|
9
11
|
// Suppresses source map uploading logs during build
|
|
10
12
|
silent: true,
|
|
11
|
-
|
|
12
13
|
org: "${orgSlug}",
|
|
13
|
-
project: "${projectSlug}"
|
|
14
|
+
project: "${projectSlug}",${selfHosted ? `\n url: "${url}"` : ''}
|
|
14
15
|
}`;
|
|
15
16
|
}
|
|
16
17
|
|