"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/index.ts
var _cac = require('cac');
var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
var _dotenv = require('dotenv'); var dotenv = _interopRequireWildcard(_dotenv);

// package.json
var version = "0.3.5";

// src/node/config.ts
var _prompts = require('prompts'); var _prompts2 = _interopRequireDefault(_prompts);

// src/node/git.ts
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
var _fs = require('fs');
var _simplegit = require('simple-git');


var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);

// src/utils/chalk.ts

var _figlet = require('figlet'); var _figlet2 = _interopRequireDefault(_figlet);

function welcome() {
  const text = _figlet2.default.textSync("LDesign", {
    horizontalLayout: "full"
  });
  console.log(_chalk2.default.green(text));
  const spinner = _ora2.default.call(void 0, "\u{1F449} \u68C0\u67E5\u6784\u5EFA\u73AF\u5883...").start();
  spinner.succeed(_chalk2.default.green("\u6784\u5EFA\u73AF\u5883\u6B63\u5E38"));
}
function time() {
  const date = /* @__PURE__ */ new Date();
  const hour = format(date.getHours());
  const minute = format(date.getMinutes());
  const second = format(date.getSeconds());
  return _chalk2.default.gray(`${hour}:${minute}:${second} `);
}
function format(n) {
  return n >= 10 ? `${n}` : `0${n}`;
}

// src/node/git.ts
var options = {
  baseDir: process.cwd(),
  binary: "git"
};
var git = _simplegit.simpleGit.call(void 0, options);
async function getGitInformation(answers, global) {
  try {
    const { all: config } = await git.listConfig();
    return new Promise((resolve) => {
      resolve({
        name: config["user.name"],
        email: config["user.email"]
      });
    });
  } catch (err) {
    console.log(err);
  }
}
async function initLocalGit(repo) {
  const { http_url_to_repo } = repo;
  const spinner = _ora2.default.call(void 0, `${time()} \u521D\u59CB\u5316\u672C\u5730git\u4ED3\u5E93`).start();
  await git.init();
  if (repo) {
    spinner.text = `${time()} \u6DFB\u52A0\u8FDC\u7A0B\u4ED3\u5E93`;
    await git.addRemote("origin", http_url_to_repo);
  }
  spinner.text = `${time()} \u6B63\u5728\u51C6\u5907\u7B2C\u4E00\u6B21\u63D0\u4EA4\uFF01`;
  await initCommit("Initial commit");
  spinner.succeed(`${time()} \u521D\u59CB\u5316\u63D0\u4EA4\u6210\u529F`);
}
async function initCommit(message) {
  await git.add(".");
  await git.commit(message);
  await git.push("origin", "master");
}
async function resolveGitToken() {
  const token = process.env.ACCESS_TOKEN;
  if (token) {
    console.log(`\u5F53\u524DToken\uFF1A${_chalk2.default.green(token)}\uFF0C\u5982\u9700\u66F4\u6539\uFF0C\u8BF7\u6267\u884C\uFF1A${_chalk2.default.green("ldesign config")}\u8FDB\u884C\u66F4\u6539\u3002`);
  }
}
async function resolveGitHost() {
  const host = process.env.GITLAB_URL;
  if (host) {
    console.log(`\u5F53\u524DHost\uFF1A${_chalk2.default.green(host)}\uFF0C\u5982\u9700\u66F4\u6539\uFF0C\u8BF7\u6267\u884C\uFF1A${_chalk2.default.green("ldesign config")}\u8FDB\u884C\u66F4\u6539\u3002`);
  }
}
async function setEnv(name, value) {
  const envFile = _fs.readFileSync.call(void 0, getEnvPath(), {
    encoding: "utf-8"
  });
  const env = dotenv.parse(envFile);
  env[name] = value.trim();
  let updatedEnvFile = "";
  for (const [key, value2] of Object.entries(env)) {
    updatedEnvFile += `${key}=${value2}
`;
  }
  _fs.writeFileSync.call(void 0, getEnvPath(), updatedEnvFile);
}
function getEnvPath() {
  const currentModulePath = _path2.default.resolve(__dirname);
  const envPath = _path2.default.join(currentModulePath, "..", ".env");
  return envPath;
}

// src/node/config.ts
async function setConfig(name) {
  let updateName = name;
  if (!name) {
    const res2 = await _prompts2.default.call(void 0, [
      {
        type: "select",
        name: "name",
        choices: [
          {
            title: "Git Token",
            value: "ACCESS_TOKEN"
          },
          {
            title: "Git Host",
            value: "GITLAB_URL"
          }
        ],
        message: "\u8BF7\u8F93\u5165\u9700\u8981\u4FEE\u6539\u7684\u914D\u7F6E"
      }
    ]);
    updateName = res2.name;
  }
  const res = await _prompts2.default.call(void 0, 
    {
      type: "text",
      name: "value",
      message: "\u8BF7\u8F93\u5165"
    }
  );
  if (res.value && updateName) {
    setEnv(updateName, res.value);
  }
  console.log("\u51FA\u9519");
}

// src/node/install.ts

var _npminstall = require('npminstall'); var _npminstall2 = _interopRequireDefault(_npminstall);

var _npmlog = require('npmlog'); var _npmlog2 = _interopRequireDefault(_npmlog);

// src/node/licence.ts


var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);

// src/utils/crypto.ts
var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);


var _buffer = require('buffer');
var secretKey = "longrise-leap";
var IV_LENGTH = 16;
function encrypt(text) {
  const iv = _crypto2.default.randomBytes(IV_LENGTH);
  const algorithm = "aes-256-cbc";
  const key = _crypto2.default.createHash("sha256").update(secretKey).digest();
  const cipher = _crypto2.default.createCipheriv(algorithm, key, iv);
  const encryptedBytes = new Uint8Array(cipher.update(text, "utf8"));
  const finalEncryptedBytes = new Uint8Array(cipher.final());
  const encryptedResult = new Uint8Array(encryptedBytes.length + finalEncryptedBytes.length);
  encryptedResult.set(encryptedBytes);
  encryptedResult.set(finalEncryptedBytes, encryptedBytes.length);
  return `${_buffer.Buffer.from(encryptedResult).toString("hex")}.${iv.toString("hex")}`;
}
function decrypt(encryptedText) {
  const [encrypted, ivHex] = encryptedText.split(".");
  const algorithm = "aes-256-cbc";
  const key = _crypto2.default.createHash("sha256").update(secretKey).digest();
  const iv = new Uint8Array(_buffer.Buffer.from(ivHex, "hex"));
  const decipher = _crypto2.default.createDecipheriv(algorithm, key, iv);
  const encryptedBytes = new Uint8Array(_buffer.Buffer.from(encrypted, "hex"));
  const decryptedBytes = new Uint8Array(decipher.update(encryptedBytes));
  const finalDecryptedBytes = new Uint8Array(decipher.final());
  const decryptedResult = new Uint8Array(decryptedBytes.length + finalDecryptedBytes.length);
  decryptedResult.set(decryptedBytes);
  decryptedResult.set(finalDecryptedBytes, decryptedBytes.length);
  const decoder = new TextDecoder();
  return decoder.decode(decryptedResult);
}

// src/utils/date.ts
function getCurrentDateTime() {
  const date = /* @__PURE__ */ new Date();
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, "0");
  const day = String(date.getDate()).padStart(2, "0");
  const hours = String(date.getHours()).padStart(2, "0");
  const minutes = String(date.getMinutes()).padStart(2, "0");
  const seconds = String(date.getSeconds()).padStart(2, "0");
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

// src/node/licence.ts
async function generateLicence(answers, global) {
  const { source, target } = global;
  const { typescript, eslint, git: git2 } = answers;
  const pacakgeJson = _path2.default.resolve(source, "package.json");
  const content = await _fsextra.readJson.call(void 0, pacakgeJson);
  if (!typescript) {
    delete content.devDependencies.typescript;
    delete content.devDependencies["@vue/tsconfig"];
    delete content.devDependencies["vue-tsc"];
    delete content.devDependencies["@types/node"];
    delete content.scripts["type-check"];
    content.scripts.build = content.scripts["build-only"];
    delete content.scripts["build-only"];
  }
  if (!eslint) {
    delete content.devDependencies.eslint;
    delete content.devDependencies["@antfu/eslint-config"];
    delete content.scripts.lint;
  }
  content.name = _path.basename.call(void 0, target);
  content.date = getCurrentDateTime();
  let user = null;
  if (git2) {
    user = await getGitInformation(answers, global);
  }
  if (user) {
    content.author = user;
  }
  _fs.writeFileSync.call(void 0, _path2.default.resolve(target, "licence"), encrypt(JSON.stringify(content)));
}
async function getLicence(target) {
  const content = _fs.readFileSync.call(void 0, _path.join.call(void 0, target, "licence"), { encoding: "utf-8" });
  const decodeContent = decrypt(content);
  const json = JSON.parse(decodeContent);
  const dependencies = {
    ...json.dependencies,
    ...json.devDependencies
  };
  const arr = Object.keys(dependencies).map((key) => ({
    name: key,
    version: dependencies[key]
  }));
  return Promise.resolve(arr);
}

// src/node/install.ts
_npmlog2.default.stream = process.stdout;
async function installDepedencies() {
  const target = process.cwd();
  const dependencies = await getLicence(target);
  await install(dependencies);
}
async function install(dependencies) {
  const spinner = _ora2.default.call(void 0, `${time()} \u5F00\u59CB\u5B89\u88C5\u4F9D\u8D56`);
  await _npminstall2.default.call(void 0, {
    root: process.cwd(),
    pkgs: dependencies
  }).catch((err) => {
    if (err) {
      _npmlog2.default.error("npminstall", err.message);
    } else {
      _npmlog2.default.info("npminstall", "Packages installed successfully");
    }
  });
  spinner.succeed(`${time()} \u5B89\u88C5\u6210\u529F`);
}
async function getDependencies() {
  const target = process.cwd();
  const dependencies = await getLicence(target);
  dependencies.forEach(async (item) => {
    await console.log(`${item.name}: ${_chalk2.default.green(item.version)}`);
  });
}

// src/node/dev.ts
var _vite = require('vite');
async function startDevProject() {
  console.log("33");
  const server = await _vite.createServer.call(void 0, );
  server.listen();
}

// src/node/init.ts




// src/utils/without-ts.ts




// src/utils/file.ts


var { readdir, stat, rmdir, unlink } = _fs.promises;
function isDirectoryEmpty(targetDir) {
  return new Promise((resolve, reject) => {
    if (!_fs.existsSync.call(void 0, targetDir)) {
      resolve(true);
      return;
    }
    const files = _fs.readdirSync.call(void 0, targetDir);
    resolve(files.length === 0);
  });
}

// src/node/editFiles.ts



// src/node/depend.ts




async function getPackageJson(target) {
  const pacakgeJson = _path2.default.resolve(target, "package.json");
  const content = await _fsextra.readJson.call(void 0, pacakgeJson);
  return Promise.resolve(content);
}

// src/node/copyTemplate.ts


async function copyTemplateToTarget(answers, global) {
  const spinner = _ora2.default.call(void 0, "\u5F00\u59CB\u6E05\u7A7A\u5F53\u524D\u76EE\u5F55").start();
  try {
    await _fsextra2.default.copy(global.source, global.target, {
      filter: (src, dest) => {
        if (src.includes(".git")) {
          return false;
        }
        return true;
      }
    });
    return new Promise((resolve) => {
      resolve(true);
      spinner.succeed("\u521D\u59CB\u5316\u5B8C\u6210\uFF01");
    });
  } catch (err) {
    spinner.fail("\u521D\u59CB\u5316\u5931\u8D25\uFF01");
    console.log(err);
  }
}

// src/node/clearTarget.ts


async function clearTargetFiles(answers, global) {
  if (!answers.clear) {
    return;
  }
  const spinner = _ora2.default.call(void 0, "\u5F00\u59CB\u6E05\u7A7A\u5F53\u524D\u76EE\u5F55").start();
  try {
    await _fsextra2.default.emptyDir(global.target);
    return new Promise((resolve) => {
      spinner.succeed("\u76EE\u5F55\u6E05\u7A7A\u6210\u529F");
      resolve(true);
    });
  } catch (err) {
    spinner.fail("\u6E05\u7A7A\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u5220\u9664\uFF0C\u6216\u65B0\u5EFA\u4E00\u4E2A\u7A7A\u76EE\u5F55\uFF01");
  }
}

// src/node/gitlab.ts

var _rest = require('@gitbeaker/rest');


async function createRepository(answers, global) {
  const name = _path.basename.call(void 0, global.target);
  const choices = await getUserGroups();
  const res = await _prompts2.default.call(void 0, {
    type: "select",
    name: "group",
    message: "\u8BF7\u9009\u62E9\u8981\u521B\u5EFA\u9879\u76EE\u7684\u5206\u7EC4",
    hint: "\u8BF7\u6309\u4E0A\u4E0B\u952E\u9009\u62E9!",
    warn: "\u6587\u6863\u7CFB\u7EDF\u6682\u672A\u4E0A\u7EBF!",
    float: true,
    choices
  });
  const groupId = res.group;
  const group = choices.find((a) => a.id === groupId);
  const isExist = await isRepositoriesExist(group, name);
  if (!isExist) {
    const repo = await create(groupId, name);
    return Promise.resolve(repo);
  }
  console.log("\u9879\u76EE\u5DF2\u5B58\u5728!");
  return Promise.resolve(null);
}
async function create(groupId, name) {
  const host = process.env.GITLAB_URL;
  const token = process.env.ACCESS_TOKEN;
  const api = new (0, _rest.Gitlab)({ token, host });
  const spinner = _ora2.default.call(void 0, `${time()}\u5F00\u59CB\u521B\u5EFA\u8FDC\u7A0B\u4ED3\u5E93`).start();
  try {
    const repo = await api.Projects.create({
      name,
      namespaceId: groupId
    });
    spinner.succeed(`${time()}\u521B\u5EFA\u6210\u529F\uFF0C\u8FDC\u7A0B\u4ED3\u5E93\u5730\u5740\uFF1A${repo.web_url}`);
    return Promise.resolve(repo);
  } catch (e) {
    spinner.fail("error");
    return Promise.resolve(null);
  }
}
async function getUserGroups() {
  const host = process.env.GITLAB_URL;
  const token = process.env.ACCESS_TOKEN;
  const api = new (0, _rest.Gitlab)({ token, host });
  try {
    const groups = await api.Groups.all({
      statistics: true,
      owned: false,
      perPage: 50,
      sort: "asc",
      orderBy: "name"
    });
    const result = groups.map((a) => ({
      title: a.name,
      value: a.id,
      ...a
    }));
    return Promise.resolve(result);
  } catch (error) {
    return Promise.resolve([]);
  }
}
async function isRepositoriesExist(group, name) {
  const host = process.env.GITLAB_URL;
  const token = process.env.ACCESS_TOKEN;
  const api = new (0, _rest.Gitlab)({ token, host });
  try {
    const items = await api.Projects.search(name, {});
    const result = items.find((a) => a.namespace.id === group.id && a.path === name);
    if (result) {
      return Promise.resolve(true);
    } else {
      return Promise.resolve(false);
    }
  } catch (e2) {
    return Promise.resolve(true);
  }
}

// src/node/update/desktopVue3.ts



async function updateDesktopVue3(answers, global) {
  await deleteDependenciesFromPackageJson(answers, global);
  await updateViteConfigFile(answers, global);
  await updateSrcMainTsFile(answers, global);
  await updateTsConfigFile(answers, global);
  await deleteUselessFiles(answers, global);
  await updateIndexHTMLFile(answers, global);
}
async function deleteDependenciesFromPackageJson(answers, global) {
  const content = await getPackageJson(global.target);
  delete content.dependencies;
  delete content.devDependencies;
  content.name = _path.basename.call(void 0, global.target);
  content.version = "0.0.1";
  delete content.scripts.preview;
  if (!answers.eslint) {
    delete content.scripts.lint;
  }
  if (!answers.typescript) {
    delete content.scripts["type-check"];
    content.scripts.build = content.scripts["build-only"];
    delete content.scripts["build-only"];
  }
  await _fsextra2.default.writeJson("./package.json", content, { spaces: 2 });
}
async function updateViteConfigFile(answers, global) {
  const configFile = _path.join.call(void 0, global.target, "vite.config.ts");
  const configContent = _fs.readFileSync.call(void 0, configFile, { encoding: "utf-8" });
  const pattern = /\/\*\* Delete below \*\/([\s\S]*?)\/\*\* End \*\//;
  let result = configContent.replace(pattern, "").trim().replace(/^\s*$\n/gm, "");
  if (!answers.typescript) {
    result = result.replace(/:\sConfigEnv|type\s+ConfigEnv,\s*/g, "");
  }
  _fs.writeFileSync.call(void 0, configFile, result);
  if (!answers.typescript) {
    await _fsextra2.default.move(configFile, _path.join.call(void 0, global.target, "vite.config.js"));
  }
}
async function updateSrcMainTsFile(answers, global) {
  const tsFile = _path.join.call(void 0, global.target, "src", "main.ts");
  const tsContent = _fs.readFileSync.call(void 0, tsFile, { encoding: "utf-8" });
  const pattern = /(.*)(\r?\n\s*\/\*\* 正式环境使用下面的地址 \*\/)/g;
  const result = tsContent.replace(pattern, "").replace(/\/\/\W/g, "");
  _fs.writeFileSync.call(void 0, tsFile, result);
  if (!answers.typescript) {
    await _fsextra2.default.move(tsFile, _path.join.call(void 0, global.target, "src", "main.js"));
  }
}
async function updateTsConfigFile(answers, global) {
  const configFile = _path.join.call(void 0, global.target, "tsconfig.json");
  const configContent = _fs.readFileSync.call(void 0, configFile, { encoding: "utf-8" });
  const pattern = /\/\/\s*Delete\sbelow([\S\s]*?)\/\/\s*End/gi;
  const result = configContent.replace(pattern, "").trim().replace(/^\s*$\n/gm, "");
  _fs.writeFileSync.call(void 0, configFile, result);
}
async function updateIndexHTMLFile(answers, global) {
  const htmlFile = _path.join.call(void 0, global.target, "index.html");
  const htmlContent = _fs.readFileSync.call(void 0, htmlFile, {
    encoding: "utf-8"
  });
  const name = _path.basename.call(void 0, global.target);
  const pattern = /\{\{\s*title\s*\}\}/g;
  let result = htmlContent.replace(pattern, name);
  if (!answers.typescript) {
    result = result.replace(".ts", ".js");
  }
  _fs.writeFileSync.call(void 0, htmlFile, result);
}
async function deleteUselessFiles(answers, global) {
  if (!answers.typescript) {
    await _fsextra2.default.unlink(_path.join.call(void 0, global.target, "tsconfig.json"));
    await _fsextra2.default.unlink(_path.join.call(void 0, global.target, "tsconfig.node.json"));
    await _fsextra2.default.unlink(_path.join.call(void 0, global.target, "env.d.ts"));
    await _fsextra2.default.unlink(_path.join.call(void 0, global.target, "src", "env.d.ts"));
  }
  if (!answers.eslint) {
    await _fsextra2.default.unlink(_path.join.call(void 0, global.target, ".eslintrc.cjs"));
    await _fsextra2.default.remove(_path.join.call(void 0, global.target, ".vscode"));
  }
}

// src/node/updateProjectFileContent.ts
async function updateProjectFileContent(answers, global) {
  const { pkg } = answers;
  console.log("\u5F00\u59CB\u505A\u6700\u540E\u7684\u51C6\u5907");
  if (pkg === "desktop-vue3") {
    await updateDesktopVue3(answers, global);
  }
}

// src/node/init.ts
async function initProject(type) {
  const global = {
    target: process.cwd(),
    source: ""
  };
  const answers = {
    pkg: type,
    git: false,
    typescript: false,
    eslint: false,
    clear: false
  };
  const isEmpty = await isDirectoryEmpty(global.target);
  if (!isEmpty) {
    const emptyRes = await _prompts2.default.call(void 0, {
      type: "confirm",
      name: "empty",
      message: "\u975E\u7A7A\u76EE\u5F55\uFF0C\u7EE7\u7EED\u64CD\u4F5C\u5C06\u4F1A\u5220\u9664\u73B0\u6709\u6240\u6709\u6587\u4EF6",
      initial: true
    });
    answers.clear = emptyRes.empty;
    if (!emptyRes.empty) {
      console.log("\u6B22\u8FCE\u518D\u6B21\u4F7F\u7528@ldesign/cli");
      return;
    }
  }
  await clearTargetFiles(answers, global);
  const gitRes = await _prompts2.default.call(void 0, {
    type: "confirm",
    name: "isGit",
    message: "\u662F\u5426\u8981\u4F7F\u7528git\uFF1F",
    initial: true
  });
  if (!type) {
    const res = await _prompts2.default.call(void 0, {
      type: "select",
      name: "package",
      message: "\u8BF7\u9009\u62E9\u8981\u521B\u5EFA\u7684\u9879\u76EE\u7C7B\u578B\uFF01",
      hint: "\u8BF7\u6309\u4E0A\u4E0B\u952E\u9009\u62E9!",
      warn: "\u6587\u6863\u7CFB\u7EDF\u6682\u672A\u4E0A\u7EBF!",
      float: true,
      choices: [{
        title: "\u684C\u9762\u7AEFvue3\u9879\u76EE\u6A21\u677F",
        value: "desktop-vue3"
      }, {
        title: "\u6587\u6863\u7CFB\u7EDF\u6A21\u677F",
        value: "doc"
      }],
      initial: 0
    });
    answers.pkg = res.package;
    global.source = _path.join.call(void 0, __dirname, "..", "src", "template", answers.pkg);
  }
  const tsRes = await _prompts2.default.call(void 0, {
    type: "confirm",
    name: "isTs",
    message: "\u9700\u8981\u652F\u6301typescript\u5417\uFF1F",
    initial: false
  });
  const eslintRes = await _prompts2.default.call(void 0, {
    type: "confirm",
    name: "isEslint",
    message: "\u9700\u8981\u5F00\u542Feslint\u5417\uFF1F",
    initial: false
  });
  answers.typescript = tsRes.isTs;
  answers.eslint = eslintRes.isEslint;
  answers.git = gitRes.isGit;
  await generateLicence(answers, global);
  await copyTemplateToTarget(answers, global);
  await updateProjectFileContent(answers, global);
  if (answers.git) {
    const remoteRepo = await createRepository(answers, global);
    await initLocalGit(remoteRepo);
  }
  console.log("\u5F00\u59CB\u5B89\u88C5\u4F9D\u8D56");
  await installDepedencies();
}

// src/utils/checkJava.ts
var _child_process = require('child_process');
function checkJava() {
  return new Promise((resolve) => {
    const cmd = _child_process.spawn.call(void 0, "java", ["-version"]);
    cmd.on("error", () => {
      resolve("\u68C0\u6D4B\u5230\u672C\u673A\u6CA1\u6709Java\u73AF\u5883\uFF0C\u5C06\u65E0\u6CD5\u751F\u6210jar\u5305\uFF01");
    });
    cmd.stderr.on("data", (data) => {
      resolve("\u68C0\u6D4B\u5230\u672C\u673A\u6CA1\u6709Java\u73AF\u5883\uFF0C\u5C06\u65E0\u6CD5\u751F\u6210jar\u5305\uFF01");
    });
    cmd.stdout.on("data", (data) => {
      resolve("\u68C0\u6D4B\u5230\u672C\u673A\u6CA1\u6709Java\u73AF\u5883\uFF0C\u5C06\u65E0\u6CD5\u751F\u6210jar\u5305\uFF01");
    });
    cmd.on("close", (code) => {
      if (code === 0)
        resolve(true);
      else
        resolve("\u68C0\u6D4B\u5230\u672C\u673A\u6CA1\u6709Java\u73AF\u5883\uFF0C\u5C06\u65E0\u6CD5\u751F\u6210jar\u5305\uFF01");
    });
  });
}

// src/index.ts
(async () => {
  dotenv.default.config({
    path: getEnvPath()
  });
  const cli = _cac.cac.call(void 0, "ldesign").version(version).help();
  cli.command("init [type]", "\u521D\u59CB\u5316\u4E00\u4E2A\u9879\u76EE").action(async (type) => {
    welcome();
    const isJava = await checkJava();
    if (typeof isJava !== "string" && isJava) {
      console.log("java\u5DF2\u5B89\u88C5");
    } else {
      console.log(`${time()}${_chalk2.default.red(isJava)}`);
    }
    initProject(type);
  });
  cli.command("install", "\u5B89\u88C5\u9879\u76EE\u4F9D\u8D56\uFF01").action(installDepedencies);
  cli.command("token", "\u8BBE\u7F6Egit\u7684token").action(resolveGitToken);
  cli.command("host", "\u8BBE\u7F6Egit\u7684host\u5730\u5740\uFF0C\u4E00\u822C\u60C5\u51B5\u65E0\u9700\u4FEE\u6539\uFF01").action(resolveGitHost);
  cli.command("dev", "\u542F\u52A8\u9879\u76EE\uFF01").action(startDevProject);
  cli.command("config [name]", "\u66F4\u6539\u914D\u7F6E").action(setConfig);
  cli.command("depends", "\u67E5\u770B\u9879\u76EE\u4F9D\u8D56\u4FE1\u606F").action(getDependencies);
  cli.parse();
})();
//# sourceMappingURL=index.js.map