Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
471bade
v1.0.0-rc.2: expand golden tests to top 10 consumer languages
jake-dev-99 Apr 20, 2026
4b4d85a
fix(file-resolver): repair multi-extension glob and drop debug chatter
jake-dev-99 Apr 20, 2026
d470f2a
Merge: fix(file-resolver) glob + tests
jake-dev-99 Apr 20, 2026
9fff79f
refactor(process): unify quicktype subprocess runner + argv builder
jake-dev-99 Apr 20, 2026
e8ed2a7
Merge: refactor(process) unified subprocess runner
jake-dev-99 Apr 20, 2026
1396dce
fix(backend_web): cancel listeners, handle missing <head>, extract po…
jake-dev-99 Apr 20, 2026
0dc6a9a
Merge: fix(backend_web) listener + head fallback
jake-dev-99 Apr 20, 2026
ec0da71
refactor(api): tighten public surface, symmetric bundleSource, raw op…
jake-dev-99 Apr 20, 2026
ae2e4ec
Merge: refactor(api) tighten public surface + symmetric bundleSource
jake-dev-99 Apr 20, 2026
c2e211f
refactor(layout): retire lib/src/utils/ grab-bag
jake-dev-99 Apr 20, 2026
60efed2
Merge: refactor(layout) retire lib/src/utils/
jake-dev-99 Apr 20, 2026
4d1e041
refactor(internal): TempDirSweeper + putOpt helper for language options
jake-dev-99 Apr 20, 2026
6d01a8d
Merge: refactor(internal) TempDirSweeper + putOpt helper
jake-dev-99 Apr 20, 2026
a30392f
test: cover internal helpers + every TargetType in goldens
jake-dev-99 Apr 20, 2026
5b74831
Merge: test coverage + full-matrix goldens
jake-dev-99 Apr 20, 2026
caff623
tool: harden refresh_bundle, sync_version, install_hooks, embed_bundl…
jake-dev-99 Apr 20, 2026
96acadf
Merge: tool/ hardening
jake-dev-99 Apr 20, 2026
1de4008
polish: P2 readability + idiom cleanup
jake-dev-99 Apr 20, 2026
16bb135
Merge: P2 polish
jake-dev-99 Apr 20, 2026
e5a4411
api: filter options.dart barrel, refresh api_snapshot
jake-dev-99 Apr 20, 2026
1a5a5a5
fix(type): repair TargetType.c, drop broken Smithy, guard golden test
jake-dev-99 Apr 20, 2026
c5eb44e
Merge: fix(type) repair c/smithy + golden guard
jake-dev-99 Apr 20, 2026
89e245a
fix(logging): route through package:logging; CLI writes directly to s…
jake-dev-99 Apr 20, 2026
8bdadfd
Merge: fix(logging) route through package:logging + CLI stdout
jake-dev-99 Apr 20, 2026
df99c40
config: strict loadOrDefaults, narrower glob catch, num-friendly coerce
jake-dev-99 Apr 20, 2026
419744b
Merge: config hardening pass
jake-dev-99 Apr 20, 2026
3603691
ci: integration matrix macOS + Windows, new ffi-noembed job
jake-dev-99 Apr 20, 2026
6ac87d2
Merge: CI integration matrix + ffi-noembed job
jake-dev-99 Apr 20, 2026
d11eac6
polish: exhaustive TargetType switch, smoke README, misc doc nits
jake-dev-99 Apr 20, 2026
89d10de
Merge: Sprint 8 polish
jake-dev-99 Apr 20, 2026
c08ab1c
chore: dart format sweep + api_snapshot refresh for loadOrDefaults
jake-dev-99 Apr 20, 2026
25c27f9
test(config): restore 90% coverage after strict + narrow-catch additions
jake-dev-99 Apr 20, 2026
7ddf2f4
Merge: test(config) restore coverage threshold
jake-dev-99 Apr 20, 2026
39c9a43
test(goldens): pin Process transport, drop cpp, pin quicktype@23.2.0 …
jake-dev-99 Apr 20, 2026
629f991
Merge: test(goldens) deterministic transport
jake-dev-99 Apr 20, 2026
8a9d86c
review: address PR #26 valid feedback
jake-dev-99 Apr 20, 2026
21cdb6c
Merge: address PR #26 review feedback
jake-dev-99 Apr 20, 2026
3759541
fix(io): await readAsString in _runViaProcess before temp-dir cleanup
jake-dev-99 Apr 20, 2026
fe5bc8b
fix(backend_io): await readAsString — finally was racing temp-dir delete
jake-dev-99 Apr 20, 2026
bf5a0bb
ci: pin LF line endings on goldens + api snapshot
jake-dev-99 Apr 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Force LF line endings on checkout for files the build and tests
# compare byte-for-byte. Git's default `core.autocrlf=true` on Windows
# would otherwise rewrite committed LF to CRLF at checkout, breaking:
#
# * Golden-file comparisons in test/integration/goldens/ — quicktype
# emits LF on every platform; the goldens were generated with LF.
# * API-snapshot drift detection in tool/api_snapshot.txt.
#
# Everything else stays on the repo default (Dart / Markdown / YAML
# round-trip fine under either convention).
test/integration/goldens/*.txt text eol=lf
test/integration/goldens/*.json text eol=lf
tool/api_snapshot.txt text eol=lf
45 changes: 39 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,53 @@ jobs:
path: coverage/lcov.info

integration:
name: Integration tests (ubuntu)
runs-on: ubuntu-latest
name: Integration tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
- name: Install quicktype globally
run: npm install -g quicktype
# Pinned to the version whose Process-transport output the
# golden files were generated against. Bump here + regenerate
# goldens (GOLDEN=update) in the same commit when rolling.
run: npm install -g quicktype@23.2.0
- run: flutter pub get
- name: Integration tests
run: dart test test/integration --tags=integration

ffi-noembed:
name: FFI (no embedded bundle)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- run: flutter pub get
- name: Install CMake + build deps
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential
- name: Configure + build with QT_EMBED_BUNDLE=OFF
# QT_EMBED_BUNDLE=OFF skips the embed_bundle.py custom command,
# so the native/bundle/ Node toolchain isn't needed for this
# leg — the binary ships without bundle bytes and relies on a
# runtime fetch via BundleSource.remote(...).
run: |
cmake -S native -B build/native -DQT_EMBED_BUNDLE=OFF
cmake --build build/native
- name: Run ffi_noembed smoke test
run: dart run tool/smoke/ffi_noembed_smoke.dart

example:
name: Example build_runner
runs-on: ubuntu-latest
Expand All @@ -100,11 +131,13 @@ jobs:
channel: stable
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
- name: Install quicktype globally
# build_runner's auto transport falls through to Process on CI
# (FFI plugin isn't pre-built); needs `quicktype` on PATH.
run: npm install -g quicktype
# Pinned to the version example/lib/models/user.dart was
# generated against — bump here and regenerate in the same PR.
run: npm install -g quicktype@23.2.0
- name: Install deps
working-directory: example
run: dart pub get
Expand Down
121 changes: 121 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,126 @@
# Changelog

## 1.0.0-rc.2

**War-on-debt audit pass** — two rounds of code review before 1.0.0
GA. Fixes two silent-but-real correctness bugs, closes architecture /
hygiene gaps, expands test + CI coverage, tightens the public API
with a few breaking changes that land cleanly pre-1.0.

### Breaking

- **`Log` and `inferLangType` dropped from the public barrel.** Both
had leaked out as internal helpers. Tests that need them import
from `package:quicktype_dart/src/...` directly.
- **`Log.off` deleted.** It routed through `dart:developer.log` at
OFF level — nothing consumed it, so running
`quicktype_dart --help` produced zero stdout. CLI code now writes
`stdout`/`stderr` directly; structured events
(`Log.info`/`warning`/`severe`) route through `Logger('quicktype')`
from `package:logging`.
- **`QuicktypeDart.setBundleSource(src)` → field assignment**:
`QuicktypeDart.bundleSource = src`. Getter unchanged.
- **`Config.loadOrDefaults(path)` → named parameters**:
`Config.loadOrDefaults(path: 'foo.json', strict: true)`. Adds
`strict` (defaults to `false`); CLI opts in so malformed configs
don't silently fall back to defaults.
- **`TargetType.smithy` removed.** No variant of the argName round-
trips through the bundled quicktype-core — the Smithy renderer
class is in the JS bundle but not wired to the language-dispatch
API upstream. Re-adds when upstream wires it up.

### Fixed

- **`TargetType.c.argName` was `'c'`; quicktype-core needs
`'cjson'`.** The committed golden had been a one-line `"Unknown
language name: c"` that passed trivially by matching the error
string. Fixed; the regenerated golden now contains real cJSON
struct + parse/serialize definitions.
- **FileResolver multi-extension glob** — graphql (two extensions)
silently matched nothing because the set was concatenated as
`'{.graphqls, .graphql}'` (space-padded via `Set.toString()`).
Proper brace-expansion now.
- **CLI silence** — `--help`, `--version`, and error messages were
swallowed by `Log.off` routing through `dart:developer.log`. See
above.
- **Golden test accepts error output** — `_assertLooksLikeCode` now
rejects outputs starting with `Unknown language name:`, `Error:`,
`TypeError:`, `at ReferenceError`, or fewer than 5 lines, even in
`GOLDEN=update` mode.
- **Web backend leaks** — script `onLoad`/`onError` subscriptions
now cancelled in a `finally`; parent element resolves `<head>` →
`<body>` → `<html>` instead of force-unwrapping `.head!`.
- **CWD-relative quicktype path** — `Quicktype.execute` no longer
uses `./tool/node_modules/.bin/quicktype`. Routes through shared
`resolveQuicktypeExecutable()` so invocation from any cwd works.
- **Lossy stack trace** in `Quicktype.execute`'s catch block.
- **Process timeout actually kills the child** — `runQuicktypeProcess`
now uses `Process.start` + manual `.kill()` on timeout instead of
`Process.run().timeout()` (which only times out the Dart Future).

### Added

- **Goldens for every `TargetType`** — 21 cases (dart, kotlin,
swift, typescript, csharp, python, java, go, rust, c, elixir,
elm, flow, haskell, javascript, objc, php, proptypes, ruby,
scala). Deterministic under Process transport, `quicktype@23.2.0`
pinned in CI so local + CI agree byte-for-byte. `cpp` intentionally
absent: `quicktype --lang cpp` emits "Error: Internal error: ."
upstream on inputs with nested objects; re-add when fixed.
- **`RendererOptions.raw(Map<String, String>)` factory** for callers
who already hold the kebab-case map (builder uses it).
- **`coerceRendererOptionsMap` accepts `num`** — YAML
`indentation: 2` Just Works.
- **Shared process runner** (`lib/src/internal/quicktype_process.dart`)
— `resolveQuicktypeExecutable`, `findOnPath`, `runQuicktypeProcess`.
Kills the `Quicktype.execute` ↔ `backend_io._runViaProcess`
duplication.
- **`rendererOptionsToArgv` helper** (`lib/src/internal/argv.dart`)
— single source of truth for `--flag` / `--no-flag` / `--flag
value` encoding.
- **`TempDirSweeper` class** — Windows-retry cleanup encapsulated,
testable, observable via `deferredCount`.
- **`putOpt(map, key, value)` helper** — collapses ~120 lines of
null-check boilerplate across 22 language-option files.
- **CI: integration matrix on Ubuntu + macOS + Windows** (was
Ubuntu-only).
- **CI: `ffi-noembed` job** — builds `native/` with
`-DQT_EMBED_BUNDLE=OFF` and runs `tool/smoke/ffi_noembed_smoke.dart`.
- **`tool/smoke/README.md`** documenting which smoke scripts are
CI-wired vs manual-only.
- **Unit tests** for argv, `RendererOptions.raw`, `TempDirSweeper`,
`package_layout`, and expanded `config_test.dart` (strict mode,
fromMap shape errors, `ConfigException.toString`, mkdir side
effect).

### Changed

- **`lib/src/utils/` retired** in favor of purpose-named homes:
`paths.dart` → `internal/package_layout.dart`, `shell.dart` →
`internal/shell.dart`, `type_infer.dart` → `models/type_infer.dart`,
`logging.dart` → `src/logging.dart`, `file_resolver.dart` →
`src/file_resolver.dart`.
- **`TargetType.defaultPath`** rewritten as an exhaustive Dart 3
switch expression — adding a new `TargetType` is now a compile
error here until handled.
- **`_detectFilesForTarget`** narrows its catch from `Object` to
`FormatException` + `FileSystemException`, with remediation hints.
- **`Config.defaults()`** side effect (mkdir `models/`) now
documented at factory and class level.
- **Tool hardening**: `refresh_bundle.dart` probes `bash`/`python3`
and sanity-checks the repo root; `sync_version.dart` hard-fails on
missing targets (was warn-and-skip); `install_hooks.dart` checks
`chmod` exit; `embed_bundle.py` wraps file I/O with clear errors.

### Deferred (post-1.0)

- Upstream fix for `quicktype -l cpp` internal-error; re-add the cpp
golden when it lands.
- Full `Log` migration to richer `package:logging` usage (per-
subsystem filtering, LogRecord formatting, test subscription
harness). Current setup (root INFO forwarded to stdout/stderr in
the CLI) is enough to ship.

## 1.0.0-rc.1

**First release candidate for 1.0.** No code changes on top of 0.9.0 —
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Flutter's plugin system expects this file at `android/build.gradle`.

group = "io.simplezen.quicktype_dart"
version = "1.0.0-rc.1"
version = "1.0.0-rc.2"

buildscript {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion ios/quicktype_dart.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'quicktype_dart'
s.version = '1.0.0-rc.1'
s.version = '1.0.0-rc.2'
s.summary = 'Cross-platform type generation from JSON.'
s.description = <<-DESC
Embeds quicktype-core inside a QuickJS-NG runtime via FFI so Flutter
Expand Down
84 changes: 59 additions & 25 deletions lib/entrypoint_cli.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'dart:async';
import 'dart:io';

import 'package:args/args.dart';
import 'package:logging/logging.dart';

import 'src/config.dart';
import 'src/internal/quicktype_process.dart';
import 'src/quicktype.dart';
import 'src/utils/logging.dart';
import 'src/version.dart';

/// Entry point for the `quicktype_dart` CLI.
Expand All @@ -19,6 +21,8 @@ import 'src/version.dart';
class QuicktypeCLI {
/// Runs the CLI with [args] and returns the exit code (0 on success).
static Future<int> run(List<String> args) async {
_installLogForwarder();

final parser = ArgParser()
..addOption('config',
abbr: 'c',
Expand All @@ -32,15 +36,13 @@ class QuicktypeCLI {
try {
final options = parser.parse(args);

// Handle help request
if (options.flag('help')) {
_printUsage();
return 0;
}

// Handle version request
if (options.flag('version')) {
_printVersion();
await _printVersion();
return 0;
}

Expand All @@ -49,12 +51,11 @@ class QuicktypeCLI {
return await Quicktype.executeNative(options.rest);
}

// Run with specified config
final configPath = options.option('config') ?? Config.defaultConfigFile;
return await _generateFromConfig(configPath);
} catch (e, stackTrace) {
Log.off('Error: $e');
Log.off('Stack trace: $stackTrace');
stderr.writeln('Error: $e');
stderr.writeln(stackTrace);
return 1;
}
}
Expand All @@ -63,31 +64,36 @@ class QuicktypeCLI {
/// commands, and executes them. Returns exit code 0 on full success,
/// 1 if any command failed.
static Future<int> _generateFromConfig(String configPath) async {
Log.off('Running quicktype with config: $configPath');
stdout.writeln('Running quicktype with config: $configPath');

final quicktype = Quicktype(Config.loadOrDefaults(configPath));
// CLI invocations surface config-parse errors directly instead of
// silently running with defaults — the user asked for this config,
// we don't get to decide it's invalid.
final quicktype =
Quicktype(Config.loadOrDefaults(path: configPath, strict: true));
final commands = await quicktype.buildCommandsFromConfig();
final results = await quicktype.executeAll(commands);

final successCount = results.where((r) => r.success).length;
Log.off('Generated $successCount/${results.length} files successfully');
stdout.writeln(
'Generated $successCount/${results.length} files successfully');

// Print any errors
final failures = results.where((r) => !r.success).toList();
if (failures.isNotEmpty) {
Log.off('\nErrors:');
stderr.writeln('\nErrors:');
for (final f in failures) {
Log.off(' - ${f.sourcePath} → ${f.targetPath}: ${f.errorMessage}');
stderr.writeln(
' - ${f.sourcePath} → ${f.targetPath}: ${f.errorMessage}');
}
return 1;
}

return 0;
}

/// Print CLI usage information
/// Print CLI usage information.
static void _printUsage() {
Log.off('''
stdout.writeln('''
Quicktype Dart - Generate types from schemas

Usage:
Expand All @@ -102,23 +108,51 @@ Examples:
quicktype Generate using quicktype.json
quicktype -c custom.json Generate using custom.json

For more details: https://github.com/yourusername/quicktype_dart
For more details: https://github.com/jake-dev-99/quicktype_dart
''');
}

/// Print version information
static void _printVersion() {
Log.off('Quicktype Dart v$packageVersion');

/// Print version information.
static Future<void> _printVersion() async {
stdout.writeln('Quicktype Dart v$packageVersion');
try {
final result = Process.runSync('quicktype', ['--version']);
final exe = await resolveQuicktypeExecutable();
final result = Process.runSync(exe, ['--version']);
if (result.exitCode == 0) {
Log.off('Native quicktype: ${result.stdout.toString().trim()}');
stdout.writeln('Native quicktype: ${(result.stdout as String).trim()}');
} else {
Log.off('Native quicktype: not available');
stdout.writeln('Native quicktype: exited ${result.exitCode}');
}
} catch (_) {
Log.off('Native quicktype: not installed');
} on QuicktypeException {
stdout.writeln('Native quicktype: not installed');
} catch (e) {
stdout.writeln('Native quicktype: $e');
}
}

/// Wires the **root** logger's records (everything under
/// `Logger.root`, including our `Logger('quicktype')` tree and any
/// transitive `package:logging` consumers) to stdout/stderr so
/// library diagnostics (`Log.info` etc.) reach the terminal when run
/// as a CLI. Sets the root level to INFO on entry.
///
/// Idempotent: re-runs in the same process (tests) cancel the
/// previous subscription before attaching a new one.
static void _installLogForwarder() {
Logger.root.level = Level.INFO;
_logSubscription?.cancel();
_logSubscription = Logger.root.onRecord.listen((record) {
// Process stdout/stderr are owned by the runtime; never close them.
if (record.level >= Level.WARNING) {
stderr.writeln('[${record.level.name}] ${record.message}');
} else {
stdout.writeln('[${record.level.name}] ${record.message}');
}
});
}

// ignore: cancel_subscriptions
// Subscription lives for the process lifetime; cancellation happens
// on re-entry (tests) via _installLogForwarder above.
static StreamSubscription<LogRecord>? _logSubscription;
}
Loading
Loading