qdmp-cli 0.1.4 → 0.1.6

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/constants.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const TEMPLATES = [
2
2
  {
3
3
  name: "default",
4
- value: "frontend/echo-uniapp-template",
4
+ value: "frontend/miniapp-taro-template",
5
5
  desc: "千岛小程序默认模版",
6
6
  emoji: "🟢",
7
7
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qdmp-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "qdmp-cli",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/utils/gitClone.js CHANGED
@@ -3,9 +3,9 @@ import path from "path";
3
3
  import chalk from "chalk";
4
4
  import { rm } from "fs/promises";
5
5
  import { existsSync } from "fs";
6
+ import { spawn } from "child_process";
6
7
  import { inquirerConfirm } from "./interactive.js";
7
8
  import { error } from "./logHandler.js";
8
- import { execSync } from "./common.js";
9
9
  /**
10
10
  * 下载项目
11
11
  * @param {string} projectName - 项目名称
@@ -38,13 +38,29 @@ export const download = async (projectName, repo) => {
38
38
  const clone = async (repo, name) => {
39
39
  const spinner = ora("正在拉取项目......").start();
40
40
  try {
41
- await execSync(`git clone --depth 1 git@g.echo.tech:${repo}.git ${name}`);
41
+ // 使用 spawn 并继承 stdio,允许 SSH 首次连接时用户交互确认
42
+ spinner.stop();
43
+ await new Promise((resolve, reject) => {
44
+ const child = spawn(
45
+ "git",
46
+ ["clone", "--depth", "1", `git@g.echo.tech:${repo}.git`, name],
47
+ { stdio: "inherit" }
48
+ );
49
+ child.on("close", (code) => {
50
+ if (code === 0) {
51
+ resolve();
52
+ } else {
53
+ reject(new Error(`git clone 退出码: ${code}`));
54
+ }
55
+ });
56
+ child.on("error", (err) => {
57
+ reject(err);
58
+ });
59
+ });
42
60
  const gitPath = path.join(process.cwd(), name, ".git");
43
61
  await rm(gitPath, { recursive: true, force: true });
44
- spinner.succeed(chalk.green(`模版创建成功!请进入 ${name} 目录开始开发`));
45
- } catch (error) {
46
- spinner.fail(chalk.red(`模版创建失败: ${error.message}`));
47
- } finally {
48
- spinner.stop();
62
+ console.log(chalk.green(`✔ 模版创建成功!请进入 ${name} 目录开始开发`));
63
+ } catch (err) {
64
+ console.log(chalk.red(`✖ 模版创建失败: ${err.message}`));
49
65
  }
50
66
  };