Skip to content

Commit b104741

Browse files
pieternTanishqDatabricks
authored andcommitted
Replace nwidger/jsoncolor with an in-tree colorizer (databricks#5170)
## Changes Drop `github.com/nwidger/jsoncolor` and replace `fancyJSON` with a small in-tree colorizer over `json.MarshalIndent` output. Same ANSI palette as before (green strings, cyan numbers, bold-green `true`, red `false`, magenta `null`, bold-blue keys). `defaultRenderer.renderJson` now gates colorization on cmdio TTY/color capabilities; `pretty_json` template helper stays on `!color.NoColor` for parity with the other helpers in `renderFuncMap`. ## Why `fancyJSON` was the last caller of `nwidger/jsoncolor`, and it was the only thing forcing `fatih/color.Color` values across a package boundary. Removing it unblocks a future `fatih/color` migration and replaces the incidental "color is off because fatih's package init saw stdout isn't a TTY" gating with explicit cmdio capability checks. ## Tests - Unit tests in `libs/cmdio/jsoncolor_test.go` cover string/number/literal tokens, escape sequences, key vs value, empty containers, and a round-trip property test (stripping ANSI yields the original bytes). - Manual smoke: `databricks current-user me -o json` on a TTY shows the same colors as before; piped or `NO_COLOR=1` produces plain JSON. _PR description drafted with Claude Code._
1 parent bcc52e5 commit b104741

68 files changed

Lines changed: 1061 additions & 698 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### CLI
66

77
* `databricks api` now works against unified hosts. Adds `--account` to scope a call to the account API and `--workspace-id` to override the workspace routing identifier per call. A `?o=<workspace-id>` query parameter on the path (the SPOG URL convention used by the Databricks UI) is also recognized as a per-call workspace override, so URLs pasted from the browser route correctly.
8+
* JSON output for single objects now uses standard `"key": "value"` spacing (matching list output and `encoding/json` defaults).
89

910
### Bundles
1011

NOTICE

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ mattn/go-isatty - https://github.com/mattn/go-isatty
155155
Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
156156
License - https://github.com/mattn/go-isatty/blob/master/LICENSE
157157

158-
nwidger/jsoncolor - https://github.com/nwidger/jsoncolor
159-
Copyright (c) 2016 Niels Widger
160-
License - https://github.com/nwidger/jsoncolor/blob/master/LICENSE
161-
162158
sabhiram/go-gitignore - https://github.com/sabhiram/go-gitignore
163159
Copyright (c) 2015 Shaba Abhiram
164160
License - https://github.com/sabhiram/go-gitignore/blob/master/LICENSE
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
>>> [CLI] apps deploy test-app --no-wait
33
{
4-
"deployment_id":"dep-123",
5-
"mode":"SNAPSHOT",
6-
"source_code_path":"/Workspace/apps/test-app",
4+
"deployment_id": "dep-123",
5+
"mode": "SNAPSHOT",
6+
"source_code_path": "/Workspace/apps/test-app",
77
"status": {
8-
"message":"Deployment pending",
9-
"state":"PENDING"
8+
"message": "Deployment pending",
9+
"state": "PENDING"
1010
}
1111
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
>>> [CLI] apps deploy test-app --no-wait
33
{
4-
"deployment_id":"dep-123",
5-
"mode":"SNAPSHOT",
6-
"source_code_path":"/Workspace/apps/test-app",
4+
"deployment_id": "dep-123",
5+
"mode": "SNAPSHOT",
6+
"source_code_path": "/Workspace/apps/test-app",
77
"status": {
8-
"message":"Deployment pending",
9-
"state":"PENDING"
8+
"message": "Deployment pending",
9+
"state": "PENDING"
1010
}
1111
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"id":"[USERID]",
3-
"userName":"[USERNAME]"
2+
"id": "[USERID]",
3+
"userName": "[USERNAME]"
44
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"id":"[USERID]",
3-
"userName":"[USERNAME]"
2+
"id": "[USERID]",
3+
"userName": "[USERNAME]"
44
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"id":"[USERID]",
3-
"userName":"[USERNAME]"
2+
"id": "[USERID]",
3+
"userName": "[USERNAME]"
44
}

acceptance/auth/host-metadata-cache/output.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
{
44
"profiles": [
55
{
6-
"name":"cached",
7-
"host":"[DATABRICKS_URL]",
8-
"cloud":"aws",
9-
"auth_type":"",
10-
"valid":false
6+
"name": "cached",
7+
"host": "[DATABRICKS_URL]",
8+
"cloud": "aws",
9+
"auth_type": "",
10+
"valid": false
1111
}
1212
]
1313
}
@@ -16,11 +16,11 @@
1616
{
1717
"profiles": [
1818
{
19-
"name":"cached",
20-
"host":"[DATABRICKS_URL]",
21-
"cloud":"aws",
22-
"auth_type":"",
23-
"valid":false
19+
"name": "cached",
20+
"host": "[DATABRICKS_URL]",
21+
"cloud": "aws",
22+
"auth_type": "",
23+
"valid": false
2424
}
2525
]
2626
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
2-
"created_time":[UNIX_TIME_MILLIS],
3-
"creator_user_name":"[USERNAME]",
4-
"job_id":[NUMID],
5-
"run_as_user_name":"[USERNAME]",
2+
"created_time": [UNIX_TIME_MILLIS],
3+
"creator_user_name": "[USERNAME]",
4+
"job_id": [NUMID],
5+
"run_as_user_name": "[USERNAME]",
66
"settings": {
77
"deployment": {
8-
"kind":"BUNDLE",
9-
"metadata_file_path":"/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
8+
"kind": "BUNDLE",
9+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
1010
},
11-
"edit_mode":"UI_LOCKED",
11+
"edit_mode": "UI_LOCKED",
1212
"email_notifications": {},
13-
"format":"MULTI_TASK",
14-
"max_concurrent_runs":1,
15-
"name":"Updated Job",
13+
"format": "MULTI_TASK",
14+
"max_concurrent_runs": 1,
15+
"name": "Updated Job",
1616
"queue": {
17-
"enabled":true
17+
"enabled": true
1818
},
19-
"timeout_seconds":0,
19+
"timeout_seconds": 0,
2020
"webhook_notifications": {}
2121
}
2222
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
2-
"created_time":[UNIX_TIME_MILLIS],
3-
"creator_user_name":"[USERNAME]",
4-
"job_id":[NUMID],
5-
"run_as_user_name":"[USERNAME]",
2+
"created_time": [UNIX_TIME_MILLIS],
3+
"creator_user_name": "[USERNAME]",
4+
"job_id": [NUMID],
5+
"run_as_user_name": "[USERNAME]",
66
"settings": {
77
"deployment": {
8-
"kind":"BUNDLE",
9-
"metadata_file_path":"/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
8+
"kind": "BUNDLE",
9+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
1010
},
11-
"edit_mode":"UI_LOCKED",
11+
"edit_mode": "UI_LOCKED",
1212
"email_notifications": {},
13-
"format":"MULTI_TASK",
14-
"max_concurrent_runs":1,
15-
"name":"Updated Job",
13+
"format": "MULTI_TASK",
14+
"max_concurrent_runs": 1,
15+
"name": "Updated Job",
1616
"queue": {
17-
"enabled":true
17+
"enabled": true
1818
},
1919
"run_as": {
20-
"user_name":"[USERNAME]"
20+
"user_name": "[USERNAME]"
2121
},
22-
"timeout_seconds":0,
22+
"timeout_seconds": 0,
2323
"webhook_notifications": {}
2424
}
2525
}

0 commit comments

Comments
 (0)