chore:little fixes and formating and linting and patches
This commit is contained in:
@@ -10,6 +10,11 @@ import { generateReadme } from './generate-readme';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
// Pre-compiled regex patterns for performance
|
||||
const PRE_RELEASE_SUFFIX_REGEX = /-.*$/;
|
||||
const LOCAL_SUFFIX_REGEX = /-local$/;
|
||||
const WORKSPACE_PREFIX_REGEX = /^workspace:/;
|
||||
|
||||
// Types
|
||||
interface PackageJson {
|
||||
name: string;
|
||||
@@ -72,7 +77,7 @@ const getNextVersion = (version: string, type: ReleaseType): string => {
|
||||
throw new Error('Invalid version');
|
||||
}
|
||||
return type.startsWith('pre')
|
||||
? nextVersion.replace(/-.*$/, '-rc')
|
||||
? nextVersion.replace(PRE_RELEASE_SUFFIX_REGEX, '-rc')
|
||||
: nextVersion;
|
||||
};
|
||||
|
||||
@@ -92,7 +97,7 @@ const loadPackages = (
|
||||
const pkgJson = JSON.parse(
|
||||
fs.readFileSync(pkgPath, 'utf-8')
|
||||
) as PackageJson;
|
||||
const version = pkgJson.version.replace(/-local$/, '');
|
||||
const version = pkgJson.version.replace(LOCAL_SUFFIX_REGEX, '');
|
||||
return [
|
||||
pkgJson.name,
|
||||
{
|
||||
@@ -140,8 +145,12 @@ const updatePackageJsonForRelease = (
|
||||
depName,
|
||||
dependents.includes(depName)
|
||||
? packages[depName]?.nextVersion ||
|
||||
depVersion.replace(/-local$/, '').replace(/^workspace:/, '')
|
||||
: depVersion.replace(/-local$/, '').replace(/^workspace:/, ''),
|
||||
depVersion
|
||||
.replace(LOCAL_SUFFIX_REGEX, '')
|
||||
.replace(WORKSPACE_PREFIX_REGEX, '')
|
||||
: depVersion
|
||||
.replace(LOCAL_SUFFIX_REGEX, '')
|
||||
.replace(WORKSPACE_PREFIX_REGEX, ''),
|
||||
]
|
||||
)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user