@voidwalkers/void-cli
Advanced tools
Comparing version 0.1.8 to 0.1.9
{ | ||
"name": "@voidwalkers/void-cli", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "CLI for Void Walkers Void", | ||
@@ -5,0 +5,0 @@ "main": "./src/app.js", |
@@ -54,3 +54,3 @@ import fs from 'node:fs'; | ||
process.exit(0); | ||
return; | ||
} | ||
@@ -95,3 +95,3 @@ } | ||
process.exit(0); | ||
return; | ||
} | ||
@@ -120,3 +120,3 @@ | ||
process.exit(0); | ||
return; | ||
} | ||
@@ -192,3 +192,3 @@ | ||
process.exit(0); | ||
return; | ||
} | ||
@@ -195,0 +195,0 @@ |
import {Command} from 'commander'; | ||
import {deploy as deployFunctions} from '#src/lib/deploy/functions.js'; | ||
import {deploy as deployWebsites} from '#src/lib/deploy/websites.js'; | ||
import {deploy as deployFunctions} from '#src/lib/components/functions.js'; | ||
import {deploy as deployWebsites} from '#src/lib/components/websites.js'; | ||
@@ -6,0 +6,0 @@ const command = new Command('deploy'); |
@@ -5,7 +5,7 @@ import fs from 'node:fs'; | ||
import {init as initFunctions} from '#src/lib/components/functions.js'; | ||
import {init as initMongo} from '#src/lib/components/mongo.js'; | ||
import {init as initWebsites} from '#src/lib/components/websites.js'; | ||
import {PATH_CONFIG, PATH_FUNCTIONS, PATH_WEBSITES} from '#src/lib/constants.js'; | ||
import {loadConfig} from '#src/lib/helper.js'; | ||
import {init as initFunctions} from '#src/lib/init/functions.js'; | ||
import {init as initMongo} from '#src/lib/init/mongo.js'; | ||
import {init as initWebsites} from '#src/lib/init/websites.js'; | ||
@@ -39,3 +39,3 @@ const command = new Command('enable'); | ||
process.exit(0); | ||
return; | ||
} | ||
@@ -42,0 +42,0 @@ |
@@ -6,7 +6,7 @@ import fs from 'node:fs'; | ||
import {init as initFunctions} from '#src/lib/components/functions.js'; | ||
import {init as initMongo} from '#src/lib/components/mongo.js'; | ||
import {init as initWebsites} from '#src/lib/components/websites.js'; | ||
import {PATH_CONFIG, PATH_FUNCTIONS, PATH_WEBSITES, RX_BASE64} from '#src/lib/constants.js'; | ||
import {loadConfig} from '#src/lib/helper.js'; | ||
import {init as initFunctions} from '#src/lib/init/functions.js'; | ||
import {init as initMongo} from '#src/lib/init/mongo.js'; | ||
import {init as initWebsites} from '#src/lib/init/websites.js'; | ||
@@ -13,0 +13,0 @@ function createConfig(slug, tokenPrivate, tokenPublic) { |
import {Argument, Command} from 'commander'; | ||
import { | ||
createDatabase as createMongoDatabase, | ||
dropDatabase as dropMongoDatabase | ||
} from '#src/lib/components/mongo.js'; | ||
import {loadConfig} from '#src/lib/helper.js'; | ||
@@ -20,11 +24,23 @@ | ||
) | ||
.option('-d, --database <name>', 'Pretty formatted to use in JS code') | ||
.option('-p, --pretty', 'Pretty formatted to use in JS code') | ||
.action((mode, {pretty}) => { | ||
.action((mode, {database, pretty}) => { | ||
const config = loadConfig(); | ||
// TODO: Select db | ||
if (!database) { | ||
database = 'default'; | ||
} | ||
database = config.project.mongo.databases.find(({name}) => name === database); | ||
if (!database) { | ||
console.log('Database not found'); | ||
process.exit(1); | ||
} | ||
const host = 'mongo-svc.void.svc.cluster.local'; | ||
const userName = `user-${config.project.slug}`; // TODO: Length | ||
const password = encodeURIComponent(config.project.mongo.databases.find(({name}) => name === 'default').password); | ||
const databaseName = `project-${config.project.slug}-default`; // TODO: Length | ||
const userName = `user-${config.project.slug}`; | ||
const password = encodeURIComponent(database.password); | ||
const databaseName = `project-${config.project.slug}-${database.name}`; | ||
@@ -54,4 +70,39 @@ switch (mode) { | ||
const commandDatabase = new Command('database'); | ||
commandDatabase.description('Manage MongoDB databases'); | ||
commandDatabase.command('create') | ||
.description('Create MongoDB database') | ||
.argument('<name>', 'Database name') | ||
.action(async databaseName => { | ||
const config = loadConfig(); | ||
if (config.project.mongo?.databases.some(({name}) => name === databaseName)) { | ||
console.log(`Database "${databaseName}" already exists`); | ||
return; | ||
} | ||
await createMongoDatabase(config.project.slug, databaseName); | ||
}); | ||
commandDatabase.command('drop') | ||
.description('Drop MongoDB database') | ||
.argument('<name>', 'Database name') | ||
.action(async databaseName => { | ||
const config = loadConfig(); | ||
if (!config.project.mongo?.databases.some(({name}) => name === databaseName)) { | ||
console.log(`Database "${databaseName}" does not exist`); | ||
return; | ||
} | ||
await dropMongoDatabase(config.project.slug, databaseName); | ||
}); | ||
command.addCommand(commandCredentials); | ||
command.addCommand(commandDatabase); | ||
export default command; |
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
32875
904
15