dicebear 10.0.0-rc.2 → 10.0.0-rc.3

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.
@@ -1,3 +1,7 @@
1
1
  import type { Style } from '@dicebear/core';
2
2
  import yargs from 'yargs';
3
- export declare function addStyleCommand(cli: yargs.Argv<{}>, name: string, style: Style): yargs.Argv<{}>;
3
+ /**
4
+ * Registers a `<name> [outputPath]` subcommand on the given yargs instance,
5
+ * wired up to render avatars for the given style.
6
+ */
7
+ export declare function addStyleCommand(cli: yargs.Argv<Record<string, unknown>>, name: string, style: Style): yargs.Argv<Record<string, unknown>>;
@@ -1,6 +1,10 @@
1
1
  import chalk from 'chalk';
2
2
  import { getStyleCommandOptions } from './getStyleCommandOptions.js';
3
3
  import { handleStyleCommand } from './handleStyleCommand.js';
4
+ /**
5
+ * Registers a `<name> [outputPath]` subcommand on the given yargs instance,
6
+ * wired up to render avatars for the given style.
7
+ */
4
8
  export function addStyleCommand(cli, name, style) {
5
9
  const options = getStyleCommandOptions(style);
6
10
  return cli.command({
@@ -1 +1,6 @@
1
+ /**
2
+ * Returns a short, base-36-encoded random string suitable as an ad-hoc avatar
3
+ * seed. Uses `Math.random()` — not cryptographically secure, but sufficient
4
+ * for generating distinct sample avatars from the CLI.
5
+ */
1
6
  export declare function createRandomSeed(): string;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Returns a short, base-36-encoded random string suitable as an ad-hoc avatar
3
+ * seed. Uses `Math.random()` — not cryptographically secure, but sufficient
4
+ * for generating distinct sample avatars from the CLI.
5
+ */
1
6
  export function createRandomSeed() {
2
7
  return Math.random().toString(36).substring(2);
3
8
  }
@@ -1,2 +1,8 @@
1
1
  import { Style } from '@dicebear/core';
2
+ /**
3
+ * Extracts only the style-relevant options from the yargs argv object,
4
+ * filtering out CLI-specific keys (`_`, `$0`, `outputPath`, `count`,
5
+ * `format`, etc.) and converting weighted/range values into the shapes the
6
+ * core resolver expects.
7
+ */
2
8
  export declare function extractStyleOptions(argv: Record<string, unknown>, style: Style): Record<string, unknown>;
@@ -1,5 +1,9 @@
1
1
  import { OptionsDescriptor } from '@dicebear/core';
2
- // Parses ['variant01:2', 'variant03:1'] (array from yargs) into { variant01: 2, variant03: 1 }
2
+ /**
3
+ * Parses `['variant01:2', 'variant03:1']` (yargs array form) into a
4
+ * `{ variant01: 2, variant03: 1 }` weight map. Entries without a colon
5
+ * default to weight `1`.
6
+ */
3
7
  function parseWeightedValue(value) {
4
8
  const result = {};
5
9
  for (const pair of value) {
@@ -10,7 +14,11 @@ function parseWeightedValue(value) {
10
14
  }
11
15
  return result;
12
16
  }
13
- // Parses "10,50" into [10, 50] for range values
17
+ /**
18
+ * Parses a comma-separated string like `"10,50"` into a `[min, max]` tuple
19
+ * for range options. Passes the value through unchanged when it does not
20
+ * match the two-number form.
21
+ */
14
22
  function parseRangeValue(value) {
15
23
  if (typeof value === 'string' && value.includes(',')) {
16
24
  const parts = value.split(',').map(Number);
@@ -20,8 +28,12 @@ function parseRangeValue(value) {
20
28
  }
21
29
  return value;
22
30
  }
23
- // Extracts only the style-relevant options from the yargs argv object,
24
- // filtering out CLI-specific keys (_, $0, outputPath, count, format, etc.).
31
+ /**
32
+ * Extracts only the style-relevant options from the yargs argv object,
33
+ * filtering out CLI-specific keys (`_`, `$0`, `outputPath`, `count`,
34
+ * `format`, etc.) and converting weighted/range values into the shapes the
35
+ * core resolver expects.
36
+ */
25
37
  export function extractStyleOptions(argv, style) {
26
38
  const descriptor = new OptionsDescriptor(style).toJSON();
27
39
  const result = {};
@@ -1,2 +1,6 @@
1
1
  import type { Package } from 'update-notifier';
2
+ /**
3
+ * Reads the CLI's own `package.json` from disk. Used by `update-notifier` to
4
+ * compare the running version against the latest published one.
5
+ */
2
6
  export declare function getPackageJson(): Promise<Package>;
@@ -1,4 +1,8 @@
1
1
  import fs from 'fs-extra';
2
+ /**
3
+ * Reads the CLI's own `package.json` from disk. Used by `update-notifier` to
4
+ * compare the running version against the latest published one.
5
+ */
2
6
  export function getPackageJson() {
3
7
  const packageJson = new URL('../../package.json', import.meta.url).pathname;
4
8
  return fs.readJson(packageJson);
@@ -1,3 +1,8 @@
1
1
  import { Style } from '@dicebear/core';
2
2
  import type { Options } from 'yargs';
3
+ /**
4
+ * Builds the yargs options map for a single style command. Combines the
5
+ * shared CLI flags (`count`, `format`, `exif`, `json`) with one entry per
6
+ * field returned by the style's {@link OptionsDescriptor}.
7
+ */
3
8
  export declare function getStyleCommandOptions(style: Style): Record<string, Options>;
@@ -1,4 +1,9 @@
1
1
  import { OptionsDescriptor } from '@dicebear/core';
2
+ /**
3
+ * Builds the yargs options map for a single style command. Combines the
4
+ * shared CLI flags (`count`, `format`, `exif`, `json`) with one entry per
5
+ * field returned by the style's {@link OptionsDescriptor}.
6
+ */
2
7
  export function getStyleCommandOptions(style) {
3
8
  const descriptor = new OptionsDescriptor(style).toJSON();
4
9
  const result = {
@@ -1,3 +1,8 @@
1
1
  import { Style } from '@dicebear/core';
2
2
  import type { ArgumentsCamelCase } from 'yargs';
3
- export declare function handleStyleCommand(argv: ArgumentsCamelCase<{}>, name: string, style: Style): Promise<void>;
3
+ /**
4
+ * Handles a single style subcommand: renders the requested number of avatars
5
+ * in the chosen format, writes them to the output directory, and reports
6
+ * progress on a CLI progress bar.
7
+ */
8
+ export declare function handleStyleCommand(argv: ArgumentsCamelCase<Record<string, unknown>>, name: string, style: Style): Promise<void>;
@@ -10,6 +10,11 @@ import { extractStyleOptions } from './extractStyleOptions.js';
10
10
  import { outputStyleLicenseBanner } from './outputStyleLicenseBanner.js';
11
11
  import { createRandomSeed } from './createRandomSeed.js';
12
12
  import { writeFile } from './writeFile.js';
13
+ /**
14
+ * Handles a single style subcommand: renders the requested number of avatars
15
+ * in the chosen format, writes them to the output directory, and reports
16
+ * progress on a CLI progress bar.
17
+ */
13
18
  export async function handleStyleCommand(argv, name, style) {
14
19
  var _a, _b, _c, _d;
15
20
  const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
@@ -1,4 +1,9 @@
1
1
  import { Style } from '@dicebear/core';
2
+ /**
3
+ * Reads a style definition JSON file from disk, validates it via {@link Style},
4
+ * and returns the wrapped style together with a name derived from the file
5
+ * basename.
6
+ */
2
7
  export declare function loadDefinition(filePath: string): {
3
8
  style: Style;
4
9
  name: string;
@@ -1,6 +1,11 @@
1
1
  import { Style } from '@dicebear/core';
2
2
  import * as fs from 'node:fs';
3
3
  import * as path from 'node:path';
4
+ /**
5
+ * Reads a style definition JSON file from disk, validates it via {@link Style},
6
+ * and returns the wrapped style together with a name derived from the file
7
+ * basename.
8
+ */
4
9
  export function loadDefinition(filePath) {
5
10
  const definitionPath = path.resolve(process.cwd(), filePath);
6
11
  const definition = JSON.parse(fs.readFileSync(definitionPath, 'utf-8'));
@@ -1,2 +1,6 @@
1
1
  import { Style } from '@dicebear/core';
2
+ /**
3
+ * Loads every minified definition shipped by `@dicebear/definitions`, wraps
4
+ * each in a {@link Style}, and returns them keyed by style name.
5
+ */
2
6
  export declare function loadStyles(): Map<string, Style>;
@@ -3,6 +3,10 @@ import { createRequire } from 'node:module';
3
3
  import * as path from 'node:path';
4
4
  import * as fs from 'node:fs';
5
5
  const require = createRequire(import.meta.url);
6
+ /**
7
+ * Loads every minified definition shipped by `@dicebear/definitions`, wraps
8
+ * each in a {@link Style}, and returns them keyed by style name.
9
+ */
6
10
  export function loadStyles() {
7
11
  const definitionsDir = path.dirname(require.resolve('@dicebear/definitions/initials.json'));
8
12
  const styles = new Map();
@@ -1,2 +1,6 @@
1
1
  import type { Style } from '@dicebear/core';
2
+ /**
3
+ * Prints a colorized attribution banner with the style's source, creator,
4
+ * and license info to stdout. Skipped sections are omitted silently.
5
+ */
2
6
  export declare function outputStyleLicenseBanner(name: string, style: Style): void;
@@ -1,5 +1,9 @@
1
1
  import chalk from 'chalk';
2
2
  import chalkTemplate from 'chalk-template';
3
+ /**
4
+ * Prints a colorized attribution banner with the style's source, creator,
5
+ * and license info to stdout. Skipped sections are omitted silently.
6
+ */
3
7
  export function outputStyleLicenseBanner(name, style) {
4
8
  const meta = style.meta();
5
9
  const sourceName = meta.source().name();
@@ -1 +1,5 @@
1
+ /**
2
+ * Writes a string or binary buffer to disk, refusing to overwrite an
3
+ * existing file. Creates intermediate directories as needed.
4
+ */
1
5
  export declare function writeFile(filePath: string, content: string | ArrayBufferLike): Promise<void>;
@@ -1,5 +1,9 @@
1
1
  import fs from 'fs-extra';
2
2
  import path from 'node:path';
3
+ /**
4
+ * Writes a string or binary buffer to disk, refusing to overwrite an
5
+ * existing file. Creates intermediate directories as needed.
6
+ */
3
7
  export async function writeFile(filePath, content) {
4
8
  if (fs.existsSync(filePath)) {
5
9
  throw new Error(`File already exists at ${filePath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dicebear",
3
- "version": "10.0.0-rc.2",
3
+ "version": "10.0.0-rc.3",
4
4
  "private": false,
5
5
  "description": "CLI for DiceBear — unique avatars from dozens of styles.",
6
6
  "homepage": "https://github.com/dicebear/dicebear",
@@ -25,9 +25,9 @@
25
25
  "prepublishOnly": "npm run build"
26
26
  },
27
27
  "dependencies": {
28
- "@dicebear/converter": "10.0.0-rc.2",
29
- "@dicebear/core": "10.0.0-rc.2",
30
- "@dicebear/definitions": "^0.1.0",
28
+ "@dicebear/converter": "10.0.0-rc.3",
29
+ "@dicebear/core": "10.0.0-rc.3",
30
+ "@dicebear/definitions": "^10.0.0-rc.6",
31
31
  "ajv": "^8.17.1",
32
32
  "chalk": "^5.4.1",
33
33
  "chalk-template": "^1.1.2",