magic-glyphs 0.6.0 → 0.6.1
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/cli/index.js +16 -4
- package/data/licence-public.pem +1 -1
- package/docs/cli.md +2 -1
- package/lib.js +1 -1
- package/licence.js +3 -2
- package/package.json +3 -2
package/cli/index.js
CHANGED
|
@@ -14,7 +14,8 @@ Usage
|
|
|
14
14
|
magic-glyphs bundle [name...] [--out <file>] one script for web pages: the runtime plus the icons you name (all if none)
|
|
15
15
|
magic-glyphs static [--out <dir>] [--styles outline,solid,duotone] plain SVG files and sprites, no JavaScript
|
|
16
16
|
magic-glyphs registry [--out <dir>] [--homepage <url>] shadcn registry files to host
|
|
17
|
-
magic-glyphs login
|
|
17
|
+
magic-glyphs login YOUR-KEY | sync | logout | licence paid icons need a licence key; sync re-downloads the full set
|
|
18
|
+
magic-glyphs buy open the page where you can buy a licence
|
|
18
19
|
|
|
19
20
|
Options for add
|
|
20
21
|
--format <f> svg (default) | lottie | react | vue | json | html
|
|
@@ -53,6 +54,15 @@ async function download(){
|
|
|
53
54
|
const text=await r.text(),d=JSON.parse(text);if(!d||!Array.isArray(d.icons))throw new Error('the server sent something unexpected');
|
|
54
55
|
fs.mkdirSync(Lic.home(),{recursive:true});fs.writeFileSync(L.fullFile(),text);return d.icons.length}
|
|
55
56
|
function fail(msg){process.stderr.write('magic-glyphs: '+msg+'\n');process.exit(1)}
|
|
57
|
+
// where to buy a licence; MAGIC_GLYPHS_BUY or package.json "magicGlyphs.buy"
|
|
58
|
+
const buyUrl=()=>process.env.MAGIC_GLYPHS_BUY||(require('../package.json').magicGlyphs||{}).buy||'';
|
|
59
|
+
const BUYLINE=()=>buyUrl()?'Buy a licence: '+buyUrl()+' (or run: npx magic-glyphs buy)':'';
|
|
60
|
+
// open the buy page in the browser, only for a person at a terminal (never in CI or when MAGIC_GLYPHS_NO_OPEN is set)
|
|
61
|
+
function openBuy(){const u=buyUrl();if(!u)return false;
|
|
62
|
+
if(!process.stdout.isTTY||process.env.CI||process.env.MAGIC_GLYPHS_NO_OPEN)return false;
|
|
63
|
+
const cp=require('child_process');const [c,a]=process.platform==='win32'?['cmd',['/c','start','""',u]]:process.platform==='darwin'?['open',[u]]:['xdg-open',[u]];
|
|
64
|
+
try{const ch=cp.spawn(c,a,{stdio:'ignore',detached:true});ch.on('error',()=>{});ch.unref();return true}catch(e){return false}}
|
|
65
|
+
function failBuy(msg){process.stderr.write('magic-glyphs: '+msg+'\n');const b=BUYLINE();if(b)process.stderr.write(b+'\n');process.exit(1)}
|
|
56
66
|
const {pos,opt}=parse(process.argv.slice(2)),cmd=pos.shift();
|
|
57
67
|
try{
|
|
58
68
|
if(!cmd||opt.help||cmd==='help'){process.stdout.write(HELP);process.exit(cmd||opt.help?0:1)}
|
|
@@ -66,7 +76,7 @@ try{
|
|
|
66
76
|
else rows.forEach(r=>console.log(r.name.padEnd(28)+r.category.padEnd(11)+r.tags));
|
|
67
77
|
}
|
|
68
78
|
else if(cmd==='info'){
|
|
69
|
-
if(!pos[0])fail('Give an icon name.');const ic=L.byName.get(pos[0]);if(!ic)fail(L.known.has(pos[0])?'"'+pos[0]+'" is in the paid set. Run: magic-glyphs login
|
|
79
|
+
if(!pos[0])fail('Give an icon name.');const ic=L.byName.get(pos[0]);if(!ic)fail(L.known.has(pos[0])?'"'+pos[0]+'" is in the paid set. Run: magic-glyphs login YOUR-KEY'+(buyUrl()?'\n'+BUYLINE():''):'No icon named "'+pos[0]+'". Try: magic-glyphs search '+pos[0]);
|
|
70
80
|
console.log(['name '+ic.n,'category '+ic.c,'tags '+ic.t,'layers '+ic.L.map(l=>l.i).join(', '),'animated '+(ic.A.length?'yes ('+ic.A.length+' spring'+(ic.A.length>1?'s':'')+')':'no'),'html <magic-glyph name="'+ic.n+'"></magic-glyph>'].join('\n'));
|
|
71
81
|
}
|
|
72
82
|
else if(cmd==='add'){
|
|
@@ -84,9 +94,11 @@ try{
|
|
|
84
94
|
console.log((opt['dry-run']?'Would write ':'Wrote ')+files.length+' file'+(files.length>1?'s':'')+' to '+dir+(files.length<=6?': '+files.map(f=>f.file).join(', '):''));
|
|
85
95
|
if(format==='react'||format==='vue')console.log('These components import from the "magic-glyphs" package, so keep it installed.');}
|
|
86
96
|
}
|
|
97
|
+
else if(cmd==='buy'){const u=buyUrl();if(!u)fail('No buy page is configured.');console.log(u);if(openBuy())console.log('Opened in your browser.')}
|
|
87
98
|
else if(cmd==='login'||cmd==='sync'){
|
|
88
|
-
if(cmd==='login'){if(!pos[0])
|
|
89
|
-
|
|
99
|
+
if(cmd==='login'){if(!pos[0]||/^<.*>$/.test(pos[0])||/gumroad-key|your-.*key|^x{8}(-x{8}){3}$/i.test(pos[0])){const o=openBuy();
|
|
100
|
+
failBuy('Give the licence key from your Gumroad receipt, like: magic-glyphs login ABCD1234-EFGH5678-IJKL9012-MNOP3456'+(o?'\nOpening the buy page in your browser.':''))}
|
|
101
|
+
if(!/^MG1\./.test(pos[0].trim())){redeem(pos[0].trim()).then(k=>{const p=Lic.login(k);console.log('Licence saved for '+p.email+' ('+p.plan+', '+p.seats+' seat'+(p.seats>1?'s':'')+').');return download()}).then(n=>console.log(n?'Downloaded the full set: '+n+' icons.':'This copy already has every icon.')).catch(e=>failBuy(e.message));return}
|
|
90
102
|
const p=Lic.login(pos[0]);console.log('Licence saved for '+p.email+' ('+p.plan+', '+p.seats+' seat'+(p.seats>1?'s':'')+').')}
|
|
91
103
|
else if(!Lic.current().ok)fail(Lic.current().reason);
|
|
92
104
|
download().then(n=>console.log(n?'Downloaded the full set: '+n+' icons.':'This copy already has every icon.')).catch(e=>fail('The key is saved, but the full set could not be downloaded ('+e.message+'). Try again with: magic-glyphs sync'));}
|
package/data/licence-public.pem
CHANGED
package/docs/cli.md
CHANGED
|
@@ -56,7 +56,8 @@ Files for non-outline styles carry the style in the name, for example `heart.duo
|
|
|
56
56
|
## Licence and bundles
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
npx magic-glyphs login
|
|
59
|
+
npx magic-glyphs login YOUR-LICENCE-KEY # the key from your Gumroad receipt (no < > around it); downloads the full library
|
|
60
|
+
npx magic-glyphs buy # opens the page where you can buy a licence
|
|
60
61
|
npx magic-glyphs licence # who this computer is licensed to
|
|
61
62
|
npx magic-glyphs licence --show-key # prints the key to use on a build server
|
|
62
63
|
npx magic-glyphs sync # download the full library again
|
package/lib.js
CHANGED
|
@@ -42,7 +42,7 @@ function staticSvg(name,o){
|
|
|
42
42
|
.replace(/currentColor/g,col).replace(' overflow="visible"','');
|
|
43
43
|
}
|
|
44
44
|
function render(name,format,o){
|
|
45
|
-
const ic=byName.get(name);if(!ic)throw new Error(known.has(name)?'"'+name+'" is in the paid set and is not on this computer yet. Run: magic-glyphs login
|
|
45
|
+
const ic=byName.get(name);if(!ic)throw new Error(known.has(name)?'"'+name+'" is in the paid set and is not on this computer yet. Run: magic-glyphs login YOUR-KEY':'No icon named "'+name+'". Try: magic-glyphs search '+name);
|
|
46
46
|
o=o||{};const style=o.style||'outline';
|
|
47
47
|
if(!STYLES.includes(style))throw new Error('Unknown style "'+style+'". Use one of: '+STYLES.join(', '));
|
|
48
48
|
switch(format){
|
package/licence.js
CHANGED
|
@@ -26,11 +26,12 @@ function verify(key,publicPem){
|
|
|
26
26
|
if(payload.expires&&payload.expires<new Date().toISOString().slice(0,10))return{ok:false,reason:'This licence expired on '+payload.expires+'.',payload};
|
|
27
27
|
return{ok:true,payload};}
|
|
28
28
|
function storedKey(){if(process.env.MAGIC_GLYPHS_KEY)return process.env.MAGIC_GLYPHS_KEY;try{return JSON.parse(fs.readFileSync(storeFile(),'utf8')).key}catch(e){return null}}
|
|
29
|
-
function current(){const k=storedKey();return k?verify(k):{ok:false,reason:'No licence key. Run: magic-glyphs login
|
|
29
|
+
function current(){const k=storedKey();return k?verify(k):{ok:false,reason:'No licence key. Run: magic-glyphs login YOUR-KEY'}}
|
|
30
30
|
function login(key){const r=verify(key);if(!r.ok)throw new Error(r.reason);fs.mkdirSync(home(),{recursive:true});fs.writeFileSync(storeFile(),JSON.stringify({key:key.trim()}),{mode:0o600});return r.payload}
|
|
31
31
|
function logout(){try{fs.unlinkSync(storeFile());return true}catch(e){return false}}
|
|
32
32
|
const isFree=n=>FREE.has(n);
|
|
33
33
|
// names the caller may not export yet; empty when licensed or when every name is in the free set
|
|
34
34
|
function locked(names){const paid=names.filter(n=>!FREE.has(n));if(!paid.length)return[];return current().ok?[]:paid}
|
|
35
|
-
function lockedMessage(paid){return (paid.length===1?'"'+paid[0]+'" is':paid.length+' of these icons are')+' in the paid set. '+current().reason.replace(/^No licence key\. /,'')+(paid.length>1&&paid.length<=8?' Paid: '+paid.join(', ')+'.':'')+' Free icons: magic-glyphs list --free'}
|
|
35
|
+
function lockedMessage(paid){return (paid.length===1?'"'+paid[0]+'" is':paid.length+' of these icons are')+' in the paid set. '+current().reason.replace(/^No licence key\. /,'')+(paid.length>1&&paid.length<=8?' Paid: '+paid.join(', ')+'.':'')+' Free icons: magic-glyphs list --free'+buyLine()}
|
|
36
|
+
function buyLine(){let u=process.env.MAGIC_GLYPHS_BUY;if(!u)try{u=(require('./package.json').magicGlyphs||{}).buy}catch(e){}return u?'\nBuy a licence: '+u+' (or run: npx magic-glyphs buy)':''}
|
|
36
37
|
module.exports={home,FREE,PLANS,keygen,issue,verify,current,login,logout,isFree,locked,lockedMessage,storeFile};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magic-glyphs",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Animated icons with spring motion and sound: web component, React, Vue, static SVG, Lottie export and a CLI. 120 icons free.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "Lewis John Villamor",
|
|
@@ -68,7 +68,8 @@
|
|
|
68
68
|
"mcp"
|
|
69
69
|
],
|
|
70
70
|
"magicGlyphs": {
|
|
71
|
-
"api": "https://magic-glyphs-licence.lewisvillamor26.workers.dev"
|
|
71
|
+
"api": "https://magic-glyphs-licence.lewisvillamor26.workers.dev",
|
|
72
|
+
"buy": "https://magicscraper.gumroad.com/l/vjaxbp"
|
|
72
73
|
},
|
|
73
74
|
"homepage": "https://magic-glyphs-site.lewisvillamor26.workers.dev"
|
|
74
75
|
}
|