hackages
Version:
CLI tool for learning software development concepts through test-driven development
85 lines (84 loc) • 2.9 kB
JavaScript
import { apiClient } from "./api.js";
import { printError } from "../utils/console.js";
export async function getAllTechnologies() {
try {
const response = await apiClient.tech.getAllTechnologies();
return response.technologies;
}
catch (error) {
printError(`Failed to get technologies: ${error}`);
throw error;
}
}
export async function getTechnologyConfig(tech) {
try {
const response = await apiClient.tech.getTechnologyConfig(tech);
return response.config;
}
catch (error) {
printError(`Failed to get technology config: ${error}`);
throw error;
}
}
/**
* Get repository templates for different technologies
* @returns Map of technology to repository template
*/
export function getRepositoryTemplates() {
return {
typescript: {
name: "TypeScript Template",
ssh: "git@github.com:hackages/ts-template.git",
https: "https://github.com/hackages/ts-template.git",
description: "TypeScript project template with Vitest testing setup"
},
javascript: {
name: "JavaScript Template",
ssh: "git@github.com:hackages/js-template.git",
https: "https://github.com/hackages/js-template.git",
description: "JavaScript project template with Vitest testing setup"
},
python: {
name: "Python Template",
ssh: "git@github.com:hackages/python-template.git",
https: "https://github.com/hackages/python-template.git",
description: "Python project template with Vitest testing setup"
},
go: {
name: "Go Template",
ssh: "git@github.com:hackages/go-template.git",
https: "https://github.com/hackages/go-template.git",
description: "Go project template with Vitest testing setup"
},
java: {
name: "Java Template",
ssh: "git@github.com:hackages/java-template.git",
https: "https://github.com/hackages/java-template.git",
description: "Java project template with Vitest testing setup"
},
};
}
/**
* Get technology configuration with repository templates
* @param tech Technology name
* @returns Technology configuration with repository information
*/
export function getTechnologyConfigWithRepository(tech) {
const templates = getRepositoryTemplates();
const template = templates[tech.toLowerCase()];
const baseConfig = {
tech,
extension: tech === 'typescript' ? '.spec.ts' : '.spec.js',
srcExt: tech === 'typescript' ? '.ts' : '.js'
};
if (template) {
return {
...baseConfig,
repository: {
ssh: template.ssh,
https: template.https
}
};
}
return baseConfig;
}