Pārlūkot izejas kodu

Automates bumping js file versions. Experimental, please revert Makefile

if it causes problems.
factor2
Boris Grozev 10 gadus atpakaļ
vecāks
revīzija
e5fa02a1d4
3 mainītis faili ar 28 papildinājumiem un 2 dzēšanām
  1. 2
    1
      .gitignore
  2. 1
    1
      Makefile
  3. 25
    0
      bump-js-versions.sh

+ 2
- 1
.gitignore Parādīt failu

@@ -1,4 +1,5 @@
1 1
 node_modules
2 2
 *.swp
3 3
 .idea/
4
-*.iml
4
+*.iml
5
+.*.tmp

+ 1
- 1
Makefile Parādīt failu

@@ -21,4 +21,4 @@ clean:
21 21
 	@rm -f $(OUTPUT_DIR)/*.bundle.js
22 22
 
23 23
 deploy:
24
-	@mkdir -p $(DEPLOY_DIR) && cp $(OUTPUT_DIR)/*.bundle.js $(DEPLOY_DIR)
24
+	@mkdir -p $(DEPLOY_DIR) && cp $(OUTPUT_DIR)/*.bundle.js $(DEPLOY_DIR) && ./bump-js-versions.sh

+ 25
- 0
bump-js-versions.sh Parādīt failu

@@ -0,0 +1,25 @@
1
+#!/bin/sh
2
+
3
+# This script finds all js files included from index.html which have been
4
+# modified and bumps their version (the value of the "v" parameter used
5
+# in index.html)
6
+
7
+# contents of index.html at HEAD (excluding not-committed changes)
8
+index=`git show HEAD:index.html`
9
+
10
+# js files included from index.html. The sort needed for comm
11
+jsfiles=.bump-js-versions-jsfiles.tmp
12
+echo "$index" | grep '<script src=".*"' -o | sed -e 's/<script src="//' | sed -e 's/\?.*//' |  tr -d \" | sort > $jsfiles
13
+
14
+# modified files since the last commit
15
+gitmodified=.bump-js-versions-gitmodified.tmp
16
+git ls-files -m | sort > $gitmodified
17
+
18
+for file in `comm -12 $jsfiles $gitmodified` ;do
19
+    old_version=`echo "$index" | grep "<script src=\"${file}?v=[0-9]*" -o | sed -e 's/.*v=//'| tr -d \"`
20
+    new_version=$((1+$old_version))
21
+    echo Bumping version of $file from $old_version to $new_version
22
+    sed -i.tmp -e "s%script src=\"${file}\?v=.*\"%script src=\"$file?v=$new_version\"%" index.html
23
+done
24
+
25
+rm -f $jsfiles $gitmodified index.html.tmp

Notiek ielāde…
Atcelt
Saglabāt