Skip to content

Commit 0f26bf8

Browse files
authored
release: v1.10.0 (#40)
release-npm Closes #23 ## Summary - JSON Schema for `twee-ts.config.json` — editor autocomplete and validation (#23) - `scaffoldConfig()` emits `$schema` field - Schema published alongside npm package at `schemas/twee-ts.config.schema.json` - SchemaStore registration PR submitted: SchemaStore/schemastore#5447 ## Checklist - [x] Tests pass (`pnpm test`) - [x] Type check passes (`pnpm run typecheck`) - [x] Build succeeds (`pnpm run build`) - [x] Formatting clean (`pnpm run format:check`) - [x] CHANGELOG.md updated with new version ## Release Merging this PR will trigger `release-npm-action` to publish v1.10.0 to npm. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents b517261 + df2a352 commit 0f26bf8

File tree

5 files changed

+153
-4
lines changed

5 files changed

+153
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.10.0] - 2026-03-06
9+
10+
### Added
11+
12+
- JSON Schema for `twee-ts.config.json` — provides editor autocomplete and validation in VS Code, WebStorm, and other JSON Schema-aware editors ([#23](https://github.com/rohal12/twee-ts/issues/23))
13+
- `scaffoldConfig()` now emits a `$schema` field pointing to the published schema
14+
- Schema published alongside the npm package at `schemas/twee-ts.config.schema.json`
15+
816
## [1.9.0] - 2026-03-06
917

1018
### Added

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"twee-ts": "./dist/bin/twee-ts.js"
4444
},
4545
"files": [
46-
"dist"
46+
"dist",
47+
"schemas"
4748
],
4849
"scripts": {
4950
"build": "tsup",

schemas/twee-ts.config.schema.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://unpkg.com/@rohal12/twee-ts/schemas/twee-ts.config.schema.json",
4+
"title": "twee-ts Configuration",
5+
"description": "Configuration file for twee-ts, a TypeScript Twee-to-HTML compiler.",
6+
"type": "object",
7+
"additionalProperties": false,
8+
"properties": {
9+
"$schema": {
10+
"type": "string",
11+
"description": "JSON Schema reference for editor support."
12+
},
13+
"sources": {
14+
"type": "array",
15+
"items": { "type": "string" },
16+
"description": "Files or directories to compile."
17+
},
18+
"output": {
19+
"type": "string",
20+
"description": "Output file path."
21+
},
22+
"outputMode": {
23+
"type": "string",
24+
"enum": ["html", "twee3", "twee1", "twine2-archive", "twine1-archive", "json"],
25+
"default": "html",
26+
"description": "Output mode."
27+
},
28+
"formatId": {
29+
"type": "string",
30+
"description": "Story format directory ID (e.g. 'sugarcube-2')."
31+
},
32+
"startPassage": {
33+
"type": "string",
34+
"description": "Name of the starting passage.",
35+
"default": "Start"
36+
},
37+
"formatPaths": {
38+
"type": "array",
39+
"items": { "type": "string" },
40+
"description": "Extra directories to search for story formats."
41+
},
42+
"formatIndices": {
43+
"type": "array",
44+
"items": { "type": "string" },
45+
"description": "URLs to SFA-compatible index.json files for remote format lookup."
46+
},
47+
"formatUrls": {
48+
"type": "array",
49+
"items": { "type": "string" },
50+
"description": "Direct URLs to format.js files."
51+
},
52+
"useTweegoPath": {
53+
"type": "boolean",
54+
"default": true,
55+
"description": "Also search TWEEGO_PATH env for formats."
56+
},
57+
"modules": {
58+
"type": "array",
59+
"items": { "type": "string" },
60+
"description": "Module files to inject into <head>."
61+
},
62+
"headFile": {
63+
"type": "string",
64+
"description": "Raw HTML file to append to <head>."
65+
},
66+
"trim": {
67+
"type": "boolean",
68+
"default": true,
69+
"description": "Trim passage whitespace."
70+
},
71+
"twee2Compat": {
72+
"type": "boolean",
73+
"default": false,
74+
"description": "Twee2 compatibility mode."
75+
},
76+
"testMode": {
77+
"type": "boolean",
78+
"default": false,
79+
"description": "Enable debug/test mode option."
80+
},
81+
"noRemote": {
82+
"type": "boolean",
83+
"default": false,
84+
"description": "Disable remote format fetching."
85+
},
86+
"tagAliases": {
87+
"type": "object",
88+
"additionalProperties": { "type": "string" },
89+
"description": "Map alias tags to canonical special tags (e.g. { \"library\": \"script\" })."
90+
},
91+
"sourceInfo": {
92+
"type": "boolean",
93+
"default": false,
94+
"description": "Emit source file and line as data- attributes on passage elements."
95+
}
96+
}
97+
}

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ export function validateConfig(data: unknown): string[] {
124124

125125
/** Return a default config JSON string for --init scaffolding. */
126126
export function scaffoldConfig(): string {
127-
const config: TweeTsConfig = {
127+
const config = {
128+
$schema: 'https://unpkg.com/@rohal12/twee-ts/schemas/twee-ts.config.schema.json',
128129
sources: ['src/'],
129130
output: 'story.html',
130131
};

test/config.test.ts

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect } from 'vitest';
22
import { join } from 'node:path';
3-
import { mkdirSync, writeFileSync, rmSync } from 'node:fs';
3+
import { mkdirSync, writeFileSync, rmSync, readFileSync } from 'node:fs';
44
import { validateConfig, loadConfig, scaffoldConfig, CONFIG_FILENAME } from '../src/config.js';
55

66
const TMP_DIR = join(__dirname, '.tmp-config-test');
@@ -145,10 +145,52 @@ describe('loadConfig', () => {
145145
});
146146

147147
describe('scaffoldConfig', () => {
148-
it('returns valid JSON with sources and output', () => {
148+
it('returns valid JSON with $schema, sources, and output', () => {
149149
const json = scaffoldConfig();
150150
const parsed = JSON.parse(json);
151+
expect(parsed.$schema).toBe('https://unpkg.com/@rohal12/twee-ts/schemas/twee-ts.config.schema.json');
151152
expect(parsed.sources).toEqual(['src/']);
152153
expect(parsed.output).toBe('story.html');
153154
});
154155
});
156+
157+
describe('JSON Schema', () => {
158+
it('is valid JSON and covers all TweeTsConfig fields', () => {
159+
const schemaPath = join(__dirname, '..', 'schemas', 'twee-ts.config.schema.json');
160+
const schema = JSON.parse(readFileSync(schemaPath, 'utf-8'));
161+
162+
expect(schema.type).toBe('object');
163+
164+
const expectedFields = [
165+
'sources',
166+
'output',
167+
'outputMode',
168+
'formatId',
169+
'startPassage',
170+
'formatPaths',
171+
'formatIndices',
172+
'formatUrls',
173+
'useTweegoPath',
174+
'modules',
175+
'headFile',
176+
'trim',
177+
'twee2Compat',
178+
'testMode',
179+
'noRemote',
180+
'tagAliases',
181+
'sourceInfo',
182+
];
183+
184+
for (const field of expectedFields) {
185+
expect(schema.properties).toHaveProperty(field);
186+
}
187+
});
188+
189+
it('accepts $schema field in config validation', () => {
190+
const errors = validateConfig({
191+
$schema: 'https://unpkg.com/@rohal12/twee-ts/schemas/twee-ts.config.schema.json',
192+
sources: ['src/'],
193+
});
194+
expect(errors).toEqual([]);
195+
});
196+
});

0 commit comments

Comments
 (0)