MCPcopy
hub / github.com/vercel/next.js / getDeploymentId

Function getDeploymentId

test/lib/next-test-utils.ts:2074–2105  ·  view source on GitHub ↗
(appDir: string, isDev: boolean)

Source from the content-addressed store, hash-verified

2072 curRes.headers.get('x-nextjs-cache') || curRes.headers.get('x-vercel-cache')
2073
2074export function getDeploymentId(appDir: string, isDev: boolean) {
2075 let requiredServerFiles
2076 if (!isDev) {
2077 // File isn't written in dev, but it might still exist because it was created by a prior
2078 // production build.
2079 try {
2080 requiredServerFiles = JSON.parse(
2081 readFileSync(
2082 path.join(appDir, getDistDir(), 'required-server-files.json'),
2083 'utf8'
2084 )
2085 )
2086 } catch {}
2087 }
2088
2089 const deploymentId: string | undefined =
2090 requiredServerFiles?.config?.deploymentId
2091 const immutableAssetToken: string | undefined =
2092 requiredServerFiles?.config?.experimental?.immutableAssetToken
2093 const assetToken: string | undefined = immutableAssetToken || deploymentId
2094
2095 return {
2096 deploymentId,
2097 getDeploymentIdQuery(ampersand = false) {
2098 return deploymentId ? `${ampersand ? '&' : '?'}dpl=${deploymentId}` : ''
2099 },
2100 assetToken,
2101 getAssetQuery(ampersand = false) {
2102 return assetToken ? `${ampersand ? '&' : '?'}dpl=${assetToken}` : ''
2103 },
2104 }
2105}

Callers 9

runTestsFunction · 0.90
runTestsFunction · 0.90
runTestsFunction · 0.90
runTestsFunction · 0.90
runTestsFunction · 0.90
runTestsFunction · 0.90
runTestsFunction · 0.90
runTestsFunction · 0.90
runTestsFunction · 0.90

Calls 4

readFileSyncFunction · 0.85
getDistDirFunction · 0.85
parseMethod · 0.45
joinMethod · 0.45

Tested by 7

runTestsFunction · 0.72
runTestsFunction · 0.72
runTestsFunction · 0.72
runTestsFunction · 0.72
runTestsFunction · 0.72
runTestsFunction · 0.72
runTestsFunction · 0.72