bobp 0.5.0 → 0.7.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.
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +17 -5
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var X=Object.create;var E=Object.defineProperty,Z=Object.defineProperties,
|
|
3
|
-
`).map(p=>({str:p,font:
|
|
2
|
+
"use strict";var X=Object.create;var E=Object.defineProperty,Z=Object.defineProperties,tt=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertyNames,b=Object.getOwnPropertySymbols,nt=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var T=(t,e,o)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,d=(t,e)=>{for(var o in e||(e={}))C.call(e,o)&&T(t,o,e[o]);if(b)for(var o of b(e))rt.call(e,o)&&T(t,o,e[o]);return t},f=(t,e)=>Z(t,et(e));var it=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ot(e))!C.call(t,r)&&r!==o&&E(t,r,{get:()=>e[r],enumerable:!(n=tt(e,r))||n.enumerable});return t};var S=(t,e,o)=>(o=t!=null?X(nt(t)):{},it(e||!t||!t.__esModule?E(o,"default",{value:t,enumerable:!0}):o,t));var a=(t,e,o)=>new Promise((n,r)=>{var m=i=>{try{s(o.next(i))}catch(l){r(l)}},c=i=>{try{s(o.throw(i))}catch(l){r(l)}},s=i=>i.done?n(i.value):Promise.resolve(i.value).then(m,c);s((o=o.apply(t,e)).next())});var W=S(require("yargs")),q=require("yargs/helpers");var j=require("path"),I=require("fs"),L=require("canvas");var D=1280,P=640,F='"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',st=`700 80px ${F}`,ct=`300 48px ${F}`,k=1.2;function R({title:t,description:e,path:o}){let n=(0,L.createCanvas)(D,P),{width:r,height:m}=n,c=n.getContext("2d");c.fillStyle="#001220",c.fillRect(0,0,r,m),c.textAlign="center",c.textBaseline="top";let s=[{str:t,font:st,y:0,h:0,g:1.3},...e.split(`
|
|
3
|
+
`).map(p=>({str:p,font:ct,y:0,h:0,g:k}))].map(p=>pt(c,p)),i=s[s.length-1].h;i-=i/k,i=s.reduce((p,V)=>p+V.h,-i),i=Math.ceil(i);let l=Math.floor((P-i)*.5);for(let p of s)at(c,p,l),l+=p.h;let K=(0,j.join)(o,"cover.png"),Q=n.toBuffer("image/png");(0,I.writeFileSync)(K,Q)}function at(t,e,o){t.fillStyle="white",t.font=e.font,t.fillText(e.str,D*.5,o+e.y)}function pt(t,e){t.font=e.font;let o=t.measureText(e.str),{actualBoundingBoxAscent:n,actualBoundingBoxDescent:r}=o,m=n+r;return f(d({},e),{y:n,h:m*e.g})}var g=require("fs"),u=require("path"),_=S(require("degit")),B=require("rimraf");function J(t){return a(this,null,function*(){yield mt(t),lt(t),dt(t)})}function mt(e){return a(this,arguments,function*({name:t}){return yield(0,_.default)("rdarida/template-electron#main").clone((0,u.resolve)(process.cwd(),t))})}function lt({name:t,productName:e}){let o=(0,u.resolve)(process.cwd(),t,"package.json"),n=(0,g.readFileSync)(o,{encoding:"utf-8"}),r=f(d({},JSON.parse(n)),{name:t,productName:e,version:"0.0.0"});(0,g.writeFileSync)(o,JSON.stringify(r,null,2))}function dt({name:t}){["package-lock.json"].forEach(e=>{let o=(0,u.resolve)(process.cwd(),t,e);(0,B.rimrafSync)(o)})}var h=require("path"),x=require("fs");var M=require("path"),y=(0,M.join)(__dirname,"..","templates");var ft=(0,h.join)(y,"license");function A({type:t,year:e,author:o,path:n}){let r=`${t}.txt`,m=(0,h.join)(ft,r),s=(0,x.readFileSync)(m,{encoding:"utf-8"}).replace("[year]",e).replace("[author]",o),i=(0,h.join)(n,"LICENSE");(0,x.writeFileSync)(i,s)}var v=require("path"),O=require("fs"),G=S(require("degit")),H=require("rimraf");function Y(t){return a(this,null,function*(){yield gt(t),ut(t),yt(t)})}function gt(e){return a(this,arguments,function*({name:t}){return yield(0,G.default)("rdarida/template-next#main").clone((0,v.resolve)(process.cwd(),t))})}function ut({name:t}){let e=(0,v.resolve)(process.cwd(),t,"package.json"),o=(0,O.readFileSync)(e,{encoding:"utf-8"}),n=f(d({},JSON.parse(o)),{name:t,version:"0.0.0"});(0,O.writeFileSync)(e,JSON.stringify(n,null,2))}function yt({name:t}){["package-lock.json"].forEach(e=>{let o=(0,v.resolve)(process.cwd(),t,e);(0,H.rimrafSync)(o)})}var w=require("path"),N=require("fs");var $=(0,w.join)(y,"prettier");function z({path:t}){let e=(0,N.readdirSync)($);for(let o of e){let n=(0,w.join)($,o),r=(0,w.join)(t,`.${o}`);(0,N.copyFileSync)(n,r)}}function U(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9\-]/g,"")}(0,W.default)((0,q.hideBin)(process.argv)).scriptName("bobp").usage("$0 <cmd> [args]","Usage").demandCommand(1,"Need 1").command("cover <title> <description> [path]","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"}).positional("path",{default:process.cwd(),describe:"Output path for the generated cover image",type:"string"}),t=>R(t)).command("license <author> [year] [type] [path]","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"}).positional("path",{default:process.cwd(),describe:"Output path for the generated LICENSE file",type:"string"}),t=>A(t)).command("electron <productName> [name]","Creates a new Electron project in the current working directory",t=>t.positional("productName",{demandOption:!0,describe:"Name of the application",type:"string"}).positional("name",{describe:"Name of the project directory and npm package",type:"string"}),o=>a(null,[o],function*({productName:t,name:e}){e=e||U(t),yield J({name:e,productName:t})})).command("next <name>","Creates a new Next.js project in the current working directory",t=>t.positional("name",{demandOption:!0,describe:"Name of the project directory and npm package",type:"string"}),t=>a(null,null,function*(){return yield Y(t)})).command("prettier [path]","Copies Prettier configuration files into the current working directory",t=>t.positional("path",{default:process.cwd(),describe:"Output path for the generated Prettier configuration files",type:"string"}),t=>z(t)).help().strict().parse();
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ type CoverOptions = {
|
|
|
10
10
|
*/
|
|
11
11
|
description: string;
|
|
12
12
|
/**
|
|
13
|
-
* Output
|
|
14
|
-
* (default:
|
|
13
|
+
* Output path for the generated cover.png
|
|
14
|
+
* (default: the current working directory)
|
|
15
15
|
*/
|
|
16
16
|
path: string;
|
|
17
17
|
};
|
|
@@ -50,13 +50,18 @@ type LicenseOptions = {
|
|
|
50
50
|
year: string;
|
|
51
51
|
/** Author or copyright holder name */
|
|
52
52
|
author: string;
|
|
53
|
+
/**
|
|
54
|
+
* Output path for the generated LICENSE file
|
|
55
|
+
* (default: the current working directory)
|
|
56
|
+
*/
|
|
57
|
+
path: string;
|
|
53
58
|
};
|
|
54
59
|
/**
|
|
55
60
|
* Generates a LICENSE file in the current working directory.
|
|
56
61
|
*
|
|
57
62
|
* @param options Configuration options for the license generation.
|
|
58
63
|
*/
|
|
59
|
-
declare function license({ type, year, author }: LicenseOptions): void;
|
|
64
|
+
declare function license({ type, year, author, path }: LicenseOptions): void;
|
|
60
65
|
|
|
61
66
|
/**
|
|
62
67
|
* Options used to generate a new Next.js project.
|
|
@@ -74,11 +79,18 @@ type NextOptions = {
|
|
|
74
79
|
*/
|
|
75
80
|
declare function next(nextOptions: NextOptions): Promise<void>;
|
|
76
81
|
|
|
82
|
+
type PrettierOptions = {
|
|
83
|
+
/**
|
|
84
|
+
* Output path for the generated Prettier configuration files
|
|
85
|
+
* (default: the current working directory)
|
|
86
|
+
*/
|
|
87
|
+
path: string;
|
|
88
|
+
};
|
|
77
89
|
/**
|
|
78
90
|
* Copies Prettier configuration files into the current working directory.
|
|
79
91
|
*/
|
|
80
|
-
declare function prettier(): void;
|
|
92
|
+
declare function prettier({ path }: PrettierOptions): void;
|
|
81
93
|
|
|
82
94
|
declare function normalize(name: string): string;
|
|
83
95
|
|
|
84
|
-
export { type CoverOptions, type ElectronOptions, type LicenseOptions, type NextOptions, cover, electron, license, next, normalize, prettier };
|
|
96
|
+
export { type CoverOptions, type ElectronOptions, type LicenseOptions, type NextOptions, type PrettierOptions, cover, electron, license, next, normalize, prettier };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var G=Object.create;var
|
|
2
|
-
`).map(a=>({str:a,font:et,y:0,h:0,g:D}))].map(a=>rt(
|
|
1
|
+
"use strict";var G=Object.create;var d=Object.defineProperty,U=Object.defineProperties,W=Object.getOwnPropertyDescriptor,q=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,Q=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var P=(t,e,o)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,m=(t,e)=>{for(var o in e||(e={}))O.call(e,o)&&P(t,o,e[o]);if(w)for(var o of w(e))V.call(e,o)&&P(t,o,e[o]);return t},l=(t,e)=>U(t,q(e));var X=(t,e)=>{for(var o in e)d(t,o,{get:e[o],enumerable:!0})},C=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of K(e))!O.call(t,r)&&r!==o&&d(t,r,{get:()=>e[r],enumerable:!(n=W(e,r))||n.enumerable});return t};var I=(t,e,o)=>(o=t!=null?G(Q(t)):{},C(e||!t||!t.__esModule?d(o,"default",{value:t,enumerable:!0}):o,t)),Z=t=>C(d({},"__esModule",{value:!0}),t);var g=(t,e,o)=>new Promise((n,r)=>{var p=i=>{try{s(o.next(i))}catch(f){r(f)}},c=i=>{try{s(o.throw(i))}catch(f){r(f)}},s=i=>i.done?n(i.value):Promise.resolve(i.value).then(p,c);s((o=o.apply(t,e)).next())});var yt={};X(yt,{cover:()=>ot,electron:()=>it,license:()=>ft,next:()=>mt,normalize:()=>xt,prettier:()=>ut});module.exports=Z(yt);var F=require("path"),j=require("fs"),k=require("canvas");var _=1280,R=640,L='"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',tt=`700 80px ${L}`,et=`300 48px ${L}`,D=1.2;function ot({title:t,description:e,path:o}){let n=(0,k.createCanvas)(_,R),{width:r,height:p}=n,c=n.getContext("2d");c.fillStyle="#001220",c.fillRect(0,0,r,p),c.textAlign="center",c.textBaseline="top";let s=[{str:t,font:tt,y:0,h:0,g:1.3},...e.split(`
|
|
2
|
+
`).map(a=>({str:a,font:et,y:0,h:0,g:D}))].map(a=>rt(c,a)),i=s[s.length-1].h;i-=i/D,i=s.reduce((a,z)=>a+z.h,-i),i=Math.ceil(i);let f=Math.floor((R-i)*.5);for(let a of s)nt(c,a,f),f+=a.h;let $=(0,F.join)(o,"cover.png"),Y=n.toBuffer("image/png");(0,j.writeFileSync)($,Y)}function nt(t,e,o){t.fillStyle="white",t.font=e.font,t.fillText(e.str,_*.5,o+e.y)}function rt(t,e){t.font=e.font;let o=t.measureText(e.str),{actualBoundingBoxAscent:n,actualBoundingBoxDescent:r}=o,p=n+r;return l(m({},e),{y:n,h:p*e.g})}var u=require("fs"),x=require("path"),b=I(require("degit")),J=require("rimraf");function it(t){return g(this,null,function*(){yield st(t),ct(t),at(t)})}function st(e){return g(this,arguments,function*({name:t}){return yield(0,b.default)("rdarida/template-electron#main").clone((0,x.resolve)(process.cwd(),t))})}function ct({name:t,productName:e}){let o=(0,x.resolve)(process.cwd(),t,"package.json"),n=(0,u.readFileSync)(o,{encoding:"utf-8"}),r=l(m({},JSON.parse(n)),{name:t,productName:e,version:"0.0.0"});(0,u.writeFileSync)(o,JSON.stringify(r,null,2))}function at({name:t}){["package-lock.json"].forEach(e=>{let o=(0,x.resolve)(process.cwd(),t,e);(0,J.rimrafSync)(o)})}var h=require("path"),v=require("fs");var B=require("path"),y=(0,B.join)(__dirname,"..","templates");var pt=(0,h.join)(y,"license");function ft({type:t,year:e,author:o,path:n}){let r=`${t}.txt`,p=(0,h.join)(pt,r),s=(0,v.readFileSync)(p,{encoding:"utf-8"}).replace("[year]",e).replace("[author]",o),i=(0,h.join)(n,"LICENSE");(0,v.writeFileSync)(i,s)}var S=require("path"),T=require("fs"),H=I(require("degit")),M=require("rimraf");function mt(t){return g(this,null,function*(){yield lt(t),gt(t),dt(t)})}function lt(e){return g(this,arguments,function*({name:t}){return yield(0,H.default)("rdarida/template-next#main").clone((0,S.resolve)(process.cwd(),t))})}function gt({name:t}){let e=(0,S.resolve)(process.cwd(),t,"package.json"),o=(0,T.readFileSync)(e,{encoding:"utf-8"}),n=l(m({},JSON.parse(o)),{name:t,version:"0.0.0"});(0,T.writeFileSync)(e,JSON.stringify(n,null,2))}function dt({name:t}){["package-lock.json"].forEach(e=>{let o=(0,S.resolve)(process.cwd(),t,e);(0,M.rimrafSync)(o)})}var E=require("path"),N=require("fs");var A=(0,E.join)(y,"prettier");function ut({path:t}){let e=(0,N.readdirSync)(A);for(let o of e){let n=(0,E.join)(A,o),r=(0,E.join)(t,`.${o}`);(0,N.copyFileSync)(n,r)}}function xt(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9\-]/g,"")}0&&(module.exports={cover,electron,license,next,normalize,prettier});
|