wooga_wooget 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +20 -0
- data/Gemfile +3 -0
- data/Licence.md +21 -0
- data/README.md +48 -0
- data/Rakefile +80 -0
- data/bin/wooget +5 -0
- data/lib/wooget.rb +57 -0
- data/lib/wooget/build/build_info.rb +64 -0
- data/lib/wooget/build/builder.rb +285 -0
- data/lib/wooget/cli.rb +293 -0
- data/lib/wooget/nuget.rb +96 -0
- data/lib/wooget/paket.rb +81 -0
- data/lib/wooget/project.rb +42 -0
- data/lib/wooget/releasing.rb +112 -0
- data/lib/wooget/template/files/README.md.erb +20 -0
- data/lib/wooget/template/files/RELEASE_NOTES.md.erb +2 -0
- data/lib/wooget/template/files/assemblyinfo.erb +36 -0
- data/lib/wooget/template/files/class.erb +15 -0
- data/lib/wooget/template/files/csproj.erb +56 -0
- data/lib/wooget/template/files/gitignore.erb +13 -0
- data/lib/wooget/template/files/metafile.cs.erb +11 -0
- data/lib/wooget/template/files/paket.binary.template.erb +17 -0
- data/lib/wooget/template/files/paket.dependencies.erb +13 -0
- data/lib/wooget/template/files/paket.references.erb +2 -0
- data/lib/wooget/template/files/paket.template.erb +22 -0
- data/lib/wooget/template/files/sln.erb +32 -0
- data/lib/wooget/template/files/test_file.erb +19 -0
- data/lib/wooget/template/files/tests_assemblyinfo.erb +36 -0
- data/lib/wooget/template/files/tests_csproj.erb +67 -0
- data/lib/wooget/template/files/unity_paket.dependencies.erb +12 -0
- data/lib/wooget/template/unity.rb +73 -0
- data/lib/wooget/template/visual_studio.rb +56 -0
- data/lib/wooget/template/wooget_conf.json +13 -0
- data/lib/wooget/third_party/paket.bootstrapper.exe +0 -0
- data/lib/wooget/third_party/paket.exe +0 -0
- data/lib/wooget/third_party/paket.targets +36 -0
- data/lib/wooget/third_party/paket.unity3d.bootstrapper.exe +0 -0
- data/lib/wooget/third_party/paket.unity3d.exe +0 -0
- data/lib/wooget/util/build_error.rb +8 -0
- data/lib/wooget/util/misc.rb +91 -0
- data/lib/wooget/util/package_list_formatter.rb +59 -0
- data/lib/wooget/version.rb +22 -0
- data/tests/nuget_feed.xml +3439 -0
- data/tests/nuget_package.xml +49 -0
- data/tests/nuget_test.rb +27 -0
- data/tests/package_test.rb +72 -0
- data/tests/unity_test.rb +12 -0
- data/wiki/bootstrap.png +0 -0
- data/wiki/compiling.png +0 -0
- data/wiki/create.png +0 -0
- data/wiki/install.png +0 -0
- data/wiki/list.png +0 -0
- data/wiki/monodevelop.png +0 -0
- data/wiki/release.png +0 -0
- data/wiki/stupidmenu.png +0 -0
- data/wooget.gemspec +33 -0
- metadata +244 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 450aa53eefa1765b437a8b823aa27835643009bf
|
4
|
+
data.tar.gz: 335ec5c8076deb9f1341acd7bad251cbc28d7014
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bfc196dd5fda2c08b5fa808c51184efda609addb607d6b08b84434c02e779177485427f98ee28b55399a710873ea24f0c802d780d4560fbcb4462a2b3542879b
|
7
|
+
data.tar.gz: 2e72bbf5999f23f711478fbf741ef85fde6a5cf2045483a3f2a5e0fdf13ccb9c4788068e1076db67a7c35e139e8580caee95f0c579fffc4b856bfc72f1c7cc04
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
|
4
|
+
script: bundle exec ruby tests/package_test.rb
|
5
|
+
|
6
|
+
rvm:
|
7
|
+
- 2.3.0
|
8
|
+
- 2.2
|
9
|
+
- 2.1
|
10
|
+
- 2.0
|
11
|
+
- ruby-head
|
12
|
+
- rbx-2
|
13
|
+
- jruby-head
|
14
|
+
- jruby-9000
|
15
|
+
|
16
|
+
cache:
|
17
|
+
- bundler
|
18
|
+
|
19
|
+
# matrix:
|
20
|
+
# fast_finish: true
|
data/Gemfile
ADDED
data/Licence.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Wooga
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# wooget
|
2
|
+
|
3
|
+
A cli which allows [Unity3d](http://www.unity3d.com) projects to work with NuGet packages.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
* Configures Unity3d to work with NuGet
|
8
|
+
* Install and update packages
|
9
|
+
* List and search available packages
|
10
|
+
* Create, Build, Test and Release new NuGet packages
|
11
|
+
|
12
|
+
> Checkout [the wiki](https://github.com/wooga/wooget/wiki/) for more information
|
13
|
+
|
14
|
+
## Install
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem sources -a http://gem.sdk.wooga.com/
|
18
|
+
gem install wooga_wooget
|
19
|
+
```
|
20
|
+
|
21
|
+
> If you are working at wooga, you will need to copy the internal repo configuration from https://github.com/wooga/wdk-docs/wiki to ~/.wooget
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```
|
26
|
+
Commands:
|
27
|
+
wooget bootstrap # setup environment / project for wooget usage
|
28
|
+
wooget build --version=VERSION # build the packages in the current dir
|
29
|
+
wooget create PACKAGE_NAME # create a new package
|
30
|
+
wooget help [COMMAND] # Describe available commands or one specific command
|
31
|
+
wooget install # install packages into this unity project
|
32
|
+
wooget list # list available packages + version
|
33
|
+
wooget paket ARGS # call bundled version of paket and pass args
|
34
|
+
wooget paket_unity3d ARGS # call bundled version of paket.unity3d and pass args
|
35
|
+
wooget prerelease # prerelease package in current dir
|
36
|
+
wooget release # release package in current dir
|
37
|
+
wooget search # search packages by a regex
|
38
|
+
wooget test # run package tests in mono
|
39
|
+
wooget update # update packages into this unity project
|
40
|
+
|
41
|
+
Options:
|
42
|
+
-v, [--verbose], [--no-verbose] # Spit out tons of logging info
|
43
|
+
-q, [--quiet], [--no-quiet] # Suppress stdout
|
44
|
+
[--path=PATH] # Path to the project you want to install things into
|
45
|
+
# Default: /Users/donaldhutchison/workspace/wooget
|
46
|
+
|
47
|
+
```
|
48
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# # #
|
2
|
+
# Get gemspec info
|
3
|
+
require 'octokit'
|
4
|
+
require 'json'
|
5
|
+
require 'httpclient'
|
6
|
+
|
7
|
+
gemspec_file = Dir['*.gemspec'].first
|
8
|
+
gemspec = eval File.read(gemspec_file), binding, gemspec_file
|
9
|
+
info = "#{gemspec.name} | #{gemspec.version} | " \
|
10
|
+
"#{gemspec.runtime_dependencies.size} dependencies | " \
|
11
|
+
"#{gemspec.files.size} files"
|
12
|
+
|
13
|
+
|
14
|
+
# # #
|
15
|
+
# Gem build and install task
|
16
|
+
|
17
|
+
desc info
|
18
|
+
task :gem do
|
19
|
+
%w(pry-byebug binding.pry).each do |dbg|
|
20
|
+
files = `ack -ir #{dbg} lib`
|
21
|
+
abort "debuggin statements left in! - #{files}" if $?.exitstatus == 0
|
22
|
+
end
|
23
|
+
|
24
|
+
puts info + "\n\n"
|
25
|
+
print " "; sh "gem build #{gemspec_file}"
|
26
|
+
FileUtils.mkdir_p 'pkg'
|
27
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "create github release"
|
31
|
+
task :github_release => :gem do
|
32
|
+
name = "#{gemspec.name}-#{gemspec.version}"
|
33
|
+
access_token = JSON.parse(File.open(File.expand_path("~/.wooget")).read)["credentials"]["github_token"]
|
34
|
+
|
35
|
+
#create github release
|
36
|
+
puts "Preparing github release #{name}"
|
37
|
+
git_url = `git remote get-url origin`.chomp.chomp ".git"
|
38
|
+
url = git_url.split(":").last
|
39
|
+
repo_name = url.split('/').last(2).join("/")
|
40
|
+
|
41
|
+
client = Octokit::Client.new access_token: access_token
|
42
|
+
|
43
|
+
release_options = {
|
44
|
+
draft: true,
|
45
|
+
name: gemspec.version,
|
46
|
+
body: "Release #{gemspec.version}"
|
47
|
+
}
|
48
|
+
|
49
|
+
release = client.create_release repo_name, name, release_options
|
50
|
+
#puts "uploading assets"
|
51
|
+
#client.upload_asset release.url, "pkg/#{name}", {content_type: "application/x-gzip" }
|
52
|
+
puts "publishing.."
|
53
|
+
client.update_release release.url, {draft: false}
|
54
|
+
puts "done"
|
55
|
+
end
|
56
|
+
|
57
|
+
task :install => :gem do
|
58
|
+
puts
|
59
|
+
sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
|
60
|
+
end
|
61
|
+
|
62
|
+
#internal only
|
63
|
+
desc "push to gem.sdk.wooga.com"
|
64
|
+
task :inabox => :gem do
|
65
|
+
client = HTTPClient.new ""
|
66
|
+
name = "#{gemspec.name}-#{gemspec.version}.gem"
|
67
|
+
resp = client.post "http://gem.sdk.wooga.com/upload", {'file'=> File.open(File.join("pkg",name))}
|
68
|
+
puts "response from gem.sdk.wooga.com #{resp.body}"
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "build, push to gem server and create github release"
|
72
|
+
task :release =>[:gem, :inabox, :github_release]
|
73
|
+
|
74
|
+
# # #
|
75
|
+
# Start an IRB session with the gem loaded
|
76
|
+
|
77
|
+
desc "#{gemspec.name} | IRB"
|
78
|
+
task :irb do
|
79
|
+
sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
|
80
|
+
end
|
data/bin/wooget
ADDED
data/lib/wooget.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative "wooget/version"
|
2
|
+
require_relative "wooget/cli"
|
3
|
+
require_relative "wooget/releasing"
|
4
|
+
require_relative "wooget/build/build_info"
|
5
|
+
require_relative "wooget/build/builder"
|
6
|
+
require_relative "wooget/project"
|
7
|
+
require_relative "wooget/paket"
|
8
|
+
require_relative "wooget/nuget"
|
9
|
+
require_relative "wooget/util/misc"
|
10
|
+
require_relative "wooget/util/package_list_formatter"
|
11
|
+
require_relative "wooget/template/visual_studio"
|
12
|
+
require_relative "wooget/template/unity"
|
13
|
+
require_relative "wooget/util/build_error"
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
# Gem.find_files("wooget/**/*.rb").each { |path| require path }
|
18
|
+
|
19
|
+
require 'logger'
|
20
|
+
|
21
|
+
module Wooget
|
22
|
+
@@log = Logger.new(STDOUT)
|
23
|
+
@@log.level = Logger::Severity::ERROR
|
24
|
+
@@log.formatter = proc do |severity, datetime, progname, msg|
|
25
|
+
msg = msg + "\n" unless msg.end_with? "\n"
|
26
|
+
msg.start_with?("[quiet]") ? "#{msg.sub("[quiet]","")}" : "[#{severity} #{datetime}] : #{msg}"
|
27
|
+
end
|
28
|
+
|
29
|
+
@@credentials = {username: "", password: "", github_token: ""}
|
30
|
+
@@repos = {:default => "legacy"}
|
31
|
+
|
32
|
+
def self.log
|
33
|
+
@@log
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.log= log
|
37
|
+
@@log = log
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.credentials
|
41
|
+
@@credentials
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.no_status_log msg
|
45
|
+
@@log.debug "[quiet]"+msg.uncolorize
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.repos
|
49
|
+
@@repos
|
50
|
+
end
|
51
|
+
|
52
|
+
#default repositiory to use
|
53
|
+
def self.repo
|
54
|
+
@@repos[:default]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
3
|
+
module Wooget
|
4
|
+
module Build
|
5
|
+
class BuildInfo
|
6
|
+
attr_accessor :template_files, :output_dir, :version, :release_notes, :project_root
|
7
|
+
attr_reader :package_ids
|
8
|
+
|
9
|
+
def initialize template_files=[], output_dir=Dir.pwd, version="919.919.919", release_notes="no notes!", project_root=Dir.pwd
|
10
|
+
|
11
|
+
@template_files = template_files
|
12
|
+
@output_dir = output_dir
|
13
|
+
@version = version
|
14
|
+
@release_notes = release_notes
|
15
|
+
|
16
|
+
@invalid_reason = []
|
17
|
+
@project_root = project_root
|
18
|
+
@package_ids = get_ids
|
19
|
+
end
|
20
|
+
|
21
|
+
def package_names
|
22
|
+
@package_ids.map { |id| [id, @version, "nupkg"].join "." }
|
23
|
+
end
|
24
|
+
|
25
|
+
def invalid_reason
|
26
|
+
@invalid_reason.join ", "
|
27
|
+
end
|
28
|
+
|
29
|
+
def valid?
|
30
|
+
valid = true
|
31
|
+
|
32
|
+
unless Util.valid_version_string? @version
|
33
|
+
@invalid_reason << "Invalid version string #{@version}"
|
34
|
+
valid = false
|
35
|
+
end
|
36
|
+
|
37
|
+
unless @template_files.length > 0
|
38
|
+
@invalid_reason << "No template files provided"
|
39
|
+
valid = false
|
40
|
+
end
|
41
|
+
|
42
|
+
valid
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_name
|
46
|
+
"#{File.basename(@project_root).downcase}-#{version}".shellescape
|
47
|
+
end
|
48
|
+
|
49
|
+
def needs_dll_build?
|
50
|
+
@template_files.map { |f| Util.file_contains? File.join(project_root, f), "type project" }.any?
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
def get_ids
|
55
|
+
@template_files.map do |template|
|
56
|
+
package_path = template
|
57
|
+
package_path = File.join(project_root, template) unless Pathname(template).absolute?
|
58
|
+
|
59
|
+
File.read(package_path).scan(/id (.*)/).flatten.first
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,285 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
module Wooget
|
3
|
+
module Build
|
4
|
+
class Builder < Thor
|
5
|
+
class_option :git, desc: "Use git functionality", type: :boolean, default: true
|
6
|
+
class_option :git_push, desc: "Auto push to git", type: :boolean, default: true
|
7
|
+
class_option :git_release, desc: "Create github release", type: :boolean, default: true
|
8
|
+
class_option :native, desc: "Invoke native build functionality", type: :boolean, default: true
|
9
|
+
no_commands do
|
10
|
+
def perform_build build_info
|
11
|
+
setup_failure_reason = setup build_info
|
12
|
+
return setup_failure_reason unless setup_failure_reason.nil?
|
13
|
+
|
14
|
+
build_result = create_packages(build_info)
|
15
|
+
return if build_result == :fail
|
16
|
+
|
17
|
+
built_packages = build_info.package_names.map { |p| File.join(options[:output_dir], p) }
|
18
|
+
|
19
|
+
#dirty hack to prevent unit test versions being pushed
|
20
|
+
if build_info.version == "919.919.919"
|
21
|
+
Wooget.log.warn "Test packages detected! aborting push"
|
22
|
+
return build_info.package_names
|
23
|
+
end
|
24
|
+
|
25
|
+
post_build build_info, built_packages
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def setup build_info
|
32
|
+
build_native_extensions if options[:native]
|
33
|
+
end
|
34
|
+
|
35
|
+
def post_build build_info, built_packages
|
36
|
+
push_packages(built_packages)
|
37
|
+
|
38
|
+
if options[:git]
|
39
|
+
_, exit_status = Util.run_cmd "git rev-parse --is-inside-work-tree", options[:path]
|
40
|
+
if exit_status == 0
|
41
|
+
|
42
|
+
commit_and_push build_info if options[:git_push]
|
43
|
+
github_release build_info, built_packages if options[:git_release]
|
44
|
+
|
45
|
+
else
|
46
|
+
Wooget.log.warn "Git requested, but #{options[:path]} doesn't appear to be a git repo"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
build_info.package_names
|
51
|
+
end
|
52
|
+
|
53
|
+
def commit_and_push build_info
|
54
|
+
Util.run_cmd "git commit -am '#{build_info.build_name}'"
|
55
|
+
Util.run_cmd "git tag '#{build_info.build_name}'"
|
56
|
+
Util.run_cmd "git push origin --tags"
|
57
|
+
Util.run_cmd "git push origin"
|
58
|
+
end
|
59
|
+
|
60
|
+
def github_release build_info, built_packages
|
61
|
+
if Wooget.credentials[:github_token].nil? or Wooget.credentials[:github_token].empty?
|
62
|
+
Wooget.log.error "Github Release Error - Couldn't find a value for github_token in the provided config"
|
63
|
+
return
|
64
|
+
end
|
65
|
+
|
66
|
+
#getting the github repo name from the url
|
67
|
+
#there must be a better way, but who cares
|
68
|
+
git_url = `git remote get-url origin`.chomp.chomp ".git"
|
69
|
+
url = git_url.split(":").last
|
70
|
+
repo_name = url.split('/').last(2).join("/")
|
71
|
+
|
72
|
+
Wooget.log.info "Connecting to github with access token.."
|
73
|
+
client = Octokit::Client.new access_token: Wooget.credentials[:github_token]
|
74
|
+
|
75
|
+
release_options = {
|
76
|
+
draft: true,
|
77
|
+
name: build_info.build_name,
|
78
|
+
body: build_info.release_notes
|
79
|
+
}
|
80
|
+
|
81
|
+
Wooget.log.info "Creating release '#{release_options[:name]}' on repo #{repo_name}"
|
82
|
+
release = client.create_release repo_name, build_info.build_name, release_options
|
83
|
+
Wooget.log.info "Uploading assets..."
|
84
|
+
built_packages.each { |package| client.upload_asset release.url, package, {content_type: "application/zip" }}
|
85
|
+
Wooget.log.info "Publishing release.."
|
86
|
+
client.update_release release.url, {draft: false}
|
87
|
+
end
|
88
|
+
|
89
|
+
def build_native_extensions
|
90
|
+
build_script_path = File.join(options[:path], "build.sh")
|
91
|
+
return unless File.exists? build_script_path
|
92
|
+
|
93
|
+
Wooget.log.info "External build script found - executing #{build_script_path}..."
|
94
|
+
stdout, status = Util.run_cmd("sh #{build_script_path}") { |p| Wooget.no_status_log("build.sh > "+p) }
|
95
|
+
raise BuildError "Native Build Error: #{stdout}" unless status == 0
|
96
|
+
end
|
97
|
+
|
98
|
+
def create_packages(build_info)
|
99
|
+
dll_build build_info if build_info.needs_dll_build?
|
100
|
+
|
101
|
+
update_metadata build_info
|
102
|
+
|
103
|
+
pack_options = {
|
104
|
+
output: options[:output_dir],
|
105
|
+
version: build_info.version,
|
106
|
+
release_notes: build_info.release_notes.shellescape,
|
107
|
+
path: build_info.project_root
|
108
|
+
}
|
109
|
+
|
110
|
+
stdout, status = Paket.pack pack_options
|
111
|
+
unless status == 0
|
112
|
+
Wooget.log.error "Pack error: #{stdout.join}"
|
113
|
+
return :fail
|
114
|
+
end
|
115
|
+
|
116
|
+
nil
|
117
|
+
end
|
118
|
+
|
119
|
+
def dll_build build_info
|
120
|
+
slns = Dir[File.join(build_info.project_root, "**/*.sln")]
|
121
|
+
abort "Can't find sln file for building test artifacts" if slns.empty?
|
122
|
+
|
123
|
+
slns.each do |sln|
|
124
|
+
next if Util.is_a_unity_project_dir(File.dirname(sln)) #don't build unity's sln file
|
125
|
+
|
126
|
+
build_log, exitstatus = Util.run_cmd("xbuild #{File.expand_path(sln)} /t:Rebuild /p:Configuration=Release") { |log| Wooget.no_status_log log }
|
127
|
+
|
128
|
+
raise BuildError, build_log.join unless exitstatus == 0
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def push_packages(built_packages)
|
133
|
+
if options[:push]
|
134
|
+
built_packages.each do |p|
|
135
|
+
if options[:confirm]
|
136
|
+
next unless yes?("Release #{p} to #{Wooget.repo}?")
|
137
|
+
end
|
138
|
+
|
139
|
+
auth = ""
|
140
|
+
if Wooget.repo == Wooget.repos[:public]
|
141
|
+
auth = Wooget.credentials[:nuget]
|
142
|
+
else
|
143
|
+
auth = "#{Wooget.credentials[:username]}:#{Wooget.credentials[:password]}"
|
144
|
+
end
|
145
|
+
|
146
|
+
Paket.push auth, Wooget.repo, p
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def update_metadata build_info
|
152
|
+
|
153
|
+
meta_files = Dir.glob(File.join(options[:path],"src", "**/*_meta.cs"))
|
154
|
+
|
155
|
+
build_info.package_ids.each do |id|
|
156
|
+
meta_files << Dir.glob(File.join(options[:path],"src", "**/*#{id.split(".").join("_")}*"))
|
157
|
+
end
|
158
|
+
|
159
|
+
meta_files.flatten!
|
160
|
+
meta_files.uniq!
|
161
|
+
|
162
|
+
meta_files.each do |file|
|
163
|
+
file_contents = File.open(file).each_line.to_a
|
164
|
+
file_contents.map! do |line|
|
165
|
+
if line =~ /public static readonly string version/
|
166
|
+
" public static readonly string version = \"#{build_info.version}\";\n"
|
167
|
+
else
|
168
|
+
line
|
169
|
+
end
|
170
|
+
end
|
171
|
+
File.open(file, "w") { |f| f << file_contents.join }
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class PrereleaseBuilder < Builder
|
177
|
+
private
|
178
|
+
def setup build_info
|
179
|
+
self.options = Thor::CoreExt::HashWithIndifferentAccess.new(options)
|
180
|
+
options[:stage] = "Prerelease"
|
181
|
+
|
182
|
+
fail_msg = check_prerelease_preconditions build_info
|
183
|
+
abort "Prerelease fail - '#{fail_msg}'" if fail_msg
|
184
|
+
|
185
|
+
set_prerelease_dependencies build_info
|
186
|
+
|
187
|
+
super
|
188
|
+
end
|
189
|
+
|
190
|
+
def check_prerelease_preconditions build_info
|
191
|
+
return "#{options[:path]} doesn't appear to be a valid package dir" unless Util.is_a_wooget_package_dir options[:path]
|
192
|
+
return "Not a prerelease version - \"#{build_info.version}\" found in RELEASE_NOTES.md" unless build_info.version =~ /prerelease/
|
193
|
+
end
|
194
|
+
|
195
|
+
def set_prerelease_dependencies build_info
|
196
|
+
paket_dependencies = []
|
197
|
+
File.open(File.join(options[:path], "paket.dependencies")).each do |line|
|
198
|
+
if line.match(/^\s*nuget\s+([\w\.]+)\s*$/)
|
199
|
+
paket_dependencies << line.chomp + " prerelease\n"
|
200
|
+
else
|
201
|
+
paket_dependencies << line
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
Wooget.log.debug "Writing out #{paket_dependencies.join} to paket.dependencies"
|
206
|
+
|
207
|
+
File.open(File.join(options[:path], "paket.dependencies"), "w") { |f| f << paket_dependencies.join }
|
208
|
+
|
209
|
+
#add prerelease to the dependencies section of paket.template files
|
210
|
+
build_info.template_files.each do |template|
|
211
|
+
paket_template = []
|
212
|
+
dependencies_section = false
|
213
|
+
|
214
|
+
File.open(File.join(options[:path], template)).each do |line|
|
215
|
+
|
216
|
+
if dependencies_section
|
217
|
+
#if this line is not indented we have left the dependencies section
|
218
|
+
unless line.match /^\s+/
|
219
|
+
dependencies_section = false
|
220
|
+
paket_template << line
|
221
|
+
next
|
222
|
+
end
|
223
|
+
|
224
|
+
#otherwise we append prerelease version tests (unless it's there already)
|
225
|
+
unless line.match />= 0.0.0-prerelease/
|
226
|
+
paket_template << "#{line.chomp} >= 0.0.0-prerelease\n"
|
227
|
+
next
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
if !dependencies_section and line.match /^dependencies/
|
232
|
+
dependencies_section = true
|
233
|
+
end
|
234
|
+
|
235
|
+
paket_template << line
|
236
|
+
end
|
237
|
+
|
238
|
+
Wooget.log.debug "Writing out #{paket_template.join} to #{template}"
|
239
|
+
|
240
|
+
File.open(File.join(options[:path], template), "w") { |f| f << paket_template.join }
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
class ReleaseBuilder < Builder
|
246
|
+
private
|
247
|
+
def setup build_info
|
248
|
+
self.options = Thor::CoreExt::HashWithIndifferentAccess.new(options)
|
249
|
+
options[:stage] = "Release"
|
250
|
+
|
251
|
+
fail_msg = check_release_preconditions build_info
|
252
|
+
abort "Prerelease fail - '#{fail_msg}'" if fail_msg
|
253
|
+
|
254
|
+
set_release_dependencies build_info
|
255
|
+
|
256
|
+
super
|
257
|
+
end
|
258
|
+
|
259
|
+
def set_release_dependencies build_info
|
260
|
+
#remove prerelease references from dependencies and template
|
261
|
+
files = build_info.template_files + %w(paket.dependencies)
|
262
|
+
files.map! { |f| f.start_with?("/") ? f : File.join(options[:path], f) }
|
263
|
+
|
264
|
+
files.each do |file|
|
265
|
+
release_dependencies = []
|
266
|
+
File.open(file).each do |line|
|
267
|
+
release_dependencies << line.sub(/\s*[>=]{1}\s*.*(prerelease)|prerelease/, "")
|
268
|
+
end
|
269
|
+
|
270
|
+
Wooget.log.debug "Writing out #{release_dependencies.join} to #{file}"
|
271
|
+
|
272
|
+
File.open(file, "w") { |f| f << release_dependencies.join }
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
#
|
277
|
+
# sets prerelease dependencies on paket files and creates prerelease template
|
278
|
+
|
279
|
+
def check_release_preconditions build_info
|
280
|
+
return "#{options[:path]} doesn't appear to be a valid package dir" unless Util.is_a_wooget_package_dir options[:path]
|
281
|
+
return "Not a full release - #{build_info.version}" if build_info.version =~ /prerelease/
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|