Class: BootstrapInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/adaptrex/bootstrapinstaller.rb

Overview

Utility class to create the Adaptrex/Ext bootstrap file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adaptrexConfig, appConfig, sdkType) ⇒ BootstrapInstaller

Returns a new instance of BootstrapInstaller.



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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/adaptrex/bootstrapinstaller.rb', line 23

def initialize(adaptrexConfig, appConfig, sdkType)
	self.success = false
	isExt = sdkType == "ext"
	if isExt then sdkVersion = appConfig.extVersion else sdkVersion = appConfig.touchVersion end
	adaptrexVersion = appConfig.adaptrexVersion
	puts "Generating the bootstrap file for " + adaptrexVersion + " and " + sdkVersion + "..."

	sdkPath = adaptrexConfig.weblibPath + "/" + sdkVersion
	adaptrexSdkPath = adaptrexConfig.weblibPath + "/" + adaptrexVersion + "/" + sdkType
	
	if isExt
		dependencyFile = "ExtDependencies.js"
	else
		dependencyFile = "TouchDependencies.js"

		#   Sencha Touch 2.1.0 has a bug that prevents compilation.  The file containing
		#   the bug is not required for the bootstrap file so we move it to a temp file
		#   during the compilation and restore it
		tmpDir = Dir.tmpdir
		FileUtils.mv(sdkPath + "/src/ux/auth2", tmpDir + "_senchatouch_auth2")
	end

	begin
		cmd = [
			"sencha -sdk " + sdkPath + " compile",
			" -classpath ",
				adaptrexSdkPath + "/src/",
			" exclude -all",
			" and include -r -f " + dependencyFile,
			" and exclude -t core",
			" and include -na Adaptrex.override",
			" and exclude -f " + dependencyFile,
			" and concat adaptrex/" + sdkType + "/bootstrap-debug.js",
			" and concat -compress adaptrex/" + sdkType + "/bootstrap.js"
		].join("")
		compileOutput = `#{cmd}`

		if compileOutput.include?"[ERR]"
			puts "There was an error creating your bootstrap file.".err
			puts "See the output from Sencha Cmd for more information".indent
			puts "-----\n" + cmd + "\n-----\n" + compileOutput + "-----\n\n"
		else
			puts((adaptrexVersion + " + " + sdkVersion + " Boostrap Installed").success)
		end

	ensure
		#   Move the broken auth2 ux back to the original Sencha Touch source folder
		if not isExt
			FileUtils.mv(tmpDir + "_senchatouch_auth2", sdkPath + "/src/ux/auth2")
		end
	end

	#	Success!
	self.success = true
end

Instance Attribute Details

#successObject

Returns the value of attribute success.



22
23
24
# File 'lib/adaptrex/bootstrapinstaller.rb', line 22

def success
  @success
end