create-valaxy 0.15.3 → 0.15.4

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