create-dlightjs
Advanced tools
Comparing version
#!/usr/bin/env node | ||
import{input as h,select as i,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("{",`{ | ||
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("{",`{ | ||
`).replace("}",` | ||
@@ -17,4 +17,4 @@ }`).replace(/,/g,`, | ||
\\______/ | ||
`;import{fileURLToPath as v}from"node:url";import x from"node-fetch";import j from"path";import r 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!":r.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 i({message:"\u{1F951} Language support",choices:[{name:"Javascript",value:"js"},{name:"Typescript",value:"ts"}]}),w=await i({message:"\u{1F4C3} blank template",choices:[{name:"yes",value:!0},{name:"no",value:!1}]}),o=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"},{name:"@iandx/easy-css",value:"@iandx/easy-css"}]}),_=["vite","vite-plugin-dlight"];o.push("@dlightjs/dlight");d==="ts"&&(o.push("@dlightjs/types"),_.push("typescript"));var $=async e=>await x(`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(o),m(_)]),P=j.resolve(v(import.meta.url),"../../templates",`dlight-vite-${w?"min-":""}${d}`);g(`cp -r ${P} ./${s}`);var u=`${s}/package.json`,b=r.readFileSync(u,{encoding:"utf8",flag:"r"});r.writeFileSync(u,b.replace("{{ PROJECT_NAME }}",s).replace("{{ DEPENDENCIES }}",a(E)).replace("{{ DEV_DEPENDENCIES }}",a(N)),{encoding:"utf8",flag:"w"});var t=await i({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!"); | ||
`;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!"); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "create-dlightjs", | ||
"version": "0.9.33", | ||
"version": "0.9.34", | ||
"description": "DLight cli", | ||
@@ -5,0 +5,0 @@ "author": { |
import { View } from "@dlightjs/dlight" | ||
export default class App extends View { | ||
@View | ||
export default class App { | ||
Body() { | ||
@@ -5,0 +6,0 @@ div("hello dlight!") |
@@ -7,3 +7,4 @@ import { View } from "@dlightjs/dlight" | ||
class App extends View implements AppProps { | ||
@View | ||
class App implements AppProps { | ||
Body() { | ||
@@ -10,0 +11,0 @@ div("hello dlight") |
Sorry, the diff of this file is not supported yet
58016
0.33%609
0.33%