milodb 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +3 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milodb",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "src/milodb.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/src/cli.js CHANGED
@@ -2,25 +2,20 @@
2
2
 
3
3
  const path = require('path');
4
4
  const fs = require('fs-extra');
5
- const MiloDB = require('./src/milodb');
5
+ const MiloDB = require(path.join(__dirname, 'milodb')); // Use path.join to correctly reference the file
6
6
 
7
7
  // Function to initialize the database
8
8
  async function initDatabase() {
9
- const dbPath = path.join(process.cwd(), 'src/db'); // Set the path where the database will be stored
9
+ const dbPath = path.join(process.cwd(), 'db'); // Set the path where the database will be stored in the host project
10
10
 
11
11
  try {
12
12
  // Create a new instance of MiloDB
13
13
  const db = new MiloDB(dbPath, false); // Default to no encryption
14
14
 
15
15
  // Ensure the database folder exists
16
- fs.ensureDirSync(dbPath);
16
+ await fs.ensureDir(dbPath);
17
17
 
18
18
  console.log(`Database initialized at: ${dbPath}`);
19
-
20
- // Optionally, you could create a default table
21
- // await db.createTable('users');
22
- // console.log('Default "users" table created.');
23
-
24
19
  } catch (error) {
25
20
  console.error('Error initializing database:', error.message);
26
21
  process.exit(1);