Skip to content

Commit 3a578e9

Browse files
authored
Cleanup deps & peers (#20)
- make all codemirror dependencies peers - all lang modes are optional dependencies - move some to dev dependencies - more readme improvements
1 parent 97af84e commit 3a578e9

File tree

11 files changed

+422
-950
lines changed

11 files changed

+422
-950
lines changed

.changeset/large-eyes-repair.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"codemirror-json-schema": minor
3+
---
4+
5+
move everything codemirror related to a peer dependency. see readme for new install instructions

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,31 @@ It's at a very early stage, but usable.
1919

2020
## Usage
2121

22-
You will need to install the relevant language mode for our library to use.
22+
To give you as much flexibility as possible, everything codemirror related is a peer or optional dependency
23+
24+
Based on whether you want to support json4, json5 or both, you will need to install the relevant language mode for our library to use.
2325

2426
### json4
2527

28+
with `auto-install-peers true` or similar:
29+
2630
```
2731
npm install --save @codemirror/lang-json codemirror-json-schema
2832
```
2933

34+
without `auto-install-peers true`:
35+
36+
```
37+
npm install --save @codemirror/lang-json codemirror-json-schema @codemirror/language @codemirror/lint @codemirror/view @codemirror/state @lezer/common
38+
```
39+
40+
#### Minimal Usage
41+
3042
```ts
31-
import { json } from "@codemirror/lang-json";
32-
import { jsonSchemaLinting, jsonSchemaHover } from "codemirror-json-schema";
43+
import { EditorState } from "@codemirror/state";
44+
import { linter } from "@codemirror/lint";
45+
import { json, jsonParseLinter } from "@codemirror/lang-json";
46+
import { jsonSchemaLinter, jsonSchemaHover } from "codemirror-json-schema";
3347

3448
const schema = {
3549
type: "object",
@@ -56,15 +70,27 @@ const state = EditorState.create({
5670

5771
### json5
5872

73+
with `auto-install-peers true` or similar:
74+
75+
```
76+
npm install --save codemirror-json5 codemirror-json-schema
77+
```
78+
79+
without `auto-install-peers true`:
80+
5981
```
60-
npm install --save codemirror-json codemirror-json-schema json5
82+
npm install --save codemirror-json5 codemirror-json-schema @codemirror/language @codemirror/lint @codemirror/view @codemirror/state @lezer/common
6183
```
6284

85+
#### Minimal Usage
86+
6387
```ts
64-
import { json5 } from "codemirror-json5";
88+
import { EditorState } from "@codemirror/state";
89+
import { linter } from "@codemirror/lint";
90+
import { json5, json5ParseLinter } from "codemirror-json5";
6591
import {
66-
jsonSchemaLinting,
67-
jsonSchemaHover,
92+
json5SchemaLinter,
93+
json5SchemaHover,
6894
} from "codemirror-json-schema/json5";
6995

7096
const schema = {

docs/modules/index.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ provides a JSON schema enabled autocomplete extension for codemirror
6363

6464
#### Defined in
6565

66-
[json-completion.ts:820](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json-completion.ts#L820)
66+
[json-completion.ts:820](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json-completion.ts#L820)
6767

6868
---
6969

@@ -100,7 +100,7 @@ provides a JSON schema enabled tooltip extension for codemirror
100100

101101
#### Defined in
102102

103-
[json-hover.ts:24](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json-hover.ts#L24)
103+
[json-hover.ts:24](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json-hover.ts#L24)
104104

105105
---
106106

@@ -135,7 +135,7 @@ Helper for simpler class instantiaton
135135

136136
#### Defined in
137137

138-
[json-validation.ts:35](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json-validation.ts#L35)
138+
[json-validation.ts:35](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json-validation.ts#L35)
139139

140140
## Utilities
141141

@@ -162,7 +162,7 @@ this could be useful for other things later!
162162

163163
#### Defined in
164164

165-
[utils/jsonPointers.ts:37](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/utils/jsonPointers.ts#L37)
165+
[utils/jsonPointers.ts:37](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/utils/jsonPointers.ts#L37)
166166

167167
---
168168

@@ -185,7 +185,7 @@ retrieve a Map of all the json pointers in a document
185185

186186
#### Defined in
187187

188-
[utils/jsonPointers.ts:98](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/utils/jsonPointers.ts#L98)
188+
[utils/jsonPointers.ts:98](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/utils/jsonPointers.ts#L98)
189189

190190
---
191191

@@ -210,7 +210,7 @@ retrieve a JSON pointer for a given position in the editor
210210

211211
#### Defined in
212212

213-
[utils/jsonPointers.ts:81](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/utils/jsonPointers.ts#L81)
213+
[utils/jsonPointers.ts:81](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/utils/jsonPointers.ts#L81)
214214

215215
---
216216

@@ -237,7 +237,7 @@ Mimics the behavior of `json-source-map`'s `parseJSONDocument` function, for jso
237237

238238
#### Defined in
239239

240-
[utils/parseJSON5Document.ts:28](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/utils/parseJSON5Document.ts#L28)
240+
[utils/parseJSON5Document.ts:28](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/utils/parseJSON5Document.ts#L28)
241241

242242
---
243243

@@ -264,7 +264,7 @@ Return parsed data and json5 pointers for a given codemirror EditorState
264264

265265
#### Defined in
266266

267-
[utils/parseJSON5Document.ts:14](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/utils/parseJSON5Document.ts#L14)
267+
[utils/parseJSON5Document.ts:14](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/utils/parseJSON5Document.ts#L14)
268268

269269
---
270270

@@ -291,7 +291,7 @@ Mimics the behavior of `json-source-map`'s `parseJSONDocument` function using co
291291

292292
#### Defined in
293293

294-
[utils/parseJSONDocument.ts:23](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/utils/parseJSONDocument.ts#L23)
294+
[utils/parseJSONDocument.ts:23](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/utils/parseJSONDocument.ts#L23)
295295

296296
---
297297

@@ -318,7 +318,7 @@ Return parsed data and json pointers for a given codemirror EditorState
318318

319319
#### Defined in
320320

321-
[utils/parseJSONDocument.ts:9](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/utils/parseJSONDocument.ts#L9)
321+
[utils/parseJSONDocument.ts:9](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/utils/parseJSONDocument.ts#L9)
322322

323323
## Type Aliases
324324

@@ -335,7 +335,7 @@ Return parsed data and json pointers for a given codemirror EditorState
335335

336336
#### Defined in
337337

338-
[json-hover.ts:9](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json-hover.ts#L9)
338+
[json-hover.ts:9](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json-hover.ts#L9)
339339

340340
---
341341

@@ -345,7 +345,7 @@ Return parsed data and json pointers for a given codemirror EditorState
345345

346346
#### Defined in
347347

348-
[json-hover.ts:11](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json-hover.ts#L11)
348+
[json-hover.ts:11](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json-hover.ts#L11)
349349

350350
---
351351

@@ -362,7 +362,7 @@ Return parsed data and json pointers for a given codemirror EditorState
362362

363363
#### Defined in
364364

365-
[json-hover.ts:13](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json-hover.ts#L13)
365+
[json-hover.ts:13](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json-hover.ts#L13)
366366

367367
---
368368

@@ -372,7 +372,7 @@ Return parsed data and json pointers for a given codemirror EditorState
372372

373373
#### Defined in
374374

375-
[utils/jsonPointers.ts:8](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/utils/jsonPointers.ts#L8)
375+
[utils/jsonPointers.ts:8](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/utils/jsonPointers.ts#L8)
376376

377377
---
378378

@@ -389,7 +389,7 @@ Return parsed data and json pointers for a given codemirror EditorState
389389

390390
#### Defined in
391391

392-
[types.ts:3](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/types.ts#L3)
392+
[types.ts:3](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/types.ts#L3)
393393

394394
---
395395

@@ -408,7 +408,7 @@ Return parsed data and json pointers for a given codemirror EditorState
408408

409409
#### Defined in
410410

411-
[types.ts:8](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/types.ts#L8)
411+
[types.ts:8](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/types.ts#L8)
412412

413413
---
414414

@@ -418,7 +418,7 @@ Return parsed data and json pointers for a given codemirror EditorState
418418

419419
#### Defined in
420420

421-
[types.ts:15](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/types.ts#L15)
421+
[types.ts:15](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/types.ts#L15)
422422

423423
---
424424

@@ -435,4 +435,4 @@ Return parsed data and json pointers for a given codemirror EditorState
435435

436436
#### Defined in
437437

438-
[json-validation.ts:24](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json-validation.ts#L24)
438+
[json-validation.ts:24](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json-validation.ts#L24)

docs/modules/json5.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Instantiates a JSONHover instance with the JSON5 mode
4444

4545
#### Defined in
4646

47-
[json5-hover.ts:11](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json5-hover.ts#L11)
47+
[json5-hover.ts:11](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json5-hover.ts#L11)
4848

4949
---
5050

@@ -79,4 +79,4 @@ Instantiates a JSONValidation instance with the JSON5 mode
7979

8080
#### Defined in
8181

82-
[json5-validation.ts:10](https://github.com/acao/cm6-language-json-schema/blob/958509c/src/json5-validation.ts#L10)
82+
[json5-validation.ts:10](https://github.com/acao/codemirror-json-schema/blob/c97650d/src/json5-validation.ts#L10)

lefthook.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ pre-commit:
1010
prettier:
1111
glob: "*.{js,ts,jsx,tsx,json,css,html,yml,mdx,md}"
1212
run: pnpm prettier --write {staged_files}
13+
stage_fixed: true
1314
typedoc:
1415
run: pnpm typedoc
1516
glob: "*.{js,ts,jsx,tsx}"
17+
stage_fixed: true
1618
test:
17-
run: pnpm test:coverage
19+
run: pnpm vitest related --run --dom {staged_files}
20+
glob: "*.{js,ts,jsx,tsx}"
21+
fail_text: Tests failed or not found on {staged_files}
22+
check:
23+
run: pnpm tsc --noEmit
1824
glob: "*.{js,ts,jsx,tsx}"

package.json

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,26 @@
4242
"types": "./dist/json5.d.ts"
4343
}
4444
},
45-
"repository": {
46-
"type": "git",
47-
"url": "https://github.com/acao/codemirror-json-schema.git"
48-
},
45+
"repository": "github:acao/codemirror-json-schema",
4946
"homepage": "https://codemirror-json-schema.netlify.app/",
5047
"dependencies": {
51-
"@changesets/cli": "^2.26.2",
52-
"@codemirror/autocomplete": "^6.8.1",
53-
"@codemirror/buildhelper": "^1.0.0",
54-
"@codemirror/commands": "^6.2.4",
55-
"@codemirror/lang-json": "^6.0.1",
56-
"@codemirror/language": "^6.8.0",
57-
"@codemirror/lint": "^6.4.0",
58-
"@codemirror/state": "^6.2.1",
59-
"@codemirror/theme-one-dark": "^6.1.2",
60-
"@codemirror/view": "^6.14.1",
61-
"@lezer/common": "^1.0.3",
6248
"@sagold/json-pointer": "^5.1.1",
6349
"@types/json-schema": "^7.0.12",
64-
"codemirror": "^6.0.1",
65-
"json-schema": "0.2.3",
66-
"json-schema-library": "^8.0.0",
67-
"typedoc": "^0.24.8",
68-
"typedoc-plugin-markdown": "^3.15.3"
50+
"json-schema": "^0.2.3",
51+
"json-schema-library": "^8.0.0"
6952
},
7053
"optionalDependencies": {
54+
"@codemirror/lang-json": "^6.0.1",
7155
"codemirror-json5": "^1.0.3",
7256
"json5": "^2.2.3"
7357
},
58+
"peerDependencies": {
59+
"@lezer/common": "^1.0.3",
60+
"@codemirror/language": "^6.8.0",
61+
"@codemirror/lint": "^6.4.0",
62+
"@codemirror/state": "^6.2.1",
63+
"@codemirror/view": "^6.14.1"
64+
},
7465
"devDependencies": {
7566
"@vitest/coverage-v8": "^0.33.0",
7667
"codemirror-json5": "^1.0.3",
@@ -80,14 +71,22 @@
8071
"typescript": "^5.1.6",
8172
"vite": "^4.4.4",
8273
"vitest": "0.33.0",
83-
"vitest-dom": "^0.1.0"
74+
"vitest-dom": "^0.1.0",
75+
"@changesets/cli": "^2.26.2",
76+
"typedoc": "^0.24.8",
77+
"typedoc-plugin-markdown": "^3.15.3",
78+
"@codemirror/theme-one-dark": "^6.1.2",
79+
"@codemirror/autocomplete": "^6.8.1",
80+
"@codemirror/commands": "^6.2.4",
81+
"codemirror": "^6.0.1"
8482
},
8583
"scripts": {
8684
"dev": "vite ./dev --port 3000",
8785
"build": "tsc && vite build ./dev --outDir ../public --emptyOutDir && pnpm typedoc",
8886
"test": "vitest --dom",
8987
"test:coverage": "vitest run --dom --coverage",
9088
"release": "pnpm build && changeset publish",
91-
"typedoc": "typedoc --out docs src/index.ts src/json5.ts"
89+
"typedoc": "typedoc --out docs src/index.ts src/json5.ts",
90+
"postinstall": "lefthook install"
9291
}
9392
}

0 commit comments

Comments
 (0)