From e11807fe0a62dade1faaee93b8e061774a866fea Mon Sep 17 00:00:00 2001 From: brklntmhwk_w <86272619+brklntmhwk@users.noreply.github.com.> Date: Tue, 29 Oct 2024 16:12:20 +0900 Subject: [PATCH] sixth commit --- .github/workflows/ci.yml | 33 ++++++---- .github/workflows/release.yml | 49 +++++++++++++++ package.json | 6 +- renovate.json | 20 +++++++ src/index.ts | 2 +- src/print.ts | 109 ---------------------------------- 6 files changed, 95 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 renovate.json delete mode 100644 src/print.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d707836..15e90c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,10 +4,28 @@ on: pull_request: branches: - main + push: + branches: + - main jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install Dependencies + run: bun install --no-save + - name: Format & Lint Code + run: bun --bun run check build: runs-on: ubuntu-latest + timeout-minutes: 30 steps: - name: Checkout uses: actions/checkout@v4 @@ -19,9 +37,9 @@ jobs: run: bun install --no-save - name: Build run: bun --bun run build - release: - needs: build + test: runs-on: ubuntu-latest + timeout-minutes: 30 steps: - name: Checkout uses: actions/checkout@v4 @@ -31,12 +49,5 @@ jobs: bun-version: latest - name: Install Dependencies run: bun install --no-save - - name: Set up Node.js env - uses: actions/setup-node@v4 - with: - node-version: 20 - registry-url: "https://registry.npmjs.org" - - name: Publish - run: npm publish --access public --tag ${{ env.RELEASE_TAG }} - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Test Code + run: bun test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..21161b4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Package release + +on: + workflow_dispatch: + inputs: + release: + description: "Release type (one of): major, minor, patch" + required: true + type: choice + options: + - major + - minor + - patch + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install Dependencies + run: bun install --no-save + - name: Build + run: bun --bun run build + release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install Dependencies + run: bun install --no-save + - name: Set up Node.js env + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: "https://registry.npmjs.org" + - name: Publish + run: npm publish --access public --tag ${{ env.RELEASE_TAG }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index ce2a75d..1edc819 100644 --- a/package.json +++ b/package.json @@ -24,11 +24,11 @@ ], "scripts": { "build": "tsc --project tsconfig.build.json", - "format": "bunx biome format ./src", + "format": "bunx biome format ./src ./test", "format:fix": "bunx biome format --write ./src ./test", - "lint": "bunx biome lint ./src", + "lint": "bunx biome lint ./src ./test", "lint:fix": "bunx biome lint --write ./src ./test", - "check": "bunx biome check ./src", + "check": "bunx biome check ./src ./test", "check:fix": "bunx biome check --write ./src ./test", "test-type": "type-coverage" }, diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..4d70a67 --- /dev/null +++ b/renovate.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base"], + "schedule": ["after 3am and before 5am on the first day of the month"], + "timezone": "Asia/Tokyo", + "dependencyDashboard": true, + "packageRules": [ + { + "groupName": "Dependencies (non-major update)", + "matchDepTypes": ["dependencies"], + "matchUpdateTypes": ["minor", "patch", "pin", "digest"], + "automerge": true + }, + { + "groupName": "DevDependencies", + "matchDepTypes": ["devDependencies"], + "automerge": true + } + ] +} diff --git a/src/index.ts b/src/index.ts index a34815c..277563c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,7 @@ import { const remarkCard: Plugin<[], Root> = () => { return (tree) => { visit(tree, isContainerDirective, (node) => { - if (!(node.name === "card-grid")) return; + if (node.name !== "card-grid") return; if (node.children.length === 0) return; node.data = { diff --git a/src/print.ts b/src/print.ts deleted file mode 100644 index 0995faa..0000000 --- a/src/print.ts +++ /dev/null @@ -1,109 +0,0 @@ -import rehypeStringify from "rehype-stringify"; -import remarkDirective from "remark-directive"; -import remarkParse from "remark-parse"; -import remarkRehype from "remark-rehype"; -import { unified } from "unified"; -import remarkCard from "./index"; - -const normalizeHtml = (html: string) => { - return html.replace(/[\n\s]*(<)|>([\n\s]*)/g, (match, p1, p2) => - p1 ? "<" : ">", - ); -}; - -const parseMarkdown = async (markdown: string, debug = false) => { - const remarkProcessor = unified() - .use(remarkParse) - .use(remarkDirective) - .use(remarkCard) - .use(remarkRehype) - .use(rehypeStringify); - - if (debug) { - const remarkOutput = await remarkProcessor.run( - remarkProcessor.parse(markdown), - ); - console.log("Remark output:", JSON.stringify(remarkOutput, null, 2)); - } - - const output = String(await remarkProcessor.process(markdown)); - - if (debug) { - console.log( - `HTML output: - ${normalizeHtml(output)}`, - ); - } - - return output; -}; - -const markdown1 = ` -:::card{.card1.solid} -![image alt](https://xxxxx.xxx/yyy.jpg) -mark -down -1 -::: -`; - -const markdown2 = ` -:::card[card alt]{.card2.double} -![](https://xxxxx.xxx/yyy.jpg) -mark -down -2 -following sentence -[link alt](https://google.com/) -**strong sentence** -::: -`; - -const markdown3 = ` -:::card[card alt]{.card3.dashed} -[![image alt](https://xxxxx.xxx/yyy.jpg)](https://unsplash.com) -mark -down -3 -::: -`; - -const markdown4 = ` -::::card-grid -:::card[card alt]{.card4-1.solid} -![image alt](https://xxxxx.xxx/yyy.jpg) -card 4-1 -::: -:::card[card alt]{.card4-2.solid} -![image alt](https://xxxxx.xxx/yyy.jpg) -card 4-2 -::: -:::card[card alt]{.card4-3.solid} -![image alt](https://xxxxx.xxx/yyy.jpg) -card 4-3 -::: -:::: -`; - -const markdown5 = ` -::::card-grid{.card-grid} -:::card[card alt]{.card5-1.double} -![image alt](https://xxxxx.xxx/yyy.jpg) -card 5-1 -::: -:::card[card alt]{.card5-2.double} -![image alt](https://xxxxx.xxx/yyy.jpg) -card 5-2 -::: -:::card[card alt]{.card5-3.double} -![image alt](https://xxxxx.xxx/yyy.jpg) -card 5-3 -::: -:::: -`; - -await parseMarkdown(markdown1, true); -await parseMarkdown(markdown2, true); -await parseMarkdown(markdown3, true); -await parseMarkdown(markdown4, true); -await parseMarkdown(markdown5, true);