@appland/appmap 3.39.0 → 3.40.1
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 +36 -0
- package/built/appmap.html +1 -1
- package/built/cli.js +2 -0
- package/built/cli.js.map +1 -1
- package/built/cmds/open/open.js.map +1 -1
- package/built/cmds/record/action/countAppMaps.js +1 -1
- package/built/cmds/record/action/countAppMaps.js.map +1 -1
- package/built/cmds/record/record.js +2 -0
- package/built/cmds/record/record.js.map +1 -1
- package/built/cmds/runCommand.js +2 -1
- package/built/cmds/runCommand.js.map +1 -1
- package/built/cmds/stats/stats.js +282 -0
- package/built/cmds/stats/stats.js.map +1 -0
- package/built/cmds/stats/types/appMapSize.js +3 -0
- package/built/cmds/stats/types/appMapSize.js.map +1 -0
- package/built/cmds/stats/types/functionExecutionTime.js +3 -0
- package/built/cmds/stats/types/functionExecutionTime.js.map +1 -0
- package/built/fingerprint/appmapIndex.js +2 -1
- package/built/fingerprint/appmapIndex.js.map +1 -1
- package/built/fingerprint/fingerprintDirectoryCommand.js +1 -1
- package/built/fingerprint/fingerprintDirectoryCommand.js.map +1 -1
- package/built/fingerprint/fingerprintQueue.js +21 -9
- package/built/fingerprint/fingerprintQueue.js.map +1 -1
- package/built/fingerprint/fingerprintWatchCommand.js +21 -11
- package/built/fingerprint/fingerprintWatchCommand.js.map +1 -1
- package/built/fingerprint/fingerprinter.js +28 -24
- package/built/fingerprint/fingerprinter.js.map +1 -1
- package/built/main.js.map +1 -1
- package/built/utils.js +45 -84
- package/built/utils.js.map +1 -1
- package/package.json +1 -1
package/built/utils.js
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.prefixLines = exports.exists = exports.listAppMapFiles = exports.processFiles = exports.writeFileAtomic = exports.mtime = exports.baseName = exports.verbose = exports.endTime = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const async_1 = require("async");
|
|
9
|
+
const glob_1 = __importDefault(require("glob"));
|
|
10
|
+
const util_1 = require("util");
|
|
11
|
+
const path_1 = require("path");
|
|
9
12
|
const StartTime = Date.now();
|
|
10
13
|
function endTime() {
|
|
11
14
|
return (Date.now() - StartTime) / 1000;
|
|
12
15
|
}
|
|
16
|
+
exports.endTime = endTime;
|
|
13
17
|
let isVerbose = false;
|
|
14
|
-
function verbose(
|
|
18
|
+
function verbose(v = null) {
|
|
15
19
|
if (v !== null) {
|
|
16
20
|
isVerbose = v;
|
|
17
21
|
}
|
|
18
22
|
return isVerbose;
|
|
19
23
|
}
|
|
20
|
-
|
|
24
|
+
exports.verbose = verbose;
|
|
25
|
+
function baseName(fileName) {
|
|
21
26
|
return fileName.substring(0, fileName.length - '.appmap.json'.length);
|
|
22
27
|
}
|
|
28
|
+
exports.baseName = baseName;
|
|
23
29
|
/**
|
|
24
30
|
* Gets the last modified time of a file.
|
|
25
31
|
*
|
|
26
|
-
* @returns
|
|
32
|
+
* @returns file mtime in ms, or null if the file does not exist or
|
|
27
33
|
* is not a file.
|
|
28
34
|
*/
|
|
29
|
-
// NB: 'ctime' is actually the time that the stats of the file were last changed.
|
|
30
|
-
// And 'birthtime' is not guaranteed across platforms.
|
|
31
|
-
// Therefore mtime is the most reliable indicator of when the file was created,
|
|
32
|
-
// especially since we write files atomically (e.g. by moving them into place after writing them
|
|
33
|
-
// as temp files).
|
|
34
35
|
async function mtime(filePath) {
|
|
36
|
+
// NB: 'ctime' is actually the time that the stats of the file were last changed.
|
|
37
|
+
// And 'birthtime' is not guaranteed across platforms.
|
|
38
|
+
// Therefore mtime is the most reliable indicator of when the file was created,
|
|
39
|
+
// especially since we write files atomically (e.g. by moving them into place after writing them
|
|
40
|
+
// as temp files).
|
|
35
41
|
let fileStat;
|
|
36
42
|
try {
|
|
37
|
-
fileStat = await
|
|
43
|
+
fileStat = await fs_1.promises.stat(filePath);
|
|
38
44
|
}
|
|
39
45
|
catch (e) {
|
|
40
46
|
return null;
|
|
@@ -44,37 +50,32 @@ async function mtime(filePath) {
|
|
|
44
50
|
}
|
|
45
51
|
return fileStat.mtimeMs;
|
|
46
52
|
}
|
|
53
|
+
exports.mtime = mtime;
|
|
47
54
|
/**
|
|
48
55
|
* Atomically write a file by first writing to a temporary file in the same
|
|
49
56
|
* directory then renaming in place.
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
57
|
+
* @param dirName target directory path
|
|
58
|
+
* @param fileName target file name
|
|
59
|
+
* @param suffix used to create the temporary file name
|
|
60
|
+
* @param data
|
|
54
61
|
*/
|
|
55
|
-
async function writeFileAtomic(dirName, fileName,
|
|
56
|
-
const suffix = jobId.toString();
|
|
62
|
+
async function writeFileAtomic(dirName, fileName, suffix, data) {
|
|
57
63
|
// first make sure the temp name isn't too long
|
|
58
64
|
const NAME_MAX = 255; // note: might not be true on some esoteric systems
|
|
59
65
|
const name = fileName.slice(0, NAME_MAX - suffix.length - 1);
|
|
60
|
-
const tempFilePath = join(dirName, `${name}.${suffix}`);
|
|
61
|
-
await
|
|
62
|
-
await
|
|
66
|
+
const tempFilePath = (0, path_1.join)(dirName, `${name}.${suffix}`);
|
|
67
|
+
await fs_1.promises.writeFile(tempFilePath, data);
|
|
68
|
+
await fs_1.promises.rename(tempFilePath, (0, path_1.join)(dirName, fileName));
|
|
63
69
|
}
|
|
70
|
+
exports.writeFileAtomic = writeFileAtomic;
|
|
64
71
|
/**
|
|
65
72
|
* Call a function with each matching file. No guarantee is given that
|
|
66
73
|
* files will be processed in any particular order.
|
|
67
|
-
*
|
|
68
|
-
* @param {string} pattern
|
|
69
|
-
* @param {(filePath: string): void} fn
|
|
70
|
-
* @param {(fileCount: number): void} fileCountFn
|
|
71
74
|
*/
|
|
72
|
-
async function processFiles(pattern, fn,
|
|
73
|
-
|
|
74
|
-
fileCountFn = (/** @type {number} */ count) => { }) {
|
|
75
|
-
const q = queue(fn, 5);
|
|
75
|
+
async function processFiles(pattern, fn, fileCountFn = (count) => { }) {
|
|
76
|
+
const q = (0, async_1.queue)(fn, 5);
|
|
76
77
|
q.pause();
|
|
77
|
-
const files = await promisify(
|
|
78
|
+
const files = await (0, util_1.promisify)(glob_1.default)(pattern);
|
|
78
79
|
if (fileCountFn) {
|
|
79
80
|
fileCountFn(files.length);
|
|
80
81
|
}
|
|
@@ -84,27 +85,22 @@ fileCountFn = (/** @type {number} */ count) => { }) {
|
|
|
84
85
|
q.resume();
|
|
85
86
|
await q.drain();
|
|
86
87
|
}
|
|
88
|
+
exports.processFiles = processFiles;
|
|
87
89
|
/**
|
|
88
90
|
* Lists all appmap.json files in a directory, and passes them to a function.
|
|
89
91
|
* With `await`, `listAppMapFiles` blocks until all the files have been processed.
|
|
90
|
-
*
|
|
91
|
-
* @param {string} directory
|
|
92
|
-
* @param {Function(string)} fn
|
|
93
92
|
*/
|
|
94
93
|
async function listAppMapFiles(directory, fn) {
|
|
95
94
|
if (verbose()) {
|
|
96
95
|
console.warn(`Scanning ${directory} for AppMaps`);
|
|
97
96
|
}
|
|
98
|
-
await Promise.all((await promisify(
|
|
97
|
+
await Promise.all((await (0, util_1.promisify)(glob_1.default)(`${directory}/**/*.appmap.json`)).map(fn));
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
* @param {PathLike} path
|
|
102
|
-
* @returns {Promise<boolean>}
|
|
103
|
-
*/
|
|
99
|
+
exports.listAppMapFiles = listAppMapFiles;
|
|
104
100
|
function exists(path) {
|
|
105
101
|
return new Promise((resolve) => {
|
|
106
|
-
|
|
107
|
-
.access(path,
|
|
102
|
+
fs_1.promises
|
|
103
|
+
.access(path, fs_1.constants.R_OK)
|
|
108
104
|
.then(() => {
|
|
109
105
|
resolve(true);
|
|
110
106
|
})
|
|
@@ -113,50 +109,15 @@ function exists(path) {
|
|
|
113
109
|
});
|
|
114
110
|
});
|
|
115
111
|
}
|
|
116
|
-
|
|
117
|
-
return buildAppMap()
|
|
118
|
-
.source(JSON.parse(await fsp.readFile(filePath)))
|
|
119
|
-
.normalize()
|
|
120
|
-
.build();
|
|
121
|
-
}
|
|
122
|
-
function formatValue(value) {
|
|
123
|
-
if (!value) {
|
|
124
|
-
return 'Null';
|
|
125
|
-
}
|
|
126
|
-
const valueStr = value.value.indexOf('#<') === 0 ? null : value.value;
|
|
127
|
-
return [value.class, valueStr].filter((e) => e).join(' ');
|
|
128
|
-
}
|
|
129
|
-
function formatHttpServerRequest(event) {
|
|
130
|
-
const data = {
|
|
131
|
-
method: event.httpServerRequest.request_method,
|
|
132
|
-
path: event.httpServerRequest.normalized_path_info || event.httpServerRequest.path_info,
|
|
133
|
-
statusCode: event.returnEvent && event.httpServerResponse
|
|
134
|
-
? event.httpServerResponse.status_code || event.httpServerResponse.status
|
|
135
|
-
: '<none>',
|
|
136
|
-
};
|
|
137
|
-
return [data.method, data.path, `(${data.statusCode})`].join(' ');
|
|
138
|
-
}
|
|
112
|
+
exports.exists = exists;
|
|
139
113
|
/**
|
|
140
114
|
* Append a prefix to each line in a string
|
|
141
|
-
* @param
|
|
142
|
-
* @param
|
|
143
|
-
* @returns
|
|
115
|
+
* @param str the string to be prefixed
|
|
116
|
+
* @param prefix a string to prefix each line with
|
|
117
|
+
* @returns the resulting string which starts each line with a prefix
|
|
144
118
|
*/
|
|
145
119
|
function prefixLines(str, prefix) {
|
|
146
120
|
return str.replace(/^/gm, prefix);
|
|
147
121
|
}
|
|
148
|
-
|
|
149
|
-
baseName,
|
|
150
|
-
endTime,
|
|
151
|
-
formatValue,
|
|
152
|
-
formatHttpServerRequest,
|
|
153
|
-
writeFileAtomic,
|
|
154
|
-
listAppMapFiles,
|
|
155
|
-
loadAppMap,
|
|
156
|
-
mtime,
|
|
157
|
-
verbose,
|
|
158
|
-
processFiles,
|
|
159
|
-
exists,
|
|
160
|
-
prefixLines,
|
|
161
|
-
};
|
|
122
|
+
exports.prefixLines = prefixLines;
|
|
162
123
|
//# sourceMappingURL=utils.js.map
|
package/built/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgF;AAChF,iCAA2C;AAC3C,gDAAwB;AACxB,+BAAiC;AACjC,+BAA4B;AAE5B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAE7B,SAAgB,OAAO;IACrB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;AACzC,CAAC;AAFD,0BAEC;AAED,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,SAAgB,OAAO,CAAC,IAAoB,IAAI;IAC9C,IAAI,CAAC,KAAK,IAAI,EAAE;QACd,SAAS,GAAG,CAAC,CAAC;KACf;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AALD,0BAKC;AAED,SAAgB,QAAQ,CAAC,QAAgB;IACvC,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC;AAFD,4BAEC;AAED;;;;;GAKG;AACI,KAAK,UAAU,KAAK,CAAC,QAAkB;IAC5C,iFAAiF;IACjF,sDAAsD;IACtD,+EAA+E;IAC/E,gGAAgG;IAChG,kBAAkB;IAElB,IAAI,QAAe,CAAC;IACpB,IAAI;QACF,QAAQ,GAAG,MAAM,aAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KACrC;IAAC,OAAO,CAAC,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