@qrdx/cli 0.0.9 → 0.0.10

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.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +16 -23
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -47,7 +47,7 @@ qrdx generate <data> [options]
47
47
  | `--logo` | | — | Center logo image URL (use with `--level H`) |
48
48
  | `--no-logo` | | — | Skip the logo prompt in interactive mode |
49
49
  | `--margin` | | `0` | Quiet zone margin (modules) |
50
- | `--template` | | — | Decorative template: `Arrow` `StandardBox` `SquareBorder` `StrikedBox` `Halloween` |
50
+ | `--template` | | — | A frame drawn as a template (the whole file is `--size`, the code smaller inside it): `Arrow` `StandardBox` `SquareBorder` `StrikedBox` `Halloween` `DotRing` |
51
51
  | `--frame` | | — | Call-to-action frame: <!-- catalogue:FRAME_STYLES -->`none`, `banner-bottom`, `banner-top`, `border`, `rounded-border`, `speech-bubble`, `banner-top-bottom`, `speech-bubble-top`, `chat-bubble`, `circle`, `polaroid`, `phone`, `ticket`, `badge`, `envelope`, `tag`, `menu-card`, `sticker`, `gradient-border`, `focus`<!-- /catalogue --> |
52
52
  | `--frame-text` | | `Scan me` | Frame label, up to 24 characters (`""` hides it) |
53
53
  | `--frame-color` | | `#000000` | Frame color (hex) |
@@ -87,7 +87,7 @@ qrdx generate "https://qrdx.dev" \
87
87
  qrdx generate "https://qrdx.dev" -o gradient.svg \
88
88
  --fg '{"type":"linear","stops":[{"color":"#6366f1","offset":0},{"color":"#ec4899","offset":100}],"angle":135}'
89
89
 
90
- # Template
90
+ # A frame drawn as a template
91
91
  qrdx generate "https://qrdx.dev" --template Arrow -o arrow.svg
92
92
 
93
93
  # "Scan me" frame
@@ -140,7 +140,7 @@ Each gradient needs at least 2 stops; `offset` is a percentage from 0 to 100.
140
140
 
141
141
  ## Interactive mode
142
142
 
143
- When run in a TTY without an output path or data, `qrdx generate` starts a guided prompt flow: data, output path, then optional customizations (patterns, colors, template, logo, margin). In CI (`CI=true`) or when stdin/stdout is not a TTY it never prompts.
143
+ When run in a TTY without an output path or data, `qrdx generate` starts a guided prompt flow: data, output path, then optional customizations (patterns, colors, frame, logo, margin). In CI (`CI=true`) or when stdin/stdout is not a TTY it never prompts.
144
144
 
145
145
  ## Requirements
146
146
 
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFileSync, mkdirSync, writeFileSync, createReadStream } from 'fs';
3
3
  import { join, resolve, extname } from 'path';
4
+ import { BODY_PATTERN, CORNER_EYE_PATTERNS, CORNER_EYE_DOT_PATTERNS, BUILT_IN_FRAMES, getAllTemplates, DEFAULT_FRAME_TEXT, FRAME_TEXT_MAX_LENGTH, DEFAULT_MARGIN, getFrameDimensions, getTemplateIds, colorConfigSchema, errorLevelSchema, QRCodeSVG, svgToEPS, FRAME_STYLES } from 'qrdx';
4
5
  import { readFile } from 'fs/promises';
5
- import { BODY_PATTERN, CORNER_EYE_PATTERNS, CORNER_EYE_DOT_PATTERNS, getTemplateIds, BUILT_IN_FRAMES, DEFAULT_FRAME_TEXT, FRAME_TEXT_MAX_LENGTH, DEFAULT_MARGIN, getFrameDimensions, colorConfigSchema, errorLevelSchema, QRCodeSVG, svgToEPS, FRAME_STYLES } from 'qrdx';
6
6
  import { getQRAsPNG } from 'qrdx/node';
7
7
  import { createElement } from 'react';
8
8
  import { renderToStaticMarkup } from 'react-dom/server';
@@ -234,6 +234,7 @@ var RESET = "\x1B[0m";
234
234
  var TEXT = "\x1B[38;5;145m";
235
235
  var GREEN = "\x1B[38;5;114m";
236
236
  var DIM = "\x1B[38;5;102m";
237
+ var TEMPLATE_CHOICE = "template:";
237
238
  var HEX_COLOR = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
238
239
  var MAX_PNG_SIZE = 1e4;
239
240
  function parseColorFlag(value) {
@@ -824,31 +825,20 @@ async function runGenerate(args, meta) {
824
825
  const dotVal = res;
825
826
  dotColor = dotVal ? parseColorFlag(dotVal) : void 0;
826
827
  }
827
- if (!flags.template) {
828
- const templateIds = getTemplateIds();
828
+ if (flags.frame === void 0 && !frame && !flags.template) {
829
829
  const res = await p.select({
830
- message: `Template ${DIM}(decorative wrapper around the QR code)${RESET}`,
831
- options: [
832
- { value: "", label: "none" },
833
- ...templateIds.filter((id) => id !== "default").map((id) => ({ value: id, label: id }))
834
- ],
835
- initialValue: ""
836
- });
837
- if (isCancel2(res)) {
838
- handleCancel();
839
- }
840
- template = res || void 0;
841
- }
842
- if (flags.frame === void 0 && !frame) {
843
- const res = await p.select({
844
- message: `Frame ${DIM}(call-to-action label around the code)${RESET}`,
845
- // Every built-in frame, by its style name and its name
830
+ message: `Frame ${DIM}(around the code)${RESET}`,
846
831
  options: [
847
832
  { value: "none", label: "none" },
848
833
  ...BUILT_IN_FRAMES.map((item) => ({
849
834
  value: item.style,
850
835
  label: item.style,
851
836
  hint: item.name
837
+ })),
838
+ ...getAllTemplates().filter((item) => item.id !== "default").map((item) => ({
839
+ value: `${TEMPLATE_CHOICE}${item.id}`,
840
+ label: item.id,
841
+ hint: `${item.name} (--template)`
852
842
  }))
853
843
  ],
854
844
  initialValue: "none"
@@ -856,7 +846,10 @@ async function runGenerate(args, meta) {
856
846
  if (isCancel2(res)) {
857
847
  handleCancel();
858
848
  }
859
- if (res !== "none") {
849
+ const choice = res;
850
+ if (choice.startsWith(TEMPLATE_CHOICE)) {
851
+ template = choice.slice(TEMPLATE_CHOICE.length);
852
+ } else if (choice !== "none") {
860
853
  const text2 = await p.text({
861
854
  message: `Frame text ${DIM}(up to ${FRAME_TEXT_MAX_LENGTH} characters)${RESET}`,
862
855
  placeholder: DEFAULT_FRAME_TEXT,
@@ -871,7 +864,7 @@ async function runGenerate(args, meta) {
871
864
  handleCancel();
872
865
  }
873
866
  frame = {
874
- style: res,
867
+ style: choice,
875
868
  text: text2 || DEFAULT_FRAME_TEXT
876
869
  };
877
870
  }
@@ -1252,8 +1245,8 @@ ${BOLD}Generate Options:${RESET3}
1252
1245
  --no-logo Skip the logo prompt in interactive mode
1253
1246
  --margin Quiet zone margin in modules ${DIM3}(default: 0)${RESET3}
1254
1247
  --size Output pixel size for SVG/PNG/WebP ${DIM3}(default: 512)${RESET3}
1255
- --template Decorative template wrapper:
1256
- ${DIM3}Arrow, StandardBox, SquareBorder, StrikedBox, Halloween${RESET3}
1248
+ --template A frame drawn as a template (the whole artwork is --size):
1249
+ ${DIM3}${getTemplateIds().filter((id) => id !== "default").join(", ")}${RESET3}
1257
1250
  --frame Call-to-action frame (adds space around the code), e.g.:
1258
1251
  ${DIM3}none, banner-bottom, banner-top, rounded-border,${RESET3}
1259
1252
  ${DIM3}speech-bubble, polaroid, phone, ticket, sticker${RESET3}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrdx/cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "QR code generator CLI for developers: styled SVG, PNG, WebP and vector EPS QR codes from the command line",
5
5
  "keywords": [
6
6
  "qr-code",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@clack/prompts": "^1.8.1",
47
47
  "picocolors": "^1.1.1",
48
- "qrdx": "0.0.52",
48
+ "qrdx": "0.0.53",
49
49
  "react": "19.3.1",
50
50
  "react-dom": "19.3.1"
51
51
  },