neocities 0.0.14 → 0.0.17

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: a86ab831702d89fe136292b63504f9960aaff08badc8b787646b9c77fd7a9a7c
4
- data.tar.gz: 8cbfa0f010c1a9f1d8651035f679aac6de9e2e501116eff35830be7ccd64b81f
3
+ metadata.gz: 2e868d70dd0564036428471413481d66f764cde75087d25a4aef0ec945d5792b
4
+ data.tar.gz: 9d180d291b6169253110534aef62a48ec3ee8b43a8f50dc6a4635695d1ce525a
5
5
  SHA512:
6
- metadata.gz: 36fe45489c68d0c3147ad71376487551244304d421b8f688f47114c9cdd8d536d2769e280c1b1df6d942c218eff1b55c55207f0814b87b347753897d34e84e15
7
- data.tar.gz: 4e0c825a0326eb3fc0bd43deccaf7a65963ff272c5477eb8aaea0f6329af5fec9611e81f5d9a7a7deeb824f84e92204d83ed23bfa99b70fc837c2e0dd19834f3
6
+ metadata.gz: d2a884cc70d5ffb3521a472e2f1a582963f44b3e390f171486c6c3d08125041779cf65e562decc6a3aeaafbfa2d7e956efbb22ee77cd7b5cb3e3f096d7d15e11
7
+ data.tar.gz: aab95d2837cdcdfa49b35cabf4a4b57fae898f2189bcd16f34b16e5729b9f415491fe4c7a024376d0b0e5eb24c98cea2c5743269fa6d21431876bd2b4f58e157
data/ext/mkrf_conf.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
- require 'rubygems/dependency_installer.rb'
2
+ require 'rubygems/command'
3
+ require 'rubygems/dependency_installer'
3
4
  begin
4
5
  Gem::Command.build_args = ARGV
5
6
  rescue NoMethodError
data/lib/neocities/cli.rb CHANGED
@@ -161,15 +161,23 @@ module Neocities
161
161
  def push
162
162
  @no_gitignore = false
163
163
  @excluded_files = []
164
+ @dry_run = false
165
+ @prune = false
164
166
  loop {
165
167
  case @subargs[0]
166
168
  when '--no-gitignore' then @subargs.shift; @no_gitignore = true
167
169
  when '-e' then @subargs.shift; @excluded_files.push(@subargs.shift)
170
+ when '--dry-run' then @subargs.shift; @dry_run = true
171
+ when '--prune' then @subargs.shift; @prune = true
168
172
  when /^-/ then puts(@pastel.red.bold("Unknown option: #{@subargs[0].inspect}")); display_push_help_and_exit
169
173
  else break
170
174
  end
171
175
  }
172
176
 
177
+ if @dry_run
178
+ puts @pastel.green.bold("Doing a dry run, not actually pushing anything")
179
+ end
180
+
173
181
  root_path = Pathname @subargs[0]
174
182
 
175
183
  if !root_path.exist?
@@ -182,6 +190,28 @@ module Neocities
182
190
  display_push_help_and_exit
183
191
  end
184
192
 
193
+ if @prune
194
+ pruned_dirs = []
195
+ resp = @client.list
196
+ resp[:files].each do |file|
197
+ path = Pathname(File.join(@subargs[0], file[:path]))
198
+
199
+ pruned_dirs << path if !path.exist? && (file[:is_directory])
200
+
201
+ if !path.exist? && !pruned_dirs.include?(path.dirname)
202
+ print @pastel.bold("Deleting #{file[:path]} ... ")
203
+ resp = @client.delete_wrapper_with_dry_run file[:path], @dry_run
204
+
205
+ if resp[:result] == 'success'
206
+ print @pastel.green.bold("SUCCESS") + "\n"
207
+ else
208
+ print "\n"
209
+ display_response resp
210
+ end
211
+ end
212
+ end
213
+ end
214
+
185
215
  Dir.chdir(root_path) do
186
216
  paths = Dir.glob(File.join('**', '*'))
187
217
 
@@ -216,7 +246,7 @@ module Neocities
216
246
  paths.each do |path|
217
247
  next if path.directory?
218
248
  print @pastel.bold("Uploading #{path} ... ")
219
- resp = @client.upload path, path
249
+ resp = @client.upload path, path, @dry_run
220
250
 
221
251
  if resp[:result] == 'error' && resp[:error_type] == 'file_exists'
222
252
  print @pastel.yellow.bold("EXISTS") + "\n"
@@ -334,6 +364,8 @@ HERE
334
364
 
335
365
  #{@pastel.green '$ neocities push --no-gitignore .'} Don't use .gitignore to exclude files
336
366
 
367
+ #{@pastel.green '$ neocities push --dry-run .'} Just show what would be uploaded
368
+
337
369
  HERE
338
370
  exit
339
371
  end
@@ -42,7 +42,7 @@ module Neocities
42
42
  post 'upload_hash', remote_path => sha1_hash
43
43
  end
44
44
 
45
- def upload(path, remote_path=nil)
45
+ def upload(path, remote_path=nil, dry_run=false)
46
46
  path = Pathname path
47
47
 
48
48
  unless path.exist?
@@ -56,12 +56,24 @@ module Neocities
56
56
  if res[:files] && res[:files][remote_path.to_s.to_sym] == true
57
57
  return {result: 'error', error_type: 'file_exists', message: 'file already exists and matches local file, not uploading'}
58
58
  else
59
- File.open(path.to_s) do |file|
60
- post 'upload', rpath => file
59
+ if dry_run
60
+ return {result: 'success'}
61
+ else
62
+ File.open(path.to_s) do |file|
63
+ post 'upload', rpath => file
64
+ end
61
65
  end
62
66
  end
63
67
  end
64
68
 
69
+ def delete_wrapper_with_dry_run(paths, dry_run=false)
70
+ if dry_run
71
+ return {result: 'success'}
72
+ else
73
+ delete(paths)
74
+ end
75
+ end
76
+
65
77
  def delete(*paths)
66
78
  post 'delete', 'filenames[]' => paths
67
79
  end
@@ -1,3 +1,3 @@
1
1
  module Neocities
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.17'
3
3
  end
data/neocities.gemspec CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency 'tty-table', '~> 0.10', '= 0.10.0'
21
21
  spec.add_dependency 'tty-prompt', '~> 0.12', '= 0.12.0'
22
22
  spec.add_dependency 'pastel', '~> 0.7', '= 0.7.2'
23
- spec.add_dependency 'httpclient', '~> 2.8', '>= 2.8.3'
23
+ spec.add_dependency 'httpclient-fixcerts', '~> 2.8', '>= 2.8.5'
24
24
  spec.add_dependency 'rake', '~> 12.3', '>= 12.3.1'
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neocities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Drake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-24 00:00:00.000000000 Z
11
+ date: 2022-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-table
@@ -71,7 +71,7 @@ dependencies:
71
71
  - !ruby/object:Gem::Version
72
72
  version: 0.7.2
73
73
  - !ruby/object:Gem::Dependency
74
- name: httpclient
74
+ name: httpclient-fixcerts
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
77
  - - "~>"
@@ -79,7 +79,7 @@ dependencies:
79
79
  version: '2.8'
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 2.8.3
82
+ version: 2.8.5
83
83
  type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
@@ -89,7 +89,7 @@ dependencies:
89
89
  version: '2.8'
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 2.8.3
92
+ version: 2.8.5
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rake
95
95
  requirement: !ruby/object:Gem::Requirement