dicebear 8.0.2 → 9.0.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/LICENSE +1 -1
- package/README.md +6 -6
- package/lib/utils/addStyleCommand.d.ts +1 -1
- package/lib/utils/addStyleCommand.js +6 -4
- package/lib/utils/writeFile.d.ts +1 -0
- package/lib/utils/writeFile.js +14 -0
- package/package.json +6 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<h1><img src="https://www.dicebear.com/logo-readme.svg" width="28" /> DiceBear CLI</h1>
|
|
2
2
|
|
|
3
3
|
<p>
|
|
4
|
-
<img src="https://api.dicebear.com/
|
|
5
|
-
<img src="https://api.dicebear.com/
|
|
6
|
-
<img src="https://api.dicebear.com/
|
|
7
|
-
<img src="https://api.dicebear.com/
|
|
8
|
-
<img src="https://api.dicebear.com/
|
|
9
|
-
<img src="https://api.dicebear.com/
|
|
4
|
+
<img src="https://api.dicebear.com/9.x/adventurer/svg?seed=Mimi&backgroundColor=0077b6&radius=10" width="64" />
|
|
5
|
+
<img src="https://api.dicebear.com/9.x/open-peeps/svg?seed=Kitty&backgroundColor=0096c7&radius=10" width="64" />
|
|
6
|
+
<img src="https://api.dicebear.com/9.x/pixel-art/svg?seed=Lilly&backgroundColor=00b4d8&radius=10" width="64" />
|
|
7
|
+
<img src="https://api.dicebear.com/9.x/lorelei/svg?seed=Tigger&backgroundColor=48cae4&radius=10" width="64" />
|
|
8
|
+
<img src="https://api.dicebear.com/9.x/bottts/svg?seed=Zoe&backgroundColor=90e0ef&radius=10" width="64" />
|
|
9
|
+
<img src="https://api.dicebear.com/9.x/initials/svg?seed=..&backgroundColor=ade8f4&radius=10" width="64" />
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
[Playground](https://www.dicebear.com/playground) |
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAvatar } from '@dicebear/core';
|
|
2
|
+
import { toJpeg, toPng } from '@dicebear/converter';
|
|
2
3
|
import cliProgress from 'cli-progress';
|
|
3
4
|
import PQueue from 'p-queue';
|
|
4
5
|
import os from 'node:os';
|
|
@@ -10,6 +11,7 @@ import { getOptionsBySchema } from './getOptionsBySchema.js';
|
|
|
10
11
|
import { validateInputBySchema } from './validateInputBySchema.js';
|
|
11
12
|
import { outputStyleLicenseBanner } from './outputStyleLicenseBanner.js';
|
|
12
13
|
import { createRandomSeed } from './createRandomSeed.js';
|
|
14
|
+
import { writeFile } from './writeFile.js';
|
|
13
15
|
export function addStyleCommand(cli, name, style) {
|
|
14
16
|
const schema = getStyleCommandSchema(style);
|
|
15
17
|
return cli.command({
|
|
@@ -46,17 +48,17 @@ export function addStyleCommand(cli, name, style) {
|
|
|
46
48
|
});
|
|
47
49
|
switch (format) {
|
|
48
50
|
case 'svg':
|
|
49
|
-
await avatar.
|
|
51
|
+
await writeFile(fileName, avatar.toString());
|
|
50
52
|
break;
|
|
51
53
|
case 'png':
|
|
52
|
-
await avatar.
|
|
54
|
+
await writeFile(fileName, await toPng(avatar.toString(), { includeExif }).toArrayBuffer());
|
|
53
55
|
break;
|
|
54
56
|
case 'jpg':
|
|
55
57
|
case 'jpeg':
|
|
56
|
-
await avatar.
|
|
58
|
+
await writeFile(fileName, await toJpeg(avatar.toString(), { includeExif }).toArrayBuffer());
|
|
57
59
|
break;
|
|
58
60
|
case 'json':
|
|
59
|
-
await
|
|
61
|
+
await writeFile(fileName, JSON.stringify(avatar.toJson(), null, 2));
|
|
60
62
|
break;
|
|
61
63
|
}
|
|
62
64
|
if (json && 'json' !== format) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writeFile(filePath: string, content: string | ArrayBuffer): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export async function writeFile(filePath, content) {
|
|
4
|
+
if (fs.existsSync(filePath)) {
|
|
5
|
+
throw new Error(`File already exists at ${filePath}`);
|
|
6
|
+
}
|
|
7
|
+
fs.ensureDir(path.dirname(filePath));
|
|
8
|
+
if (typeof content === 'string') {
|
|
9
|
+
await fs.writeFile(filePath, content);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
await fs.writeFile(filePath, new Uint8Array(content));
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dicebear",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "CLI for DiceBear - An avatar library for designers and developers",
|
|
6
6
|
"homepage": "https://github.com/dicebear/dicebear",
|
|
@@ -25,18 +25,16 @@
|
|
|
25
25
|
"prepublishOnly": "npm run build"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@dicebear/collection": "
|
|
29
|
-
"@dicebear/
|
|
30
|
-
"@
|
|
28
|
+
"@dicebear/collection": "9.0.0",
|
|
29
|
+
"@dicebear/converter": "9.0.0",
|
|
30
|
+
"@dicebear/core": "9.0.0",
|
|
31
31
|
"ajv": "^8.12.0",
|
|
32
32
|
"chalk": "^5.2.0",
|
|
33
33
|
"chalk-template": "^1.0.0",
|
|
34
34
|
"cli-progress": "^3.12.0",
|
|
35
|
-
"exiftool-vendored": "^23.0.0",
|
|
36
35
|
"fs-extra": "^11.1.1",
|
|
37
36
|
"json-schema-merge-allof": "^0.8.1",
|
|
38
37
|
"p-queue": "^7.3.4",
|
|
39
|
-
"sharp": "^0.32.6",
|
|
40
38
|
"update-notifier": "^6.0.2",
|
|
41
39
|
"yargs": "^17.7.1"
|
|
42
40
|
},
|
|
@@ -51,7 +49,7 @@
|
|
|
51
49
|
"typescript": "^5.1.6"
|
|
52
50
|
},
|
|
53
51
|
"engines": {
|
|
54
|
-
"node": ">=
|
|
52
|
+
"node": ">=18.0.0"
|
|
55
53
|
},
|
|
56
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "c9e66450840d4f29faee6362249348bb3d18798b"
|
|
57
55
|
}
|