Automate your development process, increase visibility.
@CommandHandler("Kotlin Spring 5 generator", "Generate a new spring Kotlin project")
export class KotlinSpring5 extends JavaSeed
public projectEditor(ctx: HandlerContext, params: this): ProjectEditor {
return transformSeed;
}
const transformSeed: ProjectEditor = project: Project, ctx: HandlerContext, pars: KotlinSpring5) => {
const artifact = camelize(pars.artifactId);
const appName = artifact.charAt(0).toUpperCase() + artifact.substr(1);
const smartArtifactId = (pars.artifactId === "${projectName}") ? project.name : pars.artifactId;
return updatePom(project, smartArtifactId, pars.groupId, pars.version, pars.description)
.then(inferFromKotlinSource)
.then(structure => !!structure ?
renameAppClass(project, structure, appName)
.then(p => movePackage(p, structure.applicationPackage, pars.rootPackage, AllKotlinFiles))
: project);
};
function renameAppClass(project: Project, structure: SpringBootProjectStructure,
appName: string): Promise {
return doWithFiles(project, AllKotlinFiles, f =>
f.replaceAll(structure.applicationClassStem, appName)
.then(f => f.path.includes(structure.applicationClassStem) ?
f.setPath(f.path.replace(structure.applicationClassStem, appName)) :
f
)
)
}
@CommandHandler("Upgrade versions of Spring Boot across an org", "upgrade spring boot version")
export class SpringBootVersionUpgrade extends EditorCommandSupport {
@Secret(Secrets.userToken(["repo", "user"]))
protected githubToken;
@Parameter({
displayName: "Desired Spring Boot version",
description: "The desired Spring Boot version across these repos",
pattern: /^.+$/,
validInput: "Semantic version",
required: false,
})
public desiredBootVersion: string;
public projectEditor(): ProjectEditor {
return setSpringBootVersionEditor(this.desiredBootVersion);
}
public editInfo(p: Project): EditMode {
return new PullRequest("spring-boot-" + this.desiredBootVersion,
"Upgrade Spring Boot to " + this.desiredBootVersion);
}
}
export function setSpringBootVersionEditor(desiredBootVersion: string): AnyProjectEditor {
return p =>
doWithAtMostOneMatch(p, "pom.xml",
parentStanzaOfGrammar(SpringBootStarter), m => {
if (m.version.value !== desiredBootVersion) {
m.version.value = desiredBootVersion;
}
});
}
@CommandHandler("Query Stack Overflow", "search so")
@Tags("stack-overflow")
export class SearchStackOverflow implements HandleCommand {
@Parameter({ description: "your search query", pattern: /^.*$/ })
public q: string;
public handle(ctx: HandlerContext): Promise {
return axios.get(`${apiSearchUrl}${encodeURIComponent(this.q)}`)
.then(res => this.handleResult(res, this.q))
.then(msg => return ctx.messageClient.respond(msg) });
}
}