sanity-plugin-graph-view 1.0.4 → 1.0.8

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.
@@ -0,0 +1,133 @@
1
+ ---
2
+ name: CI & Release
3
+
4
+ # Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
5
+ run-name: >-
6
+ ${{
7
+ inputs.release && inputs.test && 'Build studio-v2 ➤ Test ➤ Publish to NPM' ||
8
+ inputs.release && !inputs.test && 'Build studio-v2 ➤ Skip Tests ➤ Publish to NPM' ||
9
+ github.event_name == 'workflow_dispatch' && inputs.test && 'Build studio-v2 ➤ Test' ||
10
+ github.event_name == 'workflow_dispatch' && !inputs.test && 'Build studio-v2 ➤ Skip Tests' ||
11
+ ''
12
+ }}
13
+
14
+ on:
15
+ # Build on pushes branches that have a PR (including drafts)
16
+ pull_request:
17
+ # Build on commits pushed to branches without a PR if it's in the allowlist
18
+ push:
19
+ branches: [main,studio-v2]
20
+ # https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
21
+ workflow_dispatch:
22
+ inputs:
23
+ test:
24
+ description: Run tests
25
+ required: true
26
+ default: true
27
+ type: boolean
28
+ release:
29
+ description: Release new version
30
+ required: true
31
+ default: false
32
+ type: boolean
33
+
34
+ concurrency:
35
+ # On PRs builds will cancel if new pushes happen before the CI completes, as it defines `github.head_ref` and gives it the name of the branch the PR wants to merge into
36
+ # Otherwise `github.run_id` ensures that you can quickly merge a queue of PRs without causing tests to auto cancel on any of the commits pushed to main.
37
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
38
+ cancel-in-progress: true
39
+
40
+ jobs:
41
+ log-the-inputs:
42
+ name: Log inputs
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - run: |
46
+ echo "Inputs: $INPUTS"
47
+ env:
48
+ INPUTS: ${{ toJSON(inputs) }}
49
+
50
+ build:
51
+ runs-on: ubuntu-latest
52
+ name: Lint & Build
53
+ steps:
54
+ - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
55
+ - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
56
+ with:
57
+ cache: npm
58
+ node-version: lts/*
59
+ - run: npm ci
60
+ # Linting can be skipped
61
+ - run: npm run lint --if-present
62
+ if: github.event.inputs.test != 'false'
63
+ # But not the build script, as semantic-release will crash if this command fails so it makes sense to test it early
64
+ - run: npm run prepublishOnly --if-present
65
+
66
+ # test:
67
+ # needs: build
68
+ # # The test matrix can be skipped, in case a new release needs to be fast-tracked and tests are already passing on main
69
+ # if: github.event.inputs.test != 'false'
70
+ # runs-on: ${{ matrix.os }}
71
+ # name: Node.js ${{ matrix.node }} / ${{ matrix.os }}
72
+ # strategy:
73
+ # # A test failing on windows doesn't mean it'll fail on macos. It's useful to let all tests run to its completion to get the full picture
74
+ # fail-fast: false
75
+ # matrix:
76
+ # # Run the testing suite on each major OS with the latest LTS release of Node.js
77
+ # os: [macos-latest, ubuntu-latest, windows-latest]
78
+ # node: [lts/*]
79
+ # # It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
80
+ # include:
81
+ # - os: ubuntu-latest
82
+ # # Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
83
+ # node: lts/-2
84
+ # - os: ubuntu-latest
85
+ # # Test the actively developed version that will become the latest LTS release next October
86
+ # node: current
87
+ # steps:
88
+ # # It's only necessary to do this for windows, as mac and ubuntu are sane OS's that already use LF
89
+ # - name: Set git to use LF
90
+ # if: matrix.os == 'windows-latest'
91
+ # run: |
92
+ # git config --global core.autocrlf false
93
+ # git config --global core.eol lf
94
+ # - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
95
+ # - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
96
+ # with:
97
+ # cache: npm
98
+ # node-version: ${{ matrix.node }}
99
+ # - run: npm i
100
+ # - run: npm test --if-present
101
+
102
+ release:
103
+ # needs: [build, test]
104
+ needs: [build]
105
+ # only run if opt-in during workflow_dispatch
106
+ if: always() && github.event.inputs.release == 'true' && needs.build.result != 'failure' && needs.test.result != 'failure' && needs.test.result != 'cancelled'
107
+ runs-on: ubuntu-latest
108
+ name: Semantic release
109
+ steps:
110
+ - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
111
+ with:
112
+ # Need to fetch entire commit history to
113
+ # analyze every commit since last release
114
+ fetch-depth: 0
115
+ - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
116
+ with:
117
+ cache: npm
118
+ node-version: lts/*
119
+ - run: npm ci
120
+ # Branches that will release new versions are defined in .releaserc.json
121
+ - run: npx semantic-release
122
+ # Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
123
+ # e.g. git tags were pushed but it exited before `npm publish`
124
+ if: always()
125
+ env:
126
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127
+ NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
128
+ # Re-run semantic release with rich logs if it failed to publish for easier debugging
129
+ - run: npx semantic-release --dry-run --debug
130
+ if: failure()
131
+ env:
132
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133
+ NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "@sanity/semantic-release-preset",
3
+ "branches": ["main", {"name": "studio-v2", "channel": "studio-v2", "range": "1.0.x"}]
4
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ <!-- markdownlint-disable --><!-- textlint-disable -->
2
+
3
+ # 📓 Changelog
4
+
5
+ All notable changes to this project will be documented in this file. See
6
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
+
8
+ ## [1.0.8](https://github.com/sanity-io/sanity-plugin-graph-view/compare/v1.0.7...v1.0.8) (2022-11-22)
9
+
10
+ ### Bug Fixes
11
+
12
+ - **ci:** added semver workflow ([d179815](https://github.com/sanity-io/sanity-plugin-graph-view/commit/d179815f36bd260c8ea6d33a9e66b1e8968700b6))
13
+ - **ci:** publish using semantic-release ([1c40d3e](https://github.com/sanity-io/sanity-plugin-graph-view/commit/1c40d3ef18928e3521eac79e725ff72737a72b2e))
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2016–2020 Sanity.io
3
+ Copyright (c) 2022–2020 Sanity.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -5,16 +5,35 @@
5
5
  <p><img src="assets/screengrab.gif" width="540" alt="Screengrab of the Graph tool" /></p>
6
6
  </div>
7
7
 
8
+ > This is a Sanity Studio v2 plugin. For the v3 version, please refer to the [v3-branch](https://github.com/sanity-io/sanity-plugin-graph-view).
9
+
8
10
  Wonder how a visualization of your dataset will look? How many authors do you have? How many items have they worked on? And are currently working on! Edits and changes are shown in real-time!
9
11
 
10
12
  **Explore your data with this plugin, seek out strange corners and data types, boldly go where you could not before!**
11
13
 
14
+ ## Installation and use
15
+
16
+ <div style="padding: 1em; border: solid 2px red;">
17
+ **Important!** Due to an [outstanding issue with Three.js](https://github.com/sanity-io/sanity-plugin-graph-view/issues/4), you currently **have to use Yarn to install packages, not NPM, and add this to your app's `package.json`**:
18
+
19
+ ```json
20
+ "resolutions": {
21
+ "**/three": "0.119.1"
22
+ }
23
+ ```
24
+ We hope to remedy this in the future.
25
+ </div>
26
+
27
+
12
28
  ```sh
13
- # In your Sanity Studio repository:
14
- sanity install graph-view
29
+ yarn add sanity-plugin-graph-view@studio-v2
30
+ ```
15
31
 
16
- # Start the Studio
17
- sanity start
32
+ Next, add `"graph-view"` to `sanity.json` plugins array:
33
+ ```json
34
+ "plugins": [
35
+ "graph-view"
36
+ ]
18
37
  ```
19
38
 
20
39
  ## Configuration
@@ -23,7 +42,7 @@ Edit `./config/graph-view.json`:
23
42
 
24
43
  ```json
25
44
  {
26
- "query": "*[_type == 'a' || _type == 'b']"
45
+ "query": "*[_type in ['a', 'b']]"
27
46
  }
28
47
  ```
29
48
 
@@ -31,7 +50,17 @@ For references to turn into graph edges, the entire document must be fetched, bu
31
50
 
32
51
  ```json
33
52
  {
34
- "query": "*[_type == 'a' || _type == 'b']{ 'refs': [author._ref, publisher._ref] }"
53
+ "query": "*[_type in ['a', 'b']]{ 'refs': [author, publisher] }"
54
+ }
55
+ ```
56
+
57
+ By default, the plugin uses `doc.title || doc.name || doc._id` as the node label.
58
+
59
+ If you want to use another property, compute a `title` property in your query, e.g.:
60
+
61
+ ```json
62
+ {
63
+ "query": "*[_type in ['a', 'b']] { ..., \"title\": select(_type == 'a' => 'Title A', _type == 'b' => 'Title B') }"
35
64
  }
36
65
  ```
37
66