create-valaxy 0.28.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import r from"node:fs";import s from"node:path";import C from"node:process";import{fileURLToPath as
|
|
2
|
-
${e.red("Removing")} ${e.dim(
|
|
3
|
-
`),l.name==="blog"){const
|
|
4
|
-
`)),l.name==="addon")return;let
|
|
1
|
+
import r from"node:fs";import s from"node:path";import C from"node:process";import{fileURLToPath as P}from"node:url";import{colors as e}from"consola/utils";import{execa as j}from"execa";import V from"minimist";import f from"prompts";const B="0.28.1",k={name:"starter",repo:"https://github.com/valaxyjs/valaxy-theme-starter"};async function H(t){const n=k.name;let o=t.themeName||n;const y=`valaxy-theme-${o.trim()}`;return console.log(` ${e.dim("npx")} ${e.gray("degit")} ${e.blue(k.repo)} ${e.yellow(y)}`),await j("npx",["degit",k.repo,y],{stdio:"inherit"}),console.log(),console.log(` ${e.bold("Check it")}:`),console.log(),console.log(`- Change ${e.bold("author")} name in ${e.yellow("LICENSE")} & ${e.green("package.json")} & ${e.blue(".github")}`),console.log(`- Change ${e.blue("valaxy.config.ts")} theme: ${e.yellow("starter")} to ${e.cyan(`${o}`)}`),console.log(`- Rename ${e.yellow(`valaxy-theme-${o}`)} to ${e.cyan(`valaxy-theme-${o}`)}`),console.log(),console.log(` ${e.cyan("\u2728")}`),console.log(),`valaxy-theme-${o}`}const J={_gitignore:".gitignore",_npmrc:".npmrc"},W=[{name:"yun",display:"Yun",desc:"A light & clean theme (default)",color:e.cyan},{name:"press",display:"Press",desc:"A document-oriented theme",color:e.green},{name:"custom",display:"Custom",desc:"Enter a custom theme name",color:e.yellow}],N=[{name:"blog",display:"Blog",desc:"For Most Users",message:"Project name:",initial:"valaxy-blog",color:e.cyan},{name:"theme",display:"Theme",desc:"For Theme Developers",message:"Theme name: valaxy-theme-",initial:"starter",prefix:"valaxy-theme-",color:e.green,customInit:async t=>H(t).catch(n=>{console.error(n)})},{name:"addon",display:"Addon",desc:"For Addon Developers",message:"Addon name: valaxy-addon-",initial:"template",prefix:"valaxy-addon-",color:e.yellow}],A=N.map(t=>t.name),I="valaxy-theme-",Y=/^[a-z\d\-_]+$/,G=P(import.meta.url);function D(t){if(!Y.test(t))throw new Error(`Invalid theme name: "${t}"`);return s.resolve(G,"../..",`template-blog-${t}`)}function X(t){try{return r.existsSync(D(t))}catch{return!1}}function q(t){const n=t.trim();return n.startsWith(I)?n.slice(I.length):n}function K(t,n){const o={...t,dependencies:{...t.dependencies}};return n==="yun"||(o.dependencies?.["valaxy-theme-yun"]&&delete o.dependencies["valaxy-theme-yun"],o.dependencies[`valaxy-theme-${n}`]="latest"),o}function Q(t,n){if(n==="yun")return t;let o=t;return o=o.replace("import type { UserThemeConfig } from 'valaxy-theme-yun'",`// import type { UserThemeConfig } from 'valaxy-theme-${n}'`),o=o.replace("theme: 'yun'",`theme: '${n}'`),o=o.replace("defineValaxyConfig<UserThemeConfig>","defineValaxyConfig"),o=o.replace(/themeConfig: \{[\s\S]*?\n {2}\},/,"themeConfig: {},"),o}function O(t){return t?.trim().replace(/\/+$/g,"")}function Z(t){const n=r.readdirSync(t);return n.length===0||n.length===1&&n[0]===".git"}function E(t,n){r.statSync(t).isDirectory()?ee(t,n):r.copyFileSync(t,n)}function ee(t,n){r.mkdirSync(n,{recursive:!0});for(const o of r.readdirSync(t)){const y=s.resolve(t,o),m=s.resolve(n,o);E(y,m)}}function te(t){if(console.log(`
|
|
2
|
+
${e.red("Removing")} ${e.dim(t)}`),!!r.existsSync(t))for(const n of r.readdirSync(t))n!==".git"&&r.rmSync(s.resolve(t,n),{recursive:!0,force:!0})}function z(t){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(t)}function L(t){return t.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function ne(t){if(!t)return;const n=t.split(" ")[0].split("/");return{name:n[0],version:n[1]}}const d=V(C.argv.slice(2)),F=C.cwd(),oe="valaxy-blog",ae=P(import.meta.url);async function re(){console.log(),console.log(` ${e.bold("\u{1F30C} Valaxy")} ${e.blue(`v${B}`)}`),console.log();const t=O(d._[0]),n=d.template||d.t,o=d.y||d.yes,y=d.port||d.p;let m=t||oe;const v=()=>m==="."?s.basename(s.resolve()):m;let w,l=N[0],u="yun";if(o)w={projectName:m,overwrite:!1,packageName:L(v())};else{if(l=(await f({type:n&&A.includes(n)?null:"select",name:"template",message:typeof n=="string"&&!A.includes(n)?e.reset(`"${n}" isn't a valid template. Please choose from below: `):e.reset("Select a type:"),initial:0,choices:N.map(a=>{const i=a.color;return{title:i(a.display||a.name)+e.dim(` - ${a.desc}`),value:a}})})).template,l.name==="blog"){const a=await f({type:"select",name:"theme",message:e.reset("Select a theme:"),initial:0,choices:W.map(i=>{const T=i.color;return{title:T(i.display)+e.dim(` - ${i.desc}`),value:i.name}})});if(a.theme==="custom"){const i=await f({type:"text",name:"themeName",message:e.reset('Theme name (e.g. "starter" or "valaxy-theme-starter"):'),initial:"yun"});u=q(i.themeName||"yun")}else u=a.theme||"yun"}try{w=await f([{type:t?null:"text",name:"projectName",message:e.reset(l.message),initial:l.initial,onState:a=>{m=O(l.prefix?l.prefix+a.value:a.value)||l.initial}},{type:()=>!r.existsSync(m)||Z(m)?null:"confirm",name:"overwrite",message:()=>`${m==="."?"Current directory":`Target directory "${m}"`} is not empty. Remove existing files and continue?`},{type:(a,{overwrite:i})=>{if(i===!1)throw new Error(`${e.red("\u2716")} Operation cancelled`);return null},name:"overwriteChecker"},{type:()=>z(v())?null:"text",name:"packageName",message:e.reset("Package name:"),initial:()=>L(v()),validate:a=>z(a)||"Invalid package.json name"}],{onCancel:()=>{throw new Error(`${e.red("\u2716")} Operation cancelled`)}})}catch(a){console.log(a.message);return}}const{projectName:$,overwrite:U}=w,M=l.prefix?l.prefix+$:$,g=s.join(F,M);if(U?te(g):r.existsSync(g)||r.mkdirSync(g,{recursive:!0}),l.customInit)await l.customInit({themeName:$});else{const a=s.resolve(ae,"../..",`template-${l.name}`),i=(c,p)=>{const h=s.join(g,J[c]??c);p?r.writeFileSync(h,p):E(s.join(a,c),h)},T=r.readdirSync(a);for(const c of T.filter(p=>p!=="package.json"))i(c);const x=JSON.parse(r.readFileSync(s.join(a,"package.json"),"utf-8"));if(x.name=$||v(),l.name==="blog"){const c=K(x,u);Object.assign(x,c)}if(i("package.json",`${JSON.stringify(x,null,2)}
|
|
3
|
+
`),l.name==="blog")if(X(u)){const c=D(u),p=r.readdirSync(c);for(const h of p)E(s.join(c,h),s.join(g,h))}else{const c=s.join(g,"valaxy.config.ts");if(r.existsSync(c)){const p=r.readFileSync(c,"utf-8");r.writeFileSync(c,Q(p,u))}}}console.log(` ${e.dim("\u{1F4C1}")} ${e.dim(g)}`),console.log(),console.log(e.dim(" Scaffolding project in ")+m+e.dim(" ..."));const _=ne(C.env.npm_config_user_agent),S=_?_.name:"npm",R=s.relative(F,g);if(console.log(e.green(` Done.
|
|
4
|
+
`)),l.name==="addon")return;let b;if(o?b=!1:{yes:b}=await f({type:"confirm",name:"yes",initial:"Y",message:"Install and start it now?"}),b){let a;if(o?a="pnpm":{agent:a}=await f({name:"agent",type:"select",message:"Choose the agent",choices:["npm","yarn","pnpm","bun"].map(i=>({value:i,title:i})),initial:2}),!a)return;await j(a,["install"],{stdio:"inherit",cwd:g}),await j(a,y?["run","dev","--port",y]:["run","dev"],{stdio:"inherit",cwd:g})}else{switch(console.log(e.dim(`
|
|
5
5
|
start it later by:
|
|
6
|
-
`)),g!==
|
|
6
|
+
`)),g!==F&&console.log(` ${e.green("cd")} ${e.blue(R)}`),S){case"yarn":console.log(` ${e.green("yarn")}`),console.log(` ${e.green("yarn")} dev`);break;default:console.log(` ${e.green(S)} install`),console.log(` ${e.green(S)} run dev`);break}console.log(),console.log(` ${e.cyan("\u2728")}`)}}re().catch(t=>{console.error(t)});
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: home
|
|
3
|
+
|
|
4
|
+
hero:
|
|
5
|
+
name: My Site
|
|
6
|
+
text: Welcome to My Site
|
|
7
|
+
tagline: Powered by Valaxy
|
|
8
|
+
actions:
|
|
9
|
+
- theme: brand
|
|
10
|
+
text: Get Started
|
|
11
|
+
link: /
|
|
12
|
+
|
|
13
|
+
features:
|
|
14
|
+
- icon: i-ri-book-2-line
|
|
15
|
+
title: Documentation
|
|
16
|
+
details: Write docs with Markdown and Vue components.
|
|
17
|
+
- icon: i-ri-flashlight-line
|
|
18
|
+
title: Fast
|
|
19
|
+
details: Powered by Vite for instant HMR and fast builds.
|
|
20
|
+
- icon: i-ri-palette-line
|
|
21
|
+
title: Customizable
|
|
22
|
+
details: Fully customizable theme with flexible configuration.
|
|
23
|
+
---
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineValaxyConfig } from 'valaxy'
|
|
2
|
+
|
|
3
|
+
export default defineValaxyConfig({
|
|
4
|
+
theme: 'press',
|
|
5
|
+
themeConfig: {
|
|
6
|
+
nav: [
|
|
7
|
+
{ text: 'Home', link: '/' },
|
|
8
|
+
],
|
|
9
|
+
sidebar: [],
|
|
10
|
+
footer: {
|
|
11
|
+
message: 'Powered by <a href="https://valaxy.site">Valaxy</a>',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
unocss: {
|
|
15
|
+
safelist: [
|
|
16
|
+
'i-ri-book-2-line',
|
|
17
|
+
'i-ri-flashlight-line',
|
|
18
|
+
'i-ri-palette-line',
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
})
|