liuliu_cli 1.0.3 → 1.0.5
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/README.md +20 -52
- package/bin/command/create.d.ts +3 -0
- package/bin/command/create.d.ts.map +1 -1
- package/bin/index.d.ts +1 -1
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +1 -1
- package/dist/command/create.d.ts +3 -0
- package/dist/command/create.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -51,55 +51,23 @@ npm run build
|
|
|
51
51
|
2. `npm version major` (大版本,如 1.0.2 -> 2.0.0)
|
|
52
52
|
2. 发布新版本
|
|
53
53
|
1. `npm publish`
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
3. **检查 bin 文件是否存在**
|
|
77
|
-
```bash
|
|
78
|
-
# 查看全局安装的 bin 文件
|
|
79
|
-
npm list -g liuliu_cli
|
|
80
|
-
|
|
81
|
-
# 或者直接检查文件
|
|
82
|
-
# Windows: C:\Users\你的用户名\AppData\Roaming\npm\liuliu.cmd
|
|
83
|
-
# 或: C:\Users\你的用户名\AppData\Roaming\npm\node_modules\liuliu_cli\bin\index.js
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
4. **清除 npm 缓存**
|
|
87
|
-
```bash
|
|
88
|
-
npm cache clean --force
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
5. **检查文件权限(Windows)**
|
|
92
|
-
- 确保 bin/index.js 文件有执行权限
|
|
93
|
-
- 如果使用 Git,确保文件没有被 Git 修改换行符(CRLF vs LF)
|
|
94
|
-
|
|
95
|
-
6. **验证打包文件**
|
|
96
|
-
```bash
|
|
97
|
-
# 在项目目录下
|
|
98
|
-
npm run build
|
|
99
|
-
node bin/index.js -v # 应该能正常输出版本号
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
如果以上方法都无法解决,请检查:
|
|
103
|
-
- package.json 中的 `bin` 配置是否正确指向 `bin/index.js`
|
|
104
|
-
- `bin/index.js` 文件第一行是否有正确的 shebang: `#!/usr/bin/env node`
|
|
105
|
-
- `files` 字段是否包含 `bin` 目录
|
|
54
|
+
3. 时间长了发布的话就需要,重新登录
|
|
55
|
+
1. npm logout
|
|
56
|
+
2. npm login
|
|
57
|
+
|
|
58
|
+
### 配置讲解
|
|
59
|
+
|
|
60
|
+
1. 这个文件用这个Liuliu这个命令,files,只上传这些文件到npm
|
|
61
|
+
|
|
62
|
+
``` js
|
|
63
|
+
"bin": {
|
|
64
|
+
"liuliu": "bin/index.js"
|
|
65
|
+
},
|
|
66
|
+
"files": [
|
|
67
|
+
"dist",
|
|
68
|
+
"bin",
|
|
69
|
+
"README.md"
|
|
70
|
+
]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
2.
|
package/bin/command/create.d.ts
CHANGED
|
@@ -8,5 +8,8 @@ export declare function isOverwrite(fileName: string): Promise<boolean> & {
|
|
|
8
8
|
cancel: () => void;
|
|
9
9
|
};
|
|
10
10
|
export declare const templateList: Map<string, TemplateInfo>;
|
|
11
|
+
export declare const getNpmInfo: (name: string) => Promise<{}>;
|
|
12
|
+
export declare const getNpmLastestVersion: (name: string) => Promise<any>;
|
|
13
|
+
export declare const checkVersion: (name: string, version: string) => Promise<boolean>;
|
|
11
14
|
export declare function create(projectName?: string): Promise<void>;
|
|
12
15
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/command/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/command/create.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM;;EAS3C;AAED,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAajD,CAAA;AAEF,eAAO,MAAM,UAAU,GAAU,MAAM,MAAM,gBAU5C,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,iBAItD,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,EAAE,SAAS,MAAM,qBAS/D,CAAA;AAED,wBAAsB,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,iBAiDhD"}
|
package/bin/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/bin/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/bin/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("commander"),o=require("path"),r=require("fs-extra"),t=require("@inquirer/prompts"),
|
|
2
|
+
"use strict";var e=require("commander"),o=require("path"),r=require("fs-extra"),t=require("lodash"),n=require("@inquirer/prompts"),l=require("simple-git"),s=require("progress-estimator"),i=require("axios"),c="1.0.3";const a=(e=0)=>o=>`[${o+e}m`,g=(e=0)=>o=>`[${38+e};5;${o}m`,u=(e=0)=>(o,r,t)=>`[${38+e};2;${o};${r};${t}m`,h={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(h.modifier);Object.keys(h.color),Object.keys(h.bgColor);const b=function(){const e=new Map;for(const[o,r]of Object.entries(h)){for(const[o,t]of Object.entries(r))h[o]={open:`[${t[0]}m`,close:`[${t[1]}m`},r[o]=h[o],e.set(t[0],t[1]);Object.defineProperty(h,o,{value:r,enumerable:!1})}return Object.defineProperty(h,"codes",{value:e,enumerable:!1}),h.color.close="[39m",h.bgColor.close="[49m",h.color.ansi=a(),h.color.ansi256=g(),h.color.ansi16m=u(),h.bgColor.ansi=a(10),h.bgColor.ansi256=g(10),h.bgColor.ansi16m=u(10),Object.defineProperties(h,{rgbToAnsi256:{value:(e,o,r)=>e===o&&o===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(o/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){const o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!o)return[0,0,0];let[r]=o;3===r.length&&(r=[...r].map(e=>e+e).join(""));const t=Number.parseInt(r,16);return[t>>16&255,t>>8&255,255&t]},enumerable:!1},hexToAnsi256:{value:e=>h.rgbToAnsi256(...h.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let o,r,t;if(e>=232)o=(10*(e-232)+8)/255,r=o,t=o;else{const n=(e-=16)%36;o=Math.floor(e/36)/5,r=Math.floor(n/6)/5,t=n%6/5}const n=2*Math.max(o,r,t);if(0===n)return 30;let l=30+(Math.round(t)<<2|Math.round(r)<<1|Math.round(o));return 2===n&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(e,o,r)=>h.ansi256ToAnsi(h.rgbToAnsi256(e,o,r)),enumerable:!1},hexToAnsi:{value:e=>h.ansi256ToAnsi(h.hexToAnsi256(e)),enumerable:!1}}),h}(),m=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),d=0!==m&&{level:m},p={stdout:d,stderr:d};function v(e,o,r){let t=e.indexOf(o);if(-1===t)return e;const n=o.length;let l=0,s="";do{s+=e.slice(l,t)+o+r,l=t+n,t=e.indexOf(o,l)}while(-1!==t);return s+=e.slice(l),s}const{stdout:y,stderr:f}=p,w=Symbol("GENERATOR"),O=Symbol("STYLER"),C=Symbol("IS_EMPTY"),T=["ansi","ansi","ansi256","ansi16m"],B=Object.create(null),A=e=>{const o=(...e)=>e.join(" ");return((e,o={})=>{if(o.level&&!(Number.isInteger(o.level)&&o.level>=0&&o.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=y?y.level:0;e.level=void 0===o.level?r:o.level})(o,e),Object.setPrototypeOf(o,R.prototype),o};function R(e){return A(e)}Object.setPrototypeOf(R.prototype,Function.prototype);for(const[e,o]of Object.entries(b))B[e]={get(){const r=$(this,M(o.open,o.close,this[O]),this[C]);return Object.defineProperty(this,e,{value:r}),r}};B.visible={get(){const e=$(this,this[O],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const j=(e,o,r,...t)=>"rgb"===e?"ansi16m"===o?b[r].ansi16m(...t):"ansi256"===o?b[r].ansi256(b.rgbToAnsi256(...t)):b[r].ansi(b.rgbToAnsi(...t)):"hex"===e?j("rgb",o,r,...b.hexToRgb(...t)):b[r][e](...t),x=["rgb","hex","ansi256"];for(const e of x){B[e]={get(){const{level:o}=this;return function(...r){const t=M(j(e,T[o],"color",...r),b.color.close,this[O]);return $(this,t,this[C])}}};B["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:o}=this;return function(...r){const t=M(j(e,T[o],"bgColor",...r),b.bgColor.close,this[O]);return $(this,t,this[C])}}}}const k=Object.defineProperties(()=>{},{...B,level:{enumerable:!0,get(){return this[w].level},set(e){this[w].level=e}}}),M=(e,o,r)=>{let t,n;return void 0===r?(t=e,n=o):(t=r.openAll+e,n=o+r.closeAll),{open:e,close:o,openAll:t,closeAll:n,parent:r}},$=(e,o,r)=>{const t=(...e)=>S(t,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(t,k),t[w]=e,t[O]=o,t[C]=r,t},S=(e,o)=>{if(e.level<=0||!o)return e[C]?"":o;let r=e[O];if(void 0===r)return o;const{openAll:t,closeAll:n}=r;if(o.includes(""))for(;void 0!==r;)o=v(o,r.close,r.open),r=r.parent;const l=o.indexOf("\n");return-1!==l&&(o=function(e,o,r,t){let n=0,l="";do{const s="\r"===e[t-1];l+=e.slice(n,s?t-1:t)+o+(s?"\r\n":"\n")+r,n=t+1,t=e.indexOf("\n",n)}while(-1!==t);return l+=e.slice(n),l}(o,n,t,l)),t+o+n};Object.defineProperties(R.prototype,B);const P=R();R({level:f?f.level:0}),process.env.FORCE_COLOR||(process.env.FORCE_COLOR="1"),P.level=3;const E=s({spinner:{interval:100,frames:["-","+","-"].map(e=>P.green(e))}});process.cwd();process.env.FORCE_COLOR||(process.env.FORCE_COLOR="1"),P.level=3;const _=new Map([["Vite-Vue3-Typescript-template",{name:"Vite-Vue-Type",downloadUrl:"https://gitee.com/sohucw/admin-pro.git",description:"Vue3技术开发模板1",branch:"dev11"}],["Vite-Vue3-Typescript-template2",{name:"Vite-Vue-Type",downloadUrl:"git@gitee.com:sohucw/admin-pro.git",description:"Vue3技术开发模板2",branch:"dev10"}]]),L=async e=>{const{data:o}=await(async e=>{const o=`https://registry.npmjs.org/${e}`;let r={};try{r=await i.get(o)}catch(e){console.log(e)}return console.log(r),r})(e);return console.info("npm info",o),o["dist-tags"].latest};async function V(e){const s=Array.from(_).map(e=>{const[o,r]=e;return{name:o,value:o,description:r.description}});e||(e=await n.input({message:"请输入项目名称"}));const i=o.resolve(process.cwd(),e);if(r.existsSync(i)){if(!await(a=e,console.warn(`${a}文件夹存在`),n.select({message:"是否覆盖?",choices:[{name:"覆盖",value:!0},{name:"取消",value:!1}]})))return;await r.remove(i)}var a;await(async(e,o)=>{const r=await L(e),n=t.gt(r,o);return n&&(console.log(`检查到liuliu最新版本:${P.blackBright(r)},当前版本是:${o}`),console.log(`可使用:${P.yellow("npm install liuliu_cli@latest")},或者使用:${P.yellow("dawei update")}更新`)),n})("liuliu_cli",c);const g=await n.select({message:"请选择模板",choices:s}),u=_.get(g);if(u)try{await(async(e,o,r)=>{const t=l();try{await E(t.clone(e,o,r),"代码下载中",{estimate:7e3}),console.log(),console.log(P.green("代码下载成功")),console.log(P.blackBright("========================")),console.log(P.blackBright("==欢迎使用 DALIU脚手架===")),console.log(P.blackBright("========================")),console.log(),console.log(),console.log(P.blackBright("====使用npm install安装依赖========="))}catch(e){throw console.error(P.red("下载失败")),e?.message?.includes("Host key verification failed")?(console.error(P.yellow("\n提示:SSH 主机密钥验证失败")),console.error(P.yellow("解决方案:")),console.error(P.yellow("1. 如果使用 SSH URL,请先配置 SSH 密钥:")),console.error(P.yellow(' ssh-keygen -t rsa -C "your_email@example.com"')),console.error(P.yellow(" 然后将公钥添加到 Git 服务器")),console.error(P.yellow("2. 或者使用 HTTPS URL(需要输入用户名密码)")),console.error(P.yellow("3. 临时解决:手动添加主机密钥")),console.error(P.yellow(" ssh-keyscan gitee.com >> ~/.ssh/known_hosts"))):e?.message?.includes("Could not read from remote repository")?(console.error(P.yellow("\n提示:无法访问远程仓库")),console.error(P.yellow("请检查:")),console.error(P.yellow("1. 仓库地址是否正确")),console.error(P.yellow("2. 是否有访问权限")),console.error(P.yellow("3. 网络连接是否正常"))):(console.error(P.red("\n错误详情:")),console.error(e)),e}})(u.downloadUrl,e,["-b",u.branch])}catch(e){process.exit(1)}else console.error(P.red("未找到模板信息")),process.exit(1)}process.env.FORCE_COLOR||(process.env.FORCE_COLOR="1"),P.level=3;const q=new e.Command("liuliu");q.version(c,"-v,--version"),q.command("create").description("创建一个新项目").argument("[name]","项目名称").action(async e=>{V(e)}),q.parse();
|
package/dist/command/create.d.ts
CHANGED
|
@@ -8,5 +8,8 @@ export declare function isOverwrite(fileName: string): Promise<boolean> & {
|
|
|
8
8
|
cancel: () => void;
|
|
9
9
|
};
|
|
10
10
|
export declare const templateList: Map<string, TemplateInfo>;
|
|
11
|
+
export declare const getNpmInfo: (name: string) => Promise<{}>;
|
|
12
|
+
export declare const getNpmLastestVersion: (name: string) => Promise<any>;
|
|
13
|
+
export declare const checkVersion: (name: string, version: string) => Promise<boolean>;
|
|
11
14
|
export declare function create(projectName?: string): Promise<void>;
|
|
12
15
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/command/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/command/create.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM;;EAS3C;AAED,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAajD,CAAA;AAEF,eAAO,MAAM,UAAU,GAAU,MAAM,MAAM,gBAU5C,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,iBAItD,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,EAAE,SAAS,MAAM,qBAS/D,CAAA;AAED,wBAAsB,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,iBAiDhD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("commander"),o=require("path"),r=require("fs-extra"),t=require("@inquirer/prompts"),
|
|
1
|
+
"use strict";var e=require("commander"),o=require("path"),r=require("fs-extra"),t=require("lodash"),n=require("@inquirer/prompts"),l=require("simple-git"),s=require("progress-estimator"),i=require("axios"),c="1.0.3";const a=(e=0)=>o=>`[${o+e}m`,g=(e=0)=>o=>`[${38+e};5;${o}m`,u=(e=0)=>(o,r,t)=>`[${38+e};2;${o};${r};${t}m`,h={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(h.modifier);Object.keys(h.color),Object.keys(h.bgColor);const b=function(){const e=new Map;for(const[o,r]of Object.entries(h)){for(const[o,t]of Object.entries(r))h[o]={open:`[${t[0]}m`,close:`[${t[1]}m`},r[o]=h[o],e.set(t[0],t[1]);Object.defineProperty(h,o,{value:r,enumerable:!1})}return Object.defineProperty(h,"codes",{value:e,enumerable:!1}),h.color.close="[39m",h.bgColor.close="[49m",h.color.ansi=a(),h.color.ansi256=g(),h.color.ansi16m=u(),h.bgColor.ansi=a(10),h.bgColor.ansi256=g(10),h.bgColor.ansi16m=u(10),Object.defineProperties(h,{rgbToAnsi256:{value:(e,o,r)=>e===o&&o===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(o/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){const o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!o)return[0,0,0];let[r]=o;3===r.length&&(r=[...r].map(e=>e+e).join(""));const t=Number.parseInt(r,16);return[t>>16&255,t>>8&255,255&t]},enumerable:!1},hexToAnsi256:{value:e=>h.rgbToAnsi256(...h.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let o,r,t;if(e>=232)o=(10*(e-232)+8)/255,r=o,t=o;else{const n=(e-=16)%36;o=Math.floor(e/36)/5,r=Math.floor(n/6)/5,t=n%6/5}const n=2*Math.max(o,r,t);if(0===n)return 30;let l=30+(Math.round(t)<<2|Math.round(r)<<1|Math.round(o));return 2===n&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(e,o,r)=>h.ansi256ToAnsi(h.rgbToAnsi256(e,o,r)),enumerable:!1},hexToAnsi:{value:e=>h.ansi256ToAnsi(h.hexToAnsi256(e)),enumerable:!1}}),h}(),m=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),d=0!==m&&{level:m},p={stdout:d,stderr:d};function v(e,o,r){let t=e.indexOf(o);if(-1===t)return e;const n=o.length;let l=0,s="";do{s+=e.slice(l,t)+o+r,l=t+n,t=e.indexOf(o,l)}while(-1!==t);return s+=e.slice(l),s}const{stdout:y,stderr:f}=p,w=Symbol("GENERATOR"),O=Symbol("STYLER"),C=Symbol("IS_EMPTY"),T=["ansi","ansi","ansi256","ansi16m"],B=Object.create(null),A=e=>{const o=(...e)=>e.join(" ");return((e,o={})=>{if(o.level&&!(Number.isInteger(o.level)&&o.level>=0&&o.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=y?y.level:0;e.level=void 0===o.level?r:o.level})(o,e),Object.setPrototypeOf(o,R.prototype),o};function R(e){return A(e)}Object.setPrototypeOf(R.prototype,Function.prototype);for(const[e,o]of Object.entries(b))B[e]={get(){const r=$(this,M(o.open,o.close,this[O]),this[C]);return Object.defineProperty(this,e,{value:r}),r}};B.visible={get(){const e=$(this,this[O],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const j=(e,o,r,...t)=>"rgb"===e?"ansi16m"===o?b[r].ansi16m(...t):"ansi256"===o?b[r].ansi256(b.rgbToAnsi256(...t)):b[r].ansi(b.rgbToAnsi(...t)):"hex"===e?j("rgb",o,r,...b.hexToRgb(...t)):b[r][e](...t),x=["rgb","hex","ansi256"];for(const e of x){B[e]={get(){const{level:o}=this;return function(...r){const t=M(j(e,T[o],"color",...r),b.color.close,this[O]);return $(this,t,this[C])}}};B["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:o}=this;return function(...r){const t=M(j(e,T[o],"bgColor",...r),b.bgColor.close,this[O]);return $(this,t,this[C])}}}}const k=Object.defineProperties(()=>{},{...B,level:{enumerable:!0,get(){return this[w].level},set(e){this[w].level=e}}}),M=(e,o,r)=>{let t,n;return void 0===r?(t=e,n=o):(t=r.openAll+e,n=o+r.closeAll),{open:e,close:o,openAll:t,closeAll:n,parent:r}},$=(e,o,r)=>{const t=(...e)=>S(t,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(t,k),t[w]=e,t[O]=o,t[C]=r,t},S=(e,o)=>{if(e.level<=0||!o)return e[C]?"":o;let r=e[O];if(void 0===r)return o;const{openAll:t,closeAll:n}=r;if(o.includes(""))for(;void 0!==r;)o=v(o,r.close,r.open),r=r.parent;const l=o.indexOf("\n");return-1!==l&&(o=function(e,o,r,t){let n=0,l="";do{const s="\r"===e[t-1];l+=e.slice(n,s?t-1:t)+o+(s?"\r\n":"\n")+r,n=t+1,t=e.indexOf("\n",n)}while(-1!==t);return l+=e.slice(n),l}(o,n,t,l)),t+o+n};Object.defineProperties(R.prototype,B);const P=R();R({level:f?f.level:0}),process.env.FORCE_COLOR||(process.env.FORCE_COLOR="1"),P.level=3;const E=s({spinner:{interval:100,frames:["-","+","-"].map(e=>P.green(e))}});process.cwd();process.env.FORCE_COLOR||(process.env.FORCE_COLOR="1"),P.level=3;const _=new Map([["Vite-Vue3-Typescript-template",{name:"Vite-Vue-Type",downloadUrl:"https://gitee.com/sohucw/admin-pro.git",description:"Vue3技术开发模板1",branch:"dev11"}],["Vite-Vue3-Typescript-template2",{name:"Vite-Vue-Type",downloadUrl:"git@gitee.com:sohucw/admin-pro.git",description:"Vue3技术开发模板2",branch:"dev10"}]]),L=async e=>{const{data:o}=await(async e=>{const o=`https://registry.npmjs.org/${e}`;let r={};try{r=await i.get(o)}catch(e){console.log(e)}return console.log(r),r})(e);return console.info("npm info",o),o["dist-tags"].latest};async function V(e){const s=Array.from(_).map(e=>{const[o,r]=e;return{name:o,value:o,description:r.description}});e||(e=await n.input({message:"请输入项目名称"}));const i=o.resolve(process.cwd(),e);if(r.existsSync(i)){if(!await(a=e,console.warn(`${a}文件夹存在`),n.select({message:"是否覆盖?",choices:[{name:"覆盖",value:!0},{name:"取消",value:!1}]})))return;await r.remove(i)}var a;await(async(e,o)=>{const r=await L(e),n=t.gt(r,o);return n&&(console.log(`检查到liuliu最新版本:${P.blackBright(r)},当前版本是:${o}`),console.log(`可使用:${P.yellow("npm install liuliu_cli@latest")},或者使用:${P.yellow("dawei update")}更新`)),n})("liuliu_cli",c);const g=await n.select({message:"请选择模板",choices:s}),u=_.get(g);if(u)try{await(async(e,o,r)=>{const t=l();try{await E(t.clone(e,o,r),"代码下载中",{estimate:7e3}),console.log(),console.log(P.green("代码下载成功")),console.log(P.blackBright("========================")),console.log(P.blackBright("==欢迎使用 DALIU脚手架===")),console.log(P.blackBright("========================")),console.log(),console.log(),console.log(P.blackBright("====使用npm install安装依赖========="))}catch(e){throw console.error(P.red("下载失败")),e?.message?.includes("Host key verification failed")?(console.error(P.yellow("\n提示:SSH 主机密钥验证失败")),console.error(P.yellow("解决方案:")),console.error(P.yellow("1. 如果使用 SSH URL,请先配置 SSH 密钥:")),console.error(P.yellow(' ssh-keygen -t rsa -C "your_email@example.com"')),console.error(P.yellow(" 然后将公钥添加到 Git 服务器")),console.error(P.yellow("2. 或者使用 HTTPS URL(需要输入用户名密码)")),console.error(P.yellow("3. 临时解决:手动添加主机密钥")),console.error(P.yellow(" ssh-keyscan gitee.com >> ~/.ssh/known_hosts"))):e?.message?.includes("Could not read from remote repository")?(console.error(P.yellow("\n提示:无法访问远程仓库")),console.error(P.yellow("请检查:")),console.error(P.yellow("1. 仓库地址是否正确")),console.error(P.yellow("2. 是否有访问权限")),console.error(P.yellow("3. 网络连接是否正常"))):(console.error(P.red("\n错误详情:")),console.error(e)),e}})(u.downloadUrl,e,["-b",u.branch])}catch(e){process.exit(1)}else console.error(P.red("未找到模板信息")),process.exit(1)}process.env.FORCE_COLOR||(process.env.FORCE_COLOR="1"),P.level=3;const q=new e.Command("liuliu");q.version(c,"-v,--version"),q.command("create").description("创建一个新项目").argument("[name]","项目名称").action(async e=>{V(e)}),q.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "liuliu_cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rollup -c rollup.config.js --bundleConfigAsCjs"
|
|
6
6
|
},
|
|
@@ -10,20 +10,23 @@
|
|
|
10
10
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
11
11
|
"@rollup/plugin-terser": "^0.4.4",
|
|
12
12
|
"@types/fs-extra": "^11.0.4",
|
|
13
|
+
"@types/lodash": "^4.17.21",
|
|
13
14
|
"@types/node": "^25.0.3",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
15
|
+
"axios": "^1.13.2",
|
|
16
|
+
"loadsh": "^0.0.4",
|
|
16
17
|
"rollup": "^4.54.0",
|
|
17
18
|
"rollup-plugin-node-externals": "^8.1.2",
|
|
18
19
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
19
|
-
"simple-git": "^3.30.0",
|
|
20
20
|
"tslib": "^2.8.1",
|
|
21
21
|
"typescript": "^5.9.3"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@inquirer/prompts": "^7.10.1",
|
|
25
25
|
"chalk": "^5.6.2",
|
|
26
|
-
"
|
|
26
|
+
"commander": "^14.0.2",
|
|
27
|
+
"fs-extra": "^11.3.3",
|
|
28
|
+
"progress-estimator": "^0.3.1",
|
|
29
|
+
"simple-git": "^3.30.0"
|
|
27
30
|
},
|
|
28
31
|
"author": "liuliu",
|
|
29
32
|
"bin": {
|