dip 4.2.0 → 7.0.0
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 +85 -42
- data/exe/dip +8 -8
- data/lib/dip.rb +2 -2
- data/lib/dip/cli.rb +47 -33
- data/lib/dip/cli/base.rb +11 -0
- data/lib/dip/cli/console.rb +9 -8
- data/lib/dip/cli/dns.rb +33 -32
- data/lib/dip/cli/nginx.rb +27 -26
- data/lib/dip/cli/ssh.rb +27 -23
- data/lib/dip/command.rb +8 -7
- data/lib/dip/commands/compose.rb +21 -16
- data/lib/dip/commands/console.rb +6 -6
- data/lib/dip/commands/dns.rb +7 -7
- data/lib/dip/commands/list.rb +3 -3
- data/lib/dip/commands/nginx.rb +4 -4
- data/lib/dip/commands/provision.rb +1 -1
- data/lib/dip/commands/run.rb +44 -19
- data/lib/dip/commands/ssh.rb +13 -5
- data/lib/dip/config.rb +73 -15
- data/lib/dip/environment.rb +24 -8
- data/lib/dip/ext/hash.rb +1 -1
- data/lib/dip/interaction_tree.rb +3 -16
- data/lib/dip/version.rb +1 -1
- metadata +46 -12
    
        data/lib/dip/cli/dns.rb
    CHANGED
    
    | @@ -1,30 +1,31 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 3 | 
            +
            require "thor"
         | 
| 4 | 
            +
            require_relative "./base"
         | 
| 4 5 | 
             
            require_relative "../commands/dns"
         | 
| 5 6 |  | 
| 6 7 | 
             
            module Dip
         | 
| 7 8 | 
             
              class CLI
         | 
| 8 9 | 
             
                # See more https://github.com/aacebedo/dnsdock
         | 
| 9 | 
            -
                class DNS <  | 
| 10 | 
            +
                class DNS < Base
         | 
| 10 11 | 
             
                  desc "up", "Run dnsdock container"
         | 
| 11 | 
            -
                  method_option :help, aliases:  | 
| 12 | 
            -
                                       desc:  | 
| 13 | 
            -
                  method_option :name, aliases:  | 
| 14 | 
            -
                                       desc:  | 
| 15 | 
            -
                  method_option :socket, aliases:  | 
| 16 | 
            -
                                         desc:  | 
| 17 | 
            -
                  method_option :net, aliases:  | 
| 18 | 
            -
                                      desc:  | 
| 19 | 
            -
                  method_option :publish, aliases:  | 
| 20 | 
            -
                                          desc:  | 
| 21 | 
            -
                  method_option :image, aliases:  | 
| 22 | 
            -
                                        desc:  | 
| 23 | 
            -
                  method_option :domain, aliases:  | 
| 24 | 
            -
                                         desc:  | 
| 12 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 13 | 
            +
                                       desc: "Display usage information"
         | 
| 14 | 
            +
                  method_option :name, aliases: "-n", type: :string, default: "dnsdock",
         | 
| 15 | 
            +
                                       desc: "Container name"
         | 
| 16 | 
            +
                  method_option :socket, aliases: "-s", type: :string, default: "/var/run/docker.sock",
         | 
| 17 | 
            +
                                         desc: "Path to docker socket"
         | 
| 18 | 
            +
                  method_option :net, aliases: "-t", type: :string, default: "frontend",
         | 
| 19 | 
            +
                                      desc: "Container network name"
         | 
| 20 | 
            +
                  method_option :publish, aliases: "-p", type: :string, default: "53/udp",
         | 
| 21 | 
            +
                                          desc: "Container port"
         | 
| 22 | 
            +
                  method_option :image, aliases: "-i", type: :string, default: "aacebedo/dnsdock:latest-amd64",
         | 
| 23 | 
            +
                                        desc: "Docker image name"
         | 
| 24 | 
            +
                  method_option :domain, aliases: "-d", type: :string, default: "docker",
         | 
| 25 | 
            +
                                         desc: "Top level domain"
         | 
| 25 26 | 
             
                  def up
         | 
| 26 27 | 
             
                    if options[:help]
         | 
| 27 | 
            -
                      invoke :help, [ | 
| 28 | 
            +
                      invoke :help, ["up"]
         | 
| 28 29 | 
             
                    else
         | 
| 29 30 | 
             
                      Dip::Commands::DNS::Up.new(
         | 
| 30 31 | 
             
                        name: options.fetch(:name),
         | 
| @@ -38,13 +39,13 @@ module Dip | |
| 38 39 | 
             
                  end
         | 
| 39 40 |  | 
| 40 41 | 
             
                  desc "down", "Stop dnsdock container"
         | 
| 41 | 
            -
                  method_option :help, aliases:  | 
| 42 | 
            -
                                       desc:  | 
| 43 | 
            -
                  method_option :name, aliases:  | 
| 44 | 
            -
                                       desc:  | 
| 42 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 43 | 
            +
                                       desc: "Display usage information"
         | 
| 44 | 
            +
                  method_option :name, aliases: "-n", type: :string, default: "dnsdock",
         | 
| 45 | 
            +
                                       desc: "Container name"
         | 
| 45 46 | 
             
                  def down
         | 
| 46 47 | 
             
                    if options[:help]
         | 
| 47 | 
            -
                      invoke :help, [ | 
| 48 | 
            +
                      invoke :help, ["down"]
         | 
| 48 49 | 
             
                    else
         | 
| 49 50 | 
             
                      Dip::Commands::DNS::Down.new(
         | 
| 50 51 | 
             
                        name: options.fetch(:name)
         | 
| @@ -53,11 +54,11 @@ module Dip | |
| 53 54 | 
             
                  end
         | 
| 54 55 |  | 
| 55 56 | 
             
                  desc "restart", "Stop and start dnsdock container"
         | 
| 56 | 
            -
                  method_option :help, aliases:  | 
| 57 | 
            -
                                       desc:  | 
| 57 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 58 | 
            +
                                       desc: "Display usage information"
         | 
| 58 59 | 
             
                  def restart(*args)
         | 
| 59 60 | 
             
                    if options[:help]
         | 
| 60 | 
            -
                      invoke :help, [ | 
| 61 | 
            +
                      invoke :help, ["restart"]
         | 
| 61 62 | 
             
                    else
         | 
| 62 63 | 
             
                      Dip::CLI::DNS.start(["down"] + args)
         | 
| 63 64 | 
             
                      sleep 1
         | 
| @@ -66,15 +67,15 @@ module Dip | |
| 66 67 | 
             
                  end
         | 
| 67 68 |  | 
| 68 69 | 
             
                  desc "ip", "Get ip address of dnsdock container"
         | 
| 69 | 
            -
                  method_option :help, aliases:  | 
| 70 | 
            -
                                       desc:  | 
| 71 | 
            -
                  method_option :name, aliases:  | 
| 72 | 
            -
                                       desc:  | 
| 73 | 
            -
                  method_option :net, aliases:  | 
| 74 | 
            -
                                      desc:  | 
| 70 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 71 | 
            +
                                       desc: "Display usage information"
         | 
| 72 | 
            +
                  method_option :name, aliases: "-n", type: :string, default: "dnsdock",
         | 
| 73 | 
            +
                                       desc: "Container name"
         | 
| 74 | 
            +
                  method_option :net, aliases: "-t", type: :string, default: "frontend",
         | 
| 75 | 
            +
                                      desc: "Container network name"
         | 
| 75 76 | 
             
                  def ip
         | 
| 76 77 | 
             
                    if options[:help]
         | 
| 77 | 
            -
                      invoke :help, [ | 
| 78 | 
            +
                      invoke :help, ["status"]
         | 
| 78 79 | 
             
                    else
         | 
| 79 80 | 
             
                      Dip::Commands::DNS::IP.new(
         | 
| 80 81 | 
             
                        name: options.fetch(:name),
         | 
    
        data/lib/dip/cli/nginx.rb
    CHANGED
    
    | @@ -1,31 +1,32 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 3 | 
            +
            require "thor"
         | 
| 4 | 
            +
            require_relative "./base"
         | 
| 4 5 | 
             
            require_relative "../commands/nginx"
         | 
| 5 6 |  | 
| 6 7 | 
             
            module Dip
         | 
| 7 8 | 
             
              class CLI
         | 
| 8 9 | 
             
                # See more https://github.com/bibendi/nginx-proxy
         | 
| 9 | 
            -
                class Nginx <  | 
| 10 | 
            +
                class Nginx < Base
         | 
| 10 11 | 
             
                  desc "up", "Run nginx container"
         | 
| 11 | 
            -
                  method_option :help, aliases:  | 
| 12 | 
            -
                                       desc:  | 
| 13 | 
            -
                  method_option :name, aliases:  | 
| 14 | 
            -
                                       desc:  | 
| 15 | 
            -
                  method_option :socket, aliases:  | 
| 16 | 
            -
                                         desc:  | 
| 17 | 
            -
                  method_option :net, aliases:  | 
| 18 | 
            -
                                      desc:  | 
| 19 | 
            -
                  method_option :publish, aliases:  | 
| 20 | 
            -
                                          desc:  | 
| 21 | 
            -
                  method_option :image, aliases:  | 
| 22 | 
            -
                                        desc:  | 
| 23 | 
            -
                  method_option :domain, aliases:  | 
| 24 | 
            -
                                         desc:  | 
| 25 | 
            -
                  method_option :certs, aliases:  | 
| 12 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 13 | 
            +
                                       desc: "Display usage information"
         | 
| 14 | 
            +
                  method_option :name, aliases: "-n", type: :string, default: "nginx",
         | 
| 15 | 
            +
                                       desc: "Container name"
         | 
| 16 | 
            +
                  method_option :socket, aliases: "-s", type: :string, default: "/var/run/docker.sock",
         | 
| 17 | 
            +
                                         desc: "Path to docker socket"
         | 
| 18 | 
            +
                  method_option :net, aliases: "-t", type: :string, default: "frontend",
         | 
| 19 | 
            +
                                      desc: "Container network name"
         | 
| 20 | 
            +
                  method_option :publish, aliases: "-p", type: :array, default: ["80:80"],
         | 
| 21 | 
            +
                                          desc: "Container port(s). For more than one port, separate them by a space"
         | 
| 22 | 
            +
                  method_option :image, aliases: "-i", type: :string, default: "bibendi/nginx-proxy:latest",
         | 
| 23 | 
            +
                                        desc: "Docker image name"
         | 
| 24 | 
            +
                  method_option :domain, aliases: "-d", type: :string, default: "docker",
         | 
| 25 | 
            +
                                         desc: "Top level domain"
         | 
| 26 | 
            +
                  method_option :certs, aliases: "-c", type: :string, desc: "Path to ssl certificates"
         | 
| 26 27 | 
             
                  def up
         | 
| 27 28 | 
             
                    if options[:help]
         | 
| 28 | 
            -
                      invoke :help, [ | 
| 29 | 
            +
                      invoke :help, ["up"]
         | 
| 29 30 | 
             
                    else
         | 
| 30 31 | 
             
                      Dip::Commands::Nginx::Up.new(
         | 
| 31 32 | 
             
                        name: options.fetch(:name),
         | 
| @@ -40,13 +41,13 @@ module Dip | |
| 40 41 | 
             
                  end
         | 
| 41 42 |  | 
| 42 43 | 
             
                  desc "down", "Stop nginx container"
         | 
| 43 | 
            -
                  method_option :help, aliases:  | 
| 44 | 
            -
                                       desc:  | 
| 45 | 
            -
                  method_option :name, aliases:  | 
| 46 | 
            -
                                       desc:  | 
| 44 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 45 | 
            +
                                       desc: "Display usage information"
         | 
| 46 | 
            +
                  method_option :name, aliases: "-n", type: :string, default: "nginx",
         | 
| 47 | 
            +
                                       desc: "Container name"
         | 
| 47 48 | 
             
                  def down
         | 
| 48 49 | 
             
                    if options[:help]
         | 
| 49 | 
            -
                      invoke :help, [ | 
| 50 | 
            +
                      invoke :help, ["down"]
         | 
| 50 51 | 
             
                    else
         | 
| 51 52 | 
             
                      Dip::Commands::Nginx::Down.new(
         | 
| 52 53 | 
             
                        name: options.fetch(:name)
         | 
| @@ -55,11 +56,11 @@ module Dip | |
| 55 56 | 
             
                  end
         | 
| 56 57 |  | 
| 57 58 | 
             
                  desc "restart", "Stop and start nginx container"
         | 
| 58 | 
            -
                  method_option :help, aliases:  | 
| 59 | 
            -
                                       desc:  | 
| 59 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 60 | 
            +
                                       desc: "Display usage information"
         | 
| 60 61 | 
             
                  def restart(*args)
         | 
| 61 62 | 
             
                    if options[:help]
         | 
| 62 | 
            -
                      invoke :help, [ | 
| 63 | 
            +
                      invoke :help, ["restart"]
         | 
| 63 64 | 
             
                    else
         | 
| 64 65 | 
             
                      Dip::CLI::Nginx.start(["down"] + args)
         | 
| 65 66 | 
             
                      sleep 1
         | 
    
        data/lib/dip/cli/ssh.rb
    CHANGED
    
    | @@ -1,31 +1,35 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 3 | 
            +
            require "thor"
         | 
| 4 | 
            +
            require_relative "./base"
         | 
| 4 5 | 
             
            require_relative "../commands/ssh"
         | 
| 5 6 |  | 
| 6 7 | 
             
            module Dip
         | 
| 7 8 | 
             
              class CLI
         | 
| 8 | 
            -
                class SSH <  | 
| 9 | 
            +
                class SSH < Base
         | 
| 9 10 | 
             
                  desc "up", "Run ssh-agent container"
         | 
| 10 | 
            -
                  method_option :help, aliases:  | 
| 11 | 
            -
                                       desc:  | 
| 12 | 
            -
                  method_option :key, aliases:  | 
| 13 | 
            -
                                      desc:  | 
| 14 | 
            -
                  method_option :volume, aliases:  | 
| 15 | 
            -
                                         desc:  | 
| 16 | 
            -
                  method_option :interactive, aliases:  | 
| 17 | 
            -
                                              desc:  | 
| 11 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 12 | 
            +
                                       desc: "Display usage information"
         | 
| 13 | 
            +
                  method_option :key, aliases: "-k", type: :string, default: "$HOME/.ssh/id_rsa",
         | 
| 14 | 
            +
                                      desc: "Path to ssh key"
         | 
| 15 | 
            +
                  method_option :volume, aliases: "-v", type: :string, default: "$HOME",
         | 
| 16 | 
            +
                                         desc: "Mounted docker volume"
         | 
| 17 | 
            +
                  method_option :interactive, aliases: "-t", type: :boolean, default: true,
         | 
| 18 | 
            +
                                              desc: "Run in interactive mode"
         | 
| 19 | 
            +
                  method_option :user, aliases: "-u", type: :string,
         | 
| 20 | 
            +
                                       desc: "UID for ssh-agent container"
         | 
| 18 21 | 
             
                  # Backward compatibility
         | 
| 19 | 
            -
                  method_option :nonteractive, aliases:  | 
| 20 | 
            -
                                               desc:  | 
| 22 | 
            +
                  method_option :nonteractive, aliases: "-T", type: :boolean,
         | 
| 23 | 
            +
                                               desc: "Run in noninteractive mode"
         | 
| 21 24 | 
             
                  def up
         | 
| 22 25 | 
             
                    if options[:help]
         | 
| 23 | 
            -
                      invoke :help, [ | 
| 26 | 
            +
                      invoke :help, ["up"]
         | 
| 24 27 | 
             
                    else
         | 
| 25 28 | 
             
                      Dip::Commands::SSH::Up.new(
         | 
| 26 29 | 
             
                        key: options.fetch(:key),
         | 
| 27 30 | 
             
                        volume: options.fetch(:volume),
         | 
| 28 | 
            -
                        interactive: options.nonteractive? ? false : options.interactive | 
| 31 | 
            +
                        interactive: options.nonteractive? ? false : options.interactive?,
         | 
| 32 | 
            +
                        user: options.user
         | 
| 29 33 | 
             
                      ).execute
         | 
| 30 34 | 
             
                    end
         | 
| 31 35 | 
             
                  end
         | 
| @@ -33,22 +37,22 @@ module Dip | |
| 33 37 | 
             
                  map add: :up
         | 
| 34 38 |  | 
| 35 39 | 
             
                  desc "down", "Stop ssh-agent container"
         | 
| 36 | 
            -
                  method_option :help, aliases:  | 
| 37 | 
            -
                                       desc:  | 
| 40 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 41 | 
            +
                                       desc: "Display usage information"
         | 
| 38 42 | 
             
                  def down
         | 
| 39 43 | 
             
                    if options[:help]
         | 
| 40 | 
            -
                      invoke :help, [ | 
| 44 | 
            +
                      invoke :help, ["down"]
         | 
| 41 45 | 
             
                    else
         | 
| 42 46 | 
             
                      Dip::Commands::SSH::Down.new.execute
         | 
| 43 47 | 
             
                    end
         | 
| 44 48 | 
             
                  end
         | 
| 45 49 |  | 
| 46 50 | 
             
                  desc "restart", "Stop and start ssh-agent container"
         | 
| 47 | 
            -
                  method_option :help, aliases:  | 
| 48 | 
            -
                                       desc:  | 
| 51 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 52 | 
            +
                                       desc: "Display usage information"
         | 
| 49 53 | 
             
                  def restart(*args)
         | 
| 50 54 | 
             
                    if options[:help]
         | 
| 51 | 
            -
                      invoke :help, [ | 
| 55 | 
            +
                      invoke :help, ["restart"]
         | 
| 52 56 | 
             
                    else
         | 
| 53 57 | 
             
                      Dip::CLI::SSH.start(["down"] + args)
         | 
| 54 58 | 
             
                      sleep 1
         | 
| @@ -57,11 +61,11 @@ module Dip | |
| 57 61 | 
             
                  end
         | 
| 58 62 |  | 
| 59 63 | 
             
                  desc "status", "Show status of ssh-agent container"
         | 
| 60 | 
            -
                  method_option :help, aliases:  | 
| 61 | 
            -
                                       desc:  | 
| 64 | 
            +
                  method_option :help, aliases: "-h", type: :boolean,
         | 
| 65 | 
            +
                                       desc: "Display usage information"
         | 
| 62 66 | 
             
                  def status
         | 
| 63 67 | 
             
                    if options[:help]
         | 
| 64 | 
            -
                      invoke :help, [ | 
| 68 | 
            +
                      invoke :help, ["status"]
         | 
| 65 69 | 
             
                    else
         | 
| 66 70 | 
             
                      Dip::Commands::SSH::Status.new.execute
         | 
| 67 71 | 
             
                    end
         | 
    
        data/lib/dip/command.rb
    CHANGED
    
    | @@ -9,15 +9,15 @@ module Dip | |
| 9 9 | 
             
                def_delegators self, :shell, :subshell
         | 
| 10 10 |  | 
| 11 11 | 
             
                class ExecRunner
         | 
| 12 | 
            -
                  def self.call( | 
| 13 | 
            -
                    ::Process.exec(env,  | 
| 12 | 
            +
                  def self.call(cmdline, env: {}, **options)
         | 
| 13 | 
            +
                    ::Process.exec(env, cmdline, options)
         | 
| 14 14 | 
             
                  end
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                class SubshellRunner
         | 
| 18 | 
            -
                  def self.call( | 
| 19 | 
            -
                    return if ::Kernel.system(env,  | 
| 20 | 
            -
                    raise Dip::Error, "Command '#{ | 
| 18 | 
            +
                  def self.call(cmdline, env: {}, panic: true, **options)
         | 
| 19 | 
            +
                    return if ::Kernel.system(env, cmdline, options)
         | 
| 20 | 
            +
                    raise Dip::Error, "Command '#{cmdline}' executed with error." if panic
         | 
| 21 21 | 
             
                  end
         | 
| 22 22 | 
             
                end
         | 
| 23 23 |  | 
| @@ -25,11 +25,12 @@ module Dip | |
| 25 25 | 
             
                  def shell(cmd, argv = [], subshell: false, **options)
         | 
| 26 26 | 
             
                    cmd = Dip.env.interpolate(cmd)
         | 
| 27 27 | 
             
                    argv = argv.map { |arg| Dip.env.interpolate(arg) }
         | 
| 28 | 
            +
                    cmdline = [cmd, *argv].compact.join(" ")
         | 
| 28 29 |  | 
| 29 | 
            -
                    puts [Dip.env.vars,  | 
| 30 | 
            +
                    puts [Dip.env.vars, cmdline].inspect if Dip.debug?
         | 
| 30 31 |  | 
| 31 32 | 
             
                    runner = subshell ? SubshellRunner : ExecRunner
         | 
| 32 | 
            -
                    runner.call( | 
| 33 | 
            +
                    runner.call(cmdline, env: Dip.env.vars, **options)
         | 
| 33 34 | 
             
                  end
         | 
| 34 35 |  | 
| 35 36 | 
             
                  def subshell(*args, **kwargs)
         | 
    
        data/lib/dip/commands/compose.rb
    CHANGED
    
    | @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 3 | 
            +
            require "pathname"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require_relative "../command"
         | 
| 6 | 
            +
            require_relative "dns"
         | 
| 5 7 |  | 
| 6 8 | 
             
            module Dip
         | 
| 7 9 | 
             
              module Commands
         | 
| @@ -18,7 +20,7 @@ module Dip | |
| 18 20 | 
             
                  def execute
         | 
| 19 21 | 
             
                    Dip.env["DIP_DNS"] ||= find_dns
         | 
| 20 22 |  | 
| 21 | 
            -
                    compose_argv = Array(find_files) + Array( | 
| 23 | 
            +
                    compose_argv = Array(find_files) + Array(cli_options) + argv
         | 
| 22 24 |  | 
| 23 25 | 
             
                    shell("docker-compose", compose_argv)
         | 
| 24 26 | 
             
                  end
         | 
| @@ -29,23 +31,26 @@ module Dip | |
| 29 31 | 
             
                    return unless (files = config[:files])
         | 
| 30 32 |  | 
| 31 33 | 
             
                    if files.is_a?(Array)
         | 
| 32 | 
            -
                      files.each_with_object([]) do | | 
| 33 | 
            -
                         | 
| 34 | 
            -
                         | 
| 34 | 
            +
                      files.each_with_object([]) do |file_path, memo|
         | 
| 35 | 
            +
                        file_path = ::Dip.env.interpolate(file_path)
         | 
| 36 | 
            +
                        file_path = Pathname.new(file_path)
         | 
| 37 | 
            +
                        file_path = Dip.config.file_path.parent.join(file_path).expand_path if file_path.relative?
         | 
| 38 | 
            +
                        next unless file_path.exist?
         | 
| 35 39 |  | 
| 36 40 | 
             
                        memo << "--file"
         | 
| 37 | 
            -
                        memo <<  | 
| 41 | 
            +
                        memo << file_path.to_s
         | 
| 38 42 | 
             
                      end
         | 
| 39 43 | 
             
                    end
         | 
| 40 44 | 
             
                  end
         | 
| 41 45 |  | 
| 42 | 
            -
                  def  | 
| 43 | 
            -
                     | 
| 46 | 
            +
                  def cli_options
         | 
| 47 | 
            +
                    %i[project_name project_directory].flat_map do |name|
         | 
| 48 | 
            +
                      next unless (value = config[name])
         | 
| 49 | 
            +
                      next unless value.is_a?(String)
         | 
| 44 50 |  | 
| 45 | 
            -
             | 
| 46 | 
            -
                       | 
| 47 | 
            -
             | 
| 48 | 
            -
                    end
         | 
| 51 | 
            +
                      value = ::Dip.env.interpolate(value)
         | 
| 52 | 
            +
                      ["--#{name.to_s.tr("_", "-")}", value]
         | 
| 53 | 
            +
                    end.compact
         | 
| 49 54 | 
             
                  end
         | 
| 50 55 |  | 
| 51 56 | 
             
                  def find_dns
         | 
| @@ -53,9 +58,9 @@ module Dip | |
| 53 58 | 
             
                    net = Dip.env["FRONTEND_NETWORK"] || "frontend"
         | 
| 54 59 |  | 
| 55 60 | 
             
                    IO.pipe do |r, w|
         | 
| 56 | 
            -
                      Dip::Commands::DNS::IP | 
| 57 | 
            -
                        new(name: name, net: net) | 
| 58 | 
            -
                        execute(out: w, err: File::NULL, panic: false)
         | 
| 61 | 
            +
                      Dip::Commands::DNS::IP
         | 
| 62 | 
            +
                        .new(name: name, net: net)
         | 
| 63 | 
            +
                        .execute(out: w, err: File::NULL, panic: false)
         | 
| 59 64 |  | 
| 60 65 | 
             
                      w.close_write
         | 
| 61 66 | 
             
                      ip = r.readlines[0].to_s.strip
         | 
    
        data/lib/dip/commands/console.rb
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require_relative  | 
| 3 | 
            +
            require_relative "../command"
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Dip
         | 
| 6 6 | 
             
              module Commands
         | 
| @@ -13,9 +13,9 @@ module Dip | |
| 13 13 | 
             
                    private
         | 
| 14 14 |  | 
| 15 15 | 
             
                    def script
         | 
| 16 | 
            -
                      <<-SH.gsub(/^ | 
| 16 | 
            +
                      <<-SH.gsub(/^ {12}/, "")
         | 
| 17 17 | 
             
                        export DIP_SHELL=1
         | 
| 18 | 
            -
                        export DIP_EARLY_ENVS=#{ENV.keys.join( | 
| 18 | 
            +
                        export DIP_EARLY_ENVS=#{ENV.keys.join(",")}
         | 
| 19 19 | 
             
                        export DIP_PROMPT_TEXT="ⅆ"
         | 
| 20 20 |  | 
| 21 21 | 
             
                        function dip_clear() {
         | 
| @@ -86,9 +86,9 @@ module Dip | |
| 86 86 | 
             
                    end
         | 
| 87 87 |  | 
| 88 88 | 
             
                    def execute
         | 
| 89 | 
            -
                      if Dip | 
| 89 | 
            +
                      if Dip.config.exist?
         | 
| 90 90 | 
             
                        add_aliases(*Dip.config.interaction.keys) if Dip.config.interaction
         | 
| 91 | 
            -
                        add_aliases("compose", "up", "stop", "down", "provision")
         | 
| 91 | 
            +
                        add_aliases("compose", "up", "stop", "down", "provision", "build")
         | 
| 92 92 | 
             
                      end
         | 
| 93 93 |  | 
| 94 94 | 
             
                      clear_aliases
         | 
| @@ -107,7 +107,7 @@ module Dip | |
| 107 107 |  | 
| 108 108 | 
             
                    def clear_aliases
         | 
| 109 109 | 
             
                      out << "function dip_clear() { \n" \
         | 
| 110 | 
            -
                              "#{aliases.any? ? aliases.map { |a| "  unset -f #{a}" }.join("\n") :  | 
| 110 | 
            +
                              "#{aliases.any? ? aliases.map { |a| "  unset -f #{a}" }.join("\n") : "true"} " \
         | 
| 111 111 | 
             
                              "\n}"
         | 
| 112 112 | 
             
                    end
         | 
| 113 113 | 
             
                  end
         | 
    
        data/lib/dip/commands/dns.rb
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require "shellwords"
         | 
| 4 | 
            -
            require_relative  | 
| 4 | 
            +
            require_relative "../command"
         | 
| 5 5 |  | 
| 6 6 | 
             
            module Dip
         | 
| 7 7 | 
             
              module Commands
         | 
| @@ -24,13 +24,13 @@ module Dip | |
| 24 24 | 
             
                    private
         | 
| 25 25 |  | 
| 26 26 | 
             
                    def container_args
         | 
| 27 | 
            -
                      result = %w | 
| 27 | 
            +
                      result = %w[--detach]
         | 
| 28 28 | 
             
                      result << "--volume #{@socket}:/var/run/docker.sock:ro"
         | 
| 29 29 | 
             
                      result << "--restart always"
         | 
| 30 30 | 
             
                      result << "--publish #{@publish}"
         | 
| 31 31 | 
             
                      result << "--net #{@net}"
         | 
| 32 32 | 
             
                      result << "--name #{@name}"
         | 
| 33 | 
            -
                      result.join( | 
| 33 | 
            +
                      result.join(" ")
         | 
| 34 34 | 
             
                    end
         | 
| 35 35 | 
             
                  end
         | 
| 36 36 |  | 
| @@ -53,10 +53,10 @@ module Dip | |
| 53 53 |  | 
| 54 54 | 
             
                    def execute(**options)
         | 
| 55 55 | 
             
                      subshell("docker",
         | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 56 | 
            +
                        "inspect " \
         | 
| 57 | 
            +
                        "--format '{{ .NetworkSettings.Networks.#{@net}.IPAddress }}' " \
         | 
| 58 | 
            +
                        "#{@name}".shellsplit,
         | 
| 59 | 
            +
                        **options)
         | 
| 60 60 | 
             
                    end
         | 
| 61 61 | 
             
                  end
         | 
| 62 62 | 
             
                end
         |