@sanity/plugin-kit 2.0.8 → 2.1.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.
- package/README.md +65 -56
- package/assets/inject/prettierrc.json +6 -0
- package/assets/inject/semver-workflow/.github/workflows/main.yml +67 -29
- package/assets/inject/semver-workflow/.releaserc.json +1 -1
- package/lib/package.json +59 -58
- package/lib/src/actions/inject.js +1 -1
- package/lib/src/actions/inject.js.map +1 -1
- package/lib/src/actions/link-watch.js +1 -1
- package/lib/src/actions/link-watch.js.map +1 -1
- package/lib/src/actions/verify/validations.js +5 -5
- package/lib/src/actions/verify/validations.js.map +1 -1
- package/lib/src/configs/forced-package-versions.d.ts +5 -5
- package/lib/src/configs/forced-package-versions.js +5 -5
- package/lib/src/configs/forced-package-versions.js.map +1 -1
- package/lib/src/configs/uselessFiles.js +1 -1
- package/lib/src/configs/uselessFiles.js.map +1 -1
- package/lib/src/npm/package.js +2 -2
- package/lib/src/npm/package.js.map +1 -1
- package/lib/src/presets/semver-workflow.js +5 -5
- package/lib/src/presets/semver-workflow.js.map +1 -1
- package/lib/test/init.test.js +4 -3
- package/lib/test/init.test.js.map +1 -1
- package/lib/test/verify-package.test.js +7 -1
- package/lib/test/verify-package.test.js.map +1 -1
- package/package.json +59 -58
- package/src/actions/inject.ts +1 -1
- package/src/actions/link-watch.ts +1 -1
- package/src/actions/verify/validations.ts +3 -3
- package/src/configs/forced-package-versions.ts +5 -5
- package/src/configs/uselessFiles.ts +1 -1
- package/src/npm/package.ts +2 -2
- package/src/presets/semver-workflow.ts +5 -5
- package/assets/inject/prettierrc.js +0 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **NOTE**
|
|
4
4
|
>
|
|
5
5
|
> This is a developer preview package meant for **Sanity Studio v3** plugin development.
|
|
6
|
-
>
|
|
6
|
+
>
|
|
7
7
|
> For a v2 alternative, consider using [Sanipack](https://github.com/rexxars/sanipack).
|
|
8
8
|
|
|
9
9
|
## What is it?
|
|
@@ -16,22 +16,22 @@ The verify-package command can be used when upgrading V2 plugins to Studio V3 ve
|
|
|
16
16
|
@sanity/plugin-kit also comes with a verify-studio command that can be used to recommend upgrade steps in existing Sanity Studio v2 studio.
|
|
17
17
|
|
|
18
18
|
This package assumes and recommends [@sanity/pkg-utils](https://github.com/sanity-io/pkg-utils#sanitypkg-utils) for building,
|
|
19
|
-
and [Yalc](https://github.com/wclr/yalc) with watch for testing the plugin in Sanity Studio.
|
|
19
|
+
and [Yalc](https://github.com/wclr/yalc) with watch for testing the plugin in Sanity Studio.
|
|
20
20
|
Check the [FAQ](#faq) fro more on these.
|
|
21
21
|
|
|
22
22
|
## Table of contents
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
- [Installation](#installation)
|
|
25
|
+
- [Initialize a new plugin](#initialize-a-new-plugin)
|
|
26
|
+
- [Verify plugin package](#verify-plugin-package)
|
|
27
|
+
- [Upgrading a v2 plugin](#upgrading-a-v2-plugin)
|
|
28
|
+
- [Upgrade help in v2 Studio](#upgrade-help-in-v2-studio)
|
|
29
|
+
- [Inject config into existing v3 plugin](#inject-config-into-existing-v3)
|
|
30
|
+
- [Testing a plugin in Sanity Studio](#testing-a-plugin-in-sanity-studio)
|
|
31
|
+
- [Upgrading from plugin-kit 1.x](#upgrade-from-v1x-to-v2)
|
|
32
|
+
- [FAQ](#faq) aka "Do I _have_ to use this plugin-kit?" aka No
|
|
33
|
+
- [Configuration reference](#configuration-reference)
|
|
34
|
+
- [Developing plugin-kit](#developing-plugin-kit)
|
|
35
35
|
|
|
36
36
|
## Installation
|
|
37
37
|
|
|
@@ -48,6 +48,7 @@ Check the [FAQ](#faq) fro more on these.
|
|
|
48
48
|
### Quickstart
|
|
49
49
|
|
|
50
50
|
First, run the init command:
|
|
51
|
+
|
|
51
52
|
```bash
|
|
52
53
|
# Initialize a new plugin (outside of your Sanity studio folder)
|
|
53
54
|
npx @sanity/plugin-kit init sanity-plugin-testing-it-out
|
|
@@ -62,10 +63,11 @@ yalc add --link sanity-plugin-testing-it-out && yarn install
|
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
Now, configure the plugin in sanity.config.ts (or .js) in Sanity Studio:
|
|
66
|
+
|
|
65
67
|
```ts
|
|
66
68
|
import {defineConfig} from 'sanity'
|
|
67
69
|
import {myPlugin} from 'sanity-plugin-testing-it-out'
|
|
68
|
-
|
|
70
|
+
|
|
69
71
|
export const defineConfig({
|
|
70
72
|
//...
|
|
71
73
|
plugins: [
|
|
@@ -86,6 +88,7 @@ Since the plugin is running in watch mode, any changes you make to the plugin co
|
|
|
86
88
|
### Init options
|
|
87
89
|
|
|
88
90
|
The init commands has several config flags, run
|
|
91
|
+
|
|
89
92
|
```
|
|
90
93
|
npx @sanity/plugin-kit init --help
|
|
91
94
|
```
|
|
@@ -100,24 +103,25 @@ Verify that the plugin package is configured correctly by running:
|
|
|
100
103
|
|
|
101
104
|
### What does it do?
|
|
102
105
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
- Check package.json for:
|
|
107
|
+
- recommended script commands
|
|
108
|
+
- recommended cjs and esm configuration
|
|
109
|
+
- sanity dependency compatibility
|
|
110
|
+
- @sanity/pkg-utils devDependency
|
|
111
|
+
- recommended usage of devDependencies/peerDependencies/dependencies for certain packages
|
|
112
|
+
- Check for redundant v2 config:
|
|
113
|
+
- babel
|
|
114
|
+
- sanity.json
|
|
115
|
+
- Check for sanity imports that has changed in v3, using eslint
|
|
116
|
+
- Check tsconfig.json settings
|
|
117
|
+
- Check for [SPDX](https://spdx.org/licenses/) compatible license definition
|
|
118
|
+
- If the package uses TypeScript, this will also run `tsc --noEmit` when all other checks have passed
|
|
116
119
|
|
|
117
120
|
Each check will explain why it is needed, steps to fix it and how it can be individually disabled.
|
|
118
121
|
|
|
119
|
-
### What it is
|
|
120
|
-
|
|
122
|
+
### What it is _not_
|
|
123
|
+
|
|
124
|
+
`verify-package` is _not_ a codemod tool (yet). It will only check files and recommended settings: it will not change any files.
|
|
121
125
|
|
|
122
126
|
### Upgrading a v2 plugin
|
|
123
127
|
|
|
@@ -139,9 +143,9 @@ npx @sanity/plugin-kit verify-studio
|
|
|
139
143
|
|
|
140
144
|
This will:
|
|
141
145
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
- Check for `sanity.json,` `sanity.config.(ts|js)` and `sanity.cli.(ts|js)` and advice on how to convert the former to the latter two.
|
|
147
|
+
- Check for sanity dependencies that has changed in v3
|
|
148
|
+
- Check for sanity imports that has changed in v3, using ESlint
|
|
145
149
|
|
|
146
150
|
### Fail fast mode
|
|
147
151
|
|
|
@@ -155,18 +159,20 @@ npx @sanity/plugin-kit verify-package --studio --single
|
|
|
155
159
|
|
|
156
160
|
This will only output the first validation that fails. Useful when working through the list of issues by fixing and rerunning the command.
|
|
157
161
|
|
|
158
|
-
### Inject config into existing v3
|
|
162
|
+
### Inject config into existing v3
|
|
159
163
|
|
|
160
164
|
Consult the inject command CLI help:
|
|
165
|
+
|
|
161
166
|
```
|
|
162
167
|
npx @sanity/plugin-kit inject --help
|
|
163
168
|
```
|
|
164
169
|
|
|
165
170
|
for up-to-date specifics.
|
|
166
171
|
|
|
167
|
-
## Testing a plugin in Sanity Studio
|
|
172
|
+
## Testing a plugin in Sanity Studio
|
|
168
173
|
|
|
169
174
|
Ensure you have the following script setup in package.json:
|
|
175
|
+
|
|
170
176
|
```json
|
|
171
177
|
{
|
|
172
178
|
"scripts": {
|
|
@@ -198,15 +204,18 @@ You can now change your plugin code, which will:
|
|
|
198
204
|
5. Trigger hot-reload; you should see changes in the Studio
|
|
199
205
|
|
|
200
206
|
**Note:** Yalc will modify your studio package.json when linking; remember to revert it when you are done testing.
|
|
201
|
-
You should also put `.yalc` and `yalc.lock` into `.gitignore`.
|
|
207
|
+
You should also put `.yalc` and `yalc.lock` into `.gitignore`.
|
|
202
208
|
|
|
203
209
|
When you are done testing, you can run
|
|
210
|
+
|
|
204
211
|
```
|
|
205
212
|
npx yalc remove <your-plugin-package> && yarn install
|
|
206
213
|
```
|
|
214
|
+
|
|
207
215
|
to restore the version in `package.json`.
|
|
208
216
|
|
|
209
217
|
### Link-watch configuration
|
|
218
|
+
|
|
210
219
|
This command can be configured using `sanityPlugin.linkWatch` in package.json:
|
|
211
220
|
|
|
212
221
|
```json5
|
|
@@ -230,30 +239,31 @@ See the [FAQ](#faq).
|
|
|
230
239
|
|
|
231
240
|
## Publishing a plugin
|
|
232
241
|
|
|
233
|
-
**Note:** If you're writing a plugin that is only useful for yourself or your company,
|
|
242
|
+
**Note:** If you're writing a plugin that is only useful for yourself or your company,
|
|
234
243
|
you might want to develop the plugin directly in the Studio (saves you from having to publish at all, and has improved hot-reload dev experience).
|
|
235
244
|
|
|
236
245
|
If the plugin is shared across multiple "private" studios: register an organization on npm and make sure your module is
|
|
237
246
|
[prefixed with the organization scope](https://docs.npmjs.com/creating-and-publishing-private-packages), eg `@your-company/plugin-name`.
|
|
238
247
|
|
|
239
|
-
Also; you cannot easily remove modules/versions from npm once published.
|
|
248
|
+
Also; you cannot easily remove modules/versions from npm once published.
|
|
240
249
|
Take a good look at your `package.json` to see that the fields in there makes sense to you,
|
|
241
|
-
and make sure there are no "secrets" (authorization tokens, API keys or similar) in the plugin directory -
|
|
250
|
+
and make sure there are no "secrets" (authorization tokens, API keys or similar) in the plugin directory -
|
|
242
251
|
any files within folders defined in the `files` field inside `package.json` will be included with your module.
|
|
243
252
|
|
|
244
|
-
When you're ready to publish, run `npm publish` (or `yarn publish` if you prefer).
|
|
253
|
+
When you're ready to publish, run `npm publish` (or `yarn publish` if you prefer).
|
|
245
254
|
The `prepublishOnly` task should kick in and compile the source files, then verify the built output to ensure it looks good.
|
|
246
255
|
|
|
247
256
|
If you have not published any modules to npm before, you will be asked to create a user first.
|
|
248
257
|
|
|
249
|
-
For an opinionated template for publication based on semantic-release, see [semver-workflow preset](docs/semver-workflow.md)
|
|
258
|
+
For an opinionated template for publication based on semantic-release, see [semver-workflow preset](docs/semver-workflow.md)
|
|
250
259
|
|
|
251
260
|
### Upgrade from v1.x to v2
|
|
252
261
|
|
|
253
262
|
To upgrade a plugin that already uses `@sanity/plugin-kit` 1.x:
|
|
263
|
+
|
|
254
264
|
- Update `@sanity/plugin-kit` to version to 2.x in `package.json`
|
|
255
265
|
- Run: `npx @sanity/plugin-kit inject`
|
|
256
|
-
- This will update package.json with new defaults
|
|
266
|
+
- This will update package.json with new defaults
|
|
257
267
|
- Feel free to answer no to any file-overwrite prompts
|
|
258
268
|
- Inspect git diff to see what was changed
|
|
259
269
|
- Run: `npm install`
|
|
@@ -269,18 +279,18 @@ This package was created to make it easier to set up the build toolchain and pre
|
|
|
269
279
|
|
|
270
280
|
If you know what you're doing and don't like any magic, roll your own thing! :)
|
|
271
281
|
|
|
272
|
-
#### Q: Why use yalc?
|
|
282
|
+
#### Q: Why use yalc?
|
|
273
283
|
|
|
274
284
|
npm link & yarn link unfortunately can easily break the [rules of hooks](https://reactjs.org/docs/hooks-rules.html) due
|
|
275
|
-
to the way packages are resolved using symlinks.
|
|
285
|
+
to the way packages are resolved using symlinks.
|
|
276
286
|
|
|
277
287
|
Yalc bypass this problem as it more closely resembles installing a dependency as normal.
|
|
278
288
|
|
|
279
289
|
#### Q: Do I have to use yalc?
|
|
280
290
|
|
|
281
|
-
**A:** No!
|
|
291
|
+
**A:** No!
|
|
282
292
|
|
|
283
|
-
Feel free to use any variation of `npm link` or `yarn link` alongside `npm run watch` for testing,
|
|
293
|
+
Feel free to use any variation of `npm link` or `yarn link` alongside `npm run watch` for testing,
|
|
284
294
|
but beware that if you get errors from React along the lines of
|
|
285
295
|
|
|
286
296
|
```
|
|
@@ -291,16 +301,16 @@ This could happen for one of the following reasons:
|
|
|
291
301
|
- You might have more than one copy of React in the same app
|
|
292
302
|
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
|
|
293
303
|
```
|
|
294
|
-
|
|
304
|
+
|
|
295
305
|
you probably have to revert to using yalc, or use `npm pack` + and install the resulting tzg-file.
|
|
296
306
|
|
|
297
307
|
### Q: What appended with the Parcel recommendation?
|
|
298
308
|
|
|
299
|
-
At the time of writing (Nov 2022) the latest version of parcel (2.7) failed to build Sanity plugins.
|
|
300
|
-
The previous version (2.6) did not work with the latest version of TypeScript.
|
|
301
|
-
Pinning these versions was confusing and caused issues.
|
|
309
|
+
At the time of writing (Nov 2022) the latest version of parcel (2.7) failed to build Sanity plugins.
|
|
310
|
+
The previous version (2.6) did not work with the latest version of TypeScript.
|
|
311
|
+
Pinning these versions was confusing and caused issues.
|
|
302
312
|
|
|
303
|
-
We also saw issues with modules using nested async imports.
|
|
313
|
+
We also saw issues with modules using nested async imports.
|
|
304
314
|
|
|
305
315
|
As such, we decided to standardize plugins on the same build-tool used by Sanity studio, [@sanity/pkg-utils](https://github.com/sanity-io/pkg-utils#sanitypkg-utils).
|
|
306
316
|
|
|
@@ -315,10 +325,10 @@ and aims to standardize how this is done thought the community.
|
|
|
315
325
|
|
|
316
326
|
#### Q: Can I use another build tool or change @sanity/pkg-utils configuration?
|
|
317
327
|
|
|
318
|
-
**A:** Yes!
|
|
328
|
+
**A:** Yes!
|
|
319
329
|
|
|
320
330
|
Feel free to make any changes to `package.config.ts` as is needed.
|
|
321
|
-
`@sanity/plugin-sdk verify-package` output is only recommendations for defaults that has been tested to work in Sanity Studio.
|
|
331
|
+
`@sanity/plugin-sdk verify-package` output is only recommendations for defaults that has been tested to work in Sanity Studio.
|
|
322
332
|
Your plugin may have other needs.
|
|
323
333
|
|
|
324
334
|
You are also free to not use @sanity/pkg-utils at all; simply change your package.json build script, and disable any verification-steps
|
|
@@ -327,7 +337,7 @@ you don't care for with `sanityPlugin.verifyPackage`.
|
|
|
327
337
|
## CLI Help
|
|
328
338
|
|
|
329
339
|
```sh
|
|
330
|
-
$ npx @sanity/plugin-kit --help
|
|
340
|
+
$ npx @sanity/plugin-kit --help
|
|
331
341
|
|
|
332
342
|
Usage
|
|
333
343
|
$ plugin-kit [--help] [--debug] <command> [<args>]
|
|
@@ -394,6 +404,7 @@ MIT © [Espen Hovlandsdal](https://espen.codes/) and [Sanity.io](https://www.san
|
|
|
394
404
|
### Test in another package
|
|
395
405
|
|
|
396
406
|
In one shell, run
|
|
407
|
+
|
|
397
408
|
```sh
|
|
398
409
|
npm link
|
|
399
410
|
npm run watch
|
|
@@ -435,13 +446,11 @@ npm run test -- test/verify-package.test.ts
|
|
|
435
446
|
npm run test -- test/verify-package.test.ts --snapshot
|
|
436
447
|
```
|
|
437
448
|
|
|
438
|
-
|
|
439
449
|
## Developing plugin kit
|
|
440
450
|
|
|
441
451
|
### Release new version
|
|
442
452
|
|
|
443
|
-
Run ["CI & Release" workflow](https://github.com/sanity-io/plugin-
|
|
453
|
+
Run the ["CI & Release" workflow](https://github.com/sanity-io/plugin-kit/actions).
|
|
444
454
|
Make sure to select the main branch and check "Release new version".
|
|
445
455
|
|
|
446
456
|
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
|
447
|
-
|
|
@@ -1,18 +1,31 @@
|
|
|
1
|
+
---
|
|
1
2
|
name: CI & Release
|
|
3
|
+
|
|
2
4
|
on:
|
|
3
|
-
# Build on pushes
|
|
4
|
-
push:
|
|
5
|
-
branches: []
|
|
6
|
-
# Build on pull requests targeting release branches
|
|
5
|
+
# Build on pushes branches that have a PR (including drafts)
|
|
7
6
|
pull_request:
|
|
8
|
-
|
|
7
|
+
# Build on commits pushed to branches without a PR if it's in the allowlist
|
|
8
|
+
push:
|
|
9
|
+
branches: [main]
|
|
10
|
+
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
|
|
9
11
|
workflow_dispatch:
|
|
10
12
|
inputs:
|
|
13
|
+
test:
|
|
14
|
+
description: Run tests
|
|
15
|
+
required: true
|
|
16
|
+
default: true
|
|
17
|
+
type: boolean
|
|
11
18
|
release:
|
|
12
19
|
description: Release new version
|
|
13
20
|
required: true
|
|
14
21
|
default: false
|
|
15
|
-
type: boolean
|
|
22
|
+
type: boolean`
|
|
23
|
+
|
|
24
|
+
concurrency:
|
|
25
|
+
# 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
|
|
26
|
+
# 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.
|
|
27
|
+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
28
|
+
cancel-in-progress: true
|
|
16
29
|
|
|
17
30
|
jobs:
|
|
18
31
|
log-the-inputs:
|
|
@@ -25,57 +38,76 @@ jobs:
|
|
|
25
38
|
INPUTS: ${{ toJSON(inputs) }}
|
|
26
39
|
|
|
27
40
|
build:
|
|
28
|
-
name: Lint & Build
|
|
29
41
|
runs-on: ubuntu-latest
|
|
42
|
+
name: Lint & Build
|
|
30
43
|
steps:
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
git config --global core.autocrlf false
|
|
34
|
-
git config --global core.eol lf
|
|
35
|
-
- uses: actions/checkout@v3
|
|
36
|
-
- uses: actions/setup-node@v3
|
|
44
|
+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
|
|
45
|
+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
|
|
37
46
|
with:
|
|
38
|
-
node-version: lts/*
|
|
39
47
|
cache: npm
|
|
48
|
+
node-version: lts/*
|
|
40
49
|
- run: npm ci
|
|
50
|
+
# Linting can be skipped
|
|
41
51
|
- run: npm run lint --if-present
|
|
42
|
-
|
|
52
|
+
if: github.event.inputs.test != 'false'
|
|
53
|
+
# But not the build script, as semantic-release will crash if this command fails so it makes sense to test it early
|
|
54
|
+
- run: npm run prepublishOnly --if-present
|
|
43
55
|
|
|
44
56
|
test:
|
|
45
|
-
name: Test
|
|
46
57
|
needs: build
|
|
58
|
+
# The test matrix can be skipped, in case a new release needs to be fast-tracked and tests are already passing on main
|
|
59
|
+
if: github.event.inputs.test != 'false'
|
|
60
|
+
runs-on: ${{ matrix.os }}
|
|
61
|
+
name: Node.js ${{ matrix.node }} / ${{ matrix.os }}
|
|
47
62
|
strategy:
|
|
63
|
+
# 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
|
|
64
|
+
fail-fast: false
|
|
48
65
|
matrix:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
# Run the testing suite on each major OS with the latest LTS release of Node.js
|
|
67
|
+
os: [macos-latest, ubuntu-latest, windows-latest]
|
|
68
|
+
node: [lts/*]
|
|
69
|
+
# It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
|
|
70
|
+
include:
|
|
71
|
+
- os: ubuntu-latest
|
|
72
|
+
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
|
|
73
|
+
node: lts/-2
|
|
74
|
+
- os: ubuntu-latest
|
|
75
|
+
# Test the actively developed version that will become the latest LTS release next October
|
|
76
|
+
node: current
|
|
52
77
|
steps:
|
|
53
|
-
|
|
54
|
-
-
|
|
78
|
+
# It's only necessary to do this for windows, as mac and ubuntu are sane OS's that already use LF
|
|
79
|
+
- name: Set git to use LF
|
|
80
|
+
if: matrix.os == 'windows-latest'
|
|
81
|
+
run: |
|
|
82
|
+
git config --global core.autocrlf false
|
|
83
|
+
git config --global core.eol lf
|
|
84
|
+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
|
|
85
|
+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
|
|
55
86
|
with:
|
|
56
|
-
node-version: ${{ matrix.node }}
|
|
57
87
|
cache: npm
|
|
88
|
+
node-version: ${{ matrix.node }}
|
|
58
89
|
- run: npm ci
|
|
59
|
-
- run: npm test
|
|
90
|
+
- run: npm test
|
|
60
91
|
|
|
61
92
|
release:
|
|
62
|
-
name: Semantic release
|
|
63
93
|
needs: test
|
|
94
|
+
# only run if opt-in during workflow_dispatch, and run if tests are skipped using the toggle, but not if they have failed
|
|
95
|
+
if: always() && github.event.inputs.release == 'true' && needs.test.result != 'failure' && needs.test.result != 'cancelled'
|
|
64
96
|
runs-on: ubuntu-latest
|
|
65
|
-
|
|
66
|
-
if: inputs.release == true
|
|
97
|
+
name: Semantic release
|
|
67
98
|
steps:
|
|
68
|
-
- uses: actions/checkout@v3
|
|
99
|
+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
|
|
69
100
|
with:
|
|
70
101
|
# Need to fetch entire commit history to
|
|
71
102
|
# analyze every commit since last release
|
|
72
103
|
fetch-depth: 0
|
|
73
|
-
- uses: actions/setup-node@v3
|
|
104
|
+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
|
|
74
105
|
with:
|
|
75
|
-
node-version: lts/*
|
|
76
106
|
cache: npm
|
|
107
|
+
node-version: lts/*
|
|
77
108
|
- run: npm ci
|
|
78
109
|
# Branches that will release new versions are defined in .releaserc.json
|
|
110
|
+
# @TODO remove --dry-run after verifying everything is good to go
|
|
79
111
|
- run: npx semantic-release --dry-run
|
|
80
112
|
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
|
|
81
113
|
# e.g. git tags were pushed but it exited before `npm publish`
|
|
@@ -83,3 +115,9 @@ jobs:
|
|
|
83
115
|
env:
|
|
84
116
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
85
117
|
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
|
118
|
+
# Re-run semantic release with rich logs if it failed to publish for easier debugging
|
|
119
|
+
- run: npx semantic-release --dry-run --debug
|
|
120
|
+
if: failure()
|
|
121
|
+
env:
|
|
122
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
123
|
+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
package/lib/package.json
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/plugin-kit",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Enhanced Sanity.io plugin development experience",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"clean": "rimraf lib",
|
|
7
|
-
"prebuild": "npm run clean",
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"postbuild": "node executable-index.js",
|
|
10
|
-
"watch": "tsc --watch",
|
|
11
|
-
"test": "tap",
|
|
12
|
-
"prepare": "husky install",
|
|
13
|
-
"commit": "git-cz",
|
|
14
|
-
"lint": "eslint .",
|
|
15
|
-
"compile": "tsc --noEmit",
|
|
16
|
-
"format": "prettier src -w",
|
|
17
|
-
"prepublishOnly": "npm run build"
|
|
18
|
-
},
|
|
19
|
-
"binname": "sanity-plugin",
|
|
20
|
-
"source": "./src/index.ts",
|
|
21
|
-
"types": "./lib/src/index.d.ts",
|
|
22
|
-
"bin": "lib/src/index.js",
|
|
23
|
-
"main": "./lib/src/index.js",
|
|
24
|
-
"files": [
|
|
25
|
-
"v2-incompatible.js",
|
|
26
|
-
"src",
|
|
27
|
-
"lib",
|
|
28
|
-
"assets"
|
|
29
|
-
],
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+ssh://git@github.com/sanity-io/plugin-kit.git"
|
|
33
|
-
},
|
|
34
|
-
"engines": {
|
|
35
|
-
"node": ">=14.0.0"
|
|
36
|
-
},
|
|
37
5
|
"keywords": [
|
|
38
6
|
"sanity-io",
|
|
39
7
|
"sanity",
|
|
@@ -43,12 +11,52 @@
|
|
|
43
11
|
"typescript",
|
|
44
12
|
"bootstrap"
|
|
45
13
|
],
|
|
46
|
-
"
|
|
47
|
-
"license": "MIT",
|
|
14
|
+
"homepage": "https://github.com/sanity-io/plugin-kit#readme",
|
|
48
15
|
"bugs": {
|
|
49
16
|
"url": "https://github.com/sanity-io/plugin-kit/issues"
|
|
50
17
|
},
|
|
51
|
-
"
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+ssh://git@github.com/sanity-io/plugin-kit.git"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Sanity.io <hello@sanity.io>",
|
|
24
|
+
"main": "./lib/src/index.js",
|
|
25
|
+
"source": "./src/index.ts",
|
|
26
|
+
"types": "./lib/src/index.d.ts",
|
|
27
|
+
"bin": "lib/src/index.js",
|
|
28
|
+
"files": [
|
|
29
|
+
"v2-incompatible.js",
|
|
30
|
+
"src",
|
|
31
|
+
"lib",
|
|
32
|
+
"assets"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"prebuild": "npm run clean",
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"postbuild": "node executable-index.js",
|
|
38
|
+
"clean": "rimraf lib",
|
|
39
|
+
"commit": "git-cz",
|
|
40
|
+
"compile": "tsc --noEmit",
|
|
41
|
+
"format": "prettier src -w",
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"prepare": "husky install",
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"test": "tap",
|
|
46
|
+
"watch": "tsc --watch"
|
|
47
|
+
},
|
|
48
|
+
"tap": {
|
|
49
|
+
"browser": false,
|
|
50
|
+
"check-coverage": false,
|
|
51
|
+
"coverage-report": [
|
|
52
|
+
"html"
|
|
53
|
+
],
|
|
54
|
+
"jobs": 2,
|
|
55
|
+
"reporter": "spec",
|
|
56
|
+
"test-ignore": "^lib/.*|.*ignore.*|.*run-test-command.*|.*fixture.utils.*",
|
|
57
|
+
"timeout": 120,
|
|
58
|
+
"ts": true
|
|
59
|
+
},
|
|
52
60
|
"dependencies": {
|
|
53
61
|
"@rexxars/choosealicense-list": "^1.1.2",
|
|
54
62
|
"chalk": "^4.1.2",
|
|
@@ -78,23 +86,20 @@
|
|
|
78
86
|
"xdg-basedir": "^4.0.0",
|
|
79
87
|
"yalc": "^1.0.0-pre.53"
|
|
80
88
|
},
|
|
81
|
-
"peerDependencies": {
|
|
82
|
-
"eslint": ">=8.0.0"
|
|
83
|
-
},
|
|
84
89
|
"devDependencies": {
|
|
85
|
-
"@commitlint/cli": "^17.0
|
|
86
|
-
"@commitlint/config-conventional": "^17.0
|
|
90
|
+
"@commitlint/cli": "^17.2.0",
|
|
91
|
+
"@commitlint/config-conventional": "^17.2.0",
|
|
87
92
|
"@sanity/pkg-utils": "^1.16.2",
|
|
88
|
-
"@sanity/semantic-release-preset": "^2.0.
|
|
89
|
-
"@types/eslint": "^8.4.
|
|
93
|
+
"@sanity/semantic-release-preset": "^2.0.2",
|
|
94
|
+
"@types/eslint": "^8.4.9",
|
|
90
95
|
"@types/fs-extra": "^9.0.13",
|
|
91
96
|
"@types/inquirer": "^8.2.3",
|
|
92
97
|
"@types/node": "^17.0.40",
|
|
93
98
|
"@types/nodemon": "^1.19.2",
|
|
94
99
|
"@types/tap": "^15.0.7",
|
|
95
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
96
|
-
"@typescript-eslint/parser": "^5.
|
|
97
|
-
"eslint": "^8.
|
|
100
|
+
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
101
|
+
"@typescript-eslint/parser": "^5.42.0",
|
|
102
|
+
"eslint": "^8.26.0",
|
|
98
103
|
"eslint-config-prettier": "^8.5.0",
|
|
99
104
|
"eslint-config-sanity": "^6.0.0",
|
|
100
105
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -104,6 +109,7 @@
|
|
|
104
109
|
"json5": "^2.2.1",
|
|
105
110
|
"lint-staged": "^13.0.3",
|
|
106
111
|
"prettier": "^2.7.1",
|
|
112
|
+
"prettier-plugin-packagejson": "^2.3.0",
|
|
107
113
|
"readdirp": "^3.6.0",
|
|
108
114
|
"rimraf": "^3.0.2",
|
|
109
115
|
"sanity": "3.0.0-rc.0",
|
|
@@ -112,16 +118,11 @@
|
|
|
112
118
|
"ts-node": "^10.9.1",
|
|
113
119
|
"typescript": "^4.8.4"
|
|
114
120
|
},
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"html"
|
|
123
|
-
],
|
|
124
|
-
"test-ignore": "^lib/.*|.*ignore.*|.*run-test-command.*|.*fixture.utils.*",
|
|
125
|
-
"ts": true
|
|
126
|
-
}
|
|
121
|
+
"peerDependencies": {
|
|
122
|
+
"eslint": ">=8.0.0"
|
|
123
|
+
},
|
|
124
|
+
"engines": {
|
|
125
|
+
"node": ">=14"
|
|
126
|
+
},
|
|
127
|
+
"binname": "sanity-plugin"
|
|
127
128
|
}
|
|
@@ -286,7 +286,7 @@ function writeStaticAssets(options) {
|
|
|
286
286
|
},
|
|
287
287
|
flags.gitignore && { from: 'gitignore', to: '.gitignore' },
|
|
288
288
|
flags.typescript && { from: 'template-tsconfig.json', to: 'tsconfig.json' },
|
|
289
|
-
flags.prettier && { from: 'prettierrc.
|
|
289
|
+
flags.prettier && { from: 'prettierrc.json', to: '.prettierrc.json' },
|
|
290
290
|
]
|
|
291
291
|
.map((f) => (f ? f : undefined))
|
|
292
292
|
.filter((f) => !!f);
|