create-valaxy 0.19.8 → 0.19.10

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 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.8";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(`
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.10";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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-valaxy",
3
3
  "type": "module",
4
- "version": "0.19.8",
4
+ "version": "0.19.10",
5
5
  "description": "Create Starter Template for Valaxy",
6
6
  "author": {
7
7
  "email": "me@yunyoujun.cn",
@@ -1,17 +1,18 @@
1
- FROM node:16-alpine as build-stage
1
+ FROM node:20-alpine as build-stage
2
2
 
3
3
  WORKDIR /app
4
4
  RUN corepack enable
5
5
 
6
- COPY .npmrc package.json ./
6
+ COPY .npmrc package.json pnpm-lock.yaml ./
7
7
  RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
8
- pnpm install
8
+ pnpm install --frozen-lockfile
9
9
 
10
10
  COPY . .
11
11
  RUN pnpm build
12
12
 
13
13
  FROM nginx:stable-alpine as production-stage
14
14
 
15
+ COPY nginx.conf /etc/nginx/nginx.conf
15
16
  COPY --from=build-stage /app/dist /usr/share/nginx/html
16
17
  EXPOSE 80
17
18
 
@@ -0,0 +1,30 @@
1
+ server {
2
+ gzip on;
3
+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
4
+
5
+ listen 80;
6
+ server_name _;
7
+ index index.html;
8
+
9
+ location / {
10
+ # content location
11
+ # root /app;
12
+ root /usr/share/nginx/html;
13
+
14
+ # exact matches -> reverse clean urls -> folders -> not found
15
+ try_files $uri $uri.html $uri/ =404;
16
+
17
+ # non existent pages
18
+ error_page 404 /404.html;
19
+
20
+ # a folder without index.html raises 403 in this setup
21
+ error_page 403 /404.html;
22
+
23
+ # adjust caching headers
24
+ # files in the assets folder have hashes filenames
25
+ location ~* ^/assets/ {
26
+ expires 1y;
27
+ add_header Cache-Control "public, immutable";
28
+ }
29
+ }
30
+ }
@@ -12,8 +12,8 @@
12
12
  "serve": "vite preview"
13
13
  },
14
14
  "dependencies": {
15
- "valaxy": "0.19.8",
16
- "valaxy-theme-yun": "0.19.8"
15
+ "valaxy": "0.19.10",
16
+ "valaxy-theme-yun": "0.19.10"
17
17
  },
18
18
  "devDependencies": {
19
19
  "typescript": "^5.5.4"