oopsdb 1.1.0 → 1.2.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.
@@ -43,9 +43,15 @@ exports.getEncryptionKey = getEncryptionKey;
43
43
  const fs = __importStar(require("fs"));
44
44
  const path = __importStar(require("path"));
45
45
  const crypto = __importStar(require("crypto"));
46
- const CONFIG_DIR = path.join(process.cwd(), '.oopsdb');
47
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
48
- const BACKUPS_DIR = path.join(CONFIG_DIR, 'backups');
46
+ function getConfigDirPath() {
47
+ return path.join(process.cwd(), '.oopsdb');
48
+ }
49
+ function getConfigFilePath() {
50
+ return path.join(getConfigDirPath(), 'config.json');
51
+ }
52
+ function getBackupsDirPath() {
53
+ return path.join(getConfigDirPath(), 'backups');
54
+ }
49
55
  // We encrypt the config file itself using a static machine-local key so that
50
56
  // rogue processes can't easily read the master key in plain text from the file system.
51
57
  // Note: This machineKey is NOT used for the database backups, only the config.json.
@@ -70,16 +76,16 @@ function decryptConfig(text) {
70
76
  }
71
77
  function ensureConfigDir() {
72
78
  try {
73
- if (!fs.existsSync(CONFIG_DIR)) {
74
- fs.mkdirSync(CONFIG_DIR, { recursive: true });
79
+ if (!fs.existsSync(getConfigDirPath())) {
80
+ fs.mkdirSync(getConfigDirPath(), { recursive: true });
75
81
  }
76
- if (!fs.existsSync(BACKUPS_DIR)) {
77
- fs.mkdirSync(BACKUPS_DIR, { recursive: true });
82
+ if (!fs.existsSync(getBackupsDirPath())) {
83
+ fs.mkdirSync(getBackupsDirPath(), { recursive: true });
78
84
  }
79
85
  }
80
86
  catch (err) {
81
87
  if (err.code === 'EACCES') {
82
- throw new Error(`Permission denied creating ${CONFIG_DIR}. Check directory permissions.`);
88
+ throw new Error(`Permission denied creating ${getConfigDirPath()}. Check directory permissions.`);
83
89
  }
84
90
  if (err.code === 'ENOSPC') {
85
91
  throw new Error('Disk full. Free up space and try again.');
@@ -90,14 +96,14 @@ function ensureConfigDir() {
90
96
  function saveConfig(config) {
91
97
  ensureConfigDir();
92
98
  const encrypted = encryptConfig(JSON.stringify(config));
93
- fs.writeFileSync(CONFIG_FILE, encrypted, 'utf8');
99
+ fs.writeFileSync(getConfigFilePath(), encrypted, 'utf8');
94
100
  }
95
101
  function loadConfig() {
96
- if (!fs.existsSync(CONFIG_FILE)) {
102
+ if (!fs.existsSync(getConfigFilePath())) {
97
103
  return null;
98
104
  }
99
105
  try {
100
- const encrypted = fs.readFileSync(CONFIG_FILE, 'utf8');
106
+ const encrypted = fs.readFileSync(getConfigFilePath(), 'utf8');
101
107
  const decrypted = decryptConfig(encrypted);
102
108
  return JSON.parse(decrypted);
103
109
  }
@@ -107,10 +113,10 @@ function loadConfig() {
107
113
  }
108
114
  function getBackupsDir() {
109
115
  ensureConfigDir();
110
- return BACKUPS_DIR;
116
+ return getBackupsDirPath();
111
117
  }
112
118
  function getConfigDir() {
113
- return CONFIG_DIR;
119
+ return getConfigDirPath();
114
120
  }
115
121
  function generateMasterKey() {
116
122
  return crypto.randomBytes(32).toString('hex');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oopsdb",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Don't let AI nuke your database. Auto-backup and 1-click restore for developers using Claude Code, Cursor, Windsurf, and other AI coding agents.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {