Skip to content

Commit 4aa9835

Browse files
committed
Fix CLI execution through npm symlinks and release 7.0.4
1 parent cb5460c commit 4aa9835

8 files changed

Lines changed: 50 additions & 9 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v7.0.4
4+
5+
- fix the documentation CLI entry check when npm or npx starts it through a symlink
6+
- add an executable regression test for help output and failure exit codes
7+
38
## v7.0.3
49

510
- fix range-selector coordinate jumps during Android drags and preserve drag state while controlled viewport updates are pending (issue #780)

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ Read the public documentation from a terminal:
119119
npx --package=react-native-chart-kit chart-kit docs /docs/react-native/charts/line
120120
```
121121

122-
Use `chart-kit docs` to list pages or add `--json` for structured output. The CLI ships from version 7.0.3. No API key is required. Charts render locally in your application; the HTTP API serves documentation.
122+
Use `chart-kit docs` to list pages or add `--json` for structured output. The CLI ships from version 7.0.4. No API key is required. Charts render locally in your application; the HTTP API serves documentation.
123123

124124
See the [developer guide](https://chartkit.io/developers), [agent instructions](https://chartkit.io/llms.txt), and [OpenAPI specification](https://chartkit.io/openapi.json).

‎apps/site/public/agent-instructions.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Use Chart Kit when a user needs charts inside a React Native app: trends and tim
77
1. Read [the developer guide](https://chartkit.io/developers.md) and [installation](https://chartkit.io/docs/react-native/getting-started/installation.md).
88
2. Install `react-native-chart-kit` and `react-native-svg` in the user's app. Import modern charts from `react-native-chart-kit/v2`. The root import is the legacy-compatible API.
99
3. Use [the documentation index API](https://chartkit.io/api/v1/docs) to find a page. Read it with `GET /api/v1/docs/page?path=<returned-path>`, a `.md` URL, or `Accept: text/markdown`. No API key is needed.
10-
4. For terminal use, run `npx --package=react-native-chart-kit chart-kit docs /docs/react-native/charts/line`. Add `--json` when structured output is needed. The CLI requires package version 7.0.3 or later.
10+
4. For terminal use, run `npx --package=react-native-chart-kit chart-kit docs /docs/react-native/charts/line`. Add `--json` when structured output is needed. The CLI requires package version 7.0.4 or later.
1111
5. Test the chart with the user's data shape, empty data, and the target screen dimensions. Use the documented event types and controlled viewport pattern.
1212

1313
## Product boundaries

‎apps/site/src/pages/developers.astro‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ import LegalLayout from "../layouts/LegalLayout.astro";
3131
Import modern components from <code>react-native-chart-kit/v2</code>.
3232
Follow the <a href="/docs/react-native/getting-started/installation"
3333
>installation guide</a
34-
> for the current React Native requirements and a complete first chart. The{" "}
34+
> for the current React Native requirements and a complete first chart. The{
35+
" "
36+
}
3537
<a href="/docs/react-native/charts/line">line chart playground</a> provides
3638
an interactive example where you can test chart properties in the browser.
3739
</p>
@@ -77,7 +79,9 @@ import LegalLayout from "../layouts/LegalLayout.astro";
7779
<section>
7880
<h2>Markdown and agent instructions</h2>
7981
<p>
80-
Start with <a href="/llms.txt">llms.txt</a> to select a task and a page. Read{" "}
82+
Start with <a href="/llms.txt">llms.txt</a> to select a task and a page. Read{
83+
" "
84+
}
8185
<a href="/agent-instructions.md">agent-instructions.md</a> for package and licensing
8286
rules. Public pages support <code>Accept: text/markdown</code> and a <code
8387
>.md</code
@@ -91,7 +95,7 @@ import LegalLayout from "../layouts/LegalLayout.astro";
9195
<h2>Official CLI</h2>
9296
<p>
9397
The <code>chart-kit</code> CLI ships in <code>react-native-chart-kit</code
94-
> from version 7.0.3. It reads the public documentation API and writes Markdown
98+
> from version 7.0.4. It reads the public documentation API and writes Markdown
9599
or JSON to standard output. It makes no changes to your app and needs no API
96100
key.
97101
</p>

‎bin/chart-kit.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
2+
import { realpathSync } from "node:fs";
23
import { pathToFileURL } from "node:url";
34

45
export async function run(
@@ -72,7 +73,7 @@ export async function run(
7273

7374
if (
7475
process.argv[1] &&
75-
import.meta.url === pathToFileURL(process.argv[1]).href
76+
import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href
7677
) {
7778
process.exitCode = await run(process.argv.slice(2));
7879
}

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-chart-kit",
3-
"version": "7.0.3",
3+
"version": "7.0.4",
44
"description": "Beautiful React Native charts for dashboards, reports, and data-rich mobile apps.",
55
"keywords": [
66
"react-native",

‎scripts/cli-entry.test.mjs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { mkdtempSync, rmSync, symlinkSync } from "node:fs";
2+
import { tmpdir } from "node:os";
3+
import path from "node:path";
4+
import { spawnSync } from "node:child_process";
5+
import { fileURLToPath } from "node:url";
6+
import { describe, expect, it } from "vitest";
7+
8+
describe("npm CLI executable", () => {
9+
it("runs through the symlink created by npm and returns useful exit codes", () => {
10+
const directory = mkdtempSync(path.join(tmpdir(), "chartkit-cli-entry-"));
11+
const link = path.join(directory, "chart-kit");
12+
try {
13+
symlinkSync(
14+
fileURLToPath(new URL("../bin/chart-kit.mjs", import.meta.url)),
15+
link
16+
);
17+
const help = spawnSync(process.execPath, [link, "--help"], {
18+
encoding: "utf8"
19+
});
20+
expect(help.status).toBe(0);
21+
expect(help.stdout).toContain("Chart Kit documentation CLI");
22+
const invalid = spawnSync(process.execPath, [link, "unknown"], {
23+
encoding: "utf8"
24+
});
25+
expect(invalid.status).toBe(1);
26+
expect(JSON.parse(invalid.stderr).error.code).toBe("INVALID_ARGUMENT");
27+
} finally {
28+
rmSync(directory, { recursive: true, force: true });
29+
}
30+
});
31+
});

0 commit comments

Comments
 (0)