@lxgicstudios/ai-backup-script 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # ai-backup-script
2
+
3
+ Generate database backup scripts with AI
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g ai-backup-script
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ npx ai-backup-script "PostgreSQL daily to S3"
15
+ npx ai-backup-script "MongoDB hourly to GCS"
16
+ npx ai-backup-script "MySQL weekly to local with rotation"
17
+ ```
18
+
19
+ ## Setup
20
+
21
+ ```bash
22
+ export OPENAI_API_KEY=sk-...
23
+ ```
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@lxgicstudios/ai-backup-script",
3
+ "version": "1.0.0",
4
+ "description": "Generate database backup scripts with AI",
5
+ "main": "dist/index.js",
6
+ "bin": { "ai-backup-script": "dist/cli.js" },
7
+ "scripts": { "build": "tsc" },
8
+ "keywords": ["ai", "cli", "developer-tools", "npx", "nodejs", "openai"],
9
+ "license": "MIT",
10
+ "dependencies": { "commander": "^12.1.0", "openai": "^4.73.0", "ora": "^5.4.1" },
11
+ "devDependencies": { "typescript": "^5.6.0", "@types/node": "^22.0.0" },
12
+ "author": "LXGIC Studios",
13
+ "repository": { "type": "git", "url": "https://github.com/LXGIC-Studios/ai-backup-script" }
14
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from "commander";
4
+ import ora from "ora";
5
+ import { generate } from "./index";
6
+
7
+ const program = new Command();
8
+
9
+ program
10
+ .name("ai-backup-script")
11
+ .description("Generate database backup scripts with AI")
12
+ .version("1.0.0")
13
+ .argument("<spec>", "Backup specification (database, schedule, destination)")
14
+ .action(async (spec: string) => {
15
+ const spinner = ora("Generating...").start();
16
+ try {
17
+ const result = await generate(spec);
18
+ spinner.succeed("Done:\n");
19
+ console.log(result);
20
+ } catch (err: any) {
21
+ spinner.fail(`Error: ${err.message}`);
22
+ process.exit(1);
23
+ }
24
+ });
25
+
26
+ program.parse();
package/src/index.ts ADDED
@@ -0,0 +1,18 @@
1
+ import OpenAI from "openai";
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+
5
+ const openai = new OpenAI();
6
+
7
+ export async function generate(input: string): Promise<string> {
8
+ const userContent = `Generate a backup script for: ${input}`;
9
+ const response = await openai.chat.completions.create({
10
+ model: "gpt-4o-mini",
11
+ messages: [
12
+ { role: "system", content: `You are a DevOps expert specializing in database backups. Generate a production-ready backup script. Include: the backup command, compression, encryption option, rotation policy, error handling, logging, and restore instructions. Use bash by default. Add cron schedule suggestion.` },
13
+ { role: "user", content: userContent }
14
+ ],
15
+ temperature: 0.7,
16
+ });
17
+ return response.choices[0].message.content || "";
18
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "outDir": "dist",
6
+ "rootDir": "src",
7
+ "esModuleInterop": true,
8
+ "strict": true,
9
+ "resolveJsonModule": true,
10
+ "declaration": true
11
+ },
12
+ "include": ["src"]
13
+ }