Compare commits

...

26 commits

Author SHA1 Message Date
12c6d3f841
Merge pull request 'chore(deps): lock file maintenance' (#9) from renovate/lock-file-maintenance into main
Reviewed-on: #9
2025-06-25 05:19:17 +00:00
37b8a37d5f
chore(deps): lock file maintenance
All checks were successful
Label PRs based on size / Check PR size (pull_request) Successful in 20s
2025-06-25 00:05:20 +00:00
ecd055d3eb
Merge pull request 'chore(deps): lock file maintenance' (#8) from renovate/lock-file-maintenance into main
Reviewed-on: #8
2025-06-22 07:37:48 +00:00
7038897594
chore(deps): lock file maintenance
All checks were successful
Label PRs based on size / Check PR size (pull_request) Successful in 17s
2025-06-22 00:04:24 +00:00
c44822ffa3 chore(deps): lock file maintenance 2025-06-20 03:04:32 +00:00
3f6eab94c1
fix: Merge
Some checks failed
Release / Release (push) Failing after 28s
2025-06-19 17:23:47 +02:00
de3f5e697c
fix: fix init script 2025-06-19 17:20:25 +02:00
703db757bc
feat: Add folder execution
All checks were successful
Label PRs based on size / Check PR size (pull_request) Successful in 5s
2025-06-19 17:14:25 +02:00
50ecd8ce86
chore: Clean up imports
All checks were successful
Label PRs based on size / Check PR size (pull_request) Successful in 6s
2025-06-19 17:06:46 +02:00
618e00b677
feat: add version argument 2025-06-19 17:05:59 +02:00
semantic-release-bot
deb4eabbce chore(release): 0.3.3 [skip ci]
## [0.3.3](https://git.kjan.de/jank/project-cli/compare/v0.3.2...v0.3.3) (2025-06-19)

### Bug Fixes

* Fix wrong config ([1f0d3aa](1f0d3aa030))
2025-06-19 14:57:39 +00:00
1f0d3aa030
fix: Fix wrong config
All checks were successful
Release / Release (push) Successful in 33s
2025-06-19 16:56:51 +02:00
semantic-release-bot
f8f7ede4b9 chore(release): 0.3.2 [skip ci]
## [0.3.2](https://git.kjan.de/jank/project-cli/compare/v0.3.1...v0.3.2) (2025-06-19)

### Bug Fixes

* Remove stupid toml ([a38aedc](a38aedc248))
2025-06-19 14:16:59 +00:00
a38aedc248
fix: Remove stupid toml
All checks were successful
Release / Release (push) Successful in 33s
2025-06-19 16:16:17 +02:00
semantic-release-bot
e77e7fbac8 chore(release): 0.3.1 [skip ci]
## [0.3.1](https://git.kjan.de/jank/project-cli/compare/v0.3.0...v0.3.1) (2025-06-19)

### Bug Fixes

* Setup bun ([6a1b731](6a1b731730))
2025-06-19 14:12:37 +00:00
6a1b731730
fix: Setup bun
All checks were successful
Release / Release (push) Successful in 31s
2025-06-19 16:11:45 +02:00
semantic-release-bot
18a7d4e156 chore(release): 0.3.0 [skip ci]
## [0.3.0](https://git.kjan.de/jank/project-cli/compare/v0.2.2...v0.3.0) (2025-06-19)

### Features

* Add some compiling ([81ee09b](81ee09b42f))
2025-06-19 14:09:16 +00:00
69fa25bc1d
Merge pull request 'release' (#5) from main into release
Some checks failed
Release / Release (push) Failing after 28s
Reviewed-on: #5
2025-06-19 14:08:50 +00:00
81ee09b42f
feat: Add some compiling
All checks were successful
Label PRs based on size / Check PR size (pull_request) Successful in 5s
2025-06-19 16:07:10 +02:00
semantic-release-bot
93fc34ac15 chore(release): 0.2.2 [skip ci]
## [0.2.2](https://git.kjan.de/jank/project-cli/compare/v0.2.1...v0.2.2) (2025-06-19)

### Bug Fixes

* Fix releases ([8bfcadd](8bfcadd11f))
2025-06-19 12:15:47 +00:00
f238c9aae9
Merge pull request 'release' (#4) from main into release
All checks were successful
Release / Release (push) Successful in 27s
Reviewed-on: #4
2025-06-19 12:13:54 +00:00
8bfcadd11f
fix: Fix releases
All checks were successful
Label PRs based on size / Check PR size (pull_request) Successful in 5s
2025-06-19 14:13:29 +02:00
semantic-release-bot
9c9121500b chore(release): 0.2.1 [skip ci]
## [0.2.1](https://git.kjan.de/jank/project-cli/compare/v0.2.0...v0.2.1) (2025-06-19)

### Chores

* Add size pipeline ([8212b10](8212b10e25))
2025-06-19 12:11:12 +00:00
8212b10e25
chore: Add size pipeline
All checks were successful
Label PRs based on size / Check PR size (pull_request) Successful in 7s
Release / Release (push) Successful in 30s
2025-06-19 14:10:19 +02:00
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
10 changed files with 1519 additions and 58 deletions

19
.gitea/size.yml Normal file
View file

@ -0,0 +1,19 @@
buckets:
- maxSize: 80
label: size/small
comment: null
- maxSize: 200
label: size/medium
comment: null
- maxSize: 2000
label: size/large
comment: >
👮‍♀️⚠️ This is a friendly reminder that the diff size of this PR is bigger than
200 lines we aim for. Please consider splitting this PR into more digestible pieces!
- maxSize: Infinity
label: size/huge
comment: >
👮‍♀️🛑 This PR's diff size is quite huge.
Hopefully you know what you're doing.
If you did not commit a lot of autogenerated files intentionally,
there are few good reasons for this.

View file

@ -2,7 +2,7 @@ name: Release
on:
push:
branches:
- "main"
- "release"
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
@ -20,6 +20,9 @@ jobs:
pull-requests: write
id-token: write
steps:
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Create Release
uses: https://git.kjan.de/actions/semantic-release@v1.1.0
with:

17
.gitea/workflows/size.yml Normal file
View file

@ -0,0 +1,17 @@
name: Label PRs based on size
on: [pull_request]
jobs:
add_pr_size_label:
runs-on: ubuntu-latest
name: Check PR size
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Label and comment PR
uses: boschresearch/pr-size-labeler@v5.0.1
with:
bucketConfigFile: ".gitea/size.yml"

View file

@ -1,3 +1,45 @@
## [0.3.3](https://git.kjan.de/jank/project-cli/compare/v0.3.2...v0.3.3) (2025-06-19)
### Bug Fixes
* Fix wrong config ([1f0d3aa](https://git.kjan.de/jank/project-cli/commit/1f0d3aa030d462b7f1df1646b7b4431a8ef43d2c))
## [0.3.2](https://git.kjan.de/jank/project-cli/compare/v0.3.1...v0.3.2) (2025-06-19)
### Bug Fixes
* Remove stupid toml ([a38aedc](https://git.kjan.de/jank/project-cli/commit/a38aedc2481930a9bc5ac4454e5b0b4b6fff5104))
## [0.3.1](https://git.kjan.de/jank/project-cli/compare/v0.3.0...v0.3.1) (2025-06-19)
### Bug Fixes
* Setup bun ([6a1b731](https://git.kjan.de/jank/project-cli/commit/6a1b7317308fdeb2719c258f6c2b62463d81ca3a))
## [0.3.0](https://git.kjan.de/jank/project-cli/compare/v0.2.2...v0.3.0) (2025-06-19)
### Features
* Add some compiling ([81ee09b](https://git.kjan.de/jank/project-cli/commit/81ee09b42fafa5300e384a236602ee22f838da00))
## [0.2.2](https://git.kjan.de/jank/project-cli/compare/v0.2.1...v0.2.2) (2025-06-19)
### Bug Fixes
* Fix releases ([8bfcadd](https://git.kjan.de/jank/project-cli/commit/8bfcadd11f346645eb79027349b791d016ca2b0d))
## [0.2.1](https://git.kjan.de/jank/project-cli/compare/v0.2.0...v0.2.1) (2025-06-19)
### Chores
* Add size pipeline ([8212b10](https://git.kjan.de/jank/project-cli/commit/8212b10e2572e2e6e34775858391dc1fadb9686c))
## [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

1264
bun.lock

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,38 @@
import fs from "fs";
import os from "os";
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 JSON.parse(
fs.readFileSync(configPath + "config.json").toString(),
) 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 +41,17 @@ 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 configString = JSON.stringify(defaultConfig);
fs.writeFileSync(configPath + "config.json", configString);
const projects: Project[] = [];
saveProjects(projects);
}
function saveProjects(projects: Project[]) {
const projectsString = JSON.stringify(projects);
fs.writeFileSync(configPath + "projects.json", projectsString);
}

122
index.ts
View file

@ -1,23 +1,119 @@
#!/usr/bin/env node
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";
import { program } from "commander";
if (!fs.existsSync(configPath + "config.toml")) {
const createConfig = await confirm({
message: "No cofig has been found. Would you like to generate a new one?",
import packageJson from "./package.json";
export const VERSION = packageJson.version;
const CLI_NAME = "pcli";
program
.name("project-cli")
.description("A cli for managing projects")
.version(VERSION)
.action(async () => {
if (!fs.existsSync(configPath + "config.json")) {
const createConfig = await confirm({
message:
"No cofig has been found. Would you like to generate a new one?",
});
if (createConfig) {
generateDefaultConfig();
} else {
console.log(
"This project can not run without the config. Either create it yourself or generate the default.",
);
exit(1);
}
}
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);
}
}
const pickedProject = await select({
message: "Which Project would you like to go to?",
choices: getProjects().map((project: Project) => project.name),
});
console.log(
"__EXEC__ cd " +
getConfiguration().projectsDirectory +
"/" +
pickedProject,
);
console.log(getProjects());
});
if (createConfig) {
generateDefaultConfig();
} else {
console.log(
"This project can not run without the config. Either create it yourself or generate the default.",
);
exit(1);
}
}
program.command("init").action(() => {
console.log(`${CLI_NAME}() {
command ${CLI_NAME} "$@" | while IFS= read -r line; do
if [[ $line == __EXEC__* ]]; then
eval "\${line#__EXEC__}"
else
echo "$line"
fi
done
}`);
});
program.parse();

48
package-lock.json generated
View file

@ -1,18 +1,17 @@
{
"name": "proj-cli",
"version": "0.1.1",
"version": "0.3.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "proj-cli",
"version": "0.1.1",
"version": "0.3.3",
"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",
@ -21,6 +20,9 @@
"inquirer": "^12.6.3",
"semantic-release": "^24.2.5"
},
"bin": {
"pcli": "dist/index.js"
},
"devDependencies": {
"@types/bun": "latest"
},
@ -490,11 +492,6 @@
}
}
},
"node_modules/@jsr/std__collections": {
"version": "1.1.1",
"resolved": "https://npm.jsr.io/~/11/@jsr/std__collections/1.1.1.tgz",
"integrity": "sha512-bS4Y5f80IUeDUf+0BgVVWValgBeGcJ/UwFYTC5PBIJtrFqwEmU8IohDBwFLJILyUtiAB1jbJewl0K+REEQ9kQQ=="
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -639,9 +636,9 @@
}
},
"node_modules/@octokit/request": {
"version": "10.0.2",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.2.tgz",
"integrity": "sha512-iYj4SJG/2bbhh+iIpFmG5u49DtJ4lipQ+aPakjL9OKpsGY93wM8w06gvFbEQxcMsZcCvk5th5KkIm2m8o14aWA==",
"version": "10.0.3",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.3.tgz",
"integrity": "sha512-V6jhKokg35vk098iBqp2FBKunk3kMTXlmq+PtbV9Gl3TfskWlebSofU9uunVKhUN7xl+0+i5vt0TGTG8/p/7HA==",
"license": "MIT",
"dependencies": {
"@octokit/endpoint": "^11.0.0",
@ -1388,15 +1385,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@std/toml": {
"name": "@jsr/std__toml",
"version": "1.0.8",
"resolved": "https://npm.jsr.io/~/11/@jsr/std__toml/1.0.8.tgz",
"integrity": "sha512-rnMoiySl30TrsdnfKcroYEWIBlmPvdNoA8fn/Njy3rsZR9C8k5nUeo9kWP/D/PhxYlUaYPtmQ31YhNqGpmEZ3Q==",
"dependencies": {
"@jsr/std__collections": "^1.1.1"
}
},
"node_modules/@szmarczak/http-timer": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz",
@ -1410,13 +1398,13 @@
}
},
"node_modules/@types/bun": {
"version": "1.2.16",
"resolved": "https://registry.npmjs.org/@types/bun/-/bun-1.2.16.tgz",
"integrity": "sha512-1aCZJ/6nSiViw339RsaNhkNoEloLaPzZhxMOYEa7OzRzO41IGg5n/7I43/ZIAW/c+Q6cT12Vf7fOZOoVIzb5BQ==",
"version": "1.2.17",
"resolved": "https://registry.npmjs.org/@types/bun/-/bun-1.2.17.tgz",
"integrity": "sha512-l/BYs/JYt+cXA/0+wUhulYJB6a6p//GTPiJ7nV+QHa8iiId4HZmnu/3J/SowP5g0rTiERY2kfGKXEK5Ehltx4Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"bun-types": "1.2.16"
"bun-types": "1.2.17"
}
},
"node_modules/@types/cacheable-request": {
@ -1493,9 +1481,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "24.0.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.3.tgz",
"integrity": "sha512-R4I/kzCYAdRLzfiCabn9hxWfbuHS573x+r0dJMkkzThEa7pbrcDWK+9zu3e7aBOouf+rQAciqPFMnxwr0aWgKg==",
"version": "24.0.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.4.tgz",
"integrity": "sha512-ulyqAkrhnuNq9pB76DRBTkcS6YsmDALy6Ua63V8OhrOBgbcYt6IOdzpw5P1+dyRIyMerzLkeYWBeOXPpA9GMAA==",
"license": "MIT",
"dependencies": {
"undici-types": "~7.8.0"
@ -1681,9 +1669,9 @@
}
},
"node_modules/bun-types": {
"version": "1.2.16",
"resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.2.16.tgz",
"integrity": "sha512-ciXLrHV4PXax9vHvUrkvun9VPVGOVwbbbBF/Ev1cXz12lyEZMoJpIJABOfPcN9gDJRaiKF9MVbSygLg4NXu3/A==",
"version": "1.2.17",
"resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.2.17.tgz",
"integrity": "sha512-ElC7ItwT3SCQwYZDYoAH+q6KT4Fxjl8DtZ6qDulUFBmXA8YB4xo+l54J9ZJN+k2pphfn9vk7kfubeSd5QfTVJQ==",
"dev": true,
"license": "MIT",
"dependencies": {

View file

@ -1,8 +1,19 @@
{
"name": "proj-cli",
"version": "0.1.1",
"version": "0.3.3",
"module": "index.ts",
"type": "module",
"bin": {
"pcli": "./dist/index.js"
},
"scripts": {
"build": "bun build index.ts --outfile dist/index.js --target node",
"dev": "bun run index.ts",
"prepublishOnly": "bun run build"
},
"files": [
"dist/"
],
"devDependencies": {
"@types/bun": "latest"
},
@ -14,7 +25,6 @@
"@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",

View file

@ -1,5 +1,5 @@
module.exports = {
branches: ["main"],
branches: ["release"],
plugins: [
[
"@semantic-release/commit-analyzer",