feat(cli): split commit and release into target-based workflows
This commit is contained in:
@@ -63,7 +63,7 @@ export async function detectProjectType(): Promise<ProjectType> {
|
||||
* @param versionType Type of version bump
|
||||
* @returns New version string
|
||||
*/
|
||||
function calculateNewVersion(currentVersion: string, versionType: VersionType): string {
|
||||
export function calculateNewVersion(currentVersion: string, versionType: VersionType): string {
|
||||
const versionMatch = currentVersion.match(/^(\d+)\.(\d+)\.(\d+)/);
|
||||
|
||||
if (!versionMatch) {
|
||||
@@ -95,7 +95,7 @@ function calculateNewVersion(currentVersion: string, versionType: VersionType):
|
||||
* @param projectType The project type to determine which file to read
|
||||
* @returns The current version string
|
||||
*/
|
||||
async function readCurrentVersion(projectType: ProjectType): Promise<string> {
|
||||
export async function readCurrentVersion(projectType: ProjectType): Promise<string> {
|
||||
if (projectType === 'npm' || projectType === 'both') {
|
||||
const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
|
||||
const content = (await plugins.smartfs
|
||||
@@ -128,7 +128,7 @@ async function readCurrentVersion(projectType: ProjectType): Promise<string> {
|
||||
* @param filePath Path to the JSON file
|
||||
* @param newVersion The new version to write
|
||||
*/
|
||||
async function updateVersionFile(filePath: string, newVersion: string): Promise<void> {
|
||||
export async function updateVersionFile(filePath: string, newVersion: string): Promise<void> {
|
||||
const content = (await plugins.smartfs
|
||||
.file(filePath)
|
||||
.encoding('utf8')
|
||||
@@ -141,6 +141,30 @@ async function updateVersionFile(filePath: string, newVersion: string): Promise<
|
||||
.write(JSON.stringify(config, null, 2) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates project version files without creating commits or tags.
|
||||
*/
|
||||
export async function updateProjectVersionFiles(
|
||||
projectType: ProjectType,
|
||||
newVersion: string,
|
||||
): Promise<string[]> {
|
||||
const filesToUpdate: string[] = [];
|
||||
const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
|
||||
const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
|
||||
|
||||
if (projectType === 'npm' || projectType === 'both') {
|
||||
await updateVersionFile(packageJsonPath, newVersion);
|
||||
filesToUpdate.push('package.json');
|
||||
}
|
||||
|
||||
if (projectType === 'deno' || projectType === 'both') {
|
||||
await updateVersionFile(denoJsonPath, newVersion);
|
||||
filesToUpdate.push('deno.json');
|
||||
}
|
||||
|
||||
return filesToUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bumps the project version based on project type
|
||||
* Handles npm-only, deno-only, and dual projects with unified logic
|
||||
@@ -182,19 +206,7 @@ export async function bumpProjectVersion(
|
||||
logger.log('info', `Bumping version: ${currentVersion} → ${newVersion}`);
|
||||
|
||||
// 3. Determine which files to update
|
||||
const filesToUpdate: string[] = [];
|
||||
const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
|
||||
const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
|
||||
|
||||
if (projectType === 'npm' || projectType === 'both') {
|
||||
await updateVersionFile(packageJsonPath, newVersion);
|
||||
filesToUpdate.push('package.json');
|
||||
}
|
||||
|
||||
if (projectType === 'deno' || projectType === 'both') {
|
||||
await updateVersionFile(denoJsonPath, newVersion);
|
||||
filesToUpdate.push('deno.json');
|
||||
}
|
||||
const filesToUpdate = await updateProjectVersionFiles(projectType, newVersion);
|
||||
|
||||
// 4. Stage all updated files
|
||||
await smartshellInstance.exec(`git add ${filesToUpdate.join(' ')}`);
|
||||
|
||||
Reference in New Issue
Block a user