create-vuepress-theme-hope 2.0.0-beta.63 → 2.0.0-beta.66
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/lib/index.js +1 -1
- package/package.json +1 -1
- package/template/en-US/guide/markdown.md +6 -12
- package/template/en-US/home.md +1 -1
- package/template/en-US/slide.md +1 -1
- package/template/i18n/guide/markdown.md +6 -12
- package/template/i18n/home.md +1 -1
- package/template/i18n/slide.md +1 -1
- package/template/i18n/zh/guide/markdown.md +5 -11
- package/template/zh-CN/guide/markdown.md +5 -11
package/lib/index.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
|
|
7
7
|
*
|
|
8
8
|
* MIT Licensed
|
|
9
|
-
*/(),i=process.binding("constants"),o=n(),u="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",a=/XXXXXX/,s=(i.O_CREAT||i.fs.O_CREAT)|(i.O_EXCL||i.fs.O_EXCL)|(i.O_RDWR||i.fs.O_RDWR),c=i.EBADF||i.os.errno.EBADF,l=i.ENOENT||i.os.errno.ENOENT,f=[];var d=!1,p=!1;function b(e){var t=[],n=null;try{n=r.randomBytes(e)}catch(t){n=r.pseudoRandomBytes(e)}for(var i=0;i<e;i++)t.push(u[n[i]%u.length]);return t.join("")}function m(e){return void 0===e}function y(e,t){return"function"==typeof e?[t||{},e]:m(e)?[{},t]:[e,t]}function g(e){if(e.name)return t.join(e.dir||o,e.name);if(e.template)return e.template.replace(a,b(6));const r=[e.prefix||"tmp-",process.pid,b(12),e.postfix||""].join("");return t.join(e.dir||o,r)}function D(t,r){var n=y(t,r),i=n[0],o=n[1],u=i.name?1:i.tries||3;return isNaN(u)||u<0?o(new Error("Invalid tries")):i.template&&!i.template.match(a)?o(new Error("Invalid template provided")):void function t(){const r=g(i);e.stat(r,(function(e){if(!e)return u-- >0?t():o(new Error("Could not get a unique tmp filename, max tries reached "+r));o(null,r)}))}()}function _(t){var r=y(t)[0],n=r.name?1:r.tries||3;if(isNaN(n)||n<0)throw new Error("Invalid tries");if(r.template&&!r.template.match(a))throw new Error("Invalid template provided");do{const t=g(r);try{e.statSync(t)}catch(e){return t}}while(n-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function w(r){const n=[r];do{for(var i=n.pop(),o=!1,u=e.readdirSync(i),a=0,s=u.length;a<s;a++){var c=t.join(i,u[a]);e.lstatSync(c).isDirectory()?(o||(o=!0,n.push(i)),n.push(c)):e.unlinkSync(c)}o||e.rmdirSync(i)}while(0!==n.length)}function O(t,r,n){const i=j((function(t){try{0<=t[0]&&e.closeSync(t[0])}catch(e){if(!function(e){return P(e,-c,"EBADF")}(e)&&!C(e))throw e}try{e.unlinkSync(t[1])}catch(e){if(!C(e))throw e}}),[r,t]);return n.keep||f.unshift(i),i}function S(t,r){const n=j(r.unsafeCleanup?w:e.rmdirSync.bind(e),t);return r.keep||f.unshift(n),n}function j(e,t){var r=!1;return function n(i){if(!r){const i=f.indexOf(n);i>=0&&f.splice(i,1),r=!0,e(t)}i&&i(null)}}function x(){if(!p||d)for(;f.length;)try{f[0].call(null)}catch(e){}}function C(e){return P(e,-l,"ENOENT")}function P(e,t,r){return e.code==t||e.code==r}const F=process.versions.node.split(".").map((function(e){return parseInt(e,10)}));return 0===F[0]&&(F[1]<9||9===F[1]&&F[2]<5)&&process.addListener("uncaughtException",(function(e){throw p=!0,x(),e})),process.addListener("exit",(function(e){e&&(p=!0),x()})),nM.tmpdir=o,nM.dir=function(t,r){var n=y(t,r),i=n[0],o=n[1];D(i,(function(t,r){if(t)return o(t);e.mkdir(r,i.mode||448,(function(e){if(e)return o(e);o(null,r,S(r,i))}))}))},nM.dirSync=function(t){var r=y(t)[0];const n=_(r);return e.mkdirSync(n,r.mode||448),{name:n,removeCallback:S(n,r)}},nM.file=function(t,r){var n=y(t,r),i=n[0],o=n[1];i.postfix=m(i.postfix)?".tmp":i.postfix,D(i,(function(t,r){if(t)return o(t);e.open(r,s,i.mode||384,(function(t,n){return t?o(t):i.discardDescriptor?e.close(n,(function(t){if(t){try{e.unlinkSync(r)}catch(e){C(e)||(t=e)}return o(t)}o(null,r,void 0,O(r,-1,i))})):i.detachDescriptor?o(null,r,n,O(r,-1,i)):void o(null,r,n,O(r,n,i))}))}))},nM.fileSync=function(t){var r=y(t)[0];r.postfix=r.postfix||".tmp";const n=r.discardDescriptor||r.detachDescriptor,i=_(r);var o=e.openSync(i,s,r.mode||384);return r.discardDescriptor&&(e.closeSync(o),o=void 0),{name:i,fd:o,removeCallback:O(i,n?-1:o,r)}},nM.tmpName=D,nM.tmpNameSync=_,nM.setGracefulCleanup=function(){d=!0},nM}var oM,uM={};var aM,sM={};var cM,lM={};var fM,dM,pM,hM,bM={};function vM(){if(dM)return $A;dM=1,Object.defineProperty($A,"__esModule",{value:!0});var e=function(){if(rT)return qA;rT=1;var e=v.default,t=VA(),r=HA(),n=XA(),i=eT(),o=iT(),u=S,a=[new t,new r.UTF_16BE,new r.UTF_16LE,new r.UTF_32BE,new r.UTF_32LE,new n.sjis,new n.big5,new n.euc_jp,new n.euc_kr,new n.gb_18030,new o.ISO_2022_JP,new o.ISO_2022_KR,new o.ISO_2022_CN,new i.ISO_8859_1,new i.ISO_8859_2,new i.ISO_8859_5,new i.ISO_8859_6,new i.ISO_8859_7,new i.ISO_8859_8,new i.ISO_8859_9,new i.windows_1251,new i.windows_1256,new i.KOI8_R];return qA.detect=function(e,t){for(var r=[],n=0;n<256;n++)r[n]=0;for(n=e.length-1;n>=0;n--)r[255&e[n]]++;var i=!1;for(n=128;n<=159;n+=1)if(0!=r[n]){i=!0;break}var o={fByteStats:r,fC1Bytes:i,fRawInput:e,fRawLength:e.length,fInputBytes:e,fInputLen:e.length},u=a.map((function(e){return e.match(o)})).filter((function(e){return!!e})).sort((function(e,t){return t.confidence-e.confidence}));return t&&!0===t.returnAllMatches?u:u.length>0?u[0].name:null},qA.detectFile=function(t,r,n){var i;"function"==typeof r&&(n=r,r=void 0);var o=function(t,o){if(i&&e.closeSync(i),t)return n(t,null);n(null,u.detect(o,r))};if(r&&r.sampleSize)return i=e.openSync(t,"r"),sample=Buffer.allocUnsafe(r.sampleSize),void e.read(i,sample,0,r.sampleSize,null,(function(e){o(e,sample)}));e.readFile(t,o)},qA.detectFileSync=function(t,r){if(r&&r.sampleSize){var n=e.openSync(t,"r"),i=Buffer.allocUnsafe(r.sampleSize);return e.readSync(n,i,0,r.sampleSize),e.closeSync(n),u.detect(i,r)}return u.detect(e.readFileSync(t),r)},qA.detectAll=function(e,t){return"object"!=typeof t&&(t={}),t.returnAllMatches=!0,u.detect(e,t)},qA.detectFileAll=function(e,t,r){"function"==typeof t&&(r=t,t=void 0),"object"!=typeof t&&(t={}),t.returnAllMatches=!0,u.detectFile(e,t,r)},qA.detectFileAllSync=function(e,t){return"object"!=typeof t&&(t={}),t.returnAllMatches=!0,u.detectFileSync(e,t)},qA}(),t=b.default,r=v.default,n=ZT(),i=iM(),o=function(){if(oM)return uM;oM=1;var e=S&&S.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(uM,"__esModule",{value:!0});var t=function(t){function r(e){var r=this.constructor,n=t.call(this,"Failed to create temporary file for editor")||this;n.originalError=e;var i=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=r.prototype,n}return e(r,t),r}(Error);return uM.CreateFileError=t,uM}();$A.CreateFileError=o.CreateFileError;var u=function(){if(aM)return sM;aM=1;var e=S&&S.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(sM,"__esModule",{value:!0});var t=function(t){function r(e){var r=this.constructor,n=t.call(this,"Failed launch editor")||this;n.originalError=e;var i=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=r.prototype,n}return e(r,t),r}(Error);return sM.LaunchEditorError=t,sM}();$A.LaunchEditorError=u.LaunchEditorError;var a=function(){if(cM)return lM;cM=1;var e=S&&S.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(lM,"__esModule",{value:!0});var t=function(t){function r(e){var r=this.constructor,n=t.call(this,"Failed to read temporary file")||this;n.originalError=e;var i=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=r.prototype,n}return e(r,t),r}(Error);return lM.ReadFileError=t,lM}();$A.ReadFileError=a.ReadFileError;var s=function(){if(fM)return bM;fM=1;var e=S&&S.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(bM,"__esModule",{value:!0});var t=function(t){function r(e){var r=this.constructor,n=t.call(this,"Failed to cleanup temporary file")||this;n.originalError=e;var i=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=r.prototype,n}return e(r,t),r}(Error);return bM.RemoveFileError=t,bM}();$A.RemoveFileError=s.RemoveFileError,$A.edit=function(e,t){void 0===e&&(e="");var r=new c(e,t);return r.run(),r.cleanup(),r.text},$A.editAsync=function(e,t,r){void 0===e&&(e="");var n=new c(e,r);n.runAsync((function(e,r){if(e)setImmediate(t,e,null);else try{n.cleanup(),setImmediate(t,null,r)}catch(e){setImmediate(t,e,null)}}))};var c=function(){function c(e,t){void 0===e&&(e=""),this.text="",this.fileOptions={},this.text=e,t&&(this.fileOptions=t),this.determineEditor(),this.createTemporaryFile()}return c.splitStringBySpace=function(e){for(var t=[],r="",n=0;n<e.length;n++){var i=e[n];n>0&&" "===i&&"\\"!==e[n-1]&&r.length>0?(t.push(r),r=""):r+=i}return r.length>0&&t.push(r),t},Object.defineProperty(c.prototype,"temp_file",{get:function(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"last_exit_status",{get:function(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus},enumerable:!0,configurable:!0}),c.prototype.run=function(){return this.launchEditor(),this.readTemporaryFile(),this.text},c.prototype.runAsync=function(e){var t=this;try{this.launchEditorAsync((function(){try{t.readTemporaryFile(),setImmediate(e,null,t.text)}catch(t){setImmediate(e,t,null)}}))}catch(t){setImmediate(e,t,null)}},c.prototype.cleanup=function(){this.removeTemporaryFile()},c.prototype.determineEditor=function(){var e=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:/^win/.test(process.platform)?"notepad":"vim",t=c.splitStringBySpace(e).map((function(e){return e.replace("\\ "," ")})),r=t.shift();this.editor={args:t,bin:r}},c.prototype.createTemporaryFile=function(){try{this.tempFile=i.tmpNameSync(this.fileOptions);var e={encoding:"utf8"};this.fileOptions.hasOwnProperty("mode")&&(e.mode=this.fileOptions.mode),r.writeFileSync(this.tempFile,this.text,e)}catch(e){throw new o.CreateFileError(e)}},c.prototype.readTemporaryFile=function(){try{var t=r.readFileSync(this.tempFile);if(0===t.length)this.text="";else{var i=e.detect(t).toString();n.encodingExists(i)||(i="utf8"),this.text=n.decode(t,i)}}catch(e){throw new a.ReadFileError(e)}},c.prototype.removeTemporaryFile=function(){try{r.unlinkSync(this.tempFile)}catch(e){throw new s.RemoveFileError(e)}},c.prototype.launchEditor=function(){try{var e=t.spawnSync(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=e.status}catch(e){throw new u.LaunchEditorError(e)}},c.prototype.launchEditorAsync=function(e){var r=this;try{t.spawn(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",(function(t){r.lastExitStatus=t,setImmediate(e)}))}catch(e){throw new u.LaunchEditorError(e)}},c}();return $A.ExternalEditor=c,$A}!function(e){const t=e.exports;t.prompts={},t.Separator=ti,t.ui={BottomBar:vi,Prompt:CE},t.createPromptModule=function(e){const r=function(n,i){let o;try{o=new t.ui.Prompt(r.prompts,e)}catch(e){return Promise.reject(e)}const u=o.run(n,i);return u.ui=o,u};return r.prompts={},r.registerPrompt=function(e,t){return r.prompts[e]=t,this},r.restoreDefaultPrompts=function(){this.registerPrompt("list",MA()),this.registerPrompt("input",kA()),this.registerPrompt("number",function(){if(aA)return uA;aA=1;const e=kA();return uA=class extends e{filterInput(e){if(e&&"string"==typeof e){const t=(e=e.trim()).match(/(^-?\d+|^-?\d+\.\d*|^\d*\.\d+)(e\d+)?$/);if(t)return Number(t[0])}return null==this.opt.default?NaN:this.opt.default}},uA}()),this.registerPrompt("confirm",function(){if(cA)return sA;cA=1;const e=zn,{take:t,takeUntil:r}=OO,n=PA(),i=FA();return sA=class extends n{constructor(e,t,r){super(e,t,r);let n=!0;Object.assign(this.opt,{filter(e){let t=n;return null!=e&&""!==e&&(t=/^y(es)?/i.test(e)),t}}),null!=this.opt.default&&(n=Boolean(this.opt.default)),this.opt.default=n?"Y/n":"y/N"}_run(e){this.done=e;const n=i(this.rl);return n.keypress.pipe(r(n.line)).forEach(this.onKeypress.bind(this)),n.line.pipe(t(1)).forEach(this.onEnd.bind(this)),this.render(),this}render(t){let r=this.getQuestion();return r+="boolean"==typeof t?e.cyan(t?"Yes":"No"):this.rl.line,this.screen.render(r),this}onEnd(e){this.status="answered";const t=this.opt.filter(e);this.render(t),this.screen.done(),this.done(t)}onKeypress(){this.render()}},sA}()),this.registerPrompt("rawlist",BA()),this.registerPrompt("expand",IA()),this.registerPrompt("checkbox",RA()),this.registerPrompt("password",function(){if(mA)return vA;mA=1;const e=zn,{map:t,takeUntil:r}=OO,n=PA(),i=FA();function o(e,t){return t="string"==typeof t?t:"*",0===(e=String(e)).length?"":new Array(e.length+1).join(t)}return vA=class extends n{_run(e){this.done=e;const n=i(this.rl),o=n.line.pipe(t(this.filterInput.bind(this))),u=this.handleSubmitEvents(o);return u.success.forEach(this.onEnd.bind(this)),u.error.forEach(this.onError.bind(this)),n.keypress.pipe(r(u.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),n="";"answered"===this.status?r+=this.getMaskedValue(this.answer):r+=this.getMaskedValue(this.rl.line||""),t&&(n="\n"+e.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return"answered"===this.status?this.opt.mask?e.cyan(o(t,this.opt.mask)):e.italic.dim("[hidden]"):this.opt.mask?o(t,this.opt.mask):e.italic.dim("[input is hidden] ")}getSpinningValue(e){return this.getMaskedValue(e)}filterInput(e){return e||(null==this.opt.default?"":this.opt.default)}onEnd(e){this.status="answered",this.answer=e.value,this.render(),this.screen.done(),this.done(e.value)}onError(e){this.render(e.isValid)}onKeypress(){this.opt.default&&(this.opt.default=void 0),this.render()}},vA}()),this.registerPrompt("editor",function(){if(hM)return pM;hM=1;const e=zn,{editAsync:t}=vM(),r=PA(),n=FA(),{Subject:i}=ma;return pM=class extends r{_run(e){this.done=e,this.editorResult=new i;const t=n(this.rl);this.lineSubscription=t.line.subscribe(this.startExternalEditor.bind(this));const r=this.handleSubmitEvents(this.editorResult);return r.success.forEach(this.onEnd.bind(this)),r.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,this.render(),this}render(t){let r="",n=this.getQuestion();"answered"===this.status?n+=e.dim("Received"):n+=e.dim("Press <enter> to launch your preferred editor."),t&&(r=e.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),t(this.currentText,this.endExternalEditor.bind(this))}endExternalEditor(e,t){this.rl.resume(),e?this.editorResult.error(e):this.editorResult.next(t)}onEnd(e){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(e){this.render(e.isValid)}},pM}())},r.restoreDefaultPrompts(),r},t.prompt=t.createPromptModule(),t.registerPrompt=function(e,r){t.prompt.registerPrompt(e,r)},t.restoreDefaultPrompts=function(){t.prompt.restoreDefaultPrompts()}}(sn);const mM=(()=>{try{return 0===Xr("pnpm --version",{stdio:"ignore"}).exitCode}catch(e){return!1}})()?"pnpm":(()=>{try{return 0===Xr("yarn --version",{stdio:"ignore"}).exitCode}catch(e){return!1}})()?"yarn":"npm",yM={"简体中文":{getVersion:"获取依赖的最新版本...",createPackage:"生成 package.json...",updatePackage:"更新 package.json...",template:"生成模板...",wait:"这可能需要数分钟,请耐心等待.\n我们无法正确输出子进程的进度条,所以进程可能会看似未响应",install:"安装依赖...",success:"模板已成功生成!",devServerAsk:"是否想要现在启动 Demo 查看?",devServer:"启动开发服务器...\n启动成功后,请在浏览器输入给出的开发服务器地址(默认为 'localhost:8080')",hint:`提示: 请使用 "${mM} run docs:dev" 命令启动开发服务器`,nameMessage:"设置应用名称",nameError:"应用名称应只包含小写字母、数字和连接线 (-)",versionMessage:"设置应用版本号",versionError:"此版本无效,版本号应为 'x.x.x'",dirError:'"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "src", "docs" 等!\n例如: "npm init vuepress-theme-hope@next docs"',descriptionMessage:"设置应用描述",licenseMessage:"设置协议",i18nMessage:"项目需要用到多语言么?",workflowMessage:"是否需要一个自动部署文档到 GitHub Pages 的工作流?"},"english (US)":{getVersion:"Getting lastest version of deps...",createPackage:"Generating package.json...",updatePackage:"Updating package.json...",template:"Generating Template...",wait:"This may take a few minutes, please be patient.\nWe can not correctly output progress bar from child process, so the process may look stuck.",install:"Installing Deps...",success:"Successful Generated!",devServerAsk:"Would you like to preview template now?",devServer:"Staring dev server...\nAfter the dev server starts running, please visit the given server link ('localhost:8080' by default)",hint:`Hint: You should execute "${mM} run docs:dev" to start dev server.`,nameMessage:"Your project name",nameError:"package name should only contain lowercase characters, numbers and dash",versionMessage:"Your project version",versionError:"This version is not a valid one. Version should be like 'x.x.x'",dirError:'The brackets in "[dir]" means it is an argument, you should replace it with folder name you want to use! E.g.: "src", "docs"\nFor example: "npm init vuepress-theme-hope@next docs"',descriptionMessage:"Your project description",licenseMessage:"Your project lincense",i18nMessage:"Does the project need multiple languages?",workflowMessage:"Do you need a GitHub workflow to deploy docs on GitHub pages?"}},gM=async e=>{for(let t=1;t<=3;t++){const r=await new Promise(((t,r)=>{f.get(`${"npm"===mM?"https://registry.npmjs.org":"https://registry.yarnpkg.com"}/-/package/${e}/dist-tags`,(e=>{if(200===e.statusCode){let r="";e.on("data",(e=>r+=e)),e.on("end",(()=>{t(JSON.parse(r).next)}))}else r()})).on("error",(()=>{r()}))})).catch((()=>{console.log(`Get ${e} version failed, [${t}/3]`)}));if(r)return r}throw new Error(`Get ${e} version failed!`)},DM=(e,...t)=>{if(0===t.length)return e;const r=t.shift()||{};return Object.keys(r).forEach((t=>{"object"!=typeof e[t]||Array.isArray(e[t])||"object"!=typeof r[t]||Array.isArray(r[t])?"object"==typeof r[t]?Array.isArray(r[t])?e[t]=[...r[t]]:e[t]={...r[t]}:e[t]=r[t]:DM(e[t],r[t])})),DM(e,...t)},_M=async(t,n)=>{const i=e.resolve(process.cwd(),"package.json"),o=(e=>({"docs:build":`vuepress build ${e}`,"docs:clean-dev":`vuepress dev ${e} --clean-cache`,"docs:dev":`vuepress dev ${e}`}))(t),u=await(async e=>Object.fromEntries(await Promise.all(e.map((async e=>[e,`^${await gM(e)}`])))))(["@vuepress/client","vue","vuepress","vuepress-theme-hope"]);if(r.existsSync(i)){console.log(n.updatePackage);const e=JSON.parse(r.readFileSync(i,{encoding:"utf-8"}));DM(e,{scripts:o,devDependencies:u}),r.writeFileSync(i,`${JSON.stringify(e,null,2)}\n`,{encoding:"utf-8"})}else{console.log(n.createPackage);const e=await sn.exports.prompt([{name:"name",type:"input",message:n.nameMessage,default:"vuepress-theme-hope-template",validate:e=>!!/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/u.exec(e)||n.nameError},{name:"version",type:"input",message:n.versionMessage,default:"2.0.0",validate:e=>!!/^[0-9]+\.[0-9]+\.(?:[0=9]+|[0-9]+-[a-z]+\.[0-9])$/u.exec(e)||n.versionError},{name:"description",type:"input",message:n.descriptionMessage,default:"A project of vuepress-theme-hope"},{name:"license",type:"input",message:n.licenseMessage,default:"MIT"}]),t={...e,scripts:o,devDependencies:u};r.writeFileSync(i,`${JSON.stringify(t,null,2)}\n`,{encoding:"utf-8"})}},wM=async e=>{const t=Xr(mM,["config","get","registry"]).stdout;if("简体中文"===e){const{registry:e}=await sn.exports.prompt([{name:"registry",type:"list",message:"选择你想使用的源",choices:["国内镜像源","当前源"]}]);return"国内镜像源"===e?"https://registry.npmmirror.com/":t}return t},OM=e=>{try{r.readdirSync(e)}catch(t){r.mkdirSync(e,{recursive:!0})}},EM=(t,n)=>{const i=e.dirname(n);OM(i);const o=r.createReadStream(t),u=r.createWriteStream(n);o.pipe(u)},SM=(e,t)=>{OM(t);r.readdirSync(e,{withFileTypes:!0}).forEach((r=>{r.isFile()?EM(`${e}/${r.name}`,`${t}/${r.name}`):r.isDirectory()&&SM(`${e}/${r.name}`,`${t}/${r.name}`)}))},jM=async(t,n,i)=>{const{i18n:o,workflow:u}=await sn.exports.prompt([{name:"i18n",type:"confirm",message:i.i18nMessage,default:!1},{name:"workflow",type:"confirm",message:i.workflowMessage,default:!0}]);console.log(i.template);const a=o?"i18n":"简体中文"===n?"zh-CN":"en-US";var s,c;if(s=e.resolve(__dirname,"../template",a),c=e.resolve(process.cwd(),t),r.statSync(s).isDirectory()?SM(s,c):r.statSync(s).isFile()&&EM(s,c),u){const i=e.resolve(process.cwd(),".github/workflows");OM(i),r.writeFileSync(e.resolve(i,"deploy-docs.yml"),((t,r)=>`\nname: ${"简体中文"===r?"部署文档":"Deploy Docs"}\n\non:\n push:\n branches:\n # ${"简体中文"===r?"确保这是你正在使用的分支名称":"make sure this is the branch you are using"}\n - main\n\njobs:\n deploy-gh-pages:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v3\n with:\n fetch-depth: 0\n # ${"简体中文"===r?"如果你文档需要 Git 子模块,取消注释下一行":"if your docs needs submodules, uncomment the following line"}\n # submodules: true\n\n${"pnpm"===mM?`\n - name: ${"简体中文"===r?"安装 pnpm":"Install pnpm"}\n uses: pnpm/action-setup@v2\n with:\n version: 7\n run_install: true\n`:""}\n\n - name: ${"简体中文"===r?"设置 Node.js":"Setup Node.js"}\n uses: actions/setup-node@v3\n with:\n node-version: 16\n cache: ${mM}\n\n - name: ${"简体中文"===r?"安装依赖":"Install Deps"}\n run: ${"npm"===mM?"npm install":`${mM} install --frozen-lockfile`}\n\n - name: ${"简体中文"===r?"构建文档":"Build Docs"}\n env:\n NODE_OPTIONS: --max_old_space_size=4096\n run: ${mM} run docs:build\n\n - name: ${"简体中文"===r?"部署文档":"Deploy Docs"}\n uses: JamesIves/github-pages-deploy-action@v4\n with:\n # ${"简体中文"===r?"这是文档部署到的分支名称":"This is the branch where the docs are deployed to"}\n branch: gh-pages\n folder: ${e.join(t,".vuepress/dist").replace(/\\/g,"/")}\n\n`)(t,n),{encoding:"utf-8"})}const l=e.resolve(process.cwd(),".gitignore"),f=r.existsSync(l)?r.readFileSync(l,{encoding:"utf-8"}):"";r.writeFileSync(l,`${f}${(e=>`\nnode_modules/\n${e}/.vuepress/.cache/\n${e}/.vuepress/.temp/\n${e}/.vuepress/dist/\n`)(t)}`,{encoding:"utf-8"})},xM=((e="")=>new re(e))("vuepress-theme-hope"),CM=require("../package.json").version;xM.command("[dir]","Generate a new vuepress-theme-hope project").usage("pnpm create vuepress-theme-hope@next [dir] / npm init vuepress-theme-hope@next [dir]").example("docs").action((async e=>{if(!e)return xM.outputHelp();const{lang:t,message:r}=await(async()=>{const{language:e}=await sn.exports.prompt([{name:"language",type:"list",message:"Select a language to display / 选择显示语言",choices:["english (US)","简体中文"]}]);return{lang:e,message:yM[e]}})();if(e.startsWith("[")&&e.endsWith("]"))return console.log(r.dirError);console.log(r.getVersion),await _M(e,r),await jM(e,t,r);const n=await wM(t);console.log(r.install),console.warn(r.wait),se.exports.sync(mM,["install",..."pnpm"===mM?[]:["--registry",n]],{stdout:"inherit"}),console.log(r.success);const{choise:i}=await sn.exports.prompt([{name:"choise",type:"confirm",message:r.devServerAsk,default:!0}]);i?(console.log(r.devServer),await se.exports(mM,["run","docs:dev"],{stdout:"inherit"})):console.log(r.hint)})),xM.help((()=>[{title:"pnpm create vuepress-theme-hope@next [dir] / npm init vuepress-theme-hope@next [dir]",body:"Create a vuepress-theme-hope template in [dir]"}])),xM.version(CM),xM.parse();
|
|
9
|
+
*/(),i=process.binding("constants"),o=n(),u="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",a=/XXXXXX/,s=(i.O_CREAT||i.fs.O_CREAT)|(i.O_EXCL||i.fs.O_EXCL)|(i.O_RDWR||i.fs.O_RDWR),c=i.EBADF||i.os.errno.EBADF,l=i.ENOENT||i.os.errno.ENOENT,f=[];var d=!1,p=!1;function b(e){var t=[],n=null;try{n=r.randomBytes(e)}catch(t){n=r.pseudoRandomBytes(e)}for(var i=0;i<e;i++)t.push(u[n[i]%u.length]);return t.join("")}function m(e){return void 0===e}function y(e,t){return"function"==typeof e?[t||{},e]:m(e)?[{},t]:[e,t]}function g(e){if(e.name)return t.join(e.dir||o,e.name);if(e.template)return e.template.replace(a,b(6));const r=[e.prefix||"tmp-",process.pid,b(12),e.postfix||""].join("");return t.join(e.dir||o,r)}function D(t,r){var n=y(t,r),i=n[0],o=n[1],u=i.name?1:i.tries||3;return isNaN(u)||u<0?o(new Error("Invalid tries")):i.template&&!i.template.match(a)?o(new Error("Invalid template provided")):void function t(){const r=g(i);e.stat(r,(function(e){if(!e)return u-- >0?t():o(new Error("Could not get a unique tmp filename, max tries reached "+r));o(null,r)}))}()}function _(t){var r=y(t)[0],n=r.name?1:r.tries||3;if(isNaN(n)||n<0)throw new Error("Invalid tries");if(r.template&&!r.template.match(a))throw new Error("Invalid template provided");do{const t=g(r);try{e.statSync(t)}catch(e){return t}}while(n-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function w(r){const n=[r];do{for(var i=n.pop(),o=!1,u=e.readdirSync(i),a=0,s=u.length;a<s;a++){var c=t.join(i,u[a]);e.lstatSync(c).isDirectory()?(o||(o=!0,n.push(i)),n.push(c)):e.unlinkSync(c)}o||e.rmdirSync(i)}while(0!==n.length)}function O(t,r,n){const i=j((function(t){try{0<=t[0]&&e.closeSync(t[0])}catch(e){if(!function(e){return P(e,-c,"EBADF")}(e)&&!C(e))throw e}try{e.unlinkSync(t[1])}catch(e){if(!C(e))throw e}}),[r,t]);return n.keep||f.unshift(i),i}function S(t,r){const n=j(r.unsafeCleanup?w:e.rmdirSync.bind(e),t);return r.keep||f.unshift(n),n}function j(e,t){var r=!1;return function n(i){if(!r){const i=f.indexOf(n);i>=0&&f.splice(i,1),r=!0,e(t)}i&&i(null)}}function x(){if(!p||d)for(;f.length;)try{f[0].call(null)}catch(e){}}function C(e){return P(e,-l,"ENOENT")}function P(e,t,r){return e.code==t||e.code==r}const F=process.versions.node.split(".").map((function(e){return parseInt(e,10)}));return 0===F[0]&&(F[1]<9||9===F[1]&&F[2]<5)&&process.addListener("uncaughtException",(function(e){throw p=!0,x(),e})),process.addListener("exit",(function(e){e&&(p=!0),x()})),nM.tmpdir=o,nM.dir=function(t,r){var n=y(t,r),i=n[0],o=n[1];D(i,(function(t,r){if(t)return o(t);e.mkdir(r,i.mode||448,(function(e){if(e)return o(e);o(null,r,S(r,i))}))}))},nM.dirSync=function(t){var r=y(t)[0];const n=_(r);return e.mkdirSync(n,r.mode||448),{name:n,removeCallback:S(n,r)}},nM.file=function(t,r){var n=y(t,r),i=n[0],o=n[1];i.postfix=m(i.postfix)?".tmp":i.postfix,D(i,(function(t,r){if(t)return o(t);e.open(r,s,i.mode||384,(function(t,n){return t?o(t):i.discardDescriptor?e.close(n,(function(t){if(t){try{e.unlinkSync(r)}catch(e){C(e)||(t=e)}return o(t)}o(null,r,void 0,O(r,-1,i))})):i.detachDescriptor?o(null,r,n,O(r,-1,i)):void o(null,r,n,O(r,n,i))}))}))},nM.fileSync=function(t){var r=y(t)[0];r.postfix=r.postfix||".tmp";const n=r.discardDescriptor||r.detachDescriptor,i=_(r);var o=e.openSync(i,s,r.mode||384);return r.discardDescriptor&&(e.closeSync(o),o=void 0),{name:i,fd:o,removeCallback:O(i,n?-1:o,r)}},nM.tmpName=D,nM.tmpNameSync=_,nM.setGracefulCleanup=function(){d=!0},nM}var oM,uM={};var aM,sM={};var cM,lM={};var fM,dM,pM,hM,bM={};function vM(){if(dM)return $A;dM=1,Object.defineProperty($A,"__esModule",{value:!0});var e=function(){if(rT)return qA;rT=1;var e=v.default,t=VA(),r=HA(),n=XA(),i=eT(),o=iT(),u=S,a=[new t,new r.UTF_16BE,new r.UTF_16LE,new r.UTF_32BE,new r.UTF_32LE,new n.sjis,new n.big5,new n.euc_jp,new n.euc_kr,new n.gb_18030,new o.ISO_2022_JP,new o.ISO_2022_KR,new o.ISO_2022_CN,new i.ISO_8859_1,new i.ISO_8859_2,new i.ISO_8859_5,new i.ISO_8859_6,new i.ISO_8859_7,new i.ISO_8859_8,new i.ISO_8859_9,new i.windows_1251,new i.windows_1256,new i.KOI8_R];return qA.detect=function(e,t){for(var r=[],n=0;n<256;n++)r[n]=0;for(n=e.length-1;n>=0;n--)r[255&e[n]]++;var i=!1;for(n=128;n<=159;n+=1)if(0!=r[n]){i=!0;break}var o={fByteStats:r,fC1Bytes:i,fRawInput:e,fRawLength:e.length,fInputBytes:e,fInputLen:e.length},u=a.map((function(e){return e.match(o)})).filter((function(e){return!!e})).sort((function(e,t){return t.confidence-e.confidence}));return t&&!0===t.returnAllMatches?u:u.length>0?u[0].name:null},qA.detectFile=function(t,r,n){var i;"function"==typeof r&&(n=r,r=void 0);var o=function(t,o){if(i&&e.closeSync(i),t)return n(t,null);n(null,u.detect(o,r))};if(r&&r.sampleSize)return i=e.openSync(t,"r"),sample=Buffer.allocUnsafe(r.sampleSize),void e.read(i,sample,0,r.sampleSize,null,(function(e){o(e,sample)}));e.readFile(t,o)},qA.detectFileSync=function(t,r){if(r&&r.sampleSize){var n=e.openSync(t,"r"),i=Buffer.allocUnsafe(r.sampleSize);return e.readSync(n,i,0,r.sampleSize),e.closeSync(n),u.detect(i,r)}return u.detect(e.readFileSync(t),r)},qA.detectAll=function(e,t){return"object"!=typeof t&&(t={}),t.returnAllMatches=!0,u.detect(e,t)},qA.detectFileAll=function(e,t,r){"function"==typeof t&&(r=t,t=void 0),"object"!=typeof t&&(t={}),t.returnAllMatches=!0,u.detectFile(e,t,r)},qA.detectFileAllSync=function(e,t){return"object"!=typeof t&&(t={}),t.returnAllMatches=!0,u.detectFileSync(e,t)},qA}(),t=b.default,r=v.default,n=ZT(),i=iM(),o=function(){if(oM)return uM;oM=1;var e=S&&S.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(uM,"__esModule",{value:!0});var t=function(t){function r(e){var r=this.constructor,n=t.call(this,"Failed to create temporary file for editor")||this;n.originalError=e;var i=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=r.prototype,n}return e(r,t),r}(Error);return uM.CreateFileError=t,uM}();$A.CreateFileError=o.CreateFileError;var u=function(){if(aM)return sM;aM=1;var e=S&&S.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(sM,"__esModule",{value:!0});var t=function(t){function r(e){var r=this.constructor,n=t.call(this,"Failed launch editor")||this;n.originalError=e;var i=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=r.prototype,n}return e(r,t),r}(Error);return sM.LaunchEditorError=t,sM}();$A.LaunchEditorError=u.LaunchEditorError;var a=function(){if(cM)return lM;cM=1;var e=S&&S.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(lM,"__esModule",{value:!0});var t=function(t){function r(e){var r=this.constructor,n=t.call(this,"Failed to read temporary file")||this;n.originalError=e;var i=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=r.prototype,n}return e(r,t),r}(Error);return lM.ReadFileError=t,lM}();$A.ReadFileError=a.ReadFileError;var s=function(){if(fM)return bM;fM=1;var e=S&&S.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(bM,"__esModule",{value:!0});var t=function(t){function r(e){var r=this.constructor,n=t.call(this,"Failed to cleanup temporary file")||this;n.originalError=e;var i=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=r.prototype,n}return e(r,t),r}(Error);return bM.RemoveFileError=t,bM}();$A.RemoveFileError=s.RemoveFileError,$A.edit=function(e,t){void 0===e&&(e="");var r=new c(e,t);return r.run(),r.cleanup(),r.text},$A.editAsync=function(e,t,r){void 0===e&&(e="");var n=new c(e,r);n.runAsync((function(e,r){if(e)setImmediate(t,e,null);else try{n.cleanup(),setImmediate(t,null,r)}catch(e){setImmediate(t,e,null)}}))};var c=function(){function c(e,t){void 0===e&&(e=""),this.text="",this.fileOptions={},this.text=e,t&&(this.fileOptions=t),this.determineEditor(),this.createTemporaryFile()}return c.splitStringBySpace=function(e){for(var t=[],r="",n=0;n<e.length;n++){var i=e[n];n>0&&" "===i&&"\\"!==e[n-1]&&r.length>0?(t.push(r),r=""):r+=i}return r.length>0&&t.push(r),t},Object.defineProperty(c.prototype,"temp_file",{get:function(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"last_exit_status",{get:function(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus},enumerable:!0,configurable:!0}),c.prototype.run=function(){return this.launchEditor(),this.readTemporaryFile(),this.text},c.prototype.runAsync=function(e){var t=this;try{this.launchEditorAsync((function(){try{t.readTemporaryFile(),setImmediate(e,null,t.text)}catch(t){setImmediate(e,t,null)}}))}catch(t){setImmediate(e,t,null)}},c.prototype.cleanup=function(){this.removeTemporaryFile()},c.prototype.determineEditor=function(){var e=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:/^win/.test(process.platform)?"notepad":"vim",t=c.splitStringBySpace(e).map((function(e){return e.replace("\\ "," ")})),r=t.shift();this.editor={args:t,bin:r}},c.prototype.createTemporaryFile=function(){try{this.tempFile=i.tmpNameSync(this.fileOptions);var e={encoding:"utf8"};this.fileOptions.hasOwnProperty("mode")&&(e.mode=this.fileOptions.mode),r.writeFileSync(this.tempFile,this.text,e)}catch(e){throw new o.CreateFileError(e)}},c.prototype.readTemporaryFile=function(){try{var t=r.readFileSync(this.tempFile);if(0===t.length)this.text="";else{var i=e.detect(t).toString();n.encodingExists(i)||(i="utf8"),this.text=n.decode(t,i)}}catch(e){throw new a.ReadFileError(e)}},c.prototype.removeTemporaryFile=function(){try{r.unlinkSync(this.tempFile)}catch(e){throw new s.RemoveFileError(e)}},c.prototype.launchEditor=function(){try{var e=t.spawnSync(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=e.status}catch(e){throw new u.LaunchEditorError(e)}},c.prototype.launchEditorAsync=function(e){var r=this;try{t.spawn(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",(function(t){r.lastExitStatus=t,setImmediate(e)}))}catch(e){throw new u.LaunchEditorError(e)}},c}();return $A.ExternalEditor=c,$A}!function(e){const t=e.exports;t.prompts={},t.Separator=ti,t.ui={BottomBar:vi,Prompt:CE},t.createPromptModule=function(e){const r=function(n,i){let o;try{o=new t.ui.Prompt(r.prompts,e)}catch(e){return Promise.reject(e)}const u=o.run(n,i);return u.ui=o,u};return r.prompts={},r.registerPrompt=function(e,t){return r.prompts[e]=t,this},r.restoreDefaultPrompts=function(){this.registerPrompt("list",MA()),this.registerPrompt("input",kA()),this.registerPrompt("number",function(){if(aA)return uA;aA=1;const e=kA();return uA=class extends e{filterInput(e){if(e&&"string"==typeof e){const t=(e=e.trim()).match(/(^-?\d+|^-?\d+\.\d*|^\d*\.\d+)(e\d+)?$/);if(t)return Number(t[0])}return null==this.opt.default?NaN:this.opt.default}},uA}()),this.registerPrompt("confirm",function(){if(cA)return sA;cA=1;const e=zn,{take:t,takeUntil:r}=OO,n=PA(),i=FA();return sA=class extends n{constructor(e,t,r){super(e,t,r);let n=!0;Object.assign(this.opt,{filter(e){let t=n;return null!=e&&""!==e&&(t=/^y(es)?/i.test(e)),t}}),null!=this.opt.default&&(n=Boolean(this.opt.default)),this.opt.default=n?"Y/n":"y/N"}_run(e){this.done=e;const n=i(this.rl);return n.keypress.pipe(r(n.line)).forEach(this.onKeypress.bind(this)),n.line.pipe(t(1)).forEach(this.onEnd.bind(this)),this.render(),this}render(t){let r=this.getQuestion();return r+="boolean"==typeof t?e.cyan(t?"Yes":"No"):this.rl.line,this.screen.render(r),this}onEnd(e){this.status="answered";const t=this.opt.filter(e);this.render(t),this.screen.done(),this.done(t)}onKeypress(){this.render()}},sA}()),this.registerPrompt("rawlist",BA()),this.registerPrompt("expand",IA()),this.registerPrompt("checkbox",RA()),this.registerPrompt("password",function(){if(mA)return vA;mA=1;const e=zn,{map:t,takeUntil:r}=OO,n=PA(),i=FA();function o(e,t){return t="string"==typeof t?t:"*",0===(e=String(e)).length?"":new Array(e.length+1).join(t)}return vA=class extends n{_run(e){this.done=e;const n=i(this.rl),o=n.line.pipe(t(this.filterInput.bind(this))),u=this.handleSubmitEvents(o);return u.success.forEach(this.onEnd.bind(this)),u.error.forEach(this.onError.bind(this)),n.keypress.pipe(r(u.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),n="";"answered"===this.status?r+=this.getMaskedValue(this.answer):r+=this.getMaskedValue(this.rl.line||""),t&&(n="\n"+e.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return"answered"===this.status?this.opt.mask?e.cyan(o(t,this.opt.mask)):e.italic.dim("[hidden]"):this.opt.mask?o(t,this.opt.mask):e.italic.dim("[input is hidden] ")}getSpinningValue(e){return this.getMaskedValue(e)}filterInput(e){return e||(null==this.opt.default?"":this.opt.default)}onEnd(e){this.status="answered",this.answer=e.value,this.render(),this.screen.done(),this.done(e.value)}onError(e){this.render(e.isValid)}onKeypress(){this.opt.default&&(this.opt.default=void 0),this.render()}},vA}()),this.registerPrompt("editor",function(){if(hM)return pM;hM=1;const e=zn,{editAsync:t}=vM(),r=PA(),n=FA(),{Subject:i}=ma;return pM=class extends r{_run(e){this.done=e,this.editorResult=new i;const t=n(this.rl);this.lineSubscription=t.line.subscribe(this.startExternalEditor.bind(this));const r=this.handleSubmitEvents(this.editorResult);return r.success.forEach(this.onEnd.bind(this)),r.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,this.render(),this}render(t){let r="",n=this.getQuestion();"answered"===this.status?n+=e.dim("Received"):n+=e.dim("Press <enter> to launch your preferred editor."),t&&(r=e.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),t(this.currentText,this.endExternalEditor.bind(this))}endExternalEditor(e,t){this.rl.resume(),e?this.editorResult.error(e):this.editorResult.next(t)}onEnd(e){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(e){this.render(e.isValid)}},pM}())},r.restoreDefaultPrompts(),r},t.prompt=t.createPromptModule(),t.registerPrompt=function(e,r){t.prompt.registerPrompt(e,r)},t.restoreDefaultPrompts=function(){t.prompt.restoreDefaultPrompts()}}(sn);const mM=(()=>{try{return 0===Xr("pnpm --version",{stdio:"ignore"}).exitCode}catch(e){return!1}})()?"pnpm":(()=>{try{return 0===Xr("yarn --version",{stdio:"ignore"}).exitCode}catch(e){return!1}})()?"yarn":"npm",yM={"简体中文":{getVersion:"获取依赖的最新版本...",createPackage:"生成 package.json...",updatePackage:"更新 package.json...",template:"生成模板...",wait:"这可能需要数分钟,请耐心等待.\n我们无法正确输出子进程的进度条,所以进程可能会看似未响应",install:"安装依赖...",success:"模板已成功生成!",devServerAsk:"是否想要现在启动 Demo 查看?",devServer:"启动开发服务器...\n启动成功后,请在浏览器输入给出的开发服务器地址(默认为 'localhost:8080')",hint:`提示: 请使用 "${mM} run docs:dev" 命令启动开发服务器`,nameMessage:"设置应用名称",nameError:"应用名称应只包含小写字母、数字和连接线 (-)",versionMessage:"设置应用版本号",versionError:"此版本无效,版本号应为 'x.x.x'",dirError:'"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "src", "docs" 等!\n例如: "npm init vuepress-theme-hope@next docs"',descriptionMessage:"设置应用描述",licenseMessage:"设置协议",i18nMessage:"项目需要用到多语言么?",workflowMessage:"是否需要一个自动部署文档到 GitHub Pages 的工作流?"},"english (US)":{getVersion:"Getting lastest version of deps...",createPackage:"Generating package.json...",updatePackage:"Updating package.json...",template:"Generating Template...",wait:"This may take a few minutes, please be patient.\nWe can not correctly output progress bar from child process, so the process may look stuck.",install:"Installing Deps...",success:"Successful Generated!",devServerAsk:"Would you like to preview template now?",devServer:"Staring dev server...\nAfter the dev server starts running, please visit the given server link ('localhost:8080' by default)",hint:`Hint: You should execute "${mM} run docs:dev" to start dev server.`,nameMessage:"Your project name",nameError:"package name should only contain lowercase characters, numbers and dash",versionMessage:"Your project version",versionError:"This version is not a valid one. Version should be like 'x.x.x'",dirError:'The brackets in "[dir]" means it is an argument, you should replace it with folder name you want to use! E.g.: "src", "docs"\nFor example: "npm init vuepress-theme-hope@next docs"',descriptionMessage:"Your project description",licenseMessage:"Your project lincense",i18nMessage:"Does the project need multiple languages?",workflowMessage:"Do you need a GitHub workflow to deploy docs on GitHub pages?"}},gM=async e=>{for(let t=1;t<=3;t++){const r=await new Promise(((t,r)=>{f.get(`${"npm"===mM?"https://registry.npmjs.org":"https://registry.yarnpkg.com"}/-/package/${e}/dist-tags`,(e=>{if(200===e.statusCode){let r="";e.on("data",(e=>r+=e)),e.on("end",(()=>{t(JSON.parse(r).next)}))}else r()})).on("error",(()=>{r()}))})).catch((()=>{console.log(`Get ${e} version failed, [${t}/3]`)}));if(r)return r}throw new Error(`Get ${e} version failed!`)},DM=(e,...t)=>{if(0===t.length)return e;const r=t.shift()||{};return Object.keys(r).forEach((t=>{"object"!=typeof e[t]||Array.isArray(e[t])||"object"!=typeof r[t]||Array.isArray(r[t])?"object"==typeof r[t]?Array.isArray(r[t])?e[t]=[...r[t]]:e[t]={...r[t]}:e[t]=r[t]:DM(e[t],r[t])})),DM(e,...t)},_M=async(t,n)=>{const i=e.resolve(process.cwd(),"package.json"),o=(e=>({"docs:build":`vuepress build ${e}`,"docs:clean-dev":`vuepress dev ${e} --clean-cache`,"docs:dev":`vuepress dev ${e}`}))(t),u=await(async e=>Object.fromEntries(await Promise.all(e.map((async e=>[e,`^${await gM(e)}`])))))(["@vuepress/client","vue","vuepress","vuepress-theme-hope"]);if(r.existsSync(i)){console.log(n.updatePackage);const e=JSON.parse(r.readFileSync(i,{encoding:"utf-8"}));DM(e,{scripts:o,devDependencies:u}),r.writeFileSync(i,`${JSON.stringify(e,null,2)}\n`,{encoding:"utf-8"})}else{console.log(n.createPackage);const e=await sn.exports.prompt([{name:"name",type:"input",message:n.nameMessage,default:"vuepress-theme-hope-template",validate:e=>!!/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/u.exec(e)||n.nameError},{name:"version",type:"input",message:n.versionMessage,default:"2.0.0",validate:e=>!!/^[0-9]+\.[0-9]+\.(?:[0=9]+|[0-9]+-[a-z]+\.[0-9])$/u.exec(e)||n.versionError},{name:"description",type:"input",message:n.descriptionMessage,default:"A project of vuepress-theme-hope"},{name:"license",type:"input",message:n.licenseMessage,default:"MIT"}]),t={...e,scripts:o,devDependencies:u};r.writeFileSync(i,`${JSON.stringify(t,null,2)}\n`,{encoding:"utf-8"})}},wM=async e=>{const t=Xr(mM,["config","get","registry"]).stdout;if("简体中文"===e){const{registry:e}=await sn.exports.prompt([{name:"registry",type:"list",message:"选择你想使用的源",choices:["国内镜像源","当前源"]}]);return"国内镜像源"===e?"https://registry.npmmirror.com/":t}return t},OM=e=>{try{r.readdirSync(e)}catch(t){r.mkdirSync(e,{recursive:!0})}},EM=(t,n)=>{const i=e.dirname(n);OM(i);const o=r.createReadStream(t),u=r.createWriteStream(n);o.pipe(u)},SM=(e,t)=>{OM(t);r.readdirSync(e,{withFileTypes:!0}).forEach((r=>{r.isFile()?EM(`${e}/${r.name}`,`${t}/${r.name}`):r.isDirectory()&&SM(`${e}/${r.name}`,`${t}/${r.name}`)}))},jM=async(t,n,i)=>{const{i18n:o,workflow:u}=await sn.exports.prompt([{name:"i18n",type:"confirm",message:i.i18nMessage,default:!1},{name:"workflow",type:"confirm",message:i.workflowMessage,default:!0}]);console.log(i.template);const a=o?"i18n":"简体中文"===n?"zh-CN":"en-US";var s,c;if(s=e.resolve(__dirname,"../template",a),c=e.resolve(process.cwd(),t),r.statSync(s).isDirectory()?SM(s,c):r.statSync(s).isFile()&&EM(s,c),u){const i=e.resolve(process.cwd(),".github/workflows");OM(i),r.writeFileSync(e.resolve(i,"deploy-docs.yml"),((t,r)=>`\nname: ${"简体中文"===r?"部署文档":"Deploy Docs"}\n\non:\n push:\n branches:\n # ${"简体中文"===r?"确保这是你正在使用的分支名称":"make sure this is the branch you are using"}\n - main\n\njobs:\n deploy-gh-pages:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v3\n with:\n fetch-depth: 0\n # ${"简体中文"===r?"如果你文档需要 Git 子模块,取消注释下一行":"if your docs needs submodules, uncomment the following line"}\n # submodules: true\n\n${"pnpm"===mM?`\n - name: ${"简体中文"===r?"安装 pnpm":"Install pnpm"}\n uses: pnpm/action-setup@v2\n with:\n version: 7\n run_install: true\n`:""}\n\n - name: ${"简体中文"===r?"设置 Node.js":"Setup Node.js"}\n uses: actions/setup-node@v3\n with:\n node-version: 16\n cache: ${mM}\n\n - name: ${"简体中文"===r?"安装依赖":"Install Deps"}\n run: ${"npm"===mM?"npm install":`${mM} install --frozen-lockfile`}\n\n - name: ${"简体中文"===r?"构建文档":"Build Docs"}\n env:\n NODE_OPTIONS: --max_old_space_size=4096\n run: ${mM} run docs:build\n\n - name: ${"简体中文"===r?"部署文档":"Deploy Docs"}\n uses: JamesIves/github-pages-deploy-action@v4\n with:\n # ${"简体中文"===r?"这是文档部署到的分支名称":"This is the branch where the docs are deployed to"}\n branch: gh-pages\n folder: ${e.join(t,".vuepress/dist").replace(/\\/g,"/")}\n\n`)(t,n),{encoding:"utf-8"})}const l=e.resolve(process.cwd(),".gitignore"),f=r.existsSync(l)?r.readFileSync(l,{encoding:"utf-8"}):"";r.writeFileSync(l,`${f}${(e=>`\nnode_modules/\n${e}/.vuepress/.cache/\n${e}/.vuepress/.temp/\n${e}/.vuepress/dist/\n`)(t)}`,{encoding:"utf-8"})},xM=((e="")=>new re(e))("vuepress-theme-hope"),CM=require("../package.json").version;xM.command("[dir]","Generate a new vuepress-theme-hope project").usage("pnpm create vuepress-theme-hope@next [dir] / npm init vuepress-theme-hope@next [dir]").example("docs").action((async e=>{if(!e)return xM.outputHelp();const{lang:t,message:r}=await(async()=>{const{language:e}=await sn.exports.prompt([{name:"language",type:"list",message:"Select a language to display / 选择显示语言",choices:["english (US)","简体中文"]}]);return{lang:e,message:yM[e]}})();if(e.startsWith("[")&&e.endsWith("]"))return console.log(r.dirError);console.log(r.getVersion),await _M(e,r),await jM(e,t,r);const n=await wM(t);console.log(r.install),console.warn(r.wait),se.exports.sync(mM,["install",..."pnpm"===mM?[]:["--registry",n]],{stdout:"inherit"}),console.log(r.success);const{choice:i}=await sn.exports.prompt([{name:"choice",type:"confirm",message:r.devServerAsk,default:!0}]);i?(console.log(r.devServer),await se.exports(mM,["run","docs:dev"],{stdout:"inherit"})):console.log(r.hint)})),xM.help((()=>[{title:"pnpm create vuepress-theme-hope@next [dir] / npm init vuepress-theme-hope@next [dir]",body:"Create a vuepress-theme-hope template in [dir]"}])),xM.version(CM),xM.parse();
|
package/package.json
CHANGED
|
@@ -136,27 +136,23 @@ A custom details container
|
|
|
136
136
|
|
|
137
137
|
::::
|
|
138
138
|
|
|
139
|
-
###
|
|
139
|
+
### Code Tabs
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
::: code-tabs
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
@tab pnpm
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
146
|
pnpm add -D vuepress-theme-hope
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
::: code-group-item yarn
|
|
149
|
+
@tab yarn
|
|
152
150
|
|
|
153
151
|
```bash
|
|
154
152
|
yarn add -D vuepress-theme-hope
|
|
155
153
|
```
|
|
156
154
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
::: code-group-item npm:active
|
|
155
|
+
@tab:active npm
|
|
160
156
|
|
|
161
157
|
```bash
|
|
162
158
|
npm i -D vuepress-theme-hope
|
|
@@ -164,9 +160,7 @@ npm i -D vuepress-theme-hope
|
|
|
164
160
|
|
|
165
161
|
:::
|
|
166
162
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
- [View Detail](https://vuepress-theme-hope.github.io/v2/guide/markdown/code-group.html)
|
|
163
|
+
- [View Detail](https://vuepress-theme-hope.github.io/v2/guide/markdown/code-tabs.html)
|
|
170
164
|
|
|
171
165
|
### Superscript and Subscript
|
|
172
166
|
|
package/template/en-US/home.md
CHANGED
|
@@ -86,7 +86,7 @@ features:
|
|
|
86
86
|
|
|
87
87
|
- title: Feed support
|
|
88
88
|
icon: rss
|
|
89
|
-
details: Generate feed to allow users to
|
|
89
|
+
details: Generate feed to allow users to subscribe it
|
|
90
90
|
link: https://vuepress-theme-hope.github.io/v2/guide/advanced/feed.html
|
|
91
91
|
|
|
92
92
|
- title: PWA support
|
package/template/en-US/slide.md
CHANGED
|
@@ -136,27 +136,23 @@ A custom details container
|
|
|
136
136
|
|
|
137
137
|
::::
|
|
138
138
|
|
|
139
|
-
###
|
|
139
|
+
### Code Tabs
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
::: code-tabs
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
@tab pnpm
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
146
|
pnpm add -D vuepress-theme-hope
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
::: code-group-item yarn
|
|
149
|
+
@tab yarn
|
|
152
150
|
|
|
153
151
|
```bash
|
|
154
152
|
yarn add -D vuepress-theme-hope
|
|
155
153
|
```
|
|
156
154
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
::: code-group-item npm:active
|
|
155
|
+
@tab:active npm
|
|
160
156
|
|
|
161
157
|
```bash
|
|
162
158
|
npm i -D vuepress-theme-hope
|
|
@@ -164,9 +160,7 @@ npm i -D vuepress-theme-hope
|
|
|
164
160
|
|
|
165
161
|
:::
|
|
166
162
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
- [View Detail](https://vuepress-theme-hope.github.io/v2/guide/markdown/code-group.html)
|
|
163
|
+
- [View Detail](https://vuepress-theme-hope.github.io/v2/guide/markdown/code-tabs.html)
|
|
170
164
|
|
|
171
165
|
### Superscript and Subscript
|
|
172
166
|
|
package/template/i18n/home.md
CHANGED
|
@@ -86,7 +86,7 @@ features:
|
|
|
86
86
|
|
|
87
87
|
- title: Feed support
|
|
88
88
|
icon: rss
|
|
89
|
-
details: Generate feed to allow users to
|
|
89
|
+
details: Generate feed to allow users to subscribe it
|
|
90
90
|
link: https://vuepress-theme-hope.github.io/v2/guide/advanced/feed.html
|
|
91
91
|
|
|
92
92
|
- title: PWA support
|
package/template/i18n/slide.md
CHANGED
|
@@ -136,25 +136,21 @@ const a = 1;
|
|
|
136
136
|
|
|
137
137
|
### 代码块
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
::: code-tabs
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
@tab pnpm
|
|
142
142
|
|
|
143
143
|
```bash
|
|
144
144
|
pnpm add -D vuepress-theme-hope
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
::: code-group-item yarn
|
|
147
|
+
@tab yarn
|
|
150
148
|
|
|
151
149
|
```bash
|
|
152
150
|
yarn add -D vuepress-theme-hope
|
|
153
151
|
```
|
|
154
152
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
::: code-group-item npm:active
|
|
153
|
+
@tab:active npm
|
|
158
154
|
|
|
159
155
|
```bash
|
|
160
156
|
npm i -D vuepress-theme-hope
|
|
@@ -162,9 +158,7 @@ npm i -D vuepress-theme-hope
|
|
|
162
158
|
|
|
163
159
|
:::
|
|
164
160
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- [查看详情](https://vuepress-theme-hope.github.io/v2/zh/guide/markdown/code-group.html)
|
|
161
|
+
- [查看详情](https://vuepress-theme-hope.github.io/v2/zh/guide/markdown/code-tabs.html)
|
|
168
162
|
|
|
169
163
|
### 自定义对齐
|
|
170
164
|
|
|
@@ -136,25 +136,21 @@ const a = 1;
|
|
|
136
136
|
|
|
137
137
|
### 代码块
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
::: code-tabs
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
@tab pnpm
|
|
142
142
|
|
|
143
143
|
```bash
|
|
144
144
|
pnpm add -D vuepress-theme-hope
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
::: code-group-item yarn
|
|
147
|
+
@tab yarn
|
|
150
148
|
|
|
151
149
|
```bash
|
|
152
150
|
yarn add -D vuepress-theme-hope
|
|
153
151
|
```
|
|
154
152
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
::: code-group-item npm:active
|
|
153
|
+
@tab:active npm
|
|
158
154
|
|
|
159
155
|
```bash
|
|
160
156
|
npm i -D vuepress-theme-hope
|
|
@@ -162,9 +158,7 @@ npm i -D vuepress-theme-hope
|
|
|
162
158
|
|
|
163
159
|
:::
|
|
164
160
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- [查看详情](https://vuepress-theme-hope.github.io/v2/zh/guide/markdown/code-group.html)
|
|
161
|
+
- [查看详情](https://vuepress-theme-hope.github.io/v2/zh/guide/markdown/code-tabs.html)
|
|
168
162
|
|
|
169
163
|
### 自定义对齐
|
|
170
164
|
|