Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 10 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v5
with:
node-version: 22
cache: yarn
- run: yarn --frozen-lockfile
- run: yarn prepublishOnly
- run: yarn docs:build
version: 10
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- run: pnpm install
- run: pnpm run prepublishOnly
- run: pnpm run docs:build
- uses: actions/configure-pages@v4
- uses: actions/upload-pages-artifact@v3
with:
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v5
with:
node-version: 22
cache: yarn
registry-url: 'https://registry.npmjs.org'
- run: yarn --frozen-lockfile
- run: yarn test
version: 10
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- run: pnpm install
- run: pnpm run test
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
27 changes: 15 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v5
with:
node-version: 22
cache: yarn
- run: yarn --frozen-lockfile
- run: yarn test:mocha
- run: yarn test:tsc
- run: yarn test:lint
- run: yarn test:prettier
- run: yarn prepublishOnly
- run: yarn docs:build
- uses: actions/upload-artifact@v4
version: 10
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- run: pnpm install
- run: pnpm run test:vitest
- run: pnpm run test:tsc
- run: pnpm run test:lint
- run: pnpm run test:prettier
- run: pnpm run prepublishOnly
- run: pnpm run docs:build
- uses: actions/upload-artifact@v7
if: failure()
with:
name: test-output-changes
Expand Down
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ We request that you abide by our [code of conduct](https://observablehq.com/@obs
To contribute to Observable Plot, you’ll need a local development environment to make and test changes to Plot’s source code. To get started, follow GitHub’s tutorial on [forking (and cloning) a repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo). Once you’ve cloned your fork of the Plot repository, open a terminal and `cd` in your forked repository. Then run Yarn to install dependencies:

```bash
yarn
pnpm install
```

You may encounter an error installing [node-canvas](https://github.com/Automattic/node-canvas), such as:
Expand All @@ -28,24 +28,24 @@ brew install pkg-config cairo pango libpng jpeg giflib librsvg

## Testing

After making changes to Plot’s source code, run Plot’s test suite to verify that your code is doing what you expect and that you haven’t introduced any other unexpected changes in behavior. Plot has two types of tests: **unit tests** and **snapshot tests**. Tests are run automatically on pull requests (via GitHub Actions), but you’ll want to run them locally to verify your changes before opening a pull request. To run the tests, use Yarn:
After making changes to Plot’s source code, run Plot’s test suite to verify that your code is doing what you expect and that you haven’t introduced any other unexpected changes in behavior. Plot has two types of tests: **unit tests** and **snapshot tests**. Tests are run automatically on pull requests (via GitHub Actions), but you’ll want to run them locally to verify your changes before opening a pull request. To run the tests:

```bash
yarn test
pnpm run test
```

This will also run ESLint on Plot’s source to help catch simple mistakes, such as unused imports.

Please run Prettier before submitting any pull request. Check “format on save” in your code editor, or run:

```bash
yarn prettier --write .
pnpm exec prettier --write .
```

A test coverage report can be generated with [c8](https://github.com/bcoe/c8), in text and lcov formats, to help you identify which lines of code are not (yet!) covered by tests. Just run:

```bash
yarn test:coverage
pnpm run test:coverage
```

### Unit tests
Expand All @@ -65,7 +65,7 @@ Plot’s unit tests are written with [Mocha](https://mochajs.org).
If you like, you can also run Mocha in watch mode for a specific file, so that unit tests re-run automatically when you make changes. For example:

```bash
yarn run mocha --conditions=mocha --parallel --watch test/marks/bar-test.js
pnpm run test:vitest test/marks/bar-test.js
```

### Snapshot tests
Expand Down Expand Up @@ -98,7 +98,7 @@ export * from "./moby-dick.ts";
The best thing about snapshot tests is that you can see the live result in your browser as you make changes to Plot’s source code! This lets you immediately assess visually what Plot is doing. To preview snapshot tests during development, Plot uses [Vite](https://vitejs.dev). To start Vite:

```bash
yarn dev
pnpm run dev
```

This will open http://localhost:8008/ in your browser where you can choose a snapshot test. As you edit the source, the current test will update live in your browser as you save changes. You can change the selected test from the drop-down menu. When the drop-down menu is focused, the left and right arrow keys cycle between tests.
Expand All @@ -111,17 +111,17 @@ Running Plot’s snapshot tests will automatically generate any missing snapshot

```
rm -rf test/output
yarn test
pnpm run test:vitest
```

## Documentation

When submitting a pull request, please remember to update Plot’s documentation to reflect changes to the public API. You are also welcome to edit Plot’s [CHANGELOG.md](./CHANGELOG.md) to assist with writing future release notes. In addition, please reference any related [issues](https://github.com/observablehq/plot/issues) (or discussions) in your pull request description.

If you’d like to share a live demonstration or motivating example of your change to Plot, you can regenerate Plot’s release bundle using Yarn:
If you’d like to share a live demonstration or motivating example of your change to Plot, you can regenerate Plot’s release bundle like so:

```bash
yarn prepublishOnly
pnpm run prepublishOnly
```

The generated bundle `dist/plot.umd.js` can then be loaded like so:
Expand Down
10 changes: 5 additions & 5 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ Then, create an `index.html` file as shown above in the **UMD + local** tab. If

## Installing from npm

If you’re developing a web application using Node, you can install Plot via yarn, npm, pnpm, or your preferred package manager.
If you’re developing a web application using Node, you can install Plot via pnpm, npm, yarn, or your preferred package manager.

:::code-group

```bash [yarn]
yarn add @observablehq/plot
```bash [pnpm]
pnpm add @observablehq/plot
```

```bash [npm]
npm install @observablehq/plot
```

```bash [pnpm]
pnpm add @observablehq/plot
```bash [yarn]
yarn add @observablehq/plot
```

:::
Expand Down
27 changes: 8 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"src/**/*.js"
],
"scripts": {
"test": "yarn test:mocha && yarn test:tsc && yarn test:lint && yarn test:prettier",
"test:coverage": "c8 yarn test:mocha",
"test:mocha": "mkdir -p test/output && TZ=America/Los_Angeles tsx node_modules/.bin/mocha 'test/**/*-test.*' 'test/plot.*'",
"test": "pnpm run test:vitest && pnpm run test:tsc && pnpm run test:lint && pnpm run test:prettier",
"test:coverage": "TZ=America/Los_Angeles vitest run --coverage",
"test:vitest": "TZ=America/Los_Angeles vitest --typecheck",
"test:lint": "eslint src test",
"test:prettier": "prettier --check src test",
"test:tsc": "tsc",
Expand All @@ -52,40 +52,29 @@
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-terser": "^0.4.0",
"@types/d3": "^7.4.0",
"@types/mocha": "^10.0.1",
"@types/node": "^22.13.2",
"@typescript-eslint/eslint-plugin": "^8.24.0",
"@typescript-eslint/parser": "^8.24.0",
"@vitest/coverage-v8": "^4.0.18",
"apache-arrow": "^19.0.0",
"c8": "^10.1.3",
"canvas": "^3.1.0",
"d3-format": "^3.1.2",
"d3-geo-projection": "^4.0.0",
"eslint": "^9.20.1",
"eslint-config-prettier": "^10.0.1",
"globals": "^15.15.0",
"htl": "^0.3.0",
"js-beautify": "1",
"jsdom": "^26.0.0",
"jsdom": "^29.0.1",
"markdown-it-container": "^4.0.0",
"mocha": "^11.1.0",
"prettier": "~3.0.0",
"rollup": "^4.9.1",
"topojson-client": "^3.1.0",
"ts-morph": "^25.0.1",
"tsx": "^4.7.0",
"typescript": "^5.0.2",
"vite": "^6.1.0",
"vitepress": "^1.3.1"
},
"c8": {
"all": true,
"include": [
"src/**/*.js"
],
"reporter": [
"text",
"lcov"
]
"vitepress": "^1.3.1",
"vitest": "^4.0.8"
},
"dependencies": {
"d3": "^7.9.0",
Expand Down
Loading