Compare commits

...

6 commits

Author SHA1 Message Date
semantic-release-bot
0ec25d1693 chore(release): 0.2.0 [skip ci]
## [0.2.0](https://git.kjan.de/jank/project-cli/compare/v0.1.1...v0.2.0) (2025-06-19)

### Features

* Add basic project creation ([fb23f6f](fb23f6fd8b))
2025-06-19 11:49:48 +00:00
fb23f6fd8b
feat: Add basic project creation
All checks were successful
Release / Release (push) Successful in 32s
2025-06-19 13:48:55 +02:00
semantic-release-bot
85f3baef47 chore(release): 0.1.1 [skip ci]
## [0.1.1](https://git.kjan.de/jank/project-cli/compare/v0.1.0...v0.1.1) (2025-06-19)

### Chores

* **deps:** add renovate.json ([9284088](9284088629))
2025-06-19 08:17:26 +00:00
1f3158fd53
Merge pull request 'chore: Configure Renovate' (#1) from renovate/configure into main
All checks were successful
Release / Release (push) Successful in 31s
Reviewed-on: #1
2025-06-19 08:16:58 +00:00
semantic-release-bot
630fab7ce6 chore(release): 0.1.0 [skip ci]
## [0.1.0](https://git.kjan.de/jank/project-cli/compare/v0.0.1...v0.1.0) (2025-06-19)

### Features

* Add releases ([7dc8496](7dc849688f))

### Bug Fixes

* Use newer version of the release action ([9c16070](9c16070b54))
2025-06-19 08:14:57 +00:00
9284088629
chore(deps): add renovate.json 2025-06-19 06:03:06 +00:00
6 changed files with 8246 additions and 3 deletions

21
CHANGELOG.md Normal file
View file

@ -0,0 +1,21 @@
## [0.2.0](https://git.kjan.de/jank/project-cli/compare/v0.1.1...v0.2.0) (2025-06-19)
### Features
* Add basic project creation ([fb23f6f](https://git.kjan.de/jank/project-cli/commit/fb23f6fd8b5c4f625524a86e2378aa2b503458a8))
## [0.1.1](https://git.kjan.de/jank/project-cli/compare/v0.1.0...v0.1.1) (2025-06-19)
### Chores
* **deps:** add renovate.json ([9284088](https://git.kjan.de/jank/project-cli/commit/92840886290ed4796d16643f49b5c4d622814e55))
## [0.1.0](https://git.kjan.de/jank/project-cli/compare/v0.0.1...v0.1.0) (2025-06-19)
### Features
* Add releases ([7dc8496](https://git.kjan.de/jank/project-cli/commit/7dc849688fa9189e360c5fb491b2e8cd630a57d1))
### Bug Fixes
* Use newer version of the release action ([9c16070](https://git.kjan.de/jank/project-cli/commit/9c16070b54a634b78fffd341ac5b0190ae2fedbb))

View file

@ -4,8 +4,36 @@ import * as toml from "@std/toml";
export const configPath = os.homedir() + "/.config/project-cli/";
export interface Project {
name: string;
}
export interface Configuration {
projectsDirectory: string;
cloningCommand: string;
}
export function getProjects(): Project[] {
const projectsString = fs
.readFileSync(configPath + "projects.json")
.toString();
return JSON.parse(projectsString) as Project[];
}
export function getConfiguration(): Configuration {
return toml.parse(
fs.readFileSync(configPath + "config.toml").toString(),
) as unknown as Configuration;
}
export function addProject(project: Project) {
let projects = getProjects();
if (projects.length == undefined) {
saveProjects([project]);
} else {
projects.push(project);
saveProjects(projects);
}
}
export function generateDefaultConfig() {
@ -14,10 +42,19 @@ export function generateDefaultConfig() {
const defaultConfig: Configuration = {
projectsDirectory: os.homedir() + "/projects",
cloningCommand: "git clone %s %n",
};
const configString = toml.stringify(
defaultConfig as unknown as Record<string, unknown>,
);
fs.writeFileSync(configPath + "config.toml", configString);
const projects: Project[] = [];
saveProjects(projects);
}
function saveProjects(projects: Project[]) {
const projectsString = JSON.stringify(projects);
fs.writeFileSync(configPath + "projects.json", projectsString);
}

View file

@ -1,10 +1,15 @@
import fs from "fs";
import { confirm } from "@inquirer/prompts";
import { confirm, select, input } from "@inquirer/prompts";
import { exit } from "process";
import {
addProject,
configPath,
generateDefaultConfig,
getConfiguration,
getProjects,
type Project,
} from "./configuration/configuration";
import { execSync } from "child_process";
if (!fs.existsSync(configPath + "config.toml")) {
const createConfig = await confirm({
@ -21,3 +26,50 @@ if (!fs.existsSync(configPath + "config.toml")) {
}
}
if (
!getProjects() ||
getProjects().length == 0 ||
getProjects().length == undefined
) {
const anwser = await select({
message: "Create a new Project",
choices: ["Clone a project with git", "Create a new empty Project"],
});
if (anwser == "Clone a project with git") {
const repoUrl = await input({ message: "What is the url of the repo?" });
const wantsCustomName = await confirm({
message: "Would you like to give this project a custom name?",
default: false,
});
let customName = "";
if (wantsCustomName) {
customName = await input({
message: "What would you like the custom name to be?",
});
}
execSync(
"cd " +
getConfiguration().projectsDirectory +
" && " +
getConfiguration()
.cloningCommand.replace("%s", repoUrl)
.replace("%n", customName),
);
const newProject: Project = {
name: customName,
};
addProject(newProject);
} else if (anwser == "Create a new empty Project") {
const name = await input({
message: "What would you like to call the project?",
});
fs.mkdirSync(getConfiguration().projectsDirectory + "/" + name);
const newProject: Project = {
name: name,
};
addProject(newProject);
}
}
console.log(getProjects());

8120
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "proj-cli",
"version": "0.0.1",
"version": "0.2.0",
"module": "index.ts",
"type": "module",
"devDependencies": {
@ -10,10 +10,17 @@
"typescript": "^5.0.0"
},
"dependencies": {
"@saithodev/semantic-release-gitea": "^2.1.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/release-notes-generator": "^14.0.3",
"@std/toml": "npm:@jsr/std__toml",
"@types/commander": "^2.12.5",
"@types/inquirer": "^9.0.8",
"commander": "^14.0.0",
"inquirer": "^12.6.3"
"commitlint-plugin-cleanfeet": "^0.1.2",
"conventional-changelog-conventionalcommits": "^9.0.0",
"inquirer": "^12.6.3",
"semantic-release": "^24.2.5"
}
}

6
renovate.json Normal file
View file

@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>Renovate/renovate-config"
]
}