@themoltnet/pi-extension 0.24.0 → 0.24.1
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/dist/index.js +25 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8824,8 +8824,7 @@ async function resumeVm(config) {
|
|
|
8824
8824
|
signal: config.signal
|
|
8825
8825
|
});
|
|
8826
8826
|
if (creds.gitconfig) {
|
|
8827
|
-
const
|
|
8828
|
-
const vmGitconfig = creds.gitconfig.replace(/signingKey\s*=\s*.+/g, `signingKey = ${vmSigningKey}`);
|
|
8827
|
+
const vmGitconfig = rewriteGitconfigPaths(creds.gitconfig, vmSshDir, vmAgentDir);
|
|
8829
8828
|
await vm.fs.writeFile(`${vmAgentDir}/gitconfig`, vmGitconfig, {
|
|
8830
8829
|
mode: 420,
|
|
8831
8830
|
signal: config.signal
|
|
@@ -8848,17 +8847,6 @@ async function resumeVm(config) {
|
|
|
8848
8847
|
signal: config.signal
|
|
8849
8848
|
});
|
|
8850
8849
|
await vm.exec("chown -R agent:agent /home/agent/.pi /home/agent/.moltnet", { signal: config.signal });
|
|
8851
|
-
const gitCredHelperPath = `${vmSshDir}/git-credential-moltnet`;
|
|
8852
|
-
const credHelperScript = `#!/bin/sh
|
|
8853
|
-
echo "username=x-access-token"
|
|
8854
|
-
echo "password=$(moltnet github token --credentials ${vmSshDir}/moltnet.json)"
|
|
8855
|
-
`;
|
|
8856
|
-
await vm.fs.writeFile(gitCredHelperPath, credHelperScript, {
|
|
8857
|
-
mode: 493,
|
|
8858
|
-
signal: config.signal
|
|
8859
|
-
});
|
|
8860
|
-
await vmRun(vm, "git credential helper", `git config --global credential.helper ${gitCredHelperPath} && \
|
|
8861
|
-
git config --global url."https://github.com/".insteadOf "git@github.com:"`, config.signal);
|
|
8862
8850
|
return {
|
|
8863
8851
|
vm,
|
|
8864
8852
|
credentials: creds,
|
|
@@ -8877,6 +8865,30 @@ echo "password=$(moltnet github token --credentials ${vmSshDir}/moltnet.json)"
|
|
|
8877
8865
|
}
|
|
8878
8866
|
}
|
|
8879
8867
|
/**
|
|
8868
|
+
* Rewrite host-absolute paths inside an agent gitconfig to VM-local
|
|
8869
|
+
* equivalents before injecting it into the guest.
|
|
8870
|
+
*
|
|
8871
|
+
* Two rewrites:
|
|
8872
|
+
* - `signingKey = <host path>` → `<vmSshDir>/id_ed25519`
|
|
8873
|
+
* - `... credential-helper --credentials <host moltnet.json>`
|
|
8874
|
+
* → `<vmAgentDir>/moltnet.json`
|
|
8875
|
+
*
|
|
8876
|
+
* The credential-helper line is generated host-side by `moltnet github setup`
|
|
8877
|
+
* with a host-absolute `--credentials` path; inside the guest that path is
|
|
8878
|
+
* invalid, so it must point at the VM-side moltnet.json. The `insteadOf`
|
|
8879
|
+
* rewrite rule and every other line are workspace-independent and pass through
|
|
8880
|
+
* unchanged. A gitconfig without a credential helper is rewritten only for
|
|
8881
|
+
* `signingKey`.
|
|
8882
|
+
*
|
|
8883
|
+
* This is the single source of truth for git push auth in the guest: the
|
|
8884
|
+
* injected gitconfig carries the tokenless mint-on-demand helper, so the VM
|
|
8885
|
+
* no longer hand-rolls a credential-helper script or runs an imperative
|
|
8886
|
+
* `git config --global ... insteadOf` against the guest $HOME.
|
|
8887
|
+
*/
|
|
8888
|
+
function rewriteGitconfigPaths(gitconfig, vmSshDir, vmAgentDir) {
|
|
8889
|
+
return gitconfig.replace(/signingKey\s*=\s*.+/g, `signingKey = ${vmSshDir}/id_ed25519`).replace(/(moltnet github credential-helper --credentials )\S+/g, `$1${vmAgentDir}/moltnet.json`);
|
|
8890
|
+
}
|
|
8891
|
+
/**
|
|
8880
8892
|
* Rewrite host-absolute paths inside moltnet.json to VM-local equivalents.
|
|
8881
8893
|
*
|
|
8882
8894
|
* Fields rewritten:
|
package/package.json
CHANGED