create-valaxy 0.22.8 → 0.22.9
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 n from"node:fs";import l from"node:path";import C from"node:process";import{fileURLToPath as B}from"node:url";import{execa as N}from"execa";import{dim as m,gray as H,blue as u,yellow as f,bold as T,green as g,cyan as v,red as E,reset as w}from"kolorist";import Q from"minimist";import S from"prompts";const W="0.22.
|
1
|
+
import n from"node:fs";import l from"node:path";import C from"node:process";import{fileURLToPath as B}from"node:url";import{execa as N}from"execa";import{dim as m,gray as H,blue as u,yellow as f,bold as T,green as g,cyan as v,red as E,reset as w}from"kolorist";import Q from"minimist";import S from"prompts";const W="0.22.9",F={name:"starter",repo:"https://github.com/valaxyjs/valaxy-theme-starter"};async function q(e){const o=F.name;let a=e.themeName||o;const p=`valaxy-theme-${a.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(` ${T("Check it")}:`),console.log(),console.log(`- Change ${T("author")} name in ${f("LICENSE")} & ${g("package.json")} & ${u(".github")}`),console.log(`- Change ${u("valaxy.config.ts")} theme: ${f("starter")} to ${v(`${a}`)}`),console.log(`- Rename ${f(`valaxy-theme-${a}`)} to ${v(`valaxy-theme-${a}`)}`),console.log(),console.log(` ${v("\u2728")}`),console.log(),`valaxy-theme-${a}`}const G={_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=>q(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}],L=_.map(e=>e.name);function z(e){return e?.trim().replace(/\/+$/g,"")}function K(e){const o=n.readdirSync(e);return o.length===0||o.length===1&&o[0]===".git"}function O(e,o){n.statSync(e).isDirectory()?X(e,o):n.copyFileSync(e,o)}function X(e,o){n.mkdirSync(o,{recursive:!0});for(const a of n.readdirSync(e)){const p=l.resolve(e,a),i=l.resolve(o,a);O(p,i)}}function Z(e){if(console.log(`
|
2
2
|
${E("Removing")} ${m(e)}`),!!n.existsSync(e))for(const o of n.readdirSync(e))o!==".git"&&n.rmSync(l.resolve(e,o),{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 ee(e){if(!e)return;const o=e.split(" ")[0].split("/");return{name:o[0],version:o[1]}}const d=Q(C.argv.slice(2)),P=C.cwd(),oe="valaxy-blog",te=B(import.meta.url);async function ne(){console.log(),console.log(` ${T("\u{1F30C} Valaxy")} ${u(`v${W}`)}`),console.log();const e=z(d._[0]),o=d.template||d.t,a=d.y||d.yes,p=d.port||d.p;let i=e||oe;const $=()=>i==="."?l.basename(l.resolve()):i;let k,r=_[0];if(a)k={projectName:i,overwrite:!1,packageName:M($())};else{r=(await S({type:o&&L.includes(o)?null:"select",name:"template",message:typeof o=="string"&&!L.includes(o)?w(`"${o}" isn't a valid template. Please choose from below: `):w("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 S([{type:e?null:"text",name:"projectName",message:w(r.message),initial:r.initial,onState:t=>{i=z(r.prefix?r.prefix+t.value:t.value)||r.initial}},{type:()=>!n.existsSync(i)||K(i)?null:"confirm",name:"overwrite",message:()=>`${i==="."?"Current directory":`Target directory "${i}"`} is not empty. Remove existing files and continue?`},{type:(t,{overwrite:c})=>{if(c===!1)throw new Error(`${E("\u2716")} Operation cancelled`);return null},name:"overwriteChecker"},{type:()=>R($())?null:"text",name:"packageName",message:w("Package name:"),initial:()=>M($()),validate:t=>R(t)||"Invalid package.json name"}],{onCancel:()=>{throw new Error(`${E("\u2716")} Operation cancelled`)}})}catch(t){console.log(t.message);return}}const{projectName:h,overwrite:U}=k,V=r.prefix?r.prefix+h:h,s=l.join(P,V);if(U?Z(s):n.existsSync(s)||n.mkdirSync(s,{recursive:!0}),r.customInit)await r.customInit({themeName:h});else{const t=l.resolve(te,"../..",`template-${r.name}`),c=(y,x)=>{const A=l.join(s,G[y]??y);x?n.writeFileSync(A,x):O(l.join(t,y),A)},Y=n.readdirSync(t);for(const y of Y.filter(x=>x!=="package.json"))c(y);const I=JSON.parse(n.readFileSync(l.join(t,"package.json"),"utf-8"));I.name=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 ")+i+m(" ..."));const D=ee(C.env.npm_config_user_agent),j=D?D.name:"npm",J=l.relative(P,s);if(console.log(g(` Done.
|
4
4
|
`)),r.name==="addon")return;let b;if(a?b=!1:{yes:b}=await S({type:"confirm",name:"yes",initial:"Y",message:"Install and start it now?"}),b){let t;if(a?t="pnpm":{agent:t}=await S({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
@@ -2,7 +2,19 @@
|
|
2
2
|
|
3
3
|
You can override styles here.
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
## 示例
|
6
|
+
|
7
|
+
- New file `index.ts` to import other style files.
|
8
|
+
|
9
|
+
```ts
|
10
|
+
import './vars.scss'
|
11
|
+
```
|
12
|
+
|
13
|
+
```scss
|
14
|
+
// vars.scss
|
15
|
+
:root {
|
16
|
+
--primary-color: #007bff;
|
17
|
+
}
|
18
|
+
```
|
7
19
|
|
8
20
|
More info see <https://valaxy.site/guide/custom/styles>.
|