venfork 0.1.1 → 0.2.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/dist/index.js +30 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -8217,12 +8217,25 @@ async function setupCommand(upstreamUrl, privateMirrorName, organization) {
|
|
8217
8217
|
await $2`gh repo create ${privateMirrorRepoName} --private --clone=false`;
|
8218
8218
|
s.stop("Private mirror repository created");
|
8219
8219
|
s.start("Cloning upstream repository");
|
8220
|
-
await $2`git clone
|
8220
|
+
await $2`git clone ${config.upstreamUrl} ${tempDir}`;
|
8221
8221
|
s.stop("Upstream cloned");
|
8222
|
-
s.start("
|
8222
|
+
s.start("Detecting default branch");
|
8223
|
+
const result = await $2({
|
8224
|
+
cwd: tempDir,
|
8225
|
+
reject: false
|
8226
|
+
})`git symbolic-ref refs/remotes/origin/HEAD`;
|
8227
|
+
let defaultBranch = "main";
|
8228
|
+
if (result.exitCode === 0) {
|
8229
|
+
const match = result.stdout.trim().match(/refs\/remotes\/origin\/(.+)$/);
|
8230
|
+
if (match?.[1]) {
|
8231
|
+
defaultBranch = match[1];
|
8232
|
+
}
|
8233
|
+
}
|
8234
|
+
s.stop(`Default branch: ${defaultBranch}`);
|
8235
|
+
s.start(`Pushing ${defaultBranch} to private mirror repository`);
|
8223
8236
|
await $2({
|
8224
8237
|
cwd: tempDir
|
8225
|
-
})`git push
|
8238
|
+
})`git push git@github.com:${owner}/${config.privateMirrorName}.git ${defaultBranch}:${defaultBranch}`;
|
8226
8239
|
s.stop("Pushed to private mirror repository");
|
8227
8240
|
s.start("Cloning private mirror repository locally");
|
8228
8241
|
await $2`git clone git@github.com:${owner}/${config.privateMirrorName}.git`;
|
@@ -8626,17 +8639,25 @@ async function main() {
|
|
8626
8639
|
}
|
8627
8640
|
switch (command) {
|
8628
8641
|
case "setup": {
|
8629
|
-
const orgIndex = args.indexOf("--org");
|
8630
8642
|
let organization;
|
8631
8643
|
let upstreamUrl = args[1];
|
8632
8644
|
let privateMirrorName = args[2];
|
8633
|
-
|
8634
|
-
|
8635
|
-
|
8645
|
+
const orgEqualArg = args.find((arg) => arg.startsWith("--org="));
|
8646
|
+
if (orgEqualArg) {
|
8647
|
+
organization = orgEqualArg.split("=")[1];
|
8648
|
+
const filteredArgs = args.filter((arg) => !arg.startsWith("--org="));
|
8636
8649
|
upstreamUrl = filteredArgs[1];
|
8637
8650
|
privateMirrorName = filteredArgs[2];
|
8638
|
-
} else
|
8639
|
-
|
8651
|
+
} else {
|
8652
|
+
const orgIndex = args.indexOf("--org");
|
8653
|
+
if (orgIndex !== -1) {
|
8654
|
+
organization = args[orgIndex + 1];
|
8655
|
+
const filteredArgs = args.filter((_3, i2) => i2 !== orgIndex && i2 !== orgIndex + 1);
|
8656
|
+
upstreamUrl = filteredArgs[1];
|
8657
|
+
privateMirrorName = filteredArgs[2];
|
8658
|
+
} else if (process.env.VENFORK_ORG) {
|
8659
|
+
organization = process.env.VENFORK_ORG;
|
8660
|
+
}
|
8640
8661
|
}
|
8641
8662
|
await setupCommand(upstreamUrl, privateMirrorName, organization);
|
8642
8663
|
break;
|