neocities 0.0.16 → 0.0.18

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: 62c435913de9ee21adbc536807d56153b4c5ec3987e069e6fd7ffbca9ff16c46
4
- data.tar.gz: '069354d31728a5d4fbbc6007c1cf1133e2dec90ed8fbffbf3e5789aa210ffe83'
3
+ metadata.gz: 322b624aea971dd7a650eac8a9b6011e0f3d13ff8e4a5bb2f1a423b87bb446ac
4
+ data.tar.gz: c28f4d3296f36bb8a556fa210cc79a19a765e511fbf3b45111f93738b26014d4
5
5
  SHA512:
6
- metadata.gz: 1dab02d7cd419ffdec02a00b69a40e0661801e9b0b27c48ed3c2c44974a8b3437a99691ec3b7907a49a6812f2531aa85ae21a7d6f3737dbc1e21e471173c2697
7
- data.tar.gz: aabbe5d7fbdcae12410510dd5b26e0e37c02e879abfc544d639d0c5aeaa9628f1578530b8f47646ab589be5f811a632f4579d157891f47b9a0ef56a8705fc643
6
+ metadata.gz: ec195af25579bd74b8763ec1bc2d997ede505157fb2e6da9e27bfc4854a03526c57d8d05c593e9a10bfa8c0597649f75be03962d338933cbf763c9c75be9e110
7
+ data.tar.gz: 45ea7e5ff1bc0addafe30ca5bb9a8e3b23dabd168b01b0169ab254895d8041bb098687cfb982c5161d2d5a9d4ed2634937064c87b1f3b0bcb76b8ea1d944d031
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
@@ -48,6 +48,8 @@ module Neocities
48
48
  if !@api_key
49
49
  begin
50
50
  @api_key = File.read @app_config_path
51
+ # Remove any trailing whitespace causing HTTP requests to fail
52
+ @api_key = @api_key.strip
51
53
  rescue Errno::ENOENT
52
54
  @api_key = nil
53
55
  end
@@ -162,11 +164,13 @@ module Neocities
162
164
  @no_gitignore = false
163
165
  @excluded_files = []
164
166
  @dry_run = false
167
+ @prune = false
165
168
  loop {
166
169
  case @subargs[0]
167
170
  when '--no-gitignore' then @subargs.shift; @no_gitignore = true
168
171
  when '-e' then @subargs.shift; @excluded_files.push(@subargs.shift)
169
172
  when '--dry-run' then @subargs.shift; @dry_run = true
173
+ when '--prune' then @subargs.shift; @prune = true
170
174
  when /^-/ then puts(@pastel.red.bold("Unknown option: #{@subargs[0].inspect}")); display_push_help_and_exit
171
175
  else break
172
176
  end
@@ -188,8 +192,30 @@ module Neocities
188
192
  display_push_help_and_exit
189
193
  end
190
194
 
195
+ if @prune
196
+ pruned_dirs = []
197
+ resp = @client.list
198
+ resp[:files].each do |file|
199
+ path = Pathname(File.join(@subargs[0], file[:path]))
200
+
201
+ pruned_dirs << path if !path.exist? && (file[:is_directory])
202
+
203
+ if !path.exist? && !pruned_dirs.include?(path.dirname)
204
+ print @pastel.bold("Deleting #{file[:path]} ... ")
205
+ resp = @client.delete_wrapper_with_dry_run file[:path], @dry_run
206
+
207
+ if resp[:result] == 'success'
208
+ print @pastel.green.bold("SUCCESS") + "\n"
209
+ else
210
+ print "\n"
211
+ display_response resp
212
+ end
213
+ end
214
+ end
215
+ end
216
+
191
217
  Dir.chdir(root_path) do
192
- paths = Dir.glob(File.join('**', '*'))
218
+ paths = Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH)
193
219
 
194
220
  if @no_gitignore == false
195
221
  begin
@@ -341,6 +367,8 @@ HERE
341
367
  #{@pastel.green '$ neocities push --no-gitignore .'} Don't use .gitignore to exclude files
342
368
 
343
369
  #{@pastel.green '$ neocities push --dry-run .'} Just show what would be uploaded
370
+
371
+ #{@pastel.green '$ neocities push --prune .'} Delete site files not in dir (be careful!)
344
372
 
345
373
  HERE
346
374
  exit
@@ -66,6 +66,14 @@ module Neocities
66
66
  end
67
67
  end
68
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
+
69
77
  def delete(*paths)
70
78
  post 'delete', 'filenames[]' => paths
71
79
  end
@@ -1,3 +1,3 @@
1
1
  module Neocities
2
- VERSION = '0.0.16'
2
+ VERSION = '0.0.18'
3
3
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neocities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Drake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-01 00:00:00.000000000 Z
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-table
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 0.10.0
20
17
  - - "~>"
21
18
  - !ruby/object:Gem::Version
22
19
  version: '0.10'
20
+ - - '='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.10.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '='
28
- - !ruby/object:Gem::Version
29
- version: 0.10.0
30
27
  - - "~>"
31
28
  - !ruby/object:Gem::Version
32
29
  version: '0.10'
30
+ - - '='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.10.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: tty-prompt
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '='
38
- - !ruby/object:Gem::Version
39
- version: 0.12.0
40
37
  - - "~>"
41
38
  - !ruby/object:Gem::Version
42
39
  version: '0.12'
40
+ - - '='
41
+ - !ruby/object:Gem::Version
42
+ version: 0.12.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '='
48
- - !ruby/object:Gem::Version
49
- version: 0.12.0
50
47
  - - "~>"
51
48
  - !ruby/object:Gem::Version
52
49
  version: '0.12'
50
+ - - '='
51
+ - !ruby/object:Gem::Version
52
+ version: 0.12.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: pastel
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.0.3
151
+ rubygems_version: 3.3.26
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Neocities.org CLI and API client