packs 0.0.43 → 0.0.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/packs/configuration.rb +4 -0
- data/lib/packs/private/file_move_operation.rb +40 -5
- data/lib/packs.rb +15 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad12cf46cbfafc5f4b3b2d785f2ec2f3f67ed34cb8322bba6929a7ae584d06e1
|
4
|
+
data.tar.gz: 8712c08b31b3457b403d3814764496f3c4d46e53867f88760cadd10083e38a63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bad96e8500d53692f4930cb08ae0ed1be99b8b0524283027d424a05094d23039b5ed9bd646d94db4e67de158ca5af480288c05e799af0a82e6c46cc2c4190fc0
|
7
|
+
data.tar.gz: ed7ebf9ed287b16336187500dc1ebfb833ce569039f7ad9775e9cf84fee53be47f6326fd8b7a4f3abc61d922080dc9ae2ab8e3049583bf8165871b7a4e763ffb
|
data/lib/packs/configuration.rb
CHANGED
@@ -13,6 +13,9 @@ module Packs
|
|
13
13
|
sig { returns(UserEventLogger) }
|
14
14
|
attr_accessor :user_event_logger
|
15
15
|
|
16
|
+
sig { returns(T::Boolean) }
|
17
|
+
attr_accessor :use_pks
|
18
|
+
|
16
19
|
OnPackageTodoLintFailure = T.type_alias do
|
17
20
|
T.proc.params(output: String).void
|
18
21
|
end
|
@@ -25,6 +28,7 @@ module Packs
|
|
25
28
|
@enforce_dependencies = T.let(default_enforce_dependencies, T::Boolean)
|
26
29
|
@user_event_logger = T.let(DefaultUserEventLogger.new, UserEventLogger)
|
27
30
|
@on_package_todo_lint_failure = T.let(->(output) {}, OnPackageTodoLintFailure)
|
31
|
+
@use_pks = T.let(false, T::Boolean)
|
28
32
|
end
|
29
33
|
|
30
34
|
sig { returns(T::Boolean) }
|
@@ -53,15 +53,20 @@ module Packs
|
|
53
53
|
|
54
54
|
sig { returns(FileMoveOperation) }
|
55
55
|
def spec_file_move_operation
|
56
|
+
path_parts = filepath_without_pack_name.split('/')
|
57
|
+
folder = T.must(path_parts[0])
|
58
|
+
file_extension = T.must(filepath_without_pack_name.split('.').last)
|
59
|
+
|
56
60
|
# This could probably be implemented by some "strategy pattern" where different extension types are handled by different helpers
|
57
61
|
# Such a thing could also include, for example, when moving a controller, moving its ERB view too.
|
58
|
-
if
|
59
|
-
new_origin_pathname = origin_pathname
|
60
|
-
new_destination_pathname = destination_pathname
|
62
|
+
if folder == 'app'
|
63
|
+
new_origin_pathname = spec_pathname_for_app(origin_pathname, file_extension)
|
64
|
+
new_destination_pathname = spec_pathname_for_app(destination_pathname, file_extension)
|
61
65
|
else
|
62
|
-
new_origin_pathname = origin_pathname
|
63
|
-
new_destination_pathname = destination_pathname
|
66
|
+
new_origin_pathname = spec_pathname_for_non_app(origin_pathname, file_extension, folder)
|
67
|
+
new_destination_pathname = spec_pathname_for_non_app(destination_pathname, file_extension, folder)
|
64
68
|
end
|
69
|
+
|
65
70
|
FileMoveOperation.new(
|
66
71
|
origin_pathname: new_origin_pathname,
|
67
72
|
destination_pathname: new_destination_pathname,
|
@@ -69,8 +74,38 @@ module Packs
|
|
69
74
|
)
|
70
75
|
end
|
71
76
|
|
77
|
+
sig { params(filepath: Pathname, pack: T.nilable(Packs::Pack)).returns(String) }
|
78
|
+
def self.get_filepath_without_pack_name(filepath, pack)
|
79
|
+
if pack
|
80
|
+
filepath.to_s.gsub("#{pack.name}/", '')
|
81
|
+
else
|
82
|
+
filepath.to_s
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
72
86
|
private
|
73
87
|
|
88
|
+
sig { returns(String) }
|
89
|
+
def filepath_without_pack_name
|
90
|
+
self.class.get_filepath_without_pack_name(origin_pathname, origin_pack)
|
91
|
+
end
|
92
|
+
|
93
|
+
sig { params(pathname: Pathname, file_extension: String).returns(Pathname) }
|
94
|
+
def spec_pathname_for_app(pathname, file_extension)
|
95
|
+
pathname
|
96
|
+
.sub('/app/', '/spec/')
|
97
|
+
.sub(%r{^app/}, 'spec/')
|
98
|
+
.sub(".#{file_extension}", '_spec.rb')
|
99
|
+
end
|
100
|
+
|
101
|
+
sig { params(pathname: Pathname, file_extension: String, folder: String).returns(Pathname) }
|
102
|
+
def spec_pathname_for_non_app(pathname, file_extension, folder)
|
103
|
+
pathname
|
104
|
+
.sub("/#{folder}/", "/spec/#{folder}/")
|
105
|
+
.sub(%r{^#{folder}/}, "spec/#{folder}/")
|
106
|
+
.sub(".#{file_extension}", '_spec.rb')
|
107
|
+
end
|
108
|
+
|
74
109
|
sig { params(path: Pathname).returns(FileMoveOperation) }
|
75
110
|
def relative_to(path)
|
76
111
|
FileMoveOperation.new(
|
data/lib/packs.rb
CHANGED
@@ -32,17 +32,29 @@ module Packs
|
|
32
32
|
|
33
33
|
sig { returns(T::Boolean) }
|
34
34
|
def self.update
|
35
|
-
|
35
|
+
if Packs.config.use_pks
|
36
|
+
Private.system_with('bin/pks update')
|
37
|
+
else
|
38
|
+
Private.system_with('bin/packwerk update-todo')
|
39
|
+
end
|
36
40
|
end
|
37
41
|
|
38
42
|
sig { returns(T::Boolean) }
|
39
43
|
def self.validate
|
40
|
-
|
44
|
+
if Packs.config.use_pks
|
45
|
+
Private.system_with('bin/pks validate')
|
46
|
+
else
|
47
|
+
Private.system_with('bin/packwerk validate')
|
48
|
+
end
|
41
49
|
end
|
42
50
|
|
43
51
|
sig { params(files: T::Array[String]).returns(T::Boolean) }
|
44
52
|
def self.check(files)
|
45
|
-
|
53
|
+
if Packs.config.use_pks
|
54
|
+
Private.system_with("bin/pks check #{files.join(' ')}")
|
55
|
+
else
|
56
|
+
Private.system_with("bin/packwerk check #{files.join(' ')}")
|
57
|
+
end
|
46
58
|
end
|
47
59
|
|
48
60
|
sig do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|
@@ -344,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
344
344
|
- !ruby/object:Gem::Version
|
345
345
|
version: '0'
|
346
346
|
requirements: []
|
347
|
-
rubygems_version: 3.5.
|
347
|
+
rubygems_version: 3.5.16
|
348
348
|
signing_key:
|
349
349
|
specification_version: 4
|
350
350
|
summary: Provides CLI tools for working with ruby packs.
|