#!/bin/bash ## used when a new version of NOPERCART is ready; by E Reimer 2007-08-03; ## NOTE: originally the "current" source WAS /er/website/nopercart.js; that's where I made changes; that's where they were tested; ## but NOW I need to run this script BEFORE testing (and then ready to test all the DEMOx variants, the NOCI variant only if I've replied Y to the copying prompt). ## ## PREREQ: jsminify -- from http://ereimer.net/programs/jsminify.htm ## PREREQ: dateERW -- from http://ereimer.net/programs/general-purpose-scripts.htm cd /pix/er-NOPERCART-ShoppingCartSoftware || exit 9 ##so can be invoked from anywhere (after moving to /etc/sbin) ##--(1)-- supply the VERSION-DATE for the SOURCE-version (the other standardization is no longer needed??): DATE=$(dateERW +%Y-%m-%d) ##--2008-02-11 now using dateERW for days that change at 8am--!!-- chgsed -p ' ##--standardize the SOURCE version with chgsed-prompting-- (any changes need review) s|Version 20..-..-..|Version '$DATE'|; ##revise the Version-$DATE line(s) s|(c) 2007,....|(c) 2007,'${DATE%%-*}'|; ##2008-02-19: also revise YEAR in Copyright-notice(s) /COND-/s|^ |//|; ##ensure COND- lines HAVE leading slash-slash (no longer needed?) /-DEMO1/s|^//| |; ##ensure COND-DEMO1 lines DONOT have leading slash-slash (no longer needed?) ' ./nopercart.js ##2007-12-04: was /er/website/nopercart.js DATE=$(sed -n 's|.*Eugene Reimer, Version \(20..-..-..\).*|\1|p' nopercart.js) ##2008-02-19: replying N to chgsed means old-DATE used in zipfile-name + minify-comment echo "------INSTALL-new-version-of-nopercart: VERSION=$DATE" ##DEBUG ##--(2)-- make the DEMO1, NOCI, DEMO2, DEMO3 variant-versions: mk-variant() { ##--usage: mk-variant TAG CARTID IMGTYPE DEST -- where TAG is DEMO1/NOCI/... mv -fv $4 ${4}~ ##make a tilde-backup cat ./nopercart.js |sed ' ##2007-12-04: was /er/website/nopercart.js /COND-/{/-'$1'/!d}; ##REMOVE COND-not$TAG lines (was: DEMO1 had yanked lines from other demos, as SOURCE has) /-'$1'/s|^//| |; ##ensure COND-$TAG lines DONOT have leading slash-slash s|[ \t]*COND-.*||; ##==2009-03-25: remove COND-.* part and trim==??== /^ *CartID/s|=[^/]*;|= "'$2'";|; ##2008-03-08 revise CartID option /^ *DisplayImgColumn/s|=[^/]*;|= "'$3'";|; ##2009-03-22 revise DisplayImgColumn option; 2009-04-01: no longer needed==!!== ' |expand|todosfile >$4 ##2008-03-10 |expand|todosfile not needed; webput now does on shop*htm + noper*js ##echo -n "View $4 diffs?";read;diffsed-ignoring-whitespace 's|//.*||' ${4}~ $4 ##DEBUG (sometimes like to review changes; sometimes not) } NOCI_NONMINIFIED=/tmp/nopercart-NOCI.js ##under /tmp is fine, since can now skip minifying when testing... ##cat...|grep -v "//.*DEMO ONLY" >$NOCI_NONMINIFIED ##produce NOCI-non-minified variant; OLD method used thru 2007-11-23 mk-variant NOCI "" "" $NOCI_NONMINIFIED ##produce NOCI-non-minified variant; NEW method used from 2007-11-27 mk-variant DEMO1 "" "" /er/website/NOPERCART-DEMO1/nopercart.js ##produce DEMO1 variant (new 2007-12-04) 2008-11-12:mkdir; 2009-04-01:jpg(briefly) mk-variant DEMO2 2 jpg /er/website/NOPERCART-DEMO2/nopercart.js ##produce DEMO2 variant (new 2007-11-27) mk-variant DEMO3 3 "" /er/website/NOPERCART-DEMO3/nopercart.js ##produce DEMO3 variant (new 2007-12-04) mk-variant DEMO4 4 "" /er/website/NOPERCART-DEMO4/nopercart.js ##produce DEMO4 variant (new 2008-02-27) mk-variant DEMO1 C "" /er/website/NOPERCART-DEMOC/nopercart.js ##produce DEMOC(COUPON) (new 2008-03-06) copy DEMO1 with CartID+DisplayImgColumn mods mk-variant DEMO1 R "" /er/website/NOPERCART-DEMORB/nopercart.js ##produce DEMORB copy (new 2008-10-23) copy DEMO1 with CartID+DisplayImgColumn mods mk-variant DEMONY N jpg /er/website/NOPERCART-DEMONY/nopercart.js ##produce DEMONY variant (new 2009-03-25) cp -fuv /er/website/cgi-bin/shoppingcheckout-op.pl /er/website/NOPERCART-DEMORB/shoppingcheckout-op.pl.txt ##DEMORB Perl-script (new 2008-10-24); OptimalPay for RogerBritt cp -fuv /er/website/cgi-bin/shoppingcheckout-an.pl /er/website/NOPERCART-DEMOC/shoppingcheckout-an.pl.txt ##DEMOC Perl-script (new 2009-04-18); Authorize.net for Theresa ##--(3)-- copy (with or without minification) to nativeorchid site: echo -n "Copy to NATIVEORCHID.ORG & DEBWENDON.ORG websites (Y/N) ??"; read; if [[ $REPLY != [nN]* ]]; then ##--a chance to say NO echo -n "With Minification (Y/N) ??"; read; if [[ $REPLY == [nN]* ]]; then ##2008-02-02: non-minified for debugging cat $NOCI_NONMINIFIED >/noci/website/nopercart.js else cat $NOCI_NONMINIFIED | ##2007-08-23 minify; 2008-02-19 DATE+YEAR jsminify "nopERcart Version $DATE -- readable copy at http://ereimer.net/nopercart.htm" "(c) 2007,${DATE%%-*} NopDesign.com, Stefko, Eugene Reimer." | cat >/noci/website/nopercart.js fi cat /noci/website/nopercart.js >/debwendon/website/nopercart.js ##2008-02-02: also to debwendon ls -l /noci/website/nopercart.js /debwendon/website/nopercart.js fi ##--(4)-- produce a ZIPFILE containing the complete STABLE version (nopercart.js + shopping*htm + shop*{pl,jpg,gif} + noper-language*js); ##-- files are TAB-expanded, converted to MS-DOS-style newlines, then they're zipped into /er/website/nopercart.zip echo -n "Create new ZIPFILE (Y/N) ??"; read; if [[ $REPLY == [nN]* ]]; then exit; fi; ##a chance to say NO rm -f -R /tmp/nopercart-to-be-zipped; mkdir /tmp/nopercart-to-be-zipped ##2010-10-27: remove-->rm -f -R cp -dpRx /er/website/NOPERCART-DEMO1/{nopercart.js,shop*[^~]} /tmp/nopercart-to-be-zipped ##copy shop*[^~] files; 20081112:were under root cp -dpRx /er/website/cgi-bin/shop*[^~] /tmp/nopercart-to-be-zipped ##copy shop*[^~] files from cgi-bin cp -dpRx /er/website/nopercart.htm /tmp/nopercart-to-be-zipped/README.htm ##copy the doc as README.htm cp -dpRx ./noper-language*js /tmp/nopercart-to-be-zipped chg -n --cmd "expand|todosfile" /tmp/nopercart-to-be-zipped/*{js,htm,pl} ##text-files to ms-style; 20081112:pl->txt?? rm -f /er/website/nopercart.zip zip -j /er/website/nopercart.zip /tmp/nopercart-to-be-zipped/*[^~] ##zip; *{js,htm,pl,jpg,gif,png}-->*[^~] cp -pfv /er/website/nopercart.zip ./nopercart-$DATE.zip ##2007-08-11: keep a DATESTAMPED zipfile ##remove /tmp/tmp/*; cd /tmp/tmp; cp /er/website/nopercart.zip .; echo "under /tmp/tmp"; unzip nopercart.zip; echo "unzipping done" ##debug zipfile exit 2007-11-25: revised the handling of DEMO-differences, to permit several demo-versions (was simply omitting "DEMO ONLY" lines to make the NOCI-version); also, to reduce confusion, now using adjacent lines for different settings of same option (except ShipTable examples Example-1, Example-2...); notes: -- the version under /er/website, aka DEMO1, was the official version (can use COND-TEMP tags for experiments to be removed in the STABLE DEMO1-version); -- the zipfile will contain exactly the DEMO1 version (previously did too -- altho I sometimes mistakenly thought it had non-minified-NOCI ie: w/o "DEMO ONLY"); -- a 2nd DEMO2 version under /er/website/DEMO2 will use: WEIGHT-only in pounds, US-UPS shipping-table, Google-Checkout, USD currency; making DEMO1 version: lines with COND- but without -DEMO1 are YANKED; COND-DEMO1 lines are unyanked (leading // removed); <--DEMO1 now gets REMOVAL also... making DEMO2 version: lines with COND- but without -DEMO2 are REMOVED; COND-DEMO2 lines are unyanked (leading // removed); making NOCI version: lines with COND- but without -NOCI are REMOVED; COND-NOCI lines are unyanked (leading // removed); Style: COND-lines have either TWO LEADING SPACES or 2 leading slashes (fairly easily changed if desired) Style: multiple COND-tags can be abbreviated, eg: COND-DEMO1-NOCI 2007-12-04: now keep the SOURCE-version in /pix/er-NOPERCART-ShoppingCartSoftware ==> need to run this before any testing--!!-- now publish only DUPLICATION-FREE versions; ie: now DEMO1 also gets REMOVAL, rather than YANKING; --temporarily left the Dutch-TNT shipping-table (DEMO3) invisible to all readers; fixed by putting up link to that 3rd demo; ==consider zipfile becoming an "All-Examples-Included" version--??-- (need separate-files mods) 2008-11-12: demo1 now in its own subdir, ie: /er/website/demo1-files --> /er/website/NOPERCART-DEMO1/demo1-files 2010-10-27: remove-->rm -f -R; copy-->cp -dpRx; (tidying up prereqs when publishing);