@sentry/wizard 3.8.0 → 3.9.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 +10 -0
- package/bin.ts +14 -0
- package/dist/bin.js +9 -0
- package/dist/bin.js.map +1 -1
- package/dist/lib/Helper/Logging.d.ts +1 -0
- package/dist/lib/Helper/Logging.js +2 -1
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Setup.js +4 -0
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/Integrations/ReactNative.js +3 -3
- package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
- package/dist/package.json +11 -7
- package/dist/src/sourcemaps/tools/sentry-cli.js +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +102 -12
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.d.ts +9 -1
- package/dist/src/sveltekit/sdk-setup.js +73 -29
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +9 -5
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/ast-utils.d.ts +8 -0
- package/dist/src/utils/ast-utils.js +45 -0
- package/dist/src/utils/ast-utils.js.map +1 -0
- package/dist/src/utils/debug.d.ts +2 -0
- package/dist/src/utils/debug.js +51 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/test/utils/ast-utils.test.d.ts +1 -0
- package/dist/test/utils/ast-utils.test.js +21 -0
- package/dist/test/utils/ast-utils.test.js.map +1 -0
- package/lib/Helper/Logging.ts +1 -1
- package/lib/Setup.ts +5 -0
- package/lib/Steps/Integrations/ReactNative.ts +7 -3
- package/package.json +11 -7
- package/src/sourcemaps/tools/sentry-cli.ts +1 -1
- package/src/sourcemaps/tools/vite.ts +101 -12
- package/src/sveltekit/sdk-setup.ts +122 -43
- package/src/sveltekit/sveltekit-wizard.ts +12 -6
- package/src/utils/ast-utils.ts +20 -0
- package/src/utils/debug.ts +20 -0
- package/test/utils/ast-utils.test.ts +44 -0
- package/dist/src/sveltekit/sentry-cli-setup.d.ts +0 -2
- package/dist/src/sveltekit/sentry-cli-setup.js +0 -71
- package/dist/src/sveltekit/sentry-cli-setup.js.map +0 -1
- package/package-lock.json +0 -8910
- package/src/sveltekit/sentry-cli-setup.ts +0 -27
|
@@ -4,6 +4,7 @@ import chalk from 'chalk';
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
abort,
|
|
7
|
+
addSentryCliRc,
|
|
7
8
|
askForProjectSelection,
|
|
8
9
|
askForSelfHosted,
|
|
9
10
|
askForWizardLogin,
|
|
@@ -18,8 +19,6 @@ import { WizardOptions } from '../utils/types';
|
|
|
18
19
|
import { createExamplePage } from './sdk-example';
|
|
19
20
|
import { createOrMergeSvelteKitFiles, loadSvelteConfig } from './sdk-setup';
|
|
20
21
|
|
|
21
|
-
import { setupCLIConfig } from './sentry-cli-setup';
|
|
22
|
-
|
|
23
22
|
export async function runSvelteKitWizard(
|
|
24
23
|
options: WizardOptions,
|
|
25
24
|
): Promise<void> {
|
|
@@ -48,14 +47,21 @@ export async function runSvelteKitWizard(
|
|
|
48
47
|
alreadyInstalled: hasPackageInstalled('@sentry/sveltekit', packageJson),
|
|
49
48
|
});
|
|
50
49
|
|
|
51
|
-
await
|
|
52
|
-
|
|
53
|
-
const dsn = selectedProject.keys[0].dsn.public;
|
|
50
|
+
await addSentryCliRc(apiKeys.token);
|
|
54
51
|
|
|
55
52
|
const svelteConfig = await loadSvelteConfig();
|
|
56
53
|
|
|
57
54
|
try {
|
|
58
|
-
await createOrMergeSvelteKitFiles(
|
|
55
|
+
await createOrMergeSvelteKitFiles(
|
|
56
|
+
{
|
|
57
|
+
dsn: selectedProject.keys[0].dsn.public,
|
|
58
|
+
org: selectedProject.organization.slug,
|
|
59
|
+
project: selectedProject.slug,
|
|
60
|
+
selfHosted,
|
|
61
|
+
url: sentryUrl,
|
|
62
|
+
},
|
|
63
|
+
svelteConfig,
|
|
64
|
+
);
|
|
59
65
|
} catch (e: unknown) {
|
|
60
66
|
clack.log.error('Error while setting up the SvelteKit SDK:');
|
|
61
67
|
clack.log.info(
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
3
|
+
import { ProxifiedModule } from 'magicast';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a JS/TS file where we don't know its concrete file type yet exists
|
|
7
|
+
* and returns the full path to the file with the correct file type.
|
|
8
|
+
*/
|
|
9
|
+
export function findScriptFile(hooksFile: string): string | undefined {
|
|
10
|
+
const possibleFileTypes = ['.js', '.ts', '.mjs'];
|
|
11
|
+
return possibleFileTypes
|
|
12
|
+
.map((type) => `${hooksFile}${type}`)
|
|
13
|
+
.find((file) => fs.existsSync(file));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Checks if a Sentry package is already mentioned in the file */
|
|
17
|
+
export function hasSentryContent(mod: ProxifiedModule<object>): boolean {
|
|
18
|
+
const imports = mod.imports.$items.map((i) => i.from);
|
|
19
|
+
return !!imports.find((i) => i.startsWith('@sentry/'));
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
|
+
import * as clack from '@clack/prompts';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { prepareMessage } from '../../lib/Helper/Logging';
|
|
5
|
+
|
|
6
|
+
let debugEnabled = false;
|
|
7
|
+
|
|
8
|
+
export function debug(...args: unknown[]) {
|
|
9
|
+
if (!debugEnabled) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const msg = args.map((a) => prepareMessage(a)).join(' ');
|
|
14
|
+
|
|
15
|
+
clack.log.info(chalk.dim(msg));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function enableDebugLogs() {
|
|
19
|
+
debugEnabled = true;
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//@ts-ignore
|
|
2
|
+
import { parseModule } from 'magicast';
|
|
3
|
+
import { hasSentryContent } from '../../src/utils/ast-utils';
|
|
4
|
+
|
|
5
|
+
describe('AST utils', () => {
|
|
6
|
+
describe('hasSentryContent', () => {
|
|
7
|
+
it("returns true if a '@sentry/' import was found in the parsed module", () => {
|
|
8
|
+
const code = `
|
|
9
|
+
import { sentryVitePlugin } from "@sentry/vite-plugin";
|
|
10
|
+
import * as somethingelse from 'gs';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
plugins: [sentryVitePlugin()]
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
expect(hasSentryContent(parseModule(code))).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it.each([
|
|
20
|
+
`
|
|
21
|
+
import * as somethingelse from 'gs';
|
|
22
|
+
export default {
|
|
23
|
+
plugins: []
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
`import * as somethingelse from 'gs';
|
|
27
|
+
// import { sentryVitePlugin } from "@sentry/vite-plugin"
|
|
28
|
+
export default {
|
|
29
|
+
plugins: []
|
|
30
|
+
}
|
|
31
|
+
`,
|
|
32
|
+
`import * as thirdPartyVitePlugin from "vite-plugin-@sentry"
|
|
33
|
+
export default {
|
|
34
|
+
plugins: [thirdPartyVitePlugin()]
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
])(
|
|
38
|
+
"reutrns false for modules without a valid '@sentry/' import",
|
|
39
|
+
(code) => {
|
|
40
|
+
expect(hasSentryContent(parseModule(code))).toBe(false);
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.setupCLIConfig = void 0;
|
|
40
|
-
var SentryCli_1 = require("../../lib/Helper/SentryCli");
|
|
41
|
-
function setupCLIConfig(authToken, selectedProject, sentryUrl) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var cli, answers, props;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
cli = new SentryCli_1.SentryCli({ url: sentryUrl });
|
|
48
|
-
answers = {
|
|
49
|
-
config: {
|
|
50
|
-
organization: {
|
|
51
|
-
slug: selectedProject.organization.slug,
|
|
52
|
-
},
|
|
53
|
-
project: {
|
|
54
|
-
slug: selectedProject.slug,
|
|
55
|
-
},
|
|
56
|
-
auth: {
|
|
57
|
-
token: authToken,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
props = cli.convertAnswersToProperties(answers);
|
|
62
|
-
return [4 /*yield*/, cli.createSentryCliConfig(props)];
|
|
63
|
-
case 1:
|
|
64
|
-
_a.sent();
|
|
65
|
-
return [2 /*return*/];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
exports.setupCLIConfig = setupCLIConfig;
|
|
71
|
-
//# sourceMappingURL=sentry-cli-setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sentry-cli-setup.js","sourceRoot":"","sources":["../../../src/sveltekit/sentry-cli-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wDAAuD;AAGvD,SAAsB,cAAc,CAClC,SAAiB,EACjB,eAAkC,EAClC,SAAiB;;;;;;oBAEX,GAAG,GAAG,IAAI,qBAAS,CAAC,EAAE,GAAG,EAAE,SAAS,EAAU,CAAC,CAAC;oBAEhD,OAAO,GAAG;wBACd,MAAM,EAAE;4BACN,YAAY,EAAE;gCACZ,IAAI,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;6BACxC;4BACD,OAAO,EAAE;gCACP,IAAI,EAAE,eAAe,CAAC,IAAI;6BAC3B;4BACD,IAAI,EAAE;gCACJ,KAAK,EAAE,SAAS;6BACjB;yBACF;qBACF,CAAC;oBACI,KAAK,GAAG,GAAG,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC;oBACtD,qBAAM,GAAG,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAA;;oBAAtC,SAAsC,CAAC;;;;;CACxC;AAtBD,wCAsBC","sourcesContent":["import { Args } from '../../lib/Constants';\nimport { SentryCli } from '../../lib/Helper/SentryCli';\nimport { SentryProjectData } from '../utils/types';\n\nexport async function setupCLIConfig(\n authToken: string,\n selectedProject: SentryProjectData,\n sentryUrl: string,\n): Promise<void> {\n const cli = new SentryCli({ url: sentryUrl } as Args);\n\n const answers = {\n config: {\n organization: {\n slug: selectedProject.organization.slug,\n },\n project: {\n slug: selectedProject.slug,\n },\n auth: {\n token: authToken,\n },\n },\n };\n const props = cli.convertAnswersToProperties(answers);\n await cli.createSentryCliConfig(props);\n}\n"]}
|