raykit 0.0.483 → 0.0.484

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +20 -20
  4. data/bin/raykit +6 -6
  5. data/lib/raykit/auto_setup.rb +43 -43
  6. data/lib/raykit/command.rb +341 -341
  7. data/lib/raykit/conan/buildinfo.rb +69 -69
  8. data/lib/raykit/conanpackage.rb +49 -49
  9. data/lib/raykit/console.rb +272 -272
  10. data/lib/raykit/default_content.rb +227 -227
  11. data/lib/raykit/dir.rb +49 -49
  12. data/lib/raykit/dotnet.rb +176 -174
  13. data/lib/raykit/environment.rb +109 -109
  14. data/lib/raykit/filesystem.rb +34 -34
  15. data/lib/raykit/git/commit.rb +16 -16
  16. data/lib/raykit/git/directory.rb +216 -216
  17. data/lib/raykit/git/files.rb +46 -46
  18. data/lib/raykit/git/repositories.rb +89 -89
  19. data/lib/raykit/git/repository.rb +244 -244
  20. data/lib/raykit/installer.rb +17 -17
  21. data/lib/raykit/log.rb +80 -80
  22. data/lib/raykit/logevent.rb +49 -49
  23. data/lib/raykit/logging.rb +57 -57
  24. data/lib/raykit/markdown.rb +21 -21
  25. data/lib/raykit/msbuild.rb +54 -54
  26. data/lib/raykit/nugetpackage.rb +54 -54
  27. data/lib/raykit/nunit.rb +13 -13
  28. data/lib/raykit/project.rb +339 -339
  29. data/lib/raykit/rake.rb +39 -39
  30. data/lib/raykit/runner.rb +42 -42
  31. data/lib/raykit/secrets.rb +38 -38
  32. data/lib/raykit/sourceImport.rb +74 -74
  33. data/lib/raykit/sourceImports.rb +43 -43
  34. data/lib/raykit/string.rb +18 -18
  35. data/lib/raykit/tasks.rb +99 -99
  36. data/lib/raykit/text.rb +32 -32
  37. data/lib/raykit/timer.rb +31 -31
  38. data/lib/raykit/version.rb +103 -103
  39. data/lib/raykit/vstest.rb +24 -24
  40. data/lib/raykit/wt.rb +28 -28
  41. data/lib/raykit/zip.rb +73 -73
  42. data/lib/raykit.rb +125 -125
  43. metadata +2 -2
data/lib/raykit/dotnet.rb CHANGED
@@ -1,174 +1,176 @@
1
- # frozen_string_literal: true
2
-
3
- module Raykit
4
- class DotNet
5
- def self.init_new(name, template)
6
- if (!File.exist?("#{name}/#{name}.csproj"))
7
- puts " #{name}.csproj not found, creating..."
8
- run("dotnet new #{template} --name #{name} --output #{name} --language C# ")
9
- else
10
- puts " #{name}.csproj already exists"
11
- end
12
- end
13
-
14
- # initialize an F# library
15
- def self.initialize_fsharp_lib(name)
16
- puts `dotnet new sln --name #{name}` unless File.exist?("#{name}.sln")
17
- unless Dir.exist?(name)
18
- FileUtils.mkdir(name)
19
- Dir.chdir(name) do
20
- puts `dotnet new classlib -lang F#`
21
- end
22
- # puts `dotnet new sln`
23
- puts `dotnet sln #{name}.sln add #{name}/#{name}.fsproj`
24
-
25
- FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
26
- Dir.chdir("#{name}.Test") do
27
- puts `dotnet new nunit -lang F#`
28
- puts `dotnet add reference ../#{name}/#{name}.fsproj`
29
- end
30
-
31
- puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.fsproj`
32
- end
33
- end
34
-
35
- # initialize a C# console application
36
- def self.initialize_csharp_console(name)
37
- unless Dir.exist?(name)
38
- FileUtils.mkdir(name)
39
- Dir.chdir(name) do
40
- puts `dotnet new console -lang C#`
41
- end
42
- puts `dotnet new sln`
43
- puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
44
-
45
- FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
46
- Dir.chdir("#{name}.Test") do
47
- puts `dotnet new nunit -lang C#`
48
- puts `dotnet add reference ../#{name}/#{name}.csproj`
49
- end
50
-
51
- puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.csproj`
52
- end
53
- end
54
-
55
- # initialize a C# wpf application
56
- def self.initialize_csharp_wpf_application(name)
57
- puts `dotnet new sln --name #{name}`
58
- unless Dir.exist?(name)
59
- FileUtils.mkdir(name)
60
- Dir.chdir(name) do
61
- puts `dotnet new wpf -lang C#`
62
- end
63
- end
64
- puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
65
- initialize_csharp_lib("#{name}.Library")
66
- puts `dotnet sln #{name}.sln add #{name}.Library/#{name}.Library.csproj`
67
- puts `dotnet sln #{name}.sln add #{name}.Library.Test/#{name}.Library.Test.csproj`
68
- end
69
-
70
- # initialize a C# worker service
71
- def self.initialize_csharp_service(name)
72
- unless Dir.exist?(name)
73
- FileUtils.mkdir(name)
74
- Dir.chdir(name) do
75
- puts `dotnet new worker -lang C#`
76
- end
77
- puts `dotnet new sln`
78
- puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
79
- end
80
- end
81
-
82
- # initialize a C# library
83
- def self.initialize_csharp_lib(name)
84
- # create the solution
85
- puts " creating #{name}.sln" unless File.exist?("#{name}.sln")
86
- PROJECT.run("dotnet new sln --name #{name}") unless File.exist?("#{name}.sln")
87
- # create the library
88
- puts " creating src/#{name}/#{name}.csproj" unless File.exist?("src/#{name}/#{name}.csproj")
89
- PROJECT.run("dotnet new classlib -lang C# --name #{name} --output src/#{name}") unless File.exist?("src/#{name}/#{name}.csproj")
90
- PROJECT.run("dotnet sln #{name}.sln add src/#{name}/#{name}.csproj") unless File.exist?("src/#{name}/#{name}.csproj")
91
- # create the test
92
- puts " creating test/#{name}.Test/#{name}.Test.csproj" unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
93
- PROJECT.run("dotnet new nunit -lang C# --name #{name}.Test --output test/#{name}.Test") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
94
- PROJECT.run("dotnet sln #{name}.sln add test/#{name}.Test/#{name}.Test.csproj") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
95
- PROJECT.run("dotnet add test/#{name}.Test/#{name}.Test.csproj reference src/#{name}/#{name}.csproj") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
96
- # create a blazor server example
97
- PROJECT.run("dotnet new blazorserver -lang C# --name #{name}.BlazorServer --output examples/#{name}.BlazorServer") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
98
- PROJECT.run("dotnet sln #{name}.sln add examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
99
- PROJECT.run("dotnet add examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj reference src/#{name}/#{name}.csproj") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
100
- # generate project folders
101
- ["Interfaces", "Extensions", "Models"].each do |folder|
102
- FileUtils.mkdir_p("src/#{name}/#{folder}") unless Dir.exist?("src/#{name}/#{folder}")
103
- FileUtils.mkdir_p("test/#{name}.Test/#{folder}") unless Dir.exist?("test/#{name}.Test/#{folder}")
104
- FileUtils.mkdir_p("examples/#{name}.BlazorServer/#{folder}") unless Dir.exist?("examples/#{name}.BlazorServer/#{folder}")
105
- end
106
- end
107
-
108
- # initialize a C# razor class library
109
- def self.initialize_csharp_razorclasslib(name)
110
- # create the solution
111
- puts " creating #{name}.sln" unless File.exist?("#{name}.sln")
112
- PROJECT.run("dotnet new sln --name #{name}") unless File.exist?("#{name}.sln")
113
- # create the library
114
- puts " creating src/#{name}/#{name}.csproj" unless File.exist?("src/#{name}/#{name}.csproj")
115
- PROJECT.run("dotnet new razorclasslib -lang C# --name #{name} --output src/#{name}") unless File.exist?("src/#{name}/#{name}.csproj")
116
- PROJECT.run("dotnet sln #{name}.sln add src/#{name}/#{name}.csproj") unless File.exist?("src/#{name}/#{name}.csproj")
117
- # create the test
118
- puts " creating test/#{name}.Test/#{name}.Test.csproj" unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
119
- PROJECT.run("dotnet new nunit -lang C# --name #{name}.Test --output test/#{name}.Test") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
120
- PROJECT.run("dotnet sln #{name}.sln add test/#{name}.Test/#{name}.Test.csproj") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
121
- PROJECT.run("dotnet add test/#{name}.Test/#{name}.Test.csproj reference src/#{name}/#{name}.csproj") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
122
- # create a blazor server example
123
- PROJECT.run("dotnet new blazorserver -lang C# --name #{name}.BlazorServer --output examples/#{name}.BlazorServer") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
124
- PROJECT.run("dotnet sln #{name}.sln add examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
125
- PROJECT.run("dotnet add examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj reference src/#{name}/#{name}.csproj") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
126
- # generate project folders
127
- ["Interfaces", "Extensions", "Models", "Components", "Controllers"].each do |folder|
128
- FileUtils.mkdir_p("src/#{name}/#{folder}") unless Dir.exist?("src/#{name}/#{folder}")
129
- FileUtils.mkdir_p("test/#{name}.Test/#{folder}") unless Dir.exist?("test/#{name}.Test/#{folder}")
130
- FileUtils.mkdir_p("examples/#{name}.BlazorServer/#{folder}") unless Dir.exist?("examples/#{name}.BlazorServer/#{folder}")
131
- end
132
- end
133
-
134
- # initialize a C# blazor server application
135
- def self.initialize_csharp_blazorserver(name)
136
- # create the solution
137
- puts " creating #{name}.sln" unless File.exist?("#{name}.sln")
138
- # create the blazor server application
139
- puts " creating src/#{name}/#{name}.csproj" unless File.exist?("src/#{name}/#{name}.csproj")
140
- PROJECT.run("dotnet new blazorserver -lang C# --name #{name} --output src/#{name}") unless File.exist?("src/#{name}/#{name}.csproj")
141
- PROJECT.run("dotnet sln #{name}.sln add src/#{name}/#{name}.csproj") unless File.exist?("src/#{name}/#{name}.csproj")
142
- # generate project folders
143
- ["Interfaces", "Extensions", "Models", "Components", "Controllers"].each do |folder|
144
- FileUtils.mkdir_p("src/#{name}/#{folder}") unless Dir.exist?("src/#{name}/#{folder}")
145
- end
146
- end
147
-
148
- # initialize a C# blazor server example application
149
- def self.initialize_csharp_blazorserver_example(name)
150
- # create the solution
151
- puts " creating #{name}.sln" unless File.exist?("#{name}.sln")
152
- # create the blazor server application
153
- puts " creating examples/#{name}/#{name}.csproj" unless File.exist?("examples/#{name}/#{name}.csproj")
154
- PROJECT.run("dotnet new blazorserver -lang C# --name #{name} --output examples/#{name}") unless File.exist?("examples/#{name}/#{name}.csproj")
155
- PROJECT.run("dotnet sln #{name}.sln add examples/#{name}/#{name}.csproj") unless File.exist?("examples/#{name}/#{name}.csproj")
156
- # generate project folders
157
- ["Interfaces", "Extensions", "Models", "Components", "Controllers"].each do |folder|
158
- FileUtils.mkdir_p("examples/#{name}/#{folder}") unless Dir.exist?("examples/#{name}/#{folder}")
159
- end
160
- end
161
-
162
- def self.get_package_names(filename)
163
- package_names = []
164
- if File.exist?(filename) && filename.include?(".csproj")
165
- regex = /<PackageReference Include="([\w.-]+)"/
166
- text = IO.read(filename)
167
- text.scan(regex).each do |m|
168
- package_names << m.first.to_s
169
- end
170
- end
171
- package_names
172
- end
173
- end
174
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Raykit
4
+ class DotNet
5
+ def self.init_new(name, template)
6
+ if (!File.exist?("#{name}/#{name}.csproj"))
7
+ puts " #{name}.csproj not found, creating..."
8
+ run("dotnet new #{template} --name #{name} --output #{name} --language C# ")
9
+ else
10
+ puts " #{name}.csproj already exists"
11
+ end
12
+ end
13
+
14
+ # initialize an F# library
15
+ def self.initialize_fsharp_lib(name)
16
+ puts `dotnet new sln --name #{name}` unless File.exist?("#{name}.sln")
17
+ unless Dir.exist?(name)
18
+ FileUtils.mkdir(name)
19
+ Dir.chdir(name) do
20
+ puts `dotnet new classlib -lang F#`
21
+ end
22
+ # puts `dotnet new sln`
23
+ puts `dotnet sln #{name}.sln add #{name}/#{name}.fsproj`
24
+
25
+ FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
26
+ Dir.chdir("#{name}.Test") do
27
+ puts `dotnet new nunit -lang F#`
28
+ puts `dotnet add reference ../#{name}/#{name}.fsproj`
29
+ end
30
+
31
+ puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.fsproj`
32
+ end
33
+ end
34
+
35
+ # initialize a C# console application
36
+ def self.initialize_csharp_console(name)
37
+ unless Dir.exist?(name)
38
+ FileUtils.mkdir(name)
39
+ Dir.chdir(name) do
40
+ puts `dotnet new console -lang C#`
41
+ end
42
+ puts `dotnet new sln`
43
+ puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
44
+
45
+ FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
46
+ Dir.chdir("#{name}.Test") do
47
+ puts `dotnet new nunit -lang C#`
48
+ puts `dotnet add reference ../#{name}/#{name}.csproj`
49
+ end
50
+
51
+ puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.csproj`
52
+ end
53
+ end
54
+
55
+ # initialize a C# wpf application
56
+ def self.initialize_csharp_wpf_application(name)
57
+ puts `dotnet new sln --name #{name}`
58
+ unless Dir.exist?(name)
59
+ FileUtils.mkdir(name)
60
+ Dir.chdir(name) do
61
+ puts `dotnet new wpf -lang C#`
62
+ end
63
+ end
64
+ puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
65
+ initialize_csharp_lib("#{name}.Library")
66
+ puts `dotnet sln #{name}.sln add #{name}.Library/#{name}.Library.csproj`
67
+ puts `dotnet sln #{name}.sln add #{name}.Library.Test/#{name}.Library.Test.csproj`
68
+ end
69
+
70
+ # initialize a C# worker service
71
+ def self.initialize_csharp_service(name)
72
+ unless Dir.exist?(name)
73
+ FileUtils.mkdir(name)
74
+ Dir.chdir(name) do
75
+ puts `dotnet new worker -lang C#`
76
+ end
77
+ puts `dotnet new sln`
78
+ puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
79
+ end
80
+ end
81
+
82
+ # initialize a C# library
83
+ def self.initialize_csharp_lib(name)
84
+ # create the solution
85
+ puts " creating #{name}.sln" unless File.exist?("#{name}.sln")
86
+ PROJECT.run("dotnet new sln --name #{name}") unless File.exist?("#{name}.sln")
87
+ # create the library
88
+ puts " creating src/#{name}/#{name}.csproj" unless File.exist?("src/#{name}/#{name}.csproj")
89
+ PROJECT.run("dotnet new classlib -lang C# --name #{name} --output src/#{name}") unless File.exist?("src/#{name}/#{name}.csproj")
90
+ PROJECT.run("dotnet sln #{name}.sln add src/#{name}/#{name}.csproj") unless File.exist?("src/#{name}/#{name}.csproj")
91
+ # create the test
92
+ puts " creating test/#{name}.Test/#{name}.Test.csproj" unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
93
+ PROJECT.run("dotnet new nunit -lang C# --name #{name}.Test --output test/#{name}.Test") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
94
+ PROJECT.run("dotnet sln #{name}.sln add test/#{name}.Test/#{name}.Test.csproj") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
95
+ PROJECT.run("dotnet add test/#{name}.Test/#{name}.Test.csproj reference src/#{name}/#{name}.csproj") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
96
+ # create a blazor server example
97
+ PROJECT.run("dotnet new blazorserver -lang C# --name #{name}.BlazorServer --output examples/#{name}.BlazorServer") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
98
+ PROJECT.run("dotnet sln #{name}.sln add examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
99
+ PROJECT.run("dotnet add examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj reference src/#{name}/#{name}.csproj") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
100
+ # generate project folders
101
+ ["Interfaces", "Extensions", "Models"].each do |folder|
102
+ FileUtils.mkdir_p("src/#{name}/#{folder}") unless Dir.exist?("src/#{name}/#{folder}")
103
+ FileUtils.mkdir_p("test/#{name}.Test/#{folder}") unless Dir.exist?("test/#{name}.Test/#{folder}")
104
+ FileUtils.mkdir_p("examples/#{name}.BlazorServer/#{folder}") unless Dir.exist?("examples/#{name}.BlazorServer/#{folder}")
105
+ end
106
+ end
107
+
108
+ # initialize a C# razor class library
109
+ def self.initialize_csharp_razorclasslib(name)
110
+ # create the solution
111
+ puts " creating #{name}.sln" unless File.exist?("#{name}.sln")
112
+ PROJECT.run("dotnet new sln --name #{name}") unless File.exist?("#{name}.sln")
113
+ # create the library
114
+ puts " creating src/#{name}/#{name}.csproj" unless File.exist?("src/#{name}/#{name}.csproj")
115
+ PROJECT.run("dotnet new razorclasslib -lang C# --name #{name} --output src/#{name}") unless File.exist?("src/#{name}/#{name}.csproj")
116
+ PROJECT.run("dotnet sln #{name}.sln add src/#{name}/#{name}.csproj") unless File.exist?("src/#{name}/#{name}.csproj")
117
+ # create the test
118
+ puts " creating test/#{name}.Test/#{name}.Test.csproj" unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
119
+ PROJECT.run("dotnet new nunit -lang C# --name #{name}.Test --output test/#{name}.Test") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
120
+ PROJECT.run("dotnet sln #{name}.sln add test/#{name}.Test/#{name}.Test.csproj") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
121
+ PROJECT.run("dotnet add test/#{name}.Test/#{name}.Test.csproj reference src/#{name}/#{name}.csproj") unless File.exist?("test/#{name}.Test/#{name}.Test.csproj")
122
+ # create a blazor server example
123
+ PROJECT.run("dotnet new blazorserver -lang C# --name #{name}.BlazorServer --output examples/#{name}.BlazorServer") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
124
+ PROJECT.run("dotnet sln #{name}.sln add examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
125
+ PROJECT.run("dotnet add examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj reference src/#{name}/#{name}.csproj") unless File.exist?("examples/#{name}.BlazorServer/#{name}.BlazorServer.csproj")
126
+ # generate project folders
127
+ ["Interfaces", "Extensions", "Models", "Components", "Controllers"].each do |folder|
128
+ FileUtils.mkdir_p("src/#{name}/#{folder}") unless Dir.exist?("src/#{name}/#{folder}")
129
+ FileUtils.mkdir_p("test/#{name}.Test/#{folder}") unless Dir.exist?("test/#{name}.Test/#{folder}")
130
+ FileUtils.mkdir_p("examples/#{name}.BlazorServer/#{folder}") unless Dir.exist?("examples/#{name}.BlazorServer/#{folder}")
131
+ end
132
+ end
133
+
134
+ # initialize a C# blazor server application
135
+ def self.initialize_csharp_blazorserver(name)
136
+ # create the solution
137
+ puts " creating #{name}.sln" unless File.exist?("#{name}.sln")
138
+ PROJECT.run("dotnet new sln --name #{name}") unless File.exist?("#{name}.sln")
139
+ # create the blazor server application
140
+ puts " creating src/#{name}/#{name}.csproj" unless File.exist?("src/#{name}/#{name}.csproj")
141
+ PROJECT.run("dotnet new blazorserver -lang C# --name #{name} --output src/#{name}") unless File.exist?("src/#{name}/#{name}.csproj")
142
+ PROJECT.run("dotnet sln #{name}.sln add src/#{name}/#{name}.csproj") unless File.exist?("src/#{name}/#{name}.csproj")
143
+ # generate project folders
144
+ ["Interfaces", "Extensions", "Models", "Components", "Controllers"].each do |folder|
145
+ FileUtils.mkdir_p("src/#{name}/#{folder}") unless Dir.exist?("src/#{name}/#{folder}")
146
+ end
147
+ end
148
+
149
+ # initialize a C# blazor server example application
150
+ def self.initialize_csharp_blazorserver_example(name)
151
+ # create the solution
152
+ puts " creating #{name}.sln" unless File.exist?("#{name}.sln")
153
+ PROJECT.run("dotnet new sln --name #{name}") unless File.exist?("#{name}.sln")
154
+ # create the blazor server application
155
+ puts " creating examples/#{name}/#{name}.csproj" unless File.exist?("examples/#{name}/#{name}.csproj")
156
+ PROJECT.run("dotnet new blazorserver -lang C# --name #{name} --output examples/#{name}") unless File.exist?("examples/#{name}/#{name}.csproj")
157
+ PROJECT.run("dotnet sln #{name}.sln add examples/#{name}/#{name}.csproj") unless File.exist?("examples/#{name}/#{name}.csproj")
158
+ # generate project folders
159
+ ["Interfaces", "Extensions", "Models", "Components", "Controllers"].each do |folder|
160
+ FileUtils.mkdir_p("examples/#{name}/#{folder}") unless Dir.exist?("examples/#{name}/#{folder}")
161
+ end
162
+ end
163
+
164
+ def self.get_package_names(filename)
165
+ package_names = []
166
+ if File.exist?(filename) && filename.include?(".csproj")
167
+ regex = /<PackageReference Include="([\w.-]+)"/
168
+ text = IO.read(filename)
169
+ text.scan(regex).each do |m|
170
+ package_names << m.first.to_s
171
+ end
172
+ end
173
+ package_names
174
+ end
175
+ end
176
+ end
@@ -1,109 +1,109 @@
1
- # frozen_string_literal: true
2
-
3
- require "pathname"
4
-
5
- module Raykit
6
- # Provides functionality related to the development environment
7
- class Environment
8
- # Normalize a directory or filename to use forward slashes
9
- def self.normalize_path(name)
10
- if (windows?)
11
- normalize_windows(name)
12
- else
13
- normalize_unix(name)
14
- end
15
- end
16
-
17
- def self.normalize_unix(name)
18
- name.gsub('\\', "/")
19
- end
20
-
21
- def self.normalize_windows(name)
22
- name.gsub("/", '\\')
23
- end
24
-
25
- def self.windows?
26
- Gem.win_platform?
27
- end
28
-
29
- # The root directory for the development environment.
30
- # May be set using the environment variable DEV_ROOT,
31
- # otherwise defaults to the user home directory
32
- def self.root_dir
33
- if ENV["DEV_ROOT"].nil?
34
- Environment.home_dir
35
- else
36
- root = ENV["DEV_ROOT"].gsub("\\", "/").chomp("/")
37
- normalize_path(root)
38
- end
39
- end
40
-
41
- # The user home directory
42
- def self.home_dir
43
- return normalize_path(ENV["USERPROFILE"]) if ENV.include?("USERPROFILE")
44
- normalize_path(ENV["HOME"])
45
- end
46
-
47
- def self.log_dir
48
- get_dev_dir("log")
49
- end
50
-
51
- # Get, and create if it does not exist, a specific development directory
52
- def self.get_dev_dir(name)
53
- dir = Pathname.new("#{Environment.root_dir}/#{name}")
54
- dir.mkpath
55
- if (dir.to_s.include?("https:") || dir.to_s.include?("http:"))
56
- normalize_path(dir.to_s.gsub("https://", ".").gsub("http://", ".").gsub("//", "/"))
57
- else
58
- normalize_path(dir.to_s)
59
- end
60
- end
61
-
62
- def self.get_work_dir(url)
63
- "#{Raykit::Environment.get_dev_dir("work")}/#{url.gsub(".git", "").gsub("://", ".")}"
64
- end
65
-
66
- # Get the size of a directory and its contents
67
- def self.get_dir_size(dir)
68
- Dir.glob(File.join(dir, "**", "*"))
69
- .map { |f| File.size(f) }
70
- .inject(:+)
71
- end
72
-
73
- def self.machine
74
- return ENV["COMPUTERNAME"] unless ENV["COMPUTERNAME"].nil?
75
-
76
- machine = `hostname`
77
- machine = machine.split(".")[0] if machine.include?(".")
78
- machine.strip
79
- end
80
-
81
- def self.user
82
- ENV["USERNAME"]
83
- end
84
-
85
- def self.local_application_data
86
- "#{ENV["USERPROFILE"]}/AppData/Local".gsub('\\', "/")
87
- end
88
-
89
- def self.admin?
90
- rights = `whoami /priv`
91
- rights.include?("SeCreateGlobalPrivilege")
92
- end
93
-
94
- def self.which(name)
95
- return name if File.exist?(name)
96
-
97
- ["", ".exe", ".bat", ".cmd"].each do |ext|
98
- aname = name + ext
99
- return aname if File.exist?(aname)
100
-
101
- ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
102
- apath = "#{path.gsub('\\', "/")}/#{aname}".gsub("//", "/")
103
- return apath if File.exist?(apath)
104
- end
105
- end
106
- ""
107
- end
108
- end
109
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+
5
+ module Raykit
6
+ # Provides functionality related to the development environment
7
+ class Environment
8
+ # Normalize a directory or filename to use forward slashes
9
+ def self.normalize_path(name)
10
+ if (windows?)
11
+ normalize_windows(name)
12
+ else
13
+ normalize_unix(name)
14
+ end
15
+ end
16
+
17
+ def self.normalize_unix(name)
18
+ name.gsub('\\', "/")
19
+ end
20
+
21
+ def self.normalize_windows(name)
22
+ name.gsub("/", '\\')
23
+ end
24
+
25
+ def self.windows?
26
+ Gem.win_platform?
27
+ end
28
+
29
+ # The root directory for the development environment.
30
+ # May be set using the environment variable DEV_ROOT,
31
+ # otherwise defaults to the user home directory
32
+ def self.root_dir
33
+ if ENV["DEV_ROOT"].nil?
34
+ Environment.home_dir
35
+ else
36
+ root = ENV["DEV_ROOT"].gsub("\\", "/").chomp("/")
37
+ normalize_path(root)
38
+ end
39
+ end
40
+
41
+ # The user home directory
42
+ def self.home_dir
43
+ return normalize_path(ENV["USERPROFILE"]) if ENV.include?("USERPROFILE")
44
+ normalize_path(ENV["HOME"])
45
+ end
46
+
47
+ def self.log_dir
48
+ get_dev_dir("log")
49
+ end
50
+
51
+ # Get, and create if it does not exist, a specific development directory
52
+ def self.get_dev_dir(name)
53
+ dir = Pathname.new("#{Environment.root_dir}/#{name}")
54
+ dir.mkpath
55
+ if (dir.to_s.include?("https:") || dir.to_s.include?("http:"))
56
+ normalize_path(dir.to_s.gsub("https://", ".").gsub("http://", ".").gsub("//", "/"))
57
+ else
58
+ normalize_path(dir.to_s)
59
+ end
60
+ end
61
+
62
+ def self.get_work_dir(url)
63
+ "#{Raykit::Environment.get_dev_dir("work")}/#{url.gsub(".git", "").gsub("://", ".")}"
64
+ end
65
+
66
+ # Get the size of a directory and its contents
67
+ def self.get_dir_size(dir)
68
+ Dir.glob(File.join(dir, "**", "*"))
69
+ .map { |f| File.size(f) }
70
+ .inject(:+)
71
+ end
72
+
73
+ def self.machine
74
+ return ENV["COMPUTERNAME"] unless ENV["COMPUTERNAME"].nil?
75
+
76
+ machine = `hostname`
77
+ machine = machine.split(".")[0] if machine.include?(".")
78
+ machine.strip
79
+ end
80
+
81
+ def self.user
82
+ ENV["USERNAME"]
83
+ end
84
+
85
+ def self.local_application_data
86
+ "#{ENV["USERPROFILE"]}/AppData/Local".gsub('\\', "/")
87
+ end
88
+
89
+ def self.admin?
90
+ rights = `whoami /priv`
91
+ rights.include?("SeCreateGlobalPrivilege")
92
+ end
93
+
94
+ def self.which(name)
95
+ return name if File.exist?(name)
96
+
97
+ ["", ".exe", ".bat", ".cmd"].each do |ext|
98
+ aname = name + ext
99
+ return aname if File.exist?(aname)
100
+
101
+ ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
102
+ apath = "#{path.gsub('\\', "/")}/#{aname}".gsub("//", "/")
103
+ return apath if File.exist?(apath)
104
+ end
105
+ end
106
+ ""
107
+ end
108
+ end
109
+ end
@@ -1,34 +1,34 @@
1
- module Raykit
2
- class FileSystem
3
- def self.copy_files(source_dir, target_dir, glob_pattern)
4
- FileUtils.mkdir_p(target_dir) if !Dir.exist?(target_dir)
5
- #Dir.chdir(source_dir) do
6
- file_count = 0
7
- Dir.glob("#{source_dir}/#{glob_pattern}").each { |f|
8
- rel = f.gsub("#{source_dir}/", "")
9
- dest = "#{target_dir}/#{rel}"
10
- FileUtils.mkdir_p(File.dirname(dest)) if (!Dir.exist?(File.dirname(dest)))
11
- #puts " copying #{rel} to #{dest}"
12
- FileUtils.cp(f, dest)
13
- file_count = file_count + 1
14
- }
15
- #end
16
- puts " copied " + file_count.to_s + " file(s) from #{source_dir} to #{target_dir}"
17
- end
18
-
19
- def self.copy_file_to_dir(file, dir)
20
- dest = "#{dir}/#{File.basename(file)}"
21
- if (File.exist?(dest))
22
- return "#{dest} already exists"
23
- else
24
- FileUtils.cp(file, dest)
25
- return "#{dest} now exists"
26
- end
27
- end
28
-
29
- def self.replace_invalid_chars(str)
30
- #[\\/:"*?<>|]
31
- str.gsub('\\', "_").gsub("/", "_").gsub(":", "_").gsub("*", "_").gsub("?", "_")
32
- end
33
- end
34
- end
1
+ module Raykit
2
+ class FileSystem
3
+ def self.copy_files(source_dir, target_dir, glob_pattern)
4
+ FileUtils.mkdir_p(target_dir) if !Dir.exist?(target_dir)
5
+ #Dir.chdir(source_dir) do
6
+ file_count = 0
7
+ Dir.glob("#{source_dir}/#{glob_pattern}").each { |f|
8
+ rel = f.gsub("#{source_dir}/", "")
9
+ dest = "#{target_dir}/#{rel}"
10
+ FileUtils.mkdir_p(File.dirname(dest)) if (!Dir.exist?(File.dirname(dest)))
11
+ #puts " copying #{rel} to #{dest}"
12
+ FileUtils.cp(f, dest)
13
+ file_count = file_count + 1
14
+ }
15
+ #end
16
+ puts " copied " + file_count.to_s + " file(s) from #{source_dir} to #{target_dir}"
17
+ end
18
+
19
+ def self.copy_file_to_dir(file, dir)
20
+ dest = "#{dir}/#{File.basename(file)}"
21
+ if (File.exist?(dest))
22
+ return "#{dest} already exists"
23
+ else
24
+ FileUtils.cp(file, dest)
25
+ return "#{dest} now exists"
26
+ end
27
+ end
28
+
29
+ def self.replace_invalid_chars(str)
30
+ #[\\/:"*?<>|]
31
+ str.gsub('\\', "_").gsub("/", "_").gsub(":", "_").gsub("*", "_").gsub("?", "_")
32
+ end
33
+ end
34
+ end