Skip to content

Commit

Permalink
Merge pull request #4 from storyblok/chore/pro-76-setup-ci-releases
Browse files Browse the repository at this point in the history
[PRO-76] setup CI
  • Loading branch information
alvarosabu authored May 16, 2024
2 parents dd0ba54 + ac5d0c5 commit 926277c
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 22 deletions.
28 changes: 28 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2
updates:
- package-ecosystem: "pnpm"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: fix
prefix-development: chore
include: scope
groups:
linting-dx-tools:
patterns:
- "*lint*" # eslint, eslint-*, vue-eslint-parser, lint-staged, @commitlint/*, @typescript-eslint/*
- "prettier"
- "husky"
- "@vue/tsconfig"
- "*babel*" # babel-*, @vue/babel-preset-app, @babel/*
update-types:
- "minor"
- "patch"
testing-tools:
patterns:
- "@vue/test-utils"
- "vitest"
update-types:
- "minor"
- "patch"
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release CI

on:
push:
branches: [main, next, beta]
pull_request:
branches: [main, next, beta]

env:
PNPM_CACHE_FOLDER: .pnpm-store
HUSKY: 0 # Bypass husky commit hook for CI

jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build lib
run: pnpm run build
- name: Test run
run: pnpm run test
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release@latest
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Tests
on: [push]

env:
PNPM_CACHE_FOLDER: .pnpm-store
HUSKY: 0 # Bypass husky commit hook for CI

jobs:
test:
name: Unit Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run Unit Tests
run: pnpm run test
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is a proof of concept for a custom resolver for the Storyblok Richtext fiel
### Basic

```ts
import { RichTextResolver } from '@storyblok/richtext-resolver'
import { RichTextResolver } from '@storyblok/richtext'

const { render } = RichTextResolver()

Expand All @@ -28,7 +28,7 @@ document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
To overwrite an existing resolver, you can pass a property called resolvers available on the `RichTextResolver` options.

```ts
import { MarkTypes, RichTextResolver } from '@storyblok/richtext-resolver'
import { MarkTypes, RichTextResolver } from '@storyblok/richtext'

const html = RichTextResolver({
resolvers: {
Expand All @@ -47,7 +47,7 @@ It is possible to ensure correct typing support in a framework-agnostic way by u
- Vue `VNode`
- React `React.ReactElement`

This way the `@storyblok/richtext-resolver` is ignorant of framework specific types, avoiding having to import them and having `vue` `react` etc as dependencies.
This way the `@storyblok/richtext` is ignorant of framework specific types, avoiding having to import them and having `vue` `react` etc as dependencies.

```ts
// Vanilla
Expand Down
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@storyblok/richtext-resolver",
"name": "@storyblok/richtext",
"type": "module",
"version": "0.0.0",
"packageManager": "[email protected]",
Expand Down Expand Up @@ -109,6 +109,19 @@
"semi": true,
"singleQuote": false
},
"release": {
"branches": [
"main",
{
"name": "next",
"prerelease": true
},
{
"name": "beta",
"prerelease": true
}
]
},
"dependencies": {
"consola": "^3.2.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"dependencies": {
"@storyblok/react": "^3.0.9",
"@storyblok/richtext-resolver": "workspace:^",
"@storyblok/richtext": "workspace:^",
"@vitejs/plugin-react": "^4.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { StoryblokComponent } from '@storyblok/react'
import type { Node, SbRichtextOptions } from '@storyblok/richtext-resolver'
import { BlockTypes, RichTextResolver } from '@storyblok/richtext-resolver'
import type { Node, SbRichtextOptions } from '@storyblok/richtext'
import { BlockTypes, RichTextResolver } from '@storyblok/richtext'
import SbRichText from './SbRichText'

function componentResolver(node: Node<React.ReactElement>) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@storyblok/richtext-resolver": "workspace:^",
"@storyblok/richtext": "workspace:^",
"@storyblok/vue": "^8.0.7",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { VNode } from 'vue'
import { createTextVNode, h } from 'vue'
import { RouterLink } from 'vue-router'

import type { Node, NodeResolver, SbRichtextOptions } from '@storyblok/richtext-resolver'
import { BlockTypes, MarkTypes, RichTextResolver } from '@storyblok/richtext-resolver'
import type { Node, NodeResolver, SbRichtextOptions } from '@storyblok/richtext'
import { BlockTypes, MarkTypes, RichTextResolver } from '@storyblok/richtext'
import { StoryblokComponent } from '@storyblok/vue'
import SbRichText from './components/SbRichText.vue'

Expand Down
2 changes: 1 addition & 1 deletion playground/react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RichTextResolver } from '@storyblok/richtext-resolver'
import { RichTextResolver } from '@storyblok/richtext'
import { StoryblokComponent, useStoryblok } from '@storyblok/react'
import { SbRichText } from '@storyblok/react-richtext'
import './App.css'
Expand Down
2 changes: 1 addition & 1 deletion playground/react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineConfig({
],
resolve: {
alias: {
'@storyblok/richtext-resolver': resolve(__dirname, '../../src/index.ts'),
'@storyblok/richtext': resolve(__dirname, '../../src/index.ts'),
'@storyblok/react-richtext': resolve(__dirname, '../../packages/react/src/index.ts'),
},
},
Expand Down
2 changes: 1 addition & 1 deletion playground/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"vite-plugin-qrcode": "^0.2.3"
},
"dependencies": {
"@storyblok/richtext-resolver": "workspace:^",
"@storyblok/richtext": "workspace:^",
"storyblok-js-client": "^6.7.1"
}
}
2 changes: 1 addition & 1 deletion playground/vanilla/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './style.css'
import { MarkTypes, type Node, RichTextResolver, type SbRichtextOptions } from '@storyblok/richtext-resolver'
import { MarkTypes, type Node, RichTextResolver, type SbRichtextOptions } from '@storyblok/richtext'
import StoryblokClient from 'storyblok-js-client'

/* const doc: Node<string> = {
Expand Down
2 changes: 1 addition & 1 deletion playground/vanilla/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineConfig({
},
resolve: {
alias: {
'@storyblok/richtext-resolver': resolve(__dirname, '../../src/index.ts'),
'@storyblok/richtext': resolve(__dirname, '../../src/index.ts'),
},
},
})
2 changes: 1 addition & 1 deletion playground/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@storyblok/richtext-resolver": "workspace:^",
"@storyblok/richtext": "workspace:^",
"@storyblok/vue": "^8.0.7",
"@storyblok/vue-richtext": "workspace:^",
"vue": "^3.4.21",
Expand Down
2 changes: 1 addition & 1 deletion playground/vue/src/components/HomeView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { VNode, createTextVNode, h } from 'vue'
import { BlockTypes, MarkTypes, RichTextResolver, type Node, type SbRichtextOptions} from '@storyblok/richtext-resolver'
import { BlockTypes, MarkTypes, RichTextResolver, type Node, type SbRichtextOptions} from '@storyblok/richtext'
import { RouterLink } from 'vue-router'
import { SbRichText } from '@storyblok/vue-richtext'
import { useStoryblok } from '@storyblok/vue'
Expand Down
2 changes: 1 addition & 1 deletion playground/vue/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
],
resolve: {
alias: {
'@storyblok/richtext-resolver': resolve(__dirname, '../../src/index.ts'),
'@storyblok/richtext': resolve(__dirname, '../../src/index.ts'),
'@storyblok/vue-richtext': resolve(__dirname, '../../packages/vue/src/index.ts'),
},
},
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 926277c

Please sign in to comment.