distribuo 0.1.8

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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +38 -0
  4. data/Rakefile +36 -0
  5. data/app/controllers/concerns/distribuo/respond.rb +69 -0
  6. data/app/controllers/distribuo/admin/apps/releases_controller.rb +41 -0
  7. data/app/controllers/distribuo/admin/apps_controller.rb +40 -0
  8. data/app/controllers/distribuo/application_admin_controller.rb +12 -0
  9. data/app/controllers/distribuo/application_controller.rb +5 -0
  10. data/app/controllers/distribuo/apps/releases_controller.rb +32 -0
  11. data/app/controllers/distribuo/apps_controller.rb +16 -0
  12. data/app/helpers/distribuo/application_helper.rb +29 -0
  13. data/app/jobs/distribuo/application_job.rb +4 -0
  14. data/app/mailers/distribuo/application_mailer.rb +6 -0
  15. data/app/models/distribuo/app.rb +24 -0
  16. data/app/models/distribuo/application_record.rb +5 -0
  17. data/app/models/distribuo/download.rb +5 -0
  18. data/app/models/distribuo/release.rb +55 -0
  19. data/app/policies/distribuo/app_policy.rb +11 -0
  20. data/app/policies/distribuo/application_policy.rb +57 -0
  21. data/app/policies/distribuo/release_policy.rb +11 -0
  22. data/app/tables/distribuo/apps_table.rb +28 -0
  23. data/app/tables/distribuo/releases_table.rb +29 -0
  24. data/app/views/distribuo/admin/apps/edit.html.slim +17 -0
  25. data/app/views/distribuo/admin/apps/index.html.slim +2 -0
  26. data/app/views/distribuo/admin/apps/releases/edit.html.slim +17 -0
  27. data/app/views/distribuo/admin/apps/releases/index.html.slim +2 -0
  28. data/app/views/distribuo/apps/index.html.slim +28 -0
  29. data/app/views/distribuo/apps/releases/manifest.plist.erb +31 -0
  30. data/config/routes.rb +17 -0
  31. data/db/migrate/20201118080121_create_distribuo_apps.rb +12 -0
  32. data/db/migrate/20201118080220_create_distribuo_releases.rb +13 -0
  33. data/db/migrate/20201118111356_create_distribuo_downloads.rb +10 -0
  34. data/db/migrate/20201118143143_add_build_number_to_release.rb +5 -0
  35. data/lib/distribuo/active_record_helpers.rb +11 -0
  36. data/lib/distribuo/configuration.rb +32 -0
  37. data/lib/distribuo/engine.rb +20 -0
  38. data/lib/distribuo/version.rb +5 -0
  39. data/lib/distribuo.rb +34 -0
  40. metadata +179 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f95efbe44bc0bd312f1992deaf59fe01e30737d29a5223cc3e21f15c6db6055b
4
+ data.tar.gz: e3737eaf47783bb1188000e6a19e6f4fb976677de2e344861ca7e61c21878354
5
+ SHA512:
6
+ metadata.gz: 75fd3e8831ac3ccbe25793d6ed540b398f1ce8cdd3974080b77c7bc5cc237900227b3ba51fbe8d6e78ca460c8c09336d63a12fc49dcaa97c799af4e267050ea0
7
+ data.tar.gz: 1eeb0a7ef43895e0f39c9239da8a2f007ff6d1b35798cd998d411953224dad5901fac84e9ff81f1d2ec626e4eb3eae04b19274185fafa894b155bf5e2ea9297d
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Tom de Grunt
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Distribuo
2
+
3
+ Easy to use in-house distribution of Mobile apps. For now Enterprise and Ad-Hoc apps only.
4
+
5
+ ## Features
6
+
7
+ - Several app operating systems: iOS/Android/Windows/MacOS/tvOS
8
+ - Several release types: Alpha/Beta/Enterprise/Production/Store/Custom
9
+ - Icon extraction from apk/ipa
10
+ - Build-information extraction from apk/ipa (build-number, version-string, bundle-id, etc)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'distribuo'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```bash
23
+ $ bundle
24
+ ```
25
+
26
+ Or install it yourself as:
27
+
28
+ ```bash
29
+ $ gem install distribuo
30
+ ```
31
+
32
+ ## Contributing
33
+
34
+ Contribution directions go here.
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Distribuo'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
33
+
34
+ # Adds the Auxilium semver task
35
+ spec = Gem::Specification.find_by_name 'auxilium'
36
+ load "#{spec.gem_dir}/lib/tasks/semver.rake"
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ module Respond
5
+ # Informs the user and redirects when needed
6
+ #
7
+ # @param result [Boolean] was update or create succesful
8
+ # @param options [Hash] additional options
9
+ #
10
+ # There is also a list of options that could be used along with validators:
11
+ #
12
+ # * <tt>:path</tt> - Specifies where to redirect to in case of success
13
+ # * <tt>:notice</tt> - What to show on success
14
+ # * <tt>:error</tt> - What to show on error
15
+ # * <tt>:action</tt> - What action to render
16
+ # * <tt>:error_action</tt> - What action to render in case of failure
17
+ # * <tt>:model</tt> - What model to use for auto-generated notice/error flashes
18
+ #
19
+ def respond(result, options = {})
20
+ options[:action] ||= :index
21
+ options[:error_action] ||= :edit
22
+ options[:continue_action] ||= options[:error_action]
23
+
24
+ respond_flash(result, options)
25
+
26
+ if respond_redirect?(result)
27
+ respond_redirect(result, options)
28
+ else
29
+ render result ? options[:continue_action] : options[:error_action]
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def respond_redirect(result, options)
36
+ return unless respond_redirect?(result)
37
+
38
+ redirect_to_options = options[:path] if options.include?(:path)
39
+ redirect_to_options ||= { action: options[:action] }
40
+
41
+ redirect_to(redirect_to_options) && return
42
+ end
43
+
44
+ def respond_flash(result, options)
45
+ model_name = options[:model_name] || human_model_name(options)
46
+
47
+ if !result
48
+ flash.now[:error] = options[:error] || I18n.t('flash.error', model: model_name)
49
+ elsif respond_redirect?(result)
50
+ flash[:notice] = options[:notice] || I18n.t('flash.notice', model: model_name)
51
+ else
52
+ flash.now[:notice] = options[:notice] || I18n.t('flash.notice', model: model_name)
53
+ end
54
+ end
55
+
56
+ def respond_redirect?(result)
57
+ return false unless result
58
+ return false if params[:commit] == 'continue'
59
+
60
+ true
61
+ end
62
+
63
+ def human_model_name(options)
64
+ return options[:model].model_name.human.downcase if options.include?(:model)
65
+
66
+ Distribuo.const_get(self.class.name.demodulize.gsub(/Controller$/, '').singularize).model_name.human.downcase
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency 'distribuo/application_admin_controller'
4
+
5
+ module Distribuo
6
+ module Admin
7
+ module Apps
8
+ class ReleasesController < ApplicationAdminController
9
+ before_action :set_objects
10
+
11
+ def new
12
+ render :edit
13
+ end
14
+
15
+ def create
16
+ authorize @release
17
+ respond(@release.update(permitted_attributes(@release)), action: :index)
18
+ end
19
+
20
+ def show
21
+ render :edit
22
+ end
23
+
24
+ def edit; end
25
+
26
+ def update
27
+ authorize @release
28
+ respond(@release.update(permitted_attributes(@release)), action: :index)
29
+ end
30
+
31
+ private
32
+
33
+ def set_objects
34
+ @app = Distribuo::App.find(params[:app_id]) if params[:app_id]
35
+ @release = @app.releases.find(params[:id]) if params[:id]
36
+ @release ||= @app.releases.new
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency 'distribuo/application_admin_controller'
4
+
5
+ module Distribuo
6
+ module Admin
7
+ class AppsController < ApplicationAdminController
8
+ before_action :set_objects, except: [:index]
9
+
10
+ def new
11
+ render :edit
12
+ end
13
+
14
+ def create
15
+ authorize @app
16
+ @app.update(permitted_attributes(@app))
17
+ respond_with @app, action: :index
18
+ end
19
+
20
+ def show
21
+ render :edit
22
+ end
23
+
24
+ def edit; end
25
+
26
+ def update
27
+ authorize @app
28
+ @app.update(permitted_attributes(@app))
29
+ respond_with @app, action: :index
30
+ end
31
+
32
+ private
33
+
34
+ def set_objects
35
+ @app = Distribuo::App.find(params[:id]) if params[:id]
36
+ @app ||= Distribuo::App.new
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency 'distribuo/application_controller'
4
+ require_dependency 'concerns/distribuo/respond'
5
+
6
+ module Distribuo
7
+ class ApplicationAdminController < ApplicationController
8
+ include Pundit
9
+ include Respond
10
+ include Distribuo.config.admin_authentication_module.constantize if Distribuo.config.admin_authentication_module
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Distribuo
2
+ class ApplicationController < Distribuo.config.base_controller.constantize
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ module Apps
5
+ # FIXME: This should probably inherit from an ApplicatoinController
6
+ class ReleasesController < ActionController::Base
7
+ # skip_before_action :authenticate_user!
8
+ before_action :set_objects
9
+
10
+ def download
11
+ if request.get?
12
+ @release.downloads.create(ip: request.ip)
13
+ send_data @release.build.download, filename: @release.build.filename.to_s,
14
+ content_type: @release.build.content_type
15
+ else
16
+ head 204
17
+ end
18
+ end
19
+
20
+ def manifest
21
+ render plist: 'manifest.plist.erb'
22
+ end
23
+
24
+ private
25
+
26
+ def set_objects
27
+ @app = App.find(params[:app_id]) if params[:app_id]
28
+ @release = @app.releases.find(params[:release_id]) if params[:release_id]
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ class AppsController < ApplicationController
5
+ before_action :set_objects
6
+
7
+ def index; end
8
+
9
+ private
10
+
11
+ def set_objects
12
+ @apps = Distribuo.config.current_mobiliable.apps
13
+ @apps = Distribuo::App.all if @apps.count == 0
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ module Distribuo
2
+ module ApplicationHelper
3
+ def distribuo_apps_menu
4
+ Satis::Menus::Builder.build(:apps) do |m|
5
+ m.item :create, icon: 'fal fa-plus', link: distribuo.new_admin_app_path
6
+ end
7
+ end
8
+
9
+ def distribuo_app_menu
10
+ Satis::Menus::Builder.build(:app) do |m|
11
+ m.item :releases, icon: 'box_open', link: admin_app_releases_path(@app) if @app&.persisted?
12
+ end
13
+ end
14
+
15
+ def distribuo_app_releases_menu
16
+ Satis::Menus::Builder.build(:app_releases) do |m|
17
+ m.item :new, label: 'New', link: new_admin_app_release_path(@app)
18
+ end
19
+ end
20
+
21
+ def method_missing(method, *args, &block)
22
+ if main_app.respond_to?(method)
23
+ main_app.send(method, *args)
24
+ else
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ module Distribuo
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Distribuo
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,24 @@
1
+ module Distribuo
2
+ class App < ApplicationRecord
3
+ has_one_attached :icon
4
+
5
+ belongs_to :mobiliable, polymorphic: true, optional: true
6
+ has_many :releases
7
+
8
+ scope :administrable, -> { all }
9
+
10
+ OPERATING_SYSTEMS = [
11
+ %w[iOS ios],
12
+ %w[Android android],
13
+ %w[Windows windows],
14
+ %w[MacOS macos],
15
+ %w[tvOS tvos]
16
+ ].freeze
17
+
18
+ RELEASE_TYPES = %w[alpha beta enterprise production store].freeze
19
+
20
+ def latest_release
21
+ releases.first
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module Distribuo
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Distribuo
2
+ class Download < ApplicationRecord
3
+ belongs_to :release, class_name: 'Release', foreign_key: 'distribuo_release_id'
4
+ end
5
+ end
@@ -0,0 +1,55 @@
1
+ module Distribuo
2
+ class Release < ApplicationRecord
3
+ has_one_attached :build
4
+
5
+ belongs_to :app
6
+ has_many :downloads, class_name: 'Download', foreign_key: 'distribuo_release_id', dependent: :destroy
7
+
8
+ scope :administrable, -> { all }
9
+
10
+ acts_as_list scope: :app_id
11
+ default_scope -> { order(position: :desc) }
12
+
13
+ after_save :set_release_details
14
+
15
+ def download_url(controller, from_manifest: false)
16
+ if app.operating_system == 'ios' && from_manifest == false
17
+ url = controller.distribuo.app_release_manifest_url(app_id: app.id, release_id: id, host: controller.request.host,
18
+ protocol: controller.request.protocol, format: :plist)
19
+ "itms-services://?action=download-manifest&url=#{url}"
20
+ else
21
+ controller.distribuo.app_release_download_url(app, self, host: controller.request.host,
22
+ protocol: controller.request.protocol)
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def set_release_details
29
+ build_upload = attachment_changes['build'].attachable
30
+ Tempfile.create([File.basename(build_upload.original_filename, File.extname(build_upload.original_filename)),
31
+ File.extname(build_upload.original_filename)]) do |f|
32
+ f.write build_upload.read.force_encoding('utf-8')
33
+ attachment_changes['build'].attachable.rewind
34
+
35
+ ipa = AppParser.parse(f.path)
36
+
37
+ updates = {}
38
+ updates[:build_number] = ipa.version unless build_number.present?
39
+ updates[:version] = ipa.version_string unless version.present?
40
+ updates[:bundle_id] = ipa.bundle_id unless bundle_id.present?
41
+ update(updates) if updates.present?
42
+
43
+ file_name = ipa.icons.reject { |i| i[:dimensions].nil? }.max { |i| i[:dimensions]&.first.to_i }&.[](:file_name)
44
+ if file_name
45
+ si = StringIO.new
46
+ si.write(ipa.icon_data(file_name))
47
+ si.rewind
48
+
49
+ app.icon.attach(io: si, filename: file_name)
50
+ end
51
+ end
52
+ attachment_changes['build'].attachable.rewind
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ class AppPolicy < Distribuo::ApplicationPolicy
5
+ def permitted_attributes
6
+ return [] unless user.admin?
7
+
8
+ %i[name release_type operating_system icon]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ class ApplicationPolicy
5
+ attr_reader :user, :record
6
+
7
+ def initialize(user, record)
8
+ @user = user
9
+ @record = record
10
+ end
11
+
12
+ def index?
13
+ true
14
+ end
15
+
16
+ def show?
17
+ true
18
+ end
19
+
20
+ def create?
21
+ true
22
+ end
23
+
24
+ def new?
25
+ create?
26
+ end
27
+
28
+ def update?
29
+ true
30
+ end
31
+
32
+ def edit?
33
+ update?
34
+ end
35
+
36
+ def destroy?
37
+ false
38
+ end
39
+
40
+ def event?
41
+ update?
42
+ end
43
+
44
+ class Scope
45
+ attr_reader :user, :scope
46
+
47
+ def initialize(user, scope)
48
+ @user = user
49
+ @scope = scope
50
+ end
51
+
52
+ def resolve
53
+ scope.administrable
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ class ReleasePolicy < Distribuo::ApplicationPolicy
5
+ def permitted_attributes
6
+ return [] unless user.is_admin?
7
+
8
+ %i[id app_id version notes build build_number bundle_id]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ class AppsTable < ApplicationTable
5
+ model Distribuo::App
6
+
7
+ column(:icon) do |app|
8
+ app.icon.attached? ? image_tag(main_app.url_for(app.icon.variant(resize_to_limit: [20, 20]))) : ''
9
+ end
10
+ column(:name)
11
+ column(:release_type)
12
+ column(:operating_system)
13
+ column(:created_at)
14
+
15
+ filter(:platform)
16
+
17
+ initial_order :created_at, :desc
18
+
19
+ row_link { |app| distribuo.admin_app_path(app) }
20
+
21
+ private
22
+
23
+ def scope
24
+ @scope = App.all
25
+ @scope
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ class ReleasesTable < ApplicationTable
5
+ model Release
6
+
7
+ column(:release, &:position)
8
+ column(:bundle_id)
9
+ column(:version)
10
+ column(:build_number, &:build_number)
11
+ column(:unique_downloads) { |row| row.downloads.distinct.count(:ip) }
12
+ column(:total_downloads) { |row| row.downloads.count }
13
+ column(:created_at)
14
+
15
+ filter(:version)
16
+
17
+ initial_order :created_at, :desc
18
+
19
+ row_link { |release| distribuo.edit_admin_app_release_path(release.app, release) }
20
+
21
+ private
22
+
23
+ def scope
24
+ @scope = Release.all
25
+ @scope = @scope.where(app_id: params[:app_id]) if params[:app_id]
26
+ @scope
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ = sts.form_for [:admin, @app] do |f|
2
+ = sts.card(title: t('.app'), menu: distribuo_app_menu, icon: 'fad fa-laptop-mobile') do |card|
3
+ - card.action
4
+ = f.submit
5
+
6
+ .grid.grid-cols-12.gap-4
7
+ .col-span-12
8
+ - if @app.icon.attached?
9
+ = image_tag(main_app.url_for(@app.icon.variant(resize_to_limit: [32, 32])))
10
+ .col-span-12
11
+ = f.input :name
12
+ .col-span-12
13
+ = f.input :release_type, collection: Distribuo::App::RELEASE_TYPES
14
+ .col-span-12
15
+ = f.input :operating_system, collection: Distribuo::App::OPERATING_SYSTEMS
16
+ .col-span-12
17
+ = f.input :icon, as: :file
@@ -0,0 +1,2 @@
1
+ = sts.card title: t('.apps'), icon: 'fad fa-laptop-mobile', content_padding: false, menu: distribuo_apps_menu do |card|
2
+ = sts.table :distribuo_apps
@@ -0,0 +1,17 @@
1
+ = sts.form_for([:admin, @app, @release]) do |f|
2
+ = sts.card(title: t('release')) do |card|
3
+ - card.action
4
+ = f.submit
5
+ .grid.grid-cols-12.gap-4
6
+ .col-span-12
7
+ = f.input :build, as: :file
8
+ .col-span-12
9
+ = f.input :notes
10
+ .col-span-12
11
+ | The below fields will be automatically set, when you upload a build. You could choose to override them here.
12
+ .col-span-12
13
+ = f.input :version
14
+ .col-span-12
15
+ = f.input :build_number
16
+ .col-span-12
17
+ = f.input :bundle_id
@@ -0,0 +1,2 @@
1
+ = sts.card title: t('.releases'), icon: 'fad fa-ship', content_padding: false, menu: distribuo_app_releases_menu do |card|
2
+ = sts.table 'distribuo/releases', parameters: {app_id: @app.id}
@@ -0,0 +1,28 @@
1
+ = sts.card title: t('.apps') do |card|
2
+ .grid.grid-cols-12.gap-4
3
+ .col-span-12
4
+ - for app in @apps do
5
+ .grid.grid-cols-12.gap-4
6
+ .col-span-8
7
+ = app.name
8
+
9
+ = sts.info class: "grid grid-cols-1 gap-4 sm:grid-cols-3" do |info|
10
+ = info.item :icon, class: "sm:col-span-1"
11
+ - if app.icon.attached?
12
+ = image_tag(main_app.url_for(app.icon.variant(resize_to_limit: [48, 48])))
13
+
14
+ = info.item :operating_system, content: app.operating_system, class: "sm:col-span-1"
15
+ = info.item :release_type, content: app.release_type, class: "sm:col-span-1"
16
+
17
+ - if app.latest_release
18
+ .col-span-4
19
+
20
+ = t('.latest_release')
21
+ = sts.info class: "grid grid-cols-1 gap-4 sm:grid-cols-3" do |info|
22
+
23
+ = info.item :version, content: app.latest_release.version, class: "sm:col-span-1"
24
+ = info.item :build_number, content: app.latest_release.build_number, class: "sm:col-span-1"
25
+ = info.item :notes, content: app.latest_release.notes, class: "sm:col-span-3"
26
+ = info.item :download, class: "sm:col-span-1"
27
+ = link_to(app.latest_release.download_url(self), data: { turbo: false }) do
28
+ i.fal.fa-cloud-arrow-down.fa-2x
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>items</key>
6
+ <array>
7
+ <dict>
8
+ <key>assets</key>
9
+ <array>
10
+ <dict>
11
+ <key>kind</key>
12
+ <string>software-package</string>
13
+ <key>url</key>
14
+ <string><%=@release.download_url(controller, from_manifest: true)%></string>
15
+ </dict>
16
+ </array>
17
+ <key>metadata</key>
18
+ <dict>
19
+ <key>bundle-identifier</key>
20
+ <string><%=@release.bundle_id%></string>
21
+ <key>bundle-version</key>
22
+ <string><%=@release.version%></string>
23
+ <key>kind</key>
24
+ <string>software</string>
25
+ <key>title</key>
26
+ <string><%=@release.app.name%></string>
27
+ </dict>
28
+ </dict>
29
+ </array>
30
+ </dict>
31
+ </plist>
data/config/routes.rb ADDED
@@ -0,0 +1,17 @@
1
+ Distribuo::Engine.routes.draw do
2
+ resources :apps do
3
+ resources :releases, controller: 'apps/releases' do
4
+ get 'download', action: :download
5
+ get 'manifest', action: :manifest
6
+ end
7
+ end
8
+
9
+ namespace :admin do
10
+ resources :apps do
11
+ resources :releases, controller: 'apps/releases'
12
+ end
13
+ end
14
+
15
+ get '/', to: 'apps#index'
16
+ get '/:id', to: 'apps#show'
17
+ end
@@ -0,0 +1,12 @@
1
+ class CreateDistribuoApps < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :distribuo_apps, id: :uuid do |t|
4
+ t.string :name
5
+ t.string :release_type
6
+ t.string :operating_system
7
+ t.references :mobiliable, type: :uuid, polymorphic: true, index: { name: 'index_app_on_mobiliable' }
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class CreateDistribuoReleases < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :distribuo_releases, id: :uuid do |t|
4
+ t.references :app, type: :uuid, index: true
5
+ t.string :bundle_id
6
+ t.integer :position
7
+ t.string :version
8
+ t.text :notes
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class CreateDistribuoDownloads < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :distribuo_downloads, type: :uuid do |t|
4
+ t.references :distribuo_release, null: false, foreign_key: true, type: :uuid
5
+ t.string :ip
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddBuildNumberToRelease < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :distribuo_releases, :build_number, :string
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecordHelpers
4
+ extend ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def mobiliable
8
+ has_many :apps, as: :mobiliable, class_name: 'Distribuo::App'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,32 @@
1
+ module Distribuo
2
+ class Configuration
3
+ attr_accessor :admin_authentication_module, :base_controller
4
+ attr_writer :logger, :admin_mount_point, :current_mobiliable, :mobiliable_objects
5
+
6
+ def initialize
7
+ @logger = Logger.new(STDOUT)
8
+ @logger.level = Logger::INFO
9
+ @base_controller = '::ApplicationController'
10
+ end
11
+
12
+ # logger [Object].
13
+ def logger
14
+ @logger.is_a?(Proc) ? instance_exec(&@logger) : @logger
15
+ end
16
+
17
+ # admin_mount_point [String].
18
+ def admin_mount_point
19
+ @admin_mount_point ||= '/distribuo'
20
+ end
21
+
22
+ # Only used to limit what users can see when using admin
23
+ def mobiliable_objects
24
+ [*instance_exec(&@mobiliable_objects)] if @mobiliable_objects
25
+ end
26
+
27
+ # Used to set current scribable, used when creating new sites or importing sites
28
+ def current_mobiliable
29
+ instance_exec(&@current_mobiliable) if @current_mobiliable
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ module Distribuo
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Distribuo
4
+
5
+ def self.mounted_path
6
+ route = Rails.application.routes.routes.detect do |route|
7
+ route.app == self
8
+ end
9
+ route && route.path
10
+ end
11
+
12
+ initializer :append_migrations do |app|
13
+ unless app.root.to_s.match? root.to_s
14
+ config.paths['db/migrate'].expanded.each do |expanded_path|
15
+ app.config.paths['db/migrate'] << expanded_path
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Distribuo
4
+ VERSION = '0.1.8'
5
+ end
data/lib/distribuo.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'acts_as_list'
2
+ require 'app_parser'
3
+ require 'pundit'
4
+
5
+ require 'distribuo/engine'
6
+ require 'distribuo/configuration'
7
+ require 'distribuo/active_record_helpers'
8
+
9
+ module Distribuo
10
+ class Error < StandardError; end
11
+
12
+ class << self
13
+ attr_reader :config
14
+
15
+ def setup
16
+ @config = Configuration.new
17
+ yield config
18
+ end
19
+
20
+ def i18n_store
21
+ @i18n_store ||= Scribo::I18nStore.new
22
+ end
23
+
24
+ def logger
25
+ @config.logger
26
+ end
27
+ end
28
+
29
+ # Include helpers
30
+ ActiveSupport.on_load(:active_record) do
31
+ include ActiveRecordHelpers
32
+ Mime::Type.register 'application/plist', :plist
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: distribuo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.8
5
+ platform: ruby
6
+ authors:
7
+ - Tom de Grunt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: acts_as_list
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: app_parser
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: image_processing
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pg
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pundit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: auxilium
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3'
111
+ description: Simple mobile app distribution
112
+ email:
113
+ - tom@degrunt.nl
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - MIT-LICENSE
119
+ - README.md
120
+ - Rakefile
121
+ - app/controllers/concerns/distribuo/respond.rb
122
+ - app/controllers/distribuo/admin/apps/releases_controller.rb
123
+ - app/controllers/distribuo/admin/apps_controller.rb
124
+ - app/controllers/distribuo/application_admin_controller.rb
125
+ - app/controllers/distribuo/application_controller.rb
126
+ - app/controllers/distribuo/apps/releases_controller.rb
127
+ - app/controllers/distribuo/apps_controller.rb
128
+ - app/helpers/distribuo/application_helper.rb
129
+ - app/jobs/distribuo/application_job.rb
130
+ - app/mailers/distribuo/application_mailer.rb
131
+ - app/models/distribuo/app.rb
132
+ - app/models/distribuo/application_record.rb
133
+ - app/models/distribuo/download.rb
134
+ - app/models/distribuo/release.rb
135
+ - app/policies/distribuo/app_policy.rb
136
+ - app/policies/distribuo/application_policy.rb
137
+ - app/policies/distribuo/release_policy.rb
138
+ - app/tables/distribuo/apps_table.rb
139
+ - app/tables/distribuo/releases_table.rb
140
+ - app/views/distribuo/admin/apps/edit.html.slim
141
+ - app/views/distribuo/admin/apps/index.html.slim
142
+ - app/views/distribuo/admin/apps/releases/edit.html.slim
143
+ - app/views/distribuo/admin/apps/releases/index.html.slim
144
+ - app/views/distribuo/apps/index.html.slim
145
+ - app/views/distribuo/apps/releases/manifest.plist.erb
146
+ - config/routes.rb
147
+ - db/migrate/20201118080121_create_distribuo_apps.rb
148
+ - db/migrate/20201118080220_create_distribuo_releases.rb
149
+ - db/migrate/20201118111356_create_distribuo_downloads.rb
150
+ - db/migrate/20201118143143_add_build_number_to_release.rb
151
+ - lib/distribuo.rb
152
+ - lib/distribuo/active_record_helpers.rb
153
+ - lib/distribuo/configuration.rb
154
+ - lib/distribuo/engine.rb
155
+ - lib/distribuo/version.rb
156
+ homepage: https://code.entropydecelerator.com/components/distribuo
157
+ licenses:
158
+ - MIT
159
+ metadata: {}
160
+ post_install_message:
161
+ rdoc_options: []
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubygems_version: 3.3.7
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: Simple mobile app distribution
179
+ test_files: []