create-vuepress-theme-hope 2.0.0-beta.89 → 2.0.0-beta.91
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/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{cac as e}from"cac";import{execaCommandSync as s,execaCommand as n}from"execa";import t from"inquirer";import{readdirSync as r,mkdirSync as a,statSync as o,createReadStream as i,createWriteStream as c,writeFileSync as p,existsSync as l,readFileSync as u}from"fs";import{dirname as g,resolve as m,join as d}from"path";import{fileURLToPath as h}from"url";import{get as v}from"https";const y={"简体中文":{getVersion:"获取依赖的最新版本...",createPackage:"生成 package.json...",updatePackage:"更新 package.json...",template:"生成模板...",wait:"这可能需要数分钟,请耐心等待.\n我们无法正确输出子进程的进度条,所以进程可能会看似未响应",install:"安装依赖...",success:"模板已成功生成!",devServerAsk:"是否想要现在启动 Demo 查看?",devServer:"启动开发服务器...\n启动成功后,请在浏览器输入给出的开发服务器地址(默认为 'localhost:8080')",nameMessage:"设置应用名称",nameError:"应用名称应只包含小写字母、数字和连接线 (-)",versionMessage:"设置应用版本号",versionError:"此版本无效,版本号应为 'x.x.x'",descriptionMessage:"设置应用描述",licenseMessage:"设置协议",i18nMessage:"项目需要用到多语言么?",gitMessage:"是否初始化 Git 仓库?",workflowMessage:"是否需要一个自动部署文档到 GitHub Pages 的工作流?",packageManager:"选择包管理器",hint:e=>`提示: 请使用 "${e} run docs:dev" 命令启动开发服务器`,dirError:e=>`"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "src", "docs" 等!\n例如: "${e} init vuepress-theme-hope@next docs"`},"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)",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'",descriptionMessage:"Your project description",licenseMessage:"Your project lincense",i18nMessage:"Does the project need multiple languages?",gitMessage:"Initialize a git repository?",workflowMessage:"Do you need a GitHub workflow to deploy docs on GitHub pages?",packageManager:"Choose package manager",hint:e=>`Hint: You should execute "${e} run docs:dev" to start dev server.`,dirError:e=>`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: "${e} init vuepress-theme-hope@next docs"`}},f=(e,...s)=>{if(0===s.length)return e;const n=s.shift()||{};return Object.keys(n).forEach((s=>{"object"!=typeof e[s]||Array.isArray(e[s])||"object"!=typeof n[s]||Array.isArray(n[s])?"object"==typeof n[s]?Array.isArray(n[s])?e[s]=[...n[s]]:e[s]={...n[s]}:e[s]=n[s]:f(e[s],n[s])})),f(e,...s)},w=e=>{try{r(e)}catch(s){a(e,{recursive:!0})}},$=(e,s)=>{const n=g(s);w(n);const t=i(e),r=c(s);t.pipe(r)},k=(e,s)=>{w(s);r(e,{withFileTypes:!0}).forEach((n=>{n.isFile()?$(`${e}/${n.name}`,`${s}/${n.name}`):n.isDirectory()&&k(`${e}/${n.name}`,`${s}/${n.name}`)}))},b=async(e,s)=>{for(let n=1;n<=3;n++){const t=await new Promise(((n,t)=>{v(`${"npm"===e?"https://registry.npmjs.org":"https://registry.yarnpkg.com"}/-/package/${s}/dist-tags`,(e=>{if(200===e.statusCode){let s="";e.on("data",(e=>s+=e)),e.on("end",(()=>{n(JSON.parse(s).next)}))}else t()})).on("error",(()=>{t()}))})).catch((()=>{console.log(`Get ${s} version failed, [${n}/3]`)}));if(t)return t}throw new Error(`Get ${s} version failed!`)},M=["npm"];(()=>{try{return 0===s("yarn --version",{stdio:"ignore"}).exitCode}catch(e){return!1}})()&&M.push("yarn"),(()=>{try{return 0===s("pnpm --version",{stdio:"ignore"}).exitCode}catch(e){return!1}})()&&M.push("pnpm");const j=h(import.meta.url),x=g(j),S=e=>{const s=m(process.cwd(),".gitignore"),n=l(s)?u(s,{encoding:"utf-8"}):"";p(s,`${n}${(e=>`\nnode_modules/\n${e}/.vuepress/.cache/\n${e}/.vuepress/.temp/\n${e}/.vuepress/dist/\n`)(e)}`,{encoding:"utf-8"})},D=async(e,n,r,a)=>{const{i18n:i,workflow:c}=await t.prompt([{name:"i18n",type:"confirm",message:a.i18nMessage,default:!1},{name:"workflow",type:"confirm",message:a.workflowMessage,default:!0}]);console.log(a.template);var l,u;if(l=m(x,"../template",i?"i18n":"简体中文"===r?"zh-CN":"en-US"),u=m(process.cwd(),n),o(l).isDirectory()?k(l,u):o(l).isFile()&&$(l,u),c){const s=m(process.cwd(),".github/workflows");w(s),p(m(s,"deploy-docs.yml"),((e,s,n)=>`\nname: ${"简体中文"===n?"部署文档":"Deploy Docs"}\n\non:\n push:\n branches:\n # ${"简体中文"===n?"确保这是你正在使用的分支名称":"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 # ${"简体中文"===n?"如果你文档需要 Git 子模块,取消注释下一行":"if your docs needs submodules, uncomment the following line"}\n # submodules: true\n\n${"pnpm"===e?`\n - name: ${"简体中文"===n?"安装 pnpm":"Install pnpm"}\n uses: pnpm/action-setup@v2\n with:\n version: 7\n run_install: true\n`:""}\n\n - name: ${"简体中文"===n?"设置 Node.js":"Setup Node.js"}\n uses: actions/setup-node@v3\n with:\n node-version: 16\n cache: ${e}\n\n - name: ${"简体中文"===n?"安装依赖":"Install Deps"}\n run: ${"npm"===e?"npm install":`${e} install --frozen-lockfile`}\n\n - name: ${"简体中文"===n?"构建文档":"Build Docs"}\n env:\n NODE_OPTIONS: --max_old_space_size=4096\n run: |-\n ${e} run docs:build\n > ${d(s,".vuepress/dist/.nojekyll").replace(/\\/g,"/")}\n\n - name: ${"简体中文"===n?"部署文档":"Deploy Docs"}\n uses: JamesIves/github-pages-deploy-action@v4\n with:\n # ${"简体中文"===n?"这是文档部署到的分支名称":"This is the branch where the docs are deployed to"}\n branch: gh-pages\n folder: ${d(s,".vuepress/dist").replace(/\\/g,"/")}\n\n`)(e,n,r),{encoding:"utf-8"})}if((()=>{try{return s("git log"),!0}catch{return!1}})())S(n);else if((()=>{try{return s("git log"),!0}catch{return!1}})()){const{git:e}=await t.prompt([{name:"git",type:"confirm",message:a.gitMessage,default:!0}]);e&&(s("git init"),S(n))}},E=async(e,s,n)=>{const r=m(process.cwd(),"package.json"),a=(e=>({"docs:build":`vuepress build ${e}`,"docs:clean-dev":`vuepress dev ${e} --clean-cache`,"docs:dev":`vuepress dev ${e}`}))(s),o=await(async(e,s)=>Object.fromEntries(await Promise.all(s.map((async s=>[s,`^${await b(e,s)}`])))))(e,["@vuepress/client","vue","vuepress","vuepress-theme-hope"]);if(l(r)){console.log(n.updatePackage);const e=JSON.parse(u(r,{encoding:"utf-8"}));f(e,{scripts:a,devDependencies:o}),p(r,`${JSON.stringify(e,null,2)}\n`,{encoding:"utf-8"})}else{console.log(n.createPackage);const e={...await t.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"}]),scripts:a,devDependencies:o};p(r,`${JSON.stringify(e,null,2)}\n`,{encoding:"utf-8"})}},G=async(e,n)=>{const r=(e=>s(`${e} config get registry`).stdout)(e);if("简体中文"===n){const{registry:e}=await t.prompt([{name:"registry",type:"list",message:"选择你想使用的源",choices:["国内镜像源","当前源"]}]);return"国内镜像源"===e?"https://registry.npmmirror.com/":r}return r};var A="2.0.0-beta.
|
|
2
|
+
import{cac as e}from"cac";import{execaCommandSync as s,execaCommand as n}from"execa";import t from"inquirer";import{readdirSync as r,mkdirSync as a,statSync as o,createReadStream as i,createWriteStream as c,writeFileSync as p,existsSync as l,readFileSync as u}from"fs";import{dirname as g,resolve as m,join as d}from"path";import{fileURLToPath as h}from"url";import{get as v}from"https";const y={"简体中文":{getVersion:"获取依赖的最新版本...",createPackage:"生成 package.json...",updatePackage:"更新 package.json...",template:"生成模板...",wait:"这可能需要数分钟,请耐心等待.\n我们无法正确输出子进程的进度条,所以进程可能会看似未响应",install:"安装依赖...",success:"模板已成功生成!",devServerAsk:"是否想要现在启动 Demo 查看?",devServer:"启动开发服务器...\n启动成功后,请在浏览器输入给出的开发服务器地址(默认为 'localhost:8080')",nameMessage:"设置应用名称",nameError:"应用名称应只包含小写字母、数字和连接线 (-)",versionMessage:"设置应用版本号",versionError:"此版本无效,版本号应为 'x.x.x'",descriptionMessage:"设置应用描述",licenseMessage:"设置协议",i18nMessage:"项目需要用到多语言么?",gitMessage:"是否初始化 Git 仓库?",workflowMessage:"是否需要一个自动部署文档到 GitHub Pages 的工作流?",packageManager:"选择包管理器",hint:e=>`提示: 请使用 "${e} run docs:dev" 命令启动开发服务器`,dirError:e=>`"[dir]" 的方括号表示此处为一个参数,你应该替换为自己想使用的文件夹名称,如 "src", "docs" 等!\n例如: "${e} init vuepress-theme-hope@next docs"`},"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)",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'",descriptionMessage:"Your project description",licenseMessage:"Your project lincense",i18nMessage:"Does the project need multiple languages?",gitMessage:"Initialize a git repository?",workflowMessage:"Do you need a GitHub workflow to deploy docs on GitHub pages?",packageManager:"Choose package manager",hint:e=>`Hint: You should execute "${e} run docs:dev" to start dev server.`,dirError:e=>`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: "${e} init vuepress-theme-hope@next docs"`}},f=(e,...s)=>{if(0===s.length)return e;const n=s.shift()||{};return Object.keys(n).forEach((s=>{"object"!=typeof e[s]||Array.isArray(e[s])||"object"!=typeof n[s]||Array.isArray(n[s])?"object"==typeof n[s]?Array.isArray(n[s])?e[s]=[...n[s]]:e[s]={...n[s]}:e[s]=n[s]:f(e[s],n[s])})),f(e,...s)},w=e=>{try{r(e)}catch(s){a(e,{recursive:!0})}},$=(e,s)=>{const n=g(s);w(n);const t=i(e),r=c(s);t.pipe(r)},k=(e,s)=>{w(s);r(e,{withFileTypes:!0}).forEach((n=>{n.isFile()?$(`${e}/${n.name}`,`${s}/${n.name}`):n.isDirectory()&&k(`${e}/${n.name}`,`${s}/${n.name}`)}))},b=async(e,s)=>{for(let n=1;n<=3;n++){const t=await new Promise(((n,t)=>{v(`${"npm"===e?"https://registry.npmjs.org":"https://registry.yarnpkg.com"}/-/package/${s}/dist-tags`,(e=>{if(200===e.statusCode){let s="";e.on("data",(e=>s+=e)),e.on("end",(()=>{n(JSON.parse(s).next)}))}else t()})).on("error",(()=>{t()}))})).catch((()=>{console.log(`Get ${s} version failed, [${n}/3]`)}));if(t)return t}throw new Error(`Get ${s} version failed!`)},M=["npm"];(()=>{try{return 0===s("yarn --version",{stdio:"ignore"}).exitCode}catch(e){return!1}})()&&M.push("yarn"),(()=>{try{return 0===s("pnpm --version",{stdio:"ignore"}).exitCode}catch(e){return!1}})()&&M.push("pnpm");const j=h(import.meta.url),x=g(j),S=e=>{const s=m(process.cwd(),".gitignore"),n=l(s)?u(s,{encoding:"utf-8"}):"";p(s,`${n}${(e=>`\nnode_modules/\n${e}/.vuepress/.cache/\n${e}/.vuepress/.temp/\n${e}/.vuepress/dist/\n`)(e)}`,{encoding:"utf-8"})},D=async(e,n,r,a)=>{const{i18n:i,workflow:c}=await t.prompt([{name:"i18n",type:"confirm",message:a.i18nMessage,default:!1},{name:"workflow",type:"confirm",message:a.workflowMessage,default:!0}]);console.log(a.template);var l,u;if(l=m(x,"../template",i?"i18n":"简体中文"===r?"zh-CN":"en-US"),u=m(process.cwd(),n),o(l).isDirectory()?k(l,u):o(l).isFile()&&$(l,u),c){const s=m(process.cwd(),".github/workflows");w(s),p(m(s,"deploy-docs.yml"),((e,s,n)=>`\nname: ${"简体中文"===n?"部署文档":"Deploy Docs"}\n\non:\n push:\n branches:\n # ${"简体中文"===n?"确保这是你正在使用的分支名称":"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 # ${"简体中文"===n?"如果你文档需要 Git 子模块,取消注释下一行":"if your docs needs submodules, uncomment the following line"}\n # submodules: true\n\n${"pnpm"===e?`\n - name: ${"简体中文"===n?"安装 pnpm":"Install pnpm"}\n uses: pnpm/action-setup@v2\n with:\n version: 7\n run_install: true\n`:""}\n\n - name: ${"简体中文"===n?"设置 Node.js":"Setup Node.js"}\n uses: actions/setup-node@v3\n with:\n node-version: 16\n cache: ${e}\n\n - name: ${"简体中文"===n?"安装依赖":"Install Deps"}\n run: ${"npm"===e?"npm install":`${e} install --frozen-lockfile`}\n\n - name: ${"简体中文"===n?"构建文档":"Build Docs"}\n env:\n NODE_OPTIONS: --max_old_space_size=4096\n run: |-\n ${e} run docs:build\n > ${d(s,".vuepress/dist/.nojekyll").replace(/\\/g,"/")}\n\n - name: ${"简体中文"===n?"部署文档":"Deploy Docs"}\n uses: JamesIves/github-pages-deploy-action@v4\n with:\n # ${"简体中文"===n?"这是文档部署到的分支名称":"This is the branch where the docs are deployed to"}\n branch: gh-pages\n folder: ${d(s,".vuepress/dist").replace(/\\/g,"/")}\n\n`)(e,n,r),{encoding:"utf-8"})}if((()=>{try{return s("git log"),!0}catch{return!1}})())S(n);else if((()=>{try{return s("git log"),!0}catch{return!1}})()){const{git:e}=await t.prompt([{name:"git",type:"confirm",message:a.gitMessage,default:!0}]);e&&(s("git init"),S(n))}},E=async(e,s,n)=>{const r=m(process.cwd(),"package.json"),a=(e=>({"docs:build":`vuepress build ${e}`,"docs:clean-dev":`vuepress dev ${e} --clean-cache`,"docs:dev":`vuepress dev ${e}`}))(s),o=await(async(e,s)=>Object.fromEntries(await Promise.all(s.map((async s=>[s,`^${await b(e,s)}`])))))(e,["@vuepress/client","vue","vuepress","vuepress-theme-hope"]);if(l(r)){console.log(n.updatePackage);const e=JSON.parse(u(r,{encoding:"utf-8"}));f(e,{scripts:a,devDependencies:o}),p(r,`${JSON.stringify(e,null,2)}\n`,{encoding:"utf-8"})}else{console.log(n.createPackage);const e={...await t.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"}]),scripts:a,devDependencies:o};p(r,`${JSON.stringify(e,null,2)}\n`,{encoding:"utf-8"})}},G=async(e,n)=>{const r=(e=>s(`${e} config get registry`).stdout)(e);if("简体中文"===n){const{registry:e}=await t.prompt([{name:"registry",type:"list",message:"选择你想使用的源",choices:["国内镜像源","当前源"]}]);return"国内镜像源"===e?"https://registry.npmmirror.com/":r}return r};var A="2.0.0-beta.90";const P=e("vuepress-theme-hope"),z=A;P.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 P.outputHelp();const{lang:r,message:a}=await(async()=>{const{language:e}=await t.prompt([{name:"language",type:"list",message:"Select a language to display / 选择显示语言",choices:["english (US)","简体中文"]}]);return{lang:e,message:y[e]}})(),o=await(async e=>(await t.prompt([{name:"packageManager",type:"list",message:e,choices:M}])).packageManager)(a.packageManager);if(e.startsWith("[")&&e.endsWith("]"))return console.log(a.dirError(o));console.log(a.getVersion),await E(o,e,a),await D(o,e,r,a);const i="pnpm"===o?"":await G(o,r);console.log(a.install),console.warn(a.wait),s(`${o} install ${i?"":`--registry ${i}`}`,{stdout:"inherit"}),console.log(a.success);const{choice:c}=await t.prompt([{name:"choice",type:"confirm",message:a.devServerAsk,default:!0}]);c?(console.log(a.devServer),await n(`${o} run docs:dev`,{stdout:"inherit"})):console.log(a.hint(o))})),P.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]"}])),P.version(z),P.parse();
|