create-dlightjs
Advanced tools
Comparing version
#!/usr/bin/env node | ||
import{input as h,select as r,checkbox as y}from"@inquirer/prompts";import{execSync as g}from"child_process";function l(e){console.log(`\x1B[0;32m\u2714\uFE0F ${e}\x1B[0m`)}function s(e){console.log(`\x1B[0;36m${e}\x1B[0m`)}function n(e){return JSON.stringify(e).replace("{",`{ | ||
import{input as h,select as r,checkbox as y}from"@inquirer/prompts";import{execSync as g}from"child_process";function l(e){console.log(`\x1B[0;32m\u2714\uFE0F ${e}\x1B[0m`)}function n(e){console.log(`\x1B[0;36m${e}\x1B[0m`)}function a(e){return JSON.stringify(e).replace("{",`{ | ||
`).replace("}",` | ||
@@ -17,4 +17,4 @@ }`).replace(/,/g,`, | ||
\\______/ | ||
`;import{fileURLToPath as v}from"node:url";import j from"node-fetch";import x from"path";import o from"fs";var a=await h({message:"\u{1F4BB} Your project name",default:"my-dlight-app",validate:e=>e.length===0?"Enter a valid project name!":o.existsSync(e)?"Folder already exsits":/^[a-z]+([-_][a-z0-9]+)*$/.test(e)?!0:"Use lowercase letters, no spaces or special characters. Use hyphens or underscores to separate words."}),d=await r({message:"\u{1F951} Language support",choices:[{name:"Javascript",value:"js"},{name:"Typescript",value:"ts"}]}),w=await r({message:"\u{1F4C3} blank template",choices:[{name:"yes",value:!0},{name:"no",value:!1}]}),_=await y({message:"\u{1F4E6} Packages to be installed",choices:[{name:"@dlightjs/components",value:"@dlightjs/components"},{name:"@dlightjs/decorators",value:"@dlightjs/decorators"},{name:"@dlightjs/material-icons",value:"@dlightjs/material-icons"},{name:"@dlightjs/markit",value:"@dlightjs/markit"},{name:"@iandx/easy-css",value:"@iandx/easy-css"}]}),i=["vite","vite-plugin-dlight"];_.push("@dlightjs/dlight");d==="ts"&&(i.push("@dlightjs/types"),i.push("typescript"));var $=async e=>await j(`https://registry.npmjs.org/${e}`).then(async D=>await D.json()).then(D=>D["dist-tags"].latest),m=async e=>{let D={};return await Promise.all(e.map(async c=>{let f=await $(c);D[c]=`^${f}`})),D},[E,N]=await Promise.all([m(_),m(i)]),P=x.resolve(v(import.meta.url),"../../templates",`dlight-vite-${w?"min-":""}${d}`);g(`cp -r ${P} ./${a}`);var u=`${a}/package.json`,b=o.readFileSync(u,{encoding:"utf8",flag:"r"});o.writeFileSync(u,b.replace("{{ PROJECT_NAME }}",a).replace("{{ DEPENDENCIES }}",n(E)).replace("{{ DEV_DEPENDENCIES }}",n(N)),{encoding:"utf8",flag:"w"});var t=await r({message:"\u{1F372} Package manager",choices:[{name:"NPM",value:"npm"},{name:"PNPM",value:"pnpm"},{name:"YARN",value:"yarn"},{name:"NONE",value:void 0,description:"Install by yourself"}]});if(t){g(`${t} install`,{cwd:a,stdio:"inherit"}),l(`Successfully installed dependencies using ${t}!`);let e="";t==="pnpm"?e="pnpm dev":t==="npm"?e="npm run dev":t==="yarn"&&(e="yarn dev"),s(`Run app with \`cd ${a} && ${e}\` | ||
`)}s("\u{1F389} All done!");s(p);s(":D Happy coding in DLight!"); | ||
`;import{fileURLToPath as v}from"node:url";import j from"node-fetch";import w from"path";import o from"fs";var s=await h({message:"\u{1F4BB} Your project name",default:"my-dlight-app",validate:e=>e.length===0?"Enter a valid project name!":o.existsSync(e)?"Folder already exsits":/^[a-z]+([-_][a-z0-9]+)*$/.test(e)?!0:"Use lowercase letters, no spaces or special characters. Use hyphens or underscores to separate words."}),d=await r({message:"\u{1F951} Language support",choices:[{name:"Javascript",value:"js"},{name:"Typescript",value:"ts"}]}),x=await r({message:"\u{1F4C3} blank template",choices:[{name:"yes",value:!0},{name:"no",value:!1}]}),_=await y({message:"\u{1F4E6} Packages to be installed",choices:[{name:"@dlightjs/components",value:"@dlightjs/components"},{name:"@dlightjs/material-icons",value:"@dlightjs/material-icons"},{name:"@dlightjs/markit",value:"@dlightjs/markit"}]}),i=["vite","vite-plugin-dlight"];_.push("@dlightjs/dlight");d==="ts"&&(i.push("@dlightjs/types"),i.push("typescript"));var $=async e=>await j(`https://registry.npmjs.org/${e}`).then(async D=>await D.json()).then(D=>D["dist-tags"].latest),m=async e=>{let D={};return await Promise.all(e.map(async c=>{let f=await $(c);D[c]=`^${f}`})),D},[E,N]=await Promise.all([m(_),m(i)]),P=w.resolve(v(import.meta.url),"../../templates",`dlight-vite-${x?"min-":""}${d}`);g(`cp -r ${P} ./${s}`);var u=`${s}/package.json`,b=o.readFileSync(u,{encoding:"utf8",flag:"r"});o.writeFileSync(u,b.replace("{{ PROJECT_NAME }}",s).replace("{{ DEPENDENCIES }}",a(E)).replace("{{ DEV_DEPENDENCIES }}",a(N)),{encoding:"utf8",flag:"w"});var t=await r({message:"\u{1F372} Package manager",choices:[{name:"NPM",value:"npm"},{name:"PNPM",value:"pnpm"},{name:"YARN",value:"yarn"},{name:"NONE",value:void 0,description:"Install by yourself"}]});if(t){g(`${t} install`,{cwd:s,stdio:"inherit"}),l(`Successfully installed dependencies using ${t}!`);let e="";t==="pnpm"?e="pnpm dev":t==="npm"?e="npm run dev":t==="yarn"&&(e="yarn dev"),n(`Run app with \`cd ${s} && ${e}\` | ||
`)}n("\u{1F389} All done!");n(p);n(":D Happy coding in DLight!"); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "create-dlightjs", | ||
"version": "0.10.1", | ||
"version": "1.0.0-alpha.0", | ||
"description": "DLight cli", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -10,9 +10,9 @@ import { View } from "@dlightjs/dlight" | ||
Body() { | ||
View() { | ||
div() | ||
.className(wrap) | ||
.class(wrap) | ||
{ | ||
Header() | ||
div() | ||
.className(slogan2) | ||
.class(slogan2) | ||
{ | ||
@@ -22,24 +22,24 @@ p() | ||
span("D") | ||
.className(colorD) | ||
.class(colorD) | ||
span("Light") | ||
.className(colorL) | ||
.class(colorL) | ||
} | ||
p("Your Modern") | ||
.className(m0) | ||
p("Web Framework") | ||
p("DX-First UI") | ||
.class(m0) | ||
p("Rendering Library") | ||
} | ||
div() | ||
.className(countWrap) | ||
.class(countWrap) | ||
{ | ||
p(this.count) | ||
.className(`${countBtn} ${countText}`) | ||
.class(`${countBtn} ${countText}`) | ||
div() | ||
.className(btnWrap) | ||
.class(btnWrap) | ||
{ | ||
Button("count ++") | ||
.onclick(() => { | ||
.onClick(() => { | ||
this.count++ | ||
}) | ||
Button("count --") | ||
.onclick(() => { | ||
.onClick(() => { | ||
this.count-- | ||
@@ -46,0 +46,0 @@ }) |
@@ -7,13 +7,13 @@ import { View } from "@dlightjs/dlight" | ||
@Content content | ||
onclick | ||
@Prop onClick | ||
btnStatus = 0 | ||
Body() { | ||
View() { | ||
button(this.content) | ||
.className(this.btnStatus[index] === 1 ? `${countBtn} ${btnHover}` : countBtn) | ||
.onclick(this.onclick) | ||
.onmouseover(() => { | ||
.class(this.btnStatus === 1 ? `${countBtn} ${btnHover}` : countBtn) | ||
.onClick(this.onClick) | ||
.onMouseOver(() => { | ||
this.btnStatus = 1 | ||
}) | ||
.onmouseleave(() => { | ||
.onMouseLeave(() => { | ||
this.btnStatus = 0 | ||
@@ -20,0 +20,0 @@ }) |
@@ -21,9 +21,9 @@ import { View } from "@dlightjs/dlight" | ||
Body() { | ||
View() { | ||
div() | ||
.className(headerWrap) | ||
.class(headerWrap) | ||
{ | ||
img() | ||
.src("./logo_title.png") | ||
.className(headerLogo) | ||
.class(headerLogo) | ||
div() | ||
@@ -33,3 +33,3 @@ { | ||
a(navItem.navName) | ||
.className(navBtn) | ||
.class(navBtn) | ||
.href(navItem.url) | ||
@@ -36,0 +36,0 @@ } |
@@ -5,6 +5,2 @@ import { defineConfig } from 'vite' | ||
export default defineConfig({ | ||
server: { | ||
port: 4320 | ||
}, | ||
base: '', | ||
plugins: [ | ||
@@ -11,0 +7,0 @@ dlight({ files: "**/*.view.js" }) |
@@ -5,5 +5,5 @@ import { View } from "@dlightjs/dlight" | ||
export default class App { | ||
Body() { | ||
View() { | ||
div("hello dlight!") | ||
} | ||
} |
@@ -5,6 +5,2 @@ import { defineConfig } from 'vite' | ||
export default defineConfig({ | ||
server: { | ||
port: 4320 | ||
}, | ||
base: '', | ||
plugins: [ | ||
@@ -11,0 +7,0 @@ dlight({ files: "**/*.view.js" }) |
@@ -9,3 +9,3 @@ import { View } from "@dlightjs/dlight" | ||
class App implements AppProps { | ||
Body() { | ||
View() { | ||
div("hello dlight") | ||
@@ -12,0 +12,0 @@ } |
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"useDefineForClassFields": true, | ||
"module": "ESNext", | ||
"lib": ["ESNext", "DOM"], | ||
"moduleResolution": "Node", | ||
"strict": true, | ||
"isolatedModules": true, | ||
"esModuleInterop": true, | ||
"noEmit": true, | ||
"noUnusedParameters": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": true | ||
"strict": true | ||
}, | ||
"ts-node": { | ||
"esm": true | ||
}, | ||
"include": [ | ||
"src/" | ||
] | ||
} | ||
} | ||
} |
@@ -5,6 +5,2 @@ import { defineConfig } from 'vite' | ||
export default defineConfig({ | ||
server: { | ||
port: 4320 | ||
}, | ||
base: '', | ||
plugins: [ | ||
@@ -11,0 +7,0 @@ dlight({ files: "**/*.view.ts" }) |
@@ -8,5 +8,6 @@ import { View } from "@dlightjs/dlight" | ||
content: string | ||
onclick: () => void | ||
onClick: () => void | ||
index: number | ||
} | ||
@View | ||
@@ -18,24 +19,24 @@ class App { | ||
@View | ||
Btn = (({ content, onclick, index }: BtnProps) => { | ||
Btn = (({ content, onClick, index }: BtnProps) => { | ||
button(content) | ||
.className(this.btnStatus[index] === 1 ? `${countBtn} ${btnHover}` : countBtn) | ||
.onclick(onclick) | ||
.onmouseover(() => { | ||
.class(this.btnStatus[index] === 1 ? `${countBtn} ${btnHover}` : countBtn) | ||
.onClick(onClick) | ||
.onMouseOver(() => { | ||
this.btnStatus[index] = 1 | ||
this.btnStatus = [...this.btnStatus] | ||
}) | ||
.onmouseleave(() => { | ||
.onMouseLeave(() => { | ||
this.btnStatus[index] = 0 | ||
this.btnStatus = [...this.btnStatus] | ||
}) | ||
}) as any as SubTyped<BtnProps> | ||
}) as Pretty as SubTyped<BtnProps> | ||
Body() { | ||
View() { | ||
div() | ||
.className(wrap) | ||
.class(wrap) | ||
{ | ||
Header() | ||
div() | ||
.className(slogan2) | ||
.class(slogan2) | ||
{ | ||
@@ -45,21 +46,21 @@ p() | ||
span("D") | ||
.className(colorD) | ||
.class(colorD) | ||
span("Light") | ||
.className(colorL) | ||
.class(colorL) | ||
} | ||
p("Your Modern") | ||
.className(m0) | ||
p("Web Framework") | ||
p("DX-first UI") | ||
.class(m0) | ||
p("Rendering Library") | ||
} | ||
div() | ||
.className(countWrap) | ||
.class(countWrap) | ||
{ | ||
p(this.count) | ||
.className(`${countBtn} ${countText}`) | ||
.class(`${countBtn} ${countText}`) | ||
div() | ||
.className(btnWrap) | ||
.class(btnWrap) | ||
{ | ||
this.Btn("count ++") | ||
.index(0) | ||
.onclick(() => { | ||
.onClick(() => { | ||
this.count++ | ||
@@ -69,3 +70,3 @@ }) | ||
.index(1) | ||
.onclick(() => { | ||
.onClick(() => { | ||
this.count-- | ||
@@ -72,0 +73,0 @@ }) |
@@ -30,13 +30,13 @@ import { View } from "@dlightjs/dlight" | ||
a(navName) | ||
.className(navBtn) | ||
.class(navBtn) | ||
.href(url) | ||
}) as any as Typed<NavProps> | ||
}) as Pretty as Typed<NavProps> | ||
Body() { | ||
View() { | ||
div() | ||
.className(headerWrap) | ||
.class(headerWrap) | ||
{ | ||
img() | ||
.src("./logo_title.png") | ||
.className(headerLogo) | ||
.class(headerLogo) | ||
div() | ||
@@ -43,0 +43,0 @@ { |
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"useDefineForClassFields": true, | ||
"module": "ESNext", | ||
"lib": ["ESNext", "DOM"], | ||
"moduleResolution": "Node", | ||
"strict": true, | ||
"isolatedModules": true, | ||
"esModuleInterop": true, | ||
"noEmit": true, | ||
"noUnusedParameters": true, | ||
"skipLibCheck": true, | ||
"experimentalDecorators": true | ||
"strict": true | ||
}, | ||
"ts-node": { | ||
"esm": true | ||
}, | ||
"include": [ | ||
"src/" | ||
] | ||
} | ||
} | ||
} |
@@ -5,6 +5,2 @@ import { defineConfig } from 'vite' | ||
export default defineConfig({ | ||
server: { | ||
port: 4320 | ||
}, | ||
base: '', | ||
plugins: [ | ||
@@ -11,0 +7,0 @@ dlight({ files: "**/*.view.ts" }) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
57212
-1.83%581
-6.29%