From b77ef9759f8e450bbf507018b9100ef2d3d56668 Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Thu, 9 Aug 2018 10:40:00 -0700 Subject: [PATCH] A few final fixes (#298) --- lib/deploy/hosting/hashcache.js | 20 +++++++++++++------- lib/deploy/hosting/uploader.js | 4 ++-- package.json | 12 +++++++++--- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/deploy/hosting/hashcache.js b/lib/deploy/hosting/hashcache.js index abb8e4af..54c7805a 100644 --- a/lib/deploy/hosting/hashcache.js +++ b/lib/deploy/hosting/hashcache.js @@ -2,10 +2,16 @@ const fs = require("fs-extra"); const path = require("path"); const logger = require("../../logger"); -exports.load = function(cwd) { +function cachePath(cwd, name) { + return path.resolve(cwd, ".firebase/hosting." + name + ".cache"); +} + +exports.load = function(cwd, name) { try { const out = {}; - lines = fs.readFileSync(path.resolve(cwd, ".firebase/hostingcache"), { encoding: "utf8" }); + lines = fs.readFileSync(cachePath(cwd, name), { + encoding: "utf8", + }); lines.split("\n").forEach(function(line) { const d = line.split(","); if (d.length === 3) { @@ -15,21 +21,21 @@ exports.load = function(cwd) { return out; } catch (e) { if (e.code === "ENOENT") { - logger.debug("[hosting] hash cache not populated"); + logger.debug("[hosting] hash cache [" + name + "] not populated"); } else { - logger.debug("[hosting] hash cache load error:", e.message); + logger.debug("[hosting] hash cache [" + name + "] load error:", e.message); } return {}; } }; -exports.dump = function(cwd, data) { +exports.dump = function(cwd, name, data) { let st = ""; let count = 0; for (let path in data) { count++; st += path + "," + data[path].mtime + "," + data[path].hash + "\n"; } - fs.outputFileSync(path.resolve(cwd, ".firebase/hostingcache"), st, { encoding: "utf8" }); - logger.debug("[hosting] hash cache stored for", count, "files"); + fs.outputFileSync(cachePath(cwd, name), st, { encoding: "utf8" }); + logger.debug("[hosting] hash cache [" + name + "] stored for", count, "files"); }; diff --git a/lib/deploy/hosting/uploader.js b/lib/deploy/hosting/uploader.js index 98f8370a..2ae26bc3 100644 --- a/lib/deploy/hosting/uploader.js +++ b/lib/deploy/hosting/uploader.js @@ -32,7 +32,7 @@ class Uploader { this.version = options.version; this.cwd = options.cwd || process.cwd(); - this.cache = hashcache.load(this.cwd); + this.cache = hashcache.load(this.cwd, "0"); this.cacheNew = {}; this.gzipLevel = options.gzipLevel || 9; @@ -78,7 +78,7 @@ class Uploader { .wait() .then(self.queuePopulate.bind(self)) .then(function() { - hashcache.dump(self.cwd, self.cacheNew); + hashcache.dump(self.cwd, "0", self.cacheNew); logger.debug("[hosting][hash queue][FINAL]", self.hashQueue.stats()); self.populateQueue.close(); return self.populateQueue.wait(); diff --git a/package.json b/package.json index f3ea9ae7..7df2272a 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,13 @@ "bugs": { "url": "https://github.com/firebase/firebase-tools/issues" }, - "files": ["bin/**", "lib/**", "commands/**", "templates/**", "index.js"], + "files": [ + "bin/**", + "lib/**", + "commands/**", + "templates/**", + "index.js" + ], "homepage": "https://github.com/firebase/firebase-tools", "dependencies": { "JSONStream": "^1.2.1", @@ -68,9 +74,9 @@ "ora": "0.2.3", "portfinder": "^1.0.13", "progress": "^2.0.0", - "request": "^2.58.0", + "request": "^2.87.0", "semver": "^5.0.3", - "superstatic": "^5.0.2", + "superstatic": "^6.0.1", "tar": "^4.3.0", "tmp": "0.0.33", "universal-analytics": "^0.4.16",