- API: `pnpm build` bundles dist/ into apps/api/.output (esbuild), with Linux musl native packages for sharp and argon2 kept alongside - docker/api.Dockerfile copies that output; no pnpm install on the server - add dist/migrate.js (prisma migrate deploy equivalent, same _prisma_migrations table and lock) so the Prisma CLI is not needed at runtime - pnpm-workspace: supportedArchitectures for linux/x64/musl - admin: apps/admin/.env.production sets VITE_SITE_URL for the production build - drop NPM_REGISTRY / SITE_URL build args from compose and .env.example - gitignore: anchor node_modules rules so pre-built node_modules are committed - README: describe the pre-built deploy flow Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
49 lines
1021 B
JavaScript
49 lines
1021 B
JavaScript
'use strict'
|
|
|
|
const parse = require('./parse')
|
|
const constants = require('../internal/constants')
|
|
const SemVer = require('../classes/semver')
|
|
|
|
const truncate = (version, truncation, options) => {
|
|
if (!constants.RELEASE_TYPES.includes(truncation)) {
|
|
return null
|
|
}
|
|
|
|
const clonedVersion = cloneInputVersion(version, options)
|
|
return clonedVersion && doTruncation(clonedVersion, truncation)
|
|
}
|
|
|
|
const cloneInputVersion = (version, options) => {
|
|
const versionStringToParse = (
|
|
version instanceof SemVer ? version.version : version
|
|
)
|
|
|
|
return parse(versionStringToParse, options)
|
|
}
|
|
|
|
const doTruncation = (version, truncation) => {
|
|
if (isPrerelease(truncation)) {
|
|
return version.version
|
|
}
|
|
|
|
version.prerelease = []
|
|
|
|
switch (truncation) {
|
|
case 'major':
|
|
version.minor = 0
|
|
version.patch = 0
|
|
break
|
|
case 'minor':
|
|
version.patch = 0
|
|
break
|
|
}
|
|
|
|
return version.format()
|
|
}
|
|
|
|
const isPrerelease = (type) => {
|
|
return type.startsWith('pre')
|
|
}
|
|
|
|
module.exports = truncate
|