generated from Apodini/Template-Repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrator
executable file
·56 lines (45 loc) · 1.54 KB
/
migrator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env ruby
#
# This source file is part of the Apodini open source project
#
# SPDX-FileCopyrightText: 2021 Paul Schmiedmayer and the project authors (see CONTRIBUTORS.md) <[email protected]>
#
# SPDX-License-Identifier: MIT
#
require 'open3'
if ARGV.count != 1
puts "Usage: #{$0} <migrator-command>"
exit 0
end
$action = ARGV[0]
class ACTION
MIGRATE = "migrate"
GENERATE = "generate"
COMPARE = "compare"
end
def command(action:)
migrator = "swift run migrator"
target = "./Resources"
packageName = "QONECTIQ"
oldAPI = "ExampleDocuments/api_qonectiq1.0.0.json"
newAPI = "ExampleDocuments/api_qonectiq2.0.0.json"
case action
when ACTION::MIGRATE
return "#{migrator} migrate rest -t=#{target} -d=#{target}/#{oldAPI} -m=#{target}/ExampleDocuments/migration_guide.json -n=#{packageName}"
when ACTION::GENERATE
return "#{migrator} generate rest -d=#{target}/#{oldAPI} -n=#{packageName} -t=#{target}"
when ACTION::COMPARE
return "#{migrator} compare -o #{target}/#{oldAPI} -n #{target}/#{newAPI} -m #{target}/ExampleDocuments -f json"
else
puts "Usage: #{$0} | Use one of the following commands: <generate> or <compare>. After generating the migration guide with the <compare> command, the library can be migrated via <migrate>"
exit 0
end
end
def migrator()
cmd = command(action: $action)
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
puts stdout.read
puts stderr.read
end
end
migrator()