create-enpage
Advanced tools
Comparing version 0.0.16 to 0.0.17
#!/usr/bin/env node | ||
import k from"degit";import{program as m}from"commander";import{resolve as i}from"path";import b from"path";import r from"chalk";import{existsSync as x,mkdirSync as S,lstatSync as v,readdirSync as D,readFileSync as E,writeFileSync as g}from"fs";import{input as s}from"@inquirer/prompts";import{randomUUID as O}from"crypto";import{execSync as $}from"child_process";m.description("Create a new Enpage template").argument("[directory]","Directory to create the template in",".").action(async n=>{let e=i(process.cwd(),n);x(e)?v(e).isDirectory()?U(e)||(console.log(r.red(`Directory ${e} is not empty. Aborting.`)),process.exit(1)):(console.log(r.red(`${e} exists but is not a directory. Aborting.`)),process.exit(1)):(process.stdout.write(`Creating directory ${e}... `),S(e,{recursive:!0}),console.log(r.blue("OK"))),process.stdout.write("Cloning template example... "),await k("enpage/enpage/packages/template-example").clone(e),console.log(r.blue("OK")),console.log(""),console.log("Let's set up your new template:");let d=await s({message:"Enter a template description",validate(t){return t.length>0?!0:"Description cannot be empty"}}),u=await s({message:"Enter the author's name",validate(t){return t.length>0?!0:"Author name cannot be empty"}}),f=await s({message:"Enter tags for the template (optional, comma separated)"}),c=await s({message:"Enter a homepage URL (optional)",validate(t){if(t.length===0)return!0;try{return new URL(t),!0}catch{}return"Homepage URL must start with https://"}}),y={id:O()},h=f.split(",").map(t=>t.trim()),p=i(e,"package.json"),o=JSON.parse(E(p,"utf-8"));for(let t of["dependencies","devDependencies","peerDependencies","optionalDependencies"])if(o[t])for(let[l,w]of Object.entries(o[t]))w.startsWith("workspace:")&&(o[t][l]="latest");o.name=`enpage-template-${b.basename(e)}`,o.enpage=y,o.author=u,o.keywords=[...new Set([...o.keywords,...h])],o.license="UNLICENSED",o.description=d,o.homepage=c.length>0?c:void 0,process.stdout.write("Writing package.json... "),g(p,JSON.stringify(o,null,2)),console.log(r.blue("OK")),console.log("Installing dependencies... ");let a=_();if(a==="pnpm"){let t=i(e,"pnpm-workspace.yaml");g(t,` | ||
`)}$(`${a} install`,{cwd:e}),console.log(r.blue("All done!")),console.log(`You can now develop your template: | ||
`),console.log(r.blue(` cd ${n}`)),console.log(r.blue(` ${a} start`)),console.log(""),process.exit(0)});m.parse();function U(n){return D(n).length===0}function _(){let n;if(process.env.npm_config_user_agent){let e=process.env.npm_config_user_agent.split(" ")[0];n=e.slice(0,e.lastIndexOf("/"))}return n||(console.log("Warning: could not detect package manager"),n="npm"),n} | ||
import v from"degit";import{program as u}from"commander";import{resolve as i}from"path";import k from"path";import r from"chalk";import{existsSync as x,mkdirSync as S,lstatSync as E,readdirSync as D,readFileSync as O,writeFileSync as m}from"fs";import{input as a,select as $}from"@inquirer/prompts";import{execSync as N}from"child_process";u.description("Create a new Enpage template").argument("[directory]","Directory to create the template in",".").action(async n=>{let e=i(process.cwd(),n);x(e)?E(e).isDirectory()?P(e)||(console.log(r.red(`Directory ${e} is not empty. Aborting.`)),process.exit(1)):(console.log(r.red(`${e} exists but is not a directory. Aborting.`)),process.exit(1)):(process.stdout.write(`Creating directory ${e}... `),S(e,{recursive:!0}),console.log(r.blue("OK"))),process.stdout.write("Cloning template example... "),await v("enpage/enpage/packages/template-example",{cache:!1}).clone(e),console.log(r.blue("OK")),console.log(""),console.log("Let's set up your new template:");let d=await a({message:"Name your template",validate(t){return t.length>0?!0:"Name cannot be empty"}}),f=await a({message:"Enter a template description",validate(t){return t.length>0?!0:"Description cannot be empty"}}),y=await a({message:"Enter the author's name",validate(t){return t.length>0?!0:"Author name cannot be empty"}}),c=await $({message:"Choose the visibility of the template",choices:[{name:"Private",value:"private",description:"For your eyes only"},{name:"Public",value:"public",description:"To be available on Enpage (paid or free users)"}]});c==="public"&&console.log(` > You will need to publish your template to make it available on Enpage. | ||
`);let h=await a({message:"Enter tags for the template (optional, comma separated)"}),l=await a({message:"Enter a homepage URL (optional)",validate(t){if(t.length===0)return!0;try{return new URL(t),!0}catch{}return"Homepage URL must start with https://"}}),w=h.split(",").map(t=>t.trim()),p=i(e,"package.json"),o=JSON.parse(O(p,"utf-8"));for(let t of["dependencies","devDependencies","peerDependencies","optionalDependencies"])if(o[t])for(let[g,b]of Object.entries(o[t]))b.startsWith("workspace:")&&(o[t][g]="latest");o.name=`enpage-template-${k.basename(e)}`,o.author=y,o.keywords=[...new Set([...o.keywords,...w])],o.license="UNLICENSED",o.homepage=l.length>0?l:void 0,o.enpage={name:d,description:f},c==="private"&&(o.enpage.private=!0,o.private=!0),process.stdout.write("Writing package.json... "),m(p,JSON.stringify(o,null,2)),console.log(r.blue("OK")),console.log("Installing dependencies... ");let s=_();if(s==="pnpm"){let t=i(e,"pnpm-workspace.yaml");m(t,` | ||
`)}N(`${s} install`,{cwd:e}),console.log(r.blue("All done!")),console.log(`You can now develop your template: | ||
`),console.log(r.blue(` cd ${n}`)),console.log(r.blue(` ${s} start`)),console.log(""),process.exit(0)});u.parse();function P(n){return D(n).length===0}function _(){let n;if(process.env.npm_config_user_agent){let e=process.env.npm_config_user_agent.split(" ")[0];n=e.slice(0,e.lastIndexOf("/"))}return n||(console.log("Warning: could not detect package manager"),n="npm"),n} |
{ | ||
"name": "create-enpage", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "A CLI for creating Enpage templates.", | ||
@@ -17,3 +17,3 @@ "type": "module", | ||
"dependencies": { | ||
"@inquirer/prompts": "5.0.5", | ||
"@inquirer/prompts": "5.3.8", | ||
"chalk": "5.3.0", | ||
@@ -25,3 +25,3 @@ "commander": "12.1.0", | ||
"@types/degit": "2.8.6", | ||
"tsup": "8.0.2" | ||
"tsup": "8.2.4" | ||
}, | ||
@@ -31,4 +31,5 @@ "scripts": { | ||
"build": "tsup", | ||
"lint": "biome check ." | ||
"lint": "biome check .", | ||
"ci:lint": "biome check ." | ||
} | ||
} |
36955
15
+ Added@inquirer/number@1.1.0(transitive)
+ Added@inquirer/prompts@5.3.8(transitive)
+ Added@inquirer/search@1.1.0(transitive)
- Removed@inquirer/prompts@5.0.5(transitive)
Updated@inquirer/prompts@5.3.8