label_weaver 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 290288a3de5f82f2011f9dbd603e6b9f8ee369bb64ffdc77c544004f4dc6e5e8
4
- data.tar.gz: 9377d8b8a5a46c8630a9d0f3ba6e38189ff68dd1679b84cc6b4a2bdc1058c11a
3
+ metadata.gz: c0e81d732a25f3c7ed75a3c975633aefcefe0ba5b0c6c33fbb2565d31469e3f4
4
+ data.tar.gz: c90c1d33620e1b5c76aac616db225c431fe350f0a2a7cd935a6e77d29b6e4af9
5
5
  SHA512:
6
- metadata.gz: 8b12f4ed0bb7cef83d3066680a623ba9d8ef03b67ea643b684ba985aee57e7d1502b573519d242942dc01f1af91a422c79ae605eada47d4510265c874924e9c8
7
- data.tar.gz: 1cf1ff573c45a3972e46dce59bca1f432aec28e7f275ce15c0dcd98401f0f75b54063aae5db24763339a275b0329eab77ae2b022e53fc6b09ed9b81a702282fd
6
+ metadata.gz: 02ebb42b5c87d1ad2e4a5eeadb0d7baf731566144f0296b853345fbe83d292083fa5b1ff7f63ac07a9538bca53bf247aa0732d7f3306a92153382a8c0ae956c7
7
+ data.tar.gz: 78c68d51a19bfc52cc16993bf02b758f5759027f90044d066818a742c541bf45cc7106b0563b0365ff54ee8d6effa2daafa2acbb3ab110b2166037bb408df11c
data/label_weaver.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "label_weaver"
5
- spec.version = "0.0.10"
5
+ spec.version = "0.0.11"
6
6
  spec.authors = ["Stefan Exner"]
7
7
  spec.email = ["stex@stex.codes"]
8
8
  spec.homepage = "https://gitlab.com/lopo-tech/label_weaver"
@@ -23,7 +23,7 @@ module LabelWeaver
23
23
  end
24
24
 
25
25
  Hooks.new.run(:develop, :before_start)
26
- repo.clone_or_update
26
+ repo.clone_or_update(always_clone: configuration.always_clone)
27
27
  copy_repository_files
28
28
  handle_file_merges
29
29
  Hooks.new.run(:develop, :after_start)
@@ -0,0 +1,17 @@
1
+ module LabelWeaver
2
+ module CLI
3
+ module Actions
4
+ class PrintConfiguration < Sod::Action
5
+ include Import[:logger, :configuration]
6
+
7
+ on "--print-configuration"
8
+
9
+ description "Prints out the currently active configuration after evaluation"
10
+
11
+ def call(*)
12
+ puts JSON.pretty_generate(configuration.to_h)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -26,6 +26,7 @@ module LabelWeaver
26
26
  dsl.new :label_weaver, banner: specification.banner do
27
27
  on(::LabelWeaver::CLI::Actions::Init, context:)
28
28
  on(::LabelWeaver::CLI::Actions::PrepareBaseProject, context:)
29
+ on(::LabelWeaver::CLI::Actions::PrintConfiguration, context:)
29
30
  on(::LabelWeaver::CLI::Commands::Develop, context:)
30
31
  on(::LabelWeaver::CLI::Commands::Diff, context:)
31
32
  on(Sod::Prefabs::Actions::Version, context:)
@@ -9,6 +9,7 @@ module LabelWeaver
9
9
  required(:repository).filled(:string)
10
10
  required(:branch).filled(:string)
11
11
  end
12
+ optional(:always_clone).filled(:bool)
12
13
  optional(:excluded_upstream_files).array(:string)
13
14
  optional(:forced_upstream_files).array(:string)
14
15
  optional(:hooks).hash do
@@ -1,7 +1,18 @@
1
+ # This is the main configuration file for label_weaver in your project.
2
+ # It is parsed as ERb, feel free to use e.g. environment variables like
3
+ # "<%= ENV['BRANCH_NAME'] %>" or conditionals.
4
+ # The result still has to be valid YAML though.
5
+
1
6
  git:
2
7
  repository: "git@gitlab.com:lopo-tech/label_weaver.git"
3
8
  branch: "main"
4
9
 
10
+ # If set to +true+, the upstream repository is always cloned
11
+ # instead of the newest changes being pulled for an already cloned repository.
12
+ # This is useful if you change the upstream branch a lot and want to make
13
+ # sure you always have a clean state.
14
+ # always_clone: false
15
+
5
16
  # Files to exclude from the upstream repository, they will not be copied over to the whitelabel project.
6
17
  # Shell filename globbing rules apply, not regular expressions
7
18
  #excluded_upstream_files:
@@ -4,13 +4,14 @@ module LabelWeaver
4
4
  module Configuration
5
5
  # Defines the configuration model for use throughout the gem.
6
6
  Model = Data.define(
7
+ :always_clone,
7
8
  :excluded_upstream_files,
8
9
  :git,
9
10
  :hooks,
10
11
  :merges,
11
12
  :forced_upstream_files
12
13
  ) do
13
- def initialize(git:, hooks: {}, excluded_upstream_files: [], forced_upstream_files: [], merges: [])
14
+ def initialize(git:, always_clone: false, hooks: {}, excluded_upstream_files: [], forced_upstream_files: [], merges: [])
14
15
  super
15
16
  end
16
17
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "erb"
3
4
  require "cogger"
4
5
  require "containable"
5
6
  require "runcom"
@@ -12,7 +13,10 @@ module LabelWeaver
12
13
 
13
14
  register :configuration do
14
15
  if self[:xdg_config].active
15
- data = self[:defaults].merge(YAML.load_file(self[:xdg_config].active, symbolize_names: true))
16
+ configuration_file = File.read(self[:xdg_config].active)
17
+ config = ERB.new(configuration_file).result
18
+
19
+ data = self[:defaults].merge(YAML.load(config, symbolize_names: true))
16
20
  contract = Configuration::Contract.call(**data)
17
21
 
18
22
  raise ArgumentError.new(contract.errors.to_h) if contract.failure?
@@ -45,7 +45,12 @@ module LabelWeaver
45
45
  #
46
46
  # Clones the repository if it doesn't exist yet locally or fetches the latest updates
47
47
  #
48
- def clone_or_update
48
+ def clone_or_update(always_clone: false)
49
+ if always_clone
50
+ logger.info "Set to always clone the repository. Deleting any previously checked out version..."
51
+ FileUtils.rm_rf(repository_path)
52
+ end
53
+
49
54
  if repository_path.exist?
50
55
  logger.info "Pulling latest changes from remote repository (#{repository_url})..."
51
56
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: label_weaver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Exner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-13 00:00:00.000000000 Z
11
+ date: 2024-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cogger
@@ -239,6 +239,7 @@ files:
239
239
  - lib/label_weaver/cli/actions/diff/format.rb
240
240
  - lib/label_weaver/cli/actions/init.rb
241
241
  - lib/label_weaver/cli/actions/prepare_base_project.rb
242
+ - lib/label_weaver/cli/actions/print_configuration.rb
242
243
  - lib/label_weaver/cli/commands/develop.rb
243
244
  - lib/label_weaver/cli/commands/diff.rb
244
245
  - lib/label_weaver/cli/shell.rb