refactor: convert to mono-repo
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: ci
|
||||
name: shorebird_cli
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -8,17 +8,17 @@ on:
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/shorebird_cli.yaml"
|
||||
- "lib/**"
|
||||
- "test/**"
|
||||
- "pubspec.yaml"
|
||||
- "packages/shorebird_cli/lib/**"
|
||||
- "packages/shorebird_cli/test/**"
|
||||
- "packages/shorebird_cli/pubspec.yaml"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- ".github/workflows/shorebird_cli.yaml"
|
||||
- "lib/**"
|
||||
- "test/**"
|
||||
- "pubspec.yaml"
|
||||
- "packages/shorebird_cli/lib/**"
|
||||
- "packages/shorebird_cli/test/**"
|
||||
- "packages/shorebird_cli/pubspec.yaml"
|
||||
|
||||
jobs:
|
||||
semantic-pull-request:
|
||||
@@ -1,3 +1,5 @@
|
||||
## shorebird_cli
|
||||
## shorebird
|
||||
|
||||
The Shorebird command-line tool.
|
||||
Home of the Shorebird Tools 🐦
|
||||
|
||||
🚧 Under construction... 🚧
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:mason_logger/mason_logger.dart';
|
||||
|
||||
/// {@template sample_command}
|
||||
///
|
||||
/// `shorebird sample`
|
||||
/// A [Command] to exemplify a sub command
|
||||
/// {@endtemplate}
|
||||
class PublishCommand extends Command<int> {
|
||||
/// {@macro sample_command}
|
||||
PublishCommand({required Logger logger}) : _logger = logger;
|
||||
|
||||
@override
|
||||
String get description => 'Publish an update.';
|
||||
|
||||
@override
|
||||
String get name => 'publish';
|
||||
|
||||
final Logger _logger;
|
||||
|
||||
@override
|
||||
Future<int> run() async {
|
||||
_logger.info('Coming soon...');
|
||||
return ExitCode.success.code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## shorebird_cli
|
||||
|
||||
The Shorebird command-line tool.
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:mason_logger/mason_logger.dart';
|
||||
|
||||
/// {@template sample_command}
|
||||
///
|
||||
/// `shorebird sample`
|
||||
/// A [Command] to exemplify a sub command
|
||||
/// {@endtemplate}
|
||||
class PublishCommand extends Command<int> {
|
||||
/// {@macro sample_command}
|
||||
PublishCommand({required Logger logger, http.Client? httpClient})
|
||||
: _logger = logger,
|
||||
_httpClient = httpClient ?? http.Client();
|
||||
|
||||
@override
|
||||
String get description => 'Publish an update.';
|
||||
|
||||
@override
|
||||
String get name => 'publish';
|
||||
|
||||
final Logger _logger;
|
||||
final http.Client _httpClient;
|
||||
|
||||
@override
|
||||
Future<int> run() async {
|
||||
final args = argResults!.rest;
|
||||
if (args.isEmpty || args.length > 1) {
|
||||
usageException('A single file path must be specified.');
|
||||
}
|
||||
|
||||
final artifact = File(args.first);
|
||||
if (!artifact.existsSync()) {
|
||||
_logger.err('File not found: ${artifact.path}');
|
||||
return ExitCode.noInput.code;
|
||||
}
|
||||
|
||||
final request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse('http://localhost:8080/deploy'),
|
||||
);
|
||||
final file = await http.MultipartFile.fromPath('file', artifact.path);
|
||||
request.files.add(file);
|
||||
final response = await _httpClient.send(request);
|
||||
|
||||
if (response.statusCode != HttpStatus.ok) {
|
||||
_logger.err(
|
||||
'Deploy failed: ${response.statusCode} ${response.reasonPhrase}',
|
||||
);
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
_logger.success('Deployed ${artifact.path} successfully!');
|
||||
|
||||
return ExitCode.success.code;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ environment:
|
||||
dependencies:
|
||||
args: ^2.3.1
|
||||
cli_completion: ^0.2.0
|
||||
http: ^0.13.5
|
||||
mason_logger: ^0.2.4
|
||||
pub_updater: ^0.2.4
|
||||
|
||||
Reference in New Issue
Block a user