create-valaxy 1.1.0 → 1.2.0
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 +4 -4
- package/package.json +14 -2
- package/template-blog/README.md +36 -13
- package/template-blog/package.json +3 -3
- package/template-blog/pages/posts/hello-valaxy.md +3 -1
- package/template-blog/pnpm-workspace.yaml +9 -0
- package/template-blog/site.config.ts +1 -0
- package/template-blog-press/site.config.ts +1 -0
- package/template-blog/_npmrc +0 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import x from"node:process";import r from"node:fs";import l from"node:path";import{fileURLToPath as U}from"node:url";import{colors as t}from"consola/utils";import{execa as E}from"execa";import J from"minimist";import v from"prompts";const Y="1.
|
|
2
|
-
${t.red("Removing")} ${t.dim(e)}`),!!r.existsSync(e))for(const n of r.readdirSync(e))n!==".git"&&r.rmSync(l.resolve(e,n),{recursive:!0,force:!0})}function R(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function P(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function ae(e){if(!e)return;const n=e.split(" ")[0].split("/");return{name:n[0],version:n[1]}}const u=J(x.argv.slice(2)),D=x.cwd(),re="valaxy-blog",ie=U(import.meta.url);async function le(){console.log(),console.log(` ${t.bold("\u{1F30C} Valaxy")} ${t.blue(`v${Y}`)}`),console.log();const e=O(u._[0]),n=u.template||u.t,o=u.y||u.yes,
|
|
3
|
-
`),i.name==="blog")if(Q(f)){const m=L(f),
|
|
4
|
-
`)),i.name==="addon")return;let k;if(o?k=!1:{yes:k}=await v({type:"confirm",name:"yes",initial:"Y",message:"Install and start it now?"}),k){let c;if(o?c="pnpm":{agent:c}=await v({name:"agent",type:"select",message:"Choose the agent",choices:["npm","yarn","pnpm","bun"].map(a=>({value:a,title:a})),initial:2}),!c)return;await E(c,["install"],{stdio:"inherit",cwd:s}),await E(c,
|
|
1
|
+
import x from"node:process";import r from"node:fs";import l from"node:path";import{fileURLToPath as U}from"node:url";import{colors as t}from"consola/utils";import{execa as E}from"execa";import J from"minimist";import v from"prompts";const Y="1.2.0",N={name:"starter",repo:"https://github.com/valaxyjs/valaxy-theme-starter"};async function G(e){const n=N.name;let o=e.themeName||n;const p=`valaxy-theme-${o.trim()}`;return console.log(` ${t.dim("npx")} ${t.gray("degit")} ${t.blue(N.repo)} ${t.yellow(p)}`),await E("npx",["degit",N.repo,p],{stdio:"inherit"}),console.log(),console.log(` ${t.bold("Check it")}:`),console.log(),console.log(`- Change ${t.bold("author")} name in ${t.yellow("LICENSE")} & ${t.green("package.json")} & ${t.blue(".github")}`),console.log(`- Change ${t.blue("valaxy.config.ts")} theme: ${t.yellow("starter")} to ${t.cyan(`${o}`)}`),console.log(`- Rename ${t.yellow(`valaxy-theme-${o}`)} to ${t.cyan(`valaxy-theme-${o}`)}`),console.log(),console.log(` ${t.cyan("\u2728")}`),console.log(),`valaxy-theme-${o}`}const W={_gitignore:".gitignore"},Z=[{name:"yun",display:"Yun",desc:"A light & clean theme (default)",color:t.cyan},{name:"press",display:"Press",desc:"A document-oriented theme",color:t.green},{name:"custom",display:"Custom",desc:"Enter a custom theme name",color:t.yellow}],w=[{name:"blog",display:"Blog",desc:"For Most Users",message:"Project name:",initial:"valaxy-blog",color:t.cyan},{name:"theme",display:"Theme",desc:"For Theme Developers",message:"Theme name: valaxy-theme-",initial:"starter",prefix:"valaxy-theme-",color:t.green,customInit:async e=>G(e).catch(n=>{console.error(n)})},{name:"addon",display:"Addon",desc:"For Addon Developers",message:"Addon name: valaxy-addon-",initial:"template",prefix:"valaxy-addon-",color:t.yellow}],F=w.map(e=>e.name),z="valaxy-theme-",q=/^[a-z\d\-_]+$/,K=U(import.meta.url);function L(e){if(!q.test(e))throw new Error(`Invalid theme name: "${e}"`);return l.resolve(K,"../..",`template-blog-${e}`)}function Q(e){try{return r.existsSync(L(e))}catch{return!1}}function X(e){const n=e.trim();return n.startsWith(z)?n.slice(z.length):n}function ee(e,n){const o={...e,dependencies:{...e.dependencies}};return n==="yun"||(o.dependencies?.["valaxy-theme-yun"]&&delete o.dependencies["valaxy-theme-yun"],o.dependencies[`valaxy-theme-${n}`]=n==="press"&&o.dependencies.valaxy||"latest"),o}function te(e,n){if(n==="yun")return e;let o=e;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(e){return e?.trim().replace(/\/+$/g,"")}function M(e){const n=r.readdirSync(e);return n.length===0||n.length===1&&n[0]===".git"}function _(e,n){r.statSync(e).isDirectory()?ne(e,n):r.copyFileSync(e,n)}function ne(e,n){r.mkdirSync(n,{recursive:!0});for(const o of r.readdirSync(e)){const p=l.resolve(e,o),g=l.resolve(n,o);_(p,g)}}function oe(e){if(console.log(`
|
|
2
|
+
${t.red("Removing")} ${t.dim(e)}`),!!r.existsSync(e))for(const n of r.readdirSync(e))n!==".git"&&r.rmSync(l.resolve(e,n),{recursive:!0,force:!0})}function R(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function P(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function ae(e){if(!e)return;const n=e.split(" ")[0].split("/");return{name:n[0],version:n[1]}}const u=J(x.argv.slice(2)),D=x.cwd(),re="valaxy-blog",ie=U(import.meta.url);async function le(){console.log(),console.log(` ${t.bold("\u{1F30C} Valaxy")} ${t.blue(`v${Y}`)}`),console.log();const e=O(u._[0]),n=u.template||u.t,o=u.y||u.yes,p=u.port||u.p;let g=e||re;const S=()=>g==="."?l.basename(l.resolve()):g;let b;const C=w.find(c=>c.name===n);if(o&&n&&!C)throw new Error(`Unknown template: ${n}. Choose ${F.join(", ")}.`);let i=C||w[0],f="yun";if(o)b={projectName:g,overwrite:!1,packageName:P(S())};else{const c=await v({type:n&&F.includes(n)?null:"select",name:"template",message:typeof n=="string"&&!F.includes(n)?t.reset(`"${n}" isn't a valid template. Please choose from below: `):t.reset("Select a type:"),initial:0,choices:w.map(a=>{const y=a.color;return{title:y(a.display||a.name)+t.dim(` - ${a.desc}`),value:a}})});if(!C&&!c.template)return;if(i=c.template||i,i.name==="blog"){const a=await v({type:"select",name:"theme",message:t.reset("Select a theme:"),initial:0,choices:Z.map(y=>{const h=y.color;return{title:h(y.display)+t.dim(` - ${y.desc}`),value:y.name}})});if(a.theme==="custom"){const y=await v({type:"text",name:"themeName",message:t.reset('Theme name (e.g. "starter" or "valaxy-theme-starter"):'),initial:"yun"});f=X(y.themeName||"yun")}else f=a.theme||"yun"}try{b=await v([{type:e?null:"text",name:"projectName",message:t.reset(i.message),initial:i.initial,onState:a=>{g=O(i.prefix?i.prefix+a.value:a.value)||i.initial}},{type:()=>!r.existsSync(g)||M(g)?null:"confirm",name:"overwrite",message:()=>`${g==="."?"Current directory":`Target directory "${g}"`} is not empty. Remove existing files and continue?`},{type:(a,{overwrite:y})=>{if(y===!1)throw new Error(`${t.red("\u2716")} Operation cancelled`);return null},name:"overwriteChecker"},{type:()=>R(S())?null:"text",name:"packageName",message:t.reset("Package name:"),initial:()=>P(S()),validate:a=>R(a)||"Invalid package.json name"}],{onCancel:()=>{throw new Error(`${t.red("\u2716")} Operation cancelled`)}})}catch(a){console.log(a.message);return}}const{projectName:T=g,overwrite:V,packageName:H}=b,I=e||(i.prefix?i.prefix+T:T),s=l.resolve(D,I);if(o&&r.existsSync(s)&&!M(s))throw new Error(`Target directory "${I}" is not empty. Run without --yes to confirm overwriting.`);if(V?oe(s):r.existsSync(s)||r.mkdirSync(s,{recursive:!0}),i.customInit)await i.customInit({themeName:T});else{const c=l.resolve(ie,"../..",`template-${i.name}`),a=(m,d)=>{const $=l.join(s,W[m]??m);d?r.writeFileSync($,d):_(l.join(c,m),$)},y=r.readdirSync(c);for(const m of y.filter(d=>d!=="package.json"))a(m);const h=JSON.parse(r.readFileSync(l.join(c,"package.json"),"utf-8"));if(h.name=H||P(l.basename(s)),i.name==="blog"){const m=ee(h,f);Object.assign(h,m)}if(a("package.json",`${JSON.stringify(h,null,2)}
|
|
3
|
+
`),i.name==="blog")if(Q(f)){const m=L(f),d=r.readdirSync(m);for(const $ of d)_(l.join(m,$),l.join(s,$))}else{const m=l.join(s,"valaxy.config.ts");if(r.existsSync(m)){const d=r.readFileSync(m,"utf-8");r.writeFileSync(m,te(d,f))}}}console.log(` ${t.dim("\u{1F4C1}")} ${t.dim(s)}`),console.log(),console.log(t.dim(" Scaffolding project in ")+g+t.dim(" ..."));const A=ae(x.env.npm_config_user_agent),j=A?A.name:"npm",B=l.relative(D,s);if(console.log(t.green(` Done.
|
|
4
|
+
`)),i.name==="addon")return;let k;if(o?k=!1:{yes:k}=await v({type:"confirm",name:"yes",initial:"Y",message:"Install and start it now?"}),k){let c;if(o?c="pnpm":{agent:c}=await v({name:"agent",type:"select",message:"Choose the agent",choices:["npm","yarn","pnpm","bun"].map(a=>({value:a,title:a})),initial:2}),!c)return;await E(c,["install"],{stdio:"inherit",cwd:s}),await E(c,p?["run","dev","--port",p]:["run","dev"],{stdio:"inherit",cwd:s})}else{switch(console.log(t.dim(`
|
|
5
5
|
start it later by:
|
|
6
6
|
`)),s!==D&&console.log(` ${t.green("cd")} ${t.blue(B)}`),j){case"yarn":console.log(` ${t.green("yarn")}`),console.log(` ${t.green("yarn")} dev`);break;default:console.log(` ${t.green(j)} install`),console.log(` ${t.green(j)} run dev`);break}console.log(),console.log(` ${t.cyan("\u2728")}`)}}le().catch(e=>{console.error(e),x.exitCode=1});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-valaxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "Create Starter Template for Valaxy",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "me@yunyoujun.cn",
|
|
@@ -28,7 +28,19 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"bin",
|
|
30
30
|
"dist",
|
|
31
|
-
"template-*/**/*"
|
|
31
|
+
"template-*/**/*",
|
|
32
|
+
"!template-*/*.log",
|
|
33
|
+
"!template-*/.env*",
|
|
34
|
+
"!template-*/.valaxy/**",
|
|
35
|
+
"!template-*/.vite-ssg-dist/**",
|
|
36
|
+
"!template-*/.vite-ssg-temp/**",
|
|
37
|
+
"!template-*/dist-ssr/**",
|
|
38
|
+
"!template-*/dist/**",
|
|
39
|
+
"!template-*/node_modules/**",
|
|
40
|
+
"!template-*/public/atom.xml",
|
|
41
|
+
"!template-*/public/feed.json",
|
|
42
|
+
"!template-*/public/feed.xml",
|
|
43
|
+
"!template-*/public/valaxy-fuse-list.json"
|
|
32
44
|
],
|
|
33
45
|
"engines": {
|
|
34
46
|
"node": ">=22.12.0"
|
package/template-blog/README.md
CHANGED
|
@@ -1,28 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# My Valaxy blog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Follow the [Getting Started guide](https://valaxy.site/guide/getting-started) ([中文](https://valaxy.site/zh/guide/getting-started)). Requires Node.js `>=22.12.0` and pnpm `>=10.26.0`. Keep `pnpm-workspace.yaml`, which includes dependency build script permissions for installation.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
pnpm install
|
|
9
|
+
pnpm dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Open the `Preview` address in the terminal (usually `http://localhost:4859/`). Leave the server running while editing; stop it with `Ctrl+C`.
|
|
13
|
+
|
|
14
|
+
### Write a post
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
Create `pages/posts/first-post.md`:
|
|
17
|
+
|
|
18
|
+
```md
|
|
19
|
+
---
|
|
20
|
+
title: My first post
|
|
21
|
+
date: 2026-10-05
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
Hello, Valaxy!
|
|
15
25
|
```
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
Use your publication date. Save the file, then open `/posts/first-post` or click its title on the home page. You can also generate a file with `pnpm exec valaxy new first-post` from a second terminal in this project.
|
|
18
28
|
|
|
19
29
|
### Config
|
|
20
30
|
|
|
21
|
-
|
|
31
|
+
Edit `site.config.ts` for `title`, `author.name`, `description`, `lang`, and your production `url`. The URL is used in post links, RSS, and the sitemap; replace the example before deployment.
|
|
32
|
+
|
|
33
|
+
Keep an explicit `timezone` (the Yun template uses `Asia/Shanghai`) so the build server and visitors display the same post times. For precise publication times, use an offset such as `2026-10-05T14:30:00+08:00`; `valaxy new` generates this format automatically.
|
|
34
|
+
|
|
35
|
+
Edit `valaxy.config.ts` for theme and framework options. Yun's large home page text uses `themeConfig.banner.title`. Replace or disable the template's example social links, sponsorship details, and footer registration information before deployment.
|
|
36
|
+
|
|
37
|
+
### Build and preview
|
|
38
|
+
|
|
39
|
+
Stop the development server, then run:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pnpm build
|
|
43
|
+
pnpm serve
|
|
44
|
+
```
|
|
22
45
|
|
|
23
|
-
|
|
46
|
+
The build prerenders pages into `dist/`. Open the preview address (usually `http://localhost:4173/`) and check the home page and `/posts/first-post`, including after a refresh. The corresponding files are `dist/index.html` and `dist/posts/first-post.html`.
|
|
24
47
|
|
|
25
|
-
|
|
48
|
+
Run `pnpm build` again after editing; `pnpm serve` only serves existing output. See the [deployment guide](https://valaxy.site/guide/deploy) to deploy `dist/`.
|
|
26
49
|
|
|
27
50
|
### Docker
|
|
28
51
|
|
|
@@ -38,7 +61,7 @@ In most cases, you only need to work in the `pages` folder.
|
|
|
38
61
|
|
|
39
62
|
- `pages`: your all pages
|
|
40
63
|
- `posts`: write your posts here, will be counted as posts
|
|
41
|
-
- `styles`: override theme styles, `index.
|
|
64
|
+
- `styles`: override theme styles, `index.ts`/`index.scss`/`index.css` will be loaded automatically
|
|
42
65
|
- `components`: custom your vue components (will be loaded automatically)
|
|
43
66
|
- `layouts`: custom layouts (use it by `layout: xxx` in md)
|
|
44
67
|
- `locales`: custom i18n
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"node": ">=22.12.0"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "
|
|
10
|
+
"build": "valaxy build --ssg",
|
|
11
11
|
"build:spa": "valaxy build",
|
|
12
12
|
"build:ssg": "valaxy build --ssg",
|
|
13
13
|
"dev": "valaxy",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"serve": "vite preview"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"valaxy": "1.
|
|
19
|
-
"valaxy-theme-yun": "1.
|
|
18
|
+
"valaxy": "1.2.0",
|
|
19
|
+
"valaxy-theme-yun": "1.2.0",
|
|
20
20
|
"vue": "^3.5.41",
|
|
21
21
|
"vue-router": "^5.0.0"
|
|
22
22
|
},
|
|
@@ -24,4 +24,6 @@ Components in `components/` can be used directly in Markdown. This cover uses Vu
|
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Edit `site.config.ts` for your site title, author, description, and production URL. Edit `valaxy.config.ts` for theme and framework options.
|
|
28
|
+
|
|
29
|
+
Add Markdown posts to `pages/posts/`, then run `pnpm build` to generate your site in `dist/`. Preview the result with `pnpm serve`.
|
package/template-blog/_npmrc
DELETED