From e76ecc2b9548981aee8677dde64e6681ffb568d4 Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Tue, 7 May 2024 04:23:35 -0700 Subject: [PATCH] initial implementation --- .github/workflows/linux.yml | 3 +- README.md | 44 ++++++++++++++++++ alienfile | 34 ++++++++++---- author.yml | 5 +- dist.ini | 7 ++- lib/Alien/cue.pm | 28 +++++++++++- t/00_diag.t | 91 +++++++++++++++++++++++++++++++++++++ t/alien_cue.t | 5 +- 8 files changed, 201 insertions(+), 16 deletions(-) create mode 100644 README.md create mode 100644 t/00_diag.t diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4d84fdb..68e60a7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -17,7 +17,8 @@ jobs: fail-fast: false matrix: cip_tag: - - "5.37" + - "5.39" + - "5.38" - "5.36" - "5.34" - "5.32" diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0f0321 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# Alien::cue ![static](https://github.com/PerlAlien/Alien-cue/workflows/static/badge.svg) ![linux](https://github.com/PerlAlien/Alien-cue/workflows/linux/badge.svg) + +Find or download the cue configuration language tool + +# SYNOPSIS + +In your script or module: + +```perl +use Alien::cue; +use Env qw( @PATH ); + +unshift @PATH, Alien::cue->bin_dir; +``` + +# DESCRIPTION + +This package can be used by other CPAN modules that require cue, +the configuration language tool. + +# HELPERS + +## cue + +``` +%{cue} +``` + +Returns the name of the cue command. Usually just `cue`. + +# SEE ALSO + +[Alien](https://metacpan.org/pod/Alien), [Alien::Base](https://metacpan.org/pod/Alien::Base), [Alien::Build::Manual::AlienUser](https://metacpan.org/pod/Alien::Build::Manual::AlienUser) + +# AUTHOR + +Graham Ollis + +# COPYRIGHT AND LICENSE + +This software is copyright (c) 2024 by Graham Ollis. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. diff --git a/alienfile b/alienfile index da0dd35..c306c64 100644 --- a/alienfile +++ b/alienfile @@ -1,13 +1,31 @@ use alienfile; -plugin 'PkgConfig' => 'libfoo'; + +plugin 'Probe::CommandLine' => ( + command => 'cue', + args => [ 'version' ], + match => qr/cue version/, + version => qr/cue version ([0-9\.]+)/, +); + share { - plugin Download => ( - url => 'http://...', - filter => qr/*\.tar\.gz$/, - version => qr/([0-9\.]+)/, + + requires 'Alien::Go'; + + plugin 'Download::GitHub' => ( + github_user => 'cue-lang', + github_repo => 'cue', + prefer => sub { + my($build, $res) = @_; + return { + type => 'list', + list => [grep { $_->{version} !~ /alpha/ } @{ $res->{list} }], + }; + }, ); - plugin Extract => 'tar.gz'; - plugin 'Build::Autoconf'; -}; + build [ + 'env GOPATH=%{.install.prefix} go install ./cmd/cue', + 'env GOPATH=%{.install.prefix} go clean -modcache', + ]; +}; diff --git a/author.yml b/author.yml index 40420cc..50db382 100644 --- a/author.yml +++ b/author.yml @@ -11,6 +11,5 @@ pod_coverage: skip: 0 # format is "Class#method" or "Class",regex allowed # for either Class or method. - private: [] - - + private: + - Alien::cue#alien_helper diff --git a/dist.ini b/dist.ini index 0296db4..1c89e9b 100644 --- a/dist.ini +++ b/dist.ini @@ -5,6 +5,10 @@ copyright_holder = Graham Ollis copyright_year = 2024 version = 0.01 +[AlienBase::Doc] +name = cue +type = tool + [@Author::Plicease] :version = 2.75 release_tests = 1 @@ -21,4 +25,5 @@ irc = irc://irc.perl.org/#native [Author::Plicease::Upload] cpan = 0 - +[AlienBuild] +:version = 0.10 diff --git a/lib/Alien/cue.pm b/lib/Alien/cue.pm index 058f254..e7dd944 100644 --- a/lib/Alien/cue.pm +++ b/lib/Alien/cue.pm @@ -5,9 +5,33 @@ use warnings; use 5.008004; use base qw( Alien::Base ); -# ABSTRACT: Find or download the cue programming language tool +# ABSTRACT: Find or download the cue configuration language tool # VERSION +# ALIEN SYNOPSIS -1; +=head1 DESCRIPTION + +This package can be used by other CPAN modules that require cue, +the configuration language tool. + +=head1 HELPERS + +=head2 cue + + %{cue} +Returns the name of the cue command. Usually just C. +=cut + +sub alien_helper +{ + return { + cue => sub { 'cue' }, + }; +} + +# ALIEN SEE ALSO + + +1; diff --git a/t/00_diag.t b/t/00_diag.t new file mode 100644 index 0000000..b508753 --- /dev/null +++ b/t/00_diag.t @@ -0,0 +1,91 @@ +use Test2::V0 -no_srand => 1; +use Config; + +eval { require 'Test/More.pm' }; + +# This .t file is generated. +# make changes instead to dist.ini + +my %modules; +my $post_diag; + +$modules{$_} = $_ for qw( + Alien::Base + Alien::Build + Alien::Build::MM + Alien::Build::Plugin::Download::GitHub + ExtUtils::MakeMaker + Test2::V0 + Test::Alien +); + + + +my @modules = sort keys %modules; + +sub spacer () +{ + diag ''; + diag ''; + diag ''; +} + +pass 'okay'; + +my $max = 1; +$max = $_ > $max ? $_ : $max for map { length $_ } @modules; +our $format = "%-${max}s %s"; + +spacer; + +my @keys = sort grep /(MOJO|PERL|\A(LC|HARNESS)_|\A(SHELL|LANG)\Z)/i, keys %ENV; + +if(@keys > 0) +{ + diag "$_=$ENV{$_}" for @keys; + + if($ENV{PERL5LIB}) + { + spacer; + diag "PERL5LIB path"; + diag $_ for split $Config{path_sep}, $ENV{PERL5LIB}; + + } + elsif($ENV{PERLLIB}) + { + spacer; + diag "PERLLIB path"; + diag $_ for split $Config{path_sep}, $ENV{PERLLIB}; + } + + spacer; +} + +diag sprintf $format, 'perl', "$] $^O $Config{archname}"; + +foreach my $module (sort @modules) +{ + my $pm = "$module.pm"; + $pm =~ s{::}{/}g; + if(eval { require $pm; 1 }) + { + my $ver = eval { $module->VERSION }; + $ver = 'undef' unless defined $ver; + diag sprintf $format, $module, $ver; + } + else + { + diag sprintf $format, $module, '-'; + } +} + +if($post_diag) +{ + spacer; + $post_diag->(); +} + +spacer; + +done_testing; + diff --git a/t/alien_cue.t b/t/alien_cue.t index 576994c..0ed1ff3 100644 --- a/t/alien_cue.t +++ b/t/alien_cue.t @@ -1,7 +1,10 @@ use Test2::V0 -no_srand => 1; use Alien::cue; +use Test::Alien; -ok 1, 'todo'; +alien_ok 'Alien::cue'; +run_ok(['cue', 'version']) + ->note; done_testing;