create-done-coding 0.2.12-alpha.1 → 0.2.13

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 CHANGED
@@ -1,5 +1,5 @@
1
- # create-done-coding
2
-
3
- ```ts
4
- pnpm create done-coding
5
- ```
1
+ # create-done-coding
2
+
3
+ ```ts
4
+ pnpm create done-coding
5
+ ```
package/dist/index.js CHANGED
@@ -1,34 +1,6 @@
1
- "use strict";const ve=require("yargs"),ue=require("util"),x=require("path"),q=require("fs"),be=require("assert"),Ze=require("url"),v=require("node:fs"),ne=require("node:path"),L=require("chalk"),G=require("prompts"),ye=require("node:child_process");var Ee=typeof document<"u"?document.currentScript:null;class Q extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,Q)}}function Se(){return Xe()?0:1}function Xe(){return ke()&&!process.defaultApp}function ke(){return!!process.versions.electron}function xe(i){return i.slice(Se()+1)}function et(){return process.argv[Se()]}/**
2
- * @license
3
- * Copyright (c) 2016, Contributors
4
- * SPDX-License-Identifier: ISC
5
- */function H(i){if(i!==i.toLowerCase()&&i!==i.toUpperCase()||(i=i.toLowerCase()),i.indexOf("-")===-1&&i.indexOf("_")===-1)return i;{let r="",a=!1;const c=i.match(/^-+/);for(let u=c?c[0].length:0;u<i.length;u++){let g=i.charAt(u);a&&(a=!1,g=g.toUpperCase()),u!==0&&(g==="-"||g==="_")?a=!0:g!=="-"&&g!=="_"&&(r+=g)}return r}}function Ne(i,t){const r=i.toLowerCase();t=t||"-";let a="";for(let c=0;c<i.length;c++){const u=r.charAt(c),g=i.charAt(c);u!==g&&c>0?a+=`${t}${r.charAt(c)}`:a+=g}return a}function Fe(i){return i==null?!1:typeof i=="number"||/^0x[0-9a-f]+$/i.test(i)?!0:/^0[^.]/.test(i)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(i)}/**
6
- * @license
7
- * Copyright (c) 2016, Contributors
8
- * SPDX-License-Identifier: ISC
9
- */function tt(i){if(Array.isArray(i))return i.map(g=>typeof g!="string"?g+"":g);i=i.trim();let t=0,r=null,a=null,c=null;const u=[];for(let g=0;g<i.length;g++){if(r=a,a=i.charAt(g),a===" "&&!c){r!==" "&&t++;continue}a===c?c=null:(a==="'"||a==='"')&&!c&&(c=a),u[t]||(u[t]=""),u[t]+=a}return u}/**
10
- * @license
11
- * Copyright (c) 2016, Contributors
12
- * SPDX-License-Identifier: ISC
13
- */var $;(function(i){i.BOOLEAN="boolean",i.STRING="string",i.NUMBER="number",i.ARRAY="array"})($||($={}));/**
14
- * @license
15
- * Copyright (c) 2016, Contributors
16
- * SPDX-License-Identifier: ISC
17
- */let I;class nt{constructor(t){I=t}parse(t,r){const a=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},r),c=tt(t),u=typeof t=="string",g=st(Object.assign(Object.create(null),a.alias)),h=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},a.configuration),E=Object.assign(Object.create(null),a.default),_=a.configObjects||[],w=a.envPrefix,W=h["populate--"],z=W?"--":"_",U=Object.create(null),C=Object.create(null),B=a.__||I.format,l={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},R=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,se=new RegExp("^--"+h["negation-prefix"]+"(.+)");[].concat(a.array||[]).filter(Boolean).forEach(function(e){const s=typeof e=="object"?e.key:e,f=Object.keys(e).map(function(o){return{boolean:"bools",string:"strings",number:"numbers"}[o]}).filter(Boolean).pop();f&&(l[f][s]=!0),l.arrays[s]=!0,l.keys.push(s)}),[].concat(a.boolean||[]).filter(Boolean).forEach(function(e){l.bools[e]=!0,l.keys.push(e)}),[].concat(a.string||[]).filter(Boolean).forEach(function(e){l.strings[e]=!0,l.keys.push(e)}),[].concat(a.number||[]).filter(Boolean).forEach(function(e){l.numbers[e]=!0,l.keys.push(e)}),[].concat(a.count||[]).filter(Boolean).forEach(function(e){l.counts[e]=!0,l.keys.push(e)}),[].concat(a.normalize||[]).filter(Boolean).forEach(function(e){l.normalize[e]=!0,l.keys.push(e)}),typeof a.narg=="object"&&Object.entries(a.narg).forEach(([e,s])=>{typeof s=="number"&&(l.nargs[e]=s,l.keys.push(e))}),typeof a.coerce=="object"&&Object.entries(a.coerce).forEach(([e,s])=>{typeof s=="function"&&(l.coercions[e]=s,l.keys.push(e))}),typeof a.config<"u"&&(Array.isArray(a.config)||typeof a.config=="string"?[].concat(a.config).filter(Boolean).forEach(function(e){l.configs[e]=!0}):typeof a.config=="object"&&Object.entries(a.config).forEach(([e,s])=>{(typeof s=="boolean"||typeof s=="function")&&(l.configs[e]=s)})),Ge(a.key,g,a.default,l.arrays),Object.keys(E).forEach(function(e){(l.aliases[e]||[]).forEach(function(s){E[s]=E[e]})});let N=null;Ke();let V=[];const j=Object.assign(Object.create(null),{_:[]}),de={};for(let e=0;e<c.length;e++){const s=c[e],f=s.replace(/^-{3,}/,"---");let o,n,p,d,m,O;if(s!=="--"&&/^-/.test(s)&&k(s))re(s);else if(f.match(/^---+(=|$)/)){re(s);continue}else if(s.match(/^--.+=/)||!h["short-option-groups"]&&s.match(/^-.+=/))d=s.match(/^--?([^=]+)=([\s\S]*)$/),d!==null&&Array.isArray(d)&&d.length>=3&&(b(d[1],l.arrays)?e=Z(e,d[1],c,d[2]):b(d[1],l.nargs)!==!1?e=K(e,d[1],c,d[2]):y(d[1],d[2],!0));else if(s.match(se)&&h["boolean-negation"])d=s.match(se),d!==null&&Array.isArray(d)&&d.length>=2&&(n=d[1],y(n,b(n,l.arrays)?[!1]:!1));else if(s.match(/^--.+/)||!h["short-option-groups"]&&s.match(/^-[^-]+/))d=s.match(/^--?(.+)/),d!==null&&Array.isArray(d)&&d.length>=2&&(n=d[1],b(n,l.arrays)?e=Z(e,n,c):b(n,l.nargs)!==!1?e=K(e,n,c):(m=c[e+1],m!==void 0&&(!m.match(/^-/)||m.match(R))&&!b(n,l.bools)&&!b(n,l.counts)||/^(true|false)$/.test(m)?(y(n,m),e++):y(n,T(n))));else if(s.match(/^-.\..+=/))d=s.match(/^-([^=]+)=([\s\S]*)$/),d!==null&&Array.isArray(d)&&d.length>=3&&y(d[1],d[2]);else if(s.match(/^-.\..+/)&&!s.match(R))m=c[e+1],d=s.match(/^-(.\..+)/),d!==null&&Array.isArray(d)&&d.length>=2&&(n=d[1],m!==void 0&&!m.match(/^-/)&&!b(n,l.bools)&&!b(n,l.counts)?(y(n,m),e++):y(n,T(n)));else if(s.match(/^-[^-]+/)&&!s.match(R)){p=s.slice(1,-1).split(""),o=!1;for(let A=0;A<p.length;A++){if(m=s.slice(A+2),p[A+1]&&p[A+1]==="="){O=s.slice(A+3),n=p[A],b(n,l.arrays)?e=Z(e,n,c,O):b(n,l.nargs)!==!1?e=K(e,n,c,O):y(n,O),o=!0;break}if(m==="-"){y(p[A],m);continue}if(/[A-Za-z]/.test(p[A])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(m)&&b(m,l.bools)===!1){y(p[A],m),o=!0;break}if(p[A+1]&&p[A+1].match(/\W/)){y(p[A],m),o=!0;break}else y(p[A],T(p[A]))}n=s.slice(-1)[0],!o&&n!=="-"&&(b(n,l.arrays)?e=Z(e,n,c):b(n,l.nargs)!==!1?e=K(e,n,c):(m=c[e+1],m!==void 0&&(!/^(-|--)[^-]/.test(m)||m.match(R))&&!b(n,l.bools)&&!b(n,l.counts)||/^(true|false)$/.test(m)?(y(n,m),e++):y(n,T(n))))}else if(s.match(/^-[0-9]$/)&&s.match(R)&&b(s.slice(1),l.bools))n=s.slice(1),y(n,T(n));else if(s==="--"){V=c.slice(e+1);break}else if(h["halt-at-non-option"]){V=c.slice(e);break}else re(s)}pe(j,!0),pe(j,!1),Te(j),ze(),ge(j,l.aliases,E,!0),Me(j),h["set-placeholder-key"]&&De(j),Object.keys(l.counts).forEach(function(e){M(j,e.split("."))||y(e,0)}),W&&V.length&&(j[z]=[]),V.forEach(function(e){j[z].push(e)}),h["camel-case-expansion"]&&h["strip-dashed"]&&Object.keys(j).filter(e=>e!=="--"&&e.includes("-")).forEach(e=>{delete j[e]}),h["strip-aliased"]&&[].concat(...Object.keys(g).map(e=>g[e])).forEach(e=>{h["camel-case-expansion"]&&e.includes("-")&&delete j[e.split(".").map(s=>H(s)).join(".")],delete j[e]});function re(e){const s=X("_",e);(typeof s=="string"||typeof s=="number")&&j._.push(s)}function K(e,s,f,o){let n,p=b(s,l.nargs);if(p=typeof p!="number"||isNaN(p)?1:p,p===0)return P(o)||(N=Error(B("Argument unexpected for: %s",s))),y(s,T(s)),e;let d=P(o)?0:1;if(h["nargs-eats-options"])f.length-(e+1)+d<p&&(N=Error(B("Not enough arguments following: %s",s))),d=p;else{for(n=e+1;n<f.length&&(!f[n].match(/^-[^0-9]/)||f[n].match(R)||k(f[n]));n++)d++;d<p&&(N=Error(B("Not enough arguments following: %s",s)))}let m=Math.min(d,p);for(!P(o)&&m>0&&(y(s,o),m--),n=e+1;n<m+e+1;n++)y(s,f[n]);return e+m}function Z(e,s,f,o){let n=[],p=o||f[e+1];const d=b(s,l.nargs);if(b(s,l.bools)&&!/^(true|false)$/.test(p))n.push(!0);else if(P(p)||P(o)&&/^-/.test(p)&&!R.test(p)&&!k(p)){if(E[s]!==void 0){const m=E[s];n=Array.isArray(m)?m:[m]}}else{P(o)||n.push(ie(s,o,!0));for(let m=e+1;m<f.length&&!(!h["greedy-arrays"]&&n.length>0||d&&typeof d=="number"&&n.length>=d||(p=f[m],/^-/.test(p)&&!R.test(p)&&!k(p)));m++)e=m,n.push(ie(s,p,u))}return typeof d=="number"&&(d&&n.length<d||isNaN(d)&&n.length===0)&&(N=Error(B("Not enough arguments following: %s",s))),y(s,n),e}function y(e,s,f=u){if(/-/.test(e)&&h["camel-case-expansion"]){const p=e.split(".").map(function(d){return H(d)}).join(".");he(e,p)}const o=ie(e,s,f),n=e.split(".");D(j,n,o),l.aliases[e]&&l.aliases[e].forEach(function(p){const d=p.split(".");D(j,d,o)}),n.length>1&&h["dot-notation"]&&(l.aliases[n[0]]||[]).forEach(function(p){let d=p.split(".");const m=[].concat(n);m.shift(),d=d.concat(m),(l.aliases[e]||[]).includes(d.join("."))||D(j,d,o)}),b(e,l.normalize)&&!b(e,l.arrays)&&[e].concat(l.aliases[e]||[]).forEach(function(d){Object.defineProperty(de,d,{enumerable:!0,get(){return s},set(m){s=typeof m=="string"?I.normalize(m):m}})})}function he(e,s){l.aliases[e]&&l.aliases[e].length||(l.aliases[e]=[s],U[s]=!0),l.aliases[s]&&l.aliases[s].length||he(s,e)}function ie(e,s,f){f&&(s=rt(s)),(b(e,l.bools)||b(e,l.counts))&&typeof s=="string"&&(s=s==="true");let o=Array.isArray(s)?s.map(function(n){return X(e,n)}):X(e,s);return b(e,l.counts)&&(P(o)||typeof o=="boolean")&&(o=ae()),b(e,l.normalize)&&b(e,l.arrays)&&(Array.isArray(s)?o=s.map(n=>I.normalize(n)):o=I.normalize(s)),o}function X(e,s){return!h["parse-positional-numbers"]&&e==="_"||!b(e,l.strings)&&!b(e,l.bools)&&!Array.isArray(s)&&(Fe(s)&&h["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${s}`)))||!P(s)&&b(e,l.numbers))&&(s=Number(s)),s}function Te(e){const s=Object.create(null);ge(s,l.aliases,E),Object.keys(l.configs).forEach(function(f){const o=e[f]||s[f];if(o)try{let n=null;const p=I.resolve(I.cwd(),o),d=l.configs[f];if(typeof d=="function"){try{n=d(p)}catch(m){n=m}if(n instanceof Error){N=n;return}}else n=I.require(p);oe(n)}catch(n){n.name==="PermissionDenied"?N=n:e[f]&&(N=Error(B("Invalid JSON config file: %s",o)))}})}function oe(e,s){Object.keys(e).forEach(function(f){const o=e[f],n=s?s+"."+f:f;typeof o=="object"&&o!==null&&!Array.isArray(o)&&h["dot-notation"]?oe(o,n):(!M(j,n.split("."))||b(n,l.arrays)&&h["combine-arrays"])&&y(n,o)})}function ze(){typeof _<"u"&&_.forEach(function(e){oe(e)})}function pe(e,s){if(typeof w>"u")return;const f=typeof w=="string"?w:"",o=I.env();Object.keys(o).forEach(function(n){if(f===""||n.lastIndexOf(f,0)===0){const p=n.split("__").map(function(d,m){return m===0&&(d=d.substring(f.length)),H(d)});(s&&l.configs[p.join(".")]||!s)&&!M(e,p)&&y(p.join("."),o[n])}})}function Me(e){let s;const f=new Set;Object.keys(e).forEach(function(o){if(!f.has(o)&&(s=b(o,l.coercions),typeof s=="function"))try{const n=X(o,s(e[o]));[].concat(l.aliases[o]||[],o).forEach(p=>{f.add(p),e[p]=n})}catch(n){N=n}})}function De(e){return l.keys.forEach(s=>{~s.indexOf(".")||typeof e[s]>"u"&&(e[s]=void 0)}),e}function ge(e,s,f,o=!1){Object.keys(f).forEach(function(n){M(e,n.split("."))||(D(e,n.split("."),f[n]),o&&(C[n]=!0),(s[n]||[]).forEach(function(p){M(e,p.split("."))||D(e,p.split("."),f[n])}))})}function M(e,s){let f=e;h["dot-notation"]||(s=[s.join(".")]),s.slice(0,-1).forEach(function(n){f=f[n]||{}});const o=s[s.length-1];return typeof f!="object"?!1:o in f}function D(e,s,f){let o=e;h["dot-notation"]||(s=[s.join(".")]),s.slice(0,-1).forEach(function(O){O=we(O),typeof o=="object"&&o[O]===void 0&&(o[O]={}),typeof o[O]!="object"||Array.isArray(o[O])?(Array.isArray(o[O])?o[O].push({}):o[O]=[o[O],{}],o=o[O][o[O].length-1]):o=o[O]});const n=we(s[s.length-1]),p=b(s.join("."),l.arrays),d=Array.isArray(f);let m=h["duplicate-arguments-array"];!m&&b(n,l.nargs)&&(m=!0,(!P(o[n])&&l.nargs[n]===1||Array.isArray(o[n])&&o[n].length===l.nargs[n])&&(o[n]=void 0)),f===ae()?o[n]=ae(o[n]):Array.isArray(o[n])?m&&p&&d?o[n]=h["flatten-duplicate-arrays"]?o[n].concat(f):(Array.isArray(o[n][0])?o[n]:[o[n]]).concat([f]):!m&&!!p==!!d?o[n]=f:o[n]=o[n].concat([f]):o[n]===void 0&&p?o[n]=d?f:[f]:m&&!(o[n]===void 0||b(n,l.counts)||b(n,l.bools))?o[n]=[o[n],f]:o[n]=f}function Ge(...e){e.forEach(function(s){Object.keys(s||{}).forEach(function(f){l.aliases[f]||(l.aliases[f]=[].concat(g[f]||[]),l.aliases[f].concat(f).forEach(function(o){if(/-/.test(o)&&h["camel-case-expansion"]){const n=H(o);n!==f&&l.aliases[f].indexOf(n)===-1&&(l.aliases[f].push(n),U[n]=!0)}}),l.aliases[f].concat(f).forEach(function(o){if(o.length>1&&/[A-Z]/.test(o)&&h["camel-case-expansion"]){const n=Ne(o,"-");n!==f&&l.aliases[f].indexOf(n)===-1&&(l.aliases[f].push(n),U[n]=!0)}}),l.aliases[f].forEach(function(o){l.aliases[o]=[f].concat(l.aliases[f].filter(function(n){return o!==n}))}))})})}function b(e,s){const f=[].concat(l.aliases[e]||[],e),o=Object.keys(s),n=f.find(p=>o.includes(p));return n?s[n]:!1}function me(e){const s=Object.keys(l);return[].concat(s.map(o=>l[o])).some(function(o){return Array.isArray(o)?o.includes(e):o[e]})}function He(e,...s){return[].concat(...s).some(function(o){const n=e.match(o);return n&&me(n[1])})}function Qe(e){if(e.match(R)||!e.match(/^-[^-]+/))return!1;let s=!0,f;const o=e.slice(1).split("");for(let n=0;n<o.length;n++){if(f=e.slice(n+2),!me(o[n])){s=!1;break}if(o[n+1]&&o[n+1]==="="||f==="-"||/[A-Za-z]/.test(o[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(f)||o[n+1]&&o[n+1].match(/\W/))break}return s}function k(e){return h["unknown-options-as-args"]&&Je(e)}function Je(e){return e=e.replace(/^-{3,}/,"--"),e.match(R)||Qe(e)?!1:!He(e,/^-+([^=]+?)=[\s\S]*$/,se,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function T(e){return!b(e,l.bools)&&!b(e,l.counts)&&`${e}`in E?E[e]:Ye(Ve(e))}function Ye(e){return{[$.BOOLEAN]:!0,[$.STRING]:"",[$.NUMBER]:void 0,[$.ARRAY]:[]}[e]}function Ve(e){let s=$.BOOLEAN;return b(e,l.strings)?s=$.STRING:b(e,l.numbers)?s=$.NUMBER:b(e,l.bools)?s=$.BOOLEAN:b(e,l.arrays)&&(s=$.ARRAY),s}function P(e){return e===void 0}function Ke(){Object.keys(l.counts).find(e=>b(e,l.arrays)?(N=Error(B("Invalid configuration: %s, opts.count excludes opts.array.",e)),!0):b(e,l.nargs)?(N=Error(B("Invalid configuration: %s, opts.count excludes opts.narg.",e)),!0):!1)}return{aliases:Object.assign({},l.aliases),argv:Object.assign(de,j),configuration:h,defaulted:Object.assign({},C),error:N,newAliases:Object.assign({},U)}}}function st(i){const t=[],r=Object.create(null);let a=!0;for(Object.keys(i).forEach(function(c){t.push([].concat(i[c],c))});a;){a=!1;for(let c=0;c<t.length;c++)for(let u=c+1;u<t.length;u++)if(t[c].filter(function(h){return t[u].indexOf(h)!==-1}).length){t[c]=t[c].concat(t[u]),t.splice(u,1),a=!0;break}}return t.forEach(function(c){c=c.filter(function(g,h,E){return E.indexOf(g)===h});const u=c.pop();u!==void 0&&typeof u=="string"&&(r[u]=c)}),r}function ae(i){return i!==void 0?i+1:1}function we(i){return i==="__proto__"?"___proto___":i}function rt(i){return typeof i=="string"&&(i[0]==="'"||i[0]==='"')&&i[i.length-1]===i[0]?i.substring(1,i.length-1):i}/**
18
- * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
19
- * CJS and ESM environments.
20
- *
21
- * @license
22
- * Copyright (c) 2016, Contributors
23
- * SPDX-License-Identifier: ISC
24
- */var ce,le,fe;const je=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Oe=(le=(ce=process==null?void 0:process.versions)===null||ce===void 0?void 0:ce.node)!==null&&le!==void 0?le:(fe=process==null?void 0:process.version)===null||fe===void 0?void 0:fe.slice(1);if(Oe&&Number(Oe.match(/^([^.]+)/)[1])<je)throw Error(`yargs parser supports a minimum Node.js version of ${je}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const it=process?process.env:{},$e=new nt({cwd:process.cwd,env:()=>it,format:ue.format,normalize:x.normalize,resolve:x.resolve,require:i=>{if(typeof require<"u")return require(i);if(i.match(/\.json$/))return JSON.parse(q.readFileSync(i,"utf8"));throw Error("only .json config files are supported in ESM")}}),Y=function(t,r){return $e.parse(t.slice(),r).argv};Y.detailed=function(i,t){return $e.parse(i.slice(),t)};Y.camelCase=H;Y.decamelize=Ne;Y.looksLikeNumber=Fe;const ot={right:dt,center:ht},at=0,ee=1,ct=2,te=3;class lt{constructor(t){var r;this.width=t.width,this.wrap=(r=t.wrap)!==null&&r!==void 0?r:!0,this.rows=[]}span(...t){const r=this.div(...t);r.span=!0}resetOutput(){this.rows=[]}div(...t){if(t.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&typeof t[0]=="string")return this.applyLayoutDSL(t[0]);const r=t.map(a=>typeof a=="string"?this.colFromString(a):a);return this.rows.push(r),r}shouldApplyLayoutDSL(...t){return t.length===1&&typeof t[0]=="string"&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){const r=t.split(`
25
- `).map(c=>c.split(" "));let a=0;return r.forEach(c=>{c.length>1&&S.stringWidth(c[0])>a&&(a=Math.min(Math.floor(this.width*.5),S.stringWidth(c[0])))}),r.forEach(c=>{this.div(...c.map((u,g)=>({text:u.trim(),padding:this.measurePadding(u),width:g===0&&c.length>1?a:void 0})))}),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){const r=S.stripAnsi(t);return[0,r.match(/\s*$/)[0].length,0,r.match(/^\s*/)[0].length]}toString(){const t=[];return this.rows.forEach(r=>{this.rowToString(r,t)}),t.filter(r=>!r.hidden).map(r=>r.text).join(`
26
- `)}rowToString(t,r){return this.rasterize(t).forEach((a,c)=>{let u="";a.forEach((g,h)=>{const{width:E}=t[h],_=this.negatePadding(t[h]);let w=g;if(_>S.stringWidth(g)&&(w+=" ".repeat(_-S.stringWidth(g))),t[h].align&&t[h].align!=="left"&&this.wrap){const z=ot[t[h].align];w=z(w,_),S.stringWidth(w)<_&&(w+=" ".repeat((E||0)-S.stringWidth(w)-1))}const W=t[h].padding||[0,0,0,0];W[te]&&(u+=" ".repeat(W[te])),u+=Ae(t[h],w,"| "),u+=w,u+=Ae(t[h],w," |"),W[ee]&&(u+=" ".repeat(W[ee])),c===0&&r.length>0&&(u=this.renderInline(u,r[r.length-1]))}),r.push({text:u.replace(/ +$/,""),span:t.span})}),r}renderInline(t,r){const a=t.match(/^ */),c=a?a[0].length:0,u=r.text,g=S.stringWidth(u.trimRight());return r.span?this.wrap?c<g?t:(r.hidden=!0,u.trimRight()+" ".repeat(c-g)+t.trimLeft()):(r.hidden=!0,u+t):t}rasterize(t){const r=[],a=this.columnWidths(t);let c;return t.forEach((u,g)=>{u.width=a[g],this.wrap?c=S.wrap(u.text,this.negatePadding(u),{hard:!0}).split(`
27
- `):c=u.text.split(`
28
- `),u.border&&(c.unshift("."+"-".repeat(this.negatePadding(u)+2)+"."),c.push("'"+"-".repeat(this.negatePadding(u)+2)+"'")),u.padding&&(c.unshift(...new Array(u.padding[at]||0).fill("")),c.push(...new Array(u.padding[ct]||0).fill(""))),c.forEach((h,E)=>{r[E]||r.push([]);const _=r[E];for(let w=0;w<g;w++)_[w]===void 0&&_.push("");_.push(h)})}),r}negatePadding(t){let r=t.width||0;return t.padding&&(r-=(t.padding[te]||0)+(t.padding[ee]||0)),t.border&&(r-=4),r}columnWidths(t){if(!this.wrap)return t.map(g=>g.width||S.stringWidth(g.text));let r=t.length,a=this.width;const c=t.map(g=>{if(g.width)return r--,a-=g.width,g.width}),u=r?Math.floor(a/r):0;return c.map((g,h)=>g===void 0?Math.max(u,ft(t[h])):g)}}function Ae(i,t,r){return i.border?/[.']-+[.']/.test(t)?"":t.trim().length!==0?r:" ":""}function ft(i){const t=i.padding||[],r=1+(t[te]||0)+(t[ee]||0);return i.border?r+4:r}function ut(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function dt(i,t){i=i.trim();const r=S.stringWidth(i);return r<t?" ".repeat(t-r)+i:i}function ht(i,t){i=i.trim();const r=S.stringWidth(i);return r>=t?i:" ".repeat(t-r>>1)+i}let S;function pt(i,t){return S=t,new lt({width:(i==null?void 0:i.width)||ut(),wrap:i==null?void 0:i.wrap})}const Ce=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function Re(i){return i.replace(Ce,"")}function gt(i,t){const[r,a]=i.match(Ce)||["",""];i=Re(i);let c="";for(let u=0;u<i.length;u++)u!==0&&u%t===0&&(c+=`
29
- `),c+=i.charAt(u);return r&&a&&(c=`${r}${c}${a}`),c}function mt(i){return pt(i,{stringWidth:t=>[...t].length,stripAnsi:Re,wrap:gt})}function bt(i,t){let r=x.resolve(".",i),a;for(q.statSync(r).isDirectory()||(r=x.dirname(r));;){if(a=t(r,q.readdirSync(r)),a)return x.resolve(r,a);if(r=x.dirname(a=r),a===r)break}}const yt={fs:{readFileSync:q.readFileSync,writeFile:q.writeFile},format:ue.format,resolve:x.resolve,exists:i=>{try{return q.statSync(i).isFile()}catch{return!1}}};let F;class Et{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);const r=t.shift();let a=function(){};return typeof t[t.length-1]=="function"&&(a=t.pop()),a=a||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][r]&&this.updateFiles?(this.cache[this.locale][r]=r,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:a})):a(),F.format.apply(F.format,[this.cache[this.locale][r]||r].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),r=t.shift(),a=t.shift(),c=t.shift();let u=function(){};typeof t[t.length-1]=="function"&&(u=t.pop()),this.cache[this.locale]||this._readLocaleFile();let g=c===1?r:a;this.cache[this.locale][r]&&(g=this.cache[this.locale][r][c===1?"one":"other"]),!this.cache[this.locale][r]&&this.updateFiles?(this.cache[this.locale][r]={one:r,other:a},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:u})):u();const h=[g];return~g.indexOf("%d")&&h.push(c),F.format.apply(F.format,h.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(this.cache[this.locale][r]=t[r])}_taggedLiteral(t,...r){let a="";return t.forEach(function(c,u){const g=r[u+1];a+=c,typeof g<"u"&&(a+="%s")}),this.__.apply(this,[a].concat([].slice.call(r,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){const t=this,r=this.writeQueue[0],a=r.directory,c=r.locale,u=r.cb,g=this._resolveLocaleFile(a,c),h=JSON.stringify(this.cache[c],null,2);F.fs.writeFile(g,h,"utf-8",function(E){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),u(E)})}_readLocaleFile(){let t={};const r=this._resolveLocaleFile(this.directory,this.locale);try{F.fs.readFileSync&&(t=JSON.parse(F.fs.readFileSync(r,"utf-8")))}catch(a){if(a instanceof SyntaxError&&(a.message="syntax error in "+r),a.code==="ENOENT")t={};else throw a}this.cache[this.locale]=t}_resolveLocaleFile(t,r){let a=F.resolve(t,"./",r+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(a)&&~r.lastIndexOf("_")){const c=F.resolve(t,"./",r.split("_")[0]+".json");this._fileExistsSync(c)&&(a=c)}return a}_fileExistsSync(t){return F.exists(t)}}function wt(i,t){F=t;const r=new Et(i);return{__:r.__.bind(r),__n:r.__n.bind(r),setLocale:r.setLocale.bind(r),getLocale:r.getLocale.bind(r),updateLocale:r.updateLocale.bind(r),locale:r.locale}}const jt=i=>wt(i,yt),Ot="require is not supported by ESM",_e="loading a directory of commands is not supported yet for ESM";let J;try{J=Ze.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:Ee&&Ee.src||new URL("index.js",document.baseURI).href)}catch{J=process.cwd()}const At=J.substring(0,J.lastIndexOf("node_modules"));be.notStrictEqual,be.strictEqual,ue.inspect,At||process.cwd(),x.basename,x.dirname,x.extname,x.relative,x.resolve,process.cwd,process.exit,process.nextTick,typeof process.stdout.columns<"u"&&process.stdout.columns,q.readFileSync,jt({directory:x.resolve(J,"../../../locales"),updateFiles:!1});const Le=(i,t)=>{console.log(L.red(i)),console.log(L.red(t==null?void 0:t.message)),process.exit(1)},_t=()=>{const i=v.readFileSync(ne.join(__dirname,"../package.json"),"utf-8");return JSON.parse(i)},We="template-node-cli",Pe="CUSTOM",Ie=[{title:"typescript",value:"template-ts"},{title:"node-cli",value:We},{title:"web-mobile-vue3",value:"template-web-m-vue3"},{title:"web-mobile-react",value:"template-web-m-react"},{title:"uni-vue3",value:"template-uni-m-vue3"},{title:"monorepo",value:"template-monorepo"},{title:"自定义模板路径",value:Pe}],Be={type:"text",name:"projectName",message:"Project name:"},qe={type:"select",name:"template",message:"请选择模板",choices:Ie},Ue={type:"confirm",name:"saveGitHistory",message:"保留git历史"},vt=process.cwd();async function St(){const i=ne.resolve(__dirname,"../package.json"),t=v.readFileSync(i,"utf-8"),{version:r}=JSON.parse(t);return console.log(L.green(`v${r}`)),await ve(xe(process.argv)).version(r).alias("v","version").alias("h","help").options({projectName:{type:"string",alias:"p",describe:Be.message},template:{type:"string",alias:"t",choices:Ie.map(a=>a.value),describe:qe.message},saveGitHistory:{type:"boolean",alias:"s",describe:Ue.message}}).usage("Usage: $0 -m project [options]").help("help").fail(Le).argv}const xt=()=>{St().then(async i=>{const{projectName:t,template:r,saveGitHistory:a}=i,c=t??(await G(Be)).projectName,u=r??(await G(qe)).template,g=a??(await G(Ue)).saveGitHistory;if(console.log(92,c,u,g),!c.trim()){console.log(L.red("项目名称不能为空"));return}if(c.includes(" ")||c.includes("\\")||c.includes("/")){console.log(L.red("项目名称不能包含空格或者\\或者/"));return}const h=ne.resolve(vt,c);if(v.existsSync(h)){const{isRemove:C}=await G({type:"confirm",name:"isRemove",message:"项目已存在,是否删除"});if(C===!0)v.rmSync(h,{recursive:!0,force:!0});else throw new Error("项目已存在")}let E="";if(u===Pe){const{customUrl:C}=await G({type:"text",name:"customUrl",message:"请输入自定义模板路径"});E=C}else E=`https://gitee.com/justsosu/${u}`;if(console.log(L.green("正在初始化项目,请稍等...")),ye.execSync(`git clone ${E} ${c}`),g===!1){const C=`${h}/.git`;if(!v.existsSync(C))throw new Error("git目录不存在");v.rmSync(`${h}/.git`,{recursive:!0,force:!0})}else ye.execSync(`cd ${h} && git remote rename origin upstream`);const _=v.readFileSync(`${h}/package.json`,"utf-8"),w=JSON.parse(_),{name:W}=w;if(w.name=c,v.rmSync(`${h}/package.json`),u===We){const C=w.bin;w.bin={[c]:Object.values(C)[0]}}v.writeFileSync(`${h}/package.json`,JSON.stringify(w,null,2));const U=v.readFileSync(`${h}/README.md`,"utf-8").replace(W,c);v.rmSync(`${h}/README.md`),v.writeFileSync(`${h}/README.md`,U),console.log(L.green("项目初始化完成")),console.log(L.blue(`
30
- 使用步骤:
31
- 1. cd ${c}
32
- 2. pnpm install
33
- 3. pnpm run dev
34
- `))})};async function Nt(){const i=ne.resolve(__dirname,"../package.json"),t=v.readFileSync(i,"utf-8"),{version:r}=JSON.parse(t);console.log(L.green(`v${r}`))}const Ft=()=>{Nt().then(async()=>{console.log(L.red("代码片段创建功能暂未开放"))})},$t=ve(xe(process.argv)),{version:Ct}=_t(),Rt=async()=>await $t.version(Ct).alias("v","version").options({mode:{type:"string",choices:["project","fragment"],default:"project",describe:"创建项目还是代码片段",alias:"m",demandOption:!0}}).usage("Usage: $0 [options]").fail(Le).argv;Rt().then(i=>{i.mode==="project"?xt():i.mode==="fragment"&&Ft()});
1
+ "use strict";var h=Object.create;var m=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var C=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of $(n))!x.call(e,t)&&t!==i&&m(e,t,{get:()=>n[t],enumerable:!(o=b(n,t))||o.enumerable});return e};var p=(e,n,i)=>(i=e!=null?h(k(e)):{},C(n||!e||!e.__esModule?m(i,"default",{value:e,enumerable:!0}):i,e));const u=require("prompts"),g=require("node:child_process"),s=require("node:fs"),d=require("node:path"),v="template-node-cli",f="CUSTOM",_=[{title:"typescript",value:"template-ts"},{title:"node-cli",value:v},{title:"node-express",value:"template-node-express"},{title:"web-pc-vue3",value:"template-web-pc-vue3"},{title:"web-mobile-vue3",value:"template-web-m-vue3"},{title:"web-mobile-react",value:"template-web-m-react"},{title:"uni-vue3",value:"template-uni-m-vue3"},{title:"monorepo",value:"template-monorepo"},{title:"自定义模板路径",value:f}],F=process.cwd();async function O(){const e=d.resolve(__dirname,"../package.json"),n=s.readFileSync(e,"utf-8"),{version:i}=JSON.parse(n),o=(await import("chalk")).default;return console.log(o.green(`v${i}`)),await u([{type:"text",name:"projectName",message:"Project name:"},{type:"select",name:"template",message:"请选择模板",choices:_},{type:"confirm",name:"saveGitHistory",message:"保留git历史"}])}O().then(async({projectName:e,template:n,saveGitHistory:i})=>{const o=(await import("chalk")).default;if(!e.trim()){console.log(o.red("项目名称不能为空"));return}if(e.includes(" ")||e.includes("\\")||e.includes("/")){console.log(o.red("项目名称不能包含空格或者\\或者/"));return}const t=d.resolve(F,e);if(s.existsSync(t)){const{isRemove:c}=await u({type:"confirm",name:"isRemove",message:"项目已存在,是否删除"});if(c===!0)s.rmSync(t,{recursive:!0,force:!0});else throw new Error("项目已存在")}let a="";if(n===f){const{customUrl:c}=await u({type:"text",name:"customUrl",message:"请输入自定义模板路径"});a=c}else a=`https://gitee.com/justsosu/${n}`;if(console.log(o.green("正在初始化项目,请稍等...")),g.execSync(`git clone ${a} ${e}`),i===!1){const c=`${t}/.git`;if(!s.existsSync(c))throw new Error("git目录不存在");s.rmSync(`${t}/.git`,{recursive:!0,force:!0})}else g.execSync(`cd ${t} && git remote rename origin upstream`);const y=s.readFileSync(`${t}/package.json`,"utf-8"),r=JSON.parse(y),{name:w}=r;if(r.name=e,s.rmSync(`${t}/package.json`),n===v){const c=r.bin;r.bin={[e]:Object.values(c)[0]}}s.writeFileSync(`${t}/package.json`,JSON.stringify(r,null,2));const l=`${t}/README.md`;if(s.existsSync(l)){const S=s.readFileSync(l,"utf-8").replace(w,e);s.rmSync(l),s.writeFileSync(l,S)}console.log(o.green("项目初始化完成")),console.log(o.blue(`
2
+ 使用步骤:
3
+ 1. cd ${e}
4
+ 2. pnpm install
5
+ 3. pnpm run dev
6
+ `))});
package/package.json CHANGED
@@ -1,63 +1,62 @@
1
- {
2
- "name": "create-done-coding",
3
- "version": "0.2.12-alpha.1",
4
- "main": "dist/index.js",
5
- "types": "types/index.d.ts",
6
- "bin": "dist/index.js",
7
- "files": [
8
- "dist",
9
- "types"
10
- ],
11
- "scripts": {
12
- "clean": "rimraf es lib dist types",
13
- "serve": "vite",
14
- "dev": "vite build -w",
15
- "predev": "pnpm run clean",
16
- "build": "vite build",
17
- "prebuild": "pnpm run clean",
18
- "prepack": "pnpm build",
19
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
20
- "push": "dc-publish npm"
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "https://gitee.com/justsosu/create-done-coding"
25
- },
26
- "author": "JustSoSu",
27
- "license": "ISC",
28
- "sideEffects": false,
29
- "devDependencies": {
30
- "@commitlint/cli": "^16.3.0",
31
- "@commitlint/config-conventional": "^16.2.4",
32
- "@done-coding/publish": "0.0.8",
33
- "@types/node": "^16.18.58",
34
- "@types/prompts": "^2.4.6",
35
- "@types/yargs": "^17.0.28",
36
- "@typescript-eslint/eslint-plugin": "^6.7.0",
37
- "@typescript-eslint/parser": "^6.7.0",
38
- "conventional-changelog-cli": "^4.1.0",
39
- "eslint": "^8.49.0",
40
- "eslint-config-alloy": "^5.1.2",
41
- "husky": "^8.0.3",
42
- "lint-staged": "^12.5.0",
43
- "prettier": "^3.0.3",
44
- "rimraf": "^5.0.1",
45
- "typescript": "^5.2.2",
46
- "vite": "^4.4.11",
47
- "vite-plugin-dts": "^3.6.0"
48
- },
49
- "lint-staged": {
50
- "*.{ts,js,vue,jsx,tsx}": [
51
- "eslint --fix",
52
- "prettier --write"
53
- ]
54
- },
55
- "engines": {
56
- "node": ">=16.0.0"
57
- },
58
- "dependencies": {
59
- "chalk": "^4.1.2",
60
- "prompts": "^2.4.2",
61
- "yargs": "^17.7.2"
62
- }
63
- }
1
+ {
2
+ "name": "create-done-coding",
3
+ "version": "0.2.13",
4
+ "main": "dist/index.js",
5
+ "types": "types/index.d.ts",
6
+ "bin": {
7
+ "create-done-coding": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "types"
12
+ ],
13
+ "scripts": {
14
+ "clean": "rimraf es lib dist types",
15
+ "serve": "vite",
16
+ "dev": "vite build -w",
17
+ "predev": "pnpm run clean",
18
+ "build": "vite build",
19
+ "prebuild": "pnpm run clean",
20
+ "prepack": "pnpm build",
21
+ "push": "dc-publish npm"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://gitee.com/justsosu/create-done-coding"
26
+ },
27
+ "author": "JustSoSu",
28
+ "license": "ISC",
29
+ "sideEffects": false,
30
+ "devDependencies": {
31
+ "@commitlint/cli": "^16.3.0",
32
+ "@commitlint/config-conventional": "^16.2.4",
33
+ "@done-coding/publish": "0.0.10",
34
+ "@types/node": "^16.18.58",
35
+ "@types/prompts": "^2.4.6",
36
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
37
+ "@typescript-eslint/parser": "^6.7.0",
38
+ "conventional-changelog-cli": "^4.1.0",
39
+ "eslint": "^8.49.0",
40
+ "eslint-config-alloy": "^5.1.2",
41
+ "husky": "^8.0.3",
42
+ "lint-staged": "^12.5.0",
43
+ "prettier": "^3.0.3",
44
+ "rimraf": "^5.0.1",
45
+ "typescript": "^5.2.2",
46
+ "vite": "^4.4.11",
47
+ "vite-plugin-dts": "^3.6.0"
48
+ },
49
+ "lint-staged": {
50
+ "*.{ts,js,vue,jsx,tsx}": [
51
+ "eslint --fix",
52
+ "prettier --write"
53
+ ]
54
+ },
55
+ "engines": {
56
+ "node": ">=16.0.0"
57
+ },
58
+ "dependencies": {
59
+ "chalk": "^5.3.0",
60
+ "prompts": "^2.4.2"
61
+ }
62
+ }
package/types/common.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare const failHandler: (msg: string, err: Error) => never;
2
- export declare const getPkgInfo: () => {
3
- name: string;
4
- version: string;
5
- };
@@ -1 +0,0 @@
1
- export declare const initFragment: () => void;
@@ -1 +0,0 @@
1
- export declare const initProject: () => void;