smipper 22.0.0 → 23.0.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/package.json +2 -2
- package/smipper +0 -401
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smipper",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"smipper": "./index.js"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
|
-
"
|
|
9
|
+
"index.js"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "node ./node_modules/.bin/tsc index.ts && chmod +x ./index.js",
|
package/smipper
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
-
function step(op) {
|
|
17
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
-
while (_) try {
|
|
19
|
-
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;
|
|
20
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
-
switch (op[0]) {
|
|
22
|
-
case 0: case 1: t = op; break;
|
|
23
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
-
default:
|
|
27
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
-
if (t[2]) _.ops.pop();
|
|
32
|
-
_.trys.pop(); continue;
|
|
33
|
-
}
|
|
34
|
-
op = body.call(thisArg, _);
|
|
35
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.__esModule = true;
|
|
40
|
-
var fs = require("fs");
|
|
41
|
-
var got = require("got");
|
|
42
|
-
var path = require("path");
|
|
43
|
-
var sourceMap = require("source-map");
|
|
44
|
-
var url = require("url");
|
|
45
|
-
var verbose = false;
|
|
46
|
-
var stack;
|
|
47
|
-
var json = false;
|
|
48
|
-
var retries = 3;
|
|
49
|
-
var jsc = 0;
|
|
50
|
-
for (var i = 2; i < process.argv.length; ++i) {
|
|
51
|
-
try {
|
|
52
|
-
var arg = process.argv[i] || "";
|
|
53
|
-
if (verbose) {
|
|
54
|
-
console.error("got arg", arg);
|
|
55
|
-
}
|
|
56
|
-
if (arg === "-f" || arg === "--file") {
|
|
57
|
-
stack = fs.readFileSync(process.argv[++i]).toString();
|
|
58
|
-
}
|
|
59
|
-
else if (arg.startsWith("-f")) {
|
|
60
|
-
stack = fs.readFileSync(arg.substring(2)).toString();
|
|
61
|
-
}
|
|
62
|
-
else if (arg.startsWith("--file=")) {
|
|
63
|
-
stack = fs.readFileSync(arg.substring(7)).toString();
|
|
64
|
-
}
|
|
65
|
-
else if (arg === "--verbose" || arg === "-v") {
|
|
66
|
-
verbose = true;
|
|
67
|
-
}
|
|
68
|
-
else if (arg === "--version") {
|
|
69
|
-
console.log(JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8")).version);
|
|
70
|
-
process.exit(0);
|
|
71
|
-
}
|
|
72
|
-
else if (arg === "--json") {
|
|
73
|
-
json = true;
|
|
74
|
-
}
|
|
75
|
-
else if (arg === "--jsc") {
|
|
76
|
-
// jsc has the wrong column for some reason
|
|
77
|
-
jsc = 1;
|
|
78
|
-
}
|
|
79
|
-
else if (arg.startsWith("--retries")) {
|
|
80
|
-
retries = parseInt(arg.substring(9));
|
|
81
|
-
if (isNaN(retries) || retries < 0) {
|
|
82
|
-
console.error("smipper [stack|-h|--help|-v|--verbose|--version|--retries=<number>|--jsc|--json|-f=@FILE@|-");
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else if (arg === "-h" || arg === "--help") {
|
|
87
|
-
console.error("smipper [stack|-h|--help|-v|--verbose|--version|--retries=<number>|--jsc|--json|-f=@FILE@|-");
|
|
88
|
-
process.exit(0);
|
|
89
|
-
}
|
|
90
|
-
else if (arg === "-") {
|
|
91
|
-
// stdin
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
stack = arg;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
console.error("Error: " + err.toString());
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (!stack) {
|
|
103
|
-
stack = fs.readFileSync("/dev/stdin").toString();
|
|
104
|
-
if (!stack) {
|
|
105
|
-
console.error("Nothing to do");
|
|
106
|
-
process.exit(0);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function build(functionName, url, line, column) {
|
|
110
|
-
return "".concat(functionName ? "at " + functionName + " " : "").concat(url, ":").concat(line, ":").concat(column);
|
|
111
|
-
}
|
|
112
|
-
function findFile(dir, fn) {
|
|
113
|
-
var list = fs.readdirSync(dir);
|
|
114
|
-
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
|
|
115
|
-
var file = list_1[_i];
|
|
116
|
-
var match = file === fn;
|
|
117
|
-
file = dir + "/" + file;
|
|
118
|
-
var stat = fs.statSync(file);
|
|
119
|
-
if (stat && stat.isDirectory()) {
|
|
120
|
-
var ret = findFile(file, fn);
|
|
121
|
-
if (ret) {
|
|
122
|
-
return ret;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else if (match) {
|
|
126
|
-
return "file://" + file;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
function rewriteLocalControl(url) {
|
|
132
|
-
var found = findFile(process.cwd(), path.basename(url.substring(6)));
|
|
133
|
-
if (found) {
|
|
134
|
-
return found;
|
|
135
|
-
}
|
|
136
|
-
throw new Error("Couldn't resolve localcontrol " + url);
|
|
137
|
-
}
|
|
138
|
-
function load(path) {
|
|
139
|
-
return new Promise(function (resolve, reject) {
|
|
140
|
-
if (path.startsWith("http://localcontrol.netflix.com/")) {
|
|
141
|
-
try {
|
|
142
|
-
path = rewriteLocalControl(path);
|
|
143
|
-
}
|
|
144
|
-
catch (err) {
|
|
145
|
-
reject(err);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (path.startsWith("file:///")) {
|
|
150
|
-
try {
|
|
151
|
-
resolve(fs.readFileSync(path.substring(7), "utf8"));
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
reject(err);
|
|
155
|
-
}
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (!path.startsWith("http://") && !path.startsWith("https://")) {
|
|
159
|
-
reject(new Error("Not a url"));
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
// let retryIndex = 0;
|
|
163
|
-
function get() {
|
|
164
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
-
var response;
|
|
166
|
-
return __generator(this, function (_a) {
|
|
167
|
-
switch (_a.label) {
|
|
168
|
-
case 0: return [4 /*yield*/, got.get(path, { timeout: 10000 })];
|
|
169
|
-
case 1:
|
|
170
|
-
response = _a.sent();
|
|
171
|
-
console.log(response.headers);
|
|
172
|
-
return [2 /*return*/, response.body || ""];
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
get().then(resolve, reject);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
var sourceMaps = {};
|
|
181
|
-
function loadUri(path) {
|
|
182
|
-
var _this = this;
|
|
183
|
-
if (path[0] === "/") {
|
|
184
|
-
path = "file://" + path;
|
|
185
|
-
}
|
|
186
|
-
return new Promise(function (resolve, reject) {
|
|
187
|
-
if (verbose) {
|
|
188
|
-
console.log("loading", path);
|
|
189
|
-
}
|
|
190
|
-
if (!(path in sourceMaps)) {
|
|
191
|
-
sourceMaps[path] = {
|
|
192
|
-
resolvers: [resolve],
|
|
193
|
-
rejecters: [reject]
|
|
194
|
-
};
|
|
195
|
-
load(path)
|
|
196
|
-
.then(function (jsData) {
|
|
197
|
-
var idx = jsData.lastIndexOf("//# sourceMappingURL=");
|
|
198
|
-
if (verbose) {
|
|
199
|
-
console.error("Got the file", jsData.length, idx);
|
|
200
|
-
}
|
|
201
|
-
if (idx == -1) {
|
|
202
|
-
return path + ".map";
|
|
203
|
-
}
|
|
204
|
-
var mapUrl = jsData.substring(idx + 21);
|
|
205
|
-
var match = /^(data:.+\/.+;)base64,/.exec(mapUrl);
|
|
206
|
-
if (match) {
|
|
207
|
-
return mapUrl.substring(match[1].length);
|
|
208
|
-
}
|
|
209
|
-
if (mapUrl.indexOf("://") != -1) {
|
|
210
|
-
return mapUrl;
|
|
211
|
-
}
|
|
212
|
-
// console.log(mapUrl);
|
|
213
|
-
return new url.URL(mapUrl, path).href;
|
|
214
|
-
})
|
|
215
|
-
.then(function (mapUrl) {
|
|
216
|
-
// console.log(mapUrl.substring(0, 20));
|
|
217
|
-
if (mapUrl.startsWith("base64,")) {
|
|
218
|
-
return Buffer.from(mapUrl.substring(7), "base64").toString();
|
|
219
|
-
}
|
|
220
|
-
return load(mapUrl);
|
|
221
|
-
})
|
|
222
|
-
.then(function (sourceMapData) { return __awaiter(_this, void 0, void 0, function () {
|
|
223
|
-
var parsed, smap, pending;
|
|
224
|
-
return __generator(this, function (_a) {
|
|
225
|
-
switch (_a.label) {
|
|
226
|
-
case 0:
|
|
227
|
-
parsed = JSON.parse(sourceMapData);
|
|
228
|
-
return [4 /*yield*/, new sourceMap.SourceMapConsumer(parsed)];
|
|
229
|
-
case 1:
|
|
230
|
-
smap = _a.sent();
|
|
231
|
-
pending = sourceMaps[path];
|
|
232
|
-
// sourceMaps.delete(path);
|
|
233
|
-
if (pending) {
|
|
234
|
-
pending.resolvers.forEach(function (func) {
|
|
235
|
-
func(smap);
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
return [2 /*return*/];
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}); })["catch"](function (err) {
|
|
242
|
-
var pending = sourceMaps[path];
|
|
243
|
-
if (!pending) {
|
|
244
|
-
throw new Error("Gotta have pending");
|
|
245
|
-
}
|
|
246
|
-
// sourceMaps.delete(path);
|
|
247
|
-
pending.rejecters.forEach(function (func) {
|
|
248
|
-
func(err);
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
var cur = sourceMaps[path];
|
|
254
|
-
if (verbose) {
|
|
255
|
-
console.error("path is in source maps already", cur);
|
|
256
|
-
}
|
|
257
|
-
if (!cur) {
|
|
258
|
-
throw new Error("Gotta have cur");
|
|
259
|
-
}
|
|
260
|
-
cur.resolvers.push(resolve);
|
|
261
|
-
cur.rejecters.push(reject);
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
function processFrame(functionName, url, line, column) {
|
|
266
|
-
if (verbose) {
|
|
267
|
-
console.log("got frame", functionName, url, line, column);
|
|
268
|
-
}
|
|
269
|
-
if (functionName.endsWith("@")) {
|
|
270
|
-
functionName = functionName.substring(0, functionName.length - 1);
|
|
271
|
-
}
|
|
272
|
-
return new Promise(function (resolve) {
|
|
273
|
-
var newUrl, newLine, newColumn;
|
|
274
|
-
if (verbose) {
|
|
275
|
-
console.error("calling loadUri", url);
|
|
276
|
-
}
|
|
277
|
-
if (!url.includes("://") && url[0] !== "/" && fs.existsSync(url)) {
|
|
278
|
-
url = "file://".concat(process.cwd(), "/").concat(url);
|
|
279
|
-
}
|
|
280
|
-
return loadUri(url)
|
|
281
|
-
.then(function (smap) {
|
|
282
|
-
if (verbose) {
|
|
283
|
-
console.error("got map", url, Object.keys(smap));
|
|
284
|
-
}
|
|
285
|
-
// it appears that we're supposed to reduce the column
|
|
286
|
-
// number by 1 when we get this from jsc
|
|
287
|
-
var pos = smap.originalPositionFor({ line: line, column: column - jsc });
|
|
288
|
-
if (!pos.source) {
|
|
289
|
-
if (verbose) {
|
|
290
|
-
console.error("nothing here", pos);
|
|
291
|
-
}
|
|
292
|
-
throw new Error("Mapping not found");
|
|
293
|
-
}
|
|
294
|
-
// smc.sourceContentFor(pos.source);
|
|
295
|
-
newUrl = pos.source;
|
|
296
|
-
newLine = pos.line || 0;
|
|
297
|
-
newColumn = pos.column || 0;
|
|
298
|
-
})["catch"](function (err) {
|
|
299
|
-
if (verbose) {
|
|
300
|
-
console.error("didn't get map", url, err);
|
|
301
|
-
}
|
|
302
|
-
// console.error(err);
|
|
303
|
-
})["finally"](function () {
|
|
304
|
-
if (json) {
|
|
305
|
-
var ret = {
|
|
306
|
-
functionName: functionName,
|
|
307
|
-
sourceURL: newUrl ? newUrl : url,
|
|
308
|
-
line: newUrl ? newLine : line,
|
|
309
|
-
column: newUrl ? newColumn : column
|
|
310
|
-
};
|
|
311
|
-
// if (newUrl) {
|
|
312
|
-
// ret.oldSourceURL = url;
|
|
313
|
-
// ret.oldLine = line;
|
|
314
|
-
// ret.oldColumn = column;
|
|
315
|
-
// }
|
|
316
|
-
// if (newUrl) {
|
|
317
|
-
// ret.newUrl = newUrl;
|
|
318
|
-
// ret.newLine = newLine;
|
|
319
|
-
// ret.newColumn = newColumn;
|
|
320
|
-
// }
|
|
321
|
-
resolve(ret);
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
var str = void 0;
|
|
325
|
-
if (newUrl) {
|
|
326
|
-
str = "".concat(build(functionName, newUrl, newLine, newColumn), " (").concat(build("", url, line, column), ")");
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
str = build(functionName, url, line, column);
|
|
330
|
-
}
|
|
331
|
-
resolve(str);
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
if (json) {
|
|
337
|
-
var parsed = void 0;
|
|
338
|
-
try {
|
|
339
|
-
parsed = JSON.parse(stack);
|
|
340
|
-
if (!Array.isArray(parsed)) {
|
|
341
|
-
throw new Error("Expected array");
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
catch (err) {
|
|
345
|
-
console.error("Can't parse json ".concat(err));
|
|
346
|
-
process.exit(1);
|
|
347
|
-
}
|
|
348
|
-
Promise.all(parsed.map(function (frame) {
|
|
349
|
-
if (verbose) {
|
|
350
|
-
console.error("got frame frame", frame);
|
|
351
|
-
}
|
|
352
|
-
return processFrame(frame.functionName || "", frame.sourceURL || "", frame.line, frame.column);
|
|
353
|
-
}))
|
|
354
|
-
.then(function (results) {
|
|
355
|
-
results.forEach(function (frame, index) {
|
|
356
|
-
if (typeof frame !== "object") {
|
|
357
|
-
throw new Error("Huh?");
|
|
358
|
-
}
|
|
359
|
-
frame.index = index;
|
|
360
|
-
});
|
|
361
|
-
// console.log("shit", results);
|
|
362
|
-
console.log(JSON.stringify(results, null, 4));
|
|
363
|
-
})["catch"](function (error) {
|
|
364
|
-
console.error("Got an error", error);
|
|
365
|
-
process.exit(2);
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
Promise.all(stack
|
|
370
|
-
.split("\n")
|
|
371
|
-
.filter(function (x) { return x; })
|
|
372
|
-
.map(function (x) {
|
|
373
|
-
x = x.trim();
|
|
374
|
-
var match = / *at *([^ ]*).* \(?([^ ]+):([0-9]+):([0-9]+)/.exec(x);
|
|
375
|
-
if (!match) {
|
|
376
|
-
match = /([^ ]+@)?(.*):([0-9]+):([0-9]+)/.exec(x);
|
|
377
|
-
}
|
|
378
|
-
if (verbose) {
|
|
379
|
-
console.error(x, " => ", match);
|
|
380
|
-
}
|
|
381
|
-
if (!match) {
|
|
382
|
-
var nolinecol = /([^ ]*)(.*)/.exec(x);
|
|
383
|
-
if (nolinecol) {
|
|
384
|
-
return nolinecol[0];
|
|
385
|
-
}
|
|
386
|
-
return x;
|
|
387
|
-
}
|
|
388
|
-
return processFrame(match[1] || "", match[2], parseInt(match[3]), parseInt(match[4]));
|
|
389
|
-
}))
|
|
390
|
-
.then(function (results) {
|
|
391
|
-
if (!results.length) {
|
|
392
|
-
throw new Error("Empty output");
|
|
393
|
-
}
|
|
394
|
-
results.forEach(function (str) {
|
|
395
|
-
console.log(str);
|
|
396
|
-
});
|
|
397
|
-
})["catch"](function (error) {
|
|
398
|
-
console.error("Got an error", error);
|
|
399
|
-
process.exit(3);
|
|
400
|
-
});
|
|
401
|
-
}
|