@qrdx/cli 0.0.8 → 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.
- package/README.md +3 -3
- package/dist/index.js +22 -21
- 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` | | — |
|
|
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
|
-
#
|
|
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,
|
|
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, FRAME_STYLES, DEFAULT_FRAME_TEXT, FRAME_TEXT_MAX_LENGTH, DEFAULT_MARGIN, getFrameDimensions, colorConfigSchema, errorLevelSchema, QRCodeSVG, svgToEPS } 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,31 @@ 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: `
|
|
830
|
+
message: `Frame ${DIM}(around the code)${RESET}`,
|
|
831
831
|
options: [
|
|
832
|
-
{ value: "", label: "none" },
|
|
833
|
-
...
|
|
832
|
+
{ value: "none", label: "none" },
|
|
833
|
+
...BUILT_IN_FRAMES.map((item) => ({
|
|
834
|
+
value: item.style,
|
|
835
|
+
label: item.style,
|
|
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)`
|
|
842
|
+
}))
|
|
834
843
|
],
|
|
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
|
-
options: FRAME_STYLES.map((style) => ({ value: style, label: style })),
|
|
846
844
|
initialValue: "none"
|
|
847
845
|
});
|
|
848
846
|
if (isCancel2(res)) {
|
|
849
847
|
handleCancel();
|
|
850
848
|
}
|
|
851
|
-
|
|
849
|
+
const choice = res;
|
|
850
|
+
if (choice.startsWith(TEMPLATE_CHOICE)) {
|
|
851
|
+
template = choice.slice(TEMPLATE_CHOICE.length);
|
|
852
|
+
} else if (choice !== "none") {
|
|
852
853
|
const text2 = await p.text({
|
|
853
854
|
message: `Frame text ${DIM}(up to ${FRAME_TEXT_MAX_LENGTH} characters)${RESET}`,
|
|
854
855
|
placeholder: DEFAULT_FRAME_TEXT,
|
|
@@ -863,7 +864,7 @@ async function runGenerate(args, meta) {
|
|
|
863
864
|
handleCancel();
|
|
864
865
|
}
|
|
865
866
|
frame = {
|
|
866
|
-
style:
|
|
867
|
+
style: choice,
|
|
867
868
|
text: text2 || DEFAULT_FRAME_TEXT
|
|
868
869
|
};
|
|
869
870
|
}
|
|
@@ -1244,8 +1245,8 @@ ${BOLD}Generate Options:${RESET3}
|
|
|
1244
1245
|
--no-logo Skip the logo prompt in interactive mode
|
|
1245
1246
|
--margin Quiet zone margin in modules ${DIM3}(default: 0)${RESET3}
|
|
1246
1247
|
--size Output pixel size for SVG/PNG/WebP ${DIM3}(default: 512)${RESET3}
|
|
1247
|
-
--template
|
|
1248
|
-
${DIM3}
|
|
1248
|
+
--template A frame drawn as a template (the whole artwork is --size):
|
|
1249
|
+
${DIM3}${getTemplateIds().filter((id) => id !== "default").join(", ")}${RESET3}
|
|
1249
1250
|
--frame Call-to-action frame (adds space around the code), e.g.:
|
|
1250
1251
|
${DIM3}none, banner-bottom, banner-top, rounded-border,${RESET3}
|
|
1251
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.
|
|
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.
|
|
48
|
+
"qrdx": "0.0.53",
|
|
49
49
|
"react": "19.3.1",
|
|
50
50
|
"react-dom": "19.3.1"
|
|
51
51
|
},
|