dicebear 10.0.0-rc.5 → 10.0.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/lib/index.js CHANGED
@@ -3,6 +3,7 @@ import yargs from 'yargs';
3
3
  import { hideBin } from 'yargs/helpers';
4
4
  import chalk from 'chalk';
5
5
  import { getPackageJson } from './utils/getPackageJson.js';
6
+ import { resolveDefinitionPath } from './utils/resolveDefinitionPath.js';
6
7
  import { addStyleCommand } from './utils/addStyleCommand.js';
7
8
  import { loadStyles } from './utils/loadStyles.js';
8
9
  import { loadDefinition } from './utils/loadDefinition.js';
@@ -20,8 +21,7 @@ import { getStyleCommandOptions } from './utils/getStyleCommandOptions.js';
20
21
  command: '* <definition> [outputPath]',
21
22
  describe: false,
22
23
  builder: (yargs) => {
23
- const args = hideBin(process.argv);
24
- const filePath = args[0];
24
+ const filePath = resolveDefinitionPath(hideBin(process.argv));
25
25
  let options = {};
26
26
  if (filePath) {
27
27
  try {
@@ -48,5 +48,5 @@ import { getStyleCommandOptions } from './utils/getStyleCommandOptions.js';
48
48
  }
49
49
  },
50
50
  });
51
- cli.demandCommand().help().locale('en').parse();
51
+ cli.demandCommand().help().version(pkg.version).locale('en').parse();
52
52
  })();
@@ -33,9 +33,15 @@ export function getStyleCommandOptions(style) {
33
33
  switch (field.type) {
34
34
  case 'string':
35
35
  option.type = 'string';
36
+ if (field.list) {
37
+ option.array = true;
38
+ }
36
39
  break;
37
40
  case 'number':
38
41
  option.type = 'number';
42
+ if (field.list) {
43
+ option.array = true;
44
+ }
39
45
  break;
40
46
  case 'range':
41
47
  option.type = 'string';
@@ -45,12 +51,18 @@ export function getStyleCommandOptions(style) {
45
51
  break;
46
52
  case 'enum':
47
53
  option.type = 'string';
54
+ if (field.list) {
55
+ option.array = true;
56
+ }
48
57
  if (!field.weighted) {
49
58
  option.choices = field.values;
50
59
  }
51
60
  break;
52
61
  case 'color':
53
62
  option.type = 'string';
63
+ if (field.list) {
64
+ option.array = true;
65
+ }
54
66
  break;
55
67
  }
56
68
  result[key] = option;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Extracts the definition file path (the first positional argument) from the
3
+ * raw CLI arguments.
4
+ *
5
+ * Flags and the values they consume are ignored, so invocations like
6
+ * `--count 2 my-style.json`, `my-style.json --count 2`, or `--version`
7
+ * resolve correctly instead of mistaking a flag (or a flag's value) for the
8
+ * definition path. Pass the result of `hideBin(process.argv)`.
9
+ */
10
+ export declare function resolveDefinitionPath(args: string[]): string | undefined;
@@ -0,0 +1,19 @@
1
+ import { Parser } from 'yargs/helpers';
2
+ /**
3
+ * Extracts the definition file path (the first positional argument) from the
4
+ * raw CLI arguments.
5
+ *
6
+ * Flags and the values they consume are ignored, so invocations like
7
+ * `--count 2 my-style.json`, `my-style.json --count 2`, or `--version`
8
+ * resolve correctly instead of mistaking a flag (or a flag's value) for the
9
+ * definition path. Pass the result of `hideBin(process.argv)`.
10
+ */
11
+ export function resolveDefinitionPath(args) {
12
+ // yargs' built-in `--help`/`--version` and the CLI's generic `--exif`/`--json`
13
+ // flags are boolean. Declaring them keeps the parser from greedily consuming
14
+ // the following definition path as their value (e.g. `--json my-style.json`).
15
+ const positional = Parser(args, {
16
+ boolean: ['help', 'version', 'exif', 'json'],
17
+ })._[0];
18
+ return positional === undefined ? undefined : String(positional);
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dicebear",
3
- "version": "10.0.0-rc.5",
3
+ "version": "10.0.1",
4
4
  "private": false,
5
5
  "description": "CLI for DiceBear — unique avatars from dozens of styles.",
6
6
  "homepage": "https://github.com/dicebear/dicebear",
@@ -22,12 +22,13 @@
22
22
  "scripts": {
23
23
  "prebuild": "del-cli lib",
24
24
  "build": "tsc",
25
- "prepublishOnly": "npm run build"
25
+ "prepublishOnly": "npm run build",
26
+ "test": "node --test"
26
27
  },
27
28
  "dependencies": {
28
- "@dicebear/converter": "10.0.0-rc.5",
29
- "@dicebear/core": "10.0.0-rc.5",
30
- "@dicebear/styles": "^10.0.0-rc.11",
29
+ "@dicebear/converter": "10.0.1",
30
+ "@dicebear/core": "10.0.1",
31
+ "@dicebear/styles": "^10.0.0",
31
32
  "ajv": "^8.17.1",
32
33
  "chalk": "^5.4.1",
33
34
  "chalk-template": "^1.1.2",
@@ -47,6 +48,6 @@
47
48
  "typescript": "^5.9.3"
48
49
  },
49
50
  "engines": {
50
- "node": ">=18.0.0"
51
+ "node": ">=22.0.0"
51
52
  }
52
53
  }