-
Notifications
You must be signed in to change notification settings - Fork 100
Added patchflow to generate usage example #1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CTY-git
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi can you generate a usage example with the patchflow? Thanks.
plon-Susk7#5 |
patchflows are meant to be run from the CLI, so this new |
yes |
|
@plon-Susk7 can you try generating a example for a js file as well? Also please change the patchflow name to GenerateCodeUsageExample instead. |
|
Here's example for js file class VersionBumper {
constructor(initialVersion = "0.1.0") {
if (!this.isValidVersion(initialVersion)) {
throw new Error("Invalid version format. Use Semantic Versioning (MAJOR.MINOR.PATCH).");
}
this.version = initialVersion;
}
/**
* Validate the version string
* @param {string} version
* @returns {boolean}
*/
isValidVersion(version) {
return /^\d+\.\d+\.\d+$/.test(version);
}
/**
* Get the current version
* @returns {string}
*/
getVersion() {
return this.version;
}
/**
* Bump the version based on the type
* @param {string} type - "major", "minor", or "patch"
* @returns {string} - New version
*/
bump(type) {
const [major, minor, patch] = this.version.split(".").map(Number);
let newVersion;
switch (type) {
case "major":
newVersion = `${major + 1}.0.0`;
break;
case "minor":
newVersion = `${major}.${minor + 1}.0`;
break;
case "patch":
newVersion = `${major}.${minor}.${patch + 1}`;
break;
default:
throw new Error('Invalid bump type. Use "major", "minor", or "patch".');
}
this.version = newVersion;
return this.version;
}
/**
* Set the version explicitly
* @param {string} version
*/
setVersion(version) {
if (!this.isValidVersion(version)) {
throw new Error("Invalid version format. Use Semantic Versioning (MAJOR.MINOR.PATCH).");
}
this.version = version;
}
/**
* Generate a tag for the version
* @returns {string}
*/
generateTag(prefix = "v") {
return `${prefix}${this.version}`;
}
}
export default VersionBumper;
|
Done 👍 |
CTY-git
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Checklist
PR Type
What is the current behavior?
No patchflow to generate usage example.
Issue Number: #878
What is the new behavior?
This PR introduces a new patchflow that generates usage example when provided with folder_path as argument.
Other information