Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
"changelog": ["@changesets/changelog-github", {"repo": "sanity-io/code-input"}],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch"
}
5 changes: 5 additions & 0 deletions .changeset/social-moments-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sanity/code-input': patch
---

Replace `import styled from 'styled-components'` with `import {styled} from 'styled-components'`
10 changes: 0 additions & 10 deletions .eslintignore

This file was deleted.

46 changes: 0 additions & 46 deletions .eslintrc.cjs

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/format-if-needed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Auto format

on:
push:
branches: [main]

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: read # for checkout

jobs:
if-needed:
uses: sanity-io/.github/.github/workflows/format.yml@main
secrets: inherit
105 changes: 17 additions & 88 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,32 @@
---
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' ||
''
}}
name: CI

on:
# Build on pushes branches that have a PR (including drafts)
pull_request:
# Build on commits pushed to branches without a PR if it's in the allowlist
branches: [main]
push:
branches: [main]
# 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
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
log-the-inputs:
name: Log inputs
runs-on: ubuntu-latest
steps:
- run: |
echo "Inputs: $INPUTS"
env:
INPUTS: ${{ toJSON(inputs) }}

build:
runs-on: ubuntu-latest
name: Lint & Build
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
cache: npm
cache: pnpm
node-version: lts/*
- run: npm ci
# Linting can be skipped
- run: npm run lint --if-present
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
- run: pnpm install
- run: pnpm type-check
- run: pnpm lint -f gha --max-warnings 0
- run: pnpm prepublishOnly

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:
Expand All @@ -91,42 +51,11 @@ jobs:
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
cache: npm
cache: pnpm
node-version: ${{ matrix.node }}
- run: npm i
- run: npm test

release:
needs: [build, test]
# only run if opt-in during workflow_dispatch
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/create-github-app-token@v2
id: app-token
with:
app-id: ${{ secrets.ECOSPARK_APP_ID }}
private-key: ${{ secrets.ECOSPARK_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
# Uses generated token to allow pushing commits back
token: ${{ steps.app-token.outputs.token }}
# Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
persist-credentials: false
- uses: actions/setup-node@v4
with:
cache: npm
node-version: lts/*
- run: npm ci
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- run: pnpm install
- run: pnpm test
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: read # for checkout

jobs:
release:
uses: sanity-io/.github/.github/workflows/changesets.yml@main
permissions:
contents: read # for checkout
id-token: write # to enable use of OIDC for npm provenance
with:
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
secrets: inherit
16 changes: 16 additions & 0 deletions .github/workflows/renovate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Add changeset to Renovate updates

on:
pull_request_target:
types: [opened, synchronize]

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: read # for checkout

jobs:
call:
uses: sanity-io/.github/.github/workflows/changesets-from-conventional-commits.yml@main
if: github.event.pull_request.user.login == 'renovate[bot]'
secrets: inherit
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

10 changes: 0 additions & 10 deletions .npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
legacy-peer-deps=true
public-hoist-pattern[]=*prettier*
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

4 changes: 0 additions & 4 deletions .releaserc.json

This file was deleted.

7 changes: 0 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<!-- markdownlint-disable --><!-- textlint-disable -->

# 📓 Changelog

All notable changes to this project will be documented in this file. See
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [6.0.1](https://github.com/sanity-io/code-input/compare/v6.0.0...v6.0.1) (2025-08-14)

### Bug Fixes
Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# @sanity/code-input

> For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/sanity/tree/next/packages/%40sanity/code-input).

## What is it?

Code input for [Sanity](https://sanity.io/).
Expand All @@ -23,6 +21,7 @@ npm install @sanity/code-input
Add it as a plugin in `sanity.config.ts` (or .js):

```js
import {defineConfig} from 'sanity'
import {codeInput} from '@sanity/code-input'

export default defineConfig({
Expand Down Expand Up @@ -251,10 +250,3 @@ Run
`workshop dev`

To test the CodeMirror lazy component.

### Release new version

Run ["CI & Release" workflow](https://github.com/sanity-io/code-input/actions/workflows/main.yml).
Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.
3 changes: 0 additions & 3 deletions commitlint.config.cjs

This file was deleted.

44 changes: 44 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import js from '@eslint/js'
import eslintConfigPrettier from 'eslint-config-prettier/flat'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import globals from 'globals'
import ts from 'typescript-eslint'

export default ts.config([
{
ignores: [
'.workshop',
'babel.config.cjs',
'jest.config.cjs',
'lint-staged.config.cjs',
'v2-incompatible.js',
'lib',
],
},

{
extends: [js.configs.recommended, ...ts.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2018,
globals: {
...globals.browser,
...globals.nodeBuiltin,
...globals.es2018,
},
sourceType: 'module',
},
linterOptions: {reportUnusedDisableDirectives: 'error'},
rules: {
'no-console': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
},
},
react.configs.flat.recommended,
reactHooks.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
eslintConfigPrettier,
])
Loading