fauna-shell
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "fauna-shell", | ||
"description": "faunadb shell", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "Alvaro Videla", | ||
@@ -6,0 +6,0 @@ "bin": { |
@@ -38,3 +38,8 @@ fauna-shell | ||
``` | ||
You can override the value set in that file via the `FAUNA_SECRET_KEY` environment variable like this: | ||
```sh-session | ||
export FAUNA_SECRET_KEY=YOUR_FAUNADB_KEY | ||
``` | ||
The `fauna` tool will read our key from that file and then use it to authenticate against the [FaunaDB Cloud](https://dashboard.fauna.com/). | ||
@@ -291,2 +296,8 @@ | ||
OPTIONS | ||
--domain=domain [default: db.fauna.com] FaunaDB server domain | ||
--port=port [default: 443] Connection port | ||
--scheme=https|http [default: https] Connection scheme. | ||
--timeout=timeout [default: 80] Connection timeout in milliseconds | ||
DESCRIPTION | ||
@@ -300,3 +311,3 @@ Creates a database | ||
_See code: [src/commands/create-database.js](https://github.com/fauna/fauna-shell/blob/v0.0.3/src/commands/create-database.js)_ | ||
_See code: [src/commands/create-database.js](https://github.com/fauna/fauna-shell/blob/v0.0.4/src/commands/create-database.js)_ | ||
@@ -315,2 +326,8 @@ ## `fauna create-key DBNAME [ROLE]` | ||
OPTIONS | ||
--domain=domain [default: db.fauna.com] FaunaDB server domain | ||
--port=port [default: 443] Connection port | ||
--scheme=https|http [default: https] Connection scheme. | ||
--timeout=timeout [default: 80] Connection timeout in milliseconds | ||
DESCRIPTION | ||
@@ -324,3 +341,3 @@ Creates a key for the specified database | ||
_See code: [src/commands/create-key.js](https://github.com/fauna/fauna-shell/blob/v0.0.3/src/commands/create-key.js)_ | ||
_See code: [src/commands/create-key.js](https://github.com/fauna/fauna-shell/blob/v0.0.4/src/commands/create-key.js)_ | ||
@@ -338,2 +355,8 @@ ## `fauna delete-database DBNAME` | ||
OPTIONS | ||
--domain=domain [default: db.fauna.com] FaunaDB server domain | ||
--port=port [default: 443] Connection port | ||
--scheme=https|http [default: https] Connection scheme. | ||
--timeout=timeout [default: 80] Connection timeout in milliseconds | ||
DESCRIPTION | ||
@@ -347,3 +370,3 @@ Deletes a database | ||
_See code: [src/commands/delete-database.js](https://github.com/fauna/fauna-shell/blob/v0.0.3/src/commands/delete-database.js)_ | ||
_See code: [src/commands/delete-database.js](https://github.com/fauna/fauna-shell/blob/v0.0.4/src/commands/delete-database.js)_ | ||
@@ -361,2 +384,8 @@ ## `fauna delete-key KEYNAME` | ||
OPTIONS | ||
--domain=domain [default: db.fauna.com] FaunaDB server domain | ||
--port=port [default: 443] Connection port | ||
--scheme=https|http [default: https] Connection scheme. | ||
--timeout=timeout [default: 80] Connection timeout in milliseconds | ||
DESCRIPTION | ||
@@ -370,3 +399,3 @@ Deletes a key | ||
_See code: [src/commands/delete-key.js](https://github.com/fauna/fauna-shell/blob/v0.0.3/src/commands/delete-key.js)_ | ||
_See code: [src/commands/delete-key.js](https://github.com/fauna/fauna-shell/blob/v0.0.4/src/commands/delete-key.js)_ | ||
@@ -398,2 +427,8 @@ ## `fauna help [COMMAND]` | ||
OPTIONS | ||
--domain=domain [default: db.fauna.com] FaunaDB server domain | ||
--port=port [default: 443] Connection port | ||
--scheme=https|http [default: https] Connection scheme. | ||
--timeout=timeout [default: 80] Connection timeout in milliseconds | ||
DESCRIPTION | ||
@@ -407,3 +442,3 @@ Lists top level databases | ||
_See code: [src/commands/list-databases.js](https://github.com/fauna/fauna-shell/blob/v0.0.3/src/commands/list-databases.js)_ | ||
_See code: [src/commands/list-databases.js](https://github.com/fauna/fauna-shell/blob/v0.0.4/src/commands/list-databases.js)_ | ||
@@ -418,2 +453,8 @@ ## `fauna list-keys` | ||
OPTIONS | ||
--domain=domain [default: db.fauna.com] FaunaDB server domain | ||
--port=port [default: 443] Connection port | ||
--scheme=https|http [default: https] Connection scheme. | ||
--timeout=timeout [default: 80] Connection timeout in milliseconds | ||
DESCRIPTION | ||
@@ -427,3 +468,3 @@ Lists top level keys | ||
_See code: [src/commands/list-keys.js](https://github.com/fauna/fauna-shell/blob/v0.0.3/src/commands/list-keys.js)_ | ||
_See code: [src/commands/list-keys.js](https://github.com/fauna/fauna-shell/blob/v0.0.4/src/commands/list-keys.js)_ | ||
@@ -441,2 +482,8 @@ ## `fauna shell DBNAME` | ||
OPTIONS | ||
--domain=domain [default: db.fauna.com] FaunaDB server domain | ||
--port=port [default: 443] Connection port | ||
--scheme=https|http [default: https] Connection scheme. | ||
--timeout=timeout [default: 80] Connection timeout in milliseconds | ||
DESCRIPTION | ||
@@ -450,3 +497,3 @@ Starts a FaunaDB shell | ||
_See code: [src/commands/shell.js](https://github.com/fauna/fauna-shell/blob/v0.0.3/src/commands/shell.js)_ | ||
_See code: [src/commands/shell.js](https://github.com/fauna/fauna-shell/blob/v0.0.4/src/commands/shell.js)_ | ||
<!-- commandsstop --> |
@@ -7,4 +7,3 @@ const FaunaCommand = require('../lib/fauna_command.js') | ||
async run() { | ||
const {args} = this.parse(CreateDatabaseCommand); | ||
const dbname = args.dbname; | ||
const dbname = this.args.dbname; | ||
this.query( | ||
@@ -25,2 +24,6 @@ q.CreateDatabase({ name: dbname }), | ||
CreateDatabaseCommand.flags = { | ||
...FaunaCommand.flags | ||
} | ||
CreateDatabaseCommand.args = [ | ||
@@ -27,0 +30,0 @@ { |
@@ -7,5 +7,4 @@ const FaunaCommand = require('../lib/fauna_command.js') | ||
async run() { | ||
const {args} = this.parse(CreateKeyCommand); | ||
const dbname = args.dbname; | ||
const role = args.role; | ||
const dbname = this.args.dbname; | ||
const role = this.args.role; | ||
this.query( | ||
@@ -26,2 +25,6 @@ q.CreateKey({ database: q.Database(dbname), role: role }), | ||
CreateKeyCommand.flags = { | ||
...FaunaCommand.flags | ||
} | ||
CreateKeyCommand.args = [ | ||
@@ -28,0 +31,0 @@ { |
@@ -7,4 +7,3 @@ const FaunaCommand = require('../lib/fauna_command.js') | ||
async run() { | ||
const {args} = this.parse(DeleteDatabaseCommand); | ||
const dbname = args.dbname; | ||
const dbname = this.args.dbname; | ||
this.query( | ||
@@ -25,2 +24,6 @@ q.Delete(q.Database(dbname)), | ||
DeleteDatabaseCommand.flags = { | ||
...FaunaCommand.flags | ||
} | ||
DeleteDatabaseCommand.args = [ | ||
@@ -27,0 +30,0 @@ { |
@@ -7,4 +7,3 @@ const FaunaCommand = require('../lib/fauna_command.js') | ||
async run() { | ||
const {args} = this.parse(DeleteKeyCommand); | ||
const keyname = args.keyname; | ||
const keyname = this.args.keyname; | ||
const log = this.log; | ||
@@ -26,2 +25,6 @@ this.query( | ||
DeleteKeyCommand.flags = { | ||
...FaunaCommand.flags | ||
} | ||
DeleteKeyCommand.args = [ | ||
@@ -28,0 +31,0 @@ { |
@@ -22,2 +22,6 @@ const FaunaCommand = require('../lib/fauna_command.js') | ||
ListDatabasesCommand.flags = { | ||
...FaunaCommand.flags | ||
} | ||
module.exports = ListDatabasesCommand |
@@ -22,2 +22,6 @@ const FaunaCommand = require('../lib/fauna_command.js') | ||
ListKeysCommand.flags = { | ||
...FaunaCommand.flags | ||
} | ||
module.exports = ListKeysCommand |
@@ -8,4 +8,3 @@ const FaunaCommand = require('../lib/fauna_command.js') | ||
async run() { | ||
const {args} = this.parse(ShellCommand); | ||
const dbscope = args.dbname; | ||
const dbscope = this.args.dbname; | ||
const role = 'admin'; | ||
@@ -53,2 +52,6 @@ const log = this.log; | ||
ShellCommand.flags = { | ||
...FaunaCommand.flags | ||
} | ||
ShellCommand.args = [ | ||
@@ -55,0 +58,0 @@ { |
@@ -1,3 +0,2 @@ | ||
const {Command} = require('@oclif/command') | ||
const {Command, flags} = require('@oclif/command') | ||
const {getRootKey, getConfigFile} = require('../lib/misc.js') | ||
@@ -8,7 +7,21 @@ const faunadb = require('faunadb'); | ||
class FaunaCommand extends Command { | ||
async init() { | ||
const {flags: f, args: a} = this.parse(this.constructor) | ||
this.flags = f; | ||
this.args = a; | ||
} | ||
withClient(f, dbScope, role) { | ||
const log = this.log | ||
const connectionOptions = { | ||
domain: this.flags.domain, | ||
scheme: this.flags.scheme, | ||
port: this.flags.port, | ||
timeout: this.flags.timeout | ||
}; | ||
getRootKey(getConfigFile()) | ||
.then(function (rootKey) { | ||
var secret = rootKey; | ||
var secret = rootKey; | ||
if (dbScope !== undefined && role !== undefined) { | ||
@@ -18,4 +31,11 @@ secret = rootKey + ":" + dbScope + ":" + role; | ||
var client = new faunadb.Client({ secret: secret }); | ||
connectionOptions.secret = secret; | ||
var client = new faunadb.Client(connectionOptions); | ||
f(client); | ||
}).catch(function(err) { | ||
if (err.code == 'ENOENT' && err.syscall == 'open' && err.errno == -2) { | ||
log(`Error: File ${err.path} not found. \nYou must create one as explained in the project README.`); | ||
} else { | ||
log(err); | ||
} | ||
}) | ||
@@ -50,2 +70,22 @@ } | ||
FaunaCommand.flags = { | ||
domain: flags.string({ | ||
description: 'FaunaDB server domain', | ||
default: 'db.fauna.com', | ||
}), | ||
scheme: flags.string({ | ||
description: 'Connection scheme.', | ||
options: ['https', 'http'], | ||
default: 'https', | ||
}), | ||
port: flags.string({ | ||
description: 'Connection port', | ||
default: 443, | ||
}), | ||
timeout: flags.string({ | ||
description: 'Connection timeout in milliseconds', | ||
default: 80, | ||
}) | ||
} | ||
module.exports = FaunaCommand; |
@@ -13,6 +13,10 @@ const os = require('os'); | ||
return new Promise(function(resolve, reject){ | ||
fs.readFile(fileName, 'utf8', (err, data) => { | ||
err ? reject(err) : resolve(data.trim()); | ||
}); | ||
if (process.env.FAUNA_SECRET_KEY) { | ||
resolve(process.env.FAUNA_SECRET_KEY); | ||
} else { | ||
fs.readFile(fileName, 'utf8', (err, data) => { | ||
err ? reject(err) : resolve(data.trim()); | ||
}); | ||
} | ||
}); | ||
} |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
22534
312
485
5