ddenv 0.1.1 → 0.1.2
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/.rubocop.yml +3 -0
 - data/CHANGELOG.md +5 -0
 - data/README.md +22 -9
 - data/TODO.md +6 -0
 - data/ddenv.yaml +4 -1
 - data/lib/ddenv/cli.rb +19 -15
 - data/lib/ddenv/commands/up.rb +1 -1
 - data/lib/ddenv/config.rb +10 -3
 - data/lib/ddenv/goals/bundle_installed.rb +31 -0
 - data/lib/ddenv/goals/gem_installed.rb +32 -0
 - data/lib/ddenv/goals/node_build_installed.rb +11 -0
 - data/lib/ddenv/goals/node_installed.rb +47 -0
 - data/lib/ddenv/goals/node_shadowenv_created.rb +52 -0
 - data/lib/ddenv/goals/npm_packages_installed.rb +26 -0
 - data/lib/ddenv/goals/ruby_installed.rb +9 -14
 - data/lib/ddenv/goals/ruby_shadowenv_created.rb +5 -0
 - data/lib/ddenv/version.rb +1 -1
 - data/lib/ddenv.rb +8 -1
 - data/package-lock.json +870 -0
 - data/package.json +22 -0
 - metadata +24 -2
 - data/lib/ddenv/commands/help.rb +0 -12
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: be59b284b001642fbf169fb71a0c6887b2a54c4747ef52c0cc695b6b6621f7eb
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b140aa2607964e48d50555420db3d038cc1e9306ce46147e5657e97c4f2c06bd
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e59e6c7ef5f3e64ccd0962475e0137912009188b2cff521d39dc4bfacfb8645542ae432299aeefda5af817dfdb4b8999cc75186af8ef66ea79b8c15d947ac4f6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: cdcffc2846efe163d628f6ac677533e12cd8501783d72fb8ee6f5f09cb2bd37d166ca7b37628a4b2d6321762b5f902533668ca137134458506135305710d2f36
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -24,20 +24,29 @@ Next, create a `ddenv.yaml` file which contains the list of dependencies to mana 
     | 
|
| 
       24 
24 
     | 
    
         
             
            up:
         
     | 
| 
       25 
25 
     | 
    
         
             
              - homebrew: overmind
         
     | 
| 
       26 
26 
     | 
    
         
             
              - ruby: 3.3.0
         
     | 
| 
      
 27 
     | 
    
         
            +
              - bundle
         
     | 
| 
      
 28 
     | 
    
         
            +
              - node: 20.12.2
         
     | 
| 
      
 29 
     | 
    
         
            +
              - npm
         
     | 
| 
       27 
30 
     | 
    
         
             
            ```
         
     | 
| 
       28 
31 
     | 
    
         | 
| 
       29 
32 
     | 
    
         
             
            Lastly, run `ddenv up`.
         
     | 
| 
       30 
33 
     | 
    
         | 
| 
       31 
34 
     | 
    
         
             
            ```
         
     | 
| 
       32 
35 
     | 
    
         
             
            % ddenv up
         
     | 
| 
       33 
     | 
    
         
            -
            [✔] Installing Homebrew package overmind 
     | 
| 
       34 
     | 
    
         
            -
            [✔] Installing Homebrew package ruby-install 
     | 
| 
       35 
     | 
    
         
            -
            [✔] Installing Ruby v3.3.0 
     | 
| 
       36 
     | 
    
         
            -
            [✔] Initializing Shadowenv 
     | 
| 
       37 
     | 
    
         
            -
            [✔] Creating .shadowenv.d 
     | 
| 
       38 
     | 
    
         
            -
            [✔] Adding .shadowenv.d to .gitignore 
     | 
| 
       39 
     | 
    
         
            -
            [✔] Trusting .shadowenv.d 
     | 
| 
       40 
     | 
    
         
            -
            [✔] Adding Ruby to shadowenv 
     | 
| 
      
 36 
     | 
    
         
            +
            [✔] Installing Homebrew package overmind       done (previously achieved)
         
     | 
| 
      
 37 
     | 
    
         
            +
            [✔] Installing Homebrew package ruby-install   done (previously achieved)
         
     | 
| 
      
 38 
     | 
    
         
            +
            [✔] Installing Ruby v3.3.0                     done (previously achieved)
         
     | 
| 
      
 39 
     | 
    
         
            +
            [✔] Initializing Shadowenv                     done (previously achieved)
         
     | 
| 
      
 40 
     | 
    
         
            +
            [✔] Creating .shadowenv.d                      done (previously achieved)
         
     | 
| 
      
 41 
     | 
    
         
            +
            [✔] Adding .shadowenv.d to .gitignore          done (previously achieved)
         
     | 
| 
      
 42 
     | 
    
         
            +
            [✔] Trusting .shadowenv.d                      done (previously achieved)
         
     | 
| 
      
 43 
     | 
    
         
            +
            [✔] Adding Ruby to shadowenv                   done (previously achieved)
         
     | 
| 
      
 44 
     | 
    
         
            +
            [✔] Installing Ruby gem bundler                done (previously achieved)
         
     | 
| 
      
 45 
     | 
    
         
            +
            [✔] Installing bundle                          done (previously achieved)
         
     | 
| 
      
 46 
     | 
    
         
            +
            [✔] Installing Homebrew package node-build     done (previously achieved)
         
     | 
| 
      
 47 
     | 
    
         
            +
            [✔] Installing Node v20.12.2                   done (previously achieved)
         
     | 
| 
      
 48 
     | 
    
         
            +
            [✔] Adding Node to shadowenv                   done (previously achieved)
         
     | 
| 
      
 49 
     | 
    
         
            +
            [✔] Installing npm packages                    done (previously achieved)
         
     | 
| 
       41 
50 
     | 
    
         
             
            %
         
     | 
| 
       42 
51 
     | 
    
         
             
            ```
         
     | 
| 
       43 
52 
     | 
    
         | 
| 
         @@ -46,4 +55,8 @@ Now your local developer environment is ready to be used. 
     | 
|
| 
       46 
55 
     | 
    
         
             
            ## Goals
         
     | 
| 
       47 
56 
     | 
    
         | 
| 
       48 
57 
     | 
    
         
             
            - <code>homebrew: <var>PACKAGENAME</var></code> installs the Homebrew package with the given name.
         
     | 
| 
       49 
     | 
    
         
            -
            - <code>ruby 
     | 
| 
      
 58 
     | 
    
         
            +
            - <code>ruby</code> installs Ruby (with the version specified in the `.ruby-version`
         
     | 
| 
      
 59 
     | 
    
         
            +
              file).
         
     | 
| 
      
 60 
     | 
    
         
            +
            - <code>bundle</code> runs `bundle install`.
         
     | 
| 
      
 61 
     | 
    
         
            +
            - <code>node: <var>VERSION</var></code> installs the give Node.js version.
         
     | 
| 
      
 62 
     | 
    
         
            +
            - <code>npm</code> installs packages from package.json using npm.
         
     | 
    
        data/TODO.md
    ADDED
    
    
    
        data/ddenv.yaml
    CHANGED
    
    
    
        data/lib/ddenv/cli.rb
    CHANGED
    
    | 
         @@ -2,26 +2,30 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module Ddenv
         
     | 
| 
       4 
4 
     | 
    
         
             
              class CLI
         
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 5 
     | 
    
         
            +
                ROOT_CMD = Cri::Command.new_basic_root.modify do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  name        "ddenv"
         
     | 
| 
      
 7 
     | 
    
         
            +
                  usage       "ddenv [options] [command] [options]"
         
     | 
| 
      
 8 
     | 
    
         
            +
                  summary     "manage developer environment"
         
     | 
| 
      
 9 
     | 
    
         
            +
                  description "Manages your local developer environment."
         
     | 
| 
       7 
10 
     | 
    
         
             
                end
         
     | 
| 
       8 
11 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                   
     | 
| 
      
 12 
     | 
    
         
            +
                ROOT_CMD.define_command("up") do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  name        "up"
         
     | 
| 
      
 14 
     | 
    
         
            +
                  usage       "up [options]"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  summary     "bring up developer environment"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  description "Brings up the local developer environment to be in line what is described in the ddenv.yaml configuration file."
         
     | 
| 
       14 
17 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
                  case command_name
         
     | 
| 
       17 
     | 
    
         
            -
                  when "help"
         
     | 
| 
       18 
     | 
    
         
            -
                    Ddenv::Commands::Help.new.call
         
     | 
| 
       19 
     | 
    
         
            -
                  when "up"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  run do |_opts, _args, _cmd|
         
     | 
| 
       20 
19 
     | 
    
         
             
                    Ddenv::Commands::Up.new.call
         
     | 
| 
       21 
     | 
    
         
            -
                  else
         
     | 
| 
       22 
     | 
    
         
            -
                    warn "ddenv: unknown command: #{command_name}"
         
     | 
| 
       23 
     | 
    
         
            -
                    exit 64 # EX_USAGE
         
     | 
| 
       24 
20 
     | 
    
         
             
                  end
         
     | 
| 
       25 
21 
     | 
    
         
             
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                def initialize(args)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @args = args
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                def call
         
     | 
| 
      
 28 
     | 
    
         
            +
                  ROOT_CMD.run(@args)
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
       26 
30 
     | 
    
         
             
              end
         
     | 
| 
       27 
31 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ddenv/commands/up.rb
    CHANGED
    
    | 
         @@ -11,7 +11,7 @@ module Ddenv 
     | 
|
| 
       11 
11 
     | 
    
         
             
                    max_message_size = all_goals.map { _1.message.size }.max
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                    all_goals.each do |goal|
         
     | 
| 
       14 
     | 
    
         
            -
                      spinner = TTY::Spinner.new("[:spinner] :message 
     | 
| 
      
 14 
     | 
    
         
            +
                      spinner = TTY::Spinner.new("[:spinner] :message   :title")
         
     | 
| 
       15 
15 
     | 
    
         
             
                      spinner.update(message: format("%-#{max_message_size}s", goal.message))
         
     | 
| 
       16 
16 
     | 
    
         
             
                      spinner.update(title: "checking")
         
     | 
| 
       17 
17 
     | 
    
         
             
                      spinner.auto_spin
         
     | 
    
        data/lib/ddenv/config.rb
    CHANGED
    
    | 
         @@ -19,15 +19,22 @@ module Ddenv 
     | 
|
| 
       19 
19 
     | 
    
         
             
                      when Hash
         
     | 
| 
       20 
20 
     | 
    
         
             
                        [element.keys.first, element.values.first]
         
     | 
| 
       21 
21 
     | 
    
         
             
                      when String
         
     | 
| 
       22 
     | 
    
         
            -
                         
     | 
| 
       23 
     | 
    
         
            -
                        # (when a goal has no extra details)
         
     | 
| 
      
 22 
     | 
    
         
            +
                        [element, nil]
         
     | 
| 
       24 
23 
     | 
    
         
             
                      end
         
     | 
| 
       25 
24 
     | 
    
         | 
| 
       26 
25 
     | 
    
         
             
                    case key
         
     | 
| 
       27 
26 
     | 
    
         
             
                    when "homebrew"
         
     | 
| 
       28 
27 
     | 
    
         
             
                      Goals::HomebrewPackageInstalled.new(value)
         
     | 
| 
       29 
28 
     | 
    
         
             
                    when "ruby"
         
     | 
| 
       30 
     | 
    
         
            -
                      Goals::RubyInstalled.new 
     | 
| 
      
 29 
     | 
    
         
            +
                      Goals::RubyInstalled.new
         
     | 
| 
      
 30 
     | 
    
         
            +
                    when "node"
         
     | 
| 
      
 31 
     | 
    
         
            +
                      Goals::NodeInstalled.new(value)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    when "bundle"
         
     | 
| 
      
 33 
     | 
    
         
            +
                      Goals::BundleInstalled.new
         
     | 
| 
      
 34 
     | 
    
         
            +
                    when "npm"
         
     | 
| 
      
 35 
     | 
    
         
            +
                      Goals::NpmPackesInstalled.new
         
     | 
| 
      
 36 
     | 
    
         
            +
                    else
         
     | 
| 
      
 37 
     | 
    
         
            +
                      raise "unknown key: #{key}"
         
     | 
| 
       31 
38 
     | 
    
         
             
                    end
         
     | 
| 
       32 
39 
     | 
    
         
             
                  end
         
     | 
| 
       33 
40 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Ddenv
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Goals
         
     | 
| 
      
 5 
     | 
    
         
            +
                class BundleInstalled < Goal
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def message
         
     | 
| 
      
 7 
     | 
    
         
            +
                    "Installing bundle"
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  def achieved?
         
     | 
| 
      
 11 
     | 
    
         
            +
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    cmd.run("shadowenv", "exec", "--", "bundle", "check")
         
     | 
| 
      
 13 
     | 
    
         
            +
                    true
         
     | 
| 
      
 14 
     | 
    
         
            +
                  rescue StandardError
         
     | 
| 
      
 15 
     | 
    
         
            +
                    false
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def achieve
         
     | 
| 
      
 19 
     | 
    
         
            +
                    # TODO: use :pretty when passing --verbose
         
     | 
| 
      
 20 
     | 
    
         
            +
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    cmd.run("shadowenv", "exec", "--", "bundle", "install")
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def pre_goals
         
     | 
| 
      
 25 
     | 
    
         
            +
                    [
         
     | 
| 
      
 26 
     | 
    
         
            +
                      GemInstalled.new("bundler")
         
     | 
| 
      
 27 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Ddenv
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Goals
         
     | 
| 
      
 5 
     | 
    
         
            +
                class GemInstalled < Goal
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def initialize(gem_name)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    super()
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @gem_name = gem_name
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  def message
         
     | 
| 
      
 12 
     | 
    
         
            +
                    "Installing Ruby gem #{@gem_name}"
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def achieved?
         
     | 
| 
      
 16 
     | 
    
         
            +
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    stdout, _stderr = cmd.run("shadowenv", "exec", "--", "gem", "list", "-i", "^#{@gem_name}$")
         
     | 
| 
      
 18 
     | 
    
         
            +
                    stdout.chomp == "true"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def achieve
         
     | 
| 
      
 22 
     | 
    
         
            +
                    # TODO: use :pretty when passing --verbose
         
     | 
| 
      
 23 
     | 
    
         
            +
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    cmd.run("shadowenv", "exec", "--", "gem", "install", @gem_name)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  def props
         
     | 
| 
      
 28 
     | 
    
         
            +
                    [@gem_name]
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Ddenv
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Goals
         
     | 
| 
      
 5 
     | 
    
         
            +
                class NodeInstalled < Goal
         
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :node_version
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  def initialize(node_version)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    super()
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    @node_version = node_version.to_s
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def message
         
     | 
| 
      
 15 
     | 
    
         
            +
                    "Installing Node v#{node_version}"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def achieved?
         
     | 
| 
      
 19 
     | 
    
         
            +
                    node_pathname.directory?
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def achieve
         
     | 
| 
      
 23 
     | 
    
         
            +
                    # TODO: use :pretty when passing --verbose
         
     | 
| 
      
 24 
     | 
    
         
            +
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    cmd.run("node-build", node_version, node_pathname.to_s)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  def pre_goals
         
     | 
| 
      
 29 
     | 
    
         
            +
                    [
         
     | 
| 
      
 30 
     | 
    
         
            +
                      NodeBuildInstalled.new
         
     | 
| 
      
 31 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def post_goals
         
     | 
| 
      
 35 
     | 
    
         
            +
                    [
         
     | 
| 
      
 36 
     | 
    
         
            +
                      NodeShadowenvCreated.new(node_version, node_pathname.to_s)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  private
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  def node_pathname
         
     | 
| 
      
 43 
     | 
    
         
            +
                    @_node_pathname ||= Pathname.new(Dir.home) / ".node-versions" / node_version
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,52 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Ddenv
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Goals
         
     | 
| 
      
 5 
     | 
    
         
            +
                class NodeShadowenvCreated < Goal
         
     | 
| 
      
 6 
     | 
    
         
            +
                  PATH = ".shadowenv.d/20_node.lisp"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  def initialize(node_version, node_path)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    super()
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    @node_version = node_version
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @node_path = node_path
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def message
         
     | 
| 
      
 16 
     | 
    
         
            +
                    "Adding Node to shadowenv"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  def achieved?
         
     | 
| 
      
 20 
     | 
    
         
            +
                    File.file?(PATH) && File.read(PATH) == shadowenv_contents
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  def achieve
         
     | 
| 
      
 24 
     | 
    
         
            +
                    File.write(PATH, shadowenv_contents)
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    # TODO: use :pretty when passing --verbose
         
     | 
| 
      
 27 
     | 
    
         
            +
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    cmd.run("shadowenv", "trust")
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def pre_goals
         
     | 
| 
      
 32 
     | 
    
         
            +
                    [
         
     | 
| 
      
 33 
     | 
    
         
            +
                      Ddenv::Goals::ShadowenvDirCreated.new
         
     | 
| 
      
 34 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  def props
         
     | 
| 
      
 38 
     | 
    
         
            +
                    [@node_version, @node_path]
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  private
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  def shadowenv_contents
         
     | 
| 
      
 44 
     | 
    
         
            +
                    <<~CONTENTS
         
     | 
| 
      
 45 
     | 
    
         
            +
                      (provide "node" "#{@node_version}")
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                      (env/prepend-to-pathlist "PATH" "#{@node_path}/bin")
         
     | 
| 
      
 48 
     | 
    
         
            +
                    CONTENTS
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Ddenv
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Goals
         
     | 
| 
      
 5 
     | 
    
         
            +
                class NpmPackesInstalled < Goal
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def message
         
     | 
| 
      
 7 
     | 
    
         
            +
                    "Installing npm packages"
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  def achieved?
         
     | 
| 
      
 11 
     | 
    
         
            +
                    # TODO: use :pretty when passing --verbose
         
     | 
| 
      
 12 
     | 
    
         
            +
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    cmd.run("shadowenv", "exec", "--", "npx", "check-dependencies")
         
     | 
| 
      
 14 
     | 
    
         
            +
                    true
         
     | 
| 
      
 15 
     | 
    
         
            +
                  rescue StandardError
         
     | 
| 
      
 16 
     | 
    
         
            +
                    false
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  def achieve
         
     | 
| 
      
 20 
     | 
    
         
            +
                    # TODO: use :pretty when passing --verbose
         
     | 
| 
      
 21 
     | 
    
         
            +
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    cmd.run("shadowenv", "exec", "--", "npm", "install")
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -3,24 +3,19 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module Ddenv
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Goals
         
     | 
| 
       5 
5 
     | 
    
         
             
                class RubyInstalled < Goal
         
     | 
| 
       6 
     | 
    
         
            -
                  def initialize(ruby_version)
         
     | 
| 
       7 
     | 
    
         
            -
                    super()
         
     | 
| 
       8 
     | 
    
         
            -
                    @ruby_version = ruby_version
         
     | 
| 
       9 
     | 
    
         
            -
                  end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
6 
     | 
    
         
             
                  def message
         
     | 
| 
       12 
     | 
    
         
            -
                    "Installing Ruby v#{ 
     | 
| 
      
 7 
     | 
    
         
            +
                    "Installing Ruby v#{ruby_version}"
         
     | 
| 
       13 
8 
     | 
    
         
             
                  end
         
     | 
| 
       14 
9 
     | 
    
         | 
| 
       15 
10 
     | 
    
         
             
                  def achieved?
         
     | 
| 
       16 
     | 
    
         
            -
                    pathname = Pathname.new(Dir.home) / ".rubies" / "ruby-#{ 
     | 
| 
      
 11 
     | 
    
         
            +
                    pathname = Pathname.new(Dir.home) / ".rubies" / "ruby-#{ruby_version}"
         
     | 
| 
       17 
12 
     | 
    
         
             
                    pathname.directory?
         
     | 
| 
       18 
13 
     | 
    
         
             
                  end
         
     | 
| 
       19 
14 
     | 
    
         | 
| 
       20 
15 
     | 
    
         
             
                  def achieve
         
     | 
| 
       21 
16 
     | 
    
         
             
                    # TODO: use :pretty when passing --verbose
         
     | 
| 
       22 
17 
     | 
    
         
             
                    cmd = TTY::Command.new(printer: :null)
         
     | 
| 
       23 
     | 
    
         
            -
                    cmd.run("ruby-install", "--cleanup",  
     | 
| 
      
 18 
     | 
    
         
            +
                    cmd.run("ruby-install", "--cleanup", ruby_version)
         
     | 
| 
       24 
19 
     | 
    
         
             
                  end
         
     | 
| 
       25 
20 
     | 
    
         | 
| 
       26 
21 
     | 
    
         
             
                  def pre_goals
         
     | 
| 
         @@ -31,18 +26,18 @@ module Ddenv 
     | 
|
| 
       31 
26 
     | 
    
         | 
| 
       32 
27 
     | 
    
         
             
                  def post_goals
         
     | 
| 
       33 
28 
     | 
    
         
             
                    [
         
     | 
| 
       34 
     | 
    
         
            -
                      RubyShadowenvCreated.new(ruby_pathname.to_s 
     | 
| 
      
 29 
     | 
    
         
            +
                      RubyShadowenvCreated.new(ruby_version, ruby_pathname.to_s)
         
     | 
| 
       35 
30 
     | 
    
         
             
                    ]
         
     | 
| 
       36 
31 
     | 
    
         
             
                  end
         
     | 
| 
       37 
32 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
                  def props
         
     | 
| 
       39 
     | 
    
         
            -
                    [@ruby_version]
         
     | 
| 
       40 
     | 
    
         
            -
                  end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
33 
     | 
    
         
             
                  private
         
     | 
| 
       43 
34 
     | 
    
         | 
| 
      
 35 
     | 
    
         
            +
                  def ruby_version
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @_ruby_version ||= File.read(".ruby-version").chomp
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       44 
39 
     | 
    
         
             
                  def ruby_pathname
         
     | 
| 
       45 
     | 
    
         
            -
                    @_ruby_pathname ||= Pathname.new(Dir.home) / ".rubies" / "ruby-#{ 
     | 
| 
      
 40 
     | 
    
         
            +
                    @_ruby_pathname ||= Pathname.new(Dir.home) / ".rubies" / "ruby-#{ruby_version}"
         
     | 
| 
       46 
41 
     | 
    
         
             
                  end
         
     | 
| 
       47 
42 
     | 
    
         
             
                end
         
     | 
| 
       48 
43 
     | 
    
         
             
              end
         
     | 
| 
         @@ -7,6 +7,7 @@ module Ddenv 
     | 
|
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(ruby_version, ruby_path)
         
     | 
| 
       9 
9 
     | 
    
         
             
                    super()
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       10 
11 
     | 
    
         
             
                    @ruby_version = ruby_version
         
     | 
| 
       11 
12 
     | 
    
         
             
                    @ruby_path = ruby_path
         
     | 
| 
       12 
13 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -33,6 +34,10 @@ module Ddenv 
     | 
|
| 
       33 
34 
     | 
    
         
             
                    ]
         
     | 
| 
       34 
35 
     | 
    
         
             
                  end
         
     | 
| 
       35 
36 
     | 
    
         | 
| 
      
 37 
     | 
    
         
            +
                  def props
         
     | 
| 
      
 38 
     | 
    
         
            +
                    [@ruby_version, @ruby_path]
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       36 
41 
     | 
    
         
             
                  private
         
     | 
| 
       37 
42 
     | 
    
         | 
| 
       38 
43 
     | 
    
         
             
                  def shadowenv_contents
         
     | 
    
        data/lib/ddenv/version.rb
    CHANGED
    
    
    
        data/lib/ddenv.rb
    CHANGED
    
    | 
         @@ -1,8 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require "json"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "pathname"
         
     | 
| 
       4 
5 
     | 
    
         
             
            require "yaml"
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
      
 7 
     | 
    
         
            +
            require "cri"
         
     | 
| 
       6 
8 
     | 
    
         
             
            require "tty-command"
         
     | 
| 
       7 
9 
     | 
    
         
             
            require "tty-spinner"
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
         @@ -14,13 +16,18 @@ require_relative "ddenv/homebrew" 
     | 
|
| 
       14 
16 
     | 
    
         
             
            require_relative "ddenv/subclass_responsibility_error"
         
     | 
| 
       15 
17 
     | 
    
         
             
            require_relative "ddenv/version"
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            require_relative "ddenv/commands/help"
         
     | 
| 
       18 
19 
     | 
    
         
             
            require_relative "ddenv/commands/up"
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
            require_relative "ddenv/goals/homebrew_package_installed"
         
     | 
| 
       21 
22 
     | 
    
         
             
            require_relative "ddenv/goals/ruby_install_installed"
         
     | 
| 
       22 
23 
     | 
    
         
             
            require_relative "ddenv/goals/ruby_installed"
         
     | 
| 
       23 
24 
     | 
    
         
             
            require_relative "ddenv/goals/ruby_shadowenv_created"
         
     | 
| 
      
 25 
     | 
    
         
            +
            require_relative "ddenv/goals/bundle_installed"
         
     | 
| 
      
 26 
     | 
    
         
            +
            require_relative "ddenv/goals/gem_installed"
         
     | 
| 
      
 27 
     | 
    
         
            +
            require_relative "ddenv/goals/node_build_installed"
         
     | 
| 
      
 28 
     | 
    
         
            +
            require_relative "ddenv/goals/node_installed"
         
     | 
| 
      
 29 
     | 
    
         
            +
            require_relative "ddenv/goals/npm_packages_installed"
         
     | 
| 
      
 30 
     | 
    
         
            +
            require_relative "ddenv/goals/node_shadowenv_created"
         
     | 
| 
       24 
31 
     | 
    
         
             
            require_relative "ddenv/goals/shadowenv_initialized"
         
     | 
| 
       25 
32 
     | 
    
         
             
            require_relative "ddenv/goals/shadowenv_dir_created"
         
     | 
| 
       26 
33 
     | 
    
         
             
            require_relative "ddenv/goals/shadowenv_dir_git_ignored"
         
     |