plano-cli 0.0.16 → 0.0.17

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.
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,s=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,o=(o,i,p)=>(p=null!=o?e(s(o)):{},((e,s,o,i)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let p of a(s))n.call(e,p)||p===o||t(e,p,{get:()=>s[p],enumerable:!(i=r(s,p))||i.enumerable});return e})(!i&&o&&o.__esModule?p:t(p,"default",{value:o,enumerable:!0}),o)),i=require("commander"),p=require("zod"),l=require("fs"),c=require("path"),u=require("glob"),m=o(require("handlebars"),1);var f=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}},h=require("lodash-es");var d=require("lodash-es");var y=require("lodash-es");var b=require("lodash-es");var q=require("lodash-es");var z={camelCase:function(e){return(0,h.camelCase)(e)},kebabCase:function(e){return(0,d.kebabCase)(e)},lowerCase:function(e){return e.toLowerCase()},pascalCase:function(e){return(0,y.upperFirst)((0,y.camelCase)(e))},snakeCase:function(e){return(0,b.snakeCase)(e)},upperCase:function(e){return e.toUpperCase()},upperSnakeCase:function(e){return(0,q.snakeCase)(e).toUpperCase()}};Object.entries(z).map((([e,t])=>m.default.registerHelper(e,t)));var g=o(require("chalk"),1),v=require("lodash-es"),w=require("fs"),C=require("os"),j=require("path"),O="plano-templates";function x(e){return[`${(0,C.homedir)()}/${O}`,...e].map((e=>(0,j.resolve)(e))).filter((e=>(0,w.existsSync)(e))).map((e=>(0,w.readdirSync)(e,{withFileTypes:!0}).filter((e=>e.isDirectory()&&!e.name.startsWith(".git"))).map((t=>({path:e,template:t.name}))))).flat()}var S=o(require("inquirer"),1),k=require("path"),P=require("zod"),F=require("fs"),$=P.z.optional(P.z.array(P.z.object({message:P.z.string(),name:P.z.string(),required:P.z.boolean(),type:P.z.union([P.z.literal("input"),P.z.literal("select")])}))),T=P.z.optional(P.z.record(P.z.function(P.z.tuple([P.z.string()]),P.z.string())));async function U(e){const{prompts:t,helpers:r}=await async function({template:{path:e,template:t}}){const r=(0,k.resolve)(`${e}/${t}`,"context.mjs");if(!(0,F.existsSync)(r))return{prompts:[],helpers:{}};const{prompts:a,helpers:s}=await import(r);return{prompts:$.parse(a)||[],helpers:T.parse(s)||{}}}(e);if(!t)return{context:{},helpers:r};return{context:await S.default.prompt(t)||{},helpers:r}}var D=o(require("inquirer"),1),E=require("lodash-es");var H=new i.Command;H.name("plano").description("CLI to scaffold files and directories from templates").version("0.0.16","-v, --version"),H.command("generate").description("Generate files or directories from a template").argument("[name]","template name").option("-p, --paths <path...>",'Paths to templates, must be directory named "plano-templates"',[]).action((async(e,t)=>{try{let r=p.z.optional(p.z.string()).parse(e);const{paths:a}=p.z.object({paths:p.z.array(p.z.string())}).parse(t);void 0===r&&(r=await async function(e){const t=x(e),{template:r}=await D.default.prompt([{name:"template",message:"Select a template",type:"list",choices:(0,E.sortedUniq)(t.map((({template:e})=>e)))}]);return r}(a));const s=function({name:e,paths:t}){const r=x(t),a=r.find((t=>t.template===e));if(!a)throw new f([g.default.red(`Unable to find template "${e}" at paths:`),...(0,v.uniq)(r.map((e=>e.path)))]);return a}({name:r,paths:a}),{context:n,helpers:o={}}=await U({template:s});!function({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:a,template:s}}){Object.entries(r).map((([e,t])=>m.default.registerHelper(e,t)));const n=(0,c.resolve)(a,s,"template"),o=(0,u.globSync)(`${n}/**/*`,{withFileTypes:!0});o.forEach((e=>{if(e.isFile()&&!e.name.endsWith(".handlebars"))throw new f(["Template files must end with .handlebars:",e.fullpath()])}));for(let r of o){const a=m.default.compile(r.fullpath())(t).replace(`${n}/`,"");if(r.isDirectory()&&(0,l.mkdirSync)((0,c.resolve)(e,a)),r.isFile()){const s=m.default.compile((0,l.readFileSync)(r.fullpath(),"utf-8"))(t);(0,l.writeFileSync)((0,c.resolve)(e,a.replace(".handlebars","")),s)}}}({context:n,helpers:o,template:s})}catch(e){e instanceof Error&&console.log(e.message)}})),H.parse();
2
+ "use strict";var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,s=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,o=(o,i,p)=>(p=null!=o?e(s(o)):{},((e,s,o,i)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let p of a(s))n.call(e,p)||p===o||t(e,p,{get:()=>s[p],enumerable:!(i=r(s,p))||i.enumerable});return e})(!i&&o&&o.__esModule?p:t(p,"default",{value:o,enumerable:!0}),o)),i=require("commander"),p=require("zod"),l=require("fs"),c=require("path"),u=require("glob"),m=o(require("handlebars"),1);var f=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}},h=require("lodash-es");var d=require("lodash-es");var y=require("lodash-es");var b=require("lodash-es");var q=require("lodash-es");var z={camelCase:function(e){return(0,h.camelCase)(e)},kebabCase:function(e){return(0,d.kebabCase)(e)},lowerCase:function(e){return e.toLowerCase()},pascalCase:function(e){return(0,y.upperFirst)((0,y.camelCase)(e))},snakeCase:function(e){return(0,b.snakeCase)(e)},upperCase:function(e){return e.toUpperCase()},upperSnakeCase:function(e){return(0,q.snakeCase)(e).toUpperCase()}};Object.entries(z).map((([e,t])=>m.default.registerHelper(e,t)));var g=o(require("chalk"),1),v=require("lodash-es"),w=require("fs"),C=require("os"),j=require("path"),O="plano-templates";function x(e){return[`${(0,C.homedir)()}/${O}`,...e].map((e=>(0,j.resolve)(e))).filter((e=>(0,w.existsSync)(e))).map((e=>(0,w.readdirSync)(e,{withFileTypes:!0}).filter((e=>e.isDirectory()&&!e.name.startsWith(".git"))).map((t=>({path:e,template:t.name}))))).flat()}var S=o(require("inquirer"),1),k=require("path"),P=require("zod"),F=require("fs"),$=P.z.optional(P.z.array(P.z.object({message:P.z.string(),name:P.z.string(),required:P.z.boolean(),type:P.z.union([P.z.literal("input"),P.z.literal("select")])}))),T=P.z.optional(P.z.record(P.z.function(P.z.tuple([P.z.string()]),P.z.string())));async function U(e){const{prompts:t,helpers:r}=await async function({template:{path:e,template:t}}){const r=(0,k.resolve)(`${e}/${t}`,"context.mjs");if(!(0,F.existsSync)(r))return{prompts:[],helpers:{}};const{prompts:a,helpers:s}=await import(r);return{prompts:$.parse(a)||[],helpers:T.parse(s)||{}}}(e);if(!t)return{context:{},helpers:r};return{context:await S.default.prompt(t)||{},helpers:r}}var D=o(require("inquirer"),1),E=require("lodash-es");var H=new i.Command;H.name("plano").description("CLI to scaffold files and directories from templates").version("0.0.17","-v, --version"),H.command("generate").description("Generate files or directories from a template").argument("[name]","template name").option("-p, --paths <path...>",'Paths to templates, must be directory named "plano-templates"',[]).action((async(e,t)=>{try{let r=p.z.optional(p.z.string()).parse(e);const{paths:a}=p.z.object({paths:p.z.array(p.z.string())}).parse(t);void 0===r&&(r=await async function(e){const t=x(e),{template:r}=await D.default.prompt([{name:"template",message:"Select a template",type:"list",choices:(0,E.sortedUniq)(t.map((({template:e})=>e)))}]);return r}(a));const s=function({name:e,paths:t}){const r=x(t),a=r.find((t=>t.template===e));if(!a)throw new f([g.default.red(`Unable to find template "${e}" at paths:`),...(0,v.uniq)(r.map((e=>e.path)))]);return a}({name:r,paths:a}),{context:n,helpers:o={}}=await U({template:s});!function({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:a,template:s}}){Object.entries(r).map((([e,t])=>m.default.registerHelper(e,t)));const n=(0,c.resolve)(a,s,"template"),o=(0,u.globSync)(`${n}/**/*`,{withFileTypes:!0});o.forEach((e=>{if(e.isFile()&&!e.name.endsWith(".handlebars"))throw new f(["Template files must end with .handlebars:",e.fullpath()])}));for(let r of o){const a=m.default.compile(r.fullpath())(t).replace(`${n}/`,"");if(r.isDirectory()&&(0,l.mkdirSync)((0,c.resolve)(e,a)),r.isFile()){const s=m.default.compile((0,l.readFileSync)(r.fullpath(),"utf-8"))(t);(0,l.writeFileSync)((0,c.resolve)(e,a.replace(".handlebars","")),s)}}}({context:n,helpers:o,template:s})}catch(e){e instanceof Error&&console.log(e.message)}})),H.parse();
package/dist/cli/plano.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{generate as e,getTemplate as t,promptForContext as a,promptForTemplate as o}from"../chunk-SQ2YSPC5.js";import{Command as r}from"commander";import{z as s}from"zod";var n=new r;n.name("plano").description("CLI to scaffold files and directories from templates").version("0.0.16","-v, --version"),n.command("generate").description("Generate files or directories from a template").argument("[name]","template name").option("-p, --paths <path...>",'Paths to templates, must be directory named "plano-templates"',[]).action((async(r,n)=>{try{let m=s.optional(s.string()).parse(r);const{paths:p}=s.object({paths:s.array(s.string())}).parse(n);void 0===m&&(m=await o(p));const i=t({name:m,paths:p}),{context:c,helpers:l={}}=await a({template:i});e({context:c,helpers:l,template:i})}catch(e){e instanceof Error&&console.log(e.message)}})),n.parse();
2
+ import{generate as e,getTemplate as t,promptForContext as a,promptForTemplate as o}from"../chunk-SQ2YSPC5.js";import{Command as r}from"commander";import{z as s}from"zod";var n=new r;n.name("plano").description("CLI to scaffold files and directories from templates").version("0.0.17","-v, --version"),n.command("generate").description("Generate files or directories from a template").argument("[name]","template name").option("-p, --paths <path...>",'Paths to templates, must be directory named "plano-templates"',[]).action((async(r,n)=>{try{let m=s.optional(s.string()).parse(r);const{paths:p}=s.object({paths:s.array(s.string())}).parse(n);void 0===m&&(m=await o(p));const i=t({name:m,paths:p}),{context:c,helpers:l={}}=await a({template:i});e({context:c,helpers:l,template:i})}catch(e){e instanceof Error&&console.log(e.message)}})),n.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plano-cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -11,6 +11,8 @@
11
11
  "plano": "./dist/cli/plano.js"
12
12
  },
13
13
  "type": "module",
14
+ "types": "./dist/index.d.ts",
15
+ "main": "./dist/index.js",
14
16
  "exports": {
15
17
  ".": {
16
18
  "types": "./dist/index.d.ts",