create-valaxy 1.2.2 → 1.3.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,4 +1,4 @@
1
- import x from"node:process";import r from"node:fs";import i 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.2",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 d=`valaxy-theme-${o.trim()}`;return console.log(` ${t.dim("npx")} ${t.gray("degit")} ${t.blue(N.repo)} ${t.yellow(d)}`),await E("npx",["degit",N.repo,d],{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 i.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){i.basename(e)!==".npmignore"&&(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 d=i.resolve(e,o),g=i.resolve(n,o);_(d,g)}}function oe(e){if(console.log(`
1
+ import x from"node:process";import r from"node:fs";import i 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.3.1",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 d=`valaxy-theme-${o.trim()}`;return console.log(` ${t.dim("npx")} ${t.gray("degit")} ${t.blue(N.repo)} ${t.yellow(d)}`),await E("npx",["degit",N.repo,d],{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 i.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){i.basename(e)!==".npmignore"&&(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 d=i.resolve(e,o),g=i.resolve(n,o);_(d,g)}}function oe(e){if(console.log(`
2
2
  ${t.red("Removing")} ${t.dim(e)}`),!!r.existsSync(e))for(const n of r.readdirSync(e))n!==".git"&&r.rmSync(i.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,d=u.port||u.p;let g=e||re;const S=()=>g==="."?i.basename(i.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 l=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 p=a.color;return{title:p(a.display||a.name)+t.dim(` - ${a.desc}`),value:a}})});if(!C&&!c.template)return;if(l=c.template||l,l.name==="blog"){const a=await v({type:"select",name:"theme",message:t.reset("Select a theme:"),initial:0,choices:Z.map(p=>{const h=p.color;return{title:h(p.display)+t.dim(` - ${p.desc}`),value:p.name}})});if(a.theme==="custom"){const p=await v({type:"text",name:"themeName",message:t.reset('Theme name (e.g. "starter" or "valaxy-theme-starter"):'),initial:"yun"});f=X(p.themeName||"yun")}else f=a.theme||"yun"}try{b=await v([{type:e?null:"text",name:"projectName",message:t.reset(l.message),initial:l.initial,onState:a=>{g=O(l.prefix?l.prefix+a.value:a.value)||l.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:p})=>{if(p===!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||(l.prefix?l.prefix+T:T),s=i.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}),l.customInit)await l.customInit({themeName:T});else{const c=i.resolve(ie,"../..",`template-${l.name}`),a=(m,y)=>{const $=i.join(s,W[m]??m);y?r.writeFileSync($,y):_(i.join(c,m),$)},p=r.readdirSync(c);for(const m of p.filter(y=>y!=="package.json"))a(m);const h=JSON.parse(r.readFileSync(i.join(c,"package.json"),"utf-8"));if(h.name=H||P(i.basename(s)),l.name==="blog"){const m=ee(h,f);Object.assign(h,m)}if(a("package.json",`${JSON.stringify(h,null,2)}
3
3
  `),l.name==="blog")if(Q(f)){const m=L(f),y=r.readdirSync(m);for(const $ of y)_(i.join(m,$),i.join(s,$))}else{const m=i.join(s,"valaxy.config.ts");if(r.existsSync(m)){const y=r.readFileSync(m,"utf-8");r.writeFileSync(m,te(y,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=i.relative(D,s);if(console.log(t.green(` Done.
4
4
  `)),l.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,d?["run","dev","--port",d]:["run","dev"],{stdio:"inherit",cwd:s})}else{switch(console.log(t.dim(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-valaxy",
3
3
  "type": "module",
4
- "version": "1.2.2",
4
+ "version": "1.3.1",
5
5
  "description": "Create Starter Template for Valaxy",
6
6
  "author": {
7
7
  "email": "me@yunyoujun.cn",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "valaxy-addon-template",
3
3
  "version": "0.0.1",
4
+ "packageManager": "pnpm@12.5.1",
4
5
  "description": "Template for Valaxy Addon.",
5
6
  "repository": "https://github.com/YunYouJun/valaxy",
6
7
  "keywords": [
@@ -8,35 +8,61 @@ on:
8
8
  - main
9
9
  - master
10
10
  - valaxy
11
+ workflow_dispatch:
11
12
 
12
- jobs:
13
- build:
14
- runs-on: ${{ matrix.os }}
13
+ # Publish the built site with GitHub Pages. The workflow token can read
14
+ # the repository and upload the artifact.
15
+ permissions:
16
+ contents: read
17
+ pages: write
18
+ id-token: write
15
19
 
16
- strategy:
17
- matrix:
18
- node-version: [lts/*]
19
- os: [ubuntu-latest]
20
- fail-fast: false
20
+ # One deployment at a time. Let an in-progress production deploy finish.
21
+ concurrency:
22
+ group: pages
23
+ cancel-in-progress: false
21
24
 
25
+ jobs:
26
+ build:
27
+ runs-on: ubuntu-latest
22
28
  steps:
23
- - uses: actions/checkout@v2
29
+ - uses: actions/checkout@v7
30
+ with:
31
+ # Git dates for posts need the full history.
32
+ # 文章的 Git 日期需要完整提交历史。
33
+ fetch-depth: 0
24
34
 
25
- - name: Use Node.js ${{ matrix.node-version }}
26
- uses: actions/setup-node@v2
35
+ # Read the exact pnpm version from package.json's packageManager field.
36
+ - uses: pnpm/action-setup@v6
37
+
38
+ - name: Use Node.js LTS
39
+ uses: actions/setup-node@v7
27
40
  with:
28
- node-version: ${{ matrix.node-version }}
29
- registry-url: https://registry.npmjs.org/
41
+ node-version: lts/*
42
+
43
+ - name: Setup Pages
44
+ uses: actions/configure-pages@v6
30
45
 
31
- - name: 📦 Install Dependencies
32
- run: npm i
46
+ - name: Install dependencies
47
+ # The scaffold ships package.json without a lockfile.
48
+ run: pnpm install
33
49
 
34
- - name: 🌌 Build Valaxy Blog
35
- run: npm run build
50
+ - name: Build
51
+ run: pnpm run build
36
52
 
37
- - name: 🪤 Deploy to GitHub Pages
38
- uses: peaceiris/actions-gh-pages@v3
53
+ - name: Upload Pages artifact
54
+ uses: actions/upload-pages-artifact@v5
39
55
  with:
40
- github_token: ${{ secrets.GITHUB_TOKEN }}
41
- publish_dir: ./dist
42
- force_orphan: true
56
+ path: dist
57
+ include-hidden-files: true
58
+
59
+ deploy:
60
+ needs: build
61
+ runs-on: ubuntu-latest
62
+ environment:
63
+ name: github-pages
64
+ url: ${{ steps.deployment.outputs.page_url }}
65
+ steps:
66
+ - name: Deploy to GitHub Pages
67
+ id: deployment
68
+ uses: actions/deploy-pages@v5
@@ -4,7 +4,7 @@ Instructions for coding agents working in this Valaxy blog. This is a user site,
4
4
 
5
5
  ## Commands
6
6
 
7
- Use Node.js `>=22.12.0` and pnpm `>=10.26.0`. Keep `pnpm-workspace.yaml`; it records dependency build permissions.
7
+ Use Node.js `>=22.12.0` and the pnpm version pinned in `package.json`'s `packageManager` field. The deployment workflow uses Node.js LTS. Keep `pnpm-workspace.yaml`; it records dependency build permissions.
8
8
 
9
9
  ```bash
10
10
  pnpm install
@@ -1,6 +1,6 @@
1
1
  # My Valaxy blog
2
2
 
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.
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`; use the pnpm version pinned in `package.json`'s `packageManager` field. The deployment workflow uses Node.js LTS. Keep `pnpm-workspace.yaml`, which includes dependency build script permissions for installation.
4
4
 
5
5
  ## Usage
6
6
 
@@ -3,6 +3,7 @@
3
3
  "type": "module",
4
4
  "version": "0.0.0",
5
5
  "private": true,
6
+ "packageManager": "pnpm@12.5.1",
6
7
  "engines": {
7
8
  "node": ">=22.12.0"
8
9
  },
@@ -15,8 +16,8 @@
15
16
  "serve": "vite preview"
16
17
  },
17
18
  "dependencies": {
18
- "valaxy": "1.2.2",
19
- "valaxy-theme-yun": "1.2.2",
19
+ "valaxy": "1.3.1",
20
+ "valaxy-theme-yun": "1.3.1",
20
21
  "vue": "^3.5.41",
21
22
  "vue-router": "^5.0.0"
22
23
  },