bobp 0.0.12 → 0.0.14
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/cli.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";var A=Object.create;var g=Object.defineProperty,F=Object.defineProperties,H=Object.getOwnPropertyDescriptor,M=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertyNames,y=Object.getOwnPropertySymbols,G=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var T=(t,e,o)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,h=(t,e)=>{for(var o in e||(e={}))x.call(e,o)&&T(t,o,e[o]);if(y)for(var o of y(e))U.call(e,o)&&T(t,o,e[o]);return t},v=(t,e)=>F(t,M(e));var W=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Y(e))!x.call(t,r)&&r!==o&&g(t,r,{get:()=>e[r],enumerable:!(n=H(e,r))||n.enumerable});return t};var k=(t,e,o)=>(o=t!=null?A(G(t)):{},W(e||!t||!t.__esModule?g(o,"default",{value:t,enumerable:!0}):o,t));var P=k(require("yargs"));var b=require("path"),I=require("canvas"),D=require("fs");var O=1280,E=640,S="TgByAQpjkl",R='"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Q=`700 80px ${R}`,X=`300 48px ${R}`,C=1.2;function _({title:t=S,description:e=`description line1
|
|
3
3
|
${S}`}){let o=(0,I.createCanvas)(O,E),{width:n,height:r}=o,i=o.getContext("2d");i.fillStyle="#001220",i.fillRect(0,0,n,r),i.textAlign="center",i.textBaseline="top";let p=[{str:t,font:Q,y:0,h:0,g:1.3},...e.split(`
|
|
4
|
-
`).map(c=>({str:c,font:X,y:0,h:0,g:C}))].map(c=>z(i,c)),s=p[p.length-1].h;s-=s/C,s=p.reduce((c,j)=>c+j.h,-s),s=Math.ceil(s);let u=Math.floor((E-s)*.5);for(let c of p)q(i,c,u),u+=c.h;let $=(0,b.join)(process.cwd(),"cover.png");o.createPNGStream().pipe((0,D.createWriteStream)($))}function q(t,e,o){t.fillStyle="white",t.font=e.font,t.fillText(e.str,O*.5,o+e.y)}function z(t,e){t.font=e.font;let o=t.measureText(e.str),{actualBoundingBoxAscent:n,actualBoundingBoxDescent:r}=o,i=n+r;return v(h({},e),{y:n,h:i*e.g})}var m=require("path"),l=require("fs");var L=require("path"),a=(0,L.join)(__dirname,"..","templates");var J=(0,m.join)(a,"license");function N({type:t,year:e,author:o}){let n=`${t}.txt`,r=(0,m.join)(J,n),p=(0,l.readFileSync)(r,{encoding:"utf-8"}).replace("[year]",e).replace("[author]",o),s=(0,m.join)(process.cwd(),"LICENSE");(0,l.writeFileSync)(s,p)}var d=require("path"),f=require("fs");var w=(0,d.join)(a,"prettier");function B(){let t=(0,f.readdirSync)(w);for(let e of t){let o=(0,d.join)(w,e),n=(0,d.join)(process.cwd(),`.${e}`);(0,f.copyFileSync)(o,n)}}P.default.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=>N(t)).command("prettier","prettier description",t=>t,()=>B()).command("cover","cover description",t=>t.positional("title",{demandOption:!0,describe:"",type:"string"}).positional("description",{demandOption:!0,describe:"",type:"string"}),t=>_(t)).help().strict().parseSync();
|
|
4
|
+
`).map(c=>({str:c,font:X,y:0,h:0,g:C}))].map(c=>z(i,c)),s=p[p.length-1].h;s-=s/C,s=p.reduce((c,j)=>c+j.h,-s),s=Math.ceil(s);let u=Math.floor((E-s)*.5);for(let c of p)q(i,c,u),u+=c.h;let $=(0,b.join)(process.cwd(),"cover.png");o.createPNGStream().pipe((0,D.createWriteStream)($))}function q(t,e,o){t.fillStyle="white",t.font=e.font,t.fillText(e.str,O*.5,o+e.y)}function z(t,e){t.font=e.font;let o=t.measureText(e.str),{actualBoundingBoxAscent:n,actualBoundingBoxDescent:r}=o,i=n+r;return v(h({},e),{y:n,h:i*e.g})}var m=require("path"),l=require("fs");var L=require("path"),a=(0,L.join)(__dirname,"..","templates");var J=(0,m.join)(a,"license");function N({type:t,year:e,author:o}){let n=`${t}.txt`,r=(0,m.join)(J,n),p=(0,l.readFileSync)(r,{encoding:"utf-8"}).replace("[year]",e).replace("[author]",o),s=(0,m.join)(process.cwd(),"LICENSE");(0,l.writeFileSync)(s,p)}var d=require("path"),f=require("fs");var w=(0,d.join)(a,"prettier");function B(){let t=(0,f.readdirSync)(w);for(let e of t){let o=(0,d.join)(w,e),n=(0,d.join)(process.cwd(),`.${e}`);(0,f.copyFileSync)(o,n)}}P.default.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=>N(t)).command("prettier","prettier description",t=>t,()=>B()).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().parseSync();
|