瀏覽代碼

tweak(git): Move proxy url definition into config files

We'll likely want to host our own proxy. Self-hosters likewise may have
their own, but it's convenient to use isomorphic-git's for development.
Sam Atkins 11 月之前
父節點
當前提交
c436460b8c

+ 1 - 0
packages/git/config/dev.js

@@ -18,4 +18,5 @@
  */
 globalThis.__CONFIG__ = {
     sdk_url: 'http://puter.localhost:4100/sdk/puter.js',
+    proxy_url: 'https://cors.isomorphic-git.org',
 };

+ 2 - 0
packages/git/config/release.js

@@ -18,4 +18,6 @@
  */
 globalThis.__CONFIG__ = {
     sdk_url: 'https://puter.com/puter.js/v2',
+    // TODO: Host a proxy ourselves, so we're not relying on (and maybe overloading) theirs.
+    proxy_url: 'https://cors.isomorphic-git.org',
 };

+ 0 - 2
packages/git/src/git-helpers.js

@@ -18,8 +18,6 @@
  */
 import path from 'path-browserify';
 
-export const PROXY_URL = 'https://cors.isomorphic-git.org';
-
 /**
  * Attempt to locate the git repository directory.
  * @throws Error If no git repository could be found, or another error occurred.

+ 1 - 2
packages/git/src/subcommands/clone.js

@@ -18,7 +18,6 @@
  */
 import git from 'isomorphic-git';
 import http from 'isomorphic-git/http/web';
-import { PROXY_URL } from '../git-helpers.js';
 import { SHOW_USAGE } from '../help.js';
 import path from 'path-browserify';
 
@@ -107,7 +106,7 @@ export default {
         await git.clone({
             fs,
             http,
-            corsProxy: PROXY_URL,
+            corsProxy: globalThis.__CONFIG__.proxy_url,
             dir: repo_path,
             url: repository,
             depth: options.depth,

+ 3 - 3
packages/git/src/subcommands/fetch.js

@@ -18,7 +18,7 @@
  */
 import git from 'isomorphic-git';
 import http from 'isomorphic-git/http/web';
-import { determine_fetch_remote, find_repo_root, PROXY_URL } from '../git-helpers.js';
+import { determine_fetch_remote, find_repo_root } from '../git-helpers.js';
 import { SHOW_USAGE } from '../help.js';
 
 export default {
@@ -61,7 +61,7 @@ export default {
                     fs,
                     http,
                     cache,
-                    corsProxy: PROXY_URL,
+                    corsProxy: globalThis.__CONFIG__.proxy_url,
                     dir,
                     gitdir,
                     remote,
@@ -78,7 +78,7 @@ export default {
             fs,
             http,
             cache,
-            corsProxy: PROXY_URL,
+            corsProxy: globalThis.__CONFIG__.proxy_url,
             dir,
             gitdir,
             ...remote_data,

+ 2 - 2
packages/git/src/subcommands/pull.js

@@ -18,7 +18,7 @@
  */
 import git from 'isomorphic-git';
 import http from 'isomorphic-git/http/web';
-import { determine_fetch_remote, find_repo_root, PROXY_URL } from '../git-helpers.js';
+import { determine_fetch_remote, find_repo_root } from '../git-helpers.js';
 import { SHOW_USAGE } from '../help.js';
 
 export default {
@@ -78,7 +78,7 @@ export default {
         await git.pull({
             fs,
             http,
-            corsProxy: PROXY_URL,
+            corsProxy: globalThis.__CONFIG__.proxy_url,
             dir,
             gitdir,
             cache,