packs 0.0.36 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/packs/cli.rb +16 -2
- data/lib/packs/private.rb +103 -7
- data/lib/packs/user_event_logger.rb +18 -0
- data/lib/packs.rb +33 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 876b307fd78af1128f0404e37f792d5b249b77ccba825fcd8afc3729ac77c242
|
4
|
+
data.tar.gz: 39b947778eda7ce4aadd58830bb8abf320c3b1cf3f09327b503a24b93ea43add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aecd7614772de0eb3166954887d9012161697f355cd852a12d652f745c5bd424ac52839204762067fbb27d48ea8ffd56551f1c4eb6597fa50099cfd43f22070
|
7
|
+
data.tar.gz: dbc2223fe7612e204f59548136bfc8b8f77355f321cfee17d25766a94ba7fb473be9fe47f2db9d95138a746dba1a7ce687c60befba05f481cfa4b2603f2bc547
|
data/README.md
CHANGED
@@ -111,7 +111,10 @@ Make sure there are no spaces between the comma-separated list of paths of direc
|
|
111
111
|
`bin/packs rename`
|
112
112
|
|
113
113
|
## Set packs/child_pack as a child of packs/parent_pack
|
114
|
-
`bin/packs move_to_parent packs/child_pack packs/parent_pack
|
114
|
+
`bin/packs move_to_parent packs/child_pack packs/parent_pack`
|
115
|
+
|
116
|
+
## Move packs/foo to the some/directory folder, where some/directory does not contain a package.yml file
|
117
|
+
`bin/packs move_to_folder packs/foo some/directory`
|
115
118
|
|
116
119
|
|
117
120
|
## Releasing
|
data/lib/packs/cli.rb
CHANGED
@@ -7,12 +7,16 @@ module Packs
|
|
7
7
|
extend T::Sig
|
8
8
|
|
9
9
|
desc 'create packs/your_pack', 'Create pack with name packs/your_pack'
|
10
|
+
option :enforce_dependencies, type: :boolean, default: nil, aliases: :d, banner: 'Enforce dependencies'
|
10
11
|
option :enforce_privacy, type: :boolean, default: true, aliases: :p, banner: 'Enforce privacy'
|
12
|
+
option :enforce_architecture, type: :boolean, default: true, aliases: :a, banner: 'Enforce architecture'
|
11
13
|
sig { params(pack_name: String).void }
|
12
14
|
def create(pack_name)
|
13
15
|
Packs.create_pack!(
|
14
16
|
pack_name: pack_name,
|
15
|
-
|
17
|
+
enforce_dependencies: options[:enforce_dependencies],
|
18
|
+
enforce_privacy: options[:enforce_privacy],
|
19
|
+
enforce_architecture: options[:enforce_architecture]
|
16
20
|
)
|
17
21
|
exit_successfully
|
18
22
|
end
|
@@ -150,7 +154,7 @@ module Packs
|
|
150
154
|
exit_successfully
|
151
155
|
end
|
152
156
|
|
153
|
-
desc 'move_to_parent packs/child_pack packs/parent_pack
|
157
|
+
desc 'move_to_parent packs/child_pack packs/parent_pack', 'Set packs/child_pack as a child of packs/parent_pack'
|
154
158
|
sig { params(child_pack_name: String, parent_pack_name: String).void }
|
155
159
|
def move_to_parent(child_pack_name, parent_pack_name)
|
156
160
|
Packs.move_to_parent!(
|
@@ -160,6 +164,16 @@ module Packs
|
|
160
164
|
exit_successfully
|
161
165
|
end
|
162
166
|
|
167
|
+
desc 'move_to_folder packs/foo some/directory', 'Move packs/foo to the some/directory folder, where some/directory does not contain a package.yml file'
|
168
|
+
sig { params(pack_name: String, destination: String).void }
|
169
|
+
def move_to_folder(pack_name, destination)
|
170
|
+
Packs.move_to_folder!(
|
171
|
+
pack_name: pack_name,
|
172
|
+
destination: destination
|
173
|
+
)
|
174
|
+
exit_successfully
|
175
|
+
end
|
176
|
+
|
163
177
|
private
|
164
178
|
|
165
179
|
# This is used by thor to know that these private methods are not intended to be CLI commands
|
data/lib/packs/private.rb
CHANGED
@@ -47,12 +47,13 @@ module Packs
|
|
47
47
|
sig do
|
48
48
|
params(
|
49
49
|
pack_name: String,
|
50
|
-
enforce_privacy: T::Boolean,
|
51
50
|
enforce_dependencies: T.nilable(T::Boolean),
|
51
|
+
enforce_privacy: T::Boolean,
|
52
|
+
enforce_architecture: T::Boolean,
|
52
53
|
team: T.nilable(CodeTeams::Team)
|
53
54
|
).void
|
54
55
|
end
|
55
|
-
def self.create_pack!(pack_name:, enforce_privacy:,
|
56
|
+
def self.create_pack!(pack_name:, enforce_dependencies:, enforce_privacy:, enforce_architecture:, team:)
|
56
57
|
Logging.section('👋 Hi!') do
|
57
58
|
intro = Packs.config.user_event_logger.before_create_pack(pack_name)
|
58
59
|
Logging.print_bold_green(intro)
|
@@ -60,7 +61,13 @@ module Packs
|
|
60
61
|
|
61
62
|
pack_name = Private.clean_pack_name(pack_name)
|
62
63
|
|
63
|
-
package = create_pack_if_not_exists!(
|
64
|
+
package = create_pack_if_not_exists!(
|
65
|
+
pack_name: pack_name,
|
66
|
+
enforce_dependencies: enforce_dependencies,
|
67
|
+
enforce_privacy: enforce_privacy,
|
68
|
+
enforce_architecture: enforce_architecture,
|
69
|
+
team: team
|
70
|
+
)
|
64
71
|
add_public_directory(package) if package.enforce_privacy
|
65
72
|
add_readme_todo(package)
|
66
73
|
|
@@ -140,6 +147,85 @@ module Packs
|
|
140
147
|
end
|
141
148
|
end
|
142
149
|
|
150
|
+
sig do
|
151
|
+
params(
|
152
|
+
pack_name: String,
|
153
|
+
destination: String,
|
154
|
+
per_file_processors: T::Array[PerFileProcessorInterface]
|
155
|
+
).void
|
156
|
+
end
|
157
|
+
def self.move_to_folder!(pack_name:, destination:, per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new])
|
158
|
+
pack_name = Private.clean_pack_name(pack_name)
|
159
|
+
package = ParsePackwerk.all.find { |p| p.name == pack_name }
|
160
|
+
if package.nil?
|
161
|
+
raise StandardError, "Can not find package with name #{pack_name}. Make sure the argument is of the form `packs/my_pack/`"
|
162
|
+
end
|
163
|
+
|
164
|
+
# First we create a new pack that has the exact same properties of the old one!
|
165
|
+
package_last_name = package.directory.basename
|
166
|
+
new_package_name = File.join(destination, package_last_name)
|
167
|
+
|
168
|
+
new_package = ParsePackwerk::Package.new(
|
169
|
+
name: new_package_name,
|
170
|
+
enforce_dependencies: package.enforce_dependencies,
|
171
|
+
enforce_privacy: package.enforce_privacy,
|
172
|
+
enforce_architecture: package.enforce_architecture,
|
173
|
+
dependencies: package.dependencies,
|
174
|
+
violations: package.violations,
|
175
|
+
metadata: package.metadata,
|
176
|
+
config: package.config
|
177
|
+
)
|
178
|
+
ParsePackwerk.write_package_yml!(new_package)
|
179
|
+
ParsePackwerk.bust_cache!
|
180
|
+
|
181
|
+
# Move everything from the old pack to the new one
|
182
|
+
move_to_pack!(
|
183
|
+
pack_name: new_package_name,
|
184
|
+
paths_relative_to_root: [package.directory.to_s],
|
185
|
+
per_file_processors: per_file_processors
|
186
|
+
)
|
187
|
+
|
188
|
+
# Then delete the old package.yml and package_todo.yml files
|
189
|
+
package.yml.delete
|
190
|
+
package_todo_file = ParsePackwerk::PackageTodo.for(package).pathname
|
191
|
+
package_todo_file.delete if package_todo_file.exist?
|
192
|
+
|
193
|
+
ParsePackwerk.bust_cache!
|
194
|
+
|
195
|
+
ParsePackwerk.all.each do |other_package|
|
196
|
+
new_dependencies = other_package.dependencies.map { |d| d == pack_name ? new_package_name : d }
|
197
|
+
|
198
|
+
new_config = other_package.config.dup
|
199
|
+
if new_config['ignored_dependencies']
|
200
|
+
new_config['ignored_dependencies'] = new_config['ignored_dependencies'].map do |d|
|
201
|
+
d == pack_name ? new_package_name : d
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
new_other_package = ParsePackwerk::Package.new(
|
206
|
+
name: other_package.name,
|
207
|
+
enforce_dependencies: other_package.enforce_dependencies,
|
208
|
+
enforce_privacy: other_package.enforce_privacy,
|
209
|
+
enforce_architecture: other_package.enforce_architecture,
|
210
|
+
dependencies: new_dependencies.uniq.sort,
|
211
|
+
violations: other_package.violations,
|
212
|
+
metadata: other_package.metadata,
|
213
|
+
config: new_config
|
214
|
+
)
|
215
|
+
|
216
|
+
ParsePackwerk.write_package_yml!(new_other_package)
|
217
|
+
end
|
218
|
+
|
219
|
+
sorbet_config = Pathname.new('sorbet/config')
|
220
|
+
if sorbet_config.exist?
|
221
|
+
Packs.replace_in_file(
|
222
|
+
file: sorbet_config.to_s,
|
223
|
+
find: package.directory.join('spec'),
|
224
|
+
replace_with: new_package.directory.join('spec')
|
225
|
+
)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
143
229
|
sig do
|
144
230
|
params(
|
145
231
|
pack_name: String,
|
@@ -161,7 +247,12 @@ module Packs
|
|
161
247
|
parent_name = Private.clean_pack_name(parent_name)
|
162
248
|
parent_package = ParsePackwerk.all.find { |p| p.name == parent_name }
|
163
249
|
if parent_package.nil?
|
164
|
-
parent_package = create_pack_if_not_exists!(
|
250
|
+
parent_package = create_pack_if_not_exists!(
|
251
|
+
pack_name: parent_name,
|
252
|
+
enforce_dependencies: true,
|
253
|
+
enforce_privacy: true,
|
254
|
+
enforce_architecture: true
|
255
|
+
)
|
165
256
|
end
|
166
257
|
|
167
258
|
# First we create a new pack that has the exact same properties of the old one!
|
@@ -172,6 +263,7 @@ module Packs
|
|
172
263
|
name: new_package_name,
|
173
264
|
enforce_privacy: package.enforce_privacy,
|
174
265
|
enforce_dependencies: package.enforce_dependencies,
|
266
|
+
enforce_architecture: package.enforce_architecture,
|
175
267
|
dependencies: package.dependencies,
|
176
268
|
violations: package.violations,
|
177
269
|
metadata: package.metadata,
|
@@ -212,8 +304,9 @@ module Packs
|
|
212
304
|
|
213
305
|
new_other_package = ParsePackwerk::Package.new(
|
214
306
|
name: other_package.name,
|
215
|
-
enforce_privacy: other_package.enforce_privacy,
|
216
307
|
enforce_dependencies: other_package.enforce_dependencies,
|
308
|
+
enforce_privacy: other_package.enforce_privacy,
|
309
|
+
enforce_architecture: other_package.enforce_architecture,
|
217
310
|
dependencies: new_dependencies.uniq.sort,
|
218
311
|
violations: other_package.violations,
|
219
312
|
metadata: other_package.metadata,
|
@@ -305,6 +398,7 @@ module Packs
|
|
305
398
|
name: pack_name,
|
306
399
|
dependencies: (package.dependencies + [dependency_name]).uniq.sort,
|
307
400
|
enforce_privacy: package.enforce_privacy,
|
401
|
+
enforce_architecture: package.enforce_architecture,
|
308
402
|
enforce_dependencies: package.enforce_dependencies,
|
309
403
|
violations: package.violations,
|
310
404
|
metadata: package.metadata,
|
@@ -370,12 +464,13 @@ module Packs
|
|
370
464
|
sig do
|
371
465
|
params(
|
372
466
|
pack_name: String,
|
373
|
-
enforce_privacy: T::Boolean,
|
374
467
|
enforce_dependencies: T.nilable(T::Boolean),
|
468
|
+
enforce_privacy: T::Boolean,
|
469
|
+
enforce_architecture: T::Boolean,
|
375
470
|
team: T.nilable(CodeTeams::Team)
|
376
471
|
).returns(ParsePackwerk::Package)
|
377
472
|
end
|
378
|
-
def self.create_pack_if_not_exists!(pack_name:, enforce_privacy:,
|
473
|
+
def self.create_pack_if_not_exists!(pack_name:, enforce_dependencies:, enforce_privacy:, enforce_architecture:, team: nil)
|
379
474
|
allowed_locations = Packs::Specification.config.pack_paths
|
380
475
|
if allowed_locations.none? { |location| File.fnmatch(location, pack_name) }
|
381
476
|
raise StandardError, "Packs only supports packages in the the following directories: #{allowed_locations}. Please make sure to pass in the name of the pack including the full directory path, e.g. `packs/my_pack`."
|
@@ -398,6 +493,7 @@ module Packs
|
|
398
493
|
package = ParsePackwerk::Package.new(
|
399
494
|
enforce_dependencies: should_enforce_dependencies || false,
|
400
495
|
enforce_privacy: enforce_privacy,
|
496
|
+
enforce_architecture: enforce_architecture,
|
401
497
|
dependencies: [],
|
402
498
|
violations: [],
|
403
499
|
metadata: {},
|
@@ -105,6 +105,24 @@ module Packs
|
|
105
105
|
MSG
|
106
106
|
end
|
107
107
|
|
108
|
+
sig { params(pack_name: String).returns(String) }
|
109
|
+
def before_move_to_folder(pack_name)
|
110
|
+
<<~MSG
|
111
|
+
You are moving one pack to a new directory. Check out #{documentation_link} for more info!
|
112
|
+
MSG
|
113
|
+
end
|
114
|
+
|
115
|
+
sig { params(pack_name: String).returns(String) }
|
116
|
+
def after_move_to_folder(pack_name)
|
117
|
+
<<~MSG
|
118
|
+
Your next steps might be:
|
119
|
+
|
120
|
+
1) Delete the old pack when things look good: `git rm -r #{pack_name}`
|
121
|
+
|
122
|
+
2) Run `bin/packwerk update-todo` to update the violations. Make sure to run `spring stop` first.
|
123
|
+
MSG
|
124
|
+
end
|
125
|
+
|
108
126
|
sig { params(pack_name: String).returns(String) }
|
109
127
|
def on_create_public_directory_todo(pack_name)
|
110
128
|
<<~MSG
|
data/lib/packs.rb
CHANGED
@@ -49,6 +49,7 @@ module Packs
|
|
49
49
|
params(
|
50
50
|
pack_name: String,
|
51
51
|
enforce_privacy: T::Boolean,
|
52
|
+
enforce_architecture: T::Boolean,
|
52
53
|
enforce_dependencies: T.nilable(T::Boolean),
|
53
54
|
team: T.nilable(CodeTeams::Team)
|
54
55
|
).void
|
@@ -56,6 +57,7 @@ module Packs
|
|
56
57
|
def self.create_pack!(
|
57
58
|
pack_name:,
|
58
59
|
enforce_privacy: true,
|
60
|
+
enforce_architecture: true,
|
59
61
|
enforce_dependencies: nil,
|
60
62
|
team: nil
|
61
63
|
)
|
@@ -63,6 +65,7 @@ module Packs
|
|
63
65
|
pack_name: pack_name,
|
64
66
|
enforce_privacy: enforce_privacy,
|
65
67
|
enforce_dependencies: enforce_dependencies,
|
68
|
+
enforce_architecture: enforce_architecture,
|
66
69
|
team: team
|
67
70
|
)
|
68
71
|
end
|
@@ -178,6 +181,36 @@ module Packs
|
|
178
181
|
end
|
179
182
|
end
|
180
183
|
|
184
|
+
sig do
|
185
|
+
params(
|
186
|
+
pack_name: String,
|
187
|
+
destination: String,
|
188
|
+
per_file_processors: T::Array[PerFileProcessorInterface]
|
189
|
+
).void
|
190
|
+
end
|
191
|
+
def self.move_to_folder!(
|
192
|
+
pack_name:,
|
193
|
+
destination:,
|
194
|
+
per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]
|
195
|
+
)
|
196
|
+
Logging.section('👋 Hi!') do
|
197
|
+
intro = Packs.config.user_event_logger.before_move_to_folder(pack_name)
|
198
|
+
Logging.print_bold_green(intro)
|
199
|
+
end
|
200
|
+
|
201
|
+
Private.move_to_folder!(
|
202
|
+
pack_name: pack_name,
|
203
|
+
destination: destination,
|
204
|
+
per_file_processors: per_file_processors
|
205
|
+
)
|
206
|
+
|
207
|
+
Logging.section('Next steps') do
|
208
|
+
next_steps = Packs.config.user_event_logger.after_move_to_folder(pack_name)
|
209
|
+
|
210
|
+
Logging.print_bold_green(next_steps)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
181
214
|
sig do
|
182
215
|
params(
|
183
216
|
type: String,
|
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.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_ownership
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.22.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.22.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rainbow
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -314,7 +314,7 @@ metadata:
|
|
314
314
|
source_code_uri: https://github.com/rubyatscale/packs
|
315
315
|
changelog_uri: https://github.com/rubyatscale/packs/releases
|
316
316
|
allowed_push_host: https://rubygems.org
|
317
|
-
post_install_message:
|
317
|
+
post_install_message:
|
318
318
|
rdoc_options: []
|
319
319
|
require_paths:
|
320
320
|
- lib
|
@@ -329,8 +329,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
329
|
- !ruby/object:Gem::Version
|
330
330
|
version: '0'
|
331
331
|
requirements: []
|
332
|
-
rubygems_version: 3.
|
333
|
-
signing_key:
|
332
|
+
rubygems_version: 3.4.10
|
333
|
+
signing_key:
|
334
334
|
specification_version: 4
|
335
335
|
summary: Provides CLI tools for working with ruby packs.
|
336
336
|
test_files: []
|