@pixid/cli 0.1.1 → 0.2.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/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @pixid/cli
2
+
3
+ <img src="https://raw.githubusercontent.com/thilllon/pixid/main/assets/alice.png" width="64" height="64" alt="identicon for alice" />
4
+
5
+ The `pixid` command: writes a deterministic blocky identicon for any seed
6
+ string as a PNG or SVG file. Needs Node 18.3+.
7
+
8
+ ```sh
9
+ npm i -g @pixid/cli # puts `pixid` on your PATH; or run it with npx, no install
10
+ ```
11
+
12
+ ```sh
13
+ npx @pixid/cli alice # alice.png, the icon above (128×128)
14
+ npx @pixid/cli alice --out avatars/alice.svg # SVG, format inferred; creates avatars/
15
+ npx @pixid/cli 0x8ba1f109551bd432803012645ac136ddd64dba72 --scale 8 # 64×64 PNG
16
+ ```
17
+
18
+ The package is always `@pixid/cli`: there is no unscoped `pixid` package on npm,
19
+ so `npx pixid` does not fetch this CLI.
20
+
21
+ Every flag and rule: [CLI in the pixid README](https://github.com/thilllon/pixid#cli).
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{randomUUID as h}from"crypto";import{writeFileSync as b}from"fs";import{resolve as v}from"path";import{parseArgs as y}from"util";import{toPng as x}from"@pixid/png";import{toSvg as _}from"@pixid/svg";var w="0.1.1",$=`pixid - blocky identicon generator
2
+ import{randomUUID as e}from"node:crypto";import{mkdirSync as t,writeFileSync as n}from"node:fs";import{dirname as r,resolve as i}from"node:path";import{parseArgs as a}from"node:util";import{toPng as o}from"@pixid/png";import{toSvg as s}from"@pixid/svg";const c=e=>{process.stderr.write(`pixid: ${e}\n\nRun "pixid --help" for usage.\n`),process.exit(1)},l=(e,t)=>{let n=Number(t);return!Number.isInteger(n)||n<1?c(`--${e} must be a positive integer, got ${JSON.stringify(t)}`):n};((u=process.argv.slice(2))=>{let d;try{d=a({args:u,allowPositionals:!0,options:{seed:{type:`string`,short:`s`},out:{type:`string`,short:`o`},format:{type:`string`,short:`f`},size:{type:`string`},scale:{type:`string`},color:{type:`string`},bgcolor:{type:`string`},spotcolor:{type:`string`},help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}}})}catch(e){return c(e instanceof Error?e.message:String(e))}let{values:f,positionals:p}=d;if(f.help){process.stdout.write(`pixid - blocky identicon generator
3
3
 
4
4
  Usage:
5
5
  pixid [seed] [options]
@@ -17,13 +17,9 @@ Options:
17
17
  -v, --version show the version
18
18
 
19
19
  Examples:
20
- npx pixid
21
- npx pixid 0x8ba1f109551bd432803012645ac136ddd64dba72
22
- npx pixid --seed alice --out alice.svg --scale 32
23
- npx pixid --format svg --bgcolor "#ffffff"
24
- `,t=s=>{process.stderr.write(`pixid: ${s}
25
-
26
- Run "pixid --help" for usage.
27
- `),process.exit(1)},l=(s,n)=>{let e=Number(n);return!Number.isInteger(e)||e<1?t(`--${s} must be a positive integer, got ${JSON.stringify(n)}`):e},d=(s=process.argv.slice(2))=>{let n;try{n=y({args:s,allowPositionals:!0,options:{seed:{type:"string",short:"s"},out:{type:"string",short:"o"},format:{type:"string",short:"f"},size:{type:"string"},scale:{type:"string"},color:{type:"string"},bgcolor:{type:"string"},spotcolor:{type:"string"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}})}catch(r){return t(r instanceof Error?r.message:String(r))}let{values:e,positionals:g}=n;if(e.help){process.stdout.write($);return}if(e.version){process.stdout.write(`${w}
28
- `);return}if(g.length>1)return t(`expected at most one positional argument, got ${g.length}`);if(e.seed!==void 0&&g.length>0)return t("pass the seed either as a positional argument or with --seed, not both");let p=e.seed??g[0]??h(),o=e.format;if(o===void 0&&e.out!==void 0&&(o=e.out.toLowerCase().endsWith(".svg")?"svg":"png"),o??="png",o!=="png"&&o!=="svg")return t(`--format must be "png" or "svg", got ${JSON.stringify(o)}`);let f=e.out??`${p.replace(/[^a-zA-Z0-9._-]/g,"_")}.${o}`,u=e.size===void 0?void 0:l("size",e.size),m=e.scale===void 0?16:l("scale",e.scale),a={seed:p,size:u,scale:m,color:e.color,bgcolor:e.bgcolor,spotcolor:e.spotcolor},i;try{i=o==="png"?x(a):_(a)}catch(r){return t(r instanceof Error?r.message:String(r))}let c=v(process.cwd(),f);b(c,i),process.stdout.write(`${c} (${typeof i=="string"?i.length:i.byteLength} bytes)
29
- `)};d();
20
+ npx @pixid/cli
21
+ npx @pixid/cli 0x8ba1f109551bd432803012645ac136ddd64dba72
22
+ npx @pixid/cli --seed alice --out alice.svg --scale 32
23
+ npx @pixid/cli --format svg --bgcolor "#ffffff"
24
+ `);return}if(f.version){process.stdout.write(`0.2.0
25
+ `);return}if(p.length>1)return c(`expected at most one positional argument, got ${p.length}`);if(f.seed!==void 0&&p.length>0)return c(`pass the seed either as a positional argument or with --seed, not both`);let m=(f.seed??p[0])||e(),h=f.format;if(h===void 0&&f.out!==void 0&&(h=f.out.toLowerCase().endsWith(`.svg`)?`svg`:`png`),h??=`png`,h!==`png`&&h!==`svg`)return c(`--format must be "png" or "svg", got ${JSON.stringify(h)}`);let g=f.out??`${m.replace(/[^a-zA-Z0-9._-]/g,`_`).slice(0,100)}.${h}`,_={seed:m,size:f.size===void 0?void 0:l(`size`,f.size),scale:f.scale===void 0?16:l(`scale`,f.scale),color:f.color,bgcolor:f.bgcolor,spotcolor:f.spotcolor},v;try{v=h===`png`?o(_):s(_)}catch(e){return c(e instanceof Error?e.message:String(e))}let y=i(process.cwd(),g);try{t(r(y),{recursive:!0}),n(y,v)}catch(e){return c(e instanceof Error?e.message:String(e))}process.stdout.write(`${y} (${typeof v==`string`?v.length:v.byteLength} bytes)\n`)})();export{};
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var a=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var P=(r,o)=>{for(var e in o)a(r,e,{get:o[e],enumerable:!0})},E=(r,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of S(o))!z.call(r,t)&&t!==e&&a(r,t,{get:()=>o[t],enumerable:!(n=$(o,t))||n.enumerable});return r};var N=r=>E(a({},"__esModule",{value:!0}),r);var U={};P(U,{runCli:()=>O,version:()=>y});module.exports=N(U);var f=require("crypto"),u=require("fs"),m=require("path"),h=require("util"),b=require("@pixid/png"),v=require("@pixid/svg"),y="0.1.1",I=`pixid - blocky identicon generator
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("node:crypto"),t=require("node:fs"),n=require("node:path"),r=require("node:util"),i=require("@pixid/png"),a=require("@pixid/svg");const o=`0.2.0`,s=e=>{process.stderr.write(`pixid: ${e}\n\nRun "pixid --help" for usage.\n`),process.exit(1)},c=(e,t)=>{let n=Number(t);return!Number.isInteger(n)||n<1?s(`--${e} must be a positive integer, got ${JSON.stringify(t)}`):n},l=(l=process.argv.slice(2))=>{let u;try{u=(0,r.parseArgs)({args:l,allowPositionals:!0,options:{seed:{type:`string`,short:`s`},out:{type:`string`,short:`o`},format:{type:`string`,short:`f`},size:{type:`string`},scale:{type:`string`},color:{type:`string`},bgcolor:{type:`string`},spotcolor:{type:`string`},help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}}})}catch(e){return s(e instanceof Error?e.message:String(e))}let{values:d,positionals:f}=u;if(d.help){process.stdout.write(`pixid - blocky identicon generator
2
2
 
3
3
  Usage:
4
4
  pixid [seed] [options]
@@ -16,13 +16,8 @@ Options:
16
16
  -v, --version show the version
17
17
 
18
18
  Examples:
19
- npx pixid
20
- npx pixid 0x8ba1f109551bd432803012645ac136ddd64dba72
21
- npx pixid --seed alice --out alice.svg --scale 32
22
- npx pixid --format svg --bgcolor "#ffffff"
23
- `,g=r=>{process.stderr.write(`pixid: ${r}
24
-
25
- Run "pixid --help" for usage.
26
- `),process.exit(1)},d=(r,o)=>{let e=Number(o);return!Number.isInteger(e)||e<1?g(`--${r} must be a positive integer, got ${JSON.stringify(o)}`):e},O=(r=process.argv.slice(2))=>{let o;try{o=(0,h.parseArgs)({args:r,allowPositionals:!0,options:{seed:{type:"string",short:"s"},out:{type:"string",short:"o"},format:{type:"string",short:"f"},size:{type:"string"},scale:{type:"string"},color:{type:"string"},bgcolor:{type:"string"},spotcolor:{type:"string"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}})}catch(i){return g(i instanceof Error?i.message:String(i))}let{values:e,positionals:n}=o;if(e.help){process.stdout.write(I);return}if(e.version){process.stdout.write(`${y}
27
- `);return}if(n.length>1)return g(`expected at most one positional argument, got ${n.length}`);if(e.seed!==void 0&&n.length>0)return g("pass the seed either as a positional argument or with --seed, not both");let t=e.seed??n[0]??(0,f.randomUUID)(),s=e.format;if(s===void 0&&e.out!==void 0&&(s=e.out.toLowerCase().endsWith(".svg")?"svg":"png"),s??="png",s!=="png"&&s!=="svg")return g(`--format must be "png" or "svg", got ${JSON.stringify(s)}`);let x=e.out??`${t.replace(/[^a-zA-Z0-9._-]/g,"_")}.${s}`,_=e.size===void 0?void 0:d("size",e.size),w=e.scale===void 0?16:d("scale",e.scale),c={seed:t,size:_,scale:w,color:e.color,bgcolor:e.bgcolor,spotcolor:e.spotcolor},p;try{p=s==="png"?(0,b.toPng)(c):(0,v.toSvg)(c)}catch(i){return g(i instanceof Error?i.message:String(i))}let l=(0,m.resolve)(process.cwd(),x);(0,u.writeFileSync)(l,p),process.stdout.write(`${l} (${typeof p=="string"?p.length:p.byteLength} bytes)
28
- `)};0&&(module.exports={runCli,version});
19
+ npx @pixid/cli
20
+ npx @pixid/cli 0x8ba1f109551bd432803012645ac136ddd64dba72
21
+ npx @pixid/cli --seed alice --out alice.svg --scale 32
22
+ npx @pixid/cli --format svg --bgcolor "#ffffff"
23
+ `);return}if(d.version){process.stdout.write(`${o}\n`);return}if(f.length>1)return s(`expected at most one positional argument, got ${f.length}`);if(d.seed!==void 0&&f.length>0)return s(`pass the seed either as a positional argument or with --seed, not both`);let p=(d.seed??f[0])||(0,e.randomUUID)(),m=d.format;if(m===void 0&&d.out!==void 0&&(m=d.out.toLowerCase().endsWith(`.svg`)?`svg`:`png`),m??=`png`,m!==`png`&&m!==`svg`)return s(`--format must be "png" or "svg", got ${JSON.stringify(m)}`);let h=d.out??`${p.replace(/[^a-zA-Z0-9._-]/g,`_`).slice(0,100)}.${m}`,g={seed:p,size:d.size===void 0?void 0:c(`size`,d.size),scale:d.scale===void 0?16:c(`scale`,d.scale),color:d.color,bgcolor:d.bgcolor,spotcolor:d.spotcolor},_;try{_=m===`png`?(0,i.toPng)(g):(0,a.toSvg)(g)}catch(e){return s(e instanceof Error?e.message:String(e))}let v=(0,n.resolve)(process.cwd(),h);try{(0,t.mkdirSync)((0,n.dirname)(v),{recursive:!0}),(0,t.writeFileSync)(v,_)}catch(e){return s(e instanceof Error?e.message:String(e))}process.stdout.write(`${v} (${typeof _==`string`?_.length:_.byteLength} bytes)\n`)};exports.runCli=l,exports.version=o;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
+ //#region src/index.d.ts
1
2
  /** Version of `@pixid/cli`, baked in at build time. */
2
- declare const version: string;
3
+ export declare const version: string;
3
4
  /**
4
5
  * Runs the `pixid` command-line interface.
5
6
  *
@@ -10,6 +11,5 @@ declare const version: string;
10
11
  * @param argv Arguments after the executable and script name.
11
12
  * Defaults to `process.argv.slice(2)`.
12
13
  */
13
- declare const runCli: (argv?: string[]) => void;
14
-
15
- export { runCli, version };
14
+ export declare const runCli: (argv?: string[]) => void;
15
+ //#endregion
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ //#region src/index.d.ts
1
2
  /** Version of `@pixid/cli`, baked in at build time. */
2
- declare const version: string;
3
+ export declare const version: string;
3
4
  /**
4
5
  * Runs the `pixid` command-line interface.
5
6
  *
@@ -10,6 +11,5 @@ declare const version: string;
10
11
  * @param argv Arguments after the executable and script name.
11
12
  * Defaults to `process.argv.slice(2)`.
12
13
  */
13
- declare const runCli: (argv?: string[]) => void;
14
-
15
- export { runCli, version };
14
+ export declare const runCli: (argv?: string[]) => void;
15
+ //#endregion
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{randomUUID as m}from"crypto";import{writeFileSync as h}from"fs";import{resolve as b}from"path";import{parseArgs as v}from"util";import{toPng as y}from"@pixid/png";import{toSvg as x}from"@pixid/svg";var _="0.1.1",w=`pixid - blocky identicon generator
1
+ import{randomUUID as e}from"node:crypto";import{mkdirSync as t,writeFileSync as n}from"node:fs";import{dirname as r,resolve as i}from"node:path";import{parseArgs as a}from"node:util";import{toPng as o}from"@pixid/png";import{toSvg as s}from"@pixid/svg";const c=`0.2.0`,l=e=>{process.stderr.write(`pixid: ${e}\n\nRun "pixid --help" for usage.\n`),process.exit(1)},u=(e,t)=>{let n=Number(t);return!Number.isInteger(n)||n<1?l(`--${e} must be a positive integer, got ${JSON.stringify(t)}`):n},d=(d=process.argv.slice(2))=>{let f;try{f=a({args:d,allowPositionals:!0,options:{seed:{type:`string`,short:`s`},out:{type:`string`,short:`o`},format:{type:`string`,short:`f`},size:{type:`string`},scale:{type:`string`},color:{type:`string`},bgcolor:{type:`string`},spotcolor:{type:`string`},help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}}})}catch(e){return l(e instanceof Error?e.message:String(e))}let{values:p,positionals:m}=f;if(p.help){process.stdout.write(`pixid - blocky identicon generator
2
2
 
3
3
  Usage:
4
4
  pixid [seed] [options]
@@ -16,13 +16,8 @@ Options:
16
16
  -v, --version show the version
17
17
 
18
18
  Examples:
19
- npx pixid
20
- npx pixid 0x8ba1f109551bd432803012645ac136ddd64dba72
21
- npx pixid --seed alice --out alice.svg --scale 32
22
- npx pixid --format svg --bgcolor "#ffffff"
23
- `,t=s=>{process.stderr.write(`pixid: ${s}
24
-
25
- Run "pixid --help" for usage.
26
- `),process.exit(1)},l=(s,n)=>{let e=Number(n);return!Number.isInteger(e)||e<1?t(`--${s} must be a positive integer, got ${JSON.stringify(n)}`):e},I=(s=process.argv.slice(2))=>{let n;try{n=v({args:s,allowPositionals:!0,options:{seed:{type:"string",short:"s"},out:{type:"string",short:"o"},format:{type:"string",short:"f"},size:{type:"string"},scale:{type:"string"},color:{type:"string"},bgcolor:{type:"string"},spotcolor:{type:"string"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}})}catch(r){return t(r instanceof Error?r.message:String(r))}let{values:e,positionals:g}=n;if(e.help){process.stdout.write(w);return}if(e.version){process.stdout.write(`${_}
27
- `);return}if(g.length>1)return t(`expected at most one positional argument, got ${g.length}`);if(e.seed!==void 0&&g.length>0)return t("pass the seed either as a positional argument or with --seed, not both");let p=e.seed??g[0]??m(),o=e.format;if(o===void 0&&e.out!==void 0&&(o=e.out.toLowerCase().endsWith(".svg")?"svg":"png"),o??="png",o!=="png"&&o!=="svg")return t(`--format must be "png" or "svg", got ${JSON.stringify(o)}`);let d=e.out??`${p.replace(/[^a-zA-Z0-9._-]/g,"_")}.${o}`,f=e.size===void 0?void 0:l("size",e.size),u=e.scale===void 0?16:l("scale",e.scale),a={seed:p,size:f,scale:u,color:e.color,bgcolor:e.bgcolor,spotcolor:e.spotcolor},i;try{i=o==="png"?y(a):x(a)}catch(r){return t(r instanceof Error?r.message:String(r))}let c=b(process.cwd(),d);h(c,i),process.stdout.write(`${c} (${typeof i=="string"?i.length:i.byteLength} bytes)
28
- `)};export{I as runCli,_ as version};
19
+ npx @pixid/cli
20
+ npx @pixid/cli 0x8ba1f109551bd432803012645ac136ddd64dba72
21
+ npx @pixid/cli --seed alice --out alice.svg --scale 32
22
+ npx @pixid/cli --format svg --bgcolor "#ffffff"
23
+ `);return}if(p.version){process.stdout.write(`${c}\n`);return}if(m.length>1)return l(`expected at most one positional argument, got ${m.length}`);if(p.seed!==void 0&&m.length>0)return l(`pass the seed either as a positional argument or with --seed, not both`);let h=(p.seed??m[0])||e(),g=p.format;if(g===void 0&&p.out!==void 0&&(g=p.out.toLowerCase().endsWith(`.svg`)?`svg`:`png`),g??=`png`,g!==`png`&&g!==`svg`)return l(`--format must be "png" or "svg", got ${JSON.stringify(g)}`);let _=p.out??`${h.replace(/[^a-zA-Z0-9._-]/g,`_`).slice(0,100)}.${g}`,v={seed:h,size:p.size===void 0?void 0:u(`size`,p.size),scale:p.scale===void 0?16:u(`scale`,p.scale),color:p.color,bgcolor:p.bgcolor,spotcolor:p.spotcolor},y;try{y=g===`png`?o(v):s(v)}catch(e){return l(e instanceof Error?e.message:String(e))}let b=i(process.cwd(),_);try{t(r(b),{recursive:!0}),n(b,y)}catch(e){return l(e instanceof Error?e.message:String(e))}process.stdout.write(`${b} (${typeof y==`string`?y.length:y.byteLength} bytes)\n`)};export{d as runCli,c as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixid/cli",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Command-line blocky identicon generator. Writes deterministic PNG or SVG identicons from any seed string (npx @pixid/cli).",
5
5
  "keywords": [
6
6
  "identicon",
@@ -16,7 +16,7 @@
16
16
  "author": "thilllon",
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "https://github.com/thilllon/pixid.git",
19
+ "url": "git+https://github.com/thilllon/pixid.git",
20
20
  "directory": "packages/cli"
21
21
  },
22
22
  "homepage": "https://github.com/thilllon/pixid",
@@ -32,9 +32,14 @@
32
32
  "types": "./dist/index.d.ts",
33
33
  "exports": {
34
34
  ".": {
35
- "types": "./dist/index.d.ts",
36
- "import": "./dist/index.js",
37
- "require": "./dist/index.cjs"
35
+ "import": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.js"
38
+ },
39
+ "require": {
40
+ "types": "./dist/index.d.cts",
41
+ "default": "./dist/index.cjs"
42
+ }
38
43
  },
39
44
  "./run": "./dist/cli.js",
40
45
  "./package.json": "./package.json"
@@ -46,16 +51,19 @@
46
51
  "dist"
47
52
  ],
48
53
  "dependencies": {
49
- "@pixid/png": "^0.1.1",
50
- "@pixid/svg": "^0.1.1"
54
+ "@pixid/png": "^0.2.0",
55
+ "@pixid/svg": "^0.2.0"
56
+ },
57
+ "devDependencies": {
58
+ "verdaccio": "^6.10.3"
51
59
  },
52
60
  "publishConfig": {
53
61
  "access": "public"
54
62
  },
55
63
  "engines": {
56
- "node": ">=18"
64
+ "node": ">=18.3.0"
57
65
  },
58
66
  "scripts": {
59
- "build": "tsup"
67
+ "build": "tsdown"
60
68
  }
61
69
  }