samus 1.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 +7 -0
- data/LICENSE +22 -0
- data/README.md +255 -0
- data/bin/samus +87 -0
- data/commands/build/archive-git-full +3 -0
- data/commands/build/archive-git-full.help.md +7 -0
- data/commands/build/archive-tgz +3 -0
- data/commands/build/archive-tgz.help.md +7 -0
- data/commands/build/archive-zip +3 -0
- data/commands/build/archive-zip.help.md +7 -0
- data/commands/build/fs-copy +3 -0
- data/commands/build/fs-copy.help.md +8 -0
- data/commands/build/fs-mkdir +3 -0
- data/commands/build/fs-mkdir.help.md +7 -0
- data/commands/build/fs-rmrf +3 -0
- data/commands/build/fs-rmrf.help.md +7 -0
- data/commands/build/fs-sedfiles +7 -0
- data/commands/build/fs-sedfiles.help.md +8 -0
- data/commands/build/gem-build +5 -0
- data/commands/build/gem-build.help.md +7 -0
- data/commands/build/git-archive +3 -0
- data/commands/build/git-archive.help.md +8 -0
- data/commands/build/git-commit +7 -0
- data/commands/build/git-commit.help.md +8 -0
- data/commands/build/git-merge +9 -0
- data/commands/build/git-merge.help.md +8 -0
- data/commands/build/npm-test +3 -0
- data/commands/build/npm-test.help.md +7 -0
- data/commands/build/rake-task +3 -0
- data/commands/build/rake-task.help.md +7 -0
- data/commands/publish/cf-invalidate +16 -0
- data/commands/publish/cf-invalidate.help.md +8 -0
- data/commands/publish/gem-push +6 -0
- data/commands/publish/gem-push.help.md +7 -0
- data/commands/publish/git-push +15 -0
- data/commands/publish/git-push.help.md +8 -0
- data/commands/publish/npm-publish +3 -0
- data/commands/publish/npm-publish.help.md +7 -0
- data/commands/publish/s3-put +13 -0
- data/commands/publish/s3-put.help.md +10 -0
- data/lib/samus.rb +37 -0
- data/lib/samus/action.rb +60 -0
- data/lib/samus/build_action.rb +46 -0
- data/lib/samus/builder.rb +101 -0
- data/lib/samus/command.rb +99 -0
- data/lib/samus/credentials.rb +48 -0
- data/lib/samus/publish_action.rb +7 -0
- data/lib/samus/publisher.rb +38 -0
- data/lib/samus/version.rb +3 -0
- data/samus.gemspec +13 -0
- data/samus.json +44 -0
- metadata +95 -0
| @@ -0,0 +1,99 @@ | |
| 1 | 
            +
            module Samus
         | 
| 2 | 
            +
              class Command
         | 
| 3 | 
            +
                class << self
         | 
| 4 | 
            +
                  def command_paths; @@command_paths end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def list_commands(stage = nil)
         | 
| 7 | 
            +
                    stages = {}
         | 
| 8 | 
            +
                    command_paths.each do |path|
         | 
| 9 | 
            +
                      Dir.glob(File.join(path, '*', '*')).each do |dir|
         | 
| 10 | 
            +
                        type, name = *dir.split(File::SEPARATOR)[-2,2]
         | 
| 11 | 
            +
                        next if name =~ /\.md$/
         | 
| 12 | 
            +
                        next if stage && stage != type
         | 
| 13 | 
            +
                        (stages[type] ||= []).push(new(type, name))
         | 
| 14 | 
            +
                      end
         | 
| 15 | 
            +
                    end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                    puts "Commands:"
         | 
| 18 | 
            +
                    puts ""
         | 
| 19 | 
            +
                    stages.each do |type, commands|
         | 
| 20 | 
            +
                      puts "#{type}:"
         | 
| 21 | 
            +
                      puts ""
         | 
| 22 | 
            +
                      commands.sort.each do |command|
         | 
| 23 | 
            +
                        puts("  * %-20s%s" % [command.name, command.help_text.split(/\r?\n/)[0]])
         | 
| 24 | 
            +
                      end
         | 
| 25 | 
            +
                      puts ""
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                @@command_paths = [File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'commands'))]
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                attr_reader :stage, :name
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def initialize(stage, name)
         | 
| 35 | 
            +
                  @name = name
         | 
| 36 | 
            +
                  @stage = stage
         | 
| 37 | 
            +
                  load_full_path
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def show_help
         | 
| 41 | 
            +
                  puts "#{stage.capitalize} Command: #{name}"
         | 
| 42 | 
            +
                  puts ""
         | 
| 43 | 
            +
                  puts help_text
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                def help_text
         | 
| 47 | 
            +
                  @help_text ||= File.exist?(help_path) ? File.read(help_path) : ""
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                def log_command(env = {}, arguments = [])
         | 
| 51 | 
            +
                  e = env.map {|k,v| k =~ /^(AWS|__)/ ? nil : "#{k}=#{v.inspect}" }.compact.join(" ")
         | 
| 52 | 
            +
                  e = e + " " if e.size > 0
         | 
| 53 | 
            +
                  puts("[C] " + e + name + (arguments ? " " + arguments.join(" ") : ""))
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def run(opts = {})
         | 
| 57 | 
            +
                  env = (opts[:arguments] || {}).inject({}) {|h, (k, v)| h["_#{k}"] = v; h }
         | 
| 58 | 
            +
                  arguments = opts[:files] || []
         | 
| 59 | 
            +
                  dry_run = opts[:dry_run] || false
         | 
| 60 | 
            +
                  allow_fail = opts[:allow_fail] || false
         | 
| 61 | 
            +
                  pwd = opts[:pwd]
         | 
| 62 | 
            +
                  old_pwd = Dir.pwd
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                  log_command(env, arguments)
         | 
| 65 | 
            +
                  if !dry_run
         | 
| 66 | 
            +
                    exec_in_dir(pwd) do
         | 
| 67 | 
            +
                      system(env, @full_path + " " + (arguments ? arguments.join(" ") : ""))
         | 
| 68 | 
            +
                    end
         | 
| 69 | 
            +
                    if $?.to_i != 0
         | 
| 70 | 
            +
                      puts "[E] Last command failed with #{$?}#{allow_fail ? ' but allowFail=true' : ', exiting'}."
         | 
| 71 | 
            +
                      exit($?.to_i) unless allow_fail
         | 
| 72 | 
            +
                    end
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                def <=>(other)
         | 
| 77 | 
            +
                  name <=> other.name
         | 
| 78 | 
            +
                end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                private
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                def exec_in_dir(dir, &block)
         | 
| 83 | 
            +
                  dir ? Dir.chdir(dir, &block) : yield
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                def load_full_path
         | 
| 87 | 
            +
                  if path = self.class.command_paths.find {|path| File.exist?(File.join(path, stage, name)) }
         | 
| 88 | 
            +
                    @full_path = File.join(path, stage, name)
         | 
| 89 | 
            +
                  else
         | 
| 90 | 
            +
                    Samus.error "Could not find command: #{name} " +
         | 
| 91 | 
            +
                      "(cmd_paths=#{self.class.command_paths.join(':')})"
         | 
| 92 | 
            +
                  end
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                def help_path
         | 
| 96 | 
            +
                  @help_path ||= @full_path + '.help.md'
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
              end
         | 
| 99 | 
            +
            end
         | 
| @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            module Samus
         | 
| 2 | 
            +
              class Credentials
         | 
| 3 | 
            +
                attr_reader :name
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                @@credentials = {}
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def initialize(name)
         | 
| 8 | 
            +
                  @name = name
         | 
| 9 | 
            +
                  load_credential_file
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def load
         | 
| 13 | 
            +
                  return @@credentials[name] if @@credentials[name]
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  hsh = {}
         | 
| 16 | 
            +
                  data = nil
         | 
| 17 | 
            +
                  if File.executable?(@file)
         | 
| 18 | 
            +
                    data = `#{@file}`
         | 
| 19 | 
            +
                    if $?.to_i != 0
         | 
| 20 | 
            +
                      Samus.error "Loading credential #{name} failed with #{$?}"
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                  else
         | 
| 23 | 
            +
                    data = File.read(@file)
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  data.split(/\r?\n/).each do |line|
         | 
| 27 | 
            +
                    name, value = *line.strip.split(':')
         | 
| 28 | 
            +
                    hsh["_creds_#{name.strip.downcase}"] = value.strip
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  @@credentials[name] = hsh
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                private
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                def load_credential_file
         | 
| 37 | 
            +
                  Samus.config_paths.each do |path|
         | 
| 38 | 
            +
                    file = File.join(path, 'credentials', name)
         | 
| 39 | 
            +
                    if File.exist?(file)
         | 
| 40 | 
            +
                      @file = file
         | 
| 41 | 
            +
                      return
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                  Samus.error "Could not find credential: #{name} " +
         | 
| 45 | 
            +
                    "(SAMUS_CONFIG_PATH=#{Samus.config_paths.join(':')})"
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
            end
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            require 'json'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative './publish_action'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Samus
         | 
| 6 | 
            +
              class Publisher
         | 
| 7 | 
            +
                def initialize(dir)
         | 
| 8 | 
            +
                  @dir = dir
         | 
| 9 | 
            +
                  @stage = 'publish'
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def publish(dry_run = false)
         | 
| 13 | 
            +
                  Dir.chdir(@dir) do
         | 
| 14 | 
            +
                    actions.map do |action|
         | 
| 15 | 
            +
                      PublishAction.new(:dry_run => dry_run, :arguments => {
         | 
| 16 | 
            +
                        'version' => manifest['version']
         | 
| 17 | 
            +
                      }).load(action)
         | 
| 18 | 
            +
                    end.each do |action|
         | 
| 19 | 
            +
                      action.run
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                private
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def actions
         | 
| 27 | 
            +
                  manifest['actions']
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def manifest
         | 
| 31 | 
            +
                  @manifest ||= JSON.parse(File.read(manifest_file))
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def manifest_file
         | 
| 35 | 
            +
                  @manifest_file ||= File.join(@dir, 'manifest.json')
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
    
        data/samus.gemspec
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require File.expand_path('../lib/samus/version', __FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem::Specification.new do |s|
         | 
| 4 | 
            +
              s.name          = 'samus'
         | 
| 5 | 
            +
              s.summary       = 'Samus helps you release Open Source Software.'
         | 
| 6 | 
            +
              s.version       = Samus::VERSION
         | 
| 7 | 
            +
              s.author        = 'Loren Segal'
         | 
| 8 | 
            +
              s.email         = 'lsegal@soen.ca'
         | 
| 9 | 
            +
              s.homepage      = 'http://github.com/lsegal/samus'
         | 
| 10 | 
            +
              s.files         = `git ls-files`.split(/\s+/)
         | 
| 11 | 
            +
              s.executables   = ['samus']
         | 
| 12 | 
            +
              s.license       = 'BSD'
         | 
| 13 | 
            +
            end
         | 
    
        data/samus.json
    ADDED
    
    | @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "actions": [
         | 
| 3 | 
            +
                {
         | 
| 4 | 
            +
                  "action": "fs-sedfiles",
         | 
| 5 | 
            +
                  "files": ["lib/samus/version.rb"],
         | 
| 6 | 
            +
                  "arguments": {
         | 
| 7 | 
            +
                    "search": "VERSION = ['\"](.+?)['\"]",
         | 
| 8 | 
            +
                    "replace": "VERSION = '$version'"
         | 
| 9 | 
            +
                  }
         | 
| 10 | 
            +
                },
         | 
| 11 | 
            +
                {
         | 
| 12 | 
            +
                  "action": "git-commit",
         | 
| 13 | 
            +
                  "files": ["lib/samus/version.rb"]
         | 
| 14 | 
            +
                },
         | 
| 15 | 
            +
                {
         | 
| 16 | 
            +
                  "action": "git-merge",
         | 
| 17 | 
            +
                  "arguments": {
         | 
| 18 | 
            +
                    "branch": "master"
         | 
| 19 | 
            +
                  }
         | 
| 20 | 
            +
                },
         | 
| 21 | 
            +
                {
         | 
| 22 | 
            +
                  "action": "archive-git-full",
         | 
| 23 | 
            +
                  "files": ["git.tgz"],
         | 
| 24 | 
            +
                  "publish": [{
         | 
| 25 | 
            +
                    "action": "git-push",
         | 
| 26 | 
            +
                    "arguments": {
         | 
| 27 | 
            +
                      "remotes": "origin",
         | 
| 28 | 
            +
                      "refs": "master v$version"
         | 
| 29 | 
            +
                    }
         | 
| 30 | 
            +
                  }]
         | 
| 31 | 
            +
                },
         | 
| 32 | 
            +
                {
         | 
| 33 | 
            +
                  "action": "gem-build",
         | 
| 34 | 
            +
                  "files": ["*.gemspec"],
         | 
| 35 | 
            +
                  "publish": [
         | 
| 36 | 
            +
                    {
         | 
| 37 | 
            +
                      "action": "gem-push",
         | 
| 38 | 
            +
                      "files": ["*.gem"],
         | 
| 39 | 
            +
                      "credentials": "lsegal.rubygems"
         | 
| 40 | 
            +
                    }
         | 
| 41 | 
            +
                  ]
         | 
| 42 | 
            +
                }
         | 
| 43 | 
            +
              ]
         | 
| 44 | 
            +
            }
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,95 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: samus
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Loren Segal
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-02-02 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies: []
         | 
| 13 | 
            +
            description: 
         | 
| 14 | 
            +
            email: lsegal@soen.ca
         | 
| 15 | 
            +
            executables:
         | 
| 16 | 
            +
            - samus
         | 
| 17 | 
            +
            extensions: []
         | 
| 18 | 
            +
            extra_rdoc_files: []
         | 
| 19 | 
            +
            files:
         | 
| 20 | 
            +
            - LICENSE
         | 
| 21 | 
            +
            - README.md
         | 
| 22 | 
            +
            - bin/samus
         | 
| 23 | 
            +
            - commands/build/archive-git-full
         | 
| 24 | 
            +
            - commands/build/archive-git-full.help.md
         | 
| 25 | 
            +
            - commands/build/archive-tgz
         | 
| 26 | 
            +
            - commands/build/archive-tgz.help.md
         | 
| 27 | 
            +
            - commands/build/archive-zip
         | 
| 28 | 
            +
            - commands/build/archive-zip.help.md
         | 
| 29 | 
            +
            - commands/build/fs-copy
         | 
| 30 | 
            +
            - commands/build/fs-copy.help.md
         | 
| 31 | 
            +
            - commands/build/fs-mkdir
         | 
| 32 | 
            +
            - commands/build/fs-mkdir.help.md
         | 
| 33 | 
            +
            - commands/build/fs-rmrf
         | 
| 34 | 
            +
            - commands/build/fs-rmrf.help.md
         | 
| 35 | 
            +
            - commands/build/fs-sedfiles
         | 
| 36 | 
            +
            - commands/build/fs-sedfiles.help.md
         | 
| 37 | 
            +
            - commands/build/gem-build
         | 
| 38 | 
            +
            - commands/build/gem-build.help.md
         | 
| 39 | 
            +
            - commands/build/git-archive
         | 
| 40 | 
            +
            - commands/build/git-archive.help.md
         | 
| 41 | 
            +
            - commands/build/git-commit
         | 
| 42 | 
            +
            - commands/build/git-commit.help.md
         | 
| 43 | 
            +
            - commands/build/git-merge
         | 
| 44 | 
            +
            - commands/build/git-merge.help.md
         | 
| 45 | 
            +
            - commands/build/npm-test
         | 
| 46 | 
            +
            - commands/build/npm-test.help.md
         | 
| 47 | 
            +
            - commands/build/rake-task
         | 
| 48 | 
            +
            - commands/build/rake-task.help.md
         | 
| 49 | 
            +
            - commands/publish/cf-invalidate
         | 
| 50 | 
            +
            - commands/publish/cf-invalidate.help.md
         | 
| 51 | 
            +
            - commands/publish/gem-push
         | 
| 52 | 
            +
            - commands/publish/gem-push.help.md
         | 
| 53 | 
            +
            - commands/publish/git-push
         | 
| 54 | 
            +
            - commands/publish/git-push.help.md
         | 
| 55 | 
            +
            - commands/publish/npm-publish
         | 
| 56 | 
            +
            - commands/publish/npm-publish.help.md
         | 
| 57 | 
            +
            - commands/publish/s3-put
         | 
| 58 | 
            +
            - commands/publish/s3-put.help.md
         | 
| 59 | 
            +
            - lib/samus.rb
         | 
| 60 | 
            +
            - lib/samus/action.rb
         | 
| 61 | 
            +
            - lib/samus/build_action.rb
         | 
| 62 | 
            +
            - lib/samus/builder.rb
         | 
| 63 | 
            +
            - lib/samus/command.rb
         | 
| 64 | 
            +
            - lib/samus/credentials.rb
         | 
| 65 | 
            +
            - lib/samus/publish_action.rb
         | 
| 66 | 
            +
            - lib/samus/publisher.rb
         | 
| 67 | 
            +
            - lib/samus/version.rb
         | 
| 68 | 
            +
            - samus.gemspec
         | 
| 69 | 
            +
            - samus.json
         | 
| 70 | 
            +
            homepage: http://github.com/lsegal/samus
         | 
| 71 | 
            +
            licenses:
         | 
| 72 | 
            +
            - BSD
         | 
| 73 | 
            +
            metadata: {}
         | 
| 74 | 
            +
            post_install_message: 
         | 
| 75 | 
            +
            rdoc_options: []
         | 
| 76 | 
            +
            require_paths:
         | 
| 77 | 
            +
            - lib
         | 
| 78 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
              requirements:
         | 
| 80 | 
            +
              - - '>='
         | 
| 81 | 
            +
                - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                  version: '0'
         | 
| 83 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 84 | 
            +
              requirements:
         | 
| 85 | 
            +
              - - '>='
         | 
| 86 | 
            +
                - !ruby/object:Gem::Version
         | 
| 87 | 
            +
                  version: '0'
         | 
| 88 | 
            +
            requirements: []
         | 
| 89 | 
            +
            rubyforge_project: 
         | 
| 90 | 
            +
            rubygems_version: 2.0.3
         | 
| 91 | 
            +
            signing_key: 
         | 
| 92 | 
            +
            specification_version: 4
         | 
| 93 | 
            +
            summary: Samus helps you release Open Source Software.
         | 
| 94 | 
            +
            test_files: []
         | 
| 95 | 
            +
            has_rdoc: 
         |