Skip to content

Commit 32af36b

Browse files
authored
pkg: refactor packaging (2) (#1346)
1 parent c586f14 commit 32af36b

File tree

11 files changed

+31
-32
lines changed

11 files changed

+31
-32
lines changed

packaging/scripts/clean.raku

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
use v6;
44

55
use lib $?FILE.IO.parent.child("lib");
6-
use Packaging;
7-
use Registry :kinds;
6+
use Packager;
7+
use Registry :Target;
88

99
sub MAIN(
10-
Registry::Kind :$target = all-registries,
10+
Registry::Target :$target = all-registries,
1111
Bool :$dry-run = False,
1212
) {
13-
Packaging.new(
14-
target => $target,
13+
Packager.new(
14+
target => $target,
1515
dry-run => $dry-run,
1616
).clean;
1717
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# I hope that reading through these scripts will show you
66
# a lot of interesting concepts... and definitely fun!
77

8-
unit class Packaging;
8+
unit class Packager;
99

1010
use System;
1111
use Registry;
@@ -24,8 +24,8 @@ my constant @PACKAGE-TYPES = (
2424
Registries::AUR-Bin,
2525
);
2626

27-
has Bool $.dry-run is required;
28-
has Registry::Kind $.target is required;
27+
has Bool $.dry-run is required;
28+
has Registry::Target $.target is required;
2929

3030
method clean(--> Nil) { .clean for self!packages }
3131
method set-version(--> Nil) { .set-version for self!packages }
@@ -36,7 +36,7 @@ method !packages(--> Seq) {
3636
my $sys = System.new(dry-run => $!dry-run);
3737
my @packages = @PACKAGE-TYPES.map({ .new(sys => $sys) });
3838

39-
return @packages.Seq if $!target == Registry::Kind::all-registries;
39+
return @packages.Seq if $!target == Registry::Target::all-registries;
4040

41-
@packages.grep(*.kind == $!target);
41+
@packages.grep(*.target == $!target);
4242
}

packaging/scripts/lib/Registries/AUR-Bin.rakumod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ my constant PKGBUILD = PKG-ROOT.child("aur").child("lefthook-bin").child("PKGBUI
1010

1111
has SystemAPI $.sys is required;
1212

13-
method kind(--> Registry::Kind:D) { Registry::Kind::aur-bin }
13+
method target(--> Registry::Target:D) { Registry::Target::aur-bin }
1414

1515
method clean {}
1616

packaging/scripts/lib/Registries/AUR.rakumod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ my constant PKGBUILD = PKG-ROOT.child("aur").child("lefthook").child("PKGBUILD")
1010

1111
has SystemAPI $.sys is required;
1212

13-
method kind(--> Registry::Kind:D) { Registry::Kind::aur }
13+
method target(--> Registry::Target:D) { Registry::Target::aur }
1414

1515
method clean {}
1616

packaging/scripts/lib/Registries/NPM.rakumod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ my constant %NPM-BUNDLED-DISTS = (
7575
arm64-openbsd => "{NPM-BUNDLED}/bin/lefthook-openbsd-arm64/lefthook",
7676
);
7777

78-
method kind(--> Registry::Kind:D) { Registry::Kind::npm }
78+
method target(--> Registry::Target:D) { Registry::Target::npm }
7979

8080
method clean {
8181
$!sys.rm(

packaging/scripts/lib/Registries/PyPI.rakumod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ my constant @PLATFORMS = (
3030

3131
has SystemAPI $.sys is required;
3232

33-
method kind(--> Registry::Kind:D) { Registry::Kind::pypi }
33+
method target(--> Registry::Target:D) { Registry::Target::pypi }
3434

3535
method clean {
3636
$!sys.rm(

packaging/scripts/lib/Registries/RubyGems.rakumod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ my constant %RUBYGEM-DISTS = (
2222

2323
has SystemAPI $.sys is required;
2424

25-
26-
method kind(--> Registry::Kind:D) { Registry::Kind::rubygem }
25+
method target(--> Registry::Target:D) { Registry::Target::rubygem }
2726

2827
method clean {
2928
$!sys.rm("{RUBYGEMS}/libexec/".IO.dir.grep(*.d));

packaging/scripts/lib/Registry.rakumod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
unit module Registry;
22

33
# Supported regitstries.
4-
enum Kind is export(:kinds) <
4+
enum Target is export(:Target) <
55
all-registries
66

77
npm
@@ -13,7 +13,7 @@ enum Kind is export(:kinds) <
1313

1414
# Abstract interface for a registry class to implement.
1515
role Package {
16-
method kind(--> Kind:D) { ... }
16+
method target(--> Target:D) { ... }
1717
method clean(--> Nil) { ... }
1818
method set-version(--> Nil) { ... }
1919
method prepare(--> Nil) { ... }

packaging/scripts/prepare.raku

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
use v6;
44

55
use lib $?FILE.IO.parent.child("lib");
6-
use Packaging;
7-
use Registry :kinds;
6+
use Packager;
7+
use Registry :Target;
88

99
sub MAIN(
10-
Registry::Kind :$target = all-registries,
10+
Registry::Target :$target = all-registries,
1111
Bool :$dry-run = False,
1212
) {
13-
Packaging.new(
14-
target => $target,
13+
Packager.new(
14+
target => $target,
1515
dry-run => $dry-run,
1616
).prepare;
1717
}

packaging/scripts/publish.raku

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
use v6;
44

55
use lib $?FILE.IO.parent.child("lib");
6-
use Packaging;
7-
use Registry :kinds;
6+
use Packager;
7+
use Registry :Target;
88

99
sub MAIN(
10-
Registry::Kind :$target = all-registries,
10+
Registry::Target :$target = all-registries,
1111
Bool :$dry-run = False,
1212
) {
1313
Packaging.new(
14-
target => $target,
14+
target => $target,
1515
dry-run => $dry-run,
1616
).publish;
1717
}

0 commit comments

Comments
 (0)