Comparing version 3.1.17 to 3.1.18
{ | ||
"name": "akkeris", | ||
"version": "3.1.17", | ||
"version": "3.1.18", | ||
"description": "Akkeris CLI", | ||
"main": "aka.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"dev": "node -r dotenv/config aka.js" | ||
}, | ||
@@ -32,2 +33,3 @@ "bin": { | ||
"devDependencies": { | ||
"dotenv": "^8.2.0", | ||
"eslint": "^7.5.0", | ||
@@ -34,0 +36,0 @@ "eslint-config-airbnb-base": "^14.1.0", |
function format_filter(filter) { | ||
return `**Ⴤ ${filter.name}** | ||
const formatted_data = [`**Ⴤ ${filter.name}** | ||
***Id: ${filter.id}*** | ||
***Type:*** ${filter.type} | ||
${Object.keys(filter.options).map((opt) => { | ||
const label = opt.replace('_', ' ').split(' ').map((x) => x[0].toUpperCase() + x.substring(1)).join(' '); | ||
if (Array.isArray(filter.options[opt])) { | ||
return ` ***${label}:*** ${filter.options[opt].join(', ')}`; | ||
***Type:*** ${filter.type}`]; | ||
Object.entries(filter.options).forEach(([key, value]) => { | ||
const label = key.replace('_', ' ').split(' ').map((x) => x[0].toUpperCase() + x.substring(1)).join(' '); | ||
if (Array.isArray(value)) { | ||
formatted_data.push(` ***${label}:*** ${value.join(', ')}`); | ||
} else { | ||
formatted_data.push(` ***${label}:*** ${value}`); | ||
} | ||
return ` ***${label}:*** ${filter.options[opt]}`; | ||
}).join('\n')} | ||
`; | ||
}); | ||
if (Array.isArray(filter.attached_apps)) { | ||
const attached_apps = filter.attached_apps.map((attached_app) => `${attached_app.name}-${attached_app.space.name}`).join(', '); | ||
formatted_data.push(` ***Attached Apps:*** ${attached_apps}`); | ||
} | ||
return formatted_data.join('\n'); | ||
} | ||
@@ -46,2 +51,12 @@ | ||
function info(appkit, args) { | ||
appkit.api.get(`/filters/${args.FILTER_NAME}`, (err, data) => { | ||
if (err) { | ||
appkit.terminal.print(err); | ||
return; | ||
} | ||
console.log(appkit.terminal.markdown(format_filter(data))); | ||
}); | ||
} | ||
async function create(appkit, args) { | ||
@@ -123,3 +138,3 @@ const task = appkit.terminal.task(`Creating http filter **⬢ ${args.FILTER_NAME}**`); | ||
task.end('error'); | ||
appkit.terminal.error(new Error('The specified filter type was invalid, the supported options are: jwt, cors')); | ||
appkit.terminal.error(new Error('The specified filter type was invalid, the supported options are: jwt, cors, or csp')); | ||
return; | ||
@@ -427,6 +442,6 @@ } | ||
.command('filters', 'List available http filters that can be attached.', optional_app, list.bind(null, appkit)) | ||
.command('filters:info FILTER_NAME', 'Show detailed information for a filter', {}, info.bind(null, appkit)) | ||
.command('filters:create FILTER_NAME', 'Create a new http filter', filters_create_option, create.bind(null, appkit)) | ||
.command('filters:update FILTER_NAME', 'Update an existing http filter', filters_update_option, update.bind(null, appkit)) | ||
.command('filters:destroy FILTER_NAME', 'Destroy an http filter', confirm_option, destroy.bind(null, appkit)) | ||
// .command('filters:update FILTER_NAME [options..]', 'Update an http filter', {}, update.bind(null, appkit)) | ||
.command('apps:filters:attach FILTER_NAME', 'Attach an http filter to an app', filters_attach, attach.bind(null, appkit)) | ||
@@ -433,0 +448,0 @@ .command('apps:filters:detach FILTER_ATTACHMENT_ID', 'Detach an http filter to an app', { ...require_app_option, ...confirm_option }, detach.bind(null, appkit)) |
@@ -0,1 +1,3 @@ | ||
# Akkeris Command Line Interface | ||
## Installing | ||
@@ -16,3 +18,3 @@ | ||
## Other env | ||
## Other env | ||
@@ -33,2 +35,71 @@ These environment variables are only useful if for development. | ||
[https://docs.akkeris.io/](https://docs.akkeris.io/) | ||
[https://docs.akkeris.io/](https://docs.akkeris.io/) | ||
## Running in Docker | ||
If you don't want to have Node.js installed, or just want to run the Akkeris CLI in a Docker container, you can build a Docker image with: | ||
```bash | ||
docker build -t akkeris-cli . | ||
``` | ||
Or use pre-built image from DockerHub: `akkeris/cli` | ||
### Authentication | ||
You can optionally bind your `~/.netrc` and `~/.akkeris/config.json` files to the Docker container so you don't have to go through the profile setup and login process each time you use the container. If you don't have either of those files set up yet, create them. | ||
For example, on MacOS: | ||
```bash | ||
touch ~/.netrc && mkdir -p ~/.akkeris && touch ~/.akkeris/config.json | ||
docker run --rm -it -v ~/.netrc:/root/.netrc -v ~/.akkeris/config.json:/root/.akkeris/config.json akkeris/cli [COMMAND] | ||
``` | ||
### Plugins | ||
You can bind a plugins directory to the Docker container if you want to have plugins persist between usages of the Docker container: | ||
```bash | ||
docker run --rm -it -v ~/.akkeris/plugins/:/root/.akkeris/plugins/ akkeris/cli [COMMAND] | ||
``` | ||
### Alias | ||
For easier use, you can add an alias to your bash profile: | ||
```bash | ||
alias aka="docker run --rm -it -v ~/.akkeris/plugins/:/root/.akkeris/plugins/ -v ~/.netrc:/root/.netrc -v ~/.akkeris/config.json:/root/.akkeris/config.json akkeris/cli" | ||
``` | ||
Then, you can run Akkeris commands inside a Docker container like you had the Akkeris CLI installed locally: `aka version` | ||
## Development | ||
### Getting Started | ||
```bash | ||
# Clone the repo via HTTPS | ||
git clone https://github.com/akkeris/cli.git | ||
# Or via SSH | ||
git clone git@github.com:akkeris/cli.git | ||
# Change directories into the repo | ||
cd cli | ||
# Install dependencies | ||
npm install | ||
# Create a `.env` file from the `.env.example` file | ||
cp -v .env.example .env | ||
# Modify any environment variable values in `.env` as necessary | ||
# Run the local version of the Akkeris CLI by replacing `aka` with `npm run dev` | ||
npm run dev | ||
# Append any `aka` sub-commands onto the end, such as | ||
npm run dev auth:login | ||
npm run dev apps | ||
npm run dev squirrel | ||
# And you're off to the races! | ||
``` |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
277503
38
7377
104
4
12