@barmark/cli 0.12.0 → 0.14.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/CHANGELOG.md +43 -1
- package/README.md +24 -1
- package/dist/check.js +6 -1
- package/dist/export.js +39 -16
- package/dist/help.js +8 -4
- package/dist/main.js +2 -2
- package/dist/node-io.js +1 -0
- package/dist/render.js +1 -1
- package/dist/report.js +9 -2
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,46 @@ package uses [semantic versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.14.0] - 2026-11-19
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **`export --lyricsheet`** writes the chart as a ChordPro lyric sheet
|
|
14
|
+
(usually `.cho`), to stdout or `--out`; `--part <label>` writes one
|
|
15
|
+
part's chords, and `--diagrams guitar` adds guitar chord diagrams. What
|
|
16
|
+
the sheet can't carry goes to stderr as `song.chart.md: warning:
|
|
17
|
+
message`, each message naming its own bars. `--version` lists
|
|
18
|
+
`@barmark/lyricsheet`.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **`check`, `format`, `render` and the exports read more spellings of
|
|
23
|
+
the major seventh** (`CMaj9`, `Cma13`, `CmΔ7`, `C∆7`, `Cm△9`), as
|
|
24
|
+
`barmark` now reads them; they print canonically.
|
|
25
|
+
- **`render --score`: a lyric row's rhythm slashes sit on their line**,
|
|
26
|
+
with no ledger lines through them.
|
|
27
|
+
- **Uses** barmark 0.25.0, @barmark/render 0.20.2, @barmark/musicxml
|
|
28
|
+
0.9.3, @barmark/score 0.6.3, @barmark/midi 0.3.5 and
|
|
29
|
+
@barmark/lyricsheet 0.1.0 (and through them @barmark/fretboard 0.1.2
|
|
30
|
+
and @barmark/sync 0.4.3).
|
|
31
|
+
|
|
32
|
+
## [0.13.0] - 2026-11-14
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **`check` prints a problem's suggestion** (so do `part`, `transpose` and
|
|
37
|
+
`export`, which print problems the same way): `bad.chart.md:4: error: C(b2): "b2" is
|
|
38
|
+
not a tone a parenthesis can add (write C(b9))`, for errors and warnings.
|
|
39
|
+
`--format github` carries the same sentence in the annotation, and
|
|
40
|
+
`--format json` a `suggestion` field beside `message`, absent when there
|
|
41
|
+
is none. A problem with no suggestion prints as before.
|
|
42
|
+
- **`check`, `format`, `render` and the exports read a flat sixth, an
|
|
43
|
+
`add` before any tone and `Δ9`** (`F#m(b6)`, `Cadd13`, `CΔ9`), as
|
|
44
|
+
`barmark` now reads them.
|
|
45
|
+
- **Uses** barmark 0.24.0, @barmark/render 0.20.1, @barmark/musicxml
|
|
46
|
+
0.9.2, @barmark/score 0.6.1 and @barmark/midi 0.3.4 (and through them
|
|
47
|
+
@barmark/fretboard 0.1.1 and @barmark/sync 0.4.2).
|
|
48
|
+
|
|
9
49
|
## [0.12.0] - 2026-11-13
|
|
10
50
|
|
|
11
51
|
### Added
|
|
@@ -394,7 +434,9 @@ The first release of the `barmark` command. Uses `barmark` 0.8.0 and
|
|
|
394
434
|
- **The `barmark` command:** `check`, `format`, `render` and `transpose`
|
|
395
435
|
for `.chart.md` files, on npm and as standalone binaries.
|
|
396
436
|
|
|
397
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/cli-v0.
|
|
437
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/cli-v0.14.0...HEAD
|
|
438
|
+
[0.14.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.13.0...cli-v0.14.0
|
|
439
|
+
[0.13.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.12.0...cli-v0.13.0
|
|
398
440
|
[0.12.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.11.3...cli-v0.12.0
|
|
399
441
|
[0.11.3]: https://github.com/kevinpeckham/barmark/compare/cli-v0.11.2...cli-v0.11.3
|
|
400
442
|
[0.11.2]: https://github.com/kevinpeckham/barmark/compare/cli-v0.11.1...cli-v0.11.2
|
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ barmark export --musicxml song.chart.md --out song.musicxml # for MuseScore, D
|
|
|
38
38
|
barmark import song.musicxml --out song.chart.md # or a compressed song.mxl
|
|
39
39
|
barmark export --midi song.chart.md --out song.mid # for a DAW or a practice player
|
|
40
40
|
barmark import song.mid --out song.chart.md # chords named from the notes
|
|
41
|
+
barmark export --lyricsheet song.chart.md --out song.cho # a ChordPro lyric sheet
|
|
41
42
|
barmark check --strict --format github songs # warnings fail too; PR annotations
|
|
42
43
|
barmark format song.chart.md # print it in standard form
|
|
43
44
|
barmark format --write songs # rewrite the files that change
|
|
@@ -49,7 +50,10 @@ barmark render song.chart.md --diagrams guitar --left-handed --out song.html #
|
|
|
49
50
|
barmark transpose song.chart.md --to E # or --semitones -2
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
A problem the parser can suggest a fix for ends with it, as `song.chart.md:4:
|
|
54
|
+
error: C(b2): "b2" is not a tone a parenthesis can add (write C(b9))`
|
|
55
|
+
(`check`, `export`, `part` and `transpose`; `--format json` gives it as a
|
|
56
|
+
`suggestion` field). `check --format json` prints the diagnostics for other tools. `render`
|
|
53
57
|
takes the renderer's options as flags: `--theme auto|light|dark`,
|
|
54
58
|
`--numerals nashville|roman`, `--no-bar-numbers`, `--rehearsal-letters`,
|
|
55
59
|
`--no-wrap`, `--columns shared|row`, `--diagrams guitar` (a strip of guitar
|
|
@@ -105,6 +109,25 @@ names the harmony's tracks by number or name (ignoring case) instead of
|
|
|
105
109
|
letting the import choose. As for MusicXML, it exits 1 when no chart came
|
|
106
110
|
out.
|
|
107
111
|
|
|
112
|
+
`export --lyricsheet` writes the chart as a ChordPro lyric sheet, text for
|
|
113
|
+
any app that reads ChordPro (the usual extension is `.cho`), to stdout or
|
|
114
|
+
`--out`. `--part <label>` writes one part's chords with the singer's
|
|
115
|
+
words, and `--diagrams guitar` adds guitar chord diagrams. A chart with no
|
|
116
|
+
title takes its file name. What a lyric sheet can't hold goes to stderr as
|
|
117
|
+
`song.chart.md: warning: message`, each message naming its own bars. A
|
|
118
|
+
chart with errors is not exported.
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
$ barmark export --lyricsheet examples/shenandoah.chart.md
|
|
122
|
+
{title: Shenandoah}
|
|
123
|
+
{key: C}
|
|
124
|
+
{time: 4/4}
|
|
125
|
+
{comment: A simplified arrangement of the traditional song, every note a quarter.}
|
|
126
|
+
|
|
127
|
+
{start_of_verse: label="Verse"}
|
|
128
|
+
[*N.C.]Oh [C]Shenandoah [C]I long to hear [F]you
|
|
129
|
+
```
|
|
130
|
+
|
|
108
131
|
## Exit codes
|
|
109
132
|
|
|
110
133
|
| Code | Meaning |
|
package/dist/check.js
CHANGED
|
@@ -20,7 +20,12 @@ export async function check(args, io) {
|
|
|
20
20
|
if (format === "json") {
|
|
21
21
|
const files = results.map(({ path, diagnostics }) => ({
|
|
22
22
|
file: path,
|
|
23
|
-
diagnostics: diagnostics.map(({ line, severity, message }) => ({
|
|
23
|
+
diagnostics: diagnostics.map(({ line, severity, message, suggestion }) => ({
|
|
24
|
+
line,
|
|
25
|
+
severity,
|
|
26
|
+
message,
|
|
27
|
+
...(suggestion ? { suggestion } : {}),
|
|
28
|
+
})),
|
|
24
29
|
}));
|
|
25
30
|
io.stdout(`${JSON.stringify(files, null, 2)}\n`);
|
|
26
31
|
}
|
package/dist/export.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
/** barmark export: a chart in another format: MusicXML, or a
|
|
1
|
+
/** barmark export: a chart in another format: MusicXML, a MIDI file or a lyric sheet. */
|
|
2
2
|
import { basename } from "node:path";
|
|
3
|
+
import { exportLyricsheet } from "@barmark/lyricsheet";
|
|
3
4
|
import { exportMidi } from "@barmark/midi";
|
|
4
5
|
import { exportMusicXml } from "@barmark/musicxml";
|
|
5
|
-
import { parseFlags } from "./args.js";
|
|
6
|
+
import { oneOf, parseFlags } from "./args.js";
|
|
6
7
|
import { readCharts, STDIN } from "./inputs.js";
|
|
7
8
|
import { UsageError } from "./io.js";
|
|
8
9
|
import { onlyChart, writeFile, writeOutput } from "./output.js";
|
|
10
|
+
import { DIAGRAMS } from "./render.js";
|
|
9
11
|
import { textLine } from "./report.js";
|
|
10
12
|
/**
|
|
11
13
|
* `file: bar N: warning: message`, as `check` prints its findings; N is the
|
|
@@ -19,31 +21,35 @@ export function lossLine(path, loss) {
|
|
|
19
21
|
const diagnosticLine = (path, d) => d.line ? textLine(path, d) : `${path}: ${d.message}`;
|
|
20
22
|
/** The format the flags name: exactly one; --midi writes bytes, so it needs --out. */
|
|
21
23
|
function formatOf(values) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
const named = ["musicxml", "midi", "lyricsheet"].filter((f) => values[f]);
|
|
25
|
+
if (named.length > 1)
|
|
26
|
+
throw new UsageError("give one format: --musicxml, --midi or --lyricsheet");
|
|
27
|
+
const format = named[0];
|
|
28
|
+
if (format === undefined)
|
|
29
|
+
throw new UsageError("give a format: --musicxml, --midi or --lyricsheet");
|
|
30
|
+
if (format === "midi" && values.out === undefined)
|
|
31
|
+
throw new UsageError("--midi writes a file: give --out <file.mid>");
|
|
32
|
+
if (values.diagrams !== undefined && format !== "lyricsheet")
|
|
33
|
+
throw new UsageError("--diagrams goes with --lyricsheet");
|
|
34
|
+
return format;
|
|
32
35
|
}
|
|
33
36
|
export async function exportCommand(args, io) {
|
|
34
37
|
const { values, positionals } = parseFlags(args, {
|
|
35
38
|
musicxml: { type: "boolean" },
|
|
36
39
|
midi: { type: "boolean" },
|
|
40
|
+
lyricsheet: { type: "boolean" },
|
|
37
41
|
out: { type: "string" },
|
|
38
42
|
part: { type: "string" },
|
|
43
|
+
diagrams: { type: "string" },
|
|
39
44
|
});
|
|
40
45
|
const format = formatOf(values);
|
|
46
|
+
const diagrams = values.diagrams === undefined ? undefined : oneOf("diagrams", values.diagrams, DIAGRAMS);
|
|
41
47
|
const { path, text } = onlyChart(await readCharts(positionals, io, { folders: false }), "export");
|
|
42
48
|
const options = {
|
|
43
49
|
...(values.part === undefined ? {} : { part: values.part }),
|
|
44
50
|
...(path === STDIN ? {} : { title: basename(path).replace(/(\.chart)?\.[^.]*$/, "") }),
|
|
45
51
|
};
|
|
46
|
-
const result = format
|
|
52
|
+
const result = convert(format, text, options, diagrams);
|
|
47
53
|
// As transpose does: problems to stderr, and no file written from a chart with errors.
|
|
48
54
|
for (const d of result.diagnostics)
|
|
49
55
|
io.stderr(`${diagnosticLine(path, d)}\n`);
|
|
@@ -52,13 +58,30 @@ export async function exportCommand(args, io) {
|
|
|
52
58
|
io.stderr(`${values.out} not written: the chart has errors\n`);
|
|
53
59
|
return 1;
|
|
54
60
|
}
|
|
61
|
+
writeResult(result, path, values.out, io);
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
function convert(format, text, options, diagrams) {
|
|
65
|
+
if (format === "midi")
|
|
66
|
+
return exportMidi(text, options);
|
|
67
|
+
if (format === "lyricsheet")
|
|
68
|
+
return exportLyricsheet(text, { ...options, ...(diagrams ? { diagrams } : {}) });
|
|
69
|
+
return exportMusicXml(text, options);
|
|
70
|
+
}
|
|
71
|
+
/** A good result's losses to stderr, then its file or its text. */
|
|
72
|
+
function writeResult(result, path, out, io) {
|
|
55
73
|
if ("bytes" in result) {
|
|
56
74
|
for (const loss of result.losses)
|
|
57
75
|
io.stderr(`${lossLine(path, loss)}\n`);
|
|
58
76
|
// formatOf made --out required for --midi.
|
|
59
|
-
writeFile(
|
|
77
|
+
writeFile(out, result.bytes, io);
|
|
78
|
+
}
|
|
79
|
+
else if ("text" in result) {
|
|
80
|
+
// The sheet's messages name their bars already: no second naming.
|
|
81
|
+
for (const loss of result.losses)
|
|
82
|
+
io.stderr(`${lossLine(path, { message: loss.message })}\n`);
|
|
83
|
+
writeOutput(result.text, out, io);
|
|
60
84
|
}
|
|
61
85
|
else
|
|
62
|
-
writeOutput(result.xml,
|
|
63
|
-
return 0;
|
|
86
|
+
writeOutput(result.xml, out, io);
|
|
64
87
|
}
|
package/dist/help.js
CHANGED
|
@@ -3,7 +3,7 @@ export const HELP = `Usage: barmark <command> [options]
|
|
|
3
3
|
|
|
4
4
|
Commands:
|
|
5
5
|
check <paths…> Report each chart's errors and warnings
|
|
6
|
-
export <file> Write a chart as MusicXML or
|
|
6
|
+
export <file> Write a chart as MusicXML, MIDI or a lyric sheet (--musicxml, --midi, --lyricsheet)
|
|
7
7
|
format <paths…> Print or rewrite charts in standard form
|
|
8
8
|
import <file> Read a MusicXML score or a MIDI file as a chart
|
|
9
9
|
part <label> <file> Print one part of a chart of several
|
|
@@ -29,18 +29,22 @@ inside them; - reads stdin.
|
|
|
29
29
|
github: annotations on a pull request
|
|
30
30
|
json: an array of { file, diagnostics }
|
|
31
31
|
`,
|
|
32
|
-
export: `Usage: barmark export (--musicxml | --midi) <file> [options]
|
|
32
|
+
export: `Usage: barmark export (--musicxml | --midi | --lyricsheet) <file> [options]
|
|
33
33
|
|
|
34
34
|
The chart as MusicXML 4.0, for MuseScore, Dorico, Sibelius or Finale: one
|
|
35
35
|
part per declared part, playing in the chart's order. Or as a MIDI file
|
|
36
36
|
of its play order, for a DAW or a practice player; what MIDI can't hold
|
|
37
|
-
goes to stderr as file: bar N: warning: message.
|
|
38
|
-
|
|
37
|
+
goes to stderr as file: bar N: warning: message. Or as a lyric sheet, a
|
|
38
|
+
text file in ChordPro's format (usually .cho) for any app that reads
|
|
39
|
+
it; what it can't hold goes to stderr as file: warning: message. A chart
|
|
40
|
+
with errors is not exported; problems go to stderr.
|
|
39
41
|
|
|
40
42
|
--musicxml Export MusicXML
|
|
41
43
|
--midi Export a Standard MIDI File (needs --out)
|
|
42
44
|
--out <file> Write to a file instead of stdout
|
|
45
|
+
--lyricsheet Export a ChordPro lyric sheet
|
|
43
46
|
--part <label> Export only this part
|
|
47
|
+
--diagrams guitar With --lyricsheet: add guitar chord diagrams
|
|
44
48
|
`,
|
|
45
49
|
format: `Usage: barmark format <paths…> [options]
|
|
46
50
|
|
package/dist/main.js
CHANGED
|
@@ -21,8 +21,8 @@ export const COMMANDS = {
|
|
|
21
21
|
export async function main(argv, io) {
|
|
22
22
|
const [name, ...args] = argv;
|
|
23
23
|
if (name === "--version" || name === "-v") {
|
|
24
|
-
const { cli, barmark, render, musicxml, score, midi, verovio } = io.versions;
|
|
25
|
-
io.stdout(`@barmark/cli ${cli} (barmark ${barmark}, @barmark/render ${render}, @barmark/musicxml ${musicxml}, @barmark/score ${score}, @barmark/midi ${midi}, verovio ${verovio})\n`);
|
|
24
|
+
const { cli, barmark, render, musicxml, score, midi, lyricsheet, verovio } = io.versions;
|
|
25
|
+
io.stdout(`@barmark/cli ${cli} (barmark ${barmark}, @barmark/render ${render}, @barmark/musicxml ${musicxml}, @barmark/score ${score}, @barmark/midi ${midi}, @barmark/lyricsheet ${lyricsheet}, verovio ${verovio})\n`);
|
|
26
26
|
return 0;
|
|
27
27
|
}
|
|
28
28
|
if (name === "--help" || name === "-h") {
|
package/dist/node-io.js
CHANGED
package/dist/render.js
CHANGED
|
@@ -13,7 +13,7 @@ import { DEFAULT_WIDTH, MAX_WIDTH, MIN_WIDTH, scoreBody } from "./score.js";
|
|
|
13
13
|
const THEMES = ["auto", "light", "dark"];
|
|
14
14
|
const NUMERALS = ["nashville", "roman"];
|
|
15
15
|
const COLUMNS = ["shared", "row"];
|
|
16
|
-
const DIAGRAMS = ["guitar"];
|
|
16
|
+
export const DIAGRAMS = ["guitar"];
|
|
17
17
|
const escapeHtml = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
18
18
|
function htmlDocument(title, body) {
|
|
19
19
|
return `<!doctype html>
|
package/dist/report.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A diagnostic's message, ending with what to write instead when the parser
|
|
3
|
+
* has a suggestion the message does not already spell out.
|
|
4
|
+
*/
|
|
5
|
+
const sentence = (d) => d.suggestion && !d.message.includes(d.suggestion)
|
|
6
|
+
? `${d.message} (write ${d.suggestion})`
|
|
7
|
+
: d.message;
|
|
1
8
|
export function textLine(path, d) {
|
|
2
|
-
return `${path}:${d.line}: ${d.severity}: ${d
|
|
9
|
+
return `${path}:${d.line}: ${d.severity}: ${sentence(d)}`;
|
|
3
10
|
}
|
|
4
11
|
/** GitHub's workflow-command escaping for a message. */
|
|
5
12
|
const escapeData = (text) => text.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
|
|
6
13
|
export function githubLine(path, d) {
|
|
7
14
|
const file = escapeData(path).replace(/:/g, "%3A").replace(/,/g, "%2C");
|
|
8
|
-
return `::${d.severity} file=${file},line=${d.line}::${escapeData(d
|
|
15
|
+
return `::${d.severity} file=${file},line=${d.line}::${escapeData(sentence(d))}`;
|
|
9
16
|
}
|
|
10
17
|
const count = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
11
18
|
export function summary(files, errors, warnings) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barmark/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "The barmark command: check, format, render, transpose and export barmark chord charts (.chart.md) from the terminal and in CI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
"url": "https://github.com/kevinpeckham/barmark/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"barmark": "0.
|
|
41
|
-
"@barmark/render": "0.20.
|
|
42
|
-
"@barmark/musicxml": "0.9.
|
|
43
|
-
"@barmark/midi": "0.3.
|
|
44
|
-
"@barmark/
|
|
40
|
+
"barmark": "0.25.0",
|
|
41
|
+
"@barmark/render": "0.20.2",
|
|
42
|
+
"@barmark/musicxml": "0.9.3",
|
|
43
|
+
"@barmark/midi": "0.3.5",
|
|
44
|
+
"@barmark/lyricsheet": "0.1.0",
|
|
45
|
+
"@barmark/score": "0.6.3",
|
|
45
46
|
"verovio": "6.4.1"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|