Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#269 - charybdis database uploading #270

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
188 changes: 188 additions & 0 deletions charybdis/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions charybdis/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "cli",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "npx tsx src/index.ts --",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@types/figlet": "^1.7.0",
"@types/node": "^22.10.10",
"typescript": "^5.7.3"
},
"type": "module",
"dependencies": {
"@types/axios": "^0.9.36",
"axios": "^1.7.9",
"commander": "^13.1.0",
"figlet": "^1.8.0"
}
}
58 changes: 58 additions & 0 deletions charybdis/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env node

import { Command } from "commander";
import figlet from "figlet";
import axios from "axios";

const program = new Command();
const SERVER_URL = "http://localhost:3000"; // Update this with your server's address

console.log(figlet.textSync("Charybdis CLI"));

program
.version("1.0.0")
.description(
"A CLI for managing database uploading and downloading for Argos"
);

// Command to download (dump) data
program
.command("dump-dev")
.description("Download data from the cloud database into local CSVs")
.action(async () => {
try {
console.log(`Downloading data to...`);
const response = await axios.put(`${SERVER_URL}/dump`);

if (response.status === 200) {
console.log("Data successfully dumped");
} else {
console.error("Error occurred during dump:", response.statusText);
}
} catch (error) {
console.error("Failed to dump data:", error);
}
});

// Command to upload data
program
.command("upload-dev")
.description("Upload data from local CSVs into the cloud database")
.action(async (inputPath) => {
try {
console.log(`Uploading data from...`);
const response = await axios.put(`${SERVER_URL}/upload`, {
inputPath,
});

if (response.status === 200) {
console.log("Data successfully uploaded from:", inputPath);
} else {
console.error("Error occurred during upload:", response.statusText);
}
} catch (error) {
console.error("Failed to upload data:", error);
}
});

program.parse(process.argv);
4 changes: 3 additions & 1 deletion charybdis/cloud-prisma/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PrismaClient } from "./cloud-prisma-client";

export const prisma = new PrismaClient();
export const prisma = new PrismaClient();

export { PrismaClient };
4 changes: 3 additions & 1 deletion charybdis/local-prisma/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PrismaClient } from "./local-prisma-client";

export const prisma = new PrismaClient();
export const prisma = new PrismaClient();

export { PrismaClient };
Loading
Loading