create-valaxy 0.20.1 → 0.20.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import C from"node:process";import a from"node:fs";import l from"node:path";import{fileURLToPath as B}from"node:url";import{execa as N}from"execa";import{red as T,dim as m,gray as H,blue as u,yellow as f,bold as E,green as g,cyan as v,reset as S}from"kolorist";import Q from"minimist";import $ from"prompts";const W="0.20.1";function L(e){return e?.trim().replace(/\/+$/g,"")}function q(e){const o=a.readdirSync(e);return o.length===0||o.length===1&&o[0]===".git"}function z(e,o){a.statSync(e).isDirectory()?G(e,o):a.copyFileSync(e,o)}function G(e,o){a.mkdirSync(o,{recursive:!0});for(const n of a.readdirSync(e)){const p=l.resolve(e,n),r=l.resolve(o,n);z(p,r)}}function K(e){if(console.log(`
1
+ import C from"node:process";import a from"node:fs";import l from"node:path";import{fileURLToPath as B}from"node:url";import{execa as N}from"execa";import{red as T,dim as m,gray as H,blue as u,yellow as f,bold as E,green as g,cyan as v,reset as S}from"kolorist";import Q from"minimist";import $ from"prompts";const W="0.20.3";function L(e){return e?.trim().replace(/\/+$/g,"")}function q(e){const o=a.readdirSync(e);return o.length===0||o.length===1&&o[0]===".git"}function z(e,o){a.statSync(e).isDirectory()?G(e,o):a.copyFileSync(e,o)}function G(e,o){a.mkdirSync(o,{recursive:!0});for(const n of a.readdirSync(e)){const p=l.resolve(e,n),r=l.resolve(o,n);z(p,r)}}function K(e){if(console.log(`
2
2
  ${T("Removing")} ${m(e)}`),!!a.existsSync(e))for(const o of a.readdirSync(e))o!==".git"&&a.rmSync(l.resolve(e,o),{recursive:!0,force:!0})}function O(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function R(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function X(e){if(!e)return;const o=e.split(" ")[0].split("/");return{name:o[0],version:o[1]}}const F={name:"starter",display:"Starter",repo:"https://github.com/valaxyjs/valaxy-theme-starter"};async function Z(e){const o=F.name;let n=e.themeName||o;if(!n){const{theme:r}=await $({type:"text",name:"theme",message:"Theme name: valaxy-theme-",initial:o});n=r||o}const p=`valaxy-theme-${n.trim()}`;return console.log(` ${m("npx")} ${H("degit")} ${u(F.repo)} ${f(p)}`),await N("npx",["degit",F.repo,p],{stdio:"inherit"}),console.log(),console.log(` ${E("Check it")}:`),console.log(),console.log(`- Change ${E("author")} name in ${f("LICENSE")} & ${g("package.json")} & ${u(".github")}`),console.log(`- Change ${u("valaxy.config.ts")} theme: ${f("starter")} to ${v(`${n}`)}`),console.log(`- Rename ${f(`valaxy-theme-${n}`)} to ${v(`valaxy-theme-${n}`)}`),console.log(),console.log(` ${v("\u2728")}`),console.log(),`valaxy-theme-${n}`}const ee={_gitignore:".gitignore",_npmrc:".npmrc"},_=[{name:"blog",display:"Blog",desc:"For Most Users",message:"Project name:",initial:"valaxy-blog",color:v},{name:"theme",display:"Theme",desc:"For Theme Developers",message:"Theme name: valaxy-theme-",initial:"starter",prefix:"valaxy-theme-",color:g,customInit:async e=>Z(e).catch(o=>{console.error(o)})},{name:"addon",display:"Addon",desc:"For Addon Developers",message:"Addon name: valaxy-addon-",initial:"template",prefix:"valaxy-addon-",color:f}],M=_.map(e=>e.name),d=Q(C.argv.slice(2)),P=C.cwd(),oe="valaxy-blog",te=B(import.meta.url);async function ne(){console.log(),console.log(` ${E("\u{1F30C} Valaxy")} ${u(`v${W}`)}`),console.log();const e=L(d._[0]),o=d.template||d.t,n=d.y||d.yes,p=d.port||d.p;let r=e||oe;const h=()=>r==="."?l.basename(l.resolve()):r;let k,i=_[0];if(n)k={projectName:r,overwrite:!1,packageName:R(h())};else{i=(await $({type:o&&M.includes(o)?null:"select",name:"template",message:typeof o=="string"&&!M.includes(o)?S(`"${o}" isn't a valid template. Please choose from below: `):S("Select a type:"),initial:0,choices:_.map(t=>{const c=t.color;return{title:c(t.display||t.name)+m(` - ${t.desc}`),value:t}})})).template;try{k=await $([{type:e?null:"text",name:"projectName",message:S(i.message),initial:i.initial,onState:t=>{r=L(i.prefix?i.prefix+t.value:t.value)||i.initial}},{type:()=>!a.existsSync(r)||q(r)?null:"confirm",name:"overwrite",message:()=>`${r==="."?"Current directory":`Target directory "${r}"`} is not empty. Remove existing files and continue?`},{type:(t,{overwrite:c})=>{if(c===!1)throw new Error(`${T("\u2716")} Operation cancelled`);return null},name:"overwriteChecker"},{type:()=>O(h())?null:"text",name:"packageName",message:S("Package name:"),initial:()=>R(h()),validate:t=>O(t)||"Invalid package.json name"}],{onCancel:()=>{throw new Error(`${T("\u2716")} Operation cancelled`)}})}catch(t){console.log(t.message);return}}const{projectName:x,overwrite:U}=k,V=i.prefix?i.prefix+x:x,s=l.join(P,V);if(U?K(s):a.existsSync(s)||a.mkdirSync(s,{recursive:!0}),i.customInit)await i.customInit({themeName:x});else{const t=l.resolve(te,"../..",`template-${i.name}`),c=(y,w)=>{const A=l.join(s,ee[y]??y);w?a.writeFileSync(A,w):z(l.join(t,y),A)},Y=a.readdirSync(t);for(const y of Y.filter(w=>w!=="package.json"))c(y);const I=JSON.parse(a.readFileSync(l.join(t,"package.json"),"utf-8"));I.name=x||h(),c("package.json",`${JSON.stringify(I,null,2)}
3
3
  `)}console.log(` ${m("\u{1F4C1}")} ${m(s)}`),console.log(),console.log(m(" Scaffolding project in ")+r+m(" ..."));const D=X(C.env.npm_config_user_agent),j=D?D.name:"npm",J=l.relative(P,s);if(console.log(g(` Done.
4
4
  `)),i.name==="addon")return;let b;if(n?b=!1:{yes:b}=await $({type:"confirm",name:"yes",initial:"Y",message:"Install and start it now?"}),b){let t;if(n?t="pnpm":{agent:t}=await $({name:"agent",type:"select",message:"Choose the agent",choices:["npm","yarn","pnpm"].map(c=>({value:c,title:c})),initial:2}),!t)return;await N(t,["install"],{stdio:"inherit",cwd:s}),await N(t,p?["run","dev","--port",p]:["run","dev"],{stdio:"inherit",cwd:s})}else{switch(console.log(m(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-valaxy",
3
3
  "type": "module",
4
- "version": "0.20.1",
4
+ "version": "0.20.3",
5
5
  "description": "Create Starter Template for Valaxy",
6
6
  "author": {
7
7
  "email": "me@yunyoujun.cn",
@@ -12,8 +12,8 @@
12
12
  "serve": "vite preview"
13
13
  },
14
14
  "dependencies": {
15
- "valaxy": "0.20.1",
16
- "valaxy-theme-yun": "0.20.1"
15
+ "valaxy": "0.20.3",
16
+ "valaxy-theme-yun": "0.20.3"
17
17
  },
18
18
  "devDependencies": {
19
19
  "typescript": "^5.6.3"
@@ -67,7 +67,7 @@ export default defineSiteConfig({
67
67
  name: 'Twitter',
68
68
  link: 'https://twitter.com/YunYouJun',
69
69
  icon: 'i-ri-twitter-x-fill',
70
- color: '#1da1f2',
70
+ color: 'black',
71
71
  },
72
72
  {
73
73
  name: 'Telegram Channel',