forked from GMOD/Apollo3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First Apollo CLI commands: config, login, logout, and status (GMOD#354)
* Remove clientId from plugin * Consolidate to one login endpoint * Fix menu items not appearing * Stub for apollo login (issue GMOD#330 and GMOD#331) * A few mostly automatic fixes * Temporary commit with stubs for login using name and password * Start implementing login with username and password * Root login should work but needs tidying up for errors * Misc cleanups * Fix loading of commands * Get one test working * Get tests working even with imported files * Add coverage to CLI tests * Don't lint bin/ files * Draft for apollo config cli * Refactor to allow multiple profiles * Add some validation and update tests * Update oclif so we can use flagSortOrder * Make login subcommand aware of profiles * Add missing file * Refactor Profile to have address and accessType not null * Misc. cleanup * Address [checklist](GMOD#354 (review)) This commit should address most of the items in GMOD#354 (review) There are tests for most of them. `"default.rootCredentials.password" must be a string` occurs if an entry is expected to be string and instead is a number without quotes. The cli quotes as appropriate. > Make sure all commands print a sensible error message if the config file is > not valid YAML or doesn't pass validation Currently, the cli fails with a fairly friendly message if the yaml is malformed, but if it is valid, it will process it anyway * Lint and formatting fixes * Make sure tests work if config dir doesn't exist yet * Disable one test until server can be mocked --------- Co-authored-by: Garrett Stevens <stevens.garrett.j@gmail.com>
- Loading branch information
1 parent
bf85e02
commit 955d683
Showing
39 changed files
with
7,191 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dist/ | |
.eslintrc.js | ||
esm/ | ||
coverage/ | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
require: | ||
- ../../.pnp.cjs | ||
watch-extensions: | ||
- ts | ||
recursive: true | ||
reporter: spec | ||
forbidOnly: true | ||
timeout: 60000 | ||
node-option: | ||
- import=tsx | ||
- no-warnings=ExperimentalWarning | ||
- loader=@istanbuljs/esm-loader-hook | ||
- experimental-loader=../../.pnp.loader.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
extends: '@istanbuljs/nyc-config-typescript' | ||
all: true | ||
reporter: | ||
- lcov | ||
- text | ||
include: | ||
- src/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# oclif-hello-world | ||
|
||
oclif example Hello World CLI | ||
|
||
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io) | ||
[![CircleCI](https://circleci.com/gh/oclif/hello-world/tree/main.svg?style=shield)](https://circleci.com/gh/oclif/hello-world/tree/main) | ||
[![GitHub license](https://img.shields.io/github/license/oclif/hello-world)](https://github.com/oclif/hello-world/blob/main/LICENSE) | ||
|
||
<!-- toc --> | ||
|
||
- [Usage](#usage) | ||
- [Commands](#commands) | ||
<!-- tocstop --> | ||
|
||
# Usage | ||
|
||
<!-- usage --> | ||
|
||
```sh-session | ||
$ npm install -g apollo-cli | ||
$ apollo COMMAND | ||
running command... | ||
$ apollo (--version) | ||
apollo-cli/0.0.0 linux-x64 node-v18.19.0 | ||
$ apollo --help [COMMAND] | ||
USAGE | ||
$ apollo COMMAND | ||
... | ||
``` | ||
|
||
<!-- usagestop --> | ||
|
||
# Commands | ||
|
||
<!-- commands --> | ||
|
||
- [`apollo config [KEY] [VALUE]`](#apollo-config-key-value) | ||
- [`apollo help [COMMANDS]`](#apollo-help-commands) | ||
- [`apollo login`](#apollo-login) | ||
- [`apollo logout`](#apollo-logout) | ||
- [`apollo status`](#apollo-status) | ||
|
||
## `apollo config [KEY] [VALUE]` | ||
|
||
Get or set Apollo configuration options | ||
|
||
``` | ||
USAGE | ||
$ apollo config [KEY] [VALUE] [-p <value>] | ||
ARGUMENTS | ||
KEY Name of configuration parameter | ||
VALUE Parameter value | ||
FLAGS | ||
-p, --profile=<value> [default: default] Set or get configuration for this profile | ||
DESCRIPTION | ||
Get or set Apollo configuration options | ||
``` | ||
|
||
_See code: | ||
[src/commands/config.ts](https://github.com/GMOD/Apollo3/blob/v0.0.0/packages/apollo-cli/src/commands/config.ts)_ | ||
|
||
## `apollo help [COMMANDS]` | ||
|
||
Display help for apollo. | ||
|
||
``` | ||
USAGE | ||
$ apollo help [COMMANDS] [-n] | ||
ARGUMENTS | ||
COMMANDS Command to show help for. | ||
FLAGS | ||
-n, --nested-commands Include all nested commands in the output. | ||
DESCRIPTION | ||
Display help for apollo. | ||
``` | ||
|
||
_See code: | ||
[@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.8/src/commands/help.ts)_ | ||
|
||
## `apollo login` | ||
|
||
Log in to Apollo | ||
|
||
``` | ||
USAGE | ||
$ apollo login [--profile <value>] [-a <value>] [-u <value>] [-p <value>] [-f] | ||
FLAGS | ||
-a, --address=<value> Address of Apollo server | ||
-f, --force Force re-authentication even if user is already logged in | ||
-p, --password=<value> Password for <username> | ||
-u, --username=<value> Username for root login | ||
--profile=<value> [default: default] Use credentials from this profile | ||
DESCRIPTION | ||
Log in to Apollo | ||
``` | ||
|
||
_See code: | ||
[src/commands/login.ts](https://github.com/GMOD/Apollo3/blob/v0.0.0/packages/apollo-cli/src/commands/login.ts)_ | ||
|
||
## `apollo logout` | ||
|
||
Log out of Keycloak | ||
|
||
``` | ||
USAGE | ||
$ apollo logout | ||
DESCRIPTION | ||
Log out of Keycloak | ||
``` | ||
|
||
_See code: | ||
[src/commands/logout.ts](https://github.com/GMOD/Apollo3/blob/v0.0.0/packages/apollo-cli/src/commands/logout.ts)_ | ||
|
||
## `apollo status` | ||
|
||
View authentication status | ||
|
||
``` | ||
USAGE | ||
$ apollo status | ||
DESCRIPTION | ||
View authentication status | ||
``` | ||
|
||
_See code: | ||
[src/commands/status.ts](https://github.com/GMOD/Apollo3/blob/v0.0.0/packages/apollo-cli/src/commands/status.ts)_ | ||
|
||
<!-- commandsstop --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning | ||
|
||
// eslint-disable-next-line node/shebang | ||
async function main() { | ||
const {execute} = await import('@oclif/core') | ||
await execute({development: true, dir: import.meta.url}) | ||
} | ||
|
||
await main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node "%~dp0\run" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env node | ||
|
||
async function main() { | ||
const {execute} = await import('@oclif/core') | ||
await execute({dir: import.meta.url}) | ||
} | ||
|
||
await main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"name": "apollo-cli", | ||
"description": "CLI for managing an Apollo Collaboration Server", | ||
"version": "0.0.0", | ||
"author": "Apollo Team", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/GMOD/Apollo3.git", | ||
"directory": "packages/apollo-cli" | ||
}, | ||
"bin": { | ||
"apollo": "./bin/run.js" | ||
}, | ||
"type": "module", | ||
"main": "", | ||
"types": "dist/index.d.ts", | ||
"exports": "./dist/index.js", | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
"files": [ | ||
"/bin", | ||
"/dist", | ||
"/oclif.manifest.json" | ||
], | ||
"scripts": { | ||
"build": "shx rm -rf dist && tsc -b", | ||
"dev": "tsx bin/dev.js", | ||
"postpack": "shx rm -f oclif.manifest.json", | ||
"posttest": "yarn lint", | ||
"prepack": "yarn build && oclif manifest && oclif readme", | ||
"prepare": "yarn build", | ||
"test": "mocha 'src/**/*.test.ts'", | ||
"test:ci": "nyc mocha 'src/**/*.test.ts'", | ||
"version": "oclif readme && git add README.md" | ||
}, | ||
"dependencies": { | ||
"@inquirer/input": "^1.2.14", | ||
"@inquirer/password": "^1.1.14", | ||
"@inquirer/select": "^1.3.1", | ||
"@oclif/core": "^3.18.2", | ||
"@oclif/plugin-help": "^6.0.8", | ||
"joi": "^17.7.0", | ||
"open": "^9.1.0", | ||
"tslib": "^2.3.1", | ||
"yaml": "^2.3.4" | ||
}, | ||
"devDependencies": { | ||
"@istanbuljs/esm-loader-hook": "^0.2.0", | ||
"@istanbuljs/nyc-config-typescript": "^1.0.2", | ||
"@oclif/test": "^3.1.3", | ||
"@types/chai": "^4", | ||
"@types/inquirer": "^9.0.7", | ||
"@types/mocha": "^10", | ||
"@types/node": "^18.14.2", | ||
"babel-plugin-istanbul": "^6.1.1", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0", | ||
"oclif": "^4.4.2", | ||
"shx": "^0.3.3", | ||
"ts-node": "^10.3.0", | ||
"tsx": "^4.6.2", | ||
"typescript": "^5.1.6" | ||
}, | ||
"oclif": { | ||
"helpOptions": { | ||
"flagSortOrder": "none" | ||
}, | ||
"bin": "apollo", | ||
"dirname": "apollo-cli", | ||
"commands": "./dist/commands", | ||
"plugins": [ | ||
"@oclif/plugin-help" | ||
], | ||
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/apollo-cli/<%- commandPath %>", | ||
"topicSeparator": " " | ||
} | ||
} |
Oops, something went wrong.