feat: release notes (#283)
* feat: add release.ts * feat: add utils * chore: add scripts to tsconfig.json include * feat: add changelog logic, component, storybook file, scripts, and update to Node v20.9.0 (LTS) * chore: update packages * feat: use conventionalcommits for changelog preset * feat: update padding, width, and change font to mono * feat: refactor to use DialogProvider * chore: remove extra args * feat: update CHANGELOG.md, add title, and add button * refactor: use hook * chore: fix typo
This commit is contained in:
27
utils/git/getSourceRef.ts
Normal file
27
utils/git/getSourceRef.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { SimpleGit } from 'simple-git';
|
||||
import { simpleGit } from 'simple-git';
|
||||
|
||||
/**
|
||||
* Determines the source reference based on the destination branch.
|
||||
* @param destinationBranch - The destination branch for the release.
|
||||
* @returns A Promise that resolves to the source reference.
|
||||
* @throws Error if an invalid destination branch is provided.
|
||||
*/
|
||||
export async function getSourceRef(destinationBranch: string): Promise<string> {
|
||||
const git: SimpleGit = simpleGit();
|
||||
|
||||
switch (destinationBranch) {
|
||||
case 'preview':
|
||||
return 'develop';
|
||||
case 'production':
|
||||
// Get the latest tag from the repository
|
||||
const tags = await git.tags();
|
||||
const latestTag = tags.latest;
|
||||
if (!latestTag) {
|
||||
throw new Error('No tags found in the repository');
|
||||
}
|
||||
return latestTag;
|
||||
default:
|
||||
throw new Error(`Invalid destination branch: ${destinationBranch}`);
|
||||
}
|
||||
}
|
||||
69
utils/log.ts
69
utils/log.ts
@@ -1,26 +1,3 @@
|
||||
type ColorType = 'success' | 'info' | 'error' | 'warning' | keyof typeof COLORS;
|
||||
|
||||
export default function colorLog(message: string, type?: ColorType) {
|
||||
let color: string = type || COLORS.FgBlack;
|
||||
|
||||
switch (type) {
|
||||
case 'success':
|
||||
color = COLORS.FgGreen;
|
||||
break;
|
||||
case 'info':
|
||||
color = COLORS.FgBlue;
|
||||
break;
|
||||
case 'error':
|
||||
color = COLORS.FgRed;
|
||||
break;
|
||||
case 'warning':
|
||||
color = COLORS.FgYellow;
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(color, message);
|
||||
}
|
||||
|
||||
const COLORS = {
|
||||
Reset: '\x1b[0m',
|
||||
Bright: '\x1b[1m',
|
||||
@@ -46,3 +23,49 @@ const COLORS = {
|
||||
BgCyan: '\x1b[46m',
|
||||
BgWhite: '\x1b[47m',
|
||||
} as const;
|
||||
|
||||
type ColorType = 'success' | 'info' | 'error' | 'warning' | keyof typeof COLORS;
|
||||
|
||||
/**
|
||||
* Logs a message with an optional color type.
|
||||
*
|
||||
* @param message - The message to be logged.
|
||||
* @param type - The color type of the log message. Defaults to undefined.
|
||||
*/
|
||||
export default function colorLog(message: string, type?: ColorType) {
|
||||
let color: string = type || COLORS.FgBlack;
|
||||
|
||||
switch (type) {
|
||||
case 'success':
|
||||
color = COLORS.FgGreen;
|
||||
break;
|
||||
case 'info':
|
||||
color = COLORS.FgBlue;
|
||||
break;
|
||||
case 'error':
|
||||
color = COLORS.FgRed;
|
||||
break;
|
||||
case 'warning':
|
||||
color = COLORS.FgYellow;
|
||||
break;
|
||||
default:
|
||||
color = COLORS.FgWhite;
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(color, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an info message
|
||||
*
|
||||
* @param message - The message to be logged.
|
||||
*/
|
||||
export const info = (message: string) => colorLog(message, 'info');
|
||||
|
||||
/**
|
||||
* Logs an error message.
|
||||
*
|
||||
* @param message - The message to be logged
|
||||
*/
|
||||
export const error = (message: string) => colorLog(message, 'error');
|
||||
|
||||
Reference in New Issue
Block a user