asset_sync 2.15.3 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd0deada18130ef42d80d6f05d5ff0611a7587dd33d177bbc38641e6b6cad3a9
4
- data.tar.gz: cd514b4901f6a3859a00b80282139d9d712db8414ed03ab115de2c7a3dfd3c78
3
+ metadata.gz: 30fcfd0667904cde532ba24578e9bbc15f33051d5bde3e345226915c7135ccde
4
+ data.tar.gz: 67cff250568d8473c940733f182e425b811550be1c95e940498508fe5d81e656
5
5
  SHA512:
6
- metadata.gz: eb9cabad00c3dfd61c1ca47c3ba9d6a768375d3dcd6a6798e97a55cc91ee1dd5a030ebd85eeab1f2018dbcc6e6ea18f43591f09bc02f2cd0558a361a13efafb9
7
- data.tar.gz: 0c13d03567e9773383179cdfda43699e70352a0ec20c7a7c980017f32b6164eb89e4a4957e6480f1ee1a6a5cc41e270f75bcc0d5fa0dd92363129e0f227c76c7
6
+ metadata.gz: 6c2471c8dcad1fdd461fac5e7881723f012888e295e5f8bda6c13137ff1cb31f3aef2db669d71588a3a699dbd2d56366abacdf9ab0d0cae4b8e7b5dba2bff8f8
7
+ data.tar.gz: 1c5fb8a038bc21c0f8218a1dd74ec6cff47df3b43588e0b9599032559a639564341814f1576faa5b6a9f9378ca2e37de1c08f219748999f0e7a437f48e96fe22
@@ -0,0 +1,43 @@
1
+ name: "CodeQL"
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+ schedule:
9
+ - cron: "11 12 * * 0"
10
+
11
+ jobs:
12
+ analyze:
13
+ name: Analyze
14
+ runs-on: ubuntu-latest
15
+ permissions:
16
+ actions: read
17
+ contents: read
18
+ security-events: write
19
+
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ language:
24
+ - javascript
25
+ - ruby
26
+
27
+ steps:
28
+ - name: Checkout
29
+ uses: actions/checkout@v3
30
+
31
+ - name: Initialize CodeQL
32
+ uses: github/codeql-action/init@v2
33
+ with:
34
+ languages: ${{ matrix.language }}
35
+ queries: +security-and-quality
36
+
37
+ - name: Autobuild
38
+ uses: github/codeql-action/autobuild@v2
39
+
40
+ - name: Perform CodeQL Analysis
41
+ uses: github/codeql-action/analyze@v2
42
+ with:
43
+ category: "/language:${{ matrix.language }}"
@@ -29,6 +29,7 @@ jobs:
29
29
  - 2.7
30
30
  - 3.0
31
31
  - 3.1
32
+ - 3.2
32
33
  - jruby
33
34
  gemfile:
34
35
  - gemfiles/rails_6_0.gemfile
data/CHANGELOG.md CHANGED
@@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
8
  ### Added
9
9
 
10
- - Nothing
10
+ - Add `fog_options` configuration option.
11
11
 
12
12
  ### Changed
13
13
 
@@ -18,6 +18,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).
18
18
  - Nothing
19
19
 
20
20
 
21
+ ## [2.17.0] - 2023-01-13
22
+
23
+ ### Added
24
+
25
+ - Add option `fog_options`
26
+ (https://github.com/AssetSync/asset_sync/pull/431)
27
+
28
+
29
+ ## [2.16.0] - 2022-08-26
30
+
31
+ ### Added
32
+
33
+ - Add option `remote_file_list_cache_file_path`
34
+ (https://github.com/AssetSync/asset_sync/pull/428)
35
+
36
+
21
37
  ## [2.15.3] - 2022-08-25
22
38
 
23
39
  ### Fixed
@@ -1054,7 +1070,9 @@ Changes:
1054
1070
  * Merge branch 'sinatra'
1055
1071
 
1056
1072
 
1057
- [Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.15.3...HEAD
1073
+ [Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.17.0...HEAD
1074
+ [2.17.0]: https://github.com/AssetSync/asset_sync/compare/v2.16.0...v2.17.0
1075
+ [2.16.0]: https://github.com/AssetSync/asset_sync/compare/v2.15.3...v2.16.0
1058
1076
  [2.15.3]: https://github.com/AssetSync/asset_sync/compare/v2.15.2...v2.15.3
1059
1077
  [2.15.2]: https://github.com/AssetSync/asset_sync/compare/v2.15.1...v2.15.2
1060
1078
  [2.15.1]: https://github.com/AssetSync/asset_sync/compare/v2.15.0...v2.15.1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  [![Gem Version](https://img.shields.io/gem/v/asset_sync.svg?style=flat-square)](http://badge.fury.io/rb/asset_sync)
3
- [![Build Status](https://img.shields.io/travis/AssetSync/asset_sync.svg?style=flat-square)](http://travis-ci.org/AssetSync/asset_sync)
3
+ [![Tests](https://github.com/AssetSync/asset_sync/actions/workflows/tests.yaml/badge.svg)](https://github.com/AssetSync/asset_sync/actions/workflows/tests.yaml)
4
4
  [![Coverage Status](http://img.shields.io/coveralls/AssetSync/asset_sync.svg?style=flat-square)](https://coveralls.io/r/AssetSync/asset_sync)
5
5
 
6
6
 
@@ -244,8 +244,8 @@ AssetSync.configure do |config|
244
244
  #
245
245
  # Change canned ACL of uploaded object. Default is unset. Will override fog_public if set.
246
246
  # Choose from: private | public-read | public-read-write | aws-exec-read |
247
- # authenticated-read | bucket-owner-read | bucket-owner-full-control
248
- # config.aws_acl = nil
247
+ # authenticated-read | bucket-owner-read | bucket-owner-full-control
248
+ # config.aws_acl = nil
249
249
  #
250
250
  # Change host option in fog (only if you need to)
251
251
  # config.fog_host = 's3.amazonaws.com'
@@ -256,6 +256,10 @@ AssetSync.configure do |config|
256
256
  # Use http instead of https.
257
257
  # config.fog_scheme = 'http'
258
258
  #
259
+ # Extra fog options.
260
+ # Overrides any existing value (even those set by AssetSync)
261
+ # config.fog_options = {}
262
+ #
259
263
  # Automatically replace files with their equivalent gzip compressed version
260
264
  # config.gzip_compression = true
261
265
  #
@@ -275,6 +279,9 @@ AssetSync.configure do |config|
275
279
  # Path to cache file to skip scanning remote
276
280
  # config.remote_file_list_cache_file_path = './.asset_sync_remote_file_list_cache.json'
277
281
  #
282
+ # Path on remote storage to persist remote file list file
283
+ # config.remote_file_list_remote_path = '/remote/asset_sync_remote_file.json'
284
+ #
278
285
  # Fail silently. Useful for environments such as Heroku
279
286
  # config.fail_silently = true
280
287
  #
@@ -319,7 +326,7 @@ defaults: &defaults
319
326
  #
320
327
  # Change canned ACL of uploaded object. Default is unset. Will override fog_public if set.
321
328
  # Choose from: private | public-read | public-read-write | aws-exec-read |
322
- # authenticated-read | bucket-owner-read | bucket-owner-full-control
329
+ # authenticated-read | bucket-owner-read | bucket-owner-full-control
323
330
  # aws_acl: null
324
331
  #
325
332
  # Change host option in fog (only if you need to)
@@ -384,6 +391,7 @@ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
384
391
  * **concurrent_uploads**: (`true, false`) when enabled, will upload the files in different Threads, this greatly improves the upload speed. **default:** `'false'`
385
392
  * **concurrent_uploads_max_threads**: when concurrent_uploads is enabled, this determines the number of threads that will be created. **default:** `10`
386
393
  * **remote_file_list_cache_file_path**: if present, use this path to cache remote file list to skip scanning remote **default:** `nil`
394
+ * **remote_file_list_remote_path**: if present, use this path to download remote file list file to cache file list in local to skip scanning remote. useful in container environment where you cannot maintain the local file, remote_file_list_cache_file_path also needed to make use of this option **default:** `nil`
387
395
  * **enabled**: (`true, false`) when false, will disable asset sync. **default:** `'true'` (enabled)
388
396
  * **ignored\_files**: an array of files to ignore e.g. `['ignore_me.js', %r(ignore_some/\d{32}\.css)]` Useful if there are some files that are created dynamically on the server and you don't want to upload on deploy **default**: `[]`
389
397
  * **cache\_asset\_regexps**: an array of files to add cache headers e.g. `['cache_me.js', %r(cache_some\.\d{8}\.css)]` Useful if there are some files that are added to sprockets assets list and need to be set as 'Cacheable' on uploaded server. Only rails compiled regexp is matched internally **default**: `[]`
@@ -432,6 +440,7 @@ The blocks are run when local files are being scanned and uploaded
432
440
 
433
441
  * **fog\_region**: the region your storage bucket is in e.g. *eu-west-1* (AWS), *ord* (Rackspace), *japanwest* (Azure Blob)
434
442
  * **fog\_path\_style**: To use buckets with dot in names, check https://github.com/fog/fog/issues/2381#issuecomment-28088524
443
+ * **fog\_options**: For extra fog options. Overrides any existing value (even those set by AssetSync)
435
444
 
436
445
  #### AWS
437
446
 
@@ -28,12 +28,14 @@ module AssetSync
28
28
  attr_accessor :concurrent_uploads
29
29
  attr_accessor :concurrent_uploads_max_threads
30
30
  attr_accessor :remote_file_list_cache_file_path
31
+ attr_accessor :remote_file_list_remote_path
31
32
 
32
33
  # FOG configuration
33
34
  attr_accessor :fog_provider # Currently Supported ['AWS', 'Rackspace']
34
35
  attr_accessor :fog_directory # e.g. 'the-bucket-name'
35
36
  attr_accessor :fog_region # e.g. 'eu-west-1'
36
37
  attr_reader :fog_public # e.g. true, false, "default"
38
+ attr_accessor :fog_options # e.g. { enable_signature_v4_streaming: true }
37
39
 
38
40
  # Amazon AWS
39
41
  attr_accessor :aws_access_key_id
@@ -107,6 +109,7 @@ module AssetSync
107
109
  self.concurrent_uploads = false
108
110
  self.concurrent_uploads_max_threads = 10
109
111
  self.remote_file_list_cache_file_path = nil
112
+ self.remote_file_list_remote_path = nil
110
113
  @additional_local_file_paths_procs = []
111
114
 
112
115
  load_yml! if defined?(::Rails) && yml_exists?
@@ -254,6 +257,7 @@ module AssetSync
254
257
  self.concurrent_uploads = yml['concurrent_uploads'] if yml.has_key?('concurrent_uploads')
255
258
  self.concurrent_uploads_max_threads = yml['concurrent_uploads_max_threads'] if yml.has_key?('concurrent_uploads_max_threads')
256
259
  self.remote_file_list_cache_file_path = yml['remote_file_list_cache_file_path'] if yml.has_key?('remote_file_list_cache_file_path')
260
+ self.remote_file_list_remote_path = yml['remote_file_list_remote_path'] if yml.has_key?('remote_file_list_remote_path')
257
261
 
258
262
  self.azure_storage_account_name = yml['azure_storage_account_name'] if yml.has_key?("azure_storage_account_name")
259
263
  self.azure_storage_access_key = yml['azure_storage_access_key'] if yml.has_key?("azure_storage_access_key")
@@ -335,6 +339,7 @@ module AssetSync
335
339
  raise ArgumentError, "AssetSync Unknown provider: #{fog_provider} only AWS, Rackspace and Google are supported currently."
336
340
  end
337
341
 
342
+ options.merge!(@fog_options) if @fog_options
338
343
  options
339
344
  end
340
345
 
@@ -50,6 +50,7 @@ module AssetSync
50
50
  config.include_manifest = (ENV['ASSET_SYNC_INCLUDE_MANIFEST'] == 'true') if ENV.has_key?('ASSET_SYNC_INCLUDE_MANIFEST')
51
51
  config.concurrent_uploads = (ENV['ASSET_SYNC_CONCURRENT_UPLOADS'] == 'true') if ENV.has_key?('ASSET_SYNC_CONCURRENT_UPLOADS')
52
52
  config.remote_file_list_cache_file_path = ENV['ASSET_SYNC_REMOTE_FILE_LIST_CACHE_FILE_PATH'] if ENV.has_key?('ASSET_SYNC_REMOTE_FILE_LIST_CACHE_FILE_PATH')
53
+ config.remote_file_list_remote_path = ENV['ASSET_SYNC_REMOTE_FILE_LIST_REMOTE_PATH'] if ENV.has_key?('ASSET_SYNC_REMOTE_FILE_LIST_REMOTE_PATH')
53
54
  end
54
55
  end
55
56
 
@@ -47,6 +47,10 @@ module AssetSync
47
47
  self.config.remote_file_list_cache_file_path
48
48
  end
49
49
 
50
+ def remote_file_list_remote_path
51
+ self.config.remote_file_list_remote_path
52
+ end
53
+
50
54
  def ignored_files
51
55
  expand_file_names(self.config.ignored_files)
52
56
  end
@@ -72,6 +76,16 @@ module AssetSync
72
76
  return [] if ignore_existing_remote_files?
73
77
  return @remote_files if @remote_files
74
78
 
79
+ if remote_file_list_remote_path && remote_file_list_cache_file_path
80
+ log "Downloading file list file from remote"
81
+ remote_cache_file = bucket.files.get(remote_file_list_remote_path)
82
+ if remote_cache_file
83
+ File.open(remote_file_list_cache_file_path, 'w') do |local_file|
84
+ local_file.write(remote_cache_file.body)
85
+ end
86
+ end
87
+ end
88
+
75
89
  if remote_file_list_cache_file_path && File.file?(remote_file_list_cache_file_path)
76
90
  begin
77
91
  content = File.read(remote_file_list_cache_file_path)
@@ -94,6 +108,18 @@ module AssetSync
94
108
  end
95
109
  end
96
110
 
111
+ def update_remote_file_list_in_remote
112
+ return if ignore_existing_remote_files?
113
+ return unless remote_file_list_remote_path
114
+ return unless remote_file_list_cache_file_path
115
+ log "Updating file list file in remote"
116
+ remote_file = bucket.files.new({
117
+ :key => remote_file_list_remote_path,
118
+ :body => File.open(remote_file_list_cache_file_path)
119
+ })
120
+ remote_file.save
121
+ end
122
+
97
123
  def always_upload_files
98
124
  expand_file_names(self.config.always_upload) + get_manifest_path
99
125
  end
@@ -317,6 +343,7 @@ module AssetSync
317
343
  end
318
344
 
319
345
  update_remote_file_list_cache(local_files_to_upload)
346
+ update_remote_file_list_in_remote
320
347
  end
321
348
 
322
349
  def sync
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AssetSync
4
- VERSION = "2.15.3"
4
+ VERSION = "2.17.0"
5
5
  end
@@ -81,6 +81,9 @@ if defined?(AssetSync)
81
81
  # Path to cache file to skip scanning remote
82
82
  # config.remote_file_list_cache_file_path = './.asset_sync_remote_file_list_cache.json'
83
83
  #
84
+ # Path on remote storage to persist remote file list file
85
+ # config.remote_file_list_remote_path = '/remote/asset_sync_remote_file.json'
86
+ #
84
87
  # Fail silently. Useful for environments such as Heroku
85
88
  # config.fail_silently = true
86
89
  #
@@ -94,6 +94,10 @@ describe AssetSync do
94
94
  it "should default asset_regexps to empty array" do
95
95
  expect(AssetSync.config.cache_asset_regexps).to eq([])
96
96
  end
97
+
98
+ it "should default remote_file_list_remote_path to nil" do
99
+ expect(AssetSync.config.remote_file_list_remote_path).to be_nil
100
+ end
97
101
  end
98
102
 
99
103
  describe 'from yml' do
@@ -274,6 +278,28 @@ describe AssetSync do
274
278
  end
275
279
  end
276
280
 
281
+ describe 'with fog_options' do
282
+ before(:each) do
283
+ AssetSync.config = AssetSync::Config.new
284
+ AssetSync.configure do |config|
285
+ config.fog_provider = 'AWS'
286
+ config.fog_region = 'eu-west-1'
287
+ config.fog_path_style = 'true'
288
+ config.fog_options = { enable_signature_v4_streaming: true }
289
+ end
290
+ end
291
+
292
+ it "assigns fog_options" do
293
+ AssetSync.config.fog_options = { enable_signature_v4_streaming: true }
294
+ expect(AssetSync.config.fog_options).to include(
295
+ provider: 'AWS',
296
+ region: 'eu-west-1',
297
+ path_style: 'true',
298
+ enable_signature_v4_streaming: true,
299
+ )
300
+ end
301
+ end
302
+
277
303
  describe 'with invalid yml' do
278
304
  before(:each) do
279
305
  set_rails_root('with_invalid_yml')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asset_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.3
4
+ version: 2.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Hamilton
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-08-25 00:00:00.000000000 Z
14
+ date: 2023-01-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: fog-core
@@ -221,6 +221,7 @@ extensions: []
221
221
  extra_rdoc_files: []
222
222
  files:
223
223
  - ".editorconfig"
224
+ - ".github/workflows/codeql.yml"
224
225
  - ".github/workflows/tests.yaml"
225
226
  - ".gitignore"
226
227
  - ".travis.yml"
@@ -287,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
288
  - !ruby/object:Gem::Version
288
289
  version: '0'
289
290
  requirements: []
290
- rubygems_version: 3.3.17
291
+ rubygems_version: 3.4.3
291
292
  signing_key:
292
293
  specification_version: 4
293
294
  summary: Synchronises Assets in a Rails 3 application and Amazon S3/Cloudfront and