capistrano-monorepo 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e34aff2531732aec0b0b2c519e1fb9233b4db189ccf433fe5db00cbfd21441af
4
+ data.tar.gz: 0f22227a7bc7fc7ea335a060203c6c12f92f18f4719d033fedb82a66fa8d7d3b
5
+ SHA512:
6
+ metadata.gz: 493db886b0cdb10ca2d2d45d22d22a247c02863882dd22564714a948ae9de3c043faa9ecf128af159557299a885dbb6a8a9bc25592e5b8e42548e82345992cf2
7
+ data.tar.gz: e9821c878ead4e48ccf238674156da0bfc0c59d108fbc13c408304c9d813efc9ae1a76d687639578ae9d5970144e1edaa8d8bed8e577f558357a7a2879363ab7
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ require 'capistrano/monorepo/version'
2
+ require 'capistrano/monorepo/assets'
3
+
4
+ module Capistrano
5
+ module Monorepo
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ load File.expand_path('../../tasks/assets.rake', __FILE__)
2
+ # load File.expand_path(File.join(File.dirname(__FILE__), "tasks/assets.rake"))
3
+ # puts 'Hello Capistrano World!'
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Monorepo
3
+ VERSION = '0.0.1'.freeze
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ #load File.expand_path('../tasks/import-assets.rake', __FILE__)
2
+ puts "Hello Capistrano World!"
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module MonorepoAssets
3
+ VERSION = '0.0.4'
4
+ end
5
+ end
@@ -0,0 +1,61 @@
1
+ require 'pathname'
2
+
3
+ ##
4
+ # Import assets from a top level monorepo directory into the current working
5
+ # directory.
6
+ #
7
+ # When you use :repo_tree to deploy a specific directory of a monorepo, but your
8
+ # asset repository is in a different directory, you need to check out this
9
+ # top-level directory and add it to the deployment path. For example, if your
10
+ # monorepo directory structure looks something like:
11
+ #
12
+ # - /app
13
+ # - src/
14
+ # - assets -> symlink to ../../assets
15
+ # - /assets
16
+ # - /api
17
+ #
18
+ # And you want to deploy /app, the symlink to the upper directory won't exist if
19
+ # capistrano is configured to use :repo_tree "app". In order to overcome this,
20
+ # this task checks out a specified piece of the larger monorepo (in this case,
21
+ # the assets directory), and places it in the deployment directory at a
22
+ # specified location.
23
+ #
24
+ # Configuration:
25
+ # In your deploy/<stage>.rb file, you will need to specify two variables:
26
+ # - :asset_path - The location within the deployment directory where the
27
+ # assets should be placed. Relative to the deployment working
28
+ # directory.
29
+ # - :asset_source - The location of the top-level asset folder in the
30
+ # monorepo. Relative to the top level of the monorepo (i.e.
31
+ # the directory that would be used as a deployment if
32
+ # :repo_tree was not specified).
33
+ #
34
+ # In the above example, you would specify:
35
+ #
36
+ # set :asset_path, "src/assets"
37
+ # set :asset_source, "assets"
38
+ #
39
+ namespace :monorepo do
40
+ desc "Import assets from a top-level monorepo directory"
41
+ task :import_assets do
42
+ on roles(:all) do |host|
43
+ within repo_path do
44
+ final_asset_location = "#{release_path}/#{fetch(:asset_path)}"
45
+ asset_stat_result = capture "stat", "-t", "#{final_asset_location}"
46
+ asset_stat_result = asset_stat_result.split(" ")
47
+ if asset_stat_result[0] == "#{final_asset_location}"
48
+ info "Removing existing asset directory #{final_asset_location}..."
49
+ execute "rm", "-rf", "#{final_asset_location}"
50
+ end
51
+
52
+ source_dir = Pathname.new(final_asset_location).parent.to_s
53
+ info "Importing assets to #{source_dir}/#{fetch(:asset_source)}"
54
+ execute "GIT_WORK_TREE=#{source_dir}", :git, "checkout", "#{fetch(:branch)}", "--", "#{fetch(:asset_source)}"
55
+
56
+ info "Moving asset directory #{source_dir}/#{fetch(:asset_source)} to #{final_asset_location}..."
57
+ execute :mv, "#{source_dir}/#{fetch(:asset_source)}", "#{final_asset_location}"
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ require 'pathname'
2
+
3
+ ##
4
+ # Import assets from a top level monorepo directory into the current working
5
+ # directory.
6
+ #
7
+ # When you use :repo_tree to deploy a specific directory of a monorepo, but your
8
+ # asset repository is in a different directory, you need to check out this
9
+ # top-level directory and add it to the deployment path. For example, if your
10
+ # monorepo directory structure looks something like:
11
+ #
12
+ # - /app
13
+ # - src/
14
+ # - assets -> symlink to ../../assets
15
+ # - /assets
16
+ # - /api
17
+ #
18
+ # And you want to deploy /app, the symlink to the upper directory won't exist if
19
+ # capistrano is configured to use :repo_tree "app". In order to overcome this,
20
+ # this task checks out a specified piece of the larger monorepo (in this case,
21
+ # the assets directory), and places it in the deployment directory at a
22
+ # specified location.
23
+ #
24
+ # Configuration:
25
+ # In your deploy/<stage>.rb file, you will need to specify two variables:
26
+ # - :asset_path - The location within the deployment directory where the
27
+ # assets should be placed. Relative to the deployment working
28
+ # directory.
29
+ # - :asset_source - The location of the top-level asset folder in the
30
+ # monorepo. Relative to the top level of the monorepo (i.e.
31
+ # the directory that would be used as a deployment if
32
+ # :repo_tree was not specified).
33
+ #
34
+ # In the above example, you would specify:
35
+ #
36
+ # set :asset_path, "src/assets"
37
+ # set :asset_source, "assets"
38
+ #
39
+ namespace :monorepo do
40
+ desc "Import assets from a top-level monorepo directory"
41
+ task :import_assets do
42
+ on roles(:all) do |host|
43
+ within repo_path do
44
+ final_asset_location = "#{release_path}/#{fetch(:asset_path)}"
45
+ asset_stat_result = capture "stat", "-t", "#{final_asset_location}"
46
+ asset_stat_result = asset_stat_result.split(" ")
47
+ if asset_stat_result[0] == "#{final_asset_location}"
48
+ info "Removing existing asset directory #{final_asset_location}..."
49
+ execute "rm", "-rf", "#{final_asset_location}"
50
+ end
51
+
52
+ source_dir = Pathname.new(final_asset_location).parent.to_s
53
+ info "Importing assets to #{source_dir}/#{fetch(:asset_source)}"
54
+ execute "GIT_WORK_TREE=#{source_dir}", :git, "checkout", "#{fetch(:branch)}", "--", "#{fetch(:asset_source)}"
55
+
56
+ info "Moving asset directory #{source_dir}/#{fetch(:asset_source)} to #{final_asset_location}..."
57
+ execute :mv, "#{source_dir}/#{fetch(:asset_source)}", "#{final_asset_location}"
58
+ end
59
+ end
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-monorepo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Scott Johnson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 12.3.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 12.3.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.8'
69
+ description:
70
+ email:
71
+ - jaywir3@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/capistrano-monorepo.rb
77
+ - lib/capistrano-monorepoassets.rb
78
+ - lib/capistrano/monorepo.rb
79
+ - lib/capistrano/monorepo/assets.rb
80
+ - lib/capistrano/monorepo/version.rb
81
+ - lib/capistrano/monorepoassets.rb
82
+ - lib/capistrano/monorepoassets/version.rb
83
+ - lib/capistrano/tasks/assets.rake
84
+ - lib/capistrano/tasks/import-assets.rake
85
+ homepage: https://github.com/foamfactory/capistrano-monorepo
86
+ licenses:
87
+ - MPL-2.0
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubygems_version: 3.0.4
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Capistrano plugin for working with monorepos
108
+ test_files: []