adaptrex 0.9.22
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/adaptrex +21 -0
- data/lib/adaptrex/adaptrexconfig.rb +130 -0
- data/lib/adaptrex/adaptrexinstaller.rb +46 -0
- data/lib/adaptrex/appconfig.rb +103 -0
- data/lib/adaptrex/bootstrapinstaller.rb +82 -0
- data/lib/adaptrex/builder.rb +93 -0
- data/lib/adaptrex/deletetool.rb +74 -0
- data/lib/adaptrex/generate.rb +222 -0
- data/lib/adaptrex/sdkinstaller.rb +102 -0
- data/lib/adaptrex/themeinstaller.rb +118 -0
- data/lib/adaptrex/themetool.rb +44 -0
- data/lib/adaptrex/upgradetool.rb +64 -0
- data/lib/adaptrex.rb +197 -0
- data/templates/ext/app/controller/Main.js +3 -0
- data/templates/ext/app/view/Main.js +4 -0
- data/templates/ext/app/view/Viewport.js +20 -0
- data/templates/ext/app.js +6 -0
- data/templates/touch/app/view/Main.js +35 -0
- data/templates/touch/app.js +7 -0
- metadata +83 -0
data/bin/adaptrex
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2012 Adaptrex, LLC
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/adaptrex")
|
20
|
+
basePath = File.expand_path(File.dirname(__FILE__) + "/..")
|
21
|
+
Adaptrex.new(basePath, ARGV)
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012 Adaptrex, LLC
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require "etc"
|
18
|
+
require "pathname"
|
19
|
+
|
20
|
+
# Utility class to manage the .adaptrex.config file
|
21
|
+
class AdaptrexConfig
|
22
|
+
|
23
|
+
attr_accessor :weblibPath, :adaptrexVersions, :extVersions, :touchVersions
|
24
|
+
|
25
|
+
@configFilePath
|
26
|
+
def initialize
|
27
|
+
@configFilePath = Etc.getpwuid.dir + "/.adaptrex.config"
|
28
|
+
if not File.exist?(@configFilePath)
|
29
|
+
puts "Welcome To Adaptrex Tools!".blue
|
30
|
+
puts "The first time you run the Tools, we need to learn a little about your environment."
|
31
|
+
|
32
|
+
# Weblib Path is requires... make sure we set it up right away
|
33
|
+
promptForWeblibPath
|
34
|
+
else
|
35
|
+
read
|
36
|
+
updateInstalledSDKs
|
37
|
+
end
|
38
|
+
write
|
39
|
+
end
|
40
|
+
|
41
|
+
def read
|
42
|
+
config = File.new(@configFilePath, "r")
|
43
|
+
while (line = config.gets)
|
44
|
+
line.strip!
|
45
|
+
if (line[0] != "#" and line[0] != "=")
|
46
|
+
eq = line.index("=")
|
47
|
+
if (eq)
|
48
|
+
key = line[0..eq - 1].strip
|
49
|
+
value = line[eq + 1..-1].strip
|
50
|
+
|
51
|
+
if key == "weblib.path" then self.weblibPath = value
|
52
|
+
elsif key == "adaptrex.versions" then self.adaptrexVersions = value.split(",")
|
53
|
+
elsif key == "ext.versions" then self.extVersions = value.split(",")
|
54
|
+
elsif key == "touch.versions" then self.touchVersions = value.split(",")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
config.close
|
60
|
+
end
|
61
|
+
|
62
|
+
def write
|
63
|
+
settings = File.open(@configFilePath, "w")
|
64
|
+
settings.puts "#"
|
65
|
+
settings.puts "# Adaptrex Configuration"
|
66
|
+
settings.puts "# ----------------------"
|
67
|
+
settings.puts "#"
|
68
|
+
settings.puts "# This file is automatically generated and maintained by Adaptrex Tools."
|
69
|
+
settings.puts "#"
|
70
|
+
settings.puts "\n\n"
|
71
|
+
settings.puts "weblib.path = " + self.weblibPath
|
72
|
+
settings.puts "adaptrex.versions = " + self.adaptrexVersions.join(",")
|
73
|
+
if self.extVersions.length > 0
|
74
|
+
settings.puts "ext.versions = " + self.extVersions.join(",")
|
75
|
+
end
|
76
|
+
if self.touchVersions.length > 0
|
77
|
+
settings.puts "touch.versions = " + self.touchVersions.join(",")
|
78
|
+
end
|
79
|
+
settings.close
|
80
|
+
end
|
81
|
+
|
82
|
+
def promptForWeblibPath
|
83
|
+
puts "Enter the path of the folder containing your AdaptrexJS, ExtJS and Sencha Touch SDKs."
|
84
|
+
print " : "
|
85
|
+
userInput = STDIN.gets.chomp
|
86
|
+
self.weblibPath = userInput
|
87
|
+
|
88
|
+
if not File.directory?userInput
|
89
|
+
puts "You entered an invalid path".err
|
90
|
+
return promptForWeblibPath
|
91
|
+
end
|
92
|
+
|
93
|
+
updateInstalledSDKs
|
94
|
+
|
95
|
+
errorMsg = []
|
96
|
+
if adaptrexVersions.length == 0
|
97
|
+
errorMsg.push("You must have an AdaptrexJS folder.".indent)
|
98
|
+
end
|
99
|
+
if (extVersions.length + touchVersions.length == 0)
|
100
|
+
errorMsg.push("You must have at least one ExtJS or Sencha Touch SDK folder.".indent)
|
101
|
+
end
|
102
|
+
if errorMsg.length > 0
|
103
|
+
puts "The folder you entered is missing the required SDKs".err
|
104
|
+
puts errorMsg.join("\n")
|
105
|
+
return promptForWeblibPath
|
106
|
+
end
|
107
|
+
|
108
|
+
puts "Your weblib folder has been successfully configured.\n\n".success
|
109
|
+
end
|
110
|
+
|
111
|
+
def updateInstalledSDKs
|
112
|
+
self.adaptrexVersions = []
|
113
|
+
self.extVersions = []
|
114
|
+
self.touchVersions = []
|
115
|
+
|
116
|
+
Pathname.new(self.weblibPath).children.select {|path|
|
117
|
+
folderName = path.basename.to_s
|
118
|
+
if folderName =~ /\s/
|
119
|
+
puts "Weblib folder name cannot contain spaces (" + folderName + ")".success
|
120
|
+
puts "It will not be available to your applications.\n".indent
|
121
|
+
else
|
122
|
+
if folderName.start_with?"adaptrex" then self.adaptrexVersions.push(folderName)
|
123
|
+
elsif folderName.start_with?"ext" then self.extVersions.push(folderName)
|
124
|
+
elsif folderName.start_with?"sencha" then self.touchVersions.push(folderName)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class AdaptrexInstaller
|
2
|
+
|
3
|
+
attr_accessor :success, :version
|
4
|
+
def initialize (adaptrexConfig)
|
5
|
+
@adaptrexConfig = adaptrexConfig
|
6
|
+
self.success = false
|
7
|
+
puts "Adaptrex Installer".blue
|
8
|
+
|
9
|
+
versions = adaptrexConfig.adaptrexVersions
|
10
|
+
|
11
|
+
if versions.length == 1
|
12
|
+
self.version = versions[0]
|
13
|
+
else
|
14
|
+
index = 0
|
15
|
+
versions.each {|option|
|
16
|
+
puts " [" + (index + 1).to_s + "] " + versions[index]
|
17
|
+
index += 1
|
18
|
+
}
|
19
|
+
self.version = promptForAdaptrexVersion
|
20
|
+
end
|
21
|
+
|
22
|
+
puts "AdaptrexJS Configured (" + self.version + ")".success
|
23
|
+
end
|
24
|
+
|
25
|
+
def promptForAdaptrexVersion
|
26
|
+
print "Select the version to use for this webapp: "
|
27
|
+
selection = STDIN.gets.chomp
|
28
|
+
|
29
|
+
versions = @adaptrexConfig.adaptrexVersions
|
30
|
+
len = versions.length
|
31
|
+
erm = ("Invalid selection. Enter a number from 1 to " + len.to_s).err
|
32
|
+
if not selection.numeric?
|
33
|
+
puts erm
|
34
|
+
return promptForAdaptrexVersion
|
35
|
+
end
|
36
|
+
selection = Integer(selection)
|
37
|
+
|
38
|
+
if not selection === 1..len
|
39
|
+
puts erm
|
40
|
+
return promptForAdaptrexVersion
|
41
|
+
end
|
42
|
+
|
43
|
+
return versions[selection - 1]
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require "adaptrex/adaptrexinstaller"
|
2
|
+
|
3
|
+
class AppConfig
|
4
|
+
|
5
|
+
attr_accessor :adaptrexVersion, :extVersion, :touchVersion, :pages, :lastSDK, :valid
|
6
|
+
def initialize(adaptrexConfig)
|
7
|
+
@adaptrexConfig = adaptrexConfig
|
8
|
+
self.valid = false
|
9
|
+
self.pages = Hash.new
|
10
|
+
if not File.directory?"adaptrex" then Dir.mkdir("adaptrex") end
|
11
|
+
if not File.exist?"adaptrex/.app.settings" then write end
|
12
|
+
read
|
13
|
+
|
14
|
+
#
|
15
|
+
# Make sure we've got an AdaptrexJS version configured for this webapp
|
16
|
+
#
|
17
|
+
adaptrex = self.adaptrexVersion
|
18
|
+
if adaptrex.nil?
|
19
|
+
adaptrexInstaller = AdaptrexInstaller.new(adaptrexConfig)
|
20
|
+
self.adaptrexVersion = adaptrexInstaller.version
|
21
|
+
write
|
22
|
+
puts ""
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
#
|
27
|
+
# Make sure adapterx config contains the frameworks configured in this app
|
28
|
+
#
|
29
|
+
missingSDKs = []
|
30
|
+
ext = self.extVersion
|
31
|
+
touch = self.touchVersion
|
32
|
+
if not adaptrex.nil? and adaptrexConfig.adaptrexVersions.index(adaptrex).nil?
|
33
|
+
missingSDKs.push(adaptrex)
|
34
|
+
end
|
35
|
+
if not ext.nil? and adaptrexConfig.extVersions.index(ext).nil?
|
36
|
+
missingSDKs.push(ext)
|
37
|
+
end
|
38
|
+
if not touch.nil? and adaptrexConfig.touchVersions.index(touch).nil?
|
39
|
+
missingSDKs.push(touch)
|
40
|
+
end
|
41
|
+
|
42
|
+
if missingSDKs.length > 0
|
43
|
+
puts "Your weblib folder is missing SDKs used by this webapp".err
|
44
|
+
puts "Check your weblib folder at: ".indent + adaptrexConfig.weblibPath
|
45
|
+
puts "Missing the following:".indent
|
46
|
+
for sdk in missingSDKs
|
47
|
+
puts " - #{sdk}".indent
|
48
|
+
end
|
49
|
+
puts ""
|
50
|
+
return
|
51
|
+
end
|
52
|
+
|
53
|
+
self.valid = true
|
54
|
+
end
|
55
|
+
|
56
|
+
def read
|
57
|
+
settings = File.new("adaptrex/.app.settings", "r")
|
58
|
+
while (line = settings.gets)
|
59
|
+
line.strip!
|
60
|
+
if (line[0] != ?# and line[0] != ?=)
|
61
|
+
eq = line.index("=")
|
62
|
+
if (eq)
|
63
|
+
key = line[0..eq - 1].strip
|
64
|
+
value = line[eq + 1..-1].strip
|
65
|
+
|
66
|
+
if key == "adaptrex.version" then self.adaptrexVersion = value
|
67
|
+
elsif key == "ext.version" then self.extVersion = value
|
68
|
+
elsif key == "touch.version" then self.touchVersion = value
|
69
|
+
elsif key == "last.sdk" then self.lastSDK = value
|
70
|
+
else self.pages[key] = value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
settings.close
|
76
|
+
end
|
77
|
+
|
78
|
+
def write
|
79
|
+
settings = File.open("adaptrex/.app.settings", "w")
|
80
|
+
settings.puts "# Adaptrex Application Configuration"
|
81
|
+
settings.puts "# ----------------------------------"
|
82
|
+
settings.puts "#"
|
83
|
+
settings.puts "# This folder is automatically generated and maintained by Adaptrex Tools."
|
84
|
+
settings.puts "# You may modify this file directly to add or remove apps (pages) that"
|
85
|
+
settings.puts "# you have modified outside of the Adaptrex Tools."
|
86
|
+
settings.puts "\n\n"
|
87
|
+
settings.puts "# Frameworks"
|
88
|
+
settings.puts "# ----------"
|
89
|
+
if not self.adaptrexVersion.nil? then settings.puts "adaptrex.version = " + self.adaptrexVersion end
|
90
|
+
if not self.extVersion.nil? then settings.puts "ext.version = " + self.extVersion end
|
91
|
+
if not self.touchVersion.nil? then settings.puts "touch.version = " + self.touchVersion end
|
92
|
+
if not self.lastSDK.nil? then settings.puts "last.sdk = " + self.lastSDK end
|
93
|
+
|
94
|
+
settings.puts "\n\n"
|
95
|
+
settings.puts "# Applications"
|
96
|
+
settings.puts "# ------------"
|
97
|
+
self.pages.each do|key,val|
|
98
|
+
settings.puts key + " = " + val
|
99
|
+
end
|
100
|
+
|
101
|
+
settings.close
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012 Adaptrex, LLC
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
# Utility class to create the Adaptrex/Ext bootstrap file
|
18
|
+
class BootstrapInstaller
|
19
|
+
require "tmpdir"
|
20
|
+
require "fileutils"
|
21
|
+
|
22
|
+
attr_accessor :success
|
23
|
+
def initialize(adaptrexConfig, appConfig, sdkType)
|
24
|
+
self.success = false
|
25
|
+
isExt = sdkType == "ext"
|
26
|
+
if isExt then sdkVersion = appConfig.extVersion else sdkVersion = appConfig.touchVersion end
|
27
|
+
adaptrexVersion = appConfig.adaptrexVersion
|
28
|
+
puts "Generating the bootstrap file for " + adaptrexVersion + " and " + sdkVersion + "..."
|
29
|
+
|
30
|
+
adaptrexPath = adaptrexConfig.weblibPath + "/" + adaptrexVersion
|
31
|
+
sdkPath = adaptrexConfig.weblibPath + "/" + sdkVersion
|
32
|
+
|
33
|
+
cmdParts = nil
|
34
|
+
tmpDir = nil
|
35
|
+
if isExt
|
36
|
+
cmdParts = [
|
37
|
+
"and include -r -f ExtDependencies.js",
|
38
|
+
"and exclude -t core",
|
39
|
+
"and include -na Adaptrex.override.ext",
|
40
|
+
"and exclude -f ExtDependencies.js",
|
41
|
+
]
|
42
|
+
else
|
43
|
+
cmdParts = [
|
44
|
+
"and include -r -f TouchDependencies.js",
|
45
|
+
"and exclude -t core",
|
46
|
+
"and include -na Adaptrex.override.touch",
|
47
|
+
"and exclude -f TouchDependencies.js",
|
48
|
+
]
|
49
|
+
|
50
|
+
# Sencha Touch 2.1.0 has a bug that prevents compilation. The file containing
|
51
|
+
# the bug is not required for the bootstrap file so we move it to a temp file
|
52
|
+
# during the compilation and restore it
|
53
|
+
tmpDir = Dir.tmpdir
|
54
|
+
FileUtils.mv(sdkPath + "/src/ux/auth2", tmpDir + "_senchatouch_auth2")
|
55
|
+
end
|
56
|
+
|
57
|
+
begin
|
58
|
+
cmd = "sencha -sdk " + sdkPath + " compile -classpath " + adaptrexPath + "/src" +
|
59
|
+
" exclude -all and " + cmdParts.join(" and ") +
|
60
|
+
" and concat adaptrex/" + sdkType + "/bootstrap-debug.js" +
|
61
|
+
" and concat -compress adaptrex/" + sdkType + "/bootstrap.js"
|
62
|
+
compileOutput = `#{cmd}`
|
63
|
+
|
64
|
+
if compileOutput.include?"[ERR]"
|
65
|
+
puts "There was an error creating your bootstrap file.".err
|
66
|
+
puts "See the output from Sencha Cmd for more information".indent
|
67
|
+
puts "-----\n" + cmd + "\n-----\n" + compileOutput + "-----\n\n"
|
68
|
+
else
|
69
|
+
puts((adaptrexVersion + " + " + sdkVersion + " Boostrap Installed").success)
|
70
|
+
end
|
71
|
+
|
72
|
+
ensure
|
73
|
+
# Move the broken auth2 ux back to the original Sencha Touch source folder
|
74
|
+
if not isExt
|
75
|
+
FileUtils.mv(tmpDir + "_senchatouch_auth2", sdkPath + "/src/ux/auth2")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Success!
|
80
|
+
self.success = true
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012 Adaptrex, LLC
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require "tmpdir"
|
18
|
+
require "fileutils"
|
19
|
+
|
20
|
+
# Package all that pages
|
21
|
+
class AdaptrexBuilder
|
22
|
+
def initialize(adaptrexConfig, appConfig)
|
23
|
+
weblib = adaptrexConfig.weblibPath
|
24
|
+
|
25
|
+
if appConfig.pages.length == 0
|
26
|
+
puts "There are no apps (pages) to be compiled".warn
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
# Loop through each app and compile
|
32
|
+
appConfig.pages.each do|key,val|
|
33
|
+
appPath = key
|
34
|
+
parts = val.split(",")
|
35
|
+
appName = parts[0]
|
36
|
+
sdkType = parts[1]
|
37
|
+
|
38
|
+
puts "Compiling " + appName + " (" + appPath + ")"
|
39
|
+
|
40
|
+
if sdkType == "ext"
|
41
|
+
sdkVersion = appConfig.extVersion
|
42
|
+
excludes = "ExtDependencies.js"
|
43
|
+
sdkPath = weblib + "/" + sdkVersion
|
44
|
+
|
45
|
+
else
|
46
|
+
sdkVersion = appConfig.touchVersion
|
47
|
+
excludes = "TouchDependencies.js"
|
48
|
+
sdkPath = weblib + "/" + sdkVersion
|
49
|
+
|
50
|
+
# Sencha Touch 2.1.0 has a bug that prevents compilation. The file containing
|
51
|
+
# the bug is not required for the bootstrap file so we move it to a temp file
|
52
|
+
# during the compilation and restore it
|
53
|
+
tmpDir = Dir.tmpdir
|
54
|
+
FileUtils.mv(sdkPath + "/src/ux/auth2", tmpDir + "_senchatouch_auth2")
|
55
|
+
end
|
56
|
+
|
57
|
+
begin
|
58
|
+
cmd = "sencha -d -sdk=" + sdkPath + " compile" +
|
59
|
+
" -classpath=" +
|
60
|
+
appPath + "/app.js," +
|
61
|
+
appPath + "/app," +
|
62
|
+
weblib + "/" + appConfig.adaptrexVersion + "/src" +
|
63
|
+
" exclude -all" +
|
64
|
+
" and include -r -f " + appPath + "/app.js" +
|
65
|
+
" and save appset" +
|
66
|
+
" and exclude -all" +
|
67
|
+
" and include -r -f " + excludes +
|
68
|
+
" and save bootstrapexcludes" +
|
69
|
+
" and exclude -all" +
|
70
|
+
" and include -s appset and exclude -s bootstrapexcludes" +
|
71
|
+
" and concat " + appPath + "/app-all-debug.js" +
|
72
|
+
" and concat -compress " + appPath + "/app-all.js"
|
73
|
+
compileOutput = `#{cmd}`
|
74
|
+
|
75
|
+
if compileOutput.include?"[ERR]"
|
76
|
+
puts((appName + " (" + appPath + ")").err)
|
77
|
+
puts "See the output from Sencha Cmd for more information".indent
|
78
|
+
puts "-----\n" + cmd + "\n-----\n" + compileOutput + "-----\n\n"
|
79
|
+
else
|
80
|
+
print((appName + " (" + appPath + ")").success)
|
81
|
+
puts ""
|
82
|
+
end
|
83
|
+
|
84
|
+
ensure
|
85
|
+
# Move the broken auth2 ux back to the original Sencha Touch source folder
|
86
|
+
if not sdkType == "ext"
|
87
|
+
FileUtils.mv(tmpDir + "_senchatouch_auth2", sdkPath + "/src/ux/auth2")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
class DeleteTool
|
4
|
+
def initialize(appConfig)
|
5
|
+
@appConfig = appConfig
|
6
|
+
promptForDeletion
|
7
|
+
end
|
8
|
+
|
9
|
+
def promptForDeletion
|
10
|
+
@appInfoList = []
|
11
|
+
@appPages = @appConfig.pages
|
12
|
+
|
13
|
+
if @appPages.length < 1
|
14
|
+
puts "There are no pages to delete.".warn
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "Page List".blue
|
19
|
+
|
20
|
+
index = 0
|
21
|
+
@appPages.sort.map.each {|appPath,appValue|
|
22
|
+
appName = appValue.split(",")[0]
|
23
|
+
@appInfoList.push({
|
24
|
+
"name" => appName,
|
25
|
+
"path" => appPath,
|
26
|
+
"text" => appName + " (" + appPath + ")"
|
27
|
+
})
|
28
|
+
i = index + 1
|
29
|
+
if i < 10 then pad = " " else pad = "" end
|
30
|
+
puts " [" + pad + i.to_s + "] " + appName + " (" + appPath + ")"
|
31
|
+
index += 1
|
32
|
+
}
|
33
|
+
puts ""
|
34
|
+
|
35
|
+
appToDelete = promptForApplication
|
36
|
+
puts "Are you sure you want to delete " + appToDelete["text"] + ")?".warn
|
37
|
+
print "Type 'DELETE' to confirm: ".indent
|
38
|
+
confirm = STDIN.gets.chomp
|
39
|
+
|
40
|
+
if confirm == "DELETE"
|
41
|
+
FileUtils.rm_rf(appToDelete["path"])
|
42
|
+
@appConfig.pages.delete(appToDelete["path"])
|
43
|
+
@appConfig.write
|
44
|
+
puts((appToDelete["text"] + " has been deleted\n\n").success)
|
45
|
+
else
|
46
|
+
puts "Your app (page) was not deleted".warn
|
47
|
+
end
|
48
|
+
|
49
|
+
print "Do you want to delete another page? [n]: "
|
50
|
+
doAnother = STDIN.gets.chomp.downcase
|
51
|
+
if (doAnother == "y" or doAnother == "yes")
|
52
|
+
puts ""
|
53
|
+
return promptForDeletion
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def promptForApplication
|
58
|
+
print "Which page do you want to delete? : "
|
59
|
+
selection = STDIN.gets.chomp
|
60
|
+
len = @appPages.length
|
61
|
+
erm = ("Invalid selection. Enter a number from 1 to " + len.to_s).warn
|
62
|
+
if not selection.numeric?
|
63
|
+
puts erm
|
64
|
+
return promptForApplication
|
65
|
+
end
|
66
|
+
selection = Integer(selection)
|
67
|
+
if not selection === 1..len
|
68
|
+
puts erm
|
69
|
+
return promptForApplication
|
70
|
+
end
|
71
|
+
return @appInfoList[selection - 1]
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|