plano-cli 0.6.0 → 0.8.0

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.
@@ -0,0 +1 @@
1
+ import{checkbox as e,input as t,select as r}from"@inquirer/prompts";async function a({helpers:a={},prompts:o}){if(!o||!Array.isArray(o))return{context:{},helpers:a};const s={};for(let a=0;a<o.length;a++){const p=o[a];switch(p.type){case"checkbox":s[p.name]=await e(p);break;case"input":s[p.name]=await t(p);break;case"select":s[p.name]=await r(p)}}return{context:s,helpers:a}}import{resolve as o}from"path";import{z as s}from"zod";import{existsSync as p}from"fs";import{z as n}from"zod";import{z as i}from"zod";var m=i.object({message:i.string(),name:i.string(),required:i.boolean()}),l=n.object({value:n.string()}).passthrough(),c=m.extend({type:n.literal("checkbox"),choices:n.array(l)}).passthrough();import{z as f}from"zod";var h=m.extend({type:f.literal("input")}).passthrough();import{z as u}from"zod";var d=u.object({value:u.string()}).passthrough(),y=m.extend({type:u.literal("select"),choices:u.array(d)}).passthrough(),b=s.optional(s.array(s.discriminatedUnion("type",[c,h,y]))),g=s.optional(s.record(s.string(),s.function({input:s.tuple([s.string()]),output:s.string()})));async function w({template:{path:e,template:t}}){const r=o(`${e}/${t}`,"context.mjs");if(!p(r))return{prompts:[],helpers:{}};let{prompts:a,helpers:s}=await import(r);return{prompts:b.parse(a)||[],helpers:g.parse(s)||{}}}import{readFileSync as C}from"fs";import x from"handlebars";function k({context:e={},helpers:t={},path:r}){return x.compile(C(r,"utf-8"))(e)}import{existsSync as v,readdirSync as $}from"fs";import{homedir as z}from"os";import{resolve as j}from"path";var D="plano";var P=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}};function U({includeDefaultPath:e=!0,paths:t,type:r}){const a=[];return e&&a.push(function(e){switch(e){case"file":return`${z()}/${D}/file-templates`;case"snippet":return`${z()}/${D}/snippet-templates`;default:throw new P([`Unable to get default template path for type: ${e}`])}}(r)),[...a,...t].map(e=>j(e)).filter(e=>v(e)).map(e=>$(e,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.name.startsWith(".git")).map(t=>({path:e,template:t.name}))).flat()}import{select as q}from"@inquirer/prompts";import{sortedUniq as F}from"lodash-es";async function O({includeDefaultPath:e,paths:t,type:r}){const a=U({includeDefaultPath:e,paths:t,type:r});return await q({message:"Select a template",choices:F(a.map(({template:e})=>({value:e})))})}import{mkdirSync as S,writeFileSync as T,copyFileSync as A}from"fs";import{resolve as W}from"path";import{globSync as E}from"glob";import H from"handlebars";import{camelCase as L}from"lodash-es";import{kebabCase as B}from"lodash-es";import{camelCase as G,upperFirst as I}from"lodash-es";import{snakeCase as J}from"lodash-es";import{snakeCase as K}from"lodash-es";var M={camelCase:function(e){return L(e)},kebabCase:function(e){return B(e)},lowerCase:function(e){return e.toLowerCase()},pascalCase:function(e){return I(G(e))},snakeCase:function(e){return J(e)},upperCase:function(e){return e.toUpperCase()},upperSnakeCase:function(e){return K(e).toUpperCase()}};function N({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:a,template:o}}){Object.entries({...M,...r}).map(([e,t])=>H.registerHelper(e,t));const s=W(a,o,"template"),p=E(`${s}/**/*`,{withFileTypes:!0,dot:!0});for(let a of p){const o=a.fullpath(),p=H.compile(o)(t).replace(`${s}/`,"");if(a.isDirectory()&&S(W(e,p)),a.isFile())if(a.name.endsWith(".handlebars")){const a=k({context:t,helpers:r,path:o});T(W(e,p.replace(".handlebars","")),a)}else A(o,W(e,p))}}import Q from"chalk";import{uniq as R}from"lodash-es";function V({name:e,paths:t,type:r}){const a=U({paths:t,type:r}),o=a.find(t=>t.template===e);if(!o)throw new P([Q.red(`Unable to find template "${e}" at paths:`),...R(a.map(e=>e.path))]);return o}export{a as promptForContext,w as getContextPrompts,k as compileTemplate,U as getAllPaths,O as promptForTemplate,N as generate,V as getTemplate};
package/dist/cli/plano.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{compileTemplate as t,generate as e,getContextPrompts as a,getTemplate as p,promptForContext as s,promptForTemplate as o}from"../chunk-HFRGLULM.js";import{Command as n}from"commander";import{z as r}from"zod";var i=new n;i.name("plano").description("CLI to scaffold files and directories from templates").version("0.6.0","-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(t,n)=>{try{let i=r.optional(r.string()).parse(t);const{paths:m}=r.object({paths:r.array(r.string())}).parse(n);void 0===i&&(i=await o({paths:m,type:"file"}));const c=p({name:i,paths:m,type:"file"}),{helpers:l,prompts:h}=await a({template:c}),{context:d,helpers:f}=await s({helpers:l,prompts:h});e({context:d,helpers:f,template:c})}catch(t){t instanceof Error&&console.log(t.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,a)=>{try{let s=r.optional(r.string()).parse(e);const{paths:n}=r.object({paths:r.array(r.string())}).parse(a);void 0===s&&(s=await o({paths:n,type:"snippet"}));const i=p({name:s,paths:n,type:"snippet"});process.stdout.write(t({context:{},path:`${i.path}/${i.template}/snippet.handlebars`}))}catch(t){t instanceof Error&&console.log(t.message)}})),i.parse();
2
+ import{compileTemplate as t,generate as e,getContextPrompts as a,getTemplate as p,promptForContext as s,promptForTemplate as o}from"../chunk-2FL24MYQ.js";import{Command as n}from"commander";import{z as r}from"zod";var i=new n;i.name("plano").description("CLI to scaffold files and directories from templates").version("0.8.0","-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(t,n)=>{try{let i=r.optional(r.string()).parse(t);const{paths:m}=r.object({paths:r.array(r.string())}).parse(n);void 0===i&&(i=await o({paths:m,type:"file"}));const c=p({name:i,paths:m,type:"file"}),{helpers:l,prompts:h}=await a({template:c}),{context:d,helpers:f}=await s({helpers:l,prompts:h});e({context:d,helpers:f,template:c})}catch(t){t instanceof Error&&console.log(t.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,a)=>{try{let s=r.optional(r.string()).parse(e);const{paths:n}=r.object({paths:r.array(r.string())}).parse(a);void 0===s&&(s=await o({paths:n,type:"snippet"}));const i=p({name:s,paths:n,type:"snippet"});process.stdout.write(t({context:{},path:`${i.path}/${i.template}/snippet.handlebars`}))}catch(t){t instanceof Error&&console.log(t.message)}}),i.parse();
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as zod_v4_core_schemas_cjs from 'zod/v4/core/schemas.cjs';
2
+ import * as zod from 'zod';
1
3
  import { z } from 'zod';
2
4
  import { HelperDelegate } from 'handlebars';
3
5
 
@@ -7,141 +9,60 @@ interface GetContextPromptsOptions {
7
9
  template: string;
8
10
  };
9
11
  }
10
- declare const promptsSchema: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
12
+ declare const promptsSchema: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
11
13
  message: z.ZodString;
12
14
  name: z.ZodString;
13
15
  required: z.ZodBoolean;
14
- }, {
15
16
  type: z.ZodLiteral<"checkbox">;
16
17
  choices: z.ZodArray<z.ZodObject<{
17
18
  value: z.ZodString;
18
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
19
- value: z.ZodString;
20
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
21
- value: z.ZodString;
22
- }, z.ZodTypeAny, "passthrough">>, "many">;
23
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
24
- message: z.ZodString;
25
- name: z.ZodString;
26
- required: z.ZodBoolean;
27
- }, {
28
- type: z.ZodLiteral<"checkbox">;
29
- choices: z.ZodArray<z.ZodObject<{
30
- value: z.ZodString;
31
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
32
- value: z.ZodString;
33
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
34
- value: z.ZodString;
35
- }, z.ZodTypeAny, "passthrough">>, "many">;
36
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
37
- message: z.ZodString;
38
- name: z.ZodString;
39
- required: z.ZodBoolean;
40
- }, {
41
- type: z.ZodLiteral<"checkbox">;
42
- choices: z.ZodArray<z.ZodObject<{
43
- value: z.ZodString;
44
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
45
- value: z.ZodString;
46
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
47
- value: z.ZodString;
48
- }, z.ZodTypeAny, "passthrough">>, "many">;
49
- }>, z.ZodTypeAny, "passthrough">>, z.ZodObject<z.objectUtil.extendShape<{
50
- message: z.ZodString;
51
- name: z.ZodString;
52
- required: z.ZodBoolean;
53
- }, {
54
- type: z.ZodLiteral<"input">;
55
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
19
+ }, z.core.$loose>>;
20
+ }, z.core.$loose>, z.ZodObject<{
56
21
  message: z.ZodString;
57
22
  name: z.ZodString;
58
23
  required: z.ZodBoolean;
59
- }, {
60
24
  type: z.ZodLiteral<"input">;
61
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
25
+ }, z.core.$loose>, z.ZodObject<{
62
26
  message: z.ZodString;
63
27
  name: z.ZodString;
64
28
  required: z.ZodBoolean;
65
- }, {
66
- type: z.ZodLiteral<"input">;
67
- }>, z.ZodTypeAny, "passthrough">>, z.ZodObject<z.objectUtil.extendShape<{
68
- message: z.ZodString;
69
- name: z.ZodString;
70
- required: z.ZodBoolean;
71
- }, {
72
- type: z.ZodLiteral<"select">;
73
- choices: z.ZodArray<z.ZodObject<{
74
- value: z.ZodString;
75
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
76
- value: z.ZodString;
77
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
78
- value: z.ZodString;
79
- }, z.ZodTypeAny, "passthrough">>, "many">;
80
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
81
- message: z.ZodString;
82
- name: z.ZodString;
83
- required: z.ZodBoolean;
84
- }, {
85
29
  type: z.ZodLiteral<"select">;
86
30
  choices: z.ZodArray<z.ZodObject<{
87
31
  value: z.ZodString;
88
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
89
- value: z.ZodString;
90
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
91
- value: z.ZodString;
92
- }, z.ZodTypeAny, "passthrough">>, "many">;
93
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
94
- message: z.ZodString;
95
- name: z.ZodString;
96
- required: z.ZodBoolean;
97
- }, {
98
- type: z.ZodLiteral<"select">;
99
- choices: z.ZodArray<z.ZodObject<{
100
- value: z.ZodString;
101
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
102
- value: z.ZodString;
103
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
104
- value: z.ZodString;
105
- }, z.ZodTypeAny, "passthrough">>, "many">;
106
- }>, z.ZodTypeAny, "passthrough">>]>, "many">>;
32
+ }, z.core.$loose>>;
33
+ }, z.core.$loose>], "type">>>;
107
34
  type PromptsSchema = z.infer<typeof promptsSchema>;
108
35
  declare const helpersSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString], null>, z.ZodString>>>;
109
36
  type HelpersSchema = z.infer<typeof helpersSchema>;
110
37
  declare function getContextPrompts({ template: { path, template }, }: GetContextPromptsOptions): Promise<{
111
- prompts: (z.objectOutputType<z.objectUtil.extendShape<{
112
- message: z.ZodString;
113
- name: z.ZodString;
114
- required: z.ZodBoolean;
115
- }, {
116
- type: z.ZodLiteral<"checkbox">;
117
- choices: z.ZodArray<z.ZodObject<{
118
- value: z.ZodString;
119
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
120
- value: z.ZodString;
121
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
122
- value: z.ZodString;
123
- }, z.ZodTypeAny, "passthrough">>, "many">;
124
- }>, z.ZodTypeAny, "passthrough"> | z.objectOutputType<z.objectUtil.extendShape<{
125
- message: z.ZodString;
126
- name: z.ZodString;
127
- required: z.ZodBoolean;
128
- }, {
129
- type: z.ZodLiteral<"input">;
130
- }>, z.ZodTypeAny, "passthrough"> | z.objectOutputType<z.objectUtil.extendShape<{
131
- message: z.ZodString;
132
- name: z.ZodString;
133
- required: z.ZodBoolean;
134
- }, {
135
- type: z.ZodLiteral<"select">;
136
- choices: z.ZodArray<z.ZodObject<{
137
- value: z.ZodString;
138
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
139
- value: z.ZodString;
140
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
141
- value: z.ZodString;
142
- }, z.ZodTypeAny, "passthrough">>, "many">;
143
- }>, z.ZodTypeAny, "passthrough">)[];
144
- helpers: Record<string, (args_0: string) => string>;
38
+ prompts: ({
39
+ [x: string]: unknown;
40
+ message: string;
41
+ name: string;
42
+ required: boolean;
43
+ type: "checkbox";
44
+ choices: {
45
+ [x: string]: unknown;
46
+ value: string;
47
+ }[];
48
+ } | {
49
+ [x: string]: unknown;
50
+ message: string;
51
+ name: string;
52
+ required: boolean;
53
+ type: "input";
54
+ } | {
55
+ [x: string]: unknown;
56
+ message: string;
57
+ name: string;
58
+ required: boolean;
59
+ type: "select";
60
+ choices: {
61
+ [x: string]: unknown;
62
+ value: string;
63
+ }[];
64
+ })[];
65
+ helpers: Record<string, z.core.$InferOuterFunctionType<z.ZodTuple<[z.ZodString], null>, z.ZodString>>;
145
66
  }>;
146
67
 
147
68
  interface PromptForContextOptions {
@@ -150,7 +71,7 @@ interface PromptForContextOptions {
150
71
  }
151
72
  declare function promptForContext({ helpers, prompts, }: PromptForContextOptions): Promise<{
152
73
  context: Record<string, unknown>;
153
- helpers: Record<string, (args_0: string) => string>;
74
+ helpers: Record<string, zod_v4_core_schemas_cjs.$InferOuterFunctionType<zod.ZodTuple<[zod.ZodString], null>, zod.ZodString>>;
154
75
  }>;
155
76
 
156
77
  interface CompileTemplate {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{compileTemplate as o,generate as r,getAllPaths as m,getContextPrompts as p,getTemplate as t,promptForContext as L,promptForTemplate as c}from"./chunk-HFRGLULM.js";export{o as compileTemplate,r as generate,m as getAllPaths,p as getContextPrompts,t as getTemplate,L as promptForContext,c as promptForTemplate};
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-2FL24MYQ.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.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -29,21 +29,21 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/lodash-es": "^4.17.12",
32
- "@types/node": "^22.14.1",
33
- "@vitest/coverage-v8": "^3.1.1",
34
- "prettier": "^3.5.3",
35
- "terser": "^5.39.0",
36
- "tsup": "^8.4.0",
37
- "typescript": "^5.8.3",
32
+ "@types/node": "^22.18.0",
33
+ "@vitest/coverage-v8": "^3.2.4",
34
+ "prettier": "^3.6.2",
35
+ "terser": "^5.43.1",
36
+ "tsup": "^8.5.0",
37
+ "typescript": "^5.9.2",
38
38
  "vitest": "^3.1.1"
39
39
  },
40
40
  "dependencies": {
41
- "@inquirer/prompts": "^7.4.1",
42
- "chalk": "^5.4.1",
43
- "commander": "^13.1.0",
44
- "glob": "^11.0.1",
41
+ "@inquirer/prompts": "^7.8.4",
42
+ "chalk": "^5.6.0",
43
+ "commander": "^14.0.0",
44
+ "glob": "^11.0.3",
45
45
  "handlebars": "^4.7.8",
46
46
  "lodash-es": "^4.17.21",
47
- "zod": "^3.24.2"
47
+ "zod": "^4.1.5"
48
48
  }
49
49
  }
@@ -1 +0,0 @@
1
- import{checkbox as e,input as t,select as r}from"@inquirer/prompts";async function a({helpers:a={},prompts:o}){if(!o||!Array.isArray(o))return{context:{},helpers:a};const s={};for(let a=0;a<o.length;a++){const p=o[a];switch(p.type){case"checkbox":s[p.name]=await e(p);break;case"input":s[p.name]=await t(p);break;case"select":s[p.name]=await r(p)}}return{context:s,helpers:a}}import{resolve as o}from"node:path";import{z as s}from"zod";import{existsSync as p}from"node:fs";import{z as n}from"zod";import{z as i}from"zod";var m=i.object({message:i.string(),name:i.string(),required:i.boolean()}),l=n.object({value:n.string()}).passthrough(),c=m.extend({type:n.literal("checkbox"),choices:n.array(l)}).passthrough();import{z as f}from"zod";var h=m.extend({type:f.literal("input")}).passthrough();import{z as u}from"zod";var d=u.object({value:u.string()}).passthrough(),y=m.extend({type:u.literal("select"),choices:u.array(d)}).passthrough(),b=s.optional(s.array(s.discriminatedUnion("type",[c,h,y]))),g=s.optional(s.record(s.function(s.tuple([s.string()]),s.string())));async function w({template:{path:e,template:t}}){const r=o(`${e}/${t}`,"context.mjs");if(!p(r))return{prompts:[],helpers:{}};let{prompts:a,helpers:s}=await import(r);return{prompts:b.parse(a)||[],helpers:g.parse(s)||{}}}import{readFileSync as C}from"node:fs";import x from"handlebars";function k({context:e={},helpers:t={},path:r}){return x.compile(C(r,"utf-8"))(e)}import{existsSync as v,readdirSync as $}from"node:fs";import{homedir as z}from"node:os";import{resolve as j}from"node:path";var D="plano";var P=class e extends Error{constructor(t){super(function(e){return e.join("\n")}(t)),Object.setPrototypeOf(this,e.prototype)}};function U({includeDefaultPath:e=!0,paths:t,type:r}){const a=[];return e&&a.push(function(e){switch(e){case"file":return`${z()}/${D}/file-templates`;case"snippet":return`${z()}/${D}/snippet-templates`;default:throw new P([`Unable to get default template path for type: ${e}`])}}(r)),[...a,...t].map((e=>j(e))).filter((e=>v(e))).map((e=>$(e,{withFileTypes:!0}).filter((e=>e.isDirectory()&&!e.name.startsWith(".git"))).map((t=>({path:e,template:t.name}))))).flat()}import{select as q}from"@inquirer/prompts";import{sortedUniq as F}from"lodash-es";async function O({includeDefaultPath:e,paths:t,type:r}){const a=U({includeDefaultPath:e,paths:t,type:r});return await q({message:"Select a template",choices:F(a.map((({template:e})=>({value:e}))))})}import{mkdirSync as S,writeFileSync as T,copyFileSync as A}from"node:fs";import{resolve as W}from"node:path";import{globSync as E}from"glob";import H from"handlebars";import{camelCase as L}from"lodash-es";import{kebabCase as B}from"lodash-es";import{camelCase as G,upperFirst as I}from"lodash-es";import{snakeCase as J}from"lodash-es";import{snakeCase as K}from"lodash-es";var M={camelCase:function(e){return L(e)},kebabCase:function(e){return B(e)},lowerCase:function(e){return e.toLowerCase()},pascalCase:function(e){return I(G(e))},snakeCase:function(e){return J(e)},upperCase:function(e){return e.toUpperCase()},upperSnakeCase:function(e){return K(e).toUpperCase()}};function N({copyToPath:e=process.cwd(),context:t={},helpers:r={},template:{path:a,template:o}}){Object.entries({...M,...r}).map((([e,t])=>H.registerHelper(e,t)));const s=W(a,o,"template"),p=E(`${s}/**/*`,{withFileTypes:!0,dot:!0});for(let a of p){const o=a.fullpath(),p=H.compile(o)(t).replace(`${s}/`,"");if(a.isDirectory()&&S(W(e,p)),a.isFile())if(a.name.endsWith(".handlebars")){const a=k({context:t,helpers:r,path:o});T(W(e,p.replace(".handlebars","")),a)}else A(o,W(e,p))}}import Q from"chalk";import{uniq as R}from"lodash-es";function V({name:e,paths:t,type:r}){const a=U({paths:t,type:r}),o=a.find((t=>t.template===e));if(!o)throw new P([Q.red(`Unable to find template "${e}" at paths:`),...R(a.map((e=>e.path)))]);return o}export{a as promptForContext,w as getContextPrompts,k as compileTemplate,U as getAllPaths,O as promptForTemplate,N as generate,V as getTemplate};