Skip to content

Commit

Permalink
removed our dendency of the main dcli library due to problems with wa…
Browse files Browse the repository at this point in the history
…itfor no longer being supported indart.

change the # bin/env from dcli to dart.
  • Loading branch information
bsutton committed Mar 1, 2024
1 parent 37789f2 commit 091dcec
Show file tree
Hide file tree
Showing 56 changed files with 1,040 additions and 377 deletions.
116 changes: 78 additions & 38 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,131 @@
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["doctor"]
"args": [
"doctor"
]
},
{
"name": "onepub team create",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["team", "create", "one"]
}
,
"args": [
"team",
"create",
"one"
]
},
{
"name": "onepub login",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["login"],
"args": [
"login"
],
"console": "terminal"
},
{
"name": "onepub logout",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["logout"]
}
,
"args": [
"logout"
]
},
{
"name": "onepub doctor",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["doctor"]
}
,
"args": [
"doctor"
]
},
{
"name": "onepub export",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["export"]
}
,
"args": [
"export"
]
},
{
"name": "onepub export to file",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["export", "--file"]
}

,
"args": [
"export",
"--file"
]
},
{
"name": "onepub export CI/CD User",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["export", "--user", "[email protected]"]
}
,
"args": [
"export",
"--user",
"[email protected]"
]
},
{
"name": "onepub import",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["import"],
"env": {"ONEPUB_TOKEN" : "ABCDE"}
"args": [
"import"
],
"env": {
"ONEPUB_TOKEN": "ABCDE"
}
},

{
"name": "onepub pub private",
"type": "dart",
"request": "launch",
"program": "bin/onepub.dart",
"args": ["pub", "private"],
"args": [
"pub",
"private"
],
"console": "terminal"
},

{
"name": "opub login",
"type": "dart",
"request": "launch",
"program": "bin/opub.dart",
"args": ["login"],
"args": [
"login"
],
"console": "terminal"
},

{
"name": "opub publish",
"type": "dart",
"request": "launch",
"program": "/home/bsutton/git/onepub/onepub/bin/opub.dart",
"args": ["publish"],
"args": [
"publish"
],
"console": "terminal",
"cwd": "/home/bsutton/git/dcli/dcli_core"
},

{
"name": "opub get",
"type": "dart",
"request": "launch",
"program": "bin/opub.dart",
"args": ["get"],
"args": [
"get"
],
"console": "terminal"
},
{
Expand All @@ -115,28 +138,45 @@
"request": "launch",
"program": "/home/bsutton/git/onepub/onepub/bin/onepub.dart",
"cwd": "/home/bsutton/git/setversion",
"args": ["pub", "global","activate","setversion"],
"args": [
"pub",
"global",
"activate",
"setversion"
],
"console": "terminal"
},


{
"name": "onepub pub private ",
"type": "dart",
"request": "launch",
"program": "/home/bsutton/git/onepub/onepub/bin/onepub.dart",
"args": ["pub", "private"],
"args": [
"pub",
"private"
],
"cwd": "/home/bsutton/git/dvault",
"console": "terminal"
},

{
"name": "test ct auth",
"type": "dart",
"request": "launch",
"program": "/home/bsutton/git/onepub/onepub/tool/critical_test/pre_hook/auth.dart",
"console": "terminal"
},

{
"name": "onepub pub add ",
"type": "dart",
"request": "launch",
"program": "/home/bsutton/git/onepub/onepub/bin/onepub.dart",
"args": [
"pub",
"add",
"dcli"
],
"cwd": "/home/bsutton/git/issues/token",
"console": "terminal"
},
]
}
}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 4.0.0-beta.1
- support for dart 3.x
# 4.1.0-beta.1
- support for dart 3.2.x

# 3.1.0-beta.1
- moved some dependencies into the dev_dependencies section to help
Expand Down
2 changes: 1 addition & 1 deletion bin/onepub.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env dcli
#! /usr/bin/env dart

/* Copyright (C) OnePub IP Pty Ltd - All Rights Reserved
* licensed under the GPL v2.
Expand Down
2 changes: 1 addition & 1 deletion bin/opub.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env dcli
#! /usr/bin/env dart
/* Copyright (C) OnePub IP Pty Ltd - All Rights Reserved
* licensed under the GPL v2.
* Written by Brett Sutton <[email protected]>, Jan 2022
Expand Down
2 changes: 1 addition & 1 deletion lib/src/api/member.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Member {

final tokenStore = OnePubTokenStore();

final token = tokenStore.getToken(onepubApiUrl.toString());
final token = await tokenStore.getToken(onepubApiUrl.toString());
if (token != null) {
final member = await API().fetchMember(token);
return member.roles.contains(RoleEnum.SystemAdministrator.name);
Expand Down
42 changes: 23 additions & 19 deletions lib/src/commands/doctor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ import 'dart:async';
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:dcli/dcli.dart';
import 'package:dcli_core/dcli_core.dart';
import 'package:dcli_input/dcli_input.dart';
import 'package:dcli_terminal/dcli_terminal.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:strings/strings.dart';

import '../api/api.dart';
import '../onepub_settings.dart';
import '../util/one_pub_token_store.dart';
import '../util/printerr.dart';
import '../util/pub_cache.dart';
import '../version/version.g.dart';

///
Expand All @@ -34,7 +38,7 @@ class DoctorCommand extends Command<int> {
_printEnvironment();
_printShell();

tokenStatus();
await tokenStatus();
await _status();
return 0;
}
Expand Down Expand Up @@ -84,22 +88,22 @@ class DoctorCommand extends Command<int> {
print(blue('Shell Settings'));
_colprint([r'$SHELL:', env['SHELL'] ?? '']);

final shell = Shell.current;
_colprint(['Detected:', shell.name]);

if (shell.hasStartScript) {
final startScriptPath = shell.pathToStartScript;
_colprint(['Start script:', privatePath(startScriptPath ?? 'not found')]);
} else {
_colprint(['Start script:', 'not supported by shell']);
}
// TODO(bsutton): restore once dcli resolves waitfor issue.
// final shell = Shell.current;
// _colprint(['Detected:', shell.name]);
// if (shell.hasStartScript) {
// final startScriptPath = shell.pathToStartScript;
// _colprint(['Start script:', privatePath(startScriptPath ?? 'not found')]);
// } else {
// _colprint(['Start script:', 'not supported by shell']);
// }
}

Future<void> _status() async {
print('');
print(blue('Status'));
final settings = OnePubSettings.use();
if (OnePubTokenStore().isLoggedIn(settings.onepubApiUrl)) {
if (await OnePubTokenStore().isLoggedIn(settings.onepubApiUrl)) {
_colprint(['Logged In:', 'true']);
_colprint(['Active Member:', settings.operatorEmail]);
_colprint(['Organisation:', settings.organisationName]);
Expand All @@ -109,7 +113,7 @@ You are not logged into OnePub.
run: onepub login'''));
}
try {
echo('checking status... ');
await echo('checking status... ');

final status = await API().status();

Expand Down Expand Up @@ -138,20 +142,20 @@ run: onepub login'''));
}
}

void tokenStatus() {
Future<void> tokenStatus() async {
print(blue('\nRepository tokens'));

final store = OnePubTokenStore();

var hasOnePubToken = false;
for (final credential in store.credentials) {
for (final credential in await store.credentials) {
if (credential.url.host == 'onepub.dev' ||
credential.url.host == 'beta.onepub.dev') {
hasOnePubToken = true;
}
}

if (!store.isLoggedIn(OnePubSettings.use().onepubApiUrl)) {
if (!await store.isLoggedIn(OnePubSettings.use().onepubApiUrl)) {
print(red('Not logged into OnePub.'));
if (hasOnePubToken) {
print('''
Expand All @@ -162,16 +166,16 @@ as listed below.
}
}

for (final credential in store.credentials) {
for (final credential in await store.credentials) {
print(credential.url);
}
}

void _printPlatform() {
print(blue('Platform'));

_colprint(['Dart version:', DartSdk().version]);
_colprint(['Dart path:', DartSdk().pathToDartExe]);
_colprint(['Dart version:', Platform.version]);
_colprint(['Dart path:', Platform.executable]);
print('');

_colprint(['OS:', Platform.operatingSystem]);
Expand Down
7 changes: 4 additions & 3 deletions lib/src/commands/export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* Written by Brett Sutton <[email protected]>, Jan 2022
*/
import 'package:args/command_runner.dart';
import 'package:dcli/dcli.dart';
import 'package:dcli_core/dcli_core.dart';
import 'package:dcli_terminal/dcli_terminal.dart';
import 'package:validators2/validators2.dart';

import '../api/api.dart';
Expand Down Expand Up @@ -47,7 +48,7 @@ Pass in a filename or leave blank to use the default filename.''')
final file = argResults!['file'] as bool;
final user = argResults!['user'] as String?;

if (!OnePubTokenStore().isLoggedIn(OnePubSettings.use().onepubApiUrl)) {
if (!await OnePubTokenStore().isLoggedIn(OnePubSettings.use().onepubApiUrl)) {
throw ExitException(exitCode: 1, message: '''
You must be logged in to run this command.
run: onepub login
Expand All @@ -72,7 +73,7 @@ run: onepub login
throw ExitException(exitCode: 1, message: response.errorMessage!);
}
} else {
onepubToken = OnePubTokenStore().load();
onepubToken = await OnePubTokenStore().load();
}
print(orange('Exporting OnePub token for '
'${OnePubSettings.use().organisationName}.'));
Expand Down
Loading

0 comments on commit 091dcec

Please sign in to comment.