@cedarjs/telemetry 5.0.7-next.310 → 5.0.7-next.336
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/dist/telemetry.d.ts +14 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +20 -2
- package/package.json +4 -4
package/dist/telemetry.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quotes a single argument for a Windows shell command string.
|
|
3
|
+
*
|
|
4
|
+
* On Windows we spawn with `shell: true` and a command string, so every
|
|
5
|
+
* argument is re-parsed by the shell. Without quoting, anything containing a
|
|
6
|
+
* space is split: a project at `C:\Users\Ada Lovelace\app` makes node try to
|
|
7
|
+
* load `C:\Users\Ada`, and the process dies with MODULE_NOT_FOUND. The JSON
|
|
8
|
+
* payloads passed below need it too, since they contain double quotes.
|
|
9
|
+
*
|
|
10
|
+
* Follows the usual Windows argument-encoding rules: backslashes immediately
|
|
11
|
+
* before a double quote are doubled, the quote itself is escaped, and trailing
|
|
12
|
+
* backslashes are doubled so they can't escape the closing quote.
|
|
13
|
+
*/
|
|
14
|
+
export declare function quoteForWindowsShell(arg: string): string;
|
|
1
15
|
export declare const timedTelemetry: (argv: string[], options: Record<string, unknown>, func: (...args: any[]) => any) => Promise<any>;
|
|
2
16
|
export declare const errorTelemetry: (argv: string[], error: any) => Promise<void>;
|
|
3
17
|
export declare const telemetryMiddleware: () => Promise<void>;
|
package/dist/telemetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,UAuB/C;AAsDD,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EAAE,EACd,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,iBAuB9B,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,EAAE,EAAE,OAAO,GAAG,kBAS9D,CAAA;AAGD,eAAO,MAAM,mBAAmB,qBAS/B,CAAA"}
|
package/dist/telemetry.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
2
|
import os from "os";
|
|
3
3
|
import path from "path";
|
|
4
|
+
function quoteForWindowsShell(arg) {
|
|
5
|
+
let quoted = '"';
|
|
6
|
+
let backslashes = 0;
|
|
7
|
+
for (const char of arg) {
|
|
8
|
+
if (char === "\\") {
|
|
9
|
+
backslashes += 1;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (char === '"') {
|
|
13
|
+
quoted += "\\".repeat(backslashes * 2 + 1) + '"';
|
|
14
|
+
} else {
|
|
15
|
+
quoted += "\\".repeat(backslashes) + char;
|
|
16
|
+
}
|
|
17
|
+
backslashes = 0;
|
|
18
|
+
}
|
|
19
|
+
return quoted + "\\".repeat(backslashes * 2) + '"';
|
|
20
|
+
}
|
|
4
21
|
const spawnProcess = (...args) => {
|
|
5
22
|
const isWindows = os.type() === "Windows_NT";
|
|
6
|
-
const execPath = isWindows ? `"${process.execPath}"` : process.execPath;
|
|
7
23
|
const spawnOptions = isWindows ? {
|
|
8
24
|
stdio: process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY ? ["ignore", "inherit", "inherit"] : "ignore",
|
|
9
25
|
// The following options run the process in the background without a console window, even though they don't look like they would.
|
|
@@ -21,7 +37,8 @@ const spawnProcess = (...args) => {
|
|
|
21
37
|
...args
|
|
22
38
|
];
|
|
23
39
|
if (isWindows) {
|
|
24
|
-
|
|
40
|
+
const command = [process.execPath, ...scriptArgs].map(quoteForWindowsShell).join(" ");
|
|
41
|
+
spawn(command, [], spawnOptions).unref();
|
|
25
42
|
} else {
|
|
26
43
|
spawn(process.execPath, scriptArgs, spawnOptions).unref();
|
|
27
44
|
}
|
|
@@ -57,6 +74,7 @@ const telemetryMiddleware = async () => {
|
|
|
57
74
|
};
|
|
58
75
|
export {
|
|
59
76
|
errorTelemetry,
|
|
77
|
+
quoteForWindowsShell,
|
|
60
78
|
telemetryMiddleware,
|
|
61
79
|
timedTelemetry
|
|
62
80
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/telemetry",
|
|
3
|
-
"version": "5.0.7-next.
|
|
3
|
+
"version": "5.0.7-next.336",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"test:watch": "vitest watch"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@cedarjs/project-config": "5.0.7-next.
|
|
26
|
-
"@cedarjs/structure": "5.0.7-next.
|
|
25
|
+
"@cedarjs/project-config": "5.0.7-next.336",
|
|
26
|
+
"@cedarjs/structure": "5.0.7-next.336",
|
|
27
27
|
"@whatwg-node/fetch": "0.10.13",
|
|
28
28
|
"ci-info": "4.4.0",
|
|
29
29
|
"envinfo": "7.21.0",
|
|
30
|
-
"systeminformation": "5.
|
|
30
|
+
"systeminformation": "5.33.1",
|
|
31
31
|
"uuid": "11.1.0",
|
|
32
32
|
"yargs": "17.7.3"
|
|
33
33
|
},
|