tdcv2

v0.4.0
io.github.NickLiapin/tdcv2 Checked 20 hours ago Published 22 days ago

Fake, mock and test data generator: CSV, JSON, SQL from a .tdc config, made locally by TDCv2.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

tdc_check Check a TDCv2 config

Validate a .tdc config without generating anything. Returns every diagnostic with its code, line, column, hint and "did you mean" suggestion, plus warnings and whether a seed is set. Run it until the config is clean.

ParameterTypeDescription
configstringThe .tdc config text. Give this or `path`.
pathstringA .tdc file, relative to the project folder. Give this or `config`.

tdc_generate Generate data from a TDCv2 config

Make test data — CSV, JSON, SQL, any text — from a .tdc config, instead of writing a generator script. Without `output`: renders in memory and returns the first `preview` lines (max 50) — nothing is written. With `output`: writes the whole file inside the project folder and returns its size, a per-column summary and the first lines. A failed <assert> comes back as row, message, condition and values, so the config can be fixed. Same config and seed give the same bytes every time.

ParameterTypeDescription
configstringThe .tdc config text. Give this or `path`.
countintegerOverride <env count> for this run. For the delivered file keep count in the config instead.
outputstringFile to write, relative to the project folder. Omit to preview only.
pathstringA .tdc file, relative to the project folder. Give this or `config`.
previewintegerLines to return (default 10, max 50).
seedstringOverride <env seed> for this run. For the delivered file keep seed in the config instead.

tdc_find_packs Find TDCv2 data packs

Search the data packs installed on this machine by words ("last name", "iban", "city") — the paths to write in <gen type="template" value="…"/>. Never guess a path; ask this. Returns path, the locales that have it, and what it holds (never the values).

ParameterTypeDescription
query *stringWords to look for, English works best: "last name", "email", "country".
limitintegerAt most this many results (default 15).
localestringOnly packs for this locale, e.g. "fr". Says how to install it if missing.

tdc_pack_add Install TDCv2 data packs

Install data packs for other languages and countries — "fr", "de", "ja", "france", "brazil" — when tdc_find_packs says a locale is missing. Runs `tdcv2 pack add` of the engine this project uses, which downloads the packs from the public TDCv2 pack registry. In a project without a pack store it first runs `tdcv2 init --yes`, which writes tdcv2.config.json and a tdcv2-packs/ folder there (engines before --no-examples also add a few tdcv2-examples/ files).

ParameterTypeDescription
ids *arrayPack ids: a language ("fr", "pt", "zh-cn") or a country ("france", "brazil", "united_kingdom").

tdc_peek Summarise a generated file

A short summary of a CSV, JSON or SQL file in the project: row count; per column the distinct values, the split, the range; INSERT rows per table. The proof that a file holds what was asked, without reading it all.

ParameterTypeDescription
path *stringThe file, relative to the project folder.
columnstringOne column in full (up to 50 values with counts).
rowsintegerSample rows to include (default 3).

tdc_read_docs Read the TDCv2 guide and reference

Start here when asked for test data, fixtures or seed data: the TDCv2 guide ("guide" — read it before the first config), traps check does not catch ("traps"), using the data from test code in five languages ("from-code"), several linked tables in one file ("linked-tables"), the list of reference pages ("index"), or one reference page such as "generators/date". `query` searches the page list.

ParameterTypeDescription
offsetintegerFor long pages: continue from this character.
pagestringguide | traps | from-code | linked-tables | index | a reference path like generators/date. Default: guide.
querystringWords to find in the page list instead of opening a page.

tdc_format Format a TDCv2 config

Pretty-print a .tdc config the way `tdcv2 format` does. Returns the text unchanged if it does not parse.

ParameterTypeDescription
config *stringThe .tdc config text.