Skip to content

Commit

Permalink
fix(deps): compiled for sanity 3.0.0-rc.0
Browse files Browse the repository at this point in the history
npx @sanity/plugin-kit inject --preset semver-workflow
  • Loading branch information
snorrees committed Nov 7, 2022
1 parent 39eebc7 commit 20466ab
Show file tree
Hide file tree
Showing 15 changed files with 7,353 additions and 2,121 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; editorconfig.org
root = true
charset= utf8

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
6 changes: 2 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.eslintrc.js
commitlint.config.js
coverage
lib
lint-staged.config.js
node_modules
.parcel-cache
v2-incompatible.js
package.config.ts
*.js
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ module.exports = {
node: false
},
extends: [
'sanity/react', // must come before sanity/typescript
'sanity',
'sanity/typescript',
'prettier'
'sanity/react',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended'
],
overrides: [
{
Expand Down
103 changes: 75 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
---
name: CI & Release

# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
run-name: >-
${{
inputs.release && inputs.test && 'Build ➤ Test ➤ Publish to NPM' ||
inputs.release && !inputs.test && 'Build ➤ Skip Tests ➤ Publish to NPM' ||
github.event_name == 'workflow_dispatch' && inputs.test && 'Build ➤ Test' ||
github.event_name == 'workflow_dispatch' && !inputs.test && 'Build ➤ Skip Tests' ||
''
}}
on:
# Build on pushes to release branches
push:
branches: ['main', 'v3']
# Build on pull requests targeting release branches
# Build on pushes branches that have a PR (including drafts)
pull_request:
branches: ['main', 'v3']
# Build on commits pushed to branches without a PR if it's in the allowlist
push:
branches: [main, v3]
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
workflow_dispatch:
inputs:
test:
description: Run tests
required: true
default: true
type: boolean
release:
description: Release new version
required: true
default: false
type: boolean

concurrency:
# 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
# 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.
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
log-the-inputs:
name: Log inputs
Expand All @@ -25,55 +48,73 @@ jobs:
INPUTS: ${{ toJSON(inputs) }}
build:
name: Lint & Build
runs-on: ubuntu-latest
name: Lint & Build
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
with:
node-version: lts/*
cache: npm
node-version: lts/*
- run: npm ci
# Linting can be skipped
- run: npm run lint --if-present
- run: npm run prepublishOnly
if: github.event.inputs.test != 'false'
# But not the build script, as semantic-release will crash if this command fails so it makes sense to test it early
- run: npm run prepublishOnly --if-present

test:
name: Test
needs: build
# The test matrix can be skipped, in case a new release needs to be fast-tracked and tests are already passing on main
if: github.event.inputs.test != 'false'
runs-on: ${{ matrix.os }}
name: Node.js ${{ matrix.node }} / ${{ matrix.os }}
strategy:
# 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
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]
node: [lts/*, current]
runs-on: ${{ matrix.os }}
# Run the testing suite on each major OS with the latest LTS release of Node.js
os: [macos-latest, ubuntu-latest, windows-latest]
node: [lts/*]
# It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
include:
- os: ubuntu-latest
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
node: lts/-2
- os: ubuntu-latest
# Test the actively developed version that will become the latest LTS release next October
node: current
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
# It's only necessary to do this for windows, as mac and ubuntu are sane OS's that already use LF
- name: Set git to use LF
if: matrix.os == 'windows-latest'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
with:
node-version: ${{ matrix.node }}
cache: npm
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm test --if-present

release:
name: Semantic release
needs: test
runs-on: ubuntu-latest
needs: [build, test]
# only run if opt-in during workflow_dispatch
if: inputs.release == true
if: always() && github.event.inputs.release == 'true' && needs.build.result != 'failure' && needs.test.result != 'failure' && needs.test.result != 'cancelled'
runs-on: ubuntu-latest
name: Semantic release
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
with:
node-version: lts/*
cache: npm
node-version: lts/*
- run: npm ci
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
Expand All @@ -83,3 +124,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
# Re-run semantic release with rich logs if it failed to publish for easier debugging
- run: npx semantic-release --dry-run --debug
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
67 changes: 50 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
# Compiled files
lib

# Dependency directories
/node_modules

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Mac OS finder cache files
# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# macOS finder cache file
.DS_Store

# VS Code
# VS Code settings
.vscode

# Parcel
.parcel-cache
# IntelliJ
.idea
*.iml

# Cache
.cache

# Yarn
yarn.lock
# Yalc
.yalc
yalc.lock

##npm package zips
*.tgz

# Compiled plugin
lib

# IntelliJ
.idea/
*.iml
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit ""
npx --no -- commitlint --edit ""
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
npx lint-staged
File renamed without changes.
35 changes: 15 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Sanity Media

> This version of `sanity-plugin-media` is for [Sanity Studio V3](https://www.sanity.io/blog/sanity-studio-v3-developer-preview), which is currently in developer preview.
> **NOTE**
>
> The Studio V2 compatible version can be found on the [V2 branch](https://github.com/robinpyon/sanity-plugin-media).
> This is the **Sanity Studio v3 version** of sanity-plugin-media.
>
> For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/sanity-plugin-media).
## What is it?

Expand Down Expand Up @@ -67,7 +69,7 @@ Add it as a plugin in your `sanity.config.ts` (or .js) file:
```js
import {media} from 'sanity-plugin-media'

export default createConfig({
export default defineConfig({
// ...
plugins: [media()]
})
Expand All @@ -82,7 +84,7 @@ You can configure your studio to use this asset source either exclusively, or co
```js
import {media, mediaAssetSource} from 'sanity-plugin-media'

export default createConfig({
export default defineConfig({
// ...
plugins: [media()],
form: {
Expand Down Expand Up @@ -245,26 +247,19 @@ Contributions, issues and feature requests are welcome!

## License

MIT. See [license](LICENSE)
MIT-licensed. See LICENSE.

## Develop & test

Make sure to run `npm run build` once, then run

```bash
npm run link-watch
```

In another shell, `cd` to your test studio and run:
This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
with default configuration for build & watch scripts.

```bash
npx yalc add sanity-plugin-media && yarn install
```
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
on how to run this plugin with hotreload in the studio.

Now, changes in this repo will be automatically built and pushed to the studio,
triggering hotreload. Yalc avoids issues with react-hooks that are typical when using yarn/npm link.
### Release new version

### About build & watch
Run ["CI & Release" workflow](https://github.com/robinpyon/sanity-plugin-media/actions/workflows/main.yml).
Make sure to select the main branch and check "Release new version".

This plugin uses [@sanity/plugin-sdk](https://github.com/sanity-io/plugin-sdk)
with default configuration for build & watch scripts.
Semantic release will only release on configured branches, so it is safe to run release on any branch.
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
extends: ['@commitlint/config-conventional'],
}
Loading

0 comments on commit 20466ab

Please sign in to comment.