create-verse.db
Advanced tools
Comparing version 0.0.3 to 0.0.4
100
index.js
#!/usr/bin/env node | ||
const inquirer = require("inquirer"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { logSuccess, logError, logInfo } = require("../dist/core/logger"); | ||
inquirer | ||
.prompt([ | ||
{ | ||
type: "input", | ||
name: "connectionName", | ||
message: "What is the database connection name?", | ||
validate: function (input) { | ||
const regex = /\s/; | ||
if (regex.test(input)) { | ||
return "Please enter a name without spaces."; | ||
} | ||
return true; | ||
}, | ||
}, | ||
{ | ||
type: "list", | ||
name: "adapter", | ||
message: "What is the database Adapter?", | ||
choices: ["JSON", "YAML", "SQL"], | ||
}, | ||
{ | ||
type: "input", | ||
name: "dataPath", | ||
message: "What is the database dataPath?", | ||
default() { | ||
return "./Data"; | ||
}, | ||
}, | ||
{ | ||
type: "confirm", | ||
name: "devLogs_enable", | ||
message: "Do you want to enable devLogs?", | ||
default() { | ||
return false; | ||
}, | ||
}, | ||
{ | ||
type: "input", | ||
name: "devLogs_path", | ||
message: "devLogs path:", | ||
when: function (answers) { | ||
return answers.devLogs_enable; | ||
}, | ||
}, | ||
{ | ||
type: "password", | ||
name: "secret", | ||
message: "Enter Encrption Secret:", | ||
mask: "*", | ||
default() { | ||
return "versedb"; | ||
}, | ||
}, | ||
]) | ||
.then(async (answers) => { | ||
const configContent = { | ||
[answers.connectionName]: { | ||
adapter: answers.adapter, | ||
dataPath: answers.dataPath, | ||
devLogs: { | ||
enable: answers.devLogs_enable, | ||
path: answers.devLogs_path, | ||
}, | ||
encryption: { | ||
secret: answers.secret, | ||
}, | ||
}, | ||
}; | ||
const dataPath = path.join(answers.dataPath, `connection.json`); | ||
try { | ||
fs.writeFileSync(dataPath, JSON.stringify(configContent)); | ||
} catch (error) { | ||
if (error.code === "ENOENT") { | ||
fs.mkdirSync(answers.dataPath, { recursive: true }); | ||
fs.writeFileSync(dataPath, JSON.stringify(configContent)); | ||
} | ||
} | ||
logSuccess({ | ||
content: "Database connection setup successfully.\n", | ||
}); | ||
logInfo({ | ||
content: "Install verse.db package using.\n", | ||
}); | ||
logInfo({ | ||
content: "npm install verse.db.\n", | ||
}); | ||
}); |
{ | ||
"name": "create-verse.db", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "verse.db isn't just a database, it's your universal data bridge. Designed for unmatched flexibility, security, and performance, verse.db empowers you to manage your data with ease.", | ||
@@ -28,3 +28,3 @@ "license": "MIT", | ||
"bin": { | ||
"create-verse-db": "./index.js" | ||
"create-verse-db": "./bin/cli.js" | ||
}, | ||
@@ -31,0 +31,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7