@misterhuydo/sentinel 1.3.2 → 1.3.4
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/.cairn/.hint-lock +1 -1
- package/.cairn/session.json +2 -2
- package/lib/add.js +40 -11
- package/package.json +1 -1
package/.cairn/.hint-lock
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2026-03-
|
|
1
|
+
2026-03-23T18:20:09.151Z
|
package/.cairn/session.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"message": "Auto-checkpoint at 2026-03-
|
|
3
|
-
"checkpoint_at": "2026-03-
|
|
2
|
+
"message": "Auto-checkpoint at 2026-03-23T18:21:42.702Z",
|
|
3
|
+
"checkpoint_at": "2026-03-23T18:21:42.703Z",
|
|
4
4
|
"active_files": [],
|
|
5
5
|
"notes": [],
|
|
6
6
|
"mtime_snapshot": {}
|
package/lib/add.js
CHANGED
|
@@ -129,7 +129,7 @@ function ensureKnownHosts() {
|
|
|
129
129
|
const content = fs.existsSync(knownHosts) ? fs.readFileSync(knownHosts, 'utf8') : '';
|
|
130
130
|
if (content.includes('github.com')) return;
|
|
131
131
|
info('Adding GitHub to known_hosts…');
|
|
132
|
-
const r = spawnSync('ssh-keyscan', ['github.com'], { encoding: 'utf8', timeout: 10000 });
|
|
132
|
+
const r = spawnSync('ssh-keyscan', ['github.com'], { encoding: 'utf8', timeout: 10000, env: gitEnv() });
|
|
133
133
|
if (r.stdout) fs.appendFileSync(knownHosts, r.stdout);
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -175,6 +175,33 @@ function printDeployKeyInstructions(orgRepo, keyFile) {
|
|
|
175
175
|
console.log('');
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
// Ensure git/ssh are findable regardless of how Node was launched
|
|
179
|
+
function gitEnv(extra = {}) {
|
|
180
|
+
const PATH = [
|
|
181
|
+
process.env.PATH || '',
|
|
182
|
+
'/usr/bin', '/usr/local/bin', '/bin', '/usr/sbin', '/usr/local/sbin',
|
|
183
|
+
].filter(Boolean).join(':');
|
|
184
|
+
return { ...process.env, PATH, GIT_TERMINAL_PROMPT: '0', ...extra };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function findBin(name) {
|
|
188
|
+
const candidates = [
|
|
189
|
+
`/usr/bin/${name}`, `/usr/local/bin/${name}`, `/bin/${name}`,
|
|
190
|
+
];
|
|
191
|
+
for (const p of candidates) {
|
|
192
|
+
if (fs.existsSync(p)) return p;
|
|
193
|
+
}
|
|
194
|
+
// fall back to letting the shell resolve it
|
|
195
|
+
const r = spawnSync('which', [name], { encoding: 'utf8', env: gitEnv() });
|
|
196
|
+
return (r.stdout || '').trim() || name;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let _gitBin;
|
|
200
|
+
function gitBin() {
|
|
201
|
+
if (!_gitBin) _gitBin = findBin('git');
|
|
202
|
+
return _gitBin;
|
|
203
|
+
}
|
|
204
|
+
|
|
178
205
|
// ── repo discovery helpers ────────────────────────────────────────────────────
|
|
179
206
|
|
|
180
207
|
function gitUrlToOrgRepo(gitUrl) {
|
|
@@ -189,18 +216,20 @@ function toHttpsUrl(gitUrl) {
|
|
|
189
216
|
}
|
|
190
217
|
|
|
191
218
|
function isPublicRepo(gitUrl) {
|
|
192
|
-
const r = spawnSync(
|
|
219
|
+
const r = spawnSync(gitBin(), ['ls-remote', '--heads', toHttpsUrl(gitUrl)], {
|
|
193
220
|
encoding: 'utf8', timeout: 10000, stdio: ['pipe', 'pipe', 'pipe'],
|
|
194
|
-
env:
|
|
221
|
+
env: gitEnv(),
|
|
195
222
|
});
|
|
196
223
|
return r.status === 0;
|
|
197
224
|
}
|
|
198
225
|
|
|
199
226
|
function validateAccess(repoUrl, keyFile) {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
227
|
+
const extra = keyFile
|
|
228
|
+
? { GIT_SSH_COMMAND: `ssh -i ${keyFile} -o StrictHostKeyChecking=no -o BatchMode=yes` }
|
|
229
|
+
: {};
|
|
230
|
+
const r = spawnSync(gitBin(), ['ls-remote', '--heads', repoUrl], {
|
|
231
|
+
encoding: 'utf8', timeout: 15000, stdio: ['pipe', 'pipe', 'pipe'],
|
|
232
|
+
env: gitEnv(extra),
|
|
204
233
|
});
|
|
205
234
|
return { ok: r.status === 0, stderr: (r.stderr || r.error?.message || '').trim() };
|
|
206
235
|
}
|
|
@@ -258,10 +287,10 @@ async function addFromGit(gitUrl, workspace) {
|
|
|
258
287
|
step(`[2/3] Scanning repo-configs in ${repoSlug}…`);
|
|
259
288
|
|
|
260
289
|
if (!fs.existsSync(localPath)) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
290
|
+
spawnSync(gitBin(), ['clone', '--depth', '1', gitUrl, localPath], {
|
|
291
|
+
stdio: 'inherit',
|
|
292
|
+
env: gitEnv({ GIT_SSH_COMMAND: `ssh -i ${keyFile} -o StrictHostKeyChecking=no -o BatchMode=yes` }),
|
|
293
|
+
});
|
|
265
294
|
}
|
|
266
295
|
|
|
267
296
|
const discovered = discoverReposFromClone(localPath);
|