The plugin's version is a constant: no package.json among a site's public assets
pluginVersion() named package.json relative to its own module. A bundler takes such a file for an asset: a Turbopack build of a site copied the plugin's whole package.json (dependency lists, scripts, the registry and repository addresses; no secret) to /_next/static/media/package.<hash>.json, served to anyone. Webpack kept it on the server side. The version now comes from src/version.ts (scripts/write-version.mjs, run by the `version` script; a test fails when it differs from package.json). A smoke test of the built site: nothing under .next/static is a package manifest. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
bc0fa65fd7
commit
9a648b0498
@@ -1,10 +1,10 @@
|
||||
import type { BasePayload, Endpoint, PayloadRequest } from 'payload'
|
||||
|
||||
import { timingSafeEqual } from 'node:crypto'
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
import type { DoctorStatus } from './types.js'
|
||||
|
||||
import { PLUGIN_VERSION } from '../../version.js'
|
||||
import { openSignUpCollections, staffCollectionsOnOwnRoles, staffCollectionsOpenToOthers } from '../access/selfRegistration.js'
|
||||
import { countPendingCookies } from '../consent/scanner/approval.js'
|
||||
import { COOKIE_REVIEW_SLUG } from '../consent/scanner/collection.js'
|
||||
@@ -13,13 +13,9 @@ import { countAccountsWithoutTotp } from '../security/totp/setupRequired.js'
|
||||
import { clientIp, consumeRateLimit, tooManyRequests } from '../shared/rateLimit.js'
|
||||
import { turnstileSecretFromEnv } from '../turnstile/config.js'
|
||||
|
||||
/** The plugin's own version (package.json next to dist/ and src/). */
|
||||
/** The plugin's own version — a constant (src/version.ts), never a file read at run time. */
|
||||
export function pluginVersion(): string {
|
||||
try {
|
||||
return (JSON.parse(readFileSync(new URL('../../../package.json', import.meta.url), 'utf8')) as { version: string }).version
|
||||
} catch {
|
||||
return 'unknown'
|
||||
}
|
||||
return PLUGIN_VERSION
|
||||
}
|
||||
|
||||
type CollectionLike = { fields?: Array<{ name?: string }>; slug: string }
|
||||
|
||||
Reference in New Issue
Block a user