sct 1.0.1 → 1.0.7

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: 6c949eeff7191cb2699ed0ed1ba26559d7a47ca5111e154204b4e1da42356069
4
- data.tar.gz: 7c021037a4e3fc764d011e7d2e76024344a6a2b3e05672de4bc5dc0cad985042
3
+ metadata.gz: 6ecc8e55b65c59245e7d03238bb1218f47761e018c2ca2c0b14df9731b58dbb1
4
+ data.tar.gz: cb593b673991d65aa8ca36aad1629f26d18a4e0429b44d11d4a45c48b0f291f0
5
5
  SHA512:
6
- metadata.gz: 9022840b61e7414056aef611325122d8c4e1c1dce4c370f99d2b67d5ddda35b9e395444ffc6b7d79b01d530d40117cfc08159148b276263d9b8958cce488e8c5
7
- data.tar.gz: d5f967cd37ad3447f3566051894195b08ecda28773a95a9bdecc7f61bbb59efc339d6541c826b1f5a0efd6e06bc3519e1d1cce32c096b784ca1ad4518f71e0c3
6
+ metadata.gz: a85dcbcbb4cbc902cc9cd266b38539d71ec3ac4fdc4e2e1353ab66719eab607efc572c109c7c6efbd23403544dc4fb4aec01700d5858b144fd7fce99c6277e2d
7
+ data.tar.gz: 76a9ea0399f166725fa1da20fe3b6bf0b1913ec671c46db970d5460b8180eef089cd4eb76f57bb6145766f24c02fd6d2f513f9d60b15da33afa657663455fa12
@@ -24,6 +24,8 @@ module Cluster
24
24
  run_dc "build #{options.pull ? "--pull" : ""}"
25
25
  end
26
26
 
27
+ run "docker container prune -f"
28
+
27
29
  run_dc "up --detach"
28
30
 
29
31
  if options.pull or options.build
@@ -1,6 +1,6 @@
1
1
  module Sct
2
2
  class CLIToolsDistributor
3
- class << self
3
+ class << self
4
4
  def take_off
5
5
  require 'sct'
6
6
 
@@ -8,18 +8,18 @@ module Sct
8
8
 
9
9
  if tool_name && Sct::TOOLS.include?(tool_name.to_sym)
10
10
  # Triggering a specific tool
11
-
11
+
12
12
  require tool_name
13
13
  begin
14
14
  # First, remove the tool's name from the arguments
15
15
  # Since it will be parsed by the `commander` at a later point
16
16
  # and it must not contain the binary name
17
17
  ARGV.shift
18
-
18
+
19
19
  # Import the CommandsGenerator class, which is used to parse
20
20
  # the user input
21
21
  require File.join(tool_name, "commands_generator")
22
-
22
+
23
23
  # Call the tool's CommandsGenerator class and let it do its thing
24
24
  commands_generator = Object.const_get(tool_name.sct_module)::CommandsGenerator
25
25
  rescue LoadError
@@ -28,15 +28,15 @@ module Sct
28
28
  # When we launch this feature, this should never be the case
29
29
  abort("#{tool_name} can't be called via `sct #{tool_name}`, run '#{tool_name}' directly instead".red)
30
30
  end
31
-
31
+
32
32
  # Some of the tools might use other actions so need to load all
33
33
  # actions before we start the tool generator here in the future
34
34
  Sct.load_actions
35
-
35
+
36
36
  # trigger start on tool
37
37
  commands_generator.start
38
38
 
39
- else
39
+ else
40
40
  require "sct/commands_generator"
41
41
  Sct::CommandsGenerator.start
42
42
  end
@@ -47,4 +47,4 @@ module Sct
47
47
 
48
48
  end
49
49
  end
50
- end
50
+ end
@@ -10,12 +10,12 @@ module Sct
10
10
  exit 1
11
11
  end
12
12
 
13
- def dc command
14
- system "docker-compose -f ~/development/spend-cloud/docker-compose.yml #{command}"
13
+ def dc command, env = {}
14
+ system env, "docker-compose -f ~/development/spend-cloud/docker-compose.yml #{command}"
15
15
  end
16
16
 
17
- def local_dc command
18
- system "docker-compose -f #{@@file} #{command}"
17
+ def dc_dev command, env = {}
18
+ system env, "docker-compose -f #{@@file} #{command}"
19
19
  end
20
20
 
21
21
  def manifest
@@ -38,12 +38,28 @@ module Sct
38
38
  container = service_spec["container_name"]
39
39
  command = service_spec["command"] || ""
40
40
 
41
+ if Sct::Helper.is_windows?
42
+ host_machine_IP = (options.wsl_debugger ? `hostname -I | awk '{print $1}'` : `powershell.exe -c '(Test-Connection -ComputerName $env:computername -count 1).ipv4address.IPAddressToString' | dos2unix`).chomp
43
+ elsif Sct::Helper.is_mac_os?
44
+ host_machine_IP = `ipconfig getifaddr $(route get 8.8.8.8 | awk '/interface: / {print $2; }')`.chomp
45
+ else
46
+ host_machine_IP = `hostname -I | awk '{print $1}'`.chomp
47
+ end
48
+
49
+ env = {
50
+ "PUID" => `id -u`.chomp,
51
+ "PGID" => `id -g`.chomp,
52
+ "HOST_MACHINE_IP" => host_machine_IP,
53
+ "IDE_DEBUG_KEY" => "PHPSTORM",
54
+ "IDE_DEBUG_SERVER" => "docker",
55
+ }
56
+
41
57
  if options.pull
42
- return unless local_dc "pull"
58
+ return unless dc_dev "pull"
43
59
  end
44
60
 
45
61
  if options.build
46
- return unless local_dc "build --build-arg PUID=$(id -u) --build-arg PGID=$(id -g) #{options.pull ? "--pull" : ""}"
62
+ return unless dc_dev "build #{options.pull ? "--pull" : ""}", env
47
63
  end
48
64
 
49
65
  if options.pull or options.build
@@ -52,7 +68,7 @@ module Sct
52
68
 
53
69
  return unless dc "rm --stop --force #{service}"
54
70
 
55
- local_dc "run --rm --service-ports --name #{container} #{service} #{command}"
71
+ dc_dev "run --rm --service-ports --name #{container} #{service} #{command}", env
56
72
 
57
73
  dc "up --detach #{service}"
58
74
  end
@@ -1,15 +1,15 @@
1
1
  require 'yaml'
2
2
 
3
- module Shell
4
- class Runner
3
+ module Sct
4
+ class ShellCommand
5
5
 
6
6
  def error message
7
7
  UI.error message
8
8
  exit 1
9
9
  end
10
10
 
11
- def launch
12
- command = ARGV.empty? ? "sh" : ARGV.join(" ")
11
+ def execute args, options
12
+ command = args.empty? ? "sh" : args.join(" ")
13
13
 
14
14
  file = "docker-compose.dev.yml"
15
15
 
@@ -41,7 +41,9 @@ module Shell
41
41
  end
42
42
  end
43
43
 
44
- system "docker exec -it --user $(id -u):$(id -g) #{container} #{command}"
44
+ user = options.root ? "root:root" : "$(id -u):$(id -g)"
45
+
46
+ system "docker exec -it --user #{user} #{container} #{command}"
45
47
  end
46
48
 
47
49
  end
@@ -35,6 +35,11 @@ module Sct
35
35
  command :'shell' do |c|
36
36
  c.syntax = 'sct shell'
37
37
  c.description = 'run commands from the shell using docker containers'
38
+ c.option '--root', 'run as root user in the container'
39
+
40
+ c.action do |args, options|
41
+ Sct::ShellCommand.new.execute args, options
42
+ end
38
43
  end
39
44
 
40
45
  command :'dev' do |c|
@@ -42,6 +47,7 @@ module Sct
42
47
  c.description = 'start development container in the current directory'
43
48
  c.option '--build', '(re)build images before starting'
44
49
  c.option '--pull', 'pull latest images before starting'
50
+ c.option '--wsl-debugger', 'use if running the PHP debugger from WSL'
45
51
 
46
52
  c.action do |args, options|
47
53
  Sct::DevCommand.new.execute args, options
data/sct/lib/sct/tools.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  module Sct
2
2
  TOOLS = [
3
3
  :sct,
4
- :shell,
5
4
  :cluster
6
5
  ]
7
-
6
+
8
7
  # a list of all the config files we currently expect
9
- TOOL_CONFIG_FILES = [
10
-
11
- ]
12
- end
8
+ TOOL_CONFIG_FILES = []
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Sct
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -66,6 +66,10 @@ module SctCore
66
66
  return !ENV["SUDO_USER"].nil? && !ENV["SUDO_USER"].empty?
67
67
  end
68
68
 
69
+ def self.is_mac_os?
70
+ return self.operating_system == MAC_OS
71
+ end
72
+
69
73
  def self.is_windows?
70
74
  return self.operating_system == WINDOWS
71
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reshad Farid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-25 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -208,6 +208,7 @@ files:
208
208
  - sct/lib/sct/command.rb
209
209
  - sct/lib/sct/commands/dev.rb
210
210
  - sct/lib/sct/commands/mysqlproxy.rb
211
+ - sct/lib/sct/commands/shell.rb
211
212
  - sct/lib/sct/commands_generator.rb
212
213
  - sct/lib/sct/tools.rb
213
214
  - sct/lib/sct/version.rb
@@ -223,10 +224,6 @@ files:
223
224
  - sct_core/lib/sct_core/ui/interface.rb
224
225
  - sct_core/lib/sct_core/ui/ui.rb
225
226
  - sct_core/lib/sct_core/update_checker/update_checker.rb
226
- - shell/lib/shell.rb
227
- - shell/lib/shell/commands_generator.rb
228
- - shell/lib/shell/module.rb
229
- - shell/lib/shell/runner.rb
230
227
  homepage: https://gitlab.com/proactive-software/packages/sct
231
228
  licenses:
232
229
  - MIT
@@ -237,7 +234,6 @@ metadata:
237
234
  post_install_message:
238
235
  rdoc_options: []
239
236
  require_paths:
240
- - shell/lib
241
237
  - cluster/lib
242
238
  - sct/lib
243
239
  - sct_core/lib
data/shell/lib/shell.rb DELETED
@@ -1,2 +0,0 @@
1
- require_relative 'shell/runner'
2
- require_relative 'shell/module'
@@ -1,14 +0,0 @@
1
- require_relative 'runner'
2
-
3
- module Shell
4
- class CommandsGenerator
5
-
6
- def self.start
7
- self.new.run
8
- end
9
-
10
- def run
11
- Shell::Runner.new.launch
12
- end
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- require 'sct_core/helper'
2
-
3
- module Shell
4
-
5
- # import the helper functionality from SCT
6
- Helpers = Sct::Helper
7
- UI = Sct::UI
8
-
9
- end