delivery_center 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45152e885540e4eff7d90f7401c0443e9375fe82
4
- data.tar.gz: 5797ce2d4084413599c93c0fdf098f8e6acf844a
3
+ metadata.gz: 23207f459a5f09dad30070931c559061545d570b
4
+ data.tar.gz: 14fc367be4ebe50f071d5d31e322242b14fa84a1
5
5
  SHA512:
6
- metadata.gz: 78095d1fd1b554ebd4c9907ebce01b938fbc303a67e5ff0605caa8d94e89620292716b02a6cc5929d40b671c34e01cb299b5b13de6e32e58b1ef22ffdb6b25b0
7
- data.tar.gz: 4d581ac2e26e8919c32c1eaa600ecaf2135ca6a5a8954a11251e4480952989dee1c53158ae73268fa25e33f72cad41d62b306a6d149853a2cf349de102542255
6
+ metadata.gz: 979467287d849394aed44fe4bbc2ccc4036861c4fe5fc7cf5ddbe76496a0666bafbfd581cf58069d22fa1351529f4582141c69d69b373610195712a2f9faeb7b
7
+ data.tar.gz: bd8ade981eabc6df992c244712bfaaf7befff411e5b33a16332f6ba194babcfaa36fb771fb4ae70e58217bf47818e15cd4db848cb6d8327fb6ad9be80cabbe67
@@ -2,14 +2,47 @@ require 'thor'
2
2
 
3
3
  class DeliveryCenter::Cli < Thor
4
4
  require 'delivery_center/cli/database'
5
+ require 'delivery_center/cli/revision'
6
+ require 'delivery_center/cli/application'
5
7
 
6
8
  desc 'db SUBCOMMAND ...ARGS', 'manage db'
7
9
  subcommand 'db', DeliveryCenter::Cli::Database
8
10
 
11
+ desc 'revision SUBCOMMAND ...ARGS', 'manage db'
12
+ subcommand 'revision', DeliveryCenter::Cli::Revision
13
+
14
+ desc 'application SUBCOMMAND ...ARGS', 'manage db'
15
+ subcommand 'application', DeliveryCenter::Cli::Application
16
+
9
17
  desc 'server', 'run delivery center web application'
10
18
  option 'port', desc: 'listen port', default: 8080, aliases: 'p', type: :numeric
11
19
  option 'address', desc: 'listen address', default: 'localhost', aliases: 'b', type: :string
12
20
  def server
13
21
  DeliveryCenter::App.run!(options)
14
22
  end
23
+
24
+ desc 'deploy [application name]', 'deploy latest revision'
25
+ def deploy(application_name)
26
+ application = find_application(application_name)
27
+ application.deploy!
28
+ puts "current revision: #{application.current_revision.value}"
29
+ end
30
+
31
+ desc 'rollback [application name]', 'rollback previous revision'
32
+ def rollback(application_name)
33
+ application = find_application(application_name)
34
+ application.rollback!
35
+ puts "current revision: #{application.current_revision.value}"
36
+ end
37
+
38
+ private
39
+
40
+ def find_application(name)
41
+ application = DeliveryCenter::Application.find_by(name: name)
42
+ if application.nil?
43
+ DeliveryCenter.logger.error("notfound #{application}")
44
+ exit 1
45
+ end
46
+ application
47
+ end
15
48
  end
@@ -0,0 +1,15 @@
1
+ class DeliveryCenter::Cli::Application < Thor
2
+ namespace 'application'
3
+
4
+ desc 'add [application name]', 'register application'
5
+ def add(name)
6
+ if DeliveryCenter::Application.where(name: name).exists?
7
+ DeliveryCenter.logger.info("already exists #{name}.")
8
+ else
9
+ DeliveryCenter::Application.create!(name: name)
10
+ DeliveryCenter.logger.info("added #{name} application.")
11
+ end
12
+ rescue => e
13
+ DeliveryCenter.logger.error(e)
14
+ end
15
+ end
File without changes
@@ -0,0 +1,30 @@
1
+ class DeliveryCenter::Cli::Revision < Thor
2
+ namespace 'revision'
3
+
4
+ desc 'switch [application name] [revision]', 'add revision'
5
+ def add(application_name, revision)
6
+ application = find_application(application_name)
7
+ if application.revisions.where(value: revision).exists?
8
+ DeliveryCenter.logger.info("already created #{application.name} - #{revision}")
9
+ else
10
+ application.revisions.create!(value: revision)
11
+ DeliveryCenter.logger.info("create #{application.name} - #{revision}")
12
+ end
13
+ end
14
+
15
+ desc 'current [application name]', 'fetch current revision'
16
+ def current(application_name)
17
+ print find_application(application_name).current_revision.value
18
+ end
19
+
20
+ private
21
+
22
+ def find_application(name)
23
+ application = DeliveryCenter::Application.find_by(name: name)
24
+ if application.nil?
25
+ DeliveryCenter.logger.error("notfound #{application}")
26
+ exit 1
27
+ end
28
+ application
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module DeliveryCenter
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delivery_center
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takatoshi Maeda
@@ -229,7 +229,10 @@ files:
229
229
  - lib/delivery_center/app.rb
230
230
  - lib/delivery_center/application_record.rb
231
231
  - lib/delivery_center/cli.rb
232
+ - lib/delivery_center/cli/application.rb
232
233
  - lib/delivery_center/cli/database.rb
234
+ - lib/delivery_center/cli/deploy.rb
235
+ - lib/delivery_center/cli/revision.rb
233
236
  - lib/delivery_center/errors.rb
234
237
  - lib/delivery_center/models.rb
235
238
  - lib/delivery_center/models/api_key.rb
@@ -261,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
264
  version: '0'
262
265
  requirements: []
263
266
  rubyforge_project:
264
- rubygems_version: 2.5.2
267
+ rubygems_version: 2.4.5
265
268
  signing_key:
266
269
  specification_version: 4
267
270
  summary: deploy management tool