plano-cli 0.0.22 → 0.1.1
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/dist/chunk-YSHKHHP5.js +1 -0
- package/dist/cli/plano.cjs +1 -1
- package/dist/cli/plano.js +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/package.json +10 -10
- package/dist/chunk-TSMFHBY6.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"node:path";import{z as t}from"zod";import{existsSync as r}from"node: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"node:fs";import m from"handlebars";function l({context:e={},helpers:t={},path:r}){return m.compile(i(r,"utf-8"))(e)}import{existsSync as f,readdirSync as c}from"node:fs";import{homedir as h}from"node:os";import{resolve as u}from"node:path";var d="plano";var y=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}};function w({paths:e,type:t}){const r=function(e){switch(e){case"file":return`${h()}/${d}/file-templates`;case"snippet":return`${h()}/${d}/snippet-templates`;default:throw new y([`Unable to get default template path for type: ${e}`])}}(t);return[r,...e].map((e=>u(e))).filter((e=>f(e))).map((e=>c(e,{withFileTypes:!0}).filter((e=>e.isDirectory()&&!e.name.startsWith(".git"))).map((t=>({path:e,template:t.name}))))).flat()}import b from"inquirer";import{sortedUniq as C}from"lodash-es";async function g({paths:e,type:t}){const r=w({paths:e,type:t}),{template:o}=await b.prompt([{name:"template",message:"Select a template",type:"list",choices:C(r.map((({template:e})=>e)))}]);return o}import{mkdirSync as $,writeFileSync as x}from"node:fs";import{resolve as k}from"node:path";import{globSync as v}from"glob";import j from"handlebars";import{camelCase as F}from"lodash-es";import{kebabCase as T}from"lodash-es";import{camelCase as U,upperFirst as q}from"lodash-es";import{snakeCase as O}from"lodash-es";import{snakeCase as S}from"lodash-es";var D={camelCase:function(e){return F(e)},kebabCase:function(e){return T(e)},lowerCase:function(e){return e.toLowerCase()},pascalCase:function(e){return q(U(e))},snakeCase:function(e){return O(e)},upperCase:function(e){return e.toUpperCase()},upperSnakeCase:function(e){return S(e).toUpperCase()}};function E({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:o,template:a}}){Object.entries({...D,...r}).map((([e,t])=>j.registerHelper(e,t)));const s=k(o,a,"template"),p=v(`${s}/**/*`,{withFileTypes:!0});p.forEach((e=>{if(e.isFile()&&!e.name.endsWith(".handlebars"))throw new y(["Template files must end with .handlebars:",e.fullpath()])}));for(let o of p){const a=j.compile(o.fullpath())(t).replace(`${s}/`,"");if(o.isDirectory()&&$(k(e,a)),o.isFile()){const s=l({context:t,helpers:r,path:o.fullpath()});x(k(e,a.replace(".handlebars","")),s)}}}import P from"chalk";import{uniq as W}from"lodash-es";function z({name:e,paths:t,type:r}){const o=w({paths:t,type:r}),a=o.find((t=>t.template===e));if(!a)throw new y([P.red(`Unable to find template "${e}" at paths:`),...W(o.map((e=>e.path)))]);return a}export{s as getContextPrompts,n as promptForContext,l as compileTemplate,w as getAllPaths,g as promptForTemplate,E as generate,z 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,s=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,p=(p,o,i)=>(i=null!=p?e(s(p)):{},((e,s,p,o)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let i of a(s))n.call(e,i)||i===p||t(e,i,{get:()=>s[i],enumerable:!(o=r(s,i))||o.enumerable});return e})(!o&&p&&p.__esModule?i:t(i,"default",{value:p,enumerable:!0}),p)),o=require("commander"),i=require("zod"),l=require("fs"),c=require("path"),u=require("glob"),m=p(require("handlebars"),1);var h=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}},f=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,f.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"),w=p(require("handlebars"),1);function v({context:e={},helpers:t={},path:r}){return w.default.compile((0,g.readFileSync)(r,"utf-8"))(e)}var C=p(require("chalk"),1),j=require("lodash-es")
|
|
2
|
+
"use strict";var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,s=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,p=(p,o,i)=>(i=null!=p?e(s(p)):{},((e,s,p,o)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let i of a(s))n.call(e,i)||i===p||t(e,i,{get:()=>s[i],enumerable:!(o=r(s,i))||o.enumerable});return e})(!o&&p&&p.__esModule?i:t(i,"default",{value:p,enumerable:!0}),p)),o=require("commander"),i=require("zod"),l=require("fs"),c=require("path"),u=require("glob"),m=p(require("handlebars"),1);var h=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}},f=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,f.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"),w=p(require("handlebars"),1);function v({context:e={},helpers:t={},path:r}){return w.default.compile((0,g.readFileSync)(r,"utf-8"))(e)}var C=p(require("chalk"),1),j=require("lodash-es"),O=require("fs"),x=require("os"),$=require("path"),P="plano";function S({paths:e,type:t}){const r=function(e){switch(e){case"file":return`${(0,x.homedir)()}/${P}/file-templates`;case"snippet":return`${(0,x.homedir)()}/${P}/snippet-templates`;default:throw new h([`Unable to get default template path for type: ${e}`])}}(t);return[r,...e].map((e=>(0,$.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()}function k({name:e,paths:t,type:r}){const a=S({paths:t,type:r}),s=a.find((t=>t.template===e));if(!s)throw new h([C.default.red(`Unable to find template "${e}" at paths:`),...(0,j.uniq)(a.map((e=>e.path)))]);return s}var F=p(require("inquirer"),1),U=require("path"),E=require("zod"),T=require("fs"),D=E.z.optional(E.z.array(E.z.object({message:E.z.string(),name:E.z.string(),required:E.z.boolean(),type:E.z.union([E.z.literal("input"),E.z.literal("select")])}))),G=E.z.optional(E.z.record(E.z.function(E.z.tuple([E.z.string()]),E.z.string())));async function L(e){const{prompts:t,helpers:r}=await async function({template:{path:e,template:t}}){const r=(0,U.resolve)(`${e}/${t}`,"context.mjs");if(!(0,T.existsSync)(r))return{prompts:[],helpers:{}};const{prompts:a,helpers:s}=await import(r);return{prompts:D.parse(a)||[],helpers:G.parse(s)||{}}}(e);if(!t)return{context:{},helpers:r};return{context:await F.default.prompt(t)||{},helpers:r}}var W=p(require("inquirer"),1),_=require("lodash-es");async function H({paths:e,type:t}){const r=S({paths:e,type:t}),{template:a}=await W.default.prompt([{name:"template",message:"Select a template",type:"list",choices:(0,_.sortedUniq)(r.map((({template:e})=>e)))}]);return a}var I=new o.Command;I.name("plano").description("CLI to scaffold files and directories from templates").version("0.1.1","-v, --version"),I.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"',[]).action((async(e,t)=>{try{let r=i.z.optional(i.z.string()).parse(e);const{paths:a}=i.z.object({paths:i.z.array(i.z.string())}).parse(t);void 0===r&&(r=await H({paths:a,type:"file"}));const s=k({name:r,paths:a,type:"file"}),{context:n,helpers:p={}}=await L({template:s});!function({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:a,template:s}}){Object.entries({...z,...r}).map((([e,t])=>m.default.registerHelper(e,t)));const n=(0,c.resolve)(a,s,"template"),p=(0,u.globSync)(`${n}/**/*`,{withFileTypes:!0});p.forEach((e=>{if(e.isFile()&&!e.name.endsWith(".handlebars"))throw new h(["Template files must end with .handlebars:",e.fullpath()])}));for(let a of p){const s=m.default.compile(a.fullpath())(t).replace(`${n}/`,"");if(a.isDirectory()&&(0,l.mkdirSync)((0,c.resolve)(e,s)),a.isFile()){const n=v({context:t,helpers:r,path:a.fullpath()});(0,l.writeFileSync)((0,c.resolve)(e,s.replace(".handlebars","")),n)}}}({context:n,helpers:p,template:s})}catch(e){e instanceof Error&&console.log(e.message)}})),I.command("snippet").description("Generate a snippet from a template").argument("[name]","template name").option("-p, --paths <path...>",'Paths to snippets, must be directory named "plano"',[]).action((async(e,t)=>{try{let r=i.z.optional(i.z.string()).parse(e);const{paths:a}=i.z.object({paths:i.z.array(i.z.string())}).parse(t);void 0===r&&(r=await H({paths:a,type:"snippet"}));const s=k({name:r,paths:a,type:"snippet"});process.stdout.write(v({context:{},path:`${s.path}/${s.template}/snippet.handlebars`}))}catch(e){e instanceof Error&&console.log(e.message)}})),I.parse();
|
package/dist/cli/plano.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{compileTemplate as t,generate as e,getTemplate as a,promptForContext as o,promptForTemplate as s}from"../chunk-
|
|
2
|
+
import{compileTemplate as t,generate as e,getTemplate as a,promptForContext as o,promptForTemplate as s}from"../chunk-YSHKHHP5.js";import{Command as p}from"commander";import{z as n}from"zod";var r=new p;r.name("plano").description("CLI to scaffold files and directories from templates").version("0.1.1","-v, --version"),r.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"',[]).action((async(t,p)=>{try{let r=n.optional(n.string()).parse(t);const{paths:i}=n.object({paths:n.array(n.string())}).parse(p);void 0===r&&(r=await s({paths:i,type:"file"}));const m=a({name:r,paths:i,type:"file"}),{context:c,helpers:l={}}=await o({template:m});e({context:c,helpers:l,template:m})}catch(t){t instanceof Error&&console.log(t.message)}})),r.command("snippet").description("Generate a snippet from a template").argument("[name]","template name").option("-p, --paths <path...>",'Paths to snippets, must be directory named "plano"',[]).action((async(e,o)=>{try{let p=n.optional(n.string()).parse(e);const{paths:r}=n.object({paths:n.array(n.string())}).parse(o);void 0===p&&(p=await s({paths:r,type:"snippet"}));const i=a({name:p,paths:r,type:"snippet"});process.stdout.write(t({context:{},path:`${i.path}/${i.template}/snippet.handlebars`}))}catch(t){t instanceof Error&&console.log(t.message)}})),r.parse();
|
package/dist/index.d.cts
CHANGED
|
@@ -7,7 +7,9 @@ interface PromptForContextOptions {
|
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
declare function promptForContext(options: PromptForContextOptions): Promise<{
|
|
10
|
-
context:
|
|
10
|
+
context: {
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
};
|
|
11
13
|
helpers: Record<string, (args_0: string) => string>;
|
|
12
14
|
}>;
|
|
13
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ interface PromptForContextOptions {
|
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
declare function promptForContext(options: PromptForContextOptions): Promise<{
|
|
10
|
-
context:
|
|
10
|
+
context: {
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
};
|
|
11
13
|
helpers: Record<string, (args_0: string) => string>;
|
|
12
14
|
}>;
|
|
13
15
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{compileTemplate as o,generate as r,getAllPaths as
|
|
1
|
+
import{compileTemplate as o,generate as r,getAllPaths as H,getContextPrompts as m,getTemplate as p,promptForContext as t,promptForTemplate as c}from"./chunk-YSHKHHP5.js";export{o as compileTemplate,r as generate,H as getAllPaths,m as getContextPrompts,p as getTemplate,t as promptForContext,c as promptForTemplate};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plano-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/inquirer": "^9.0.7",
|
|
32
32
|
"@types/lodash-es": "^4.17.12",
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"@vitest/coverage-v8": "^1.
|
|
35
|
-
"prettier": "^3.3.
|
|
36
|
-
"terser": "^5.
|
|
37
|
-
"tsup": "^8.
|
|
38
|
-
"typescript": "^5.
|
|
39
|
-
"vitest": "^1.
|
|
33
|
+
"@types/node": "^22.7.7",
|
|
34
|
+
"@vitest/coverage-v8": "^2.1.3",
|
|
35
|
+
"prettier": "^3.3.3",
|
|
36
|
+
"terser": "^5.36.0",
|
|
37
|
+
"tsup": "^8.3.0",
|
|
38
|
+
"typescript": "^5.6.3",
|
|
39
|
+
"vitest": "^2.1.1"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"chalk": "^5.3.0",
|
|
43
43
|
"commander": "^12.1.0",
|
|
44
|
-
"glob": "^
|
|
44
|
+
"glob": "^11.0.0",
|
|
45
45
|
"handlebars": "^4.7.8",
|
|
46
|
-
"inquirer": "^
|
|
46
|
+
"inquirer": "^12.0.0",
|
|
47
47
|
"lodash-es": "^4.17.21",
|
|
48
48
|
"zod": "^3.23.8"
|
|
49
49
|
}
|
package/dist/chunk-TSMFHBY6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{resolve as t}from"path";import{z as e}from"zod";import{existsSync as r}from"fs";var a=e.optional(e.array(e.object({message:e.string(),name:e.string(),required:e.boolean(),type:e.union([e.literal("input"),e.literal("select")])}))),o=e.optional(e.record(e.function(e.tuple([e.string()]),e.string())));async function s({template:{path:e,template:s}}){const p=t(`${e}/${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(t){const{prompts:e,helpers:r}=await s(t);if(!e)return{context:{},helpers:r};return{context:await p.prompt(e)||{},helpers:r}}import{readFileSync as i}from"fs";import m from"handlebars";function l({context:t={},helpers:e={},path:r}){return m.compile(i(r,"utf-8"))(t)}import{existsSync as f,readdirSync as c}from"fs";import{homedir as h}from"os";import{resolve as u}from"path";var d="plano",y="file-templates",w="snippet-templates";var b=class t extends Error{constructor(e){super(function(t){return t.join("\n")}(e)),Object.setPrototypeOf(this,t.prototype)}};function C({paths:t,type:e}){const r=function(t){switch(t){case"file":return`${h()}/${d}/${y}`;case"snippet":return`${h()}/${d}/${w}`;default:throw new b([`Unable to get default template path for type: ${t}`])}}(e);return[r,...t].map((t=>u(t))).filter((t=>f(t))).map((t=>c(t,{withFileTypes:!0}).filter((t=>t.isDirectory()&&!t.name.startsWith(".git"))).map((e=>({path:t,template:e.name}))))).flat()}import $ from"inquirer";import{sortedUniq as g}from"lodash-es";async function x({paths:t,type:e}){const r=C({paths:t,type:e}),{template:a}=await $.prompt([{name:"template",message:"Select a template",type:"list",choices:g(r.map((({template:t})=>t)))}]);return a}import{mkdirSync as k,writeFileSync as v}from"fs";import{resolve as j}from"path";import{globSync as F}from"glob";import T from"handlebars";import{camelCase as U}from"lodash-es";import{kebabCase as q}from"lodash-es";import{camelCase as O,upperFirst as S}from"lodash-es";import{snakeCase as D}from"lodash-es";import{snakeCase as E}from"lodash-es";var P={camelCase:function(t){return U(t)},kebabCase:function(t){return q(t)},lowerCase:function(t){return t.toLowerCase()},pascalCase:function(t){return S(O(t))},snakeCase:function(t){return D(t)},upperCase:function(t){return t.toUpperCase()},upperSnakeCase:function(t){return E(t).toUpperCase()}};function W({copyToPath:t=process.cwd(),context:e={},helpers:r={},template:{path:a,template:o}}){Object.entries({...P,...r}).map((([t,e])=>T.registerHelper(t,e)));const s=j(a,o,"template"),p=F(`${s}/**/*`,{withFileTypes:!0});p.forEach((t=>{if(t.isFile()&&!t.name.endsWith(".handlebars"))throw new b(["Template files must end with .handlebars:",t.fullpath()])}));for(let a of p){const o=T.compile(a.fullpath())(e).replace(`${s}/`,"");if(a.isDirectory()&&k(j(t,o)),a.isFile()){const s=l({context:e,helpers:r,path:a.fullpath()});v(j(t,o.replace(".handlebars","")),s)}}}import z from"chalk";import{uniq as H}from"lodash-es";function L({name:t,paths:e,type:r}){const a=C({paths:e,type:r}),o=a.find((e=>e.template===t));if(!o)throw new b([z.red(`Unable to find template "${t}" at paths:`),...H(a.map((t=>t.path)))]);return o}export{s as getContextPrompts,n as promptForContext,l as compileTemplate,C as getAllPaths,x as promptForTemplate,W as generate,L as getTemplate};
|