@scalar/cli 2.13.1 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +46 -8
  2. package/chunks/{action-2BZ3AFBR.js → action-2BGAMGXU.js} +7 -6
  3. package/chunks/{action-27BJMHFD.js → action-2HPMP473.js} +4 -4
  4. package/chunks/{action-PBJFNJMY.js → action-3KP3WVPZ.js} +8 -7
  5. package/chunks/{action-5QDBZTBF.js → action-4HXB3YQR.js} +12 -11
  6. package/chunks/{action-3R3MVTP3.js → action-4HYLZRYW.js} +22 -21
  7. package/chunks/{action-WI6UW2AL.js → action-4MJXPSQU.js} +16 -15
  8. package/chunks/{action-JFNK5UCV.js → action-57SV3ZBM.js} +7 -6
  9. package/chunks/{action-FZZ2VLNA.js → action-6HFH7DAW.js} +7 -6
  10. package/chunks/{action-FR6UPGZP.js → action-APBLB3IU.js} +7 -6
  11. package/chunks/{action-5JTBIUPZ.js → action-APTGKF4W.js} +38 -36
  12. package/chunks/{action-CXQ3HLVC.js → action-BL5PWLFV.js} +21 -20
  13. package/chunks/{action-7HHTD65O.js → action-C7CNI7TP.js} +10 -10
  14. package/chunks/{action-VEXFHEQR.js → action-DJXZWPL7.js} +8 -7
  15. package/chunks/{action-F5LSDVJA.js → action-EPGLU5E3.js} +16 -15
  16. package/chunks/{action-WY4GOD2Y.js → action-EYOZ457H.js} +17 -16
  17. package/chunks/{action-XXIRB2F6.js → action-FLX3ESH7.js} +22 -21
  18. package/chunks/{action-JRPGHJGA.js → action-FOITEQNQ.js} +16 -15
  19. package/chunks/{action-5HWPNWVU.js → action-GOFCT7XK.js} +21 -20
  20. package/chunks/{action-KRXJWRCE.js → action-MJI3TI3W.js} +19 -18
  21. package/chunks/{action-PDOW5JS2.js → action-OP5DCAHN.js} +18 -16
  22. package/chunks/{action-W5VD63XO.js → action-P2QEJUBK.js} +11 -11
  23. package/chunks/{action-IUG6MPST.js → action-RRQNVUFW.js} +8 -8
  24. package/chunks/{action-3DBOUHKS.js → action-SCOJRZKD.js} +11 -10
  25. package/chunks/{action-ASBFLTOA.js → action-SRFBOLDL.js} +1 -1
  26. package/chunks/{action-W3AGGZ42.js → action-TR2T2UYB.js} +7 -6
  27. package/chunks/{action-3P66ZSL3.js → action-U2RJ3ZAU.js} +4 -4
  28. package/chunks/{action-RYLO75IN.js → action-VAJSWBMD.js} +14 -14
  29. package/chunks/{action-WEDLKGDY.js → action-VEP7LZPN.js} +4 -4
  30. package/chunks/{action-WQPMJZXL.js → action-VS22CPVB.js} +17 -16
  31. package/chunks/{action-GRAMP3QD.js → action-VW2POHCL.js} +15 -15
  32. package/chunks/{action-JEI24ZNE.js → action-VY3DRAO4.js} +11 -8
  33. package/chunks/{action-JCBTINNL.js → action-WOLNPEUQ.js} +10 -8
  34. package/chunks/{action-GLC54N3F.js → action-XA4MEYFP.js} +14 -14
  35. package/chunks/{action-GIKW67JB.js → action-Y4MKBDRC.js} +18 -17
  36. package/chunks/{action-EGF7LXVA.js → action-ZOU7EPX5.js} +19 -18
  37. package/chunks/{actions-I4HS6ASR.js → actions-PBYTDEMH.js} +16 -15
  38. package/chunks/{agent-E6PYTXAU.js → agent-NA3QFKJX.js} +7 -5
  39. package/chunks/{asyncapi-VQ7CCUCY.js → asyncapi-KCA6ZH3Q.js} +23 -18
  40. package/chunks/{build.action-LIAREWUF.js → build.action-54FHG7VL.js} +18 -17
  41. package/chunks/{chunk-JHJDLZSM.js → chunk-2KSOARE4.js} +2 -2
  42. package/chunks/{chunk-BDNCJLJP.js → chunk-2SBHCZPG.js} +1 -1
  43. package/chunks/{chunk-GARUDDWI.js → chunk-3CRO6NY4.js} +3 -1
  44. package/chunks/{chunk-UNV7BZD3.js → chunk-42YF4H6W.js} +2 -2
  45. package/chunks/{chunk-5ENKYZA4.js → chunk-4S3DGMMZ.js} +1 -1
  46. package/chunks/chunk-5D3T63G4.js +14 -0
  47. package/chunks/{chunk-F3TQHNSQ.js → chunk-6BQHLHBE.js} +7 -3
  48. package/chunks/{chunk-P4EPNS46.js → chunk-7FS7BAUX.js} +3 -3
  49. package/chunks/{chunk-M4QTWCJ7.js → chunk-7PNOYE6B.js} +4 -1
  50. package/chunks/{chunk-KTI65ZVY.js → chunk-7ZDC34NA.js} +28 -8
  51. package/chunks/{chunk-QS2T7JAK.js → chunk-AAWPGVMG.js} +2 -2
  52. package/chunks/{chunk-APX65SRT.js → chunk-ADQ6B6QI.js} +1 -1
  53. package/chunks/{chunk-QRYMQPFT.js → chunk-BLY2CF4S.js} +3 -1
  54. package/chunks/{chunk-VRZSDUZK.js → chunk-BOCMOHQA.js} +8 -1
  55. package/chunks/chunk-BY4NGQ5D.js +15 -0
  56. package/chunks/{chunk-RZDLPTXV.js → chunk-DTZBE4ZX.js} +3 -3
  57. package/chunks/{chunk-2XWUFFEZ.js → chunk-E24BNP6E.js} +1 -1
  58. package/chunks/{chunk-RQNLEGMQ.js → chunk-EOTD7HAV.js} +1 -1
  59. package/chunks/{chunk-YTTDYTVB.js → chunk-F5Q7FJRG.js} +1 -1
  60. package/chunks/chunk-GO3TSREI.js +27 -0
  61. package/chunks/{chunk-6VAEDMCP.js → chunk-H5AMMMQ3.js} +77 -11
  62. package/chunks/{chunk-RAJM56L7.js → chunk-HIDIW2FN.js} +1 -1
  63. package/chunks/{chunk-LK2ZIDHH.js → chunk-IDGT5RAQ.js} +1 -1
  64. package/chunks/chunk-IPUJEBMI.js +9 -0
  65. package/chunks/{chunk-XFBCZL7J.js → chunk-KKHTS43A.js} +3 -3
  66. package/chunks/{chunk-R3NDJICA.js → chunk-KXMZXTLK.js} +1 -1
  67. package/chunks/{chunk-QUUBUPAW.js → chunk-KZSM2SUL.js} +4 -4
  68. package/chunks/{chunk-MQ65WBVF.js → chunk-PIDLENYN.js} +7192 -6436
  69. package/chunks/{chunk-PWFA23M2.js → chunk-PRW5TKYS.js} +1 -1
  70. package/chunks/{chunk-4YQVGOHX.js → chunk-QMERQSPM.js} +2 -2
  71. package/chunks/{chunk-HZ4UKLOE.js → chunk-QTMJ3VUZ.js} +2 -2
  72. package/chunks/{chunk-LUR7BA3W.js → chunk-RRYUCZYO.js} +2 -2
  73. package/chunks/{chunk-SNSJW2JT.js → chunk-S3U2VMVL.js} +2 -2
  74. package/chunks/{chunk-DWN6JOF2.js → chunk-UM3WZUGF.js} +4 -12
  75. package/chunks/{chunk-X62ZTOQF.js → chunk-USVU6AC2.js} +23 -5
  76. package/chunks/{chunk-SIPBGEVT.js → chunk-VJ7FHLN4.js} +2 -2
  77. package/chunks/{chunk-FXELV3AW.js → chunk-W7P6VTCG.js} +25 -2
  78. package/chunks/{chunk-IDWF5L45.js → chunk-WKMOUBQJ.js} +7884 -3730
  79. package/chunks/{chunk-NOD4CBF7.js → chunk-WZSU45SV.js} +1 -1
  80. package/chunks/{chunk-6YDIOXF7.js → chunk-WZUA7IAV.js} +2 -2
  81. package/chunks/{create.action-PZMCTYGS.js → create.action-NB3YYZ7K.js} +18 -17
  82. package/chunks/{delete.action-J57JIFG3.js → delete.action-5BT3TXVZ.js} +21 -17
  83. package/chunks/{delete.action-VDSTPSWG.js → delete.action-DWMQYW62.js} +21 -17
  84. package/chunks/diff.action-ENOOLRRB.js +324 -0
  85. package/chunks/{get.action-KUP32QJT.js → get.action-2ASGSZW3.js} +17 -16
  86. package/chunks/{get.action-ZOSML6XG.js → get.action-55JDC2MJ.js} +21 -27
  87. package/chunks/{list.action-VYENIC5L.js → list.action-6QBQFGVR.js} +17 -16
  88. package/chunks/{list.action-Q5MPDR42.js → list.action-NCG6Q6S2.js} +21 -20
  89. package/chunks/{publish.action-MBAZHQ2J.js → publish.action-4Y5EXBOY.js} +38 -36
  90. package/chunks/{update.action-IEXVMUKG.js → update.action-4V6MQMWG.js} +19 -18
  91. package/chunks/{update.action-BWMCXWQ5.js → update.action-6OE54B5O.js} +18 -17
  92. package/index.js +268 -206
  93. package/package.json +13 -12
  94. package/skills/scalar-cli/SKILL.md +3 -2
  95. package/template.md +45 -7
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "engines": {
6
6
  "node": ">=24"
7
7
  },
8
- "version": "2.13.1",
8
+ "version": "2.14.0",
9
9
  "keywords": [
10
10
  "scalar",
11
11
  "openapi",
@@ -22,16 +22,16 @@
22
22
  "@clack/prompts": "0.7.0",
23
23
  "@hono/node-server": "2.1.1",
24
24
  "@quobix/vacuum": "0.30.1",
25
- "@scalar/asyncapi-upgrader": "0.1.15",
26
- "@scalar/asyncapi-validator": "0.1.10",
27
- "@scalar/json-magic": "0.15.5",
28
- "@scalar/mock-server": "0.17.4",
29
- "@scalar/openapi-to-markdown": "1.5.2",
30
- "@scalar/openapi-upgrader": "0.4.2",
31
- "@scalar/openapi-validator": "0.1.10",
32
- "@scalar/postman-to-openapi": "0.7.25",
33
- "@scalar/void-server": "2.5.15",
34
- "@scalar/workspace-store": "0.68.1",
25
+ "@scalar/asyncapi-upgrader": "0.1.18",
26
+ "@scalar/asyncapi-validator": "0.1.17",
27
+ "@scalar/json-magic": "0.17.0",
28
+ "@scalar/mock-server": "0.20.3",
29
+ "@scalar/openapi-to-markdown": "1.7.3",
30
+ "@scalar/openapi-upgrader": "0.4.6",
31
+ "@scalar/openapi-validator": "0.1.17",
32
+ "@scalar/postman-to-openapi": "0.7.28",
33
+ "@scalar/void-server": "2.5.19",
34
+ "@scalar/workspace-store": "0.69.3",
35
35
  "@stoplight/spectral-core": "1.22.0",
36
36
  "@stoplight/spectral-parsers": "1.0.5",
37
37
  "@stoplight/spectral-ruleset-bundler": "1.7.0",
@@ -41,7 +41,7 @@
41
41
  "commander": "13.1.0",
42
42
  "console-table-printer": "2.16.1",
43
43
  "get-port": "7.2.0",
44
- "hono": "^4.12.25",
44
+ "hono": "^4.13.13",
45
45
  "ignore": "7.0.5",
46
46
  "jsonc-parser": "3.2.1",
47
47
  "nanoid": "6.0.1",
@@ -51,6 +51,7 @@
51
51
  "stdout-update": "4.0.1",
52
52
  "tar-fs": "3.1.2",
53
53
  "undici": "8.10.2",
54
+ "ws": "^8.21.0",
54
55
  "yaml": "2.8.3"
55
56
  }
56
57
  }
@@ -5,13 +5,13 @@ description: "Operate the Scalar CLI (`scalar`, or `npx @scalar/cli`) to validat
5
5
 
6
6
  # Scalar CLI
7
7
 
8
- Validate, lint, bundle, mock, and preview OpenAPI and AsyncAPI descriptions, and publish them to Scalar (`@scalar/cli` 2.13.1).
8
+ Validate, lint, bundle, mock, and preview OpenAPI and AsyncAPI descriptions, and publish them to Scalar (`@scalar/cli` 2.14.0).
9
9
 
10
10
  ## Operating notes
11
11
 
12
12
  - Run `scalar <command>` when the CLI is installed, or `npx @scalar/cli <command>` when it is not.
13
13
  - Run `scalar context` for this command tree as JSON, or `scalar <command> --help` for a single command.
14
- - Log in with a personal token: `scalar auth login --token <token>`, or set `SCALAR_API_KEY` and run `scalar auth login`. Both store the session on disk for later commands. Without a token, `scalar auth login` opens a browser and waits for a person to log in, so do not run it that way. Check the session with `scalar auth whoami`.
14
+ - Log in with a personal token: `scalar auth login --token <token>`, or set `SCALAR_API_KEY` and run `scalar auth login`. An explicit --token overrides SCALAR_API_KEY and must not be empty or whitespace-only. Both store the session on disk for later commands. Without a token, `scalar auth login` opens a browser and waits for a person to log in, so do not run it that way. Check the session with `scalar auth whoami`.
15
15
  - Use --no-input before or after subcommands to disable prompts and browser launches, including under a PTY. Supply required values explicitly; missing inputs fail with exit code 1 and guidance. Piped input is never a confirmation. Cancelled prompts and EOF exit with code 1. The flag does not imply --yes or --force and neither option chooses an unspecified target.
16
16
  - Many commands prompt when a value is left out, such as a slug, a team, or a confirmation before overwriting a file, and missing values fail when interaction is disabled. Pass every value as an argument or flag: for example `--output` on `document bundle` and `document upgrade`, `--yes` on `project rollback`, and `--force` on `project init`.
17
17
  - Results go to stdout. Errors go to stderr, prefixed with `[ERROR]`.
@@ -83,3 +83,4 @@ Run `scalar context` for the arguments, options, defaults, and choices of each c
83
83
  - `scalar schema list [options]`: List shared schemas in a team namespace
84
84
  - `scalar schema get [options] [namespace] [slug]`: Download a shared schema version from the Scalar Registry
85
85
  - `scalar schema publish [options] [file]`: Publish a shared schema to the Scalar Registry
86
+ - `scalar schema diff [options] <from> <to>`: Compare two schema versions, files, or URLs
package/template.md CHANGED
@@ -88,6 +88,20 @@ scalar project publish --slug my-docs
88
88
 
89
89
  Push API descriptions to the [Scalar Registry](https://scalar.com/products/registry/getting-started), preview a Scalar Docs project locally, and publish it. In CI, run `scalar auth login --token <token>`, or set `SCALAR_API_KEY` and run `scalar auth login`.
90
90
 
91
+ ### Compare schemas
92
+
93
+ ```bash
94
+ scalar schema diff acme/widget@1.0.0 acme/widget@2.0.0
95
+ scalar schema diff acme/widget@1.0.0 acme/widget@2.0.0 --verbose
96
+ scalar schema diff acme/widget@1.0.0 acme/widget@latest --json
97
+
98
+ # CI: fail the job if the local schema drifted from what is published
99
+ scalar schema diff acme/widget@latest ./widget.json --check --verbose
100
+ scalar schema diff acme/widget@latest ./widget.json --check --quiet --ignore /description /examples
101
+ ```
102
+
103
+ Each side is a published schema (`namespace/slug@version`, where the version defaults to `latest`), a file, or a URL. Both sides are parsed and compared structurally, so formatting, key order, and JSON versus YAML never count as changes. The order of items in an array, including `required`, `enum`, and `type`, does count. Changes are listed by JSON Pointer into the documents as written. An existing path always counts as a file: prefix `./` to force a file, or add `@latest` to force the Scalar Registry. `--ignore <pointer...>` skips changes at or under a JSON Pointer, so `/properties/legacy` also skips `/properties/legacy/type` but not `/properties/legacyId`. A change above the pointer, such as all of `/properties` being added, is still reported in full. Put it after the two schemas.
104
+
91
105
  ## Install
92
106
 
93
107
  Standalone binary, no Node.js required:
@@ -143,6 +157,10 @@ The flag works before or after subcommands. It disables prompts and browser laun
143
157
 
144
158
  For `auth login`, supply a personal token using the existing `SCALAR_API_KEY` source or `--token`; without one, noninteractive login fails before starting a browser or callback server. `project preview` still runs the requested preview server but never opens its browser under `--no-input`, even with an opening option. `readme` prints the documentation URL without launching a browser.
145
159
 
160
+ An explicit `--token` takes precedence over `SCALAR_API_KEY`. An empty or whitespace-only `--token` fails without falling back to the environment or browser login. With no flag, environment-only authentication remains supported; an unset or empty environment value uses browser login, or fails under `--no-input`.
161
+
162
+ Compatibility: login previously preferred `SCALAR_API_KEY` when both sources were supplied. Scripts that rely on the environment credential must omit `--token`. The selected credential is saved for later commands.
163
+
146
164
  ## Use in CI
147
165
 
148
166
  ```yml
@@ -163,6 +181,25 @@ jobs:
163
181
 
164
182
  `--format github-actions` turns findings into annotations on the pull request. [JSON output, JUnit reports, and lint baselines →](https://scalar.com/tools/cli/ci-and-scripting)
165
183
 
184
+ To fail a job when a schema in the repository drifts from the published version, run `schema diff` with `--check`. `--verbose` prints every changed value to the job log, and a distinct exit code such as `--check 2` lets the job tell schema drift apart from an authentication or network error, which exit 1:
185
+
186
+ ```yml
187
+ steps:
188
+ - uses: actions/checkout@v6
189
+ - run: npx --yes @scalar/cli auth login
190
+ env:
191
+ SCALAR_API_KEY: ${{ secrets.SCALAR_API_KEY }}
192
+ - run: npx --yes @scalar/cli schema diff acme/widget@latest ./widget.json --check 2 --verbose
193
+ ```
194
+
195
+ | `schema diff` invocation | Identical | Differ | Error (authentication, download, parse, bad input) |
196
+ | ------------------------ | --------- | ------ | -------------------------------------------------- |
197
+ | no `--check` | exit 0 | exit 0 | exit 1 |
198
+ | `--check` | exit 0 | exit 1 | exit 1 |
199
+ | `--check <n>` (1–125) | exit 0 | exit n | exit 1 |
200
+
201
+ Put `--check` after the two schemas, or write `--check=<n>`: an optional value takes the next argument, so `--check acme/widget@1.0.0 …` is rejected. Errors always print to stderr, even with `--quiet`. To tell a difference from an error without a distinct code, read `identical` from `--json`.
202
+
166
203
  ## Commands
167
204
 
168
205
  <COMMANDS>
@@ -208,13 +245,14 @@ even in a terminal.
208
245
 
209
246
  #### List contracts
210
247
 
211
- | Command | JSON value |
212
- | ------------------------------ | -------------------------------------------------------------------------------------------------------- |
213
- | `team list --json` | Array of `{uid: string, name: string, current: boolean}` |
214
- | `registry list --json` | Array of `{namespace: string, slug: string, title: string, version: string, isPrivate: boolean}` |
215
- | `schema list --json` | Array of `{namespace: string, slug: string, title: string, version: string \| null, isPrivate: boolean}` |
216
- | `sdk list --json` | Array of SDK metadata objects described below |
217
- | `sdk get --slug <slug> --json` | One SDK metadata object |
248
+ | Command | JSON value |
249
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
250
+ | `team list --json` | Array of `{uid: string, name: string, current: boolean}` |
251
+ | `registry list --json` | Array of `{namespace: string, slug: string, title: string, version: string, isPrivate: boolean}` |
252
+ | `schema list --json` | Array of `{namespace: string, slug: string, title: string, version: string \| null, isPrivate: boolean}` |
253
+ | `sdk list --json` | Array of SDK metadata objects described below |
254
+ | `sdk get --slug <slug> --json` | One SDK metadata object |
255
+ | `schema diff <from> <to> --json` | `{from: string, to: string, identical: boolean, changes: Array<{type: "added" \| "removed" \| "changed", path: string, before?: unknown, after?: unknown}>}` |
218
256
 
219
257
  Schema `version` is the greatest version by semantic-version comparison, or
220
258
  `null` when no version exists. Registry `version` is the current version.