Permalink
Browse files

Update build script to include ko.version (selectively merged from mt…

…scout6's "versioning" branch - thanks Matt!)
  • Loading branch information...
1 parent f3158dd commit c9abfe6008a4f1e6c2b2e971e96517fdd3ab5786 @SteveSanderson SteveSanderson committed Jan 10, 2012
View
1 .gitignore
@@ -1,4 +1,5 @@
*.suo
+*.swp
*.csproj.user
bin
obj
View
14 build/build-linux
@@ -3,10 +3,17 @@
OutDebugFile='output/knockout-latest.debug.js'
OutMinFile='output/knockout-latest.js'
+Version=`cat fragments/version.txt`
+VersionHeaderPath='fragments/version-header.js'
+VersionJsFile='../src/version.js'
+sed "s/##VERSION##/$Version/" <$VersionHeaderPath > $VersionHeaderPath.temp
+sed "s/Working-Debug/$Version/" <$VersionJsFile > $VersionJsFile.temp
+
# Combine the source files
SourceFiles=`grep js < fragments/source-references.js | # Find JS references
sed "s/[ \',]//g" | # Strip off JSON fluff (whitespace, commas, quotes)
sed -e 's/.*/..\/&/' | # Fix the paths by prefixing with ../
+ sed "s/version\.js/version\.js\.temp/" | # Use a temporary version with correct version number
tr '\n' ' '` # Combine into single line
cat fragments/amd-pre.js > $OutDebugFile.temp
cat $SourceFiles >> $OutDebugFile.temp
@@ -16,14 +23,17 @@ cat fragments/amd-post.js >> $OutDebugFile.temp
curl -d output_info=compiled_code -d output_format=text -d compilation_level=ADVANCED_OPTIMIZATIONS --data-urlencode js_code@$OutDebugFile.temp "http://closure-compiler.appspot.com/compile" > $OutMinFile.temp
# Finalise each file by prefixing with version header and surrounding in function closure
-cp fragments/version-header.js $OutDebugFile
+cp $VersionHeaderPath.temp $OutDebugFile
echo "(function(window,document,navigator,undefined){" >> $OutDebugFile
cat $OutDebugFile.temp >> $OutDebugFile
echo "})(window,document,navigator);" >> $OutDebugFile
rm $OutDebugFile.temp
-cp fragments/version-header.js $OutMinFile
+cp $VersionHeaderPath.temp $OutMinFile
echo "(function(window,document,navigator,undefined){" >> $OutMinFile
cat $OutMinFile.temp >> $OutMinFile
echo "})(window,document,navigator);" >> $OutMinFile
rm $OutMinFile.temp
+
+rm $VersionHeaderPath.temp
+rm $VersionJsFile.temp
View
17 build/build-windows.bat
@@ -4,8 +4,18 @@ set OutMinFile=output\knockout-latest.js
set AllFiles=
for /f "eol=] skip=1 delims=' " %%i in (fragments\source-references.js) do set Filename=%%i& call :Concatenate
+set /p Version= <fragments\version.txt
+set VersionHeaderPath=fragments\version-header.js
+set VersionJsFile=..\src\version.js
+tools\sed "s/##VERSION##/%Version%/" <%VersionHeaderPath% > %VersionHeaderPath%.temp
+tools\sed "s/Working-Debug/%Version%/" <%VersionJsFile% > %VersionJsFile%.temp
+
goto :Combine
:Concatenate
+ if /i "%Filename%"=="src/version.js" (
+ set Filename="src/version.js.temp"
+ )
+
if /i "%AllFiles%"=="" (
set AllFiles=..\%Filename:/=\%
) else (
@@ -22,14 +32,17 @@ type fragments\amd-post.js >> %OutDebugFile%.temp
tools\curl -d output_info=compiled_code -d output_format=text -d compilation_level=ADVANCED_OPTIMIZATIONS --data-urlencode js_code@%OutDebugFile%.temp "http://closure-compiler.appspot.com/compile" > %OutMinFile%.temp
@rem Finalise each file by prefixing with version header and surrounding in function closure
-copy /y fragments\version-header.js %OutDebugFile%
+copy /y fragments\version-header.js.temp %OutDebugFile%
echo (function(window,document,navigator,undefined){ >> %OutDebugFile%
type %OutDebugFile%.temp >> %OutDebugFile%
echo })(window,document,navigator); >> %OutDebugFile%
del %OutDebugFile%.temp
-copy /y fragments\version-header.js %OutMinFile%
+copy /y fragments\version-header.js.temp %OutMinFile%
echo (function(window,document,navigator,undefined){ >> %OutMinFile%
type %OutMinFile%.temp >> %OutMinFile%
echo })(window,document,navigator); >> %OutMinFile%
del %OutMinFile%.temp
+
+del %VersionHeaderPath%.temp
+del %VersionJsFile%.temp
View
9 build/fragments/source-references.js
@@ -1,11 +1,12 @@
knockoutDebugCallback([
'src/namespace.js',
'src/google-closure-compiler-utils.js',
+ 'src/version.js',
'src/utils.js',
'src/utils.domData.js',
'src/utils.domNodeDisposal.js',
'src/utils.domManipulation.js',
- 'src/memoization.js',
+ 'src/memoization.js',
'src/subscribables/extenders.js',
'src/subscribables/subscribable.js',
'src/subscribables/dependencyDetection.js',
@@ -22,9 +23,9 @@ knockoutDebugCallback([
'src/templating/templateEngine.js',
'src/templating/templateRewriting.js',
'src/templating/templateSources.js',
- 'src/templating/templating.js',
+ 'src/templating/templating.js',
'src/binding/editDetection/compareArrays.js',
'src/binding/editDetection/arrayToDomNodeChildren.js',
'src/templating/native/nativeTemplateEngine.js',
- 'src/templating/jquery.tmpl/jqueryTmplTemplateEngine.js'
-]);
+ 'src/templating/jquery.tmpl/jqueryTmplTemplateEngine.js'
+]);
View
2 build/fragments/version-header.js
@@ -1,4 +1,4 @@
-// Knockout JavaScript library v2.1.0pre
+// Knockout JavaScript library v##VERSION##
// (c) Steven Sanderson - http://knockoutjs.com/
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
View
1 build/fragments/version.txt
@@ -0,0 +1 @@
+2.1.0pre
View
3 src/version.js
@@ -0,0 +1,3 @@
+ko.version = "Working-Debug";
+
+ko.exportSymbol('version', ko.version);

0 comments on commit c9abfe6

Please sign in to comment.