headlamp 0.1.33 → 0.1.35
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/README.md +104 -152
- package/bin/.gitkeep +4 -0
- package/bin/darwin-arm64/headlamp +0 -0
- package/dist/cli.cjs +50 -61814
- package/dist/postinstall.cjs +181 -0
- package/package.json +24 -61
- package/dist/cli.cjs.map +0 -7
- package/dist/index.js +0 -63488
- package/dist/index.js.map +0 -7
- package/dist/jest/reporter.cjs +0 -193
- package/dist/jest/setup.cjs +0 -201
- package/scripts/build.mjs +0 -123
- package/scripts/postinstall.mjs +0 -13
- package/scripts/print-publish-log.mjs +0 -29
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
const {
|
|
2
|
+
chmodSync,
|
|
3
|
+
createReadStream,
|
|
4
|
+
createWriteStream,
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
unlinkSync,
|
|
8
|
+
} = require("node:fs");
|
|
9
|
+
const path = require("node:path");
|
|
10
|
+
const https = require("node:https");
|
|
11
|
+
const zlib = require("node:zlib");
|
|
12
|
+
|
|
13
|
+
const EXECUTABLE_MODE = 0o755;
|
|
14
|
+
|
|
15
|
+
function getPackageRoot() {
|
|
16
|
+
return path.resolve(__dirname, "..");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getBinaryFileName() {
|
|
20
|
+
return process.platform === "win32" ? "headlamp.exe" : "headlamp";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isLikelyMusl() {
|
|
24
|
+
if (process.platform !== "linux") return false;
|
|
25
|
+
try {
|
|
26
|
+
const report = process.report?.getReport?.();
|
|
27
|
+
const glibcVersion = report?.header?.glibcVersionRuntime;
|
|
28
|
+
return !glibcVersion;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function resolvePlatformKey() {
|
|
35
|
+
const arch = process.arch;
|
|
36
|
+
if (process.platform === "linux") {
|
|
37
|
+
const libc = isLikelyMusl() ? "musl" : "gnu";
|
|
38
|
+
return `linux-${arch}-${libc}`;
|
|
39
|
+
}
|
|
40
|
+
return `${process.platform}-${arch}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function resolveBinaryPath() {
|
|
44
|
+
return path.join(
|
|
45
|
+
getPackageRoot(),
|
|
46
|
+
"bin",
|
|
47
|
+
resolvePlatformKey(),
|
|
48
|
+
getBinaryFileName()
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function tryChmodExecutable(filePath) {
|
|
53
|
+
if (process.platform === "win32") return;
|
|
54
|
+
try {
|
|
55
|
+
chmodSync(filePath, EXECUTABLE_MODE);
|
|
56
|
+
} catch {
|
|
57
|
+
// best-effort
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getPackageVersion() {
|
|
62
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
63
|
+
const packageJson = require(path.join(getPackageRoot(), "package.json"));
|
|
64
|
+
return String(packageJson.version ?? "");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function buildDownloadUrl({ version, platformKey }) {
|
|
68
|
+
const assetFileName = `${platformKey}-${getBinaryFileName()}.gz`;
|
|
69
|
+
return `https://github.com/dbpiper/headlamp/releases/download/v${version}/${assetFileName}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function downloadToFile({ url, destinationFilePath }) {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
const request = https.get(
|
|
75
|
+
url,
|
|
76
|
+
{ headers: { "user-agent": "headlamp-npm-postinstall" } },
|
|
77
|
+
(response) => {
|
|
78
|
+
const statusCode = response.statusCode ?? 0;
|
|
79
|
+
|
|
80
|
+
if (
|
|
81
|
+
statusCode >= 300 &&
|
|
82
|
+
statusCode < 400 &&
|
|
83
|
+
response.headers.location
|
|
84
|
+
) {
|
|
85
|
+
response.resume();
|
|
86
|
+
downloadToFile({
|
|
87
|
+
url: response.headers.location,
|
|
88
|
+
destinationFilePath,
|
|
89
|
+
}).then(resolve, reject);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (statusCode !== 200) {
|
|
94
|
+
response.resume();
|
|
95
|
+
reject(
|
|
96
|
+
new Error(
|
|
97
|
+
`headlamp postinstall: download failed (${statusCode}) from ${url}`
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const outputStream = createWriteStream(destinationFilePath);
|
|
104
|
+
response.pipe(outputStream);
|
|
105
|
+
outputStream.on("finish", resolve);
|
|
106
|
+
outputStream.on("error", reject);
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
request.on("error", reject);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function gunzipToFile({ gzFilePath, outputFilePath }) {
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
mkdirSync(path.dirname(outputFilePath), { recursive: true });
|
|
116
|
+
const inputStream = createReadStream(gzFilePath);
|
|
117
|
+
const gunzipStream = zlib.createGunzip();
|
|
118
|
+
const outputStream = createWriteStream(outputFilePath);
|
|
119
|
+
|
|
120
|
+
inputStream.on("error", reject);
|
|
121
|
+
gunzipStream.on("error", reject);
|
|
122
|
+
outputStream.on("error", reject);
|
|
123
|
+
outputStream.on("finish", resolve);
|
|
124
|
+
|
|
125
|
+
inputStream.pipe(gunzipStream).pipe(outputStream);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function safeUnlink(filePath) {
|
|
130
|
+
try {
|
|
131
|
+
unlinkSync(filePath);
|
|
132
|
+
} catch {
|
|
133
|
+
// ignore
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function ensurePlatformBinary() {
|
|
138
|
+
const binaryPath = resolveBinaryPath();
|
|
139
|
+
if (existsSync(binaryPath)) {
|
|
140
|
+
tryChmodExecutable(binaryPath);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const platformKey = resolvePlatformKey();
|
|
145
|
+
const version = getPackageVersion();
|
|
146
|
+
if (!version) {
|
|
147
|
+
throw new Error("headlamp postinstall: missing package.json version");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const downloadUrl = buildDownloadUrl({ version, platformKey });
|
|
151
|
+
const tempGzFilePath = path.join(
|
|
152
|
+
getPackageRoot(),
|
|
153
|
+
`.headlamp-${platformKey}.gz`
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
await downloadToFile({
|
|
158
|
+
url: downloadUrl,
|
|
159
|
+
destinationFilePath: tempGzFilePath,
|
|
160
|
+
});
|
|
161
|
+
await gunzipToFile({ gzFilePath: tempGzFilePath, outputFilePath: binaryPath });
|
|
162
|
+
tryChmodExecutable(binaryPath);
|
|
163
|
+
} finally {
|
|
164
|
+
safeUnlink(tempGzFilePath);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function run() {
|
|
169
|
+
try {
|
|
170
|
+
await ensurePlatformBinary();
|
|
171
|
+
} catch (error) {
|
|
172
|
+
process.stderr.write(`${String(error)}\n`);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
run();
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
package/package.json
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "headlamp",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"types": "dist-types/index.d.ts",
|
|
9
|
-
"bin": {
|
|
10
|
-
"headlamp": "dist/cli.cjs"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"dist",
|
|
14
|
-
"dist-types",
|
|
15
|
-
"scripts"
|
|
16
|
-
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "node ./scripts/build.mjs",
|
|
19
|
-
"postinstall": "node ./scripts/postinstall.mjs",
|
|
20
|
-
"prepublishOnly": "npm run build",
|
|
21
|
-
"lint": "eslint .",
|
|
22
|
-
"typecheck": "tsc --noEmit",
|
|
23
|
-
"format": "prettier --write .",
|
|
24
|
-
"format:check": "prettier --check .",
|
|
25
|
-
"release": "npm publish --access public",
|
|
26
|
-
"build:yalc": "npm run build && npx yalc publish --push && node ./scripts/print-publish-log.mjs",
|
|
27
|
-
"dev:yalc": "nodemon -w src -w src/jest -e ts,tsx,js,jsx,cjs -d 300ms -x \"npm run build:yalc\""
|
|
28
|
-
},
|
|
3
|
+
"version": "0.1.35",
|
|
4
|
+
"description": "The smart searchlight for your test suite. Fast, graph-powered selection for Jest and Cargo.",
|
|
29
5
|
"keywords": [
|
|
30
6
|
"testing",
|
|
31
7
|
"coverage",
|
|
@@ -33,47 +9,34 @@
|
|
|
33
9
|
"vitest",
|
|
34
10
|
"cli"
|
|
35
11
|
],
|
|
36
|
-
"
|
|
37
|
-
"
|
|
12
|
+
"homepage": "https://github.com/dbpiper/headlamp#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/dbpiper/headlamp/issues"
|
|
15
|
+
},
|
|
38
16
|
"repository": {
|
|
39
17
|
"type": "git",
|
|
40
18
|
"url": "git+https://github.com/dbpiper/headlamp.git"
|
|
41
19
|
},
|
|
42
|
-
"
|
|
43
|
-
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"type": "commonjs",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18"
|
|
44
24
|
},
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
"c12": "^3.2.0",
|
|
48
|
-
"es-toolkit": "^1.7.2",
|
|
49
|
-
"istanbul-lib-coverage": "^3.2.2",
|
|
50
|
-
"istanbul-lib-report": "^3.0.1",
|
|
51
|
-
"istanbul-reports": "^3.1.7",
|
|
52
|
-
"json5": "^2.2.3",
|
|
53
|
-
"picomatch": "^4.0.3"
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
54
27
|
},
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"vitest": "*"
|
|
28
|
+
"bin": {
|
|
29
|
+
"headlamp": "dist/cli.cjs"
|
|
58
30
|
},
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"eslint-plugin-import": "^2.29.1",
|
|
70
|
-
"eslint-plugin-node-import": "^1.0.5",
|
|
71
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
72
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
73
|
-
"nodemon": "^3.1.10",
|
|
74
|
-
"prettier": "^3.3.3",
|
|
75
|
-
"tslib": "^2.6.3",
|
|
76
|
-
"typescript": "^5.5.4",
|
|
77
|
-
"yalc": "^1.0.0-pre.53"
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"bin",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"postinstall": "node dist/postinstall.cjs",
|
|
39
|
+
"stage:local": "node scripts/stage-binaries.mjs --local",
|
|
40
|
+
"yalc:push": "node scripts/yalc-publish-local.mjs"
|
|
78
41
|
}
|
|
79
42
|
}
|