@prover-coder-ai/docker-git 1.0.51 → 1.0.52
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.
|
@@ -5825,14 +5825,37 @@ var ensureFileReady = (fs, resolved, onDirectoryMessage) => Effect.gen(function*
|
|
|
5825
5825
|
}
|
|
5826
5826
|
return "exists";
|
|
5827
5827
|
});
|
|
5828
|
+
var appendKeyIfMissing = (fs, resolved, source, desiredContents) => Effect.gen(function* (_) {
|
|
5829
|
+
const currentContents = yield* _(fs.readFileString(resolved));
|
|
5830
|
+
if (currentContents.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).includes(desiredContents)) return;
|
|
5831
|
+
const normalizedCurrent = currentContents.trimEnd();
|
|
5832
|
+
const nextContents = normalizedCurrent.length === 0 ? `${desiredContents}\n` : `${normalizedCurrent}\n${desiredContents}\n`;
|
|
5833
|
+
yield* _(fs.writeFileString(resolved, nextContents));
|
|
5834
|
+
yield* _(Effect.log(`Authorized keys appended from ${source} to ${resolved}`));
|
|
5835
|
+
});
|
|
5836
|
+
var resolveAuthorizedKeysSource = (fs, path, cwd) => Effect.gen(function* (_) {
|
|
5837
|
+
const sshPrivateKey = yield* _(findSshPrivateKey(fs, path, cwd));
|
|
5838
|
+
const matchingPublicKey = sshPrivateKey === null ? null : yield* _(findExistingPath(fs, `${sshPrivateKey}.pub`));
|
|
5839
|
+
return matchingPublicKey === null ? yield* _(findAuthorizedKeysSource(fs, path, cwd)) : matchingPublicKey;
|
|
5840
|
+
});
|
|
5828
5841
|
var ensureAuthorizedKeys = (baseDir, authorizedKeysPath) => withFsPathContext(({ fs, path }) => Effect.gen(function* (_) {
|
|
5829
5842
|
const resolved = resolveAuthorizedKeysPath(path, baseDir, authorizedKeysPath);
|
|
5830
|
-
|
|
5831
|
-
const
|
|
5843
|
+
const managedDefaultAuthorizedKeys = path.join(defaultProjectsRoot(process.cwd()), "authorized_keys");
|
|
5844
|
+
const state = yield* _(ensureFileReady(fs, resolved, (resolvedPath, backupPath) => `Authorized keys was a directory, moved to ${backupPath}. Creating a file at ${resolvedPath}.`));
|
|
5845
|
+
const source = yield* _(resolveAuthorizedKeysSource(fs, path, process.cwd()));
|
|
5832
5846
|
if (source === null) {
|
|
5833
5847
|
yield* _(Effect.logError(`Authorized keys not found. Create ${resolved} with your public key to enable SSH.`));
|
|
5834
5848
|
return;
|
|
5835
5849
|
}
|
|
5850
|
+
const desiredContents = (yield* _(fs.readFileString(source))).trim();
|
|
5851
|
+
if (desiredContents.length === 0) {
|
|
5852
|
+
yield* _(Effect.logWarning(`Authorized keys source ${source} is empty. Skipping SSH key sync.`));
|
|
5853
|
+
return;
|
|
5854
|
+
}
|
|
5855
|
+
if (state === "exists") {
|
|
5856
|
+
if (resolved === managedDefaultAuthorizedKeys) yield* _(appendKeyIfMissing(fs, resolved, source, desiredContents));
|
|
5857
|
+
return;
|
|
5858
|
+
}
|
|
5836
5859
|
yield* _(fs.makeDirectory(path.dirname(resolved), { recursive: true }));
|
|
5837
5860
|
yield* _(fs.copyFile(source, resolved));
|
|
5838
5861
|
yield* _(Effect.log(`Authorized keys copied from ${source} to ${resolved}`));
|