@umijs/utils 4.0.50 → 4.0.52
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/compiled/@clack/prompts/LICENSE +23 -0
- package/compiled/@clack/prompts/dist/index.d.ts +38 -0
- package/compiled/@clack/prompts/index.js +1 -0
- package/compiled/@clack/prompts/package.json +1 -0
- package/dist/BaseGenerator/BaseGenerator.d.ts +3 -4
- package/dist/BaseGenerator/BaseGenerator.js +13 -2
- package/dist/BaseGenerator/generateFile.js +1 -4
- package/dist/Generator/Generator.d.ts +16 -12
- package/dist/Generator/Generator.js +14 -5
- package/dist/getDevBanner.js +11 -22
- package/dist/getGitInfo.js +1 -4
- package/dist/importLazy.js +2 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -0
- package/dist/installDeps.js +10 -16
- package/dist/logger.js +10 -1
- package/dist/npmClient.js +7 -1
- package/dist/printHelp.js +2 -7
- package/dist/randomColor/randomColor.js +1 -4
- package/dist/register.js +4 -7
- package/dist/updatePackageJSON.js +4 -10
- package/package.json +4 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Nate Moore
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
`ansi-regex` is adapted from https://github.com/chalk/ansi-regex
|
|
14
|
+
|
|
15
|
+
MIT License
|
|
16
|
+
|
|
17
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -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=>`[0m${t}[0m`:String,bold:t?formatter("[1m","[22m","[22m[1m"):String,dim:t?formatter("[2m","[22m","[22m[2m"):String,italic:t?formatter("[3m","[23m"):String,underline:t?formatter("[4m","[24m"):String,inverse:t?formatter("[7m","[27m"):String,hidden:t?formatter("[8m","[28m"):String,strikethrough:t?formatter("[9m","[29m"):String,black:t?formatter("[30m","[39m"):String,red:t?formatter("[31m","[39m"):String,green:t?formatter("[32m","[39m"):String,yellow:t?formatter("[33m","[39m"):String,blue:t?formatter("[34m","[39m"):String,magenta:t?formatter("[35m","[39m"):String,cyan:t?formatter("[36m","[39m"):String,white:t?formatter("[37m","[39m"):String,gray:t?formatter("[90m","[39m"):String,bgBlack:t?formatter("[40m","[49m"):String,bgRed:t?formatter("[41m","[49m"):String,bgGreen:t?formatter("[42m","[49m"):String,bgYellow:t?formatter("[43m","[49m"):String,bgBlue:t?formatter("[44m","[49m"):String,bgMagenta:t?formatter("[45m","[49m"):String,bgCyan:t?formatter("[46m","[49m"):String,bgWhite:t?formatter("[47m","[49m"):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"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import prompts from '../../compiled/prompts';
|
|
2
|
-
import Generator from '../Generator/Generator';
|
|
3
|
-
interface
|
|
2
|
+
import Generator, { type IGeneratorOpts } from '../Generator/Generator';
|
|
3
|
+
interface IBaseGeneratorOpts extends Partial<Omit<IGeneratorOpts, 'args'>> {
|
|
4
4
|
path: string;
|
|
5
5
|
target: string;
|
|
6
|
-
baseDir?: string;
|
|
7
6
|
data?: any;
|
|
8
7
|
questions?: prompts.PromptObject[];
|
|
9
8
|
}
|
|
@@ -12,7 +11,7 @@ export default class BaseGenerator extends Generator {
|
|
|
12
11
|
target: string;
|
|
13
12
|
data: any;
|
|
14
13
|
questions: prompts.PromptObject[];
|
|
15
|
-
constructor({ path, target, data, questions, baseDir }:
|
|
14
|
+
constructor({ path, target, data, questions, baseDir, slient, }: IBaseGeneratorOpts);
|
|
16
15
|
prompting(): prompts.PromptObject<string>[];
|
|
17
16
|
writing(): Promise<void>;
|
|
18
17
|
}
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -33,8 +37,15 @@ var import_path = require("path");
|
|
|
33
37
|
var import_fs_extra = __toESM(require("../../compiled/fs-extra"));
|
|
34
38
|
var import_Generator = __toESM(require("../Generator/Generator"));
|
|
35
39
|
var BaseGenerator = class extends import_Generator.default {
|
|
36
|
-
constructor({
|
|
37
|
-
|
|
40
|
+
constructor({
|
|
41
|
+
path,
|
|
42
|
+
target,
|
|
43
|
+
data,
|
|
44
|
+
questions,
|
|
45
|
+
baseDir,
|
|
46
|
+
slient
|
|
47
|
+
}) {
|
|
48
|
+
super({ baseDir: baseDir || target, args: data, slient });
|
|
38
49
|
this.path = path;
|
|
39
50
|
this.target = target;
|
|
40
51
|
this.data = data;
|
|
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
21
|
|
|
25
22
|
// src/BaseGenerator/generateFile.ts
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import yParser from '../../compiled/yargs-parser';
|
|
2
|
-
interface
|
|
2
|
+
export interface IGeneratorOpts {
|
|
3
3
|
baseDir: string;
|
|
4
4
|
args: yParser.Arguments;
|
|
5
|
+
slient?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface IGeneratorBaseOpts {
|
|
8
|
+
context: Record<string, any>;
|
|
9
|
+
target: string;
|
|
10
|
+
}
|
|
11
|
+
interface IGeneratorCopyTplOpts extends IGeneratorBaseOpts {
|
|
12
|
+
templatePath: string;
|
|
13
|
+
}
|
|
14
|
+
interface IGeneratorCopyDirectoryOpts extends IGeneratorBaseOpts {
|
|
15
|
+
path: string;
|
|
5
16
|
}
|
|
6
17
|
declare class Generator {
|
|
7
18
|
baseDir: string;
|
|
8
19
|
args: yParser.Arguments;
|
|
20
|
+
slient: boolean;
|
|
9
21
|
prompts: any;
|
|
10
|
-
constructor({ baseDir, args }:
|
|
22
|
+
constructor({ baseDir, args, slient }: IGeneratorOpts);
|
|
11
23
|
run(): Promise<void>;
|
|
12
24
|
prompting(): any;
|
|
13
25
|
writing(): Promise<void>;
|
|
14
|
-
copyTpl(opts:
|
|
15
|
-
|
|
16
|
-
target: string;
|
|
17
|
-
context: object;
|
|
18
|
-
}): void;
|
|
19
|
-
copyDirectory(opts: {
|
|
20
|
-
path: string;
|
|
21
|
-
context: object;
|
|
22
|
-
target: string;
|
|
23
|
-
}): void;
|
|
26
|
+
copyTpl(opts: IGeneratorCopyTplOpts): void;
|
|
27
|
+
copyDirectory(opts: IGeneratorCopyDirectoryOpts): void;
|
|
24
28
|
}
|
|
25
29
|
export default Generator;
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -36,9 +40,10 @@ var import_glob = __toESM(require("../../compiled/glob"));
|
|
|
36
40
|
var import_mustache = __toESM(require("../../compiled/mustache"));
|
|
37
41
|
var import_prompts = __toESM(require("../../compiled/prompts"));
|
|
38
42
|
var Generator = class {
|
|
39
|
-
constructor({ baseDir, args }) {
|
|
43
|
+
constructor({ baseDir, args, slient }) {
|
|
40
44
|
this.baseDir = baseDir;
|
|
41
45
|
this.args = args;
|
|
46
|
+
this.slient = !!slient;
|
|
42
47
|
this.prompts = {};
|
|
43
48
|
}
|
|
44
49
|
async run() {
|
|
@@ -59,9 +64,11 @@ var Generator = class {
|
|
|
59
64
|
const tpl = (0, import_fs.readFileSync)(opts.templatePath, "utf-8");
|
|
60
65
|
const content = import_mustache.default.render(tpl, opts.context);
|
|
61
66
|
import_fs_extra.default.mkdirpSync((0, import_path.dirname)(opts.target));
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
if (!this.slient) {
|
|
68
|
+
console.log(
|
|
69
|
+
`${import_chalk.default.green("Write:")} ${(0, import_path.relative)(this.baseDir, opts.target)}`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
65
72
|
(0, import_fs.writeFileSync)(opts.target, content, "utf-8");
|
|
66
73
|
}
|
|
67
74
|
copyDirectory(opts) {
|
|
@@ -81,7 +88,9 @@ var Generator = class {
|
|
|
81
88
|
context: opts.context
|
|
82
89
|
});
|
|
83
90
|
} else {
|
|
84
|
-
|
|
91
|
+
if (!this.slient) {
|
|
92
|
+
console.log(`${import_chalk.default.green("Copy: ")} ${file}`);
|
|
93
|
+
}
|
|
85
94
|
const absTarget = (0, import_path.join)(opts.target, file);
|
|
86
95
|
import_fs_extra.default.mkdirpSync((0, import_path.dirname)(absTarget));
|
|
87
96
|
(0, import_fs.copyFileSync)(absFile, absTarget);
|
package/dist/getDevBanner.js
CHANGED
|
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
21
|
|
|
25
22
|
// src/getDevBanner.ts
|
|
@@ -32,34 +29,26 @@ var import_address = __toESM(require("../compiled/address"));
|
|
|
32
29
|
var import_chalk = __toESM(require("../compiled/chalk"));
|
|
33
30
|
var import_strip_ansi = __toESM(require("../compiled/strip-ansi"));
|
|
34
31
|
var BORDERS = {
|
|
35
|
-
TL: import_chalk.default.gray.dim("
|
|
36
|
-
TR: import_chalk.default.gray.dim("
|
|
37
|
-
BL: import_chalk.default.gray.dim("
|
|
38
|
-
BR: import_chalk.default.gray.dim("
|
|
39
|
-
V: import_chalk.default.gray.dim("
|
|
40
|
-
H_PURE: "
|
|
32
|
+
TL: import_chalk.default.gray.dim("\u2554"),
|
|
33
|
+
TR: import_chalk.default.gray.dim("\u2557"),
|
|
34
|
+
BL: import_chalk.default.gray.dim("\u255A"),
|
|
35
|
+
BR: import_chalk.default.gray.dim("\u255D"),
|
|
36
|
+
V: import_chalk.default.gray.dim("\u2551"),
|
|
37
|
+
H_PURE: "\u2550"
|
|
41
38
|
};
|
|
42
39
|
function getDevBanner(protocol, host = "0.0.0.0", port, offset = 8) {
|
|
43
40
|
const header = " App listening at:";
|
|
44
|
-
const footer = import_chalk.default.bold(
|
|
45
|
-
|
|
46
|
-
);
|
|
47
|
-
const local = ` ${import_chalk.default.gray(">")} Local: ${import_chalk.default.green(
|
|
48
|
-
`${protocol}//${host === "0.0.0.0" ? "localhost" : host}:${port}`
|
|
49
|
-
)} `;
|
|
41
|
+
const footer = import_chalk.default.bold(" Now you can open browser with the above addresses\u2191 ");
|
|
42
|
+
const local = ` ${import_chalk.default.gray(">")} Local: ${import_chalk.default.green(`${protocol}//${host === "0.0.0.0" ? "localhost" : host}:${port}`)} `;
|
|
50
43
|
const ip = import_address.default.ip();
|
|
51
44
|
const network = ` ${import_chalk.default.gray(">")} Network: ${ip ? import_chalk.default.green(`${protocol}//${ip}:${port}`) : import_chalk.default.gray("Not available")} `;
|
|
52
|
-
const maxLen = Math.max(
|
|
53
|
-
...[header, footer, local, network].map((x) => (0, import_strip_ansi.default)(x).length)
|
|
54
|
-
);
|
|
45
|
+
const maxLen = Math.max(...[header, footer, local, network].map((x) => (0, import_strip_ansi.default)(x).length));
|
|
55
46
|
const beforeLines = [
|
|
56
47
|
`${BORDERS.TL}${import_chalk.default.gray.dim("".padStart(maxLen, BORDERS.H_PURE))}${BORDERS.TR}`,
|
|
57
48
|
`${BORDERS.V}${header}${"".padStart(maxLen - header.length)}${BORDERS.V}`,
|
|
58
49
|
`${BORDERS.V}${local}${"".padStart(maxLen - (0, import_strip_ansi.default)(local).length)}${BORDERS.V}`
|
|
59
50
|
];
|
|
60
|
-
const mainLine = `${BORDERS.V}${network}${"".padStart(
|
|
61
|
-
maxLen - (0, import_strip_ansi.default)(network).length
|
|
62
|
-
)}${BORDERS.V}`;
|
|
51
|
+
const mainLine = `${BORDERS.V}${network}${"".padStart(maxLen - (0, import_strip_ansi.default)(network).length)}${BORDERS.V}`;
|
|
63
52
|
const afterLines = [
|
|
64
53
|
`${BORDERS.V}${"".padStart(maxLen)}${BORDERS.V}`,
|
|
65
54
|
`${BORDERS.V}${footer}${"".padStart(maxLen - (0, import_strip_ansi.default)(footer).length)}${BORDERS.V}`,
|
package/dist/getGitInfo.js
CHANGED
|
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
21
|
|
|
25
22
|
// src/getGitInfo.ts
|
package/dist/importLazy.js
CHANGED
|
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
21
|
|
|
25
22
|
// src/importLazy.ts
|
|
@@ -30,9 +27,7 @@ __export(importLazy_exports, {
|
|
|
30
27
|
module.exports = __toCommonJS(importLazy_exports);
|
|
31
28
|
var import_import_lazy = __toESM(require("../compiled/import-lazy"));
|
|
32
29
|
function importLazy(moduleName, requireFn) {
|
|
33
|
-
const importLazyLocal = (0, import_import_lazy.default)(
|
|
34
|
-
requireFn || require
|
|
35
|
-
);
|
|
30
|
+
const importLazyLocal = (0, import_import_lazy.default)(requireFn || require);
|
|
36
31
|
return importLazyLocal(moduleName);
|
|
37
32
|
}
|
|
38
33
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as chokidar from 'chokidar';
|
|
2
|
+
import * as clackPrompts from '../compiled/@clack/prompts';
|
|
2
3
|
import address from '../compiled/address';
|
|
3
4
|
import axios from '../compiled/axios';
|
|
4
5
|
import chalk from '../compiled/chalk';
|
|
@@ -43,4 +44,4 @@ export * as register from './register';
|
|
|
43
44
|
export * from './setNoDeprecation';
|
|
44
45
|
export * from './tryPaths';
|
|
45
46
|
export * from './winPath';
|
|
46
|
-
export { address, axios, chalk, cheerio, chokidar, crossSpawn, debug, deepmerge, execa, fsExtra, glob, Generator, BaseGenerator, generateFile, installDeps, lodash, logger, Mustache, pkgUp, portfinder, prompts, resolve, rimraf, semver, stripAnsi, updatePackageJSON, yParser, getGitInfo, printHelp, filesize, gzipSize, fastestLevenshtein, };
|
|
47
|
+
export { address, axios, chalk, cheerio, chokidar, crossSpawn, debug, deepmerge, execa, fsExtra, glob, Generator, BaseGenerator, generateFile, installDeps, lodash, logger, Mustache, pkgUp, portfinder, prompts, resolve, rimraf, semver, stripAnsi, updatePackageJSON, yParser, getGitInfo, printHelp, filesize, gzipSize, fastestLevenshtein, clackPrompts, };
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -35,6 +39,7 @@ __export(src_exports, {
|
|
|
35
39
|
chalk: () => import_chalk.default,
|
|
36
40
|
cheerio: () => import_cheerio.default,
|
|
37
41
|
chokidar: () => chokidar,
|
|
42
|
+
clackPrompts: () => clackPrompts,
|
|
38
43
|
crossSpawn: () => import_cross_spawn.default,
|
|
39
44
|
debug: () => import_debug.default,
|
|
40
45
|
deepmerge: () => import_deepmerge.default,
|
|
@@ -63,6 +68,7 @@ __export(src_exports, {
|
|
|
63
68
|
});
|
|
64
69
|
module.exports = __toCommonJS(src_exports);
|
|
65
70
|
var chokidar = __toESM(require("chokidar"));
|
|
71
|
+
var clackPrompts = __toESM(require("../compiled/@clack/prompts"));
|
|
66
72
|
var import_address = __toESM(require("../compiled/address"));
|
|
67
73
|
var import_axios = __toESM(require("../compiled/axios"));
|
|
68
74
|
var import_chalk = __toESM(require("../compiled/chalk"));
|
|
@@ -118,6 +124,7 @@ __reExport(src_exports, require("./winPath"), module.exports);
|
|
|
118
124
|
chalk,
|
|
119
125
|
cheerio,
|
|
120
126
|
chokidar,
|
|
127
|
+
clackPrompts,
|
|
121
128
|
crossSpawn,
|
|
122
129
|
debug,
|
|
123
130
|
deepmerge,
|
package/dist/installDeps.js
CHANGED
|
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
21
|
|
|
25
22
|
// src/installDeps.ts
|
|
@@ -43,18 +40,15 @@ function installDeps({
|
|
|
43
40
|
const devTag = useYarn || usePnpm ? "--D" : "--save-dev";
|
|
44
41
|
const installDependencies = (deps, npmStr, insStr, devStr) => {
|
|
45
42
|
console.log(`${npmStr} install dependencies packages:${deps.join(" ")}`);
|
|
46
|
-
execa.execaCommandSync(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
stdout: "pipe"
|
|
56
|
-
}
|
|
57
|
-
);
|
|
43
|
+
execa.execaCommandSync([npmStr, insStr, devStr].concat(deps).filter((n) => n).join(" "), {
|
|
44
|
+
encoding: "utf8",
|
|
45
|
+
cwd,
|
|
46
|
+
env: {
|
|
47
|
+
...process.env
|
|
48
|
+
},
|
|
49
|
+
stderr: "pipe",
|
|
50
|
+
stdout: "pipe"
|
|
51
|
+
});
|
|
58
52
|
console.log(`install dependencies packages success`);
|
|
59
53
|
};
|
|
60
54
|
if (dependencies) {
|
package/dist/logger.js
CHANGED
|
@@ -41,10 +41,11 @@ module.exports = __toCommonJS(logger_exports);
|
|
|
41
41
|
var import_path = require("path");
|
|
42
42
|
var import_chalk = __toESM(require("../compiled/chalk"));
|
|
43
43
|
var import_fs_extra = __toESM(require("../compiled/fs-extra"));
|
|
44
|
+
var import_pkg_up = require("../compiled/pkg-up");
|
|
44
45
|
var import_importLazy = require("./importLazy");
|
|
45
46
|
var enableFSLogger = process.env.FS_LOGGER !== "none" && !process.versions.webcontainer;
|
|
46
47
|
var profilers = {};
|
|
47
|
-
var loggerDir = (
|
|
48
|
+
var loggerDir = findLoggerDir();
|
|
48
49
|
var loggerPath = (0, import_path.join)(loggerDir, "umi.log");
|
|
49
50
|
var prefixes = {
|
|
50
51
|
wait: import_chalk.default.cyan("wait") + " -",
|
|
@@ -150,6 +151,14 @@ function profile(id, ...message) {
|
|
|
150
151
|
function getLatestLogFilePath() {
|
|
151
152
|
return enableFSLogger ? loggerPath : null;
|
|
152
153
|
}
|
|
154
|
+
function findLoggerDir() {
|
|
155
|
+
let baseDir = process.cwd();
|
|
156
|
+
const pkg = (0, import_pkg_up.pkgUpSync)({ cwd: baseDir });
|
|
157
|
+
if (pkg) {
|
|
158
|
+
baseDir = (0, import_path.dirname)(pkg);
|
|
159
|
+
}
|
|
160
|
+
return (0, import_path.join)(baseDir, "node_modules/.cache/logger");
|
|
161
|
+
}
|
|
153
162
|
// Annotate the CommonJS export names for ESM import in node:
|
|
154
163
|
0 && (module.exports = {
|
|
155
164
|
debug,
|
package/dist/npmClient.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -61,9 +65,11 @@ var installWithNpmClient = ({
|
|
|
61
65
|
cwd
|
|
62
66
|
}) => {
|
|
63
67
|
const { sync } = require("../compiled/cross-spawn");
|
|
68
|
+
const { NODE_ENV: _, ...env } = process.env;
|
|
64
69
|
const npm = sync(npmClient, [npmClient === "yarn" ? "" : "install"], {
|
|
65
70
|
stdio: "inherit",
|
|
66
|
-
cwd
|
|
71
|
+
cwd,
|
|
72
|
+
env
|
|
67
73
|
});
|
|
68
74
|
if (npm.error) {
|
|
69
75
|
throw npm.error;
|
package/dist/printHelp.js
CHANGED
|
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
21
|
|
|
25
22
|
// src/printHelp.ts
|
|
@@ -36,9 +33,7 @@ function exit() {
|
|
|
36
33
|
logger.fatal("A complete log of this run can be found in:");
|
|
37
34
|
logger.fatal(loggerPath);
|
|
38
35
|
}
|
|
39
|
-
logger.fatal(
|
|
40
|
-
"Consider reporting a GitHub issue on https://github.com/umijs/umi/issues"
|
|
41
|
-
);
|
|
36
|
+
logger.fatal("Consider reporting a GitHub issue on https://github.com/umijs/umi/issues");
|
|
42
37
|
}
|
|
43
38
|
function runtime(e) {
|
|
44
39
|
logger.error(e);
|
|
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
21
|
|
|
25
22
|
// src/randomColor/randomColor.ts
|
package/dist/register.js
CHANGED
|
@@ -52,13 +52,10 @@ function transform(opts) {
|
|
|
52
52
|
function register(opts) {
|
|
53
53
|
files = [];
|
|
54
54
|
if (!registered) {
|
|
55
|
-
revert = (0, import_pirates.addHook)(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
ignoreNodeModules: true
|
|
60
|
-
}
|
|
61
|
-
);
|
|
55
|
+
revert = (0, import_pirates.addHook)((code, filename) => transform({ code, filename, implementor: opts.implementor }), {
|
|
56
|
+
ext: opts.exts || HOOK_EXTS,
|
|
57
|
+
ignoreNodeModules: true
|
|
58
|
+
});
|
|
62
59
|
registered = true;
|
|
63
60
|
}
|
|
64
61
|
}
|
|
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
21
|
|
|
25
22
|
// src/updatePackageJSON.ts
|
|
@@ -39,12 +36,9 @@ function updatePackageJSON({
|
|
|
39
36
|
const packageJsonPath = (0, import_path.resolve)(cwd, "package.json");
|
|
40
37
|
const pkg = require(packageJsonPath);
|
|
41
38
|
const projectPkg = (0, import_deepmerge.default)(pkg, opts);
|
|
42
|
-
(0, import_fs.writeFileSync)(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
parser: "json"
|
|
46
|
-
})
|
|
47
|
-
);
|
|
39
|
+
(0, import_fs.writeFileSync)(packageJsonPath, import_prettier.default.format(JSON.stringify(projectPkg), {
|
|
40
|
+
parser: "json"
|
|
41
|
+
}));
|
|
48
42
|
}
|
|
49
43
|
var updatePackageJSON_default = updatePackageJSON;
|
|
50
44
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.52",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/utils#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
6
6
|
"repository": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"pino": "7.11.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
+
"@clack/prompts": "0.2.2",
|
|
28
29
|
"@hapi/joi": "17.1.1",
|
|
29
30
|
"@types/color": "3.0.3",
|
|
30
31
|
"@types/cross-spawn": "6.0.2",
|
|
@@ -97,7 +98,8 @@
|
|
|
97
98
|
"strip-ansi",
|
|
98
99
|
"yargs-parser",
|
|
99
100
|
"pirates",
|
|
100
|
-
"@hapi/joi"
|
|
101
|
+
"@hapi/joi",
|
|
102
|
+
"@clack/prompts"
|
|
101
103
|
],
|
|
102
104
|
"externals": {
|
|
103
105
|
"address": "$$LOCAL",
|