1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use serde::Deserialize;
use std::path::PathBuf;
#[derive(Deserialize)]
pub struct Config {
pub canonical: String,
pub locales: PathBuf,
#[serde(default)]
pub target: Vec<Target>,
/// Optional `[package]` block: emit a self-contained node package (compiled
/// `.js` + `.d.ts` + `package.json`) instead of (or alongside) loose `.ts`
/// targets. Point `out` at `node_modules/<name>/` for a zero-repo-footprint
/// "codegen as a dependency" setup.
pub package: Option<Package>,
}
#[derive(Deserialize)]
pub struct Package {
/// The package name written into `package.json` (e.g. `@myapp/copy`).
pub name: String,
/// Output directory for the package (e.g. `node_modules/@myapp/copy`).
pub out: PathBuf,
/// Version written into `package.json`. Defaults to `0.0.0`.
pub version: Option<String>,
/// Include the locale store (`store.js` / `store.d.ts`). Implied by `react`.
#[serde(default)]
pub store: bool,
/// Include the React hooks (`react.js` / `react.d.ts`).
#[serde(default)]
pub react: bool,
/// Emit no-arg leaves as `() => "..."` thunks (same as the `callable` target option).
#[serde(default)]
pub callable: bool,
/// Output identifier case (same as the target `case` option).
pub case: Option<String>,
/// Brand name for the API (same as the target `binding` option).
pub binding: Option<String>,
}
#[derive(Deserialize)]
pub struct Target {
pub lang: String,
pub out: PathBuf,
/// When true, no-argument leaves are emitted as `() => "..."` thunks rather
/// than bare string constants. Matches codebases where every copy leaf is
/// callable (e.g. `copy.home.title()`). TypeScript only.
#[serde(default)]
pub callable: bool,
/// For the `store` target: the import specifier to the core generated module
/// (the `typescript` target's output). Defaults to `./stele.gen`.
pub core: Option<String>,
/// For the `react` target: the import specifier to the `store` target's
/// output (where the hooks read/write the active locale). Defaults to
/// `./stele.store`.
pub store: Option<String>,
/// Output identifier case: `camel` (default), `snake`, `pascal`, or
/// `preserve`. Input keys may be in any case; this picks the output.
pub case: Option<String>,
/// The brand name the generated API is built around. Defaults to `stele`,
/// giving the type `Stele`, the factory `createStele`, and (react target)
/// `useStele` / `SteleProvider`. Set to e.g. `copy` for the classic
/// `Copy` / `createCopy` / `useCopy` names.
pub binding: Option<String>,
}