-
Notifications
You must be signed in to change notification settings - Fork 2
/
release_starter.pl
75 lines (64 loc) · 2.04 KB
/
release_starter.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
use strict;
use IO::Compress::Zip qw(zip $ZipError);
use Time::localtime;
my $opt_h;
if($opt_h) {
print "Usage: perl $0 {source} {dest}\n";
print 'Copy Javascript files from {source} to {dest}.' . "\n";
print 'Also creates a zip archive and sets @version to current time';
exit 0;
}
my $src = @ARGV[0] || "framework/js";
my $dest = @ARGV[1] || "js_starter/javascript";
my $upgrade_dest = @ARGV[2] || "js_upgrade/javascript";
my @list = qw(bm-framework.js upgrade.html return_to_quote_button.js commerce_ids.js jquery_cookie.js);
my @from_template = qw(commerce.js commerce_line.js config.js homepage.js sitewide.js);
my @upgrade_files = qw(bm-framework.js upgrade.html return_to_quote_button.js);
my @all_files = @list;
# read in template
push(@all_files,@from_template);
my $template_file = "$src/blank_template.js";
print "$template_file\n";
open(TEMPLATE,"<$template_file") or die "No template: $!";
my @template_lines = ();
while(<TEMPLATE>) {
push(@template_lines,$_);
}
close(TEMPLATE);
my @date = localtime(time);
my $datestr = ctime();
print "$datestr\n";
foreach my $file (@all_files) {
open(OUT,">$dest/$file") or die $!;
if(grep /$file/,@from_template) {
foreach my $temp_line (@template_lines) {
$temp_line =~ s/(\@version).*/$1 $datestr/;
print OUT $temp_line;
}
} else {
open(IN,"<$src/$file") or die $!;
while(<IN>) {
s/(\@version).*/$1 $datestr/;
print OUT $_;
}
}
print "Copying: $file\n";
close(OUT);
}
foreach my $file (@upgrade_files) {
open(OUT,">$upgrade_dest/$file") or die $!;
open(IN,"<$src/$file") or die $!;
while(<IN>) {
s/(\@version).*/$1 $datestr/;
print OUT $_;
}
print "Copying: $file\n";
close(OUT);
}
chdir($dest);
zip "<*.{js,css,html}>" => "../GS.COE.JA.05 - JavaScript Starter Kit/javascript.zip"
or die "zip failed: $ZipError\n";
chdir("../..");
chdir($upgrade_dest);
zip "<*.{js,css,html}>" => "../GS.COE.JA.18 - JavaScript Framework 2.0 Upgrade Kit/javascript.zip"
or die "zip failed: $ZipError\n";