Compare commits
No commits in common. "69fa25bc1dfc0a6c70734b44f828927bea0ab486" and "93fc34ac15889f122b51264bc749e042a7f91fc8" have entirely different histories.
69fa25bc1d
...
93fc34ac15
2 changed files with 59 additions and 114 deletions
60
index.ts
60
index.ts
|
@ -1,5 +1,3 @@
|
||||||
#!/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";
|
||||||
|
@ -12,18 +10,10 @@ 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";
|
|
||||||
|
|
||||||
const CLI_NAME = "pcli";
|
if (!fs.existsSync(configPath + "config.toml")) {
|
||||||
|
|
||||||
program
|
|
||||||
.name("project-cli")
|
|
||||||
.description("A cli for managing projects")
|
|
||||||
.action(async () => {
|
|
||||||
if (!fs.existsSync(configPath + "config.toml")) {
|
|
||||||
const createConfig = await confirm({
|
const createConfig = await confirm({
|
||||||
message:
|
message: "No cofig has been found. Would you like to generate a new one?",
|
||||||
"No cofig has been found. Would you like to generate a new one?",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (createConfig) {
|
if (createConfig) {
|
||||||
|
@ -34,21 +24,19 @@ program
|
||||||
);
|
);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!getProjects() ||
|
!getProjects() ||
|
||||||
getProjects().length == 0 ||
|
getProjects().length == 0 ||
|
||||||
getProjects().length == undefined
|
getProjects().length == undefined
|
||||||
) {
|
) {
|
||||||
const anwser = await select({
|
const anwser = await select({
|
||||||
message: "Create a new Project",
|
message: "Create a new Project",
|
||||||
choices: ["Clone a project with git", "Create a new empty Project"],
|
choices: ["Clone a project with git", "Create a new empty Project"],
|
||||||
});
|
});
|
||||||
if (anwser == "Clone a project with git") {
|
if (anwser == "Clone a project with git") {
|
||||||
const repoUrl = await input({
|
const repoUrl = await input({ message: "What is the url of the repo?" });
|
||||||
message: "What is the url of the repo?",
|
|
||||||
});
|
|
||||||
const wantsCustomName = await confirm({
|
const wantsCustomName = await confirm({
|
||||||
message: "Would you like to give this project a custom name?",
|
message: "Would you like to give this project a custom name?",
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -83,37 +71,5 @@ program
|
||||||
};
|
};
|
||||||
addProject(newProject);
|
addProject(newProject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(getProjects());
|
||||||
const pickedProject = await select({
|
|
||||||
message: "Which Project would you like to go to?",
|
|
||||||
choices: getProjects().map((project: Project) => project.name),
|
|
||||||
});
|
|
||||||
|
|
||||||
process.chdir(getConfiguration().projectsDirectory + "/" + pickedProject);
|
|
||||||
|
|
||||||
console.log(getProjects());
|
|
||||||
});
|
|
||||||
|
|
||||||
program.command("init").action(() => {
|
|
||||||
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();
|
|
||||||
|
|
11
package.json
11
package.json
|
@ -3,17 +3,6 @@
|
||||||
"version": "0.2.2",
|
"version": "0.2.2",
|
||||||
"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"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue