create-valaxy 0.19.10 → 0.19.12
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/template-blog/package.json +3 -3
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.19.
|
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.19.12";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
@@ -12,10 +12,10 @@
|
|
12
12
|
"serve": "vite preview"
|
13
13
|
},
|
14
14
|
"dependencies": {
|
15
|
-
"valaxy": "0.19.
|
16
|
-
"valaxy-theme-yun": "0.19.
|
15
|
+
"valaxy": "0.19.12",
|
16
|
+
"valaxy-theme-yun": "0.19.12"
|
17
17
|
},
|
18
18
|
"devDependencies": {
|
19
|
-
"typescript": "^5.
|
19
|
+
"typescript": "^5.6.2"
|
20
20
|
}
|
21
21
|
}
|