Skip to content

Commit

Permalink
merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenegriffin committed Aug 18, 2020
2 parents af3e2a4 + 54e7618 commit 3eee35a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
21 changes: 20 additions & 1 deletion src/Scripts/diag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
/* global StackTrace */
/* global aikey */
/* global appInsights */
/* global mhaVersion */
/* exported Diagnostics */

// diagnostics module

// Find the path of the current script so we can inject a script we know lives alongside it
var mhaVersionScriptPath = (function () {
var scripts = document.getElementsByTagName('script');
var script = scripts[scripts.length - 1];
var path = script.getAttribute('src', 2);
return path.split('diag')[0] + 'version.js'; // current script is diag*, so splitting here will put our path in [0]
}());

var Diagnostics = (function () {
"use strict";

Expand Down Expand Up @@ -44,7 +53,8 @@ var Diagnostics = (function () {
function ensureLastModified() {
try {
var client = new XMLHttpRequest();
client.open("HEAD", window.location.origin + "/src/Scripts/diag.js", true);
// version.js is generated on build and is the true signal of the last modified time
client.open("HEAD", mhaVersionScriptPath, true);
client.onreadystatechange = function () {
if (this.readyState == 2) {
lastUpdate = client.getResponseHeader("Last-Modified");
Expand Down Expand Up @@ -92,6 +102,10 @@ var Diagnostics = (function () {
appDiagnostics["Last Update"] = lastUpdate;
}

if (mhaVersion) {
appDiagnostics["mhaVersion"] = mhaVersion();
}

if (window.Office) {
delete appDiagnostics["Office"];
if (window.Office.context) {
Expand Down Expand Up @@ -215,6 +229,11 @@ var Diagnostics = (function () {
};
})();

// Inject our version variable
var version = document.createElement('script');
version.src = mhaVersionScriptPath;
document.getElementsByTagName('script')[0].parentNode.appendChild(version);

var script = document.createElement('script');
script.onload = function () {
// app Insights initialization
Expand Down
18 changes: 15 additions & 3 deletions tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ const version = getHash(commitID);
console.log("commitID: " + commitID);
console.log("version: " + version);

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

// 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 });
Expand Down Expand Up @@ -106,6 +103,8 @@ const targets = {
};

console.log("Deploying script");
const scriptsFolderSrc = path.join(__dirname, "..", "src", "transpiled");
const scriptsFolderDst = path.join(__dirname, "..", "Scripts", version);
for (const targetName of Object.keys(targets)) {
const fileSet = targets[targetName];
const mapName = targetName + ".map";
Expand Down Expand Up @@ -147,4 +146,17 @@ for (const targetName of Object.keys(targets)) {
fs.writeFileSync(path.join(scriptsFolderDst, targetName), result.code, "utf8");
fs.writeFileSync(path.join(scriptsFolderDst, mapName), result.map, "utf8");
}
}

if (version) {
const versionscript = path.join(scriptsFolderDst, "version.js");

console.log("Merging version (" + version + ") into js");
if (fs.existsSync(versionscript)) {
console.log(" Deleting " + versionscript);
fs.unlinkSync(versionscript);
}

console.log("Building " + versionscript);
fs.writeFileSync(versionscript, "/* exported mhaVersion */ window.mhaVersion = function () { return \"" + version + "\"; };", "utf8");
}

0 comments on commit 3eee35a

Please sign in to comment.