Compare commits

...

3 commits

Author SHA1 Message Date
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
4 changed files with 123 additions and 59 deletions

View file

@ -1,3 +1,9 @@
## [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) ## [0.2.2](https://git.kjan.de/jank/project-cli/compare/v0.2.1...v0.2.2) (2025-06-19)
### Bug Fixes ### Bug Fixes

156
index.ts
View file

@ -1,3 +1,5 @@
#!/usr/bin/env node
import fs from "fs"; import fs from "fs";
import { confirm, select, input } from "@inquirer/prompts"; import { confirm, select, input } from "@inquirer/prompts";
import { exit } from "process"; import { exit } from "process";
@ -10,66 +12,108 @@ import {
type Project, type Project,
} from "./configuration/configuration"; } from "./configuration/configuration";
import { execSync } from "child_process"; import { execSync } from "child_process";
import { program } from "commander";
if (!fs.existsSync(configPath + "config.toml")) { const CLI_NAME = "pcli";
const createConfig = await confirm({
message: "No cofig has been found. Would you like to generate a new one?",
});
if (createConfig) { program
generateDefaultConfig(); .name("project-cli")
} else { .description("A cli for managing projects")
console.log( .action(async () => {
"This project can not run without the config. Either create it yourself or generate the default.", if (!fs.existsSync(configPath + "config.toml")) {
); const createConfig = await confirm({
exit(1); message:
} "No cofig has been found. Would you like to generate a new one?",
}
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?",
}); });
if (createConfig) {
generateDefaultConfig();
} else {
console.log(
"This project can not run without the config. Either create it yourself or generate the default.",
);
exit(1);
}
} }
execSync( if (
"cd " + !getProjects() ||
getConfiguration().projectsDirectory + getProjects().length == 0 ||
" && " + getProjects().length == undefined
getConfiguration() ) {
.cloningCommand.replace("%s", repoUrl) const anwser = await select({
.replace("%n", customName), 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?",
});
}
const newProject: Project = { execSync(
name: customName, "cd " +
}; getConfiguration().projectsDirectory +
addProject(newProject); " && " +
} else if (anwser == "Create a new empty Project") { getConfiguration()
const name = await input({ .cloningCommand.replace("%s", repoUrl)
message: "What would you like to call the project?", .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),
}); });
fs.mkdirSync(getConfiguration().projectsDirectory + "/" + name);
const newProject: Project = { process.chdir(getConfiguration().projectsDirectory + "/" + pickedProject);
name: name,
}; console.log(getProjects());
addProject(newProject); });
}
} program.command("init").action(() => {
console.log(getProjects()); console.log(`${CLI_NAME}() {
local output
output=$(command ${CLI_NAME} "$@")
local exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "$output" | while IFS= read -r line; do
if [[ $line == __EXEC__* ]]; then
eval "\${line#__EXEC__}"
else
echo "$line"
fi
done
else
echo "$output" >&2
return $exit_code
fi
}`);
});
program.parse();

7
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "proj-cli", "name": "proj-cli",
"version": "0.2.2", "version": "0.3.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "proj-cli", "name": "proj-cli",
"version": "0.2.2", "version": "0.3.0",
"dependencies": { "dependencies": {
"@saithodev/semantic-release-gitea": "^2.1.0", "@saithodev/semantic-release-gitea": "^2.1.0",
"@semantic-release/changelog": "^6.0.3", "@semantic-release/changelog": "^6.0.3",
@ -21,6 +21,9 @@
"inquirer": "^12.6.3", "inquirer": "^12.6.3",
"semantic-release": "^24.2.5" "semantic-release": "^24.2.5"
}, },
"bin": {
"pcli": "dist/index.js"
},
"devDependencies": { "devDependencies": {
"@types/bun": "latest" "@types/bun": "latest"
}, },

View file

@ -1,8 +1,19 @@
{ {
"name": "proj-cli", "name": "proj-cli",
"version": "0.2.2", "version": "0.3.0",
"module": "index.ts", "module": "index.ts",
"type": "module", "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": { "devDependencies": {
"@types/bun": "latest" "@types/bun": "latest"
}, },