canary-test-cli 5.11.0 → 5.12.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/bin/canary +0 -0
- package/bin/canary.js +12 -10
- package/dist/doctor-manifest.js +83 -52
- package/dist/doctor.js +90 -44
- package/dist/engine-checks.js +277 -60
- package/dist/overlay-commands.js +155 -42
- package/dist/overlay-conflicts.js +121 -0
- package/dist/overlay-lint.js +211 -0
- package/dist/overlays-registry.js +23 -12
- package/dist/router.js +15 -14
- package/dist/skill-requirements.js +129 -0
- package/dist/source-spec.js +19 -11
- package/package.json +1 -1
- package/scripts/install.js +49 -32
package/scripts/install.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
'use strict';
|
|
3
3
|
|
|
4
|
-
const https = require(
|
|
5
|
-
const fs = require(
|
|
6
|
-
const path = require(
|
|
4
|
+
const https = require('node:https');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const path = require('node:path');
|
|
7
7
|
|
|
8
8
|
const SUPPORTED = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
'linux-x64': true,
|
|
10
|
+
'darwin-arm64': true,
|
|
11
|
+
'win32-x64': true,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
function getPlatformKey(platform, arch) {
|
|
15
15
|
const key = `${platform}-${arch}`;
|
|
16
16
|
if (!SUPPORTED[key]) {
|
|
17
17
|
throw new Error(
|
|
18
|
-
`Unsupported platform: ${key}. Supported: ${Object.keys(SUPPORTED).join(
|
|
18
|
+
`Unsupported platform: ${key}. Supported: ${Object.keys(SUPPORTED).join(', ')}`,
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
return key;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function getBinaryName(platformKey) {
|
|
25
|
-
return platformKey.startsWith(
|
|
25
|
+
return platformKey.startsWith('win32')
|
|
26
26
|
? `canary-${platformKey}.exe`
|
|
27
27
|
: `canary-${platformKey}`;
|
|
28
28
|
}
|
|
@@ -32,9 +32,9 @@ function getDownloadUrl(version, binaryName) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const TRUSTED_HOSTS = new Set([
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
'github.com',
|
|
36
|
+
'objects.githubusercontent.com',
|
|
37
|
+
'release-assets.githubusercontent.com',
|
|
38
38
|
]);
|
|
39
39
|
|
|
40
40
|
function validateRedirectHost(location) {
|
|
@@ -46,32 +46,40 @@ function validateRedirectHost(location) {
|
|
|
46
46
|
|
|
47
47
|
function download(url, destPath, redirectsLeft = 5) {
|
|
48
48
|
return new Promise((resolve, reject) => {
|
|
49
|
-
if (redirectsLeft === 0) return reject(new Error(
|
|
50
|
-
https
|
|
51
|
-
|
|
52
|
-
res.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
if (redirectsLeft === 0) return reject(new Error('Too many redirects'));
|
|
50
|
+
https
|
|
51
|
+
.get(url, (res) => {
|
|
52
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
53
|
+
res.resume(); // drain redirect response to free the socket
|
|
54
|
+
try {
|
|
55
|
+
validateRedirectHost(res.headers.location);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return reject(e);
|
|
58
|
+
}
|
|
59
|
+
return resolve(
|
|
60
|
+
download(res.headers.location, destPath, redirectsLeft - 1),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if (res.statusCode !== 200) {
|
|
64
|
+
return reject(new Error(`HTTP ${res.statusCode} fetching ${url}`));
|
|
65
|
+
}
|
|
66
|
+
const file = fs.createWriteStream(destPath);
|
|
67
|
+
res.pipe(file);
|
|
68
|
+
file.on('finish', () => file.close(resolve));
|
|
69
|
+
file.on('error', reject);
|
|
70
|
+
})
|
|
71
|
+
.on('error', reject);
|
|
64
72
|
});
|
|
65
73
|
}
|
|
66
74
|
|
|
67
75
|
async function main() {
|
|
68
|
-
const pkg = require(
|
|
76
|
+
const pkg = require('../package.json');
|
|
69
77
|
const version = pkg.version;
|
|
70
78
|
const platformKey = getPlatformKey(process.platform, process.arch);
|
|
71
79
|
const binaryName = getBinaryName(platformKey);
|
|
72
80
|
const url = getDownloadUrl(version, binaryName);
|
|
73
|
-
const destDir = path.join(__dirname,
|
|
74
|
-
const destName = process.platform ===
|
|
81
|
+
const destDir = path.join(__dirname, '..', 'bin');
|
|
82
|
+
const destName = process.platform === 'win32' ? 'canary.exe' : 'canary';
|
|
75
83
|
const destPath = path.join(destDir, destName);
|
|
76
84
|
|
|
77
85
|
fs.mkdirSync(destDir, { recursive: true });
|
|
@@ -83,5 +91,14 @@ async function main() {
|
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
// Export pure functions for testing; run main() only when executed directly.
|
|
86
|
-
module.exports = {
|
|
87
|
-
|
|
94
|
+
module.exports = {
|
|
95
|
+
getPlatformKey,
|
|
96
|
+
getBinaryName,
|
|
97
|
+
getDownloadUrl,
|
|
98
|
+
validateRedirectHost,
|
|
99
|
+
};
|
|
100
|
+
if (require.main === module)
|
|
101
|
+
main().catch((e) => {
|
|
102
|
+
process.stderr.write(e.message + '\n');
|
|
103
|
+
process.exit(1);
|
|
104
|
+
});
|