Skip to content

Commit

Permalink
Revert "Version"
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenegriffin authored Dec 20, 2019
1 parent 5707d5f commit f8bedb7
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 49 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
/.vs
/node_modules
/Scripts
/Pages
/Content
/Pages
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Pages/classicDesktopFrame.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

<link rel="stylesheet" type="text/css" href="/Content/%version%/Office.css" />
<link rel="stylesheet" type="text/css" href="/Content/%version%/App.css" />
<link rel="stylesheet" type="text/css" href="/Content/Office.css" />
<link rel="stylesheet" type="text/css" href="/Content/App.css" />

<script crossorigin="anonymous" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
<script>
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/mha.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>Message Header Analyzer</title>

<link rel="stylesheet" type="text/css" href="/Content/%version%/Office.css" />
<link rel="stylesheet" type="text/css" href="/Content/%version%/App.css" />
<link rel="stylesheet" type="text/css" href="/Content/Office.css" />
<link rel="stylesheet" type="text/css" href="/Content/App.css" />

<script crossorigin="anonymous" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/newDesktopFrame.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.5.0/css/fabric.min.css">
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.5.0/css/fabric.components.min.css">
<link rel="stylesheet" href="/Content/%version%/DesktopPane.css">
<link rel="stylesheet" href="/Content/DesktopPane.css">

<script crossorigin="anonymous" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/newMobilePaneIosFrame.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/framework7/1.6.5/css/framework7.ios.colors.min.css" />
<link rel="stylesheet" href="/node_modules/framework7-icons/css/framework7-icons.css">

<link rel="stylesheet" href="/Content/%version%/MobilePane-ios.css" />
<link rel="stylesheet" href="/Content/MobilePane-ios.css" />

<script crossorigin="anonymous" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/parentframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.5.0/css/fabric.min.css">
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.5.0/css/fabric.components.min.css">
<link rel="stylesheet" type="text/css" href="/Content/%version%/uiToggle.css" />
<link rel="stylesheet" type="text/css" href="/Content/uiToggle.css" />

<script crossorigin="anonymous" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/privacy.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta content="IE=Edge" http-equiv="X-UA-Compatible" />
<title>Message Header Analyzer Privacy Policy</title>

<link href="/Content/%version%/Office.css" rel="stylesheet" type="text/css" />
<link href="/Content/Office.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Message Header Analyzer</h1>
Expand Down
61 changes: 24 additions & 37 deletions tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,34 @@ if (key) {
console.log("No key found - skipping aikey.js generation");
}

// Simple stupid hash to reduce commit ID to something short
const getHash = function (str) {
var hash = 42;
if (str.length) { for (var i = 0; i < str.length; i++) { hash = Math.abs((hash << 5) - hash + str.charCodeAt(i)); } }
return hash.toString(16);
};

var commitID = process.env.SCM_COMMIT_ID;
if (!commitID) commitID = "test";
const version = getHash(commitID);
console.log("commitID: " + commitID);
console.log("version: " + version);
// TODO: come up with a proper version here
const version = "test";

const scriptsFolderSrc = path.join(__dirname, "..", "src", "Scripts");
const scriptsFolderDst = path.join(__dirname, "..", "Scripts", version);
const pagesFolderSrc = path.join(__dirname, "..", "src", "Pages");
const pagesFolderDst = path.join(__dirname, "..", "Pages");

// Copy files from src to dst, replacing %version% on the way if munge is true
const deploy = function (src, dst, munge) {
if (!fs.existsSync(dst)) fs.mkdirSync(dst, { recursive: true });
// Copy pages from pagesFolderSrc to pagesFolderDst, replacing %version% on the way
if (!fs.existsSync(pagesFolderDst)) {
fs.mkdirSync(pagesFolderDst);
}

console.log("Copying from " + src + " to " + dst);
const srcFiles = fs.readdirSync(src);
for (const srcFile of srcFiles) {
var srcPath = path.join(src, srcFile);
var dstPath = path.join(dst, srcFile);
console.log("Updating pages");
console.log("Copying from " + pagesFolderSrc);
console.log("Copying to " + pagesFolderDst);
const pageFiles = fs.readdirSync(pagesFolderSrc);
for (const pageFile of pageFiles) {
console.log("Considering " + pageFile);
var srcPath = path.join(pagesFolderSrc, pageFile);
var dstPath = path.join(pagesFolderDst, pageFile);

console.log(" Copying from " + srcPath + " to " + dstPath);
console.log("Copying from " + srcPath);
console.log("Copying to " + dstPath);

var fileBytes = fs.readFileSync(srcPath, "utf8");
if (munge) fileBytes = fileBytes.replace(/%version%/g, version);
fs.writeFileSync(dstPath, fileBytes, "utf8");
}
};

console.log("Deploying pages");
deploy(path.join(__dirname, "..", "src", "Pages"), path.join(__dirname, "..", "Pages"), true);

console.log("Deploying css");
deploy(path.join(__dirname, "..", "src", "Content"), path.join(__dirname, "..", "Content", version), false);
var fileBytes = fs.readFileSync(srcPath, "utf8");
fs.writeFileSync(dstPath, fileBytes.replace(/%version%/g, version), "utf8");
}

var options = {
compress: {},
Expand Down Expand Up @@ -102,24 +91,22 @@ const targets = {
"unittests/ut-XML.min.js": ["unittests/ut-XML.js"]
};

console.log("Deploying script");
for (const targetName of Object.keys(targets)) {
const fileSet = targets[targetName];
const mapName = targetName + ".map";
console.log(" Building " + targetName + " and " + mapName);
console.log("Building " + targetName + " and " + mapName);

// Create the list of files and read their sources
const files = {};
for (const file of fileSet) {
const fileName = path.basename(file);
var fileName = path.basename(file);
files[fileName] = fs.readFileSync(path.join(scriptsFolderSrc, file), "utf8");
// Copy original over verbatim to the target directory
const dstPathOrig = path.join(scriptsFolderDst, file);
const dstDir = path.dirname(dstPathOrig);
if (!fs.existsSync(dstDir)) {
fs.mkdirSync(dstDir);
}

fs.writeFileSync(dstPathOrig, files[fileName], "utf8");
if (debug) {
// Copy min over to the target directory
Expand All @@ -131,7 +118,7 @@ for (const targetName of Object.keys(targets)) {
if (!debug) {
options.sourceMap.filename = path.basename(targetName);
options.sourceMap.url = path.basename(mapName);
const result = UglifyJS.minify(files, options);
var result = UglifyJS.minify(files, options);
fs.writeFileSync(path.join(scriptsFolderDst, targetName), result.code, "utf8");
fs.writeFileSync(path.join(scriptsFolderDst, mapName), result.map, "utf8");
}
Expand Down
4 changes: 2 additions & 2 deletions tasks/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const rmdir = function (filepath) {
}
};

rmdir(path.join(__dirname, "..", "Pages"));
rmdir(path.join(__dirname, "..", "Content"));
const pagesFolder = path.join(__dirname, "..", "Pages");
rmdir(pagesFolder);

const scriptsFolder = path.join(__dirname, "..", "Scripts");
fs.readdirSync(scriptsFolder).forEach((file, index) => {
Expand Down

0 comments on commit f8bedb7

Please sign in to comment.