diff --git a/.gitignore b/.gitignore index 05318d6..9fc0b3a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,9 +21,9 @@ lib dist-spec # Downloaded spec -spec/fixtures/node-v10.20.1.tar.gz +spec/fixtures/node-*.tar.gz spec/fixtures/node.lib spec/fixtures/node_x64.lib -spec/fixtures/node-v10.20.1-headers.tar.gz +spec/fixtures/node-*-headers.tar.gz spec/fixtures/repo.git spec/fixtures/r.tmbundle diff --git a/script/get-fixtures.js b/script/get-fixtures.js index d28ebba..9b3c28c 100644 --- a/script/get-fixtures.js +++ b/script/get-fixtures.js @@ -1,32 +1,42 @@ const { DownloaderHelper } = require("node-downloader-helper") const gitly = require("gitly").default const { join, dirname } = require("path") +const { readFileSync } = require("fs") const downloadFolder = join(dirname(__dirname), "spec", "fixtures") const downloadOptions = { override: { skip: true }, } + +const atomElectronVersion = readFileSync(`${dirname(__dirname)}/.npmrc`, "utf8").match(/target=(.*)\n/)[1] + const links = [ - "https://nodejs.org/dist/v10.20.1/node-v10.20.1.tar.gz", - "https://nodejs.org/dist/v10.20.1/win-x86/node.lib", - "https://nodejs.org/dist/v10.20.1/node-v10.20.1-headers.tar.gz", + `https://nodejs.org/dist/${atomElectronVersion}/node-${atomElectronVersion}.tar.gz`, + `https://nodejs.org/dist/${atomElectronVersion}/win-x86/node.lib`, + `https://nodejs.org/dist/${atomElectronVersion}/node-${atomElectronVersion}-headers.tar.gz`, "https://github.com/atom-community/apm/raw/master/spec/fixtures/repo.git", ] -const linkMaps = [["https://nodejs.org/dist/v10.20.1/win-x64/node.lib", "node_x64.lib"]] +const linkMaps = [[`https://nodejs.org/dist/${atomElectronVersion}/win-x64/node.lib`, `node_x64.lib`]] const repos = ["https://github.com/textmate/r.tmbundle"] async function main() { + console.log(`Downloading fixtures for node ${atomElectronVersion}`) await Promise.all([ - ...links.map((link) => new DownloaderHelper(link, downloadFolder, downloadOptions).start()), + ...links.map((link) => { + console.log(`Downloading ${link}`) + return new DownloaderHelper(link, downloadFolder, downloadOptions).start() + }), ...linkMaps.map((linkMap) => { const link = linkMap[0] + console.log(`Downloading ${link}`) downloadOptions.fileName = linkMap[1] return new DownloaderHelper(link, downloadFolder, downloadOptions).start() }), ...repos.map((repo) => { + console.log(`Downloading ${repo}`) const repoParts = repo.split("/") return gitly(repo, join(downloadFolder, repoParts[repoParts.length - 1]), { throw: true }) }), diff --git a/spec/ci-spec.js b/spec/ci-spec.js index 719a402..a5c18c9 100644 --- a/spec/ci-spec.js +++ b/spec/ci-spec.js @@ -13,6 +13,8 @@ const wrench = require("wrench") const CSON = require("season") import * as apm from "../lib/apm-cli" +const atomElectronVersion = fs.readFileSync(`${path.dirname(__dirname)}/.npmrc`, "utf8").match(/target=(.*)\n/)[1] + describe("apm ci", function () { let [atomHome, resourcePath, server] = Array.from([]) @@ -29,19 +31,19 @@ describe("apm ci", function () { delete process.env.npm_config_cache const app = express() - app.get("/node/v10.20.1/node-v10.20.1.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, "fixtures", `node-${atomElectronVersion}.tar.gz`)) ) - app.get("/node/v10.20.1/node-v10.20.1-headers.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1-headers.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}-headers.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, "fixtures", `node-${atomElectronVersion}-headers.tar.gz`)) ) - app.get("/node/v10.20.1/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node.lib")) + app.get(`/node/${atomElectronVersion}/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, "fixtures", `node.lib`)) ) - app.get("/node/v10.20.1/x64/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node_x64.lib")) + app.get(`/node/${atomElectronVersion}/x64/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, "fixtures", `node_x64.lib`)) ) - app.get("/node/v10.20.1/SHASUMS256.txt", (request, response) => + app.get(`/node/${atomElectronVersion}/SHASUMS256.txt`, (request, response) => response.sendFile(path.join(__dirname, "fixtures", "SHASUMS256.txt")) ) app.get("/test-module-with-dependencies", (request, response) => @@ -69,7 +71,7 @@ describe("apm ci", function () { server.listen(3000, "127.0.0.1", function () { process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" process.env.ATOM_PACKAGES_URL = "http://localhost:3000/packages" - process.env.ATOM_ELECTRON_VERSION = "v10.20.1" + process.env.ATOM_ELECTRON_VERSION = atomElectronVersion process.env.npm_config_registry = "http://localhost:3000/" return (live = true) }) diff --git a/spec/clean-spec.js b/spec/clean-spec.js index b2db04b..8c646cc 100644 --- a/spec/clean-spec.js +++ b/spec/clean-spec.js @@ -12,6 +12,8 @@ const http = require("http") const wrench = require("wrench") import * as apm from "../lib/apm-cli" +const atomElectronVersion = fs.readFileSync(`${path.dirname(__dirname)}/.npmrc`, "utf8").match(/target=(.*)\n/)[1] + describe("apm clean", function () { let [moduleDirectory, server] = Array.from([]) @@ -21,19 +23,19 @@ describe("apm clean", function () { const app = express() - app.get("/node/v10.20.1/node-v10.20.1.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node-${atomElectronVersion}.tar.gz`)) ) - app.get("/node/v10.20.1/node-v10.20.1-headers.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1-headers.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}-headers.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node-${atomElectronVersion}-headers.tar.gz`)) ) - app.get("/node/v10.20.1/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node.lib")) + app.get(`/node/${atomElectronVersion}/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node.lib`)) ) - app.get("/node/v10.20.1/x64/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node_x64.lib")) + app.get(`/node/${atomElectronVersion}/x64/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node_x64.lib`)) ) - app.get("/node/v10.20.1/SHASUMS256.txt", (request, response) => + app.get(`/node/${atomElectronVersion}/SHASUMS256.txt`, (request, response) => response.sendFile(path.join(__dirname, "fixtures", "SHASUMS256.txt")) ) app.get("/test-module", (request, response) => @@ -51,7 +53,7 @@ describe("apm clean", function () { const atomHome = temp.mkdirSync("apm-home-dir-") process.env.ATOM_HOME = atomHome process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" - process.env.ATOM_ELECTRON_VERSION = "v10.20.1" + process.env.ATOM_ELECTRON_VERSION = atomElectronVersion process.env.npm_config_registry = "http://localhost:3000/" moduleDirectory = path.join(temp.mkdirSync("apm-test-module-"), "test-module-with-dependencies") diff --git a/spec/install-spec.js b/spec/install-spec.js index ec0a382..3a5b3dd 100644 --- a/spec/install-spec.js +++ b/spec/install-spec.js @@ -15,6 +15,8 @@ import * as apm from "../lib/apm-cli" import Install from "../lib/install" import { sync as resolveSync } from "resolve" +const atomElectronVersion = fs.readFileSync(`${path.dirname(__dirname)}/.npmrc`, "utf8").match(/target=(.*)\n/)[1] + describe("apm install", function () { let [atomHome, resourcePath] = Array.from([]) @@ -36,19 +38,19 @@ describe("apm install", function () { beforeEach(function () { const app = express() - app.get("/node/v10.20.1/node-v10.20.1.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node-${atomElectronVersion}.tar.gz`)) ) - app.get("/node/v10.20.1/node-v10.20.1-headers.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1-headers.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}-headers.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node-${atomElectronVersion}-headers.tar.gz`)) ) - app.get("/node/v10.20.1/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node.lib")) + app.get(`/node/${atomElectronVersion}/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node.lib`)) ) - app.get("/node/v10.20.1/x64/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node_x64.lib")) + app.get(`/node/${atomElectronVersion}/x64/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node_x64.lib`)) ) - app.get("/node/v10.20.1/SHASUMS256.txt", (request, response) => + app.get(`/node/${atomElectronVersion}/SHASUMS256.txt`, (request, response) => response.sendFile(path.join(__dirname, "fixtures", "SHASUMS256.txt")) ) app.get("/test-module", (request, response) => @@ -103,7 +105,7 @@ describe("apm install", function () { process.env.ATOM_HOME = atomHome process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" process.env.ATOM_PACKAGES_URL = "http://localhost:3000/packages" - process.env.ATOM_ELECTRON_VERSION = "v10.20.1" + process.env.ATOM_ELECTRON_VERSION = atomElectronVersion process.env.npm_config_registry = "http://localhost:3000/" return (live = true) }) diff --git a/spec/rebuild-spec.js b/spec/rebuild-spec.js index 9fff879..d1fb379 100644 --- a/spec/rebuild-spec.js +++ b/spec/rebuild-spec.js @@ -9,6 +9,9 @@ const temp = require("temp") const express = require("express") const http = require("http") import * as apm from "../lib/apm-cli" +import fs from "fs" + +const atomElectronVersion = fs.readFileSync(`${path.dirname(__dirname)}/.npmrc`, "utf8").match(/target=(.*)\n/)[1] describe("apm rebuild", function () { let [server, originalPathEnv] = Array.from([]) @@ -18,19 +21,19 @@ describe("apm rebuild", function () { spyOnConsole() const app = express() - app.get("/node/v10.20.1/node-v10.20.1.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node-${atomElectronVersion}.tar.gz`)) ) - app.get("/node/v10.20.1/node-v10.20.1-headers.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1-headers.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}-headers.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node-${atomElectronVersion}-headers.tar.gz`)) ) - app.get("/node/v10.20.1/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node.lib")) + app.get(`/node/${atomElectronVersion}/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node.lib`)) ) - app.get("/node/v10.20.1/x64/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node_x64.lib")) + app.get(`/node/${atomElectronVersion}/x64/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node_x64.lib`)) ) - app.get("/node/v10.20.1/SHASUMS256.txt", (request, response) => + app.get(`/node/${atomElectronVersion}/SHASUMS256.txt`, (request, response) => response.sendFile(path.join(__dirname, "fixtures", "SHASUMS256.txt")) ) @@ -42,7 +45,7 @@ describe("apm rebuild", function () { process.env.ATOM_HOME = atomHome process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" process.env.ATOM_PACKAGES_URL = "http://localhost:3000/packages" - process.env.ATOM_ELECTRON_VERSION = "v10.20.1" + process.env.ATOM_ELECTRON_VERSION = atomElectronVersion process.env.ATOM_RESOURCE_PATH = temp.mkdirSync("atom-resource-path-") originalPathEnv = process.env.PATH diff --git a/spec/stars-spec.js b/spec/stars-spec.js index a712202..27d4267 100644 --- a/spec/stars-spec.js +++ b/spec/stars-spec.js @@ -11,6 +11,8 @@ const http = require("http") const temp = require("temp") import * as apm from "../lib/apm-cli" +const atomElectronVersion = fs.readFileSync(`${path.dirname(__dirname)}/.npmrc`, "utf8").match(/target=(.*)\n/)[1] + describe("apm stars", function () { let [atomHome, server] = Array.from([]) @@ -23,19 +25,19 @@ describe("apm stars", function () { app.get("/users/hubot/stars", (request, response) => response.sendFile(path.join(__dirname, "fixtures", "stars.json")) ) - app.get("/node/v10.20.1/node-v10.20.1.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node-${atomElectronVersion}.tar.gz`)) ) - app.get("/node/v10.20.1/node-v10.20.1-headers.tar.gz", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node-v10.20.1-headers.tar.gz")) + app.get(`/node/${atomElectronVersion}/node-${atomElectronVersion}-headers.tar.gz`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node-${atomElectronVersion}-headers.tar.gz`)) ) - app.get("/node/v10.20.1/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node.lib")) + app.get(`/node/${atomElectronVersion}/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node.lib`)) ) - app.get("/node/v10.20.1/x64/node.lib", (request, response) => - response.sendFile(path.join(__dirname, "fixtures", "node_x64.lib")) + app.get(`/node/${atomElectronVersion}/x64/node.lib`, (request, response) => + response.sendFile(path.join(__dirname, `fixtures`, `node_x64.lib`)) ) - app.get("/node/v10.20.1/SHASUMS256.txt", (request, response) => + app.get(`/node/${atomElectronVersion}/SHASUMS256.txt`, (request, response) => response.sendFile(path.join(__dirname, "fixtures", "SHASUMS256.txt")) ) app.get("/tarball/test-module-1.2.0.tgz", (request, response) => @@ -57,7 +59,7 @@ describe("apm stars", function () { process.env.ATOM_API_URL = "http://localhost:3000" process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" process.env.ATOM_PACKAGES_URL = "http://localhost:3000/packages" - process.env.ATOM_ELECTRON_VERSION = "v10.20.1" + process.env.ATOM_ELECTRON_VERSION = atomElectronVersion process.env.npm_config_registry = "http://localhost:3000/" return (live = true) diff --git a/spec/upgrade-spec.js b/spec/upgrade-spec.js index fe24d79..76a1756 100644 --- a/spec/upgrade-spec.js +++ b/spec/upgrade-spec.js @@ -18,6 +18,8 @@ const apmRun = function (args, callback) { runs(callback) } +const atomElectronVersion = fs.readFileSync(`${path.dirname(__dirname)}/.npmrc`, "utf8").match(/target=(.*)\n/)[1] + describe("apm upgrade", function () { let [atomApp, atomHome, packagesDir, server] = Array.from([]) @@ -48,7 +50,7 @@ describe("apm upgrade", function () { process.env.ATOM_HOME = atomHome process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" process.env.ATOM_PACKAGES_URL = "http://localhost:3000/packages" - process.env.ATOM_ELECTRON_VERSION = "v10.20.1" + process.env.ATOM_ELECTRON_VERSION = atomElectronVersion process.env.ATOM_RESOURCE_PATH = atomApp fs.writeFileSync(path.join(atomApp, "package.json"), JSON.stringify({ version: "0.10.0" }))