bobp 0.2.1 → 0.2.3

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/README.md CHANGED
@@ -38,6 +38,24 @@ npm i -g bobp
38
38
 
39
39
  ## Commands
40
40
 
41
+ ### `cover`
42
+
43
+ Generates a PNG cover image (cover.png) in the current working directory.
44
+
45
+ **Usage:**
46
+ ```sh
47
+ npx bobp cover "Example title" "Description for the Example cover"
48
+ ```
49
+
50
+ ### `license`
51
+
52
+ Generates a LICENSE file in the current working directory.
53
+
54
+ **Usage:**
55
+ ```sh
56
+ npx bobp license "John Doe"
57
+ ```
58
+
41
59
  ### `prettier`
42
60
 
43
61
  Copies Prettier configuration files into the current working directory.
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var U=Object.create;var O=Object.defineProperty,W=Object.defineProperties,q=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols,Q=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var S=(t,e,o)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,l=(t,e)=>{for(var o in e||(e={}))w.call(e,o)&&S(t,o,e[o]);if(N)for(var o of N(e))V.call(e,o)&&S(t,o,e[o]);return t},f=(t,e)=>W(t,z(e));var X=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of K(e))!w.call(t,i)&&i!==o&&O(t,i,{get:()=>e[i],enumerable:!(n=q(e,i))||n.enumerable});return t};var C=(t,e,o)=>(o=t!=null?U(Q(t)):{},X(e||!t||!t.__esModule?O(o,"default",{value:t,enumerable:!0}):o,t));var d=(t,e,o)=>new Promise((n,i)=>{var s=c=>{try{r(o.next(c))}catch(m){i(m)}},p=c=>{try{r(o.throw(c))}catch(m){i(m)}},r=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,p);r((o=o.apply(t,e)).next())});var A=C(require("yargs")),J=require("yargs/helpers");var I=require("path"),D=require("fs"),P=require("canvas");var R=1280,b=640,L='"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Z=`700 80px ${L}`,tt=`300 48px ${L}`,E=1.2;function _({title:t,description:e}){let o=(0,P.createCanvas)(R,b),{width:n,height:i}=o,s=o.getContext("2d");s.fillStyle="#001220",s.fillRect(0,0,n,i),s.textAlign="center",s.textBaseline="top";let p=[{str:t,font:Z,y:0,h:0,g:1.3},...e.split(`
3
- `).map(a=>({str:a,font:tt,y:0,h:0,g:E}))].map(a=>ot(s,a)),r=p[p.length-1].h;r-=r/E,r=p.reduce((a,G)=>a+G.h,-r),r=Math.ceil(r);let c=Math.floor((b-r)*.5);for(let a of p)et(s,a,c),c+=a.h;let m=(0,I.join)(process.cwd(),"cover.png"),Y=o.toBuffer("image/png");(0,D.writeFileSync)(m,Y)}function et(t,e,o){t.fillStyle="white",t.font=e.font,t.fillText(e.str,R*.5,o+e.y)}function ot(t,e){t.font=e.font;let o=t.measureText(e.str),{actualBoundingBoxAscent:n,actualBoundingBoxDescent:i}=o,s=n+i;return f(l({},e),{y:n,h:s*e.g})}var u=require("path"),y=require("fs");var F=require("path"),g=(0,F.join)(__dirname,"..","templates");var nt=(0,u.join)(g,"license");function B({type:t,year:e,author:o}){let n=`${t}.txt`,i=(0,u.join)(nt,n),p=(0,y.readFileSync)(i,{encoding:"utf-8"}).replace("[year]",e).replace("[author]",o),r=(0,u.join)(process.cwd(),"LICENSE");(0,y.writeFileSync)(r,p)}var x=require("path"),h=require("fs"),j=C(require("degit")),k=require("rimraf");function H(t){return d(this,null,function*(){yield it(t),rt(t),st(t)})}function it(e){return d(this,arguments,function*({name:t}){return yield(0,j.default)("rdarida/template-next#main").clone((0,x.resolve)(process.cwd(),t))})}function rt({name:t}){let e=(0,x.resolve)(process.cwd(),t,"package.json"),o=(0,h.readFileSync)(e,{encoding:"utf-8"}),n=f(l({},JSON.parse(o)),{name:t,version:"0.0.0"});(0,h.writeFileSync)(e,JSON.stringify(n,null,2))}function st({name:t}){["package-lock.json"].forEach(e=>{let o=(0,x.resolve)(process.cwd(),t,e);(0,k.rimrafSync)(o)})}var v=require("path"),T=require("fs");var M=(0,v.join)(g,"prettier");function $(){let t=(0,T.readdirSync)(M);for(let e of t){let o=(0,v.join)(M,e),n=(0,v.join)(process.cwd(),`.${e}`);(0,T.copyFileSync)(o,n)}}(0,A.default)((0,J.hideBin)(process.argv)).scriptName("bobp").usage("$0 <cmd> [args]","Usage").demandCommand(1,"Need 1").command("license <author> [year] [type]","license description",t=>t.positional("author",{demandOption:!0,describe:"",type:"string"}).positional("year",{default:new Date().getFullYear().toString(),describe:"",type:"string"}).positional("type",{default:"mit",describe:"",type:"string"}),t=>B(t)).command("next <name>","next description",t=>t.positional("name",{demandOption:!0,describe:"",type:"string"}),t=>d(null,null,function*(){return yield H(t)})).command("prettier","Copies Prettier configuration files into the current working directory",t=>t,()=>$()).command("cover <title> <description>","cover description",t=>t.positional("title",{demandOption:!0,describe:"",type:"string"}).positional("description",{demandOption:!0,describe:"",type:"string"}),t=>_(t)).help().strict().parse();
2
+ "use strict";var U=Object.create;var N=Object.defineProperty,W=Object.defineProperties,q=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,Q=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var O=(t,e,o)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,l=(t,e)=>{for(var o in e||(e={}))S.call(e,o)&&O(t,o,e[o]);if(w)for(var o of w(e))V.call(e,o)&&O(t,o,e[o]);return t},f=(t,e)=>W(t,z(e));var X=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of K(e))!S.call(t,r)&&r!==o&&N(t,r,{get:()=>e[r],enumerable:!(n=q(e,r))||n.enumerable});return t};var b=(t,e,o)=>(o=t!=null?U(Q(t)):{},X(e||!t||!t.__esModule?N(o,"default",{value:t,enumerable:!0}):o,t));var d=(t,e,o)=>new Promise((n,r)=>{var s=c=>{try{i(o.next(c))}catch(m){r(m)}},a=c=>{try{i(o.throw(c))}catch(m){r(m)}},i=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,a);i((o=o.apply(t,e)).next())});var H=b(require("yargs")),Y=require("yargs/helpers");var I=require("path"),D=require("fs"),P=require("canvas");var L=1280,C=640,R='"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Z=`700 80px ${R}`,tt=`300 48px ${R}`,E=1.2;function _({title:t,description:e}){let o=(0,P.createCanvas)(L,C),{width:n,height:r}=o,s=o.getContext("2d");s.fillStyle="#001220",s.fillRect(0,0,n,r),s.textAlign="center",s.textBaseline="top";let a=[{str:t,font:Z,y:0,h:0,g:1.3},...e.split(`
3
+ `).map(p=>({str:p,font:tt,y:0,h:0,g:E}))].map(p=>ot(s,p)),i=a[a.length-1].h;i-=i/E,i=a.reduce((p,J)=>p+J.h,-i),i=Math.ceil(i);let c=Math.floor((C-i)*.5);for(let p of a)et(s,p,c),c+=p.h;let m=(0,I.join)(process.cwd(),"cover.png"),$=o.toBuffer("image/png");(0,D.writeFileSync)(m,$)}function et(t,e,o){t.fillStyle="white",t.font=e.font,t.fillText(e.str,L*.5,o+e.y)}function ot(t,e){t.font=e.font;let o=t.measureText(e.str),{actualBoundingBoxAscent:n,actualBoundingBoxDescent:r}=o,s=n+r;return f(l({},e),{y:n,h:s*e.g})}var u=require("path"),y=require("fs");var F=require("path"),g=(0,F.join)(__dirname,"..","templates");var nt=(0,u.join)(g,"license");function k({type:t,year:e,author:o}){let n=`${t}.txt`,r=(0,u.join)(nt,n),a=(0,y.readFileSync)(r,{encoding:"utf-8"}).replace("[year]",e).replace("[author]",o),i=(0,u.join)(process.cwd(),"LICENSE");(0,y.writeFileSync)(i,a)}var x=require("path"),h=require("fs"),B=b(require("degit")),j=require("rimraf");function M(t){return d(this,null,function*(){yield rt(t),it(t),st(t)})}function rt(e){return d(this,arguments,function*({name:t}){return yield(0,B.default)("rdarida/template-next#main").clone((0,x.resolve)(process.cwd(),t))})}function it({name:t}){let e=(0,x.resolve)(process.cwd(),t,"package.json"),o=(0,h.readFileSync)(e,{encoding:"utf-8"}),n=f(l({},JSON.parse(o)),{name:t,version:"0.0.0"});(0,h.writeFileSync)(e,JSON.stringify(n,null,2))}function st({name:t}){["package-lock.json"].forEach(e=>{let o=(0,x.resolve)(process.cwd(),t,e);(0,j.rimrafSync)(o)})}var v=require("path"),T=require("fs");var A=(0,v.join)(g,"prettier");function G(){let t=(0,T.readdirSync)(A);for(let e of t){let o=(0,v.join)(A,e),n=(0,v.join)(process.cwd(),`.${e}`);(0,T.copyFileSync)(o,n)}}(0,H.default)((0,Y.hideBin)(process.argv)).scriptName("bobp").usage("$0 <cmd> [args]","Usage").demandCommand(1,"Need 1").command("license <author> [year] [type]","Generates a LICENSE file in the current working directory",t=>t.positional("author",{demandOption:!0,describe:"Author or copyright holder name",type:"string"}).positional("year",{default:new Date().getFullYear().toString(),describe:"Year to be inserted into the license text",type:"string"}).positional("type",{default:"mit",describe:'License type (e.g. "mit")',type:"string"}),t=>k(t)).command("next <name>","next description",t=>t.positional("name",{demandOption:!0,describe:"",type:"string"}),t=>d(null,null,function*(){return yield M(t)})).command("prettier","Copies Prettier configuration files into the current working directory",t=>t,()=>G()).command("cover <title> <description>","Generates a PNG cover image (cover.png) in the current working directory",t=>t.positional("title",{demandOption:!0,describe:"Main title text displayed on the cover",type:"string"}).positional("description",{demandOption:!0,describe:"Description text displayed below the title",type:"string"}),t=>_(t)).help().strict().parse();
package/dist/index.d.ts CHANGED
@@ -1,14 +1,38 @@
1
+ /**
2
+ * Options used to generate a cover image.
3
+ */
1
4
  type CoverOptions = {
5
+ /** Main title text displayed on the cover */
2
6
  title: string;
7
+ /**
8
+ * Description text displayed below the title.
9
+ * New lines (`\n`) are respected and rendered as separate lines.
10
+ */
3
11
  description: string;
4
12
  };
13
+ /**
14
+ * Generates a PNG cover image (cover.png) in the current working directory.
15
+ *
16
+ * @param options Configuration options for the cover image.
17
+ */
5
18
  declare function cover({ title, description }: CoverOptions): void;
6
19
 
20
+ /**
21
+ * Options used to generate a LICENSE file.
22
+ */
7
23
  type LicenseOptions = {
24
+ /** License type (e.g. `MIT`) */
8
25
  type: string;
26
+ /** Year to be inserted into the license text */
9
27
  year: string;
28
+ /** Author or copyright holder name */
10
29
  author: string;
11
30
  };
31
+ /**
32
+ * Generates a LICENSE file in the current working directory.
33
+ *
34
+ * @param options Configuration options for the license generation.
35
+ */
12
36
  declare function license({ type, year, author }: LicenseOptions): void;
13
37
 
14
38
  type NextOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bobp",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "How can I help you, Bobp?",
5
5
  "keywords": [],
6
6
  "license": "MIT",