@mcp-use/cli 3.0.1-canary.3 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAuIA,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAuYD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA2oBzE"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAwIA,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAuYD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA4qBzE"}
package/dist/index.cjs CHANGED
@@ -2834,6 +2834,36 @@ async function gitCommand(command, cwd = process.cwd()) {
2834
2834
  return null;
2835
2835
  }
2836
2836
  }
2837
+ var GitCommandError = class extends Error {
2838
+ command;
2839
+ stderr;
2840
+ stdout;
2841
+ exitCode;
2842
+ constructor(opts) {
2843
+ const trimmed = opts.stderr.trim() || opts.stdout.trim() || "unknown error";
2844
+ super(`git command failed: \`${opts.command}\`
2845
+ ${trimmed}`);
2846
+ this.name = "GitCommandError";
2847
+ this.command = opts.command;
2848
+ this.stderr = opts.stderr;
2849
+ this.stdout = opts.stdout;
2850
+ this.exitCode = opts.exitCode;
2851
+ }
2852
+ };
2853
+ async function gitCommandOrThrow(command, cwd = process.cwd()) {
2854
+ try {
2855
+ const { stdout } = await execAsync(command, { cwd });
2856
+ return stdout.trim();
2857
+ } catch (error) {
2858
+ const e = error;
2859
+ throw new GitCommandError({
2860
+ command,
2861
+ stderr: (e.stderr ?? "").toString(),
2862
+ stdout: (e.stdout ?? "").toString(),
2863
+ exitCode: typeof e.code === "number" ? e.code : null
2864
+ });
2865
+ }
2866
+ }
2837
2867
  async function isGitRepo(cwd = process.cwd()) {
2838
2868
  const result = await gitCommand("git rev-parse --is-inside-work-tree", cwd);
2839
2869
  return result === "true";
@@ -2896,19 +2926,24 @@ async function getGitInfo(cwd = process.cwd()) {
2896
2926
  hasUncommittedChanges: uncommittedChanges
2897
2927
  };
2898
2928
  }
2929
+ function shellQuote(message) {
2930
+ return `"${message.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
2931
+ }
2899
2932
  async function gitInit(cwd, message = "Initial commit") {
2900
- await gitCommand("git init", cwd);
2901
- await gitCommand("git add .", cwd);
2902
- await gitCommand(`git commit -m "${message}"`, cwd);
2933
+ await gitCommandOrThrow("git init", cwd);
2934
+ await gitCommandOrThrow("git add .", cwd);
2935
+ await gitCommandOrThrow(`git commit -m ${shellQuote(message)}`, cwd);
2936
+ await gitCommandOrThrow("git branch -M main", cwd);
2937
+ await gitCommandOrThrow("git rev-parse HEAD", cwd);
2903
2938
  }
2904
2939
  async function gitAddRemoteAndPush(cwd, cloneUrl, branch = "main") {
2905
- await gitCommand(`git remote add origin ${cloneUrl}`, cwd);
2906
- await gitCommand(`git push -u origin ${branch}`, cwd);
2940
+ await gitCommandOrThrow(`git remote add origin ${cloneUrl}`, cwd);
2941
+ await gitCommandOrThrow(`git push -u origin ${branch}`, cwd);
2907
2942
  }
2908
2943
  async function gitCommitAndPush(cwd, message, branch = "main") {
2909
- await gitCommand("git add .", cwd);
2910
- await gitCommand(`git commit -m "${message}"`, cwd);
2911
- await gitCommand(`git push origin ${branch}`, cwd);
2944
+ await gitCommandOrThrow("git add .", cwd);
2945
+ await gitCommandOrThrow(`git commit -m ${shellQuote(message)}`, cwd);
2946
+ await gitCommandOrThrow(`git push origin ${branch}`, cwd);
2912
2947
  }
2913
2948
  function isGitHubUrl(url) {
2914
2949
  try {
@@ -3672,27 +3707,56 @@ async function deployCommand(options) {
3672
3707
  }
3673
3708
  }
3674
3709
  console.log(source_default.green(`\u2713 Created ${source_default.cyan(repoResult.fullName)}`));
3675
- if (!gitInfo.isGitRepo) {
3676
- await ensureGitignore(cwd);
3677
- console.log(source_default.gray("Initializing git..."));
3678
- await gitInit(cwd, "Initial commit");
3679
- console.log(source_default.gray("Pushing to GitHub..."));
3680
- await gitAddRemoteAndPush(cwd, repoResult.cloneUrl, "main");
3681
- } else {
3682
- if (await hasUncommittedChanges(cwd)) {
3683
- console.log(
3684
- source_default.red(
3685
- "\u2717 You have uncommitted changes. Commit and push before deploying."
3686
- )
3710
+ try {
3711
+ if (!gitInfo.isGitRepo) {
3712
+ await ensureGitignore(cwd);
3713
+ console.log(source_default.gray("Initializing git..."));
3714
+ await gitInit(cwd, "Initial commit");
3715
+ console.log(source_default.gray("Pushing to GitHub..."));
3716
+ await gitAddRemoteAndPush(cwd, repoResult.cloneUrl, "main");
3717
+ } else {
3718
+ if (await hasUncommittedChanges(cwd)) {
3719
+ console.log(
3720
+ source_default.red(
3721
+ "\u2717 You have uncommitted changes. Commit and push before deploying."
3722
+ )
3723
+ );
3724
+ process.exit(1);
3725
+ }
3726
+ console.log(source_default.gray("Adding remote and pushing..."));
3727
+ await gitAddRemoteAndPush(
3728
+ cwd,
3729
+ repoResult.cloneUrl,
3730
+ gitInfo.branch || "main"
3687
3731
  );
3732
+ }
3733
+ } catch (err) {
3734
+ if (err instanceof GitCommandError) {
3735
+ console.log(source_default.red(`
3736
+ \u2717 Git step failed: \`${err.command}\``));
3737
+ const stderrTrimmed = (err.stderr || err.stdout).trim();
3738
+ if (stderrTrimmed) {
3739
+ console.log(source_default.gray(stderrTrimmed));
3740
+ }
3741
+ if (/tell me who you are|user\.email|user\.name/i.test(err.stderr)) {
3742
+ console.log(
3743
+ source_default.yellow(
3744
+ `
3745
+ Set your git identity for this project and retry:
3746
+ git -C ${JSON.stringify(cwd)} config user.email "you@example.com"
3747
+ git -C ${JSON.stringify(cwd)} config user.name "Your Name"`
3748
+ )
3749
+ );
3750
+ } else if (/non-fast-forward|rejected|unrelated histories/i.test(err.stderr)) {
3751
+ console.log(
3752
+ source_default.yellow(
3753
+ "\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"
3754
+ )
3755
+ );
3756
+ }
3688
3757
  process.exit(1);
3689
3758
  }
3690
- console.log(source_default.gray("Adding remote and pushing..."));
3691
- await gitAddRemoteAndPush(
3692
- cwd,
3693
- repoResult.cloneUrl,
3694
- gitInfo.branch || "main"
3695
- );
3759
+ throw err;
3696
3760
  }
3697
3761
  console.log(source_default.green("\u2713 Code pushed to GitHub\n"));
3698
3762
  gitInfo = await getGitInfo(cwd);