mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-27 03:21:49 +03:00
Merge pull request #582 from AleoHQ/leo-add-no-logout
[CLI, CI] Leo add does not require login
This commit is contained in:
commit
66c736b3d7
6
.github/workflows/leo-add-remove.yml
vendored
6
.github/workflows/leo-add-remove.yml
vendored
@ -34,13 +34,9 @@ jobs:
|
||||
command: install
|
||||
args: --path .
|
||||
|
||||
- name: 'leo login & add'
|
||||
env:
|
||||
USER: ${{ secrets.ALEO_PM_USERNAME }}
|
||||
PASS: ${{ secrets.ALEO_PM_PASSWORD }}
|
||||
- name: 'leo add (w/o login) & remove'
|
||||
run: |
|
||||
cd .. && leo new my-app && cd my-app
|
||||
leo login -u "$USER" -p "$PASS"
|
||||
leo add argus4130/xnor
|
||||
leo remove xnor
|
||||
leo clean
|
||||
|
48
.github/workflows/leo-login-logout.yml
vendored
Normal file
48
.github/workflows/leo-login-logout.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
name: leo-login-logout
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- 'documentation/**'
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
|
||||
jobs:
|
||||
add:
|
||||
name: Add Package ('leo add')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt
|
||||
|
||||
- name: Install Leo
|
||||
uses: actions-rs/cargo@v1
|
||||
env:
|
||||
CARGO_NET_GIT_FETCH_WITH_CLI: true
|
||||
with:
|
||||
command: install
|
||||
args: --path .
|
||||
|
||||
- name: 'leo login & logout'
|
||||
env:
|
||||
USER: ${{ secrets.ALEO_PM_USERNAME }}
|
||||
PASS: ${{ secrets.ALEO_PM_PASSWORD }}
|
||||
run: |
|
||||
cd .. && leo new my-app && cd my-app
|
||||
leo login -u "$USER" -p "$PASS"
|
||||
leo add argus4130/xnor
|
||||
leo remove xnor
|
||||
leo clean
|
||||
leo logout
|
||||
|
@ -115,10 +115,6 @@ impl CLI for AddCommand {
|
||||
// Begin "Adding" context for console logging
|
||||
let span = tracing::span!(tracing::Level::INFO, "Adding");
|
||||
let _enter = span.enter();
|
||||
|
||||
// token can only be there if user has signed into Aleo PM
|
||||
// so we need to verify that token exists before doing anything else
|
||||
let token = read_token().map_err(|_| -> CLIError { NotAuthorized.into() })?;
|
||||
let path = current_dir()?;
|
||||
|
||||
// Enforce that the current directory is a leo package
|
||||
@ -137,7 +133,17 @@ impl CLI for AddCommand {
|
||||
json.insert("version", version);
|
||||
}
|
||||
|
||||
match client.post(&url).bearer_auth(token).json(&json).send() {
|
||||
let result = match read_token() {
|
||||
Ok(token) => {
|
||||
tracing::info!("Logged in, using token to authorize");
|
||||
client.post(&url).bearer_auth(token)
|
||||
}
|
||||
Err(_) => client.post(&url),
|
||||
}
|
||||
.json(&json)
|
||||
.send();
|
||||
|
||||
match result {
|
||||
Ok(response) => (response, package_name),
|
||||
//Cannot connect to the server
|
||||
Err(_error) => {
|
||||
|
Loading…
Reference in New Issue
Block a user