dorian 2.6.8 → 3.0.0
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 +4 -4
- data/.node-version +1 -1
- data/.npm-version +1 -1
- data/.rubocop.yml +25 -21
- data/.ruby-version +1 -1
- data/.tool-versions +2 -3
- data/Gemfile +0 -4
- data/Gemfile.lock +63 -116
- data/VERSION +1 -1
- data/dorian.gemspec +19 -19
- data/lib/dorian/bin.rb +82 -75
- data/package-lock.json +8 -8
- data/package.json +5 -5
- data/vendor/prettier/LICENSE +0 -4372
- data/vendor/prettier/README.md +14 -19
- data/vendor/prettier/THIRD-PARTY-NOTICES.md +6059 -0
- data/vendor/prettier/bin/prettier.cjs +27 -18
- data/vendor/prettier/doc.d.ts +11 -0
- data/vendor/prettier/doc.js +742 -776
- data/vendor/prettier/doc.mjs +743 -766
- data/vendor/prettier/index.cjs +266 -371
- data/vendor/prettier/index.d.ts +43 -16
- data/vendor/prettier/index.mjs +9615 -16721
- data/vendor/prettier/internal/experimental-cli-worker.mjs +2841 -0
- data/vendor/prettier/internal/experimental-cli.mjs +12790 -0
- data/vendor/prettier/internal/legacy-cli.mjs +6229 -0
- data/vendor/prettier/package.json +113 -108
- data/vendor/prettier/plugins/acorn.js +16 -6618
- data/vendor/prettier/plugins/acorn.mjs +16 -6456
- data/vendor/prettier/plugins/angular.js +4 -2435
- data/vendor/prettier/plugins/angular.mjs +4 -2375
- data/vendor/prettier/plugins/babel.d.ts +7 -7
- data/vendor/prettier/plugins/babel.js +15 -14271
- data/vendor/prettier/plugins/babel.mjs +15 -13986
- data/vendor/prettier/plugins/estree.d.ts +6 -1
- data/vendor/prettier/plugins/estree.js +43 -9486
- data/vendor/prettier/plugins/estree.mjs +43 -9278
- data/vendor/prettier/plugins/flow.js +19 -51476
- data/vendor/prettier/plugins/flow.mjs +19 -51218
- data/vendor/prettier/plugins/glimmer.d.ts +5 -1
- data/vendor/prettier/plugins/glimmer.js +30 -8527
- data/vendor/prettier/plugins/glimmer.mjs +30 -8414
- data/vendor/prettier/plugins/graphql.d.ts +5 -1
- data/vendor/prettier/plugins/graphql.js +15 -2408
- data/vendor/prettier/plugins/graphql.mjs +15 -2334
- data/vendor/prettier/plugins/html.d.ts +6 -1
- data/vendor/prettier/plugins/html.js +25 -8182
- data/vendor/prettier/plugins/html.mjs +25 -8077
- data/vendor/prettier/plugins/markdown.d.ts +5 -1
- data/vendor/prettier/plugins/markdown.js +57 -9063
- data/vendor/prettier/plugins/markdown.mjs +57 -8972
- data/vendor/prettier/plugins/meriyah.js +5 -5953
- data/vendor/prettier/plugins/meriyah.mjs +5 -5800
- data/vendor/prettier/plugins/postcss.d.ts +5 -1
- data/vendor/prettier/plugins/postcss.js +61 -9244
- data/vendor/prettier/plugins/postcss.mjs +61 -9046
- data/vendor/prettier/plugins/typescript.js +15 -38052
- data/vendor/prettier/plugins/typescript.mjs +15 -37726
- data/vendor/prettier/plugins/yaml.d.ts +5 -1
- data/vendor/prettier/plugins/yaml.js +157 -7423
- data/vendor/prettier/plugins/yaml.mjs +157 -7327
- data/vendor/prettier/standalone.d.ts +1 -1
- data/vendor/prettier/standalone.js +29 -3984
- data/vendor/prettier/standalone.mjs +29 -3938
- metadata +145 -40
- data/vendor/prettier/internal/cli.mjs +0 -4366
data/lib/dorian/bin.rb
CHANGED
|
@@ -5,11 +5,11 @@ require "dorian/arguments"
|
|
|
5
5
|
require "dorian/eval"
|
|
6
6
|
require "dorian/progress"
|
|
7
7
|
require "dorian/to_struct"
|
|
8
|
-
require "git"
|
|
9
8
|
require "hexapdf"
|
|
10
9
|
require "json"
|
|
11
10
|
require "mini_racer"
|
|
12
11
|
require "net/http"
|
|
12
|
+
require "open3"
|
|
13
13
|
require "parallel"
|
|
14
14
|
require "shellwords"
|
|
15
15
|
require "syntax_tree"
|
|
@@ -427,11 +427,9 @@ class Dorian
|
|
|
427
427
|
JS
|
|
428
428
|
|
|
429
429
|
if files.any?
|
|
430
|
-
each(files) { |file| format(file, context:) }
|
|
430
|
+
each(files) { |file| format(file, context: context) }
|
|
431
431
|
else
|
|
432
|
-
each(
|
|
433
|
-
Git.open(".").ls_files.map(&:first)
|
|
434
|
-
) { |file| format(file, context:) }
|
|
432
|
+
each(git_ls_files) { |file| format(file, context: context) }
|
|
435
433
|
end
|
|
436
434
|
end
|
|
437
435
|
|
|
@@ -489,8 +487,6 @@ class Dorian
|
|
|
489
487
|
down = "│ "
|
|
490
488
|
down_and_right = "├── "
|
|
491
489
|
|
|
492
|
-
git_ls_files = ->(path) { Git.open(".").ls_files(path).map(&:first) }
|
|
493
|
-
|
|
494
490
|
group =
|
|
495
491
|
lambda do |files|
|
|
496
492
|
files
|
|
@@ -526,8 +522,7 @@ class Dorian
|
|
|
526
522
|
|
|
527
523
|
keys.each do |key|
|
|
528
524
|
files =
|
|
529
|
-
git_ls_files
|
|
530
|
-
.call(key)
|
|
525
|
+
git_ls_files(key)
|
|
531
526
|
.map { |file| parsed.arguments.any? ? file.sub(key, "") : file }
|
|
532
527
|
values = group.call(files)
|
|
533
528
|
key = "#{key}/" if values.any? && key != "." && key[-1] != "/"
|
|
@@ -599,9 +594,10 @@ class Dorian
|
|
|
599
594
|
{ role: :user, content: content_3 }
|
|
600
595
|
]
|
|
601
596
|
|
|
602
|
-
message =
|
|
597
|
+
message =
|
|
598
|
+
completion(token: token(".commit"), model: "gpt-4o", messages: messages)
|
|
603
599
|
|
|
604
|
-
|
|
600
|
+
git_commit(message)
|
|
605
601
|
|
|
606
602
|
puts message
|
|
607
603
|
end
|
|
@@ -683,10 +679,7 @@ class Dorian
|
|
|
683
679
|
|
|
684
680
|
def command_dir
|
|
685
681
|
puts(
|
|
686
|
-
|
|
687
|
-
.open(".")
|
|
688
|
-
.ls_files
|
|
689
|
-
.map(&:first)
|
|
682
|
+
git_ls_files
|
|
690
683
|
.map { |path| path.split("/").first }
|
|
691
684
|
.select { |path| Dir.exist?(path) }
|
|
692
685
|
.reject { |path| path.start_with?(".") }
|
|
@@ -699,10 +692,7 @@ class Dorian
|
|
|
699
692
|
|
|
700
693
|
def command_ls
|
|
701
694
|
puts(
|
|
702
|
-
|
|
703
|
-
.open(".")
|
|
704
|
-
.ls_files
|
|
705
|
-
.map(&:first)
|
|
695
|
+
git_ls_files
|
|
706
696
|
.map { |path| path.split("/").first }
|
|
707
697
|
.reject { |path| path.start_with?(".") }
|
|
708
698
|
.select { |path| match_filetypes?(path) }
|
|
@@ -737,21 +727,17 @@ class Dorian
|
|
|
737
727
|
.reject { |line| line.empty? || line.start_with?("#") }
|
|
738
728
|
.map { |pattern| Regexp.new("\\A#{pattern}\\z") }
|
|
739
729
|
|
|
740
|
-
|
|
741
|
-
.
|
|
742
|
-
|
|
743
|
-
.
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
homefile = "#{Dir.home}/#{file}"
|
|
748
|
-
dotfile = File.expand_path("#{dir.chomp("/")}/#{file}")
|
|
749
|
-
if File.exist?(homefile) || File.symlink?(homefile)
|
|
750
|
-
File.delete(homefile)
|
|
751
|
-
end
|
|
752
|
-
FileUtils.mkdir_p(File.dirname(homefile))
|
|
753
|
-
FileUtils.ln_s(dotfile, homefile, verbose: true)
|
|
730
|
+
git_ls_files(chdir: dir).each do |file|
|
|
731
|
+
next if ignore_patterns.any? { |pattern| pattern.match?(file) }
|
|
732
|
+
|
|
733
|
+
homefile = "#{Dir.home}/#{file}"
|
|
734
|
+
dotfile = File.expand_path("#{dir.chomp("/")}/#{file}")
|
|
735
|
+
if File.exist?(homefile) || File.symlink?(homefile)
|
|
736
|
+
File.delete(homefile)
|
|
754
737
|
end
|
|
738
|
+
FileUtils.mkdir_p(File.dirname(homefile))
|
|
739
|
+
FileUtils.ln_s(dotfile, homefile, verbose: true)
|
|
740
|
+
end
|
|
755
741
|
end
|
|
756
742
|
|
|
757
743
|
def self?
|
|
@@ -774,7 +760,7 @@ class Dorian
|
|
|
774
760
|
end
|
|
775
761
|
end
|
|
776
762
|
|
|
777
|
-
compare(read_1, read_2, file_1
|
|
763
|
+
compare(read_1, read_2, file_1: file_1, file_2: file_2)
|
|
778
764
|
end
|
|
779
765
|
|
|
780
766
|
def command_each
|
|
@@ -823,15 +809,17 @@ class Dorian
|
|
|
823
809
|
def command_tally
|
|
824
810
|
each(everything) do |input|
|
|
825
811
|
outputs(
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
812
|
+
"#{
|
|
813
|
+
JSON.pretty_generate(
|
|
814
|
+
map(lines(reads(input)), progress: true) do |element|
|
|
815
|
+
if ruby.to_s.empty?
|
|
816
|
+
element
|
|
817
|
+
else
|
|
818
|
+
evaluates(it: element, returns: true, stdout: false)
|
|
819
|
+
end
|
|
820
|
+
end.tally
|
|
821
|
+
)
|
|
822
|
+
}\n"
|
|
835
823
|
)
|
|
836
824
|
end
|
|
837
825
|
end
|
|
@@ -919,10 +907,16 @@ class Dorian
|
|
|
919
907
|
end
|
|
920
908
|
|
|
921
909
|
def outputs(content, file: nil)
|
|
910
|
+
return if content.nil?
|
|
911
|
+
|
|
912
|
+
output_content = to_output(content)
|
|
913
|
+
|
|
922
914
|
if write? && file
|
|
923
|
-
File.write(file,
|
|
924
|
-
elsif
|
|
925
|
-
|
|
915
|
+
File.write(file, output_content)
|
|
916
|
+
elsif output == :raw && content.is_a?(String)
|
|
917
|
+
print output_content
|
|
918
|
+
else
|
|
919
|
+
puts output_content
|
|
926
920
|
end
|
|
927
921
|
end
|
|
928
922
|
|
|
@@ -1127,7 +1121,7 @@ class Dorian
|
|
|
1127
1121
|
end
|
|
1128
1122
|
end
|
|
1129
1123
|
|
|
1130
|
-
def each(collection, options: parallel_options, progress: false, &)
|
|
1124
|
+
def each(collection, options: parallel_options, progress: false, &block)
|
|
1131
1125
|
collection = wrap(collection)
|
|
1132
1126
|
progress_bar = progress ? create_progress_bar(collection.size) : nil
|
|
1133
1127
|
|
|
@@ -1136,7 +1130,7 @@ class Dorian
|
|
|
1136
1130
|
collection,
|
|
1137
1131
|
**options,
|
|
1138
1132
|
finish: ->(*) { progress_bar&.increment },
|
|
1139
|
-
&
|
|
1133
|
+
&block
|
|
1140
1134
|
)
|
|
1141
1135
|
else
|
|
1142
1136
|
collection.each do |element|
|
|
@@ -1145,7 +1139,7 @@ class Dorian
|
|
|
1145
1139
|
end
|
|
1146
1140
|
end
|
|
1147
1141
|
|
|
1148
|
-
def map(collection, options: parallel_options, progress: false, &)
|
|
1142
|
+
def map(collection, options: parallel_options, progress: false, &block)
|
|
1149
1143
|
collection = wrap(collection)
|
|
1150
1144
|
progress_bar = progress ? create_progress_bar(collection.size) : nil
|
|
1151
1145
|
|
|
@@ -1154,7 +1148,7 @@ class Dorian
|
|
|
1154
1148
|
collection,
|
|
1155
1149
|
**options,
|
|
1156
1150
|
finish: ->(*) { progress_bar&.increment },
|
|
1157
|
-
&
|
|
1151
|
+
&block
|
|
1158
1152
|
)
|
|
1159
1153
|
else
|
|
1160
1154
|
collection.map do |element|
|
|
@@ -1163,7 +1157,7 @@ class Dorian
|
|
|
1163
1157
|
end
|
|
1164
1158
|
end
|
|
1165
1159
|
|
|
1166
|
-
def select(collection, progress: false
|
|
1160
|
+
def select(collection, progress: false)
|
|
1167
1161
|
collection = wrap(collection)
|
|
1168
1162
|
progress_bar = progress ? create_progress_bar(collection.size) : nil
|
|
1169
1163
|
|
|
@@ -1172,7 +1166,7 @@ class Dorian
|
|
|
1172
1166
|
end
|
|
1173
1167
|
end
|
|
1174
1168
|
|
|
1175
|
-
def reject(collection, progress: false
|
|
1169
|
+
def reject(collection, progress: false)
|
|
1176
1170
|
collection = wrap(collection)
|
|
1177
1171
|
progress_bar = progress ? create_progress_bar(collection.size) : nil
|
|
1178
1172
|
|
|
@@ -1219,7 +1213,7 @@ class Dorian
|
|
|
1219
1213
|
def create_progress_bar(total)
|
|
1220
1214
|
return unless progress?
|
|
1221
1215
|
|
|
1222
|
-
Dorian::Progress.create(total
|
|
1216
|
+
Dorian::Progress.create(total: total, format: progress_format)
|
|
1223
1217
|
end
|
|
1224
1218
|
|
|
1225
1219
|
def after(input, ruby: @ruby_after || @ruby)
|
|
@@ -1229,7 +1223,7 @@ class Dorian
|
|
|
1229
1223
|
selected = false
|
|
1230
1224
|
|
|
1231
1225
|
input.select do |element|
|
|
1232
|
-
selected = true if match?(element, ruby:)
|
|
1226
|
+
selected = true if match?(element, ruby: ruby)
|
|
1233
1227
|
selected
|
|
1234
1228
|
end
|
|
1235
1229
|
end
|
|
@@ -1242,7 +1236,7 @@ class Dorian
|
|
|
1242
1236
|
selected = true
|
|
1243
1237
|
|
|
1244
1238
|
input.select do |element|
|
|
1245
|
-
selected.tap { selected = false if match?(element, ruby:) }
|
|
1239
|
+
selected.tap { selected = false if match?(element, ruby: ruby) }
|
|
1246
1240
|
end
|
|
1247
1241
|
end
|
|
1248
1242
|
end
|
|
@@ -1286,7 +1280,7 @@ class Dorian
|
|
|
1286
1280
|
end
|
|
1287
1281
|
|
|
1288
1282
|
def match?(element, ruby: @ruby)
|
|
1289
|
-
!!evaluates(ruby
|
|
1283
|
+
!!evaluates(ruby: ruby, it: element, stdout: false, returns: true)
|
|
1290
1284
|
end
|
|
1291
1285
|
|
|
1292
1286
|
def token(file)
|
|
@@ -1312,7 +1306,7 @@ class Dorian
|
|
|
1312
1306
|
"Content-Type" => "application/json",
|
|
1313
1307
|
"Authorization" => "Bearer #{token}"
|
|
1314
1308
|
},
|
|
1315
|
-
body: { model
|
|
1309
|
+
body: { model: model, messages: messages }.to_json
|
|
1316
1310
|
)
|
|
1317
1311
|
|
|
1318
1312
|
json = JSON.parse(body)
|
|
@@ -1354,8 +1348,8 @@ class Dorian
|
|
|
1354
1348
|
content_1[key],
|
|
1355
1349
|
content_2[key],
|
|
1356
1350
|
path: new_path,
|
|
1357
|
-
file_1
|
|
1358
|
-
file_2:
|
|
1351
|
+
file_1: file_1,
|
|
1352
|
+
file_2: file_2
|
|
1359
1353
|
)
|
|
1360
1354
|
end
|
|
1361
1355
|
elsif content_1.is_a?(Array) && content_2.is_a?(Array)
|
|
@@ -1373,8 +1367,8 @@ class Dorian
|
|
|
1373
1367
|
content_1[index],
|
|
1374
1368
|
content_2[index],
|
|
1375
1369
|
path: new_path,
|
|
1376
|
-
file_1
|
|
1377
|
-
file_2:
|
|
1370
|
+
file_1: file_1,
|
|
1371
|
+
file_2: file_2
|
|
1378
1372
|
)
|
|
1379
1373
|
end
|
|
1380
1374
|
elsif content_1.class != content_2.class
|
|
@@ -1409,6 +1403,20 @@ class Dorian
|
|
|
1409
1403
|
false
|
|
1410
1404
|
end
|
|
1411
1405
|
|
|
1406
|
+
def git_ls_files(path = nil, chdir: ".")
|
|
1407
|
+
command = ["git", "-C", chdir, "ls-files"]
|
|
1408
|
+
command.push("--", path) if path
|
|
1409
|
+
stdout, stderr, status = Open3.capture3(*command)
|
|
1410
|
+
abort stderr unless status.success?
|
|
1411
|
+
|
|
1412
|
+
stdout.lines.map(&:chomp)
|
|
1413
|
+
end
|
|
1414
|
+
|
|
1415
|
+
def git_commit(message)
|
|
1416
|
+
_stdout, stderr, status = Open3.capture3("git", "commit", "-m", message)
|
|
1417
|
+
abort stderr unless status.success?
|
|
1418
|
+
end
|
|
1419
|
+
|
|
1412
1420
|
def pluck(element)
|
|
1413
1421
|
element = element.from_deep_struct
|
|
1414
1422
|
|
|
@@ -1448,9 +1456,9 @@ class Dorian
|
|
|
1448
1456
|
headings = is_hashes ? data.first.to_h.keys : nil
|
|
1449
1457
|
rows = is_hashes ? data.map(&:values) : data.map { |row| wrap(row) }
|
|
1450
1458
|
if headings
|
|
1451
|
-
puts Terminal::Table.new(headings
|
|
1459
|
+
puts Terminal::Table.new(headings: headings, rows: rows)
|
|
1452
1460
|
else
|
|
1453
|
-
puts Terminal::Table.new(rows:)
|
|
1461
|
+
puts Terminal::Table.new(rows: rows)
|
|
1454
1462
|
end
|
|
1455
1463
|
end
|
|
1456
1464
|
|
|
@@ -1466,15 +1474,15 @@ class Dorian
|
|
|
1466
1474
|
returns: false
|
|
1467
1475
|
)
|
|
1468
1476
|
Dorian::Eval.eval(
|
|
1469
|
-
ruby
|
|
1470
|
-
it
|
|
1471
|
-
debug
|
|
1472
|
-
stdout
|
|
1473
|
-
stderr
|
|
1474
|
-
colorize
|
|
1475
|
-
rails
|
|
1476
|
-
fast
|
|
1477
|
-
returns:
|
|
1477
|
+
ruby: ruby,
|
|
1478
|
+
it: it,
|
|
1479
|
+
debug: debug,
|
|
1480
|
+
stdout: stdout,
|
|
1481
|
+
stderr: stderr,
|
|
1482
|
+
colorize: colorize,
|
|
1483
|
+
rails: rails,
|
|
1484
|
+
fast: fast,
|
|
1485
|
+
returns: returns
|
|
1478
1486
|
).returned
|
|
1479
1487
|
end
|
|
1480
1488
|
|
|
@@ -1497,9 +1505,8 @@ class Dorian
|
|
|
1497
1505
|
def filetype(path)
|
|
1498
1506
|
ext = File.extname(path).to_s.downcase
|
|
1499
1507
|
|
|
1500
|
-
if File.exist?(".format-ignore")
|
|
1501
|
-
|
|
1502
|
-
end
|
|
1508
|
+
return if File.exist?(".format-ignore") &&
|
|
1509
|
+
File.read(".format-ignore").split.map(&:strip).include?(path)
|
|
1503
1510
|
|
|
1504
1511
|
return :directory if Dir.exist?(path)
|
|
1505
1512
|
return :symlink if File.symlink?(path)
|
data/package-lock.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"": {
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"groovy-beautify": "
|
|
10
|
-
"prettier": "
|
|
9
|
+
"groovy-beautify": "^0.0.17",
|
|
10
|
+
"prettier": "^3.8.4"
|
|
11
11
|
},
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": "
|
|
14
|
-
"npm": "11.
|
|
13
|
+
"node": "26.3.1",
|
|
14
|
+
"npm": "11.17.0"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"node_modules/groovy-beautify": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"license": "MIT"
|
|
22
22
|
},
|
|
23
23
|
"node_modules/prettier": {
|
|
24
|
-
"version": "3.
|
|
25
|
-
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.
|
|
26
|
-
"integrity": "sha512-
|
|
24
|
+
"version": "3.8.4",
|
|
25
|
+
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.4.tgz",
|
|
26
|
+
"integrity": "sha512-N2MylSdi48+5N/6S5j+maeHbUSIzzZ5uOcX5Hm4QpV8Dkb1HFjfAKTKX6yNPJQD9AhcT3ifHNB66tWTTJDi11Q==",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"bin": {
|
|
29
29
|
"prettier": "bin/prettier.cjs"
|
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|
data/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"groovy-beautify": "
|
|
4
|
-
"prettier": "
|
|
3
|
+
"groovy-beautify": "^0.0.17",
|
|
4
|
+
"prettier": "^3.8.4"
|
|
5
5
|
},
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": "
|
|
8
|
-
"npm": "11.
|
|
7
|
+
"node": "26.3.1",
|
|
8
|
+
"npm": "11.17.0"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT"
|
|
11
|
-
}
|
|
11
|
+
}
|