From 4bc0c2b0e77715d5194fc407bc40ada22898cc90 Mon Sep 17 00:00:00 2001
From: Robert Brignull <robertbrignull@gmail.com>
Date: Mon, 24 Aug 2020 15:18:01 +0100
Subject: [PATCH 1/2] clean the lib dir before building

---
 .github/workflows/pr-checks.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml
index fb30c74a7..ce90c1e0e 100644
--- a/.github/workflows/pr-checks.yml
+++ b/.github/workflows/pr-checks.yml
@@ -24,6 +24,8 @@ jobs:
           >&2 echo "Failed: Repo should be clean before testing!"
           exit 1
         fi
+        # Wipe the lib directory incase there are extra unnecessary files in there
+        rm -rf lib
         # Generate the JavaScript files
         npm run-script build
         # Check that repo is still clean

From 9c015b7e830773c7298b6bf85e0b64bb56eb0063 Mon Sep 17 00:00:00 2001
From: Robert Brignull <robertbrignull@gmail.com>
Date: Mon, 24 Aug 2020 15:18:26 +0100
Subject: [PATCH 2/2] cleanup lib

---
 lib/finalize-db.test.js     |  2 -
 lib/finalize-db.test.js.map |  1 -
 lib/setup-tools.js          | 76 -------------------------------------
 lib/setup-tools.js.map      |  1 -
 lib/setup-tools.test.js     | 60 -----------------------------
 lib/setup-tools.test.js.map |  1 -
 lib/test-utils.js           | 22 -----------
 lib/test-utils.js.map       |  1 -
 8 files changed, 164 deletions(-)
 delete mode 100644 lib/finalize-db.test.js
 delete mode 100644 lib/finalize-db.test.js.map
 delete mode 100644 lib/setup-tools.js
 delete mode 100644 lib/setup-tools.js.map
 delete mode 100644 lib/setup-tools.test.js
 delete mode 100644 lib/setup-tools.test.js.map
 delete mode 100644 lib/test-utils.js
 delete mode 100644 lib/test-utils.js.map

diff --git a/lib/finalize-db.test.js b/lib/finalize-db.test.js
deleted file mode 100644
index 06a976fdc..000000000
--- a/lib/finalize-db.test.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=finalize-db.test.js.map
\ No newline at end of file
diff --git a/lib/finalize-db.test.js.map b/lib/finalize-db.test.js.map
deleted file mode 100644
index 2114e3726..000000000
--- a/lib/finalize-db.test.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"finalize-db.test.js","sourceRoot":"","sources":["../src/finalize-db.test.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/lib/setup-tools.js b/lib/setup-tools.js
deleted file mode 100644
index ee11fbf2c..000000000
--- a/lib/setup-tools.js
+++ /dev/null
@@ -1,76 +0,0 @@
-"use strict";
-var __importStar = (this && this.__importStar) || function (mod) {
-    if (mod && mod.__esModule) return mod;
-    var result = {};
-    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
-    result["default"] = mod;
-    return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const core = __importStar(require("@actions/core"));
-const toolcache = __importStar(require("@actions/tool-cache"));
-const path = __importStar(require("path"));
-const semver = __importStar(require("semver"));
-class CodeQLSetup {
-    constructor(codeqlDist) {
-        this.dist = codeqlDist;
-        this.tools = path.join(this.dist, 'tools');
-        this.cmd = path.join(codeqlDist, 'codeql');
-        // TODO check process.arch ?
-        if (process.platform === 'win32') {
-            this.platform = 'win64';
-            if (this.cmd.endsWith('codeql')) {
-                this.cmd += ".exe";
-            }
-        }
-        else if (process.platform === 'linux') {
-            this.platform = 'linux64';
-        }
-        else if (process.platform === 'darwin') {
-            this.platform = 'osx64';
-        }
-        else {
-            throw new Error("Unsupported plaform: " + process.platform);
-        }
-    }
-}
-exports.CodeQLSetup = CodeQLSetup;
-async function setupCodeQL() {
-    try {
-        const codeqlURL = core.getInput('tools', { required: true });
-        const codeqlURLVersion = getCodeQLURLVersion(codeqlURL);
-        let codeqlFolder = toolcache.find('CodeQL', codeqlURLVersion);
-        if (codeqlFolder) {
-            core.debug(`CodeQL found in cache ${codeqlFolder}`);
-        }
-        else {
-            const codeqlPath = await toolcache.downloadTool(codeqlURL);
-            const codeqlExtracted = await toolcache.extractTar(codeqlPath);
-            codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', codeqlURLVersion);
-        }
-        return new CodeQLSetup(path.join(codeqlFolder, 'codeql'));
-    }
-    catch (e) {
-        core.error(e);
-        throw new Error("Unable to download and extract CodeQL CLI");
-    }
-}
-exports.setupCodeQL = setupCodeQL;
-function getCodeQLURLVersion(url) {
-    const match = url.match(/\/codeql-bundle-(.*)\//);
-    if (match === null || match.length < 2) {
-        throw new Error(`Malformed tools url: ${url}. Version could not be inferred`);
-    }
-    let version = match[1];
-    if (!semver.valid(version)) {
-        core.debug(`Bundle version ${version} is not in SemVer format. Will treat it as pre-release 0.0.0-${version}.`);
-        version = '0.0.0-' + version;
-    }
-    const s = semver.clean(version);
-    if (!s) {
-        throw new Error(`Malformed tools url ${url}. Version should be in SemVer format but have ${version} instead`);
-    }
-    return s;
-}
-exports.getCodeQLURLVersion = getCodeQLURLVersion;
-//# sourceMappingURL=setup-tools.js.map
\ No newline at end of file
diff --git a/lib/setup-tools.js.map b/lib/setup-tools.js.map
deleted file mode 100644
index 70c6756eb..000000000
--- a/lib/setup-tools.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"setup-tools.js","sourceRoot":"","sources":["../src/setup-tools.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AACtC,+DAAiD;AACjD,2CAA6B;AAC7B,+CAAiC;AAEjC,MAAa,WAAW;IAMtB,YAAY,UAAkB;QAC5B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3C,4BAA4B;QAC5B,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAChC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB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AC;QACd,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;AACH,CAAC;AAnBD,kCAmBC;AAED,SAAgB,mBAAmB,CAAC,GAAW;IAE7C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAClD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,iCAAiC,CAAC,CAAC;KAC/E;IAED,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;QAC1B,IAAI,CAAC,KAAK,CAAC,kBAAkB,OAAO,gEAAgE,OAAO,GAAG,CAAC,CAAC;QAChH,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;KAC9B;IAED,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,iDAAiD,OAAO,UAAU,CAAC,CAAC;KAC/G;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AApBD,kDAoBC"}
\ No newline at end of file
diff --git a/lib/setup-tools.test.js b/lib/setup-tools.test.js
deleted file mode 100644
index a179641b1..000000000
--- a/lib/setup-tools.test.js
+++ /dev/null
@@ -1,60 +0,0 @@
-"use strict";
-var __importStar = (this && this.__importStar) || function (mod) {
-    if (mod && mod.__esModule) return mod;
-    var result = {};
-    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
-    result["default"] = mod;
-    return result;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
-    return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const toolcache = __importStar(require("@actions/tool-cache"));
-const ava_1 = __importDefault(require("ava"));
-const nock_1 = __importDefault(require("nock"));
-const path = __importStar(require("path"));
-const setupTools = __importStar(require("./setup-tools"));
-const testing_utils_1 = require("./testing-utils");
-const util = __importStar(require("./util"));
-testing_utils_1.silenceDebugOutput(ava_1.default);
-ava_1.default('download codeql bundle cache', async (t) => {
-    await util.withTmpDir(async (tmpDir) => {
-        process.env['GITHUB_WORKSPACE'] = tmpDir;
-        process.env['RUNNER_TEMP'] = path.join(tmpDir, 'temp');
-        process.env['RUNNER_TOOL_CACHE'] = path.join(tmpDir, 'cache');
-        const versions = ['20200601', '20200610'];
-        for (let i = 0; i < versions.length; i++) {
-            const version = versions[i];
-            nock_1.default('https://example.com')
-                .get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
-                .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
-            process.env['INPUT_TOOLS'] = `https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`;
-            await setupTools.setupCodeQL();
-            t.assert(toolcache.find('CodeQL', `0.0.0-${version}`));
-        }
-        const cachedVersions = toolcache.findAllVersions('CodeQL');
-        t.is(cachedVersions.length, 2);
-    });
-});
-ava_1.default('parse codeql bundle url version', t => {
-    const tests = {
-        '20200601': '0.0.0-20200601',
-        '20200601.0': '0.0.0-20200601.0',
-        '20200601.0.0': '20200601.0.0',
-        '1.2.3': '1.2.3',
-        '1.2.3-alpha': '1.2.3-alpha',
-        '1.2.3-beta.1': '1.2.3-beta.1',
-    };
-    for (const [version, expectedVersion] of Object.entries(tests)) {
-        const url = `https://github.com/.../codeql-bundle-${version}/...`;
-        try {
-            const parsedVersion = setupTools.getCodeQLURLVersion(url);
-            t.deepEqual(parsedVersion, expectedVersion);
-        }
-        catch (e) {
-            t.fail(e.message);
-        }
-    }
-});
-//# sourceMappingURL=setup-tools.test.js.map
\ No newline at end of file
diff --git a/lib/setup-tools.test.js.map b/lib/setup-tools.test.js.map
deleted file mode 100644
index cb9c70977..000000000
--- a/lib/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IAAI,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;SACxD;QAED,MAAM,cAAc,GAAG,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAE3D,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE;IAE1C,MAAM,KAAK,GAAG;QACZ,UAAU,EAAE,gBAAgB;QAC5B,YAAY,EAAE,kBAAkB;QAChC,cAAc,EAAE,cAAc;QAC9B,OAAO,EAAE,OAAO;QAChB,aAAa,EAAE,aAAa;QAC5B,cAAc,EAAE,cAAc;KAC/B,CAAC;IAEF,KAAK,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC9D,MAAM,GAAG,GAAG,wCAAwC,OAAO,MAAM,CAAC;QAElE,IAAI;YACF,MAAM,aAAa,GAAG,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YAC1D,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;SAC7C;QAAC,OAAO,CAAC,EAAE;YACV,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACnB;KACF;AACH,CAAC,CAAC,CAAC"}
\ No newline at end of file
diff --git a/lib/test-utils.js b/lib/test-utils.js
deleted file mode 100644
index ae445ea53..000000000
--- a/lib/test-utils.js
+++ /dev/null
@@ -1,22 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-function silenceDebugOutput(test) {
-    const typedTest = test;
-    typedTest.beforeEach(t => {
-        const processStdoutWrite = process.stdout.write.bind(process.stdout);
-        t.context.write = processStdoutWrite;
-        process.stdout.write = (str, encoding, cb) => {
-            // Core library will directly call process.stdout.write for commands
-            // We don't want :: commands to be executed by the runner during tests
-            if (!str.match(/^::/)) {
-                processStdoutWrite(str, encoding, cb);
-            }
-            return true;
-        };
-    });
-    typedTest.afterEach(t => {
-        process.stdout.write = t.context.write;
-    });
-}
-exports.silenceDebugOutput = silenceDebugOutput;
-//# sourceMappingURL=test-utils.js.map
\ No newline at end of file
diff --git a/lib/test-utils.js.map b/lib/test-utils.js.map
deleted file mode 100644
index e98f441b5..000000000
--- a/lib/test-utils.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":";;AAEA,SAAgB,kBAAkB,CAAC,IAAwB;IACzD,MAAM,SAAS,GAAG,IAAmC,CAAC;IAEtD,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrE,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,kBAAkB,CAAC;QACrC,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,GAAQ,EAAE,QAAc,EAAE,EAA0B,EAAE,EAAE;YAC5E,oEAAoE;YACpE,sEAAsE;YACtE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACnB,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;aACzC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;QACpB,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,gDAmBC"}
\ No newline at end of file