@sentry/wizard 3.12.0 → 3.14.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 +19 -0
- package/dist/lib/Steps/ChooseIntegration.js +1 -0
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/package.json +2 -2
- package/dist/src/android/android-wizard.js +8 -8
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +1 -1
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.d.ts +1 -0
- package/dist/src/nextjs/nextjs-wizard.js +257 -163
- 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/nextjs/utils.d.ts +1 -0
- package/dist/src/nextjs/utils.js +25 -0
- package/dist/src/nextjs/utils.js.map +1 -0
- package/dist/src/remix/remix-wizard.js +13 -11
- 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 +13 -6
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.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 +113 -42
- 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/telemetry.d.ts +1 -0
- package/dist/src/telemetry.js +27 -12
- package/dist/src/telemetry.js.map +1 -1
- 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 +49 -7
- package/dist/src/utils/clack-utils.js +238 -168
- 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 +23 -14
- 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 +2 -2
- package/src/android/android-wizard.ts +12 -10
- package/src/apple/apple-wizard.ts +2 -2
- package/src/nextjs/nextjs-wizard.ts +277 -198
- package/src/nextjs/templates.ts +3 -2
- package/src/nextjs/utils.ts +21 -0
- package/src/remix/remix-wizard.ts +15 -20
- package/src/remix/sdk-setup.ts +20 -5
- package/src/sourcemaps/sourcemaps-wizard.ts +2 -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 +86 -21
- package/src/sveltekit/utils.ts +50 -0
- package/src/telemetry.ts +22 -11
- package/src/utils/ast-utils.ts +180 -0
- package/src/utils/clack-utils.ts +238 -149
- package/src/utils/package-manager.ts +24 -12
- 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
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -22,10 +33,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
33
|
__setModuleDefault(result, mod);
|
|
23
34
|
return result;
|
|
24
35
|
};
|
|
36
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
+
if (ar || !(i in from)) {
|
|
39
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
+
ar[i] = from[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
+
};
|
|
25
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.hasSentryContent = exports.findFile = void 0;
|
|
46
|
+
exports.printJsonC = exports.parseJsonC = exports.setOrUpdateObjectProperty = exports.getOrSetObjectProperty = exports.getObjectProperty = exports.hasSentryContent = exports.findFile = void 0;
|
|
27
47
|
var fs = __importStar(require("fs"));
|
|
28
48
|
var recast = __importStar(require("recast"));
|
|
49
|
+
var b = recast.types.builders;
|
|
29
50
|
/**
|
|
30
51
|
* Checks if a file where we don't know its concrete file type yet exists
|
|
31
52
|
* and returns the full path to the file with the correct file type.
|
|
@@ -57,4 +78,134 @@ function hasSentryContent(program) {
|
|
|
57
78
|
return !!foundSentry;
|
|
58
79
|
}
|
|
59
80
|
exports.hasSentryContent = hasSentryContent;
|
|
81
|
+
/**
|
|
82
|
+
* Searches for a property of an ObjectExpression by name
|
|
83
|
+
*
|
|
84
|
+
* @param object the ObjectExpression to search in
|
|
85
|
+
* @param name the name of the property to search for
|
|
86
|
+
*
|
|
87
|
+
* @returns the property if it exists
|
|
88
|
+
*/
|
|
89
|
+
function getObjectProperty(object, name) {
|
|
90
|
+
return object.properties.find(function (p) {
|
|
91
|
+
var isObjectProp = p.type === 'Property' || p.type === 'ObjectProperty';
|
|
92
|
+
if (!isObjectProp) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
var hasMatchingLiteralKey = isObjectProp &&
|
|
96
|
+
(p.key.type === 'Literal' || p.key.type === 'StringLiteral') &&
|
|
97
|
+
p.key.value === name;
|
|
98
|
+
if (hasMatchingLiteralKey) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
// has matching identifier key
|
|
102
|
+
return isObjectProp && p.key.type === 'Identifier' && p.key.name === name;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
exports.getObjectProperty = getObjectProperty;
|
|
106
|
+
/**
|
|
107
|
+
* Attempts to find a property of an ObjectExpression by name. If it doesn't exist,
|
|
108
|
+
* the property will be added to the ObjectExpression with the provided default value.
|
|
109
|
+
*
|
|
110
|
+
* @param object the parent object expression to search in
|
|
111
|
+
* @param name the name of the property to search for
|
|
112
|
+
* @param defaultValue the default value to set if the property doesn't exist
|
|
113
|
+
*
|
|
114
|
+
* @returns the
|
|
115
|
+
*/
|
|
116
|
+
function getOrSetObjectProperty(object, name, defaultValue) {
|
|
117
|
+
var existingProperty = getObjectProperty(object, name);
|
|
118
|
+
if (existingProperty) {
|
|
119
|
+
return existingProperty;
|
|
120
|
+
}
|
|
121
|
+
var newProperty = b.property.from({
|
|
122
|
+
kind: 'init',
|
|
123
|
+
key: b.stringLiteral(name),
|
|
124
|
+
value: defaultValue,
|
|
125
|
+
});
|
|
126
|
+
object.properties.push(newProperty);
|
|
127
|
+
return newProperty;
|
|
128
|
+
}
|
|
129
|
+
exports.getOrSetObjectProperty = getOrSetObjectProperty;
|
|
130
|
+
/**
|
|
131
|
+
* Sets a property of an ObjectExpression if it exists, otherwise adds it
|
|
132
|
+
* to the ObjectExpression. Optionally, a comment can be added to the
|
|
133
|
+
* property.
|
|
134
|
+
*
|
|
135
|
+
* @param object the ObjectExpression to set the property on
|
|
136
|
+
* @param name the name of the property to set
|
|
137
|
+
* @param value the value of the property to set
|
|
138
|
+
* @param comment (optional) a comment to add to the property
|
|
139
|
+
*/
|
|
140
|
+
function setOrUpdateObjectProperty(object, name, value, comment) {
|
|
141
|
+
var newComments = comment &&
|
|
142
|
+
comment.split('\n').map(function (c) { return b.commentLine(" ".concat(c), true, false); });
|
|
143
|
+
var existingProperty = getObjectProperty(object, name);
|
|
144
|
+
if (existingProperty) {
|
|
145
|
+
existingProperty.value = value;
|
|
146
|
+
if (newComments) {
|
|
147
|
+
existingProperty.comments = __spreadArray(__spreadArray([], ((existingProperty === null || existingProperty === void 0 ? void 0 : existingProperty.comments) || []), true), newComments, true);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
object.properties.push(b.objectProperty.from(__assign({ key: b.stringLiteral(name), value: value }, (newComments && {
|
|
152
|
+
comments: newComments,
|
|
153
|
+
}))));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.setOrUpdateObjectProperty = setOrUpdateObjectProperty;
|
|
157
|
+
/**
|
|
158
|
+
* Parses a JSON string with (potential) comments (JSON-C) and returns the JS AST
|
|
159
|
+
* that can be walked and modified with recast like a normal JS AST.
|
|
160
|
+
*
|
|
161
|
+
* This is done by wrapping the JSON-C string in parentheses, thereby making it
|
|
162
|
+
* a JS `Program` with an `ExpressionStatement` as its body. The expression is then
|
|
163
|
+
* extracted from the AST and returned alongside the AST.
|
|
164
|
+
*
|
|
165
|
+
* To preserve as much original formatting as possible, the returned `ast`
|
|
166
|
+
* property should be passed to {@link `printJsonC`} to get the JSON-C string back.
|
|
167
|
+
*
|
|
168
|
+
* If the input is not valid JSON-C, the result will be undefined.
|
|
169
|
+
*
|
|
170
|
+
* @see {@link JsonCParseResult}
|
|
171
|
+
*
|
|
172
|
+
* @param jsonString a JSON-C string
|
|
173
|
+
*
|
|
174
|
+
* @returns a {@link JsonCParseResult}, containing either the JSON-C object and the AST or undefined in both cases
|
|
175
|
+
*/
|
|
176
|
+
function parseJsonC(jsonString) {
|
|
177
|
+
try {
|
|
178
|
+
var jsTsConfig = "(".concat(jsonString, ")");
|
|
179
|
+
// no idea why recast returns any here, this is dumb :/
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
181
|
+
var ast = recast.parse(jsTsConfig.toString()).program;
|
|
182
|
+
var jsonObject = (ast.body[0].type === 'ExpressionStatement' &&
|
|
183
|
+
ast.body[0].expression.type === 'ObjectExpression' &&
|
|
184
|
+
ast.body[0].expression) ||
|
|
185
|
+
undefined;
|
|
186
|
+
if (jsonObject) {
|
|
187
|
+
return { jsonObject: jsonObject, ast: ast };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch (_a) {
|
|
191
|
+
/* empty */
|
|
192
|
+
}
|
|
193
|
+
return { jsonObject: undefined, ast: undefined };
|
|
194
|
+
}
|
|
195
|
+
exports.parseJsonC = parseJsonC;
|
|
196
|
+
/**
|
|
197
|
+
* Takes the AST of a parsed JSON-C "program" and returns the JSON-C string without
|
|
198
|
+
* any of the temporary JS wrapper code that was previously applied.
|
|
199
|
+
*
|
|
200
|
+
* Only use this in conjunction with {@link `parseJsonC`}
|
|
201
|
+
*
|
|
202
|
+
* @param ast the `ast` returned from {@link `parseJsonC`}
|
|
203
|
+
*
|
|
204
|
+
* @returns the JSON-C string
|
|
205
|
+
*/
|
|
206
|
+
function printJsonC(ast) {
|
|
207
|
+
var js = recast.print(ast).code;
|
|
208
|
+
return js.substring(1, js.length - 1);
|
|
209
|
+
}
|
|
210
|
+
exports.printJsonC = printJsonC;
|
|
60
211
|
//# sourceMappingURL=ast-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../../../src/utils/ast-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../../../src/utils/ast-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AAEzB,6CAAiC;AAIjC,IAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC;;;GAGG;AACH,SAAgB,QAAQ,CACtB,QAAgB,EAChB,SAAoD;IAApD,0BAAA,EAAA,aAAuB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;IAEpD,OAAO,SAAS;SACb,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,UAAG,QAAQ,SAAG,IAAI,CAAE,EAApB,CAAoB,CAAC;SACnC,IAAI,CAAC,UAAC,IAAI,IAAK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AAC,EAAE,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC;AAHD,gCAGC","sourcesContent":["import * as fs from 'fs';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\n/**\n * Checks if a file where we don't know its concrete file type yet exists\n * and returns the full path to the file with the correct file type.\n */\nexport function findFile(\n filePath: string,\n fileTypes: string[] = ['.js', '.ts', '.mjs', '.cjs'],\n): string | undefined {\n return fileTypes\n .map((type) => `${filePath}${type}`)\n .find((file) => fs.existsSync(file));\n}\n\n/**\n * checks for require('@sentry/*') syntax\n */\nexport function hasSentryContent(program: t.Program): boolean {\n let foundSentry: boolean | undefined = false;\n recast.visit(program, {\n visitStringLiteral(path) {\n foundSentry = foundSentry || path.node.value.startsWith('@sentry/');\n this.traverse(path);\n },\n visitLiteral(path) {\n foundSentry =\n foundSentry || path.node.value?.toString().startsWith('@sentry/');\n this.traverse(path);\n },\n });\n\n return !!foundSentry;\n}\n\n/**\n * Searches for a property of an ObjectExpression by name\n *\n * @param object the ObjectExpression to search in\n * @param name the name of the property to search for\n *\n * @returns the property if it exists\n */\nexport function getObjectProperty(\n object: t.ObjectExpression,\n name: string,\n): t.Property | undefined {\n return object.properties.find((p): p is t.Property => {\n const isObjectProp = p.type === 'Property' || p.type === 'ObjectProperty';\n\n if (!isObjectProp) {\n return false;\n }\n\n const hasMatchingLiteralKey =\n isObjectProp &&\n (p.key.type === 'Literal' || p.key.type === 'StringLiteral') &&\n p.key.value === name;\n\n if (hasMatchingLiteralKey) {\n return true;\n }\n\n // has matching identifier key\n return isObjectProp && p.key.type === 'Identifier' && p.key.name === name;\n });\n}\n\n/**\n * Attempts to find a property of an ObjectExpression by name. If it doesn't exist,\n * the property will be added to the ObjectExpression with the provided default value.\n *\n * @param object the parent object expression to search in\n * @param name the name of the property to search for\n * @param defaultValue the default value to set if the property doesn't exist\n *\n * @returns the\n */\nexport function getOrSetObjectProperty(\n object: t.ObjectExpression,\n name: string,\n defaultValue:\n | t.Literal\n | t.BooleanLiteral\n | t.StringLiteral\n | t.ObjectExpression,\n): t.Property {\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n return existingProperty;\n }\n\n const newProperty = b.property.from({\n kind: 'init',\n key: b.stringLiteral(name),\n value: defaultValue,\n });\n\n object.properties.push(newProperty);\n\n return newProperty;\n}\n\n/**\n * Sets a property of an ObjectExpression if it exists, otherwise adds it\n * to the ObjectExpression. Optionally, a comment can be added to the\n * property.\n *\n * @param object the ObjectExpression to set the property on\n * @param name the name of the property to set\n * @param value the value of the property to set\n * @param comment (optional) a comment to add to the property\n */\nexport function setOrUpdateObjectProperty(\n object: t.ObjectExpression,\n name: string,\n value: t.Literal | t.BooleanLiteral | t.StringLiteral | t.ObjectExpression,\n comment?: string,\n) {\n const newComments =\n comment &&\n comment.split('\\n').map((c) => b.commentLine(` ${c}`, true, false));\n\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n existingProperty.value = value;\n if (newComments) {\n existingProperty.comments = [\n ...(existingProperty?.comments || []),\n ...newComments,\n ];\n }\n } else {\n object.properties.push(\n b.objectProperty.from({\n key: b.stringLiteral(name),\n value,\n ...(newComments && {\n comments: newComments,\n }),\n }),\n );\n }\n}\n\ntype JsonCParseResult =\n | {\n jsonObject: t.ObjectExpression;\n ast: t.Program;\n }\n | {\n jsonObject: undefined;\n ast: undefined;\n };\n\n/**\n * Parses a JSON string with (potential) comments (JSON-C) and returns the JS AST\n * that can be walked and modified with recast like a normal JS AST.\n *\n * This is done by wrapping the JSON-C string in parentheses, thereby making it\n * a JS `Program` with an `ExpressionStatement` as its body. The expression is then\n * extracted from the AST and returned alongside the AST.\n *\n * To preserve as much original formatting as possible, the returned `ast`\n * property should be passed to {@link `printJsonC`} to get the JSON-C string back.\n *\n * If the input is not valid JSON-C, the result will be undefined.\n *\n * @see {@link JsonCParseResult}\n *\n * @param jsonString a JSON-C string\n *\n * @returns a {@link JsonCParseResult}, containing either the JSON-C object and the AST or undefined in both cases\n */\nexport function parseJsonC(jsonString: string): JsonCParseResult {\n try {\n const jsTsConfig = `(${jsonString})`;\n // no idea why recast returns any here, this is dumb :/\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const ast = recast.parse(jsTsConfig.toString()).program as t.Program;\n\n const jsonObject =\n (ast.body[0].type === 'ExpressionStatement' &&\n ast.body[0].expression.type === 'ObjectExpression' &&\n ast.body[0].expression) ||\n undefined;\n\n if (jsonObject) {\n return { jsonObject, ast };\n }\n } catch {\n /* empty */\n }\n return { jsonObject: undefined, ast: undefined };\n}\n\n/**\n * Takes the AST of a parsed JSON-C \"program\" and returns the JSON-C string without\n * any of the temporary JS wrapper code that was previously applied.\n *\n * Only use this in conjunction with {@link `parseJsonC`}\n *\n * @param ast the `ast` returned from {@link `parseJsonC`}\n *\n * @returns the JSON-C string\n */\nexport function printJsonC(ast: t.Program): string {\n const js = recast.print(ast).code;\n return js.substring(1, js.length - 1);\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export declare function printWelcome(options: {
|
|
|
20
20
|
message?: string;
|
|
21
21
|
telemetryEnabled?: boolean;
|
|
22
22
|
}): void;
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function confirmContinueIfNoOrDirtyGitRepo(): Promise<void>;
|
|
24
24
|
export declare function askToInstallSentryCLI(): Promise<boolean>;
|
|
25
25
|
export declare function askForItemSelection(items: string[], message: string): Promise<{
|
|
26
26
|
value: string;
|
|
@@ -31,8 +31,18 @@ export declare function installPackage({ packageName, alreadyInstalled, askBefor
|
|
|
31
31
|
alreadyInstalled: boolean;
|
|
32
32
|
askBeforeUpdating?: boolean;
|
|
33
33
|
}): Promise<void>;
|
|
34
|
-
export declare function addSentryCliConfig(authToken: string, setupConfig?: CliSetupConfig
|
|
34
|
+
export declare function addSentryCliConfig(authToken: string, setupConfig?: CliSetupConfig): Promise<void>;
|
|
35
35
|
export declare function addDotEnvSentryBuildPluginFile(authToken: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if @param packageId is listed as a dependency in @param packageJson.
|
|
38
|
+
* If not, it will ask users if they want to continue without the package.
|
|
39
|
+
*
|
|
40
|
+
* Use this function to check if e.g. a the framework of the SDK is installed
|
|
41
|
+
*
|
|
42
|
+
* @param packageJson the package.json object
|
|
43
|
+
* @param packageId the npm name of the package
|
|
44
|
+
* @param packageName a human readable name of the package
|
|
45
|
+
*/
|
|
36
46
|
export declare function ensurePackageIsInstalled(packageJson: PackageDotJson, packageId: string, packageName: string): Promise<void>;
|
|
37
47
|
export declare function getPackageDotJson(): Promise<PackageDotJson>;
|
|
38
48
|
export declare function isUsingTypeScript(): boolean;
|
|
@@ -78,15 +88,46 @@ export declare function askForToolConfigPath(toolName: string, configFileName: s
|
|
|
78
88
|
*
|
|
79
89
|
* @param filename the name of the file to which the code snippet should be applied.
|
|
80
90
|
* If a path is provided, only the filename will be used.
|
|
81
|
-
* @param codeSnippet the snippet to be printed.
|
|
82
|
-
* Make sure to follow the diff-like format of highlighting lines that require changes
|
|
83
|
-
* and showing unchanged lines in gray.
|
|
84
91
|
*
|
|
85
|
-
*
|
|
92
|
+
* @param codeSnippet the snippet to be printed. Use {@link makeCodeSnippet} to create the
|
|
93
|
+
* diff-like format for visually highlighting unchanged or modified lines of code.
|
|
94
|
+
*
|
|
95
|
+
* @param hint (optional) a hint to be printed after the main instruction to add
|
|
96
|
+
* the code from @param codeSnippet to their @param filename.
|
|
97
|
+
*
|
|
98
|
+
* More guidelines on copy/paste instructions:
|
|
99
|
+
* @see {@link https://develop.sentry.dev/sdk/setup-wizards/#copy--paste-snippets}
|
|
100
|
+
*
|
|
86
101
|
* TODO: refactor copy paste instructions across different wizards to use this function.
|
|
87
102
|
* this might require adding a custom message parameter to the function
|
|
88
103
|
*/
|
|
89
|
-
export declare function showCopyPasteInstructions(filename: string, codeSnippet: string): Promise<void>;
|
|
104
|
+
export declare function showCopyPasteInstructions(filename: string, codeSnippet: string, hint?: string): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Callback that exposes formatting helpers for a code snippet.
|
|
107
|
+
* @param unchanged - Formats text as old code.
|
|
108
|
+
* @param plus - Formats text as new code.
|
|
109
|
+
* @param minus - Formats text as removed code.
|
|
110
|
+
*/
|
|
111
|
+
type CodeSnippetFormatter = (unchanged: (txt: string) => string, plus: (txt: string) => string, minus: (txt: string) => string) => string;
|
|
112
|
+
/**
|
|
113
|
+
* Crafts a code snippet that can be used to e.g.
|
|
114
|
+
* - print copy/paste instructions to the console
|
|
115
|
+
* - create a new config file.
|
|
116
|
+
*
|
|
117
|
+
* @param colors set this to true if you want the final snippet to be colored.
|
|
118
|
+
* This is useful for printing the snippet to the console as part of copy/paste instructions.
|
|
119
|
+
*
|
|
120
|
+
* @param callback the callback that returns the formatted code snippet.
|
|
121
|
+
* It exposes takes the helper functions for marking code as unchaned, new or removed.
|
|
122
|
+
* These functions no-op if no special formatting should be applied
|
|
123
|
+
* and otherwise apply the appropriate formatting/coloring.
|
|
124
|
+
* (@see {@link CodeSnippetFormatter})
|
|
125
|
+
*
|
|
126
|
+
* @see {@link showCopyPasteInstructions} for the helper with which to display the snippet in the console.
|
|
127
|
+
*
|
|
128
|
+
* @returns a string containing the final, formatted code snippet.
|
|
129
|
+
*/
|
|
130
|
+
export declare function makeCodeSnippet(colors: boolean, callback: CodeSnippetFormatter): string;
|
|
90
131
|
/**
|
|
91
132
|
* Creates a new config file with the given @param filepath and @param codeSnippet.
|
|
92
133
|
*
|
|
@@ -105,3 +146,4 @@ export declare function showCopyPasteInstructions(filename: string, codeSnippet:
|
|
|
105
146
|
* @returns true on sucess, false otherwise
|
|
106
147
|
*/
|
|
107
148
|
export declare function createNewConfigFile(filepath: string, codeSnippet: string, moreInformation?: string): Promise<boolean>;
|
|
149
|
+
export {};
|