@mcp-use/cli 3.0.1 → 3.0.2-canary.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/commands/deploy.d.ts.map +1 -1
- package/dist/index.cjs +90 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +90 -26
- package/dist/index.js.map +1 -1
- package/dist/utils/git.d.ts +23 -3
- package/dist/utils/git.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2814,6 +2814,36 @@ async function gitCommand(command, cwd = process.cwd()) {
|
|
|
2814
2814
|
return null;
|
|
2815
2815
|
}
|
|
2816
2816
|
}
|
|
2817
|
+
var GitCommandError = class extends Error {
|
|
2818
|
+
command;
|
|
2819
|
+
stderr;
|
|
2820
|
+
stdout;
|
|
2821
|
+
exitCode;
|
|
2822
|
+
constructor(opts) {
|
|
2823
|
+
const trimmed = opts.stderr.trim() || opts.stdout.trim() || "unknown error";
|
|
2824
|
+
super(`git command failed: \`${opts.command}\`
|
|
2825
|
+
${trimmed}`);
|
|
2826
|
+
this.name = "GitCommandError";
|
|
2827
|
+
this.command = opts.command;
|
|
2828
|
+
this.stderr = opts.stderr;
|
|
2829
|
+
this.stdout = opts.stdout;
|
|
2830
|
+
this.exitCode = opts.exitCode;
|
|
2831
|
+
}
|
|
2832
|
+
};
|
|
2833
|
+
async function gitCommandOrThrow(command, cwd = process.cwd()) {
|
|
2834
|
+
try {
|
|
2835
|
+
const { stdout } = await execAsync(command, { cwd });
|
|
2836
|
+
return stdout.trim();
|
|
2837
|
+
} catch (error) {
|
|
2838
|
+
const e = error;
|
|
2839
|
+
throw new GitCommandError({
|
|
2840
|
+
command,
|
|
2841
|
+
stderr: (e.stderr ?? "").toString(),
|
|
2842
|
+
stdout: (e.stdout ?? "").toString(),
|
|
2843
|
+
exitCode: typeof e.code === "number" ? e.code : null
|
|
2844
|
+
});
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2817
2847
|
async function isGitRepo(cwd = process.cwd()) {
|
|
2818
2848
|
const result = await gitCommand("git rev-parse --is-inside-work-tree", cwd);
|
|
2819
2849
|
return result === "true";
|
|
@@ -2876,19 +2906,24 @@ async function getGitInfo(cwd = process.cwd()) {
|
|
|
2876
2906
|
hasUncommittedChanges: uncommittedChanges
|
|
2877
2907
|
};
|
|
2878
2908
|
}
|
|
2909
|
+
function shellQuote(message) {
|
|
2910
|
+
return `"${message.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
2911
|
+
}
|
|
2879
2912
|
async function gitInit(cwd, message = "Initial commit") {
|
|
2880
|
-
await
|
|
2881
|
-
await
|
|
2882
|
-
await
|
|
2913
|
+
await gitCommandOrThrow("git init", cwd);
|
|
2914
|
+
await gitCommandOrThrow("git add .", cwd);
|
|
2915
|
+
await gitCommandOrThrow(`git commit -m ${shellQuote(message)}`, cwd);
|
|
2916
|
+
await gitCommandOrThrow("git branch -M main", cwd);
|
|
2917
|
+
await gitCommandOrThrow("git rev-parse HEAD", cwd);
|
|
2883
2918
|
}
|
|
2884
2919
|
async function gitAddRemoteAndPush(cwd, cloneUrl, branch = "main") {
|
|
2885
|
-
await
|
|
2886
|
-
await
|
|
2920
|
+
await gitCommandOrThrow(`git remote add origin ${cloneUrl}`, cwd);
|
|
2921
|
+
await gitCommandOrThrow(`git push -u origin ${branch}`, cwd);
|
|
2887
2922
|
}
|
|
2888
2923
|
async function gitCommitAndPush(cwd, message, branch = "main") {
|
|
2889
|
-
await
|
|
2890
|
-
await
|
|
2891
|
-
await
|
|
2924
|
+
await gitCommandOrThrow("git add .", cwd);
|
|
2925
|
+
await gitCommandOrThrow(`git commit -m ${shellQuote(message)}`, cwd);
|
|
2926
|
+
await gitCommandOrThrow(`git push origin ${branch}`, cwd);
|
|
2892
2927
|
}
|
|
2893
2928
|
function isGitHubUrl(url) {
|
|
2894
2929
|
try {
|
|
@@ -3652,27 +3687,56 @@ async function deployCommand(options) {
|
|
|
3652
3687
|
}
|
|
3653
3688
|
}
|
|
3654
3689
|
console.log(source_default.green(`\u2713 Created ${source_default.cyan(repoResult.fullName)}`));
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3690
|
+
try {
|
|
3691
|
+
if (!gitInfo.isGitRepo) {
|
|
3692
|
+
await ensureGitignore(cwd);
|
|
3693
|
+
console.log(source_default.gray("Initializing git..."));
|
|
3694
|
+
await gitInit(cwd, "Initial commit");
|
|
3695
|
+
console.log(source_default.gray("Pushing to GitHub..."));
|
|
3696
|
+
await gitAddRemoteAndPush(cwd, repoResult.cloneUrl, "main");
|
|
3697
|
+
} else {
|
|
3698
|
+
if (await hasUncommittedChanges(cwd)) {
|
|
3699
|
+
console.log(
|
|
3700
|
+
source_default.red(
|
|
3701
|
+
"\u2717 You have uncommitted changes. Commit and push before deploying."
|
|
3702
|
+
)
|
|
3703
|
+
);
|
|
3704
|
+
process.exit(1);
|
|
3705
|
+
}
|
|
3706
|
+
console.log(source_default.gray("Adding remote and pushing..."));
|
|
3707
|
+
await gitAddRemoteAndPush(
|
|
3708
|
+
cwd,
|
|
3709
|
+
repoResult.cloneUrl,
|
|
3710
|
+
gitInfo.branch || "main"
|
|
3667
3711
|
);
|
|
3712
|
+
}
|
|
3713
|
+
} catch (err) {
|
|
3714
|
+
if (err instanceof GitCommandError) {
|
|
3715
|
+
console.log(source_default.red(`
|
|
3716
|
+
\u2717 Git step failed: \`${err.command}\``));
|
|
3717
|
+
const stderrTrimmed = (err.stderr || err.stdout).trim();
|
|
3718
|
+
if (stderrTrimmed) {
|
|
3719
|
+
console.log(source_default.gray(stderrTrimmed));
|
|
3720
|
+
}
|
|
3721
|
+
if (/tell me who you are|user\.email|user\.name/i.test(err.stderr)) {
|
|
3722
|
+
console.log(
|
|
3723
|
+
source_default.yellow(
|
|
3724
|
+
`
|
|
3725
|
+
Set your git identity for this project and retry:
|
|
3726
|
+
git -C ${JSON.stringify(cwd)} config user.email "you@example.com"
|
|
3727
|
+
git -C ${JSON.stringify(cwd)} config user.name "Your Name"`
|
|
3728
|
+
)
|
|
3729
|
+
);
|
|
3730
|
+
} else if (/non-fast-forward|rejected|unrelated histories/i.test(err.stderr)) {
|
|
3731
|
+
console.log(
|
|
3732
|
+
source_default.yellow(
|
|
3733
|
+
"\n The remote branch already has commits. Either delete the empty GitHub repo and retry, or reconcile manually:\n git pull --rebase origin main --allow-unrelated-histories\n git push -u origin main"
|
|
3734
|
+
)
|
|
3735
|
+
);
|
|
3736
|
+
}
|
|
3668
3737
|
process.exit(1);
|
|
3669
3738
|
}
|
|
3670
|
-
|
|
3671
|
-
await gitAddRemoteAndPush(
|
|
3672
|
-
cwd,
|
|
3673
|
-
repoResult.cloneUrl,
|
|
3674
|
-
gitInfo.branch || "main"
|
|
3675
|
-
);
|
|
3739
|
+
throw err;
|
|
3676
3740
|
}
|
|
3677
3741
|
console.log(source_default.green("\u2713 Code pushed to GitHub\n"));
|
|
3678
3742
|
gitInfo = await getGitInfo(cwd);
|