@umijs/utils 4.0.0-beta.8 → 4.0.0-canary-20240513.3

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 (197) hide show
  1. package/compiled/@ampproject/remapping/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +70 -0
  2. package/compiled/@ampproject/remapping/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
  3. package/compiled/@ampproject/remapping/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
  4. package/compiled/@ampproject/remapping/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  5. package/compiled/@ampproject/remapping/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  6. package/compiled/@ampproject/remapping/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  7. package/compiled/@ampproject/remapping/LICENSE +202 -0
  8. package/compiled/@ampproject/remapping/dist/types/remapping.d.ts +19 -0
  9. package/compiled/@ampproject/remapping/dist/types/source-map.d.ts +17 -0
  10. package/compiled/@ampproject/remapping/dist/types/types.d.ts +14 -0
  11. package/compiled/@ampproject/remapping/index.js +1 -0
  12. package/compiled/@ampproject/remapping/package.json +1 -0
  13. package/compiled/@clack/prompts/LICENSE +23 -0
  14. package/compiled/@clack/prompts/dist/index.d.ts +38 -0
  15. package/compiled/@clack/prompts/index.js +1 -0
  16. package/compiled/@clack/prompts/package.json +1 -0
  17. package/compiled/@hapi/joi/index.d.ts +2218 -0
  18. package/compiled/@hapi/joi/index.js +1 -0
  19. package/compiled/@hapi/joi/package.json +1 -0
  20. package/compiled/axios/index.d.ts +29 -14
  21. package/compiled/axios/index.js +1 -1
  22. package/compiled/chalk/LICENSE +1 -1
  23. package/compiled/chalk/index.js +1 -1
  24. package/compiled/chalk/package.json +1 -1
  25. package/compiled/chalk/source/index.d.ts +318 -0
  26. package/compiled/chalk/source/vendor/supports-color/index.d.ts +55 -0
  27. package/compiled/color/color-convert/conversions.d.ts +87 -87
  28. package/compiled/color/color-convert/index.d.ts +75 -60
  29. package/compiled/color/color-convert/route.d.ts +271 -271
  30. package/compiled/color/index.d.ts +118 -121
  31. package/compiled/color/index.js +1 -1
  32. package/compiled/color/package.json +1 -4
  33. package/compiled/debug/LICENSE +10 -9
  34. package/compiled/debug/index.js +1 -1
  35. package/compiled/debug/package.json +1 -1
  36. package/compiled/execa/index.d.ts +467 -445
  37. package/compiled/execa/index.js +1 -1
  38. package/compiled/fastest-levenshtein/index.js +1 -0
  39. package/compiled/fastest-levenshtein/mod.d.ts +3 -0
  40. package/compiled/fastest-levenshtein/package.json +1 -0
  41. package/compiled/filesize/LICENSE +28 -0
  42. package/compiled/filesize/filesize.d.ts +131 -0
  43. package/compiled/filesize/index.js +8 -0
  44. package/compiled/filesize/package.json +1 -0
  45. package/compiled/filesize/types/filesize.d.ts +46 -0
  46. package/compiled/fs-extra/index.d.ts +930 -253
  47. package/compiled/fs-extra/index.js +1 -1
  48. package/compiled/fs-extra/jsonfile/index.d.ts +78 -0
  49. package/compiled/fs-extra/package.json +1 -1
  50. package/compiled/glob/LICENSE +1 -7
  51. package/compiled/glob/index.d.ts +3 -1
  52. package/compiled/glob/index.js +1 -1
  53. package/compiled/glob/package.json +1 -1
  54. package/compiled/gzip-size/LICENSE +9 -0
  55. package/compiled/gzip-size/index.d.ts +103 -0
  56. package/compiled/gzip-size/index.js +1 -0
  57. package/compiled/gzip-size/package.json +1 -0
  58. package/compiled/lodash/common/array.d.ts +0 -0
  59. package/compiled/lodash/common/collection.d.ts +0 -0
  60. package/compiled/lodash/common/common.d.ts +0 -0
  61. package/compiled/lodash/common/date.d.ts +0 -0
  62. package/compiled/lodash/common/function.d.ts +0 -0
  63. package/compiled/lodash/common/lang.d.ts +0 -0
  64. package/compiled/lodash/common/math.d.ts +0 -0
  65. package/compiled/lodash/common/number.d.ts +0 -0
  66. package/compiled/lodash/common/object.d.ts +0 -0
  67. package/compiled/lodash/common/seq.d.ts +0 -0
  68. package/compiled/lodash/common/string.d.ts +0 -0
  69. package/compiled/lodash/common/util.d.ts +0 -0
  70. package/compiled/magic-string/LICENSE +7 -0
  71. package/compiled/magic-string/index.d.ts +250 -0
  72. package/compiled/magic-string/index.js +1 -0
  73. package/compiled/magic-string/package.json +1 -0
  74. package/compiled/pirates/LICENSE +21 -0
  75. package/compiled/pirates/index.d.ts +82 -0
  76. package/compiled/pirates/index.js +1 -0
  77. package/compiled/pirates/package.json +1 -0
  78. package/compiled/pkg-up/LICENSE +1 -1
  79. package/compiled/pkg-up/index.d.ts +55 -44
  80. package/compiled/pkg-up/index.js +1 -1
  81. package/compiled/pkg-up/package.json +1 -1
  82. package/compiled/portfinder/index.js +1 -1
  83. package/compiled/portfinder/lib/portfinder.d.ts +16 -1
  84. package/compiled/portfinder/package.json +1 -1
  85. package/compiled/prettier/index.d.ts +568 -679
  86. package/compiled/prettier/index.js +62 -274
  87. package/compiled/prettier/package.json +1 -5
  88. package/compiled/resolve/index.js +1 -1
  89. package/compiled/semver/classes/range.d.ts +1 -1
  90. package/compiled/semver/classes/semver.d.ts +1 -1
  91. package/compiled/semver/functions/compare-build.d.ts +6 -1
  92. package/compiled/semver/functions/diff.d.ts +1 -5
  93. package/compiled/semver/functions/satisfies.d.ts +1 -1
  94. package/compiled/semver/index.d.ts +3 -0
  95. package/compiled/semver/index.js +1 -1
  96. package/compiled/semver/package.json +1 -1
  97. package/compiled/semver/ranges/gtr.d.ts +1 -1
  98. package/compiled/semver/ranges/intersects.d.ts +1 -1
  99. package/compiled/semver/ranges/ltr.d.ts +1 -1
  100. package/compiled/semver/ranges/max-satisfying.d.ts +1 -1
  101. package/compiled/semver/ranges/min-satisfying.d.ts +1 -1
  102. package/compiled/semver/ranges/outside.d.ts +1 -1
  103. package/compiled/semver/ranges/subset.d.ts +1 -5
  104. package/compiled/semver/ranges/valid.d.ts +1 -1
  105. package/compiled/strip-ansi/LICENSE +1 -1
  106. package/compiled/strip-ansi/index.d.ts +2 -4
  107. package/compiled/strip-ansi/index.js +1 -1
  108. package/compiled/strip-ansi/package.json +1 -1
  109. package/compiled/tar/LICENSE +15 -0
  110. package/compiled/tar/index.d.ts +943 -0
  111. package/compiled/tar/index.js +1 -0
  112. package/compiled/tar/minipass/index.d.ts +150 -0
  113. package/compiled/tar/package.json +1 -0
  114. package/compiled/tsconfig-paths/LICENSE +21 -0
  115. package/compiled/tsconfig-paths/index.js +1 -0
  116. package/compiled/tsconfig-paths/lib/index.d.ts +5 -0
  117. package/compiled/tsconfig-paths/package.json +1 -0
  118. package/compiled/yargs-parser/index.js +1 -1
  119. package/compiled/yargs-parser/package.json +1 -1
  120. package/compiled/zod/LICENSE +21 -0
  121. package/compiled/zod/index.d.ts +2 -0
  122. package/compiled/zod/index.js +1 -0
  123. package/compiled/zod/lib/ZodError.d.ts +159 -0
  124. package/compiled/zod/lib/__tests__/Mocker.d.ts +17 -0
  125. package/compiled/zod/lib/benchmarks/discriminatedUnion.d.ts +5 -0
  126. package/compiled/zod/lib/benchmarks/index.d.ts +1 -0
  127. package/compiled/zod/lib/benchmarks/object.d.ts +5 -0
  128. package/compiled/zod/lib/benchmarks/primitives.d.ts +5 -0
  129. package/compiled/zod/lib/benchmarks/realworld.d.ts +5 -0
  130. package/compiled/zod/lib/benchmarks/string.d.ts +5 -0
  131. package/compiled/zod/lib/benchmarks/union.d.ts +5 -0
  132. package/compiled/zod/lib/errors.d.ts +5 -0
  133. package/compiled/zod/lib/external.d.ts +6 -0
  134. package/compiled/zod/lib/helpers/enumUtil.d.ts +8 -0
  135. package/compiled/zod/lib/helpers/errorUtil.d.ts +9 -0
  136. package/compiled/zod/lib/helpers/parseUtil.d.ts +78 -0
  137. package/compiled/zod/lib/helpers/partialUtil.d.ts +8 -0
  138. package/compiled/zod/lib/helpers/typeAliases.d.ts +2 -0
  139. package/compiled/zod/lib/helpers/util.d.ts +47 -0
  140. package/compiled/zod/lib/index.d.ts +4 -0
  141. package/compiled/zod/lib/locales/en.d.ts +3 -0
  142. package/compiled/zod/lib/types.d.ts +975 -0
  143. package/compiled/zod/package.json +1 -0
  144. package/dist/BaseGenerator/BaseGenerator.d.ts +3 -3
  145. package/dist/BaseGenerator/BaseGenerator.js +78 -54
  146. package/dist/BaseGenerator/generateFile.d.ts +2 -1
  147. package/dist/BaseGenerator/generateFile.js +49 -22
  148. package/dist/Generator/Generator.d.ts +18 -14
  149. package/dist/Generator/Generator.js +97 -70
  150. package/dist/aliasUtils/getAliasValue.d.ts +4 -0
  151. package/dist/aliasUtils/getAliasValue.js +66 -0
  152. package/dist/aliasUtils/index.d.ts +2 -0
  153. package/dist/aliasUtils/index.js +32 -0
  154. package/dist/aliasUtils/parseCircleAlias.d.ts +4 -0
  155. package/dist/aliasUtils/parseCircleAlias.js +66 -0
  156. package/dist/getCorejsVersion.d.ts +1 -0
  157. package/dist/getCorejsVersion.js +35 -0
  158. package/dist/getDevBanner.d.ts +5 -0
  159. package/dist/getDevBanner.js +81 -0
  160. package/dist/getFileGitIno.d.ts +47 -0
  161. package/dist/getFileGitIno.js +130 -0
  162. package/dist/getGitInfo.d.ts +6 -0
  163. package/dist/getGitInfo.js +50 -0
  164. package/dist/importLazy.js +42 -14
  165. package/dist/index.d.ts +26 -3
  166. package/dist/index.js +185 -86
  167. package/dist/installDeps.js +69 -37
  168. package/dist/isJavaScriptFile.d.ts +1 -0
  169. package/dist/isJavaScriptFile.js +32 -0
  170. package/dist/isLocalDev.d.ts +4 -0
  171. package/dist/isLocalDev.js +36 -0
  172. package/dist/isMonorepo.d.ts +5 -0
  173. package/dist/isMonorepo.js +44 -0
  174. package/dist/isStyleFile.d.ts +5 -0
  175. package/dist/isStyleFile.js +44 -0
  176. package/dist/logger.d.ts +13 -6
  177. package/dist/logger.js +166 -25
  178. package/dist/node.d.ts +4 -0
  179. package/dist/node.js +61 -0
  180. package/dist/npmClient.d.ts +3 -2
  181. package/dist/npmClient.js +86 -40
  182. package/dist/printHelp.d.ts +2 -0
  183. package/dist/printHelp.js +64 -0
  184. package/dist/randomColor/randomColor.js +47 -16
  185. package/dist/readDirFiles.d.ts +9 -0
  186. package/dist/readDirFiles.js +62 -0
  187. package/dist/register.d.ts +1 -0
  188. package/dist/register.js +75 -37
  189. package/dist/setNoDeprecation.d.ts +1 -0
  190. package/dist/setNoDeprecation.js +31 -0
  191. package/dist/tryPaths.d.ts +1 -0
  192. package/dist/tryPaths.js +35 -0
  193. package/dist/updatePackageJSON.js +50 -19
  194. package/dist/winPath.js +33 -9
  195. package/dist/zod/isZodSchema.d.ts +2 -0
  196. package/dist/zod/isZodSchema.js +31 -0
  197. package/package.json +70 -44
@@ -0,0 +1,38 @@
1
+ export { isCancel } from '@clack/core';
2
+
3
+ interface TextOptions {
4
+ message: string;
5
+ placeholder?: string;
6
+ initialValue?: string;
7
+ validate?: (value: string) => string | void;
8
+ }
9
+ declare const text: (opts: TextOptions) => Promise<string | symbol>;
10
+ interface ConfirmOptions {
11
+ message: string;
12
+ active?: string;
13
+ inactive?: string;
14
+ initialValue?: boolean;
15
+ }
16
+ declare const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>;
17
+ interface Option<Value extends Readonly<string>> {
18
+ value: Value;
19
+ label?: string;
20
+ hint?: string;
21
+ }
22
+ interface SelectOptions<Options extends Option<Value>[], Value extends Readonly<string>> {
23
+ message: string;
24
+ options: Options;
25
+ initialValue?: Options[number]["value"];
26
+ }
27
+ declare const select: <Options extends Option<Value>[], Value extends string>(opts: SelectOptions<Options, Value>) => Promise<symbol | Options[number]["value"]>;
28
+ declare const multiselect: <Options extends Option<Value>[], Value extends string>(opts: SelectOptions<Options, Value>) => Promise<symbol | Options[number]["value"][]>;
29
+ declare const note: (message?: string, title?: string) => void;
30
+ declare const cancel: (message?: string) => void;
31
+ declare const intro: (title?: string) => void;
32
+ declare const outro: (message?: string) => void;
33
+ declare const spinner: () => {
34
+ start(message?: string): void;
35
+ stop(message?: string): void;
36
+ };
37
+
38
+ export { ConfirmOptions, SelectOptions, TextOptions, cancel, confirm, intro, multiselect, note, outro, select, spinner, text };
@@ -0,0 +1 @@
1
+ (function(){var t={328:function(t,e,s){let r=s(224);let n=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||r.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env);let formatter=(t,e,s=t)=>r=>{let n=""+r;let a=n.indexOf(e,t.length);return~a?t+replaceClose(n,e,s,a)+e:t+n+e};let replaceClose=(t,e,s,r)=>{let n=t.substring(0,r)+s;let a=t.substring(r+e.length);let u=a.indexOf(e);return~u?n+replaceClose(a,e,s,u):n+a};let createColors=(t=n)=>({isColorSupported:t,reset:t?t=>`${t}`:String,bold:t?formatter("","",""):String,dim:t?formatter("","",""):String,italic:t?formatter("",""):String,underline:t?formatter("",""):String,inverse:t?formatter("",""):String,hidden:t?formatter("",""):String,strikethrough:t?formatter("",""):String,black:t?formatter("",""):String,red:t?formatter("",""):String,green:t?formatter("",""):String,yellow:t?formatter("",""):String,blue:t?formatter("",""):String,magenta:t?formatter("",""):String,cyan:t?formatter("",""):String,white:t?formatter("",""):String,gray:t?formatter("",""):String,bgBlack:t?formatter("",""):String,bgRed:t?formatter("",""):String,bgGreen:t?formatter("",""):String,bgYellow:t?formatter("",""):String,bgBlue:t?formatter("",""):String,bgMagenta:t?formatter("",""):String,bgCyan:t?formatter("",""):String,bgWhite:t?formatter("",""):String});t.exports=createColors();t.exports.createColors=createColors},270:function(t){"use strict";const e="";const s=`${e}[`;const r="";const n={to(t,e){if(!e)return`${s}${t+1}G`;return`${s}${e+1};${t+1}H`},move(t,e){let r="";if(t<0)r+=`${s}${-t}D`;else if(t>0)r+=`${s}${t}C`;if(e<0)r+=`${s}${-e}A`;else if(e>0)r+=`${s}${e}B`;return r},up:(t=1)=>`${s}${t}A`,down:(t=1)=>`${s}${t}B`,forward:(t=1)=>`${s}${t}C`,backward:(t=1)=>`${s}${t}D`,nextLine:(t=1)=>`${s}E`.repeat(t),prevLine:(t=1)=>`${s}F`.repeat(t),left:`${s}G`,hide:`${s}?25l`,show:`${s}?25h`,save:`${e}7`,restore:`${e}8`};const a={up:(t=1)=>`${s}S`.repeat(t),down:(t=1)=>`${s}T`.repeat(t)};const u={screen:`${s}2J`,up:(t=1)=>`${s}1J`.repeat(t),down:(t=1)=>`${s}J`.repeat(t),line:`${s}2K`,lineEnd:`${s}K`,lineStart:`${s}1K`,lines(t){let e="";for(let s=0;s<t;s++)e+=this.line+(s<t-1?n.up():"");if(t)e+=n.left;return e}};t.exports={cursor:n,scroll:a,erase:u,beep:r}},742:function(t){"use strict";t.exports=require("process")},747:function(t){"use strict";t.exports=require("readline")},997:function(t){"use strict";t.exports=require("tty")},224:function(t){"use strict";t.exports=require("tty")},701:function(t,e,s){"use strict";const r=s(997),n=s(742),a=s(747),u=s(270),c=s(328);function _interopNamespaceDefault(t){const e=Object.create(null);if(t)for(const s in t)e[s]=t[s];return e.default=t,e}const l=_interopNamespaceDefault(a);function diffLines(t,e){if(t===e)return;const s=t.split(`\n`),r=e.split(`\n`),n=[];for(let t=0;t<Math.max(s.length,r.length);t++)s[t]!==r[t]&&n.push(t);return n}const h=Symbol("clack:cancel");function isCancel(t){return t===h}function setRawMode(t,e){t.isTTY&&t.setRawMode(e)}const p=new Set(["up","down","left","right","space","enter"]);class Prompt{constructor({render:t,input:e=n.stdin,output:s=n.stdout,...r},a=!0){this._track=!1,this._cursor=0,this.state="initial",this.error="",this.subscribers=new Map,this._prevFrame="",this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=a,this.input=e,this.output=s}prompt(){const t=new r.WriteStream(0);return t._write=(t,e,s)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),s()},this.input.pipe(t),this.rl=a.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),a.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),setRawMode(this.input,!0),this.render(),new Promise(((t,e)=>{this.once("submit",(()=>{this.output.write(u.cursor.show),setRawMode(this.input,!1),t(this.value)})),this.once("cancel",(()=>{this.output.write(u.cursor.show),setRawMode(this.input,!1),t(h)}))}))}on(t,e){const s=this.subscribers.get(t)??[];s.push({cb:e}),this.subscribers.set(t,s)}once(t,e){const s=this.subscribers.get(t)??[];s.push({cb:e,once:!0}),this.subscribers.set(t,s)}emit(t,...e){const s=this.subscribers.get(t)??[],r=[];for(const t of s)t.cb(...e),t.once&&r.push((()=>s.splice(s.indexOf(t),1)));for(const t of r)t()}unsubscribe(){this.subscribers.clear()}onKeypress(t,e){if(this.state==="error"&&(this.state="active"),e?.name&&p.has(e.name)&&this.emit("cursor",e.name),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),e?.name==="return"){if("placeholder"in this.opts&&!this.value&&(this.value=this.opts.placeholder),this.opts.validate){const t=this.opts.validate(this.value);t&&(this.error=t,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}t===""&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.removeListener("keypress",this.onKeypress),this.output.write(`\n`),setRawMode(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=this._prevFrame.split(`\n`).length-1;this.output.write(u.cursor.move(-999,t*-1))}render(){const t=this._render(this)??"";if(t!==this._prevFrame){if(this.state==="initial")this.output.write(u.cursor.hide);else{const e=diffLines(this._prevFrame,t);if(this.restoreCursor(),e&&e?.length===1){const s=e[0];this.output.write(u.cursor.move(0,s)),this.output.write(u.erase.lines(1));const r=t.split(`\n`);this.output.write(r[s]),this._prevFrame=t,this.output.write(u.cursor.move(0,r.length-s-1));return}else if(e&&e?.length>1){const s=e[0];this.output.write(u.cursor.move(0,s)),this.output.write(u.erase.down());const r=t.split(`\n`).slice(s);this.output.write(r.join(`\n`)),this._prevFrame=t;return}this.output.write(u.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}class TextPrompt extends Prompt{constructor(t){super(t),this.valueWithCursor="",this.on("finalize",(()=>{this.valueWithCursor=this.value})),this.on("value",(()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${c.inverse(c.hidden("_"))}`;else{const t=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor);this.valueWithCursor=`${t}${c.inverse(e[0])}${e.slice(1)}`}}))}get cursor(){return this._cursor}}class PasswordPrompt extends Prompt{constructor({mask:t,...e}){super(e),this.valueWithCursor="",this._mask="•",this._mask=t??"•",this.on("finalize",(()=>{this.valueWithCursor=this.masked})),this.on("value",(()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${c.inverse(c.hidden("_"))}`;else{const t=this.masked.slice(0,this.cursor),e=this.masked.slice(this.cursor);this.valueWithCursor=`${t}${c.inverse(e[0])}${e.slice(1)}`}}))}get cursor(){return this._cursor}get masked(){return this.value.split("").map((()=>this._mask)).join("")}}class SelectPrompt extends Prompt{constructor(t){super(t,!1),this.cursor=0,this.options=t.options,this.cursor=this.options.findIndex((({value:e})=>e===t.initialValue)),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()}))}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}}class ConfirmPrompt extends Prompt{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",(()=>{this.value=this._value})),this.on("confirm",(t=>{this.output.write(u.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()})),this.on("cursor",(()=>{this.value=!this.value}))}}class MultiSelectPrompt extends Prompt{constructor(t){t.validate||(t.validate=()=>{if(this.selectedValues.length===0)return`Please select at least one option\n${c.reset(c.dim(`Press ${c.gray(c.bgWhite(c.inverse(" space ")))} to select, ${c.gray(c.bgWhite(c.inverse(" enter ")))} to submit`))}`}),super(t,!1),this.cursor=0,this.once("finalize",(()=>{this.value=this.selectedValues})),this.options=t.options,this.cursor=this.options.findIndex((({value:e})=>e===t.initialValue)),this.selectedValues=[],this.cursor===-1&&(this.cursor=0),this.on("cursor",(t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.changeValue();break;case"enter":case"return":this.state="submit",this.close();break}}))}get _value(){return this.options[this.cursor]}changeValue(){this.selectedValues.some((t=>t===this._value.value))?this.selectedValues=this.selectedValues.filter((t=>t!==this._value.value)):this.selectedValues.push(this._value.value)}}function block({input:t=n.stdin,output:e=n.stdout,overwrite:s=!0,hideCursor:r=!0}={}){const a=l.createInterface({input:t,output:e,prompt:"",tabSize:1});l.emitKeypressEvents(t,a),t.isTTY&&t.setRawMode(!0);const o=(r,{name:n})=>{if(String(r)===""&&process.exit(0),!s)return;let a=n==="return"?0:-1,u=n==="return"?-1:0;l.moveCursor(e,a,u,(()=>{l.clearLine(e,1,(()=>{t.once("keypress",o)}))}))};return r&&process.stdout.write(u.cursor.hide),t.once("keypress",o),()=>{t.off("keypress",o),r&&process.stdout.write(u.cursor.show),a.close()}}e.ConfirmPrompt=ConfirmPrompt,e.MultiSelectPrompt=MultiSelectPrompt,e.PasswordPrompt=PasswordPrompt,e.Prompt=Prompt,e.SelectPrompt=SelectPrompt,e.TextPrompt=TextPrompt,e.block=block,e.isCancel=isCancel}};var e={};function __nccwpck_require__(s){var r=e[s];if(r!==undefined){return r.exports}var n=e[s]={exports:{}};var a=true;try{t[s](n,n.exports,__nccwpck_require__);a=false}finally{if(a)delete e[s]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var s={};!function(){"use strict";var t=s;const e=__nccwpck_require__(701),r=__nccwpck_require__(328),n=__nccwpck_require__(270),symbol=t=>{switch(t){case"initial":case"active":return r.cyan("●");case"cancel":return r.red("■");case"error":return r.yellow("▲");case"submit":return r.green("○")}},a="┌",u="│",c="└",text=t=>new e.TextPrompt({validate:t.validate,placeholder:t.placeholder,initialValue:t.initialValue,render(){const e=`${r.gray(u)}\n${symbol(this.state)} ${t.message}\n`,s=t.placeholder?r.inverse(t.placeholder[0])+r.dim(t.placeholder.slice(1)):r.inverse(r.hidden("_")),n=this.value?this.valueWithCursor:s;switch(this.state){case"error":return`${e.trim()}\n${r.yellow(u)} ${n}\n${r.yellow(c)} ${r.yellow(this.error)}\n`;case"submit":return`${e}${r.gray(u)} ${r.dim(this.value)}`;case"cancel":return`${e}${r.gray(u)} ${r.strikethrough(r.dim(this.value))}${this.value.trim()?`\n`+r.gray(u):""}`;default:return`${e}${r.cyan(u)} ${n}\n${r.cyan(c)}\n`}}}).prompt(),confirm=t=>{const s=t.active??"Yes",n=t.inactive??"No";return new e.ConfirmPrompt({active:s,inactive:n,initialValue:t.initialValue??!0,render(){const e=`${r.gray(u)}\n${symbol(this.state)} ${t.message}\n`,a=this.value?s:n;switch(this.state){case"submit":return`${e}${r.gray(u)} ${r.dim(a)}`;case"cancel":return`${e}${r.gray(u)} ${r.strikethrough(r.dim(a))}\n${r.gray(u)}`;default:return`${e}${r.cyan(u)} ${this.value?`${r.green("●")} ${s}`:`${r.dim("○")} ${r.dim(s)}`} ${r.dim("/")} ${this.value?`${r.dim("○")} ${r.dim(n)}`:`${r.green("●")} ${n}`}\n${r.cyan(c)}\n`}}}).prompt()},select=t=>{const i=(t,e)=>{const s=t.label??t.value;return e==="active"?`${r.green("●")} ${s} ${t.hint?r.dim(`(${t.hint})`):""}`:e==="selected"?`${r.dim(s)}`:e==="cancelled"?`${r.strikethrough(r.dim(s))}`:`${r.dim("○")} ${r.dim(s)}`};return new e.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const e=`${r.gray(u)}\n${symbol(this.state)} ${t.message}\n`;switch(this.state){case"submit":return`${e}${r.gray(u)} ${i(this.options[this.cursor],"selected")}`;case"cancel":return`${e}${r.gray(u)} ${i(this.options[this.cursor],"cancelled")}\n${r.gray(u)}`;default:return`${e}${r.cyan(u)} ${this.options.map(((t,e)=>i(t,e===this.cursor?"active":"inactive"))).join(`\n${r.cyan(u)} `)}\n${r.cyan(c)}\n`}}}).prompt()},multiselect=t=>{const i=(t,e)=>{const s=t.label??t.value;return e==="active"?`${r.cyan("◻")} ${s} ${t.hint?r.dim(`(${t.hint})`):""}`:e==="selected"?`${r.green("◼")} ${r.dim(s)}`:e==="cancelled"?`${r.strikethrough(r.dim(s))}`:e==="active-selected"?`${r.green("◼")} ${s} ${t.hint?r.dim(`(${t.hint})`):""}`:e==="submitted"?`${r.dim(s)}`:`${r.dim("◻")} ${r.dim(s)}`};return new e.MultiSelectPrompt({options:t.options,initialValue:t.initialValue,render(){let e=`${r.gray(u)}\n${symbol(this.state)} ${t.message}\n`;switch(this.state){case"submit":{const t=this.options.filter((t=>this.selectedValues.some((e=>e===t.value))));return`${e}${r.gray(u)} ${t.map(((t,e)=>i(t,"submitted"))).join(r.dim(", "))}`}case"cancel":{const t=this.options.filter((t=>this.selectedValues.some((e=>e===t.value)))).map(((t,e)=>i(t,"cancelled"))).join(r.dim(", "));return`${e}${r.gray(u)} ${t.trim()?`${t}\n${r.gray(u)}`:""}`}case"error":{const t=this.error.split(`\n`).map(((t,e)=>e===0?`${r.yellow(c)} ${r.yellow(t)}`:` ${t}`)).join(`\n`);return`${e}${r.yellow(u)} ${this.options.map(((t,e)=>{const s=this.selectedValues.includes(t.value),r=e===this.cursor;return r&&s?i(t,"active-selected"):s?i(t,"selected"):i(t,r?"active":"inactive")})).join(`\n${r.yellow(u)} `)}\n${t}\n`}default:return`${e}${r.cyan(u)} ${this.options.map(((t,e)=>{const s=this.selectedValues.includes(t.value),r=e===this.cursor;return r&&s?i(t,"active-selected"):s?i(t,"selected"):i(t,r?"active":"inactive")})).join(`\n${r.cyan(u)} `)}\n${r.cyan(c)}\n`}}}).prompt()},strip=t=>t.replace(ansiRegex(),""),note=(t="",e="")=>{const s=`\n${t}\n`.split(`\n`),n=s.reduce(((t,e)=>(e=strip(e),e.length>t?e.length:t)),0)+2,a=s.map((t=>`${r.gray(u)} ${r.dim(t)}${" ".repeat(n-strip(t).length)}${r.gray(u)}`)).join(`\n`);process.stdout.write(`${r.gray(u)}\n${r.green("○")} ${r.reset(e)} ${r.gray("─".repeat(n-e.length-1)+"╮")}\n${a}\n${r.gray("├"+"─".repeat(n+2)+"╯")}\n`)},cancel=(t="")=>{process.stdout.write(`${r.gray(c)} ${r.red(t)}\n\n`)},intro=(t="")=>{process.stdout.write(`${r.gray(a)} ${t}\n`)},outro=(t="")=>{process.stdout.write(`${r.gray(u)}\n${r.gray(c)} ${t}\n\n`)},l=["◒","◐","◓","◑"],spinner=()=>{let t,s;const a=l,c=80;return{start(l=""){l=l.replace(/\.?\.?\.$/,""),t=e.block(),process.stdout.write(`${r.gray(u)}\n${r.magenta("○")} ${l}\n`);let h=0,p=0;s=setInterval((()=>{let t=a[h];process.stdout.write(n.cursor.move(-999,-1)),process.stdout.write(`${r.magenta(t)} ${l}${Math.floor(p)>=1?".".repeat(Math.floor(p)).slice(0,3):""} \n`),h=h===a.length-1?0:h+1,p=p===a.length?0:p+.125}),c)},stop(e=""){process.stdout.write(n.cursor.move(-999,-2)),process.stdout.write(n.erase.down(2)),clearInterval(s),process.stdout.write(`${r.gray(u)}\n${r.green("○")} ${e}\n`),t()}}};function ansiRegex(){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}t.isCancel=e.isCancel,t.cancel=cancel,t.confirm=confirm,t.intro=intro,t.multiselect=multiselect,t.note=note,t.outro=outro,t.select=select,t.spinner=spinner,t.text=text}();module.exports=s})();
@@ -0,0 +1 @@
1
+ {"name":"@clack/prompts","version":"0.2.2","author":{"name":"Nate Moore","email":"nate@natemoo.re","url":"https://twitter.com/n_moore"},"license":"MIT","types":"./dist/index.d.ts"}