PDGGK opened a new pull request, #118:
URL: https://github.com/apache/iotdb-extras/pull/118
## Why
`@grafana/toolkit` was archived by Grafana and no longer receives updates,
so `npm run build` was pinned to an unmaintained toolchain. This migrates the
plugin's frontend build to `@grafana/create-plugin`, which is the supported
replacement.
## What changed
- **Build toolchain.** `grafana-toolkit plugin:build/test/dev` are replaced
by webpack, SWC/Jest, the flat ESLint config and Playwright, all driven from
the generated `.config/` directory. `.config/` is checked in as `create-plugin`
intends, carries its own "do not edit" notice, and can be refreshed later with
`npx @grafana/create-plugin update`.
- **Lockfile.** `yarn.lock` is removed in favour of `package-lock.json`,
matching the npm-based scripts the new toolchain generates.
- **`grafanaDependency` moves from `>=9.3.0` to `>=12.3.0`.** This is the
one compatibility decision in the change, so to be explicit about it: the
plugin builds and is tested against `@grafana/data`, `@grafana/ui` and
`@grafana/runtime` **13.1.0**. Those packages are webpack *externals*
(`.config/bundler/externals.ts`), resolved from the host Grafana at runtime
rather than bundled — so an API that exists in the 13.1.0 types but not on an
older host does not fail the build, it fails at runtime in the user's Grafana
with no bundled fallback. Declaring `>=12.3.0`, the floor `create-plugin`
declares for this SDK generation, states the range we can actually stand
behind. If keeping a lower floor matters more, that is worth saying now — it
would mean pinning the `@grafana/*` packages down instead.
- **Two ESLint errors fixed.** The stricter config flags
`react-hooks/immutability` in the tree-model query editors, where an array is
mutated in place and the *same* reference is then passed to `onChange` — so a
consumer comparing by reference sees no change. Both now pass a new array
instead.
To be plain about what this leaves behind: `FromValue.tsx` and
`SelectValue.tsx` still contain the identical append
(`prefixPath[prefixPath.length] = ''; onChange(prefixPath)`) a few lines below
the corrected one, where the rule does not flag it, plus two `splice`-based
removals with the same shape. I left them because these components have no test
coverage and a toolchain migration is the wrong place to change untested UI
behaviour — but I am happy to fix the remaining sites in a separate change with
tests.
- **CI workflow updated in the same change.**
`.github/workflows/grafana-plugin.yml` triggers on
`connectors/grafana-plugin/**`, pins `node-version: "14.x"`, installs with
`yarn install --frozen-lockfile` and keys both caches on
`hashFiles('**/yarn.lock')`. Since this change removes `yarn.lock`, that
workflow would fail at install, and Node 14 cannot run the new toolchain in any
case. It now takes the Node version from the plugin's `.nvmrc` — so it cannot
drift away from the toolchain again — uses `setup-node`'s npm cache keyed on
`package-lock.json`, and runs `npm ci && npm run build`. The Go/backend step is
unchanged.
- **Development environment.** `docker-compose.yaml` now also starts a
standalone IoTDB next to Grafana, and `provisioning/` wires the datasource to
it (REST on 18080 for the tree-model modes, native Thrift on 6667 for the
table-model mode). `npm run server` therefore brings up a Grafana with the
plugin loaded *and* a server to query, instead of an empty instance.
One known rough edge in the generated config:
`.config/supervisord/supervisord.conf` waits for a backend binary matching
`gpx_iotdb*`, derived from the plugin *name*, while `plugin.json` declares
`executable: gpx_apache_iotdb_datasource`. That only affects `DEVELOPMENT=true`
(the delve path); with the default `DEVELOPMENT=false` the entrypoint runs
Grafana directly, which is the path verified below. I have not hand-edited it,
since `.config/` is generated and regenerated by `create-plugin update`.
## Verification
Toolchain: `typecheck`, `lint` (0 errors; 9 remaining warnings are
pre-existing deprecation notices), `test:ci` (13 tests) and `build` all pass.
The exact command chain the updated workflow runs — `npm ci && npm run build` —
was run from a clean install to confirm `package-lock.json` and `package.json`
are in sync, since `npm ci` fails hard if they are not.
End to end against real servers, not just a green build: the plugin was
loaded into **Grafana 13.1.0** from `docker compose up`, with a real
`apache/iotdb:2.0.8` behind it. Grafana registers the plugin (`Plugin
registered pluginId=apache-iotdb-datasource`), the provisioned datasource
connects, and a **table-model** query
```sql
SELECT time, device_id, temperature FROM sensors WHERE $__timeFilter(time)
ORDER BY time
```
renders in a panel with the row-major result correctly pivoted into one
series per tag value, and the same data shown in the table view.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]