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