@aperdomoll90/ledger-ai 1.0.1 → 1.0.2
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/dist/commands/init.js +13 -6
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -74,20 +74,27 @@ To create a Supabase project:
|
|
|
74
74
|
};
|
|
75
75
|
writeFileSync(configPath, JSON.stringify(merged, null, 2) + '\n');
|
|
76
76
|
console.error('Config saved to ~/.ledger/config.json\n');
|
|
77
|
-
// Step 4: Verify Supabase connection
|
|
77
|
+
// Step 4: Verify Supabase connection by checking for notes table
|
|
78
78
|
console.error('Connecting to Supabase...');
|
|
79
79
|
const supabase = createClient(supabaseUrl, supabaseKey);
|
|
80
80
|
const { error: connError } = await supabase
|
|
81
|
-
.from('
|
|
82
|
-
.select('
|
|
81
|
+
.from('notes')
|
|
82
|
+
.select('id')
|
|
83
83
|
.limit(1);
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
// If notes table doesn't exist, it's a new database
|
|
85
|
+
const isNew = connError !== null;
|
|
86
|
+
if (isNew && !connError.message.includes('notes')) {
|
|
87
|
+
// Connection-level error (bad URL, bad key), not just missing table
|
|
86
88
|
console.error(`Connection error: ${connError.message}`);
|
|
87
89
|
console.error('Check your Supabase URL and service role key.');
|
|
88
90
|
process.exit(1);
|
|
89
91
|
}
|
|
90
|
-
|
|
92
|
+
if (isNew) {
|
|
93
|
+
console.error('Connected (new database).\n');
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.error('Connected.\n');
|
|
97
|
+
}
|
|
91
98
|
// Step 5: Validate OpenAI key
|
|
92
99
|
console.error('Validating OpenAI key...');
|
|
93
100
|
try {
|
package/package.json
CHANGED