Skip to content

Commit

Permalink
feat: frog:version meta tag
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Feb 29, 2024
1 parent b5b0606 commit a0442ba
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-hats-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Added `frog:version` meta tag.
8 changes: 8 additions & 0 deletions .scripts/postversion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { join } from 'node:path'

// Writes the current package.json version to `./src/version.ts`.
const versionFilePath = join(import.meta.dir, '../src/version.ts')
const packageJsonPath = join(import.meta.dir, '../src/package.json')
const packageVersion = (await Bun.file(packageJsonPath).json()).version

Bun.write(versionFilePath, `export const version = '${packageVersion}'\n`)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build:create-frog": "rimraf create-frog/_lib && tsc -p create-frog/tsconfig.build.json",
"changeset": "changeset",
"changeset:release": "pnpm build && changeset publish",
"changeset:version": "changeset version && pnpm install --lockfile-only",
"changeset:version": "changeset version && pnpm install --lockfile-only && bun .scripts/postversion.ts",
"clean": "rimraf src/_lib src/tsconfig.build.tsbuildinfo",
"create-frog": "node --import tsx ./create-frog/bin.ts",
"docs:dev": "pnpm --filter site dev",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { join, resolve } from 'node:path'
import devServer from '@hono/vite-dev-server'
import pc from 'picocolors'
import { createLogger, createServer } from 'vite'
import { version } from '../../version.js'
import { findEntrypoint } from '../utils/findEntrypoint.js'
import { version } from '../version.js'

type DevOptions = { host?: boolean; port?: number }

Expand Down
2 changes: 1 addition & 1 deletion src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node
import { cac } from 'cac'

import { version } from '../version.js'
import { dev } from './commands/dev.js'
import { build as build_vercel } from './commands/vercel-build.js'
import { version } from './version.js'

export const cli = cac('frog')

Expand Down
1 change: 0 additions & 1 deletion src/cli/version.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/frog-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { parsePath } from './utils/parsePath.js'
import { requestToContext } from './utils/requestToContext.js'
import { serializeJson } from './utils/serializeJson.js'
import { toSearchParams } from './utils/toSearchParams.js'
import { version } from './version.js'

export type FrogConstructorParameters<
state = undefined,
Expand Down Expand Up @@ -386,6 +387,7 @@ export class FrogBase<
content={serializeJson(baseContext)}
/>
)}
<meta property="frog:version" content={version} />
</head>
{body}
</html>,
Expand Down
1 change: 1 addition & 0 deletions src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const version = '0.2.0'

0 comments on commit a0442ba

Please sign in to comment.