plano-cli 0.0.16 → 0.0.18
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.
- package/LICENSE +21 -0
- package/dist/chunk-OPEC5HIS.js +1 -0
- package/dist/cli/plano.cjs +1 -1
- package/dist/cli/plano.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/package.json +4 -1
- package/dist/chunk-SQ2YSPC5.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Matthew Wolfe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"path";import{z as t}from"zod";import{existsSync as r}from"fs";var o=t.optional(t.array(t.object({message:t.string(),name:t.string(),required:t.boolean(),type:t.union([t.literal("input"),t.literal("select")])}))),a=t.optional(t.record(t.function(t.tuple([t.string()]),t.string())));async function s({template:{path:t,template:s}}){const p=e(`${t}/${s}`,"context.mjs");if(!r(p))return{prompts:[],helpers:{}};const{prompts:n,helpers:i}=await import(p);return{prompts:o.parse(n)||[],helpers:a.parse(i)||{}}}import p from"inquirer";async function n(e){const{prompts:t,helpers:r}=await s(e);if(!t)return{context:{},helpers:r};return{context:await p.prompt(t)||{},helpers:r}}import{readFileSync as i}from"fs";import m from"handlebars";function l({context:e={},path:t}){return m.compile(i(t,"utf-8"))(e)}import{existsSync as c,readdirSync as f}from"fs";import{homedir as u}from"os";import{resolve as h}from"path";var d="plano-templates";function b(e){return[`${u()}/${d}`,...e].map((e=>h(e))).filter((e=>c(e))).map((e=>f(e,{withFileTypes:!0}).filter((e=>e.isDirectory()&&!e.name.startsWith(".git"))).map((t=>({path:e,template:t.name}))))).flat()}import C from"inquirer";import{sortedUniq as w}from"lodash-es";async function y(e){const t=b(e),{template:r}=await C.prompt([{name:"template",message:"Select a template",type:"list",choices:w(t.map((({template:e})=>e)))}]);return r}import{mkdirSync as g,writeFileSync as x}from"fs";import{resolve as k}from"path";import{globSync as $}from"glob";import j from"handlebars";var v=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}};import{camelCase as F}from"lodash-es";import{kebabCase as O}from"lodash-es";import{camelCase as T,upperFirst as q}from"lodash-es";import{snakeCase as S}from"lodash-es";import{snakeCase as U}from"lodash-es";var D={camelCase:function(e){return F(e)},kebabCase:function(e){return O(e)},lowerCase:function(e){return e.toLowerCase()},pascalCase:function(e){return q(T(e))},snakeCase:function(e){return S(e)},upperCase:function(e){return e.toUpperCase()},upperSnakeCase:function(e){return U(e).toUpperCase()}};function E({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:o,template:a}}){Object.entries(r).map((([e,t])=>j.registerHelper(e,t)));const s=k(o,a,"template"),p=$(`${s}/**/*`,{withFileTypes:!0});p.forEach((e=>{if(e.isFile()&&!e.name.endsWith(".handlebars"))throw new v(["Template files must end with .handlebars:",e.fullpath()])}));for(let r of p){const o=j.compile(r.fullpath())(t).replace(`${s}/`,"");if(r.isDirectory()&&g(k(e,o)),r.isFile()){const a=l({context:t,path:r.fullpath()});x(k(e,o.replace(".handlebars","")),a)}}}Object.entries(D).map((([e,t])=>j.registerHelper(e,t)));import H from"chalk";import{uniq as P}from"lodash-es";function W({name:e,paths:t}){const r=b(t),o=r.find((t=>t.template===e));if(!o)throw new v([H.red(`Unable to find template "${e}" at paths:`),...P(r.map((e=>e.path)))]);return o}export{s as getContextPrompts,n as promptForContext,l as compileTemplate,b as getAllPaths,y as promptForTemplate,E as generate,W as getTemplate};
|
package/dist/cli/plano.cjs
CHANGED
|
@@ -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,
|
|
2
|
+
"use strict";var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(o,i,p)=>(p=null!=o?e(n(o)):{},((e,n,o,i)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let p of a(n))s.call(e,p)||p===o||t(e,p,{get:()=>n[p],enumerable:!(i=r(n,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()}},g=require("fs"),v=o(require("handlebars"),1);function w({context:e={},path:t}){return v.default.compile((0,g.readFileSync)(t,"utf-8"))(e)}Object.entries(z).map((([e,t])=>m.default.registerHelper(e,t)));var C=o(require("chalk"),1),j=require("lodash-es"),O=require("fs"),x=require("os"),S=require("path"),k="plano-templates";function P(e){return[`${(0,x.homedir)()}/${k}`,...e].map((e=>(0,S.resolve)(e))).filter((e=>(0,O.existsSync)(e))).map((e=>(0,O.readdirSync)(e,{withFileTypes:!0}).filter((e=>e.isDirectory()&&!e.name.startsWith(".git"))).map((t=>({path:e,template:t.name}))))).flat()}var F=o(require("inquirer"),1),$=require("path"),T=require("zod"),U=require("fs"),D=T.z.optional(T.z.array(T.z.object({message:T.z.string(),name:T.z.string(),required:T.z.boolean(),type:T.z.union([T.z.literal("input"),T.z.literal("select")])}))),E=T.z.optional(T.z.record(T.z.function(T.z.tuple([T.z.string()]),T.z.string())));async function H(e){const{prompts:t,helpers:r}=await async function({template:{path:e,template:t}}){const r=(0,$.resolve)(`${e}/${t}`,"context.mjs");if(!(0,U.existsSync)(r))return{prompts:[],helpers:{}};const{prompts:a,helpers:n}=await import(r);return{prompts:D.parse(a)||[],helpers:E.parse(n)||{}}}(e);if(!t)return{context:{},helpers:r};return{context:await F.default.prompt(t)||{},helpers:r}}var L=o(require("inquirer"),1),W=require("lodash-es");var _=new i.Command;_.name("plano").description("CLI to scaffold files and directories from templates").version("0.0.18","-v, --version"),_.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=P(e),{template:r}=await L.default.prompt([{name:"template",message:"Select a template",type:"list",choices:(0,W.sortedUniq)(t.map((({template:e})=>e)))}]);return r}(a));const n=function({name:e,paths:t}){const r=P(t),a=r.find((t=>t.template===e));if(!a)throw new f([C.default.red(`Unable to find template "${e}" at paths:`),...(0,j.uniq)(r.map((e=>e.path)))]);return a}({name:r,paths:a}),{context:s,helpers:o={}}=await H({template:n});!function({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:a,template:n}}){Object.entries(r).map((([e,t])=>m.default.registerHelper(e,t)));const s=(0,c.resolve)(a,n,"template"),o=(0,u.globSync)(`${s}/**/*`,{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(`${s}/`,"");if(r.isDirectory()&&(0,l.mkdirSync)((0,c.resolve)(e,a)),r.isFile()){const n=w({context:t,path:r.fullpath()});(0,l.writeFileSync)((0,c.resolve)(e,a.replace(".handlebars","")),n)}}}({context:s,helpers:o,template:n})}catch(e){e instanceof Error&&console.log(e.message)}})),_.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-
|
|
2
|
+
import{generate as e,getTemplate as t,promptForContext as a,promptForTemplate as o}from"../chunk-OPEC5HIS.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.18","-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/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.create,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,i=(e,t,s,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of n(t))o.call(e,l)||l===s||r(e,l,{get:()=>t[l],enumerable:!(i=a(t,l))||i.enumerable});return e},l=(e,a,n)=>(n=null!=e?t(s(e)):{},i(!a&&e&&e.__esModule?n:r(n,"default",{value:e,enumerable:!0}),e)),p={};((e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})})(p,{generate:()=>
|
|
1
|
+
"use strict";var e,t=Object.create,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,i=(e,t,s,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of n(t))o.call(e,l)||l===s||r(e,l,{get:()=>t[l],enumerable:!(i=a(t,l))||i.enumerable});return e},l=(e,a,n)=>(n=null!=e?t(s(e)):{},i(!a&&e&&e.__esModule?n:r(n,"default",{value:e,enumerable:!0}),e)),p={};((e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})})(p,{compileTemplate:()=>v,generate:()=>A,getAllPaths:()=>F,getContextPrompts:()=>b,getTemplate:()=>B,promptForContext:()=>y,promptForTemplate:()=>P}),module.exports=(e=p,i(r({},"__esModule",{value:!0}),e));var u=l(require("inquirer"),1),c=require("path"),m=require("zod"),f=require("fs"),h=m.z.optional(m.z.array(m.z.object({message:m.z.string(),name:m.z.string(),required:m.z.boolean(),type:m.z.union([m.z.literal("input"),m.z.literal("select")])}))),d=m.z.optional(m.z.record(m.z.function(m.z.tuple([m.z.string()]),m.z.string())));async function b({template:{path:e,template:t}}){const r=(0,c.resolve)(`${e}/${t}`,"context.mjs");if(!(0,f.existsSync)(r))return{prompts:[],helpers:{}};const{prompts:a,helpers:n}=await import(r);return{prompts:h.parse(a)||[],helpers:d.parse(n)||{}}}async function y(e){const{prompts:t,helpers:r}=await b(e);if(!t)return{context:{},helpers:r};return{context:await u.default.prompt(t)||{},helpers:r}}var q=require("fs"),g=l(require("handlebars"),1);function v({context:e={},path:t}){return g.default.compile((0,q.readFileSync)(t,"utf-8"))(e)}var w=l(require("inquirer"),1),C=require("lodash-es"),z=require("fs"),O=require("os"),j=require("path"),x="plano-templates";function F(e){return[`${(0,O.homedir)()}/${x}`,...e].map((e=>(0,j.resolve)(e))).filter((e=>(0,z.existsSync)(e))).map((e=>(0,z.readdirSync)(e,{withFileTypes:!0}).filter((e=>e.isDirectory()&&!e.name.startsWith(".git"))).map((t=>({path:e,template:t.name}))))).flat()}async function P(e){const t=F(e),{template:r}=await w.default.prompt([{name:"template",message:"Select a template",type:"list",choices:(0,C.sortedUniq)(t.map((({template:e})=>e)))}]);return r}var S=require("fs"),k=require("path"),T=require("glob"),$=l(require("handlebars"),1);var U=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}},_=require("lodash-es");var D=require("lodash-es");var E=require("lodash-es");var H=require("lodash-es");var M=require("lodash-es");var W={camelCase:function(e){return(0,_.camelCase)(e)},kebabCase:function(e){return(0,D.kebabCase)(e)},lowerCase:function(e){return e.toLowerCase()},pascalCase:function(e){return(0,E.upperFirst)((0,E.camelCase)(e))},snakeCase:function(e){return(0,H.snakeCase)(e)},upperCase:function(e){return e.toUpperCase()},upperSnakeCase:function(e){return(0,M.snakeCase)(e).toUpperCase()}};function A({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:a,template:n}}){Object.entries(r).map((([e,t])=>$.default.registerHelper(e,t)));const s=(0,k.resolve)(a,n,"template"),o=(0,T.globSync)(`${s}/**/*`,{withFileTypes:!0});o.forEach((e=>{if(e.isFile()&&!e.name.endsWith(".handlebars"))throw new U(["Template files must end with .handlebars:",e.fullpath()])}));for(let r of o){const a=$.default.compile(r.fullpath())(t).replace(`${s}/`,"");if(r.isDirectory()&&(0,S.mkdirSync)((0,k.resolve)(e,a)),r.isFile()){const n=v({context:t,path:r.fullpath()});(0,S.writeFileSync)((0,k.resolve)(e,a.replace(".handlebars","")),n)}}}Object.entries(W).map((([e,t])=>$.default.registerHelper(e,t)));var L=l(require("chalk"),1),N=require("lodash-es");function B({name:e,paths:t}){const r=F(t),a=r.find((t=>t.template===e));if(!a)throw new U([L.default.red(`Unable to find template "${e}" at paths:`),...(0,N.uniq)(r.map((e=>e.path)))]);return a}
|
package/dist/index.d.cts
CHANGED
|
@@ -27,6 +27,12 @@ declare function getContextPrompts({ template: { path, template }, }: GetContext
|
|
|
27
27
|
helpers: Record<string, (args_0: string) => string>;
|
|
28
28
|
}>;
|
|
29
29
|
|
|
30
|
+
interface CompileTemplate {
|
|
31
|
+
context?: Record<string, unknown>;
|
|
32
|
+
path: string;
|
|
33
|
+
}
|
|
34
|
+
declare function compileTemplate({ context, path }: CompileTemplate): string;
|
|
35
|
+
|
|
30
36
|
/**
|
|
31
37
|
* Prompt which template should be used for generation.
|
|
32
38
|
*
|
|
@@ -60,4 +66,4 @@ declare function getTemplate({ name, paths }: GetTemplateOptions): {
|
|
|
60
66
|
template: string;
|
|
61
67
|
};
|
|
62
68
|
|
|
63
|
-
export { generate, getAllPaths, getContextPrompts, getTemplate, promptForContext, promptForTemplate };
|
|
69
|
+
export { compileTemplate, generate, getAllPaths, getContextPrompts, getTemplate, promptForContext, promptForTemplate };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ declare function getContextPrompts({ template: { path, template }, }: GetContext
|
|
|
27
27
|
helpers: Record<string, (args_0: string) => string>;
|
|
28
28
|
}>;
|
|
29
29
|
|
|
30
|
+
interface CompileTemplate {
|
|
31
|
+
context?: Record<string, unknown>;
|
|
32
|
+
path: string;
|
|
33
|
+
}
|
|
34
|
+
declare function compileTemplate({ context, path }: CompileTemplate): string;
|
|
35
|
+
|
|
30
36
|
/**
|
|
31
37
|
* Prompt which template should be used for generation.
|
|
32
38
|
*
|
|
@@ -60,4 +66,4 @@ declare function getTemplate({ name, paths }: GetTemplateOptions): {
|
|
|
60
66
|
template: string;
|
|
61
67
|
};
|
|
62
68
|
|
|
63
|
-
export { generate, getAllPaths, getContextPrompts, getTemplate, promptForContext, promptForTemplate };
|
|
69
|
+
export { compileTemplate, generate, getAllPaths, getContextPrompts, getTemplate, promptForContext, promptForTemplate };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{compileTemplate as o,generate as r,getAllPaths as m,getContextPrompts as p,getTemplate as t,promptForContext as c,promptForTemplate as e}from"./chunk-OPEC5HIS.js";export{o as compileTemplate,r as generate,m as getAllPaths,p as getContextPrompts,t as getTemplate,c as promptForContext,e as promptForTemplate};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plano-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
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",
|
|
@@ -30,6 +32,7 @@
|
|
|
30
32
|
"@types/lodash-es": "^4.17.12",
|
|
31
33
|
"@types/node": "^20.10.5",
|
|
32
34
|
"@vitest/coverage-v8": "^1.1.0",
|
|
35
|
+
"prettier": "^3.2.2",
|
|
33
36
|
"terser": "^5.26.0",
|
|
34
37
|
"tsup": "^8.0.1",
|
|
35
38
|
"typedoc": "^0.25.4",
|
package/dist/chunk-SQ2YSPC5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{resolve as e}from"path";import{z as t}from"zod";import{existsSync as r}from"fs";var a=t.optional(t.array(t.object({message:t.string(),name:t.string(),required:t.boolean(),type:t.union([t.literal("input"),t.literal("select")])}))),o=t.optional(t.record(t.function(t.tuple([t.string()]),t.string())));async function s({template:{path:t,template:s}}){const p=e(`${t}/${s}`,"context.mjs");if(!r(p))return{prompts:[],helpers:{}};const{prompts:n,helpers:i}=await import(p);return{prompts:a.parse(n)||[],helpers:o.parse(i)||{}}}import p from"inquirer";async function n(e){const{prompts:t,helpers:r}=await s(e);if(!t)return{context:{},helpers:r};return{context:await p.prompt(t)||{},helpers:r}}import{existsSync as i,readdirSync as m}from"fs";import{homedir as l}from"os";import{resolve as c}from"path";var f="plano-templates";function u(e){return[`${l()}/${f}`,...e].map((e=>c(e))).filter((e=>i(e))).map((e=>m(e,{withFileTypes:!0}).filter((e=>e.isDirectory()&&!e.name.startsWith(".git"))).map((t=>({path:e,template:t.name}))))).flat()}import h from"inquirer";import{sortedUniq as d}from"lodash-es";async function b(e){const t=u(e),{template:r}=await h.prompt([{name:"template",message:"Select a template",type:"list",choices:d(t.map((({template:e})=>e)))}]);return r}import{mkdirSync as C,readFileSync as w,writeFileSync as y}from"fs";import{resolve as g}from"path";import{globSync as k}from"glob";import x from"handlebars";var $=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}};import{camelCase as j}from"lodash-es";import{kebabCase as v}from"lodash-es";import{camelCase as F,upperFirst as O}from"lodash-es";import{snakeCase as T}from"lodash-es";import{snakeCase as q}from"lodash-es";var S={camelCase:function(e){return j(e)},kebabCase:function(e){return v(e)},lowerCase:function(e){return e.toLowerCase()},pascalCase:function(e){return O(F(e))},snakeCase:function(e){return T(e)},upperCase:function(e){return e.toUpperCase()},upperSnakeCase:function(e){return q(e).toUpperCase()}};function U({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:a,template:o}}){Object.entries(r).map((([e,t])=>x.registerHelper(e,t)));const s=g(a,o,"template"),p=k(`${s}/**/*`,{withFileTypes:!0});p.forEach((e=>{if(e.isFile()&&!e.name.endsWith(".handlebars"))throw new $(["Template files must end with .handlebars:",e.fullpath()])}));for(let r of p){const a=x.compile(r.fullpath())(t).replace(`${s}/`,"");if(r.isDirectory()&&C(g(e,a)),r.isFile()){const o=x.compile(w(r.fullpath(),"utf-8"))(t);y(g(e,a.replace(".handlebars","")),o)}}}Object.entries(S).map((([e,t])=>x.registerHelper(e,t)));import D from"chalk";import{uniq as E}from"lodash-es";function H({name:e,paths:t}){const r=u(t),a=r.find((t=>t.template===e));if(!a)throw new $([D.red(`Unable to find template "${e}" at paths:`),...E(r.map((e=>e.path)))]);return a}export{s as getContextPrompts,n as promptForContext,u as getAllPaths,b as promptForTemplate,U as generate,H as getTemplate};
|