@xuranxys/cli 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -20
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ const node_readline = __toESM(require("node:readline"));
33
33
  const node_util = __toESM(require("node:util"));
34
34
  const fs = __toESM(require("fs"));
35
35
  const create_tsdown = __toESM(require("create-tsdown"));
36
+ const path = __toESM(require("path"));
36
37
 
37
38
  //#region node_modules/commander/lib/error.js
38
39
  var require_error = /* @__PURE__ */ __commonJS({ "node_modules/commander/lib/error.js": ((exports) => {
@@ -1064,7 +1065,7 @@ var require_suggestSimilar = /* @__PURE__ */ __commonJS({ "node_modules/commande
1064
1065
  var require_command = /* @__PURE__ */ __commonJS({ "node_modules/commander/lib/command.js": ((exports) => {
1065
1066
  const EventEmitter = require("node:events").EventEmitter;
1066
1067
  const childProcess = require("node:child_process");
1067
- const path = require("node:path");
1068
+ const path$2 = require("node:path");
1068
1069
  const fs$1 = require("node:fs");
1069
1070
  const process$12 = require("node:process");
1070
1071
  const { Argument: Argument$2, humanReadableArgName } = require_argument();
@@ -1989,9 +1990,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1989
1990
  ".cjs"
1990
1991
  ];
1991
1992
  function findFile(baseDir, baseName) {
1992
- const localBin = path.resolve(baseDir, baseName);
1993
+ const localBin = path$2.resolve(baseDir, baseName);
1993
1994
  if (fs$1.existsSync(localBin)) return localBin;
1994
- if (sourceExt.includes(path.extname(baseName))) return void 0;
1995
+ if (sourceExt.includes(path$2.extname(baseName))) return void 0;
1995
1996
  const foundExt = sourceExt.find((ext) => fs$1.existsSync(`${localBin}${ext}`));
1996
1997
  if (foundExt) return `${localBin}${foundExt}`;
1997
1998
  return void 0;
@@ -2007,17 +2008,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2007
2008
  } catch {
2008
2009
  resolvedScriptPath = this._scriptPath;
2009
2010
  }
2010
- executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
2011
+ executableDir = path$2.resolve(path$2.dirname(resolvedScriptPath), executableDir);
2011
2012
  }
2012
2013
  if (executableDir) {
2013
2014
  let localFile = findFile(executableDir, executableFile);
2014
2015
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2015
- const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
2016
+ const legacyName = path$2.basename(this._scriptPath, path$2.extname(this._scriptPath));
2016
2017
  if (legacyName !== this._name) localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
2017
2018
  }
2018
2019
  executableFile = localFile || executableFile;
2019
2020
  }
2020
- launchWithNode = sourceExt.includes(path.extname(executableFile));
2021
+ launchWithNode = sourceExt.includes(path$2.extname(executableFile));
2021
2022
  let proc;
2022
2023
  if (process$12.platform !== "win32") if (launchWithNode) {
2023
2024
  args.unshift(executableFile);
@@ -2791,7 +2792,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2791
2792
  * @return {Command}
2792
2793
  */
2793
2794
  nameFromFilename(filename) {
2794
- this._name = path.basename(filename, path.extname(filename));
2795
+ this._name = path$2.basename(filename, path$2.extname(filename));
2795
2796
  return this;
2796
2797
  }
2797
2798
  /**
@@ -2805,9 +2806,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2805
2806
  * @param {string} [path]
2806
2807
  * @return {(string|null|Command)}
2807
2808
  */
2808
- executableDir(path$1) {
2809
- if (path$1 === void 0) return this._executableDir;
2810
- this._executableDir = path$1;
2809
+ executableDir(path$3) {
2810
+ if (path$3 === void 0) return this._executableDir;
2811
+ this._executableDir = path$3;
2811
2812
  return this;
2812
2813
  }
2813
2814
  /**
@@ -5825,15 +5826,15 @@ var require_route = /* @__PURE__ */ __commonJS({ "node_modules/color-convert/rou
5825
5826
  };
5826
5827
  }
5827
5828
  function wrapConversion(toModel, graph) {
5828
- const path$1 = [graph[toModel].parent, toModel];
5829
+ const path$3 = [graph[toModel].parent, toModel];
5829
5830
  let fn = conversions$1[graph[toModel].parent][toModel];
5830
5831
  let cur = graph[toModel].parent;
5831
5832
  while (graph[cur].parent) {
5832
- path$1.unshift(graph[cur].parent);
5833
+ path$3.unshift(graph[cur].parent);
5833
5834
  fn = link(conversions$1[graph[cur].parent][cur], fn);
5834
5835
  cur = graph[cur].parent;
5835
5836
  }
5836
- fn.conversion = path$1;
5837
+ fn.conversion = path$3;
5837
5838
  return fn;
5838
5839
  }
5839
5840
  module.exports = function(fromModel) {
@@ -12732,12 +12733,15 @@ function validateProjectName(name) {
12732
12733
 
12733
12734
  //#endregion
12734
12735
  //#region libs/utils.ts
12735
- function jsonModify(path$1, needed) {
12736
- (0, fs.readFile)(path$1, "utf-8", (err, data) => {
12736
+ function resolveCliPath(...paths) {
12737
+ return path.default.join(__dirname, "../", ...paths);
12738
+ }
12739
+ function jsonModify(path$3, needed) {
12740
+ (0, fs.readFile)(path$3, "utf-8", (err, data) => {
12737
12741
  if (err) throw err;
12738
12742
  const json = JSON.parse(data);
12739
12743
  for (const key in needed) if (json[key]) json[key] = needed[key];
12740
- (0, fs.writeFile)(path$1, JSON.stringify(json, null, 2), (err$1) => {
12744
+ (0, fs.writeFile)(path$3, JSON.stringify(json, null, 2), (err$1) => {
12741
12745
  if (err$1) throw err$1;
12742
12746
  });
12743
12747
  });
@@ -12761,10 +12765,10 @@ async function createProject(projectName) {
12761
12765
  process.argv.push("--interactive");
12762
12766
  await require("create-vite");
12763
12767
  } else await (0, create_tsdown.create)(projectName, {});
12764
- (0, fs.copyFile)("config/prettier/.prettierrc.json", `${projectName}/.prettierrc.json`, (err) => {
12768
+ (0, fs.copyFile)(resolveCliPath("config/prettier/.prettierrc.json"), `${projectName}/.prettierrc.json`, (err) => {
12765
12769
  if (err) throw err;
12766
12770
  });
12767
- (0, fs.copyFile)("config/prettier/.prettierignore", `${projectName}/.prettierignore`, (err) => {
12771
+ (0, fs.copyFile)(resolveCliPath("config/prettier/.prettierrc.json"), `${projectName}/.prettierignore`, (err) => {
12768
12772
  if (err) throw err;
12769
12773
  });
12770
12774
  jsonModify(`${projectName}/package.json`, { devDependencies: { prettier: "^3.8.2" } });
@@ -12779,7 +12783,7 @@ async function createProject(projectName) {
12779
12783
  //#endregion
12780
12784
  //#region bin/index.ts
12781
12785
  const program = new Command();
12782
- program.version("1.0.3").description("A CLI for xuran").name("xuran");
12786
+ program.version("1.0.4").description("A CLI for xuran").name("xuran");
12783
12787
  program.command("list").description("List all available templates").action(() => {
12784
12788
  console.log("Available templates:");
12785
12789
  Object.entries(templates).forEach(([_, { name, description }]) => {
@@ -12799,7 +12803,7 @@ program.command("upgrade").description("Upgrade CLI to the latest version").acti
12799
12803
  console.log(source_default.blue.bold(`\n🔄 Checking for updates...\n`));
12800
12804
  try {
12801
12805
  const { execSync } = await import("child_process");
12802
- const currentVersion = "1.0.3";
12806
+ const currentVersion = "1.0.4";
12803
12807
  const pkgName = "@xuranxys/cli";
12804
12808
  const latestVersion = execSync(`npm view ${pkgName} version`, { encoding: "utf-8" }).trim();
12805
12809
  if (latestVersion > currentVersion) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuranxys/cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "author": "xuran",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,6 +44,7 @@
44
44
  ]
45
45
  },
46
46
  "scripts": {
47
+ "dev": "bun ./dist/index.js",
47
48
  "build": "tsdown -c tsdown.config.ts",
48
49
  "watch": "tsdown -c tsdown.config.ts -w",
49
50
  "format": "prettier \"./src/**/*.{js,jsx,ts,tsx,vue}\" --write",