-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add JSON schema for config file
- Loading branch information
Showing
7 changed files
with
87 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"@digdir/designsystemet": minor | ||
--- | ||
|
||
Add JSON schema for CLI config file, which enables editor hints. To use it, do something like this: | ||
```jsonc | ||
{ | ||
"$schema": "node_modules/@digdir/designsystemet/dist/config.schema.json" | ||
// ...config options here... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { writeFile } from 'node:fs/promises'; | ||
import { resolve } from 'node:path'; | ||
import { z } from 'zod'; | ||
import { zodToJsonSchema } from 'zod-to-json-schema'; | ||
import { configFileSchema } from '../../bin/config.js'; | ||
|
||
const schema = z | ||
.object({ | ||
$schema: z.string().optional(), | ||
}) | ||
.extend(configFileSchema.shape); | ||
|
||
writeFile( | ||
resolve(import.meta.dirname, '../../dist/config.schema.json'), | ||
JSON.stringify(zodToJsonSchema(schema), undefined, 2), | ||
{ | ||
encoding: 'utf-8', | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"$schema": "./dist/config.schema.json", | ||
"outDir": "./test-tokens-create", | ||
"themes": { | ||
"some-org": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"$schema": "./dist/config.schema.json", | ||
"outDir": "./test-tokens-create", | ||
"themes": { | ||
"digdir": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters