Skip to content

Commit

Permalink
refactor: stop using node-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Sep 5, 2023
1 parent 27bea3f commit 8d34c47
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 24 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@octokit/plugin-paginate-rest": "^2.17.0",
"@octokit/rest": "^18.12.0",
"@remix-run/changelog-github": "^0.0.5",
"@remix-run/web-fetch": "^4.4.0-pre.0",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-json": "^5.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
Expand Down
16 changes: 8 additions & 8 deletions packages/create-remix/copy-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from "node:fs";
import path from "node:path";
import stream from "node:stream";
import { promisify } from "node:util";
import fetch from "node-fetch";
import { fetch } from "@remix-run/web-fetch";
import gunzip from "gunzip-maybe";
import tar from "tar-fs";
import { ProxyAgent } from "proxy-agent";
Expand All @@ -28,9 +28,9 @@ export async function copyTemplate(
/**
* Valid templates are:
* - local file or directory on disk
* - github owner/repo shorthand
* - github owner/repo/directory shorthand
* - full github repo URL
* - GitHub owner/repo shorthand
* - GitHub owner/repo/directory shorthand
* - full GitHub repo URL
* - any tarball URL
*/

Expand Down Expand Up @@ -140,7 +140,7 @@ async function copyTemplateFromLocalFilePath(
return false;
}
if (fs.statSync(filePath).isDirectory()) {
// If our template is just a directory on disk, return true here and we'll
// If our template is just a directory on disk, return true here, and we'll
// just copy directly from there instead of "extracting" to a temp
// directory first
return true;
Expand Down Expand Up @@ -224,7 +224,7 @@ async function downloadAndExtractTarball(
headers.Authorization = `token ${token}`;
}
if (isGithubReleaseAssetUrl(tarballUrl)) {
// We can download the asset via the github api, but first we need to look
// We can download the asset via the GitHub api, but first we need to look
// up the asset id
let info = getGithubReleaseAssetInfo(tarballUrl);
headers.Accept = "application/vnd.github.v3+json";
Expand Down Expand Up @@ -297,7 +297,7 @@ async function downloadAndExtractTarball(
);
}

// file paths returned from github are always unix style
// file paths returned from GitHub are always unix style
if (filePath) {
filePath = filePath.split(path.sep).join(path.posix.sep);
}
Expand Down Expand Up @@ -419,7 +419,7 @@ function getGithubReleaseAssetInfo(browserUrl: string): ReleaseAssetInfo {
let [, owner, name, , downloadOrLatest, tag, asset] = url.pathname.split("/");

if (downloadOrLatest === "latest" && tag === "download") {
// handle the Github URL quirk for latest releases
// handle the GitHub URL quirk for latest releases
tag = "latest";
}

Expand Down
3 changes: 1 addition & 2 deletions packages/create-remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"create-remix": "dist/cli.js"
},
"dependencies": {
"@remix-run/web-fetch": "^4.4.0-pre.0",
"arg": "^5.0.1",
"chalk": "^4.1.2",
"execa": "5.1.1",
"gunzip-maybe": "^1.4.2",
"log-update": "^5.0.1",
"node-fetch": "^2.6.9",
"proxy-agent": "^6.3.0",
"recursive-readdir": "^2.2.3",
"rimraf": "^4.1.2",
Expand All @@ -34,7 +34,6 @@
},
"devDependencies": {
"@types/gunzip-maybe": "^1.4.0",
"@types/node-fetch": "^2.5.7",
"@types/recursive-readdir": "^2.2.1",
"@types/tar-fs": "^2.0.1",
"esbuild": "0.17.6",
Expand Down
2 changes: 0 additions & 2 deletions packages/remix-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"lodash": "^4.17.21",
"lodash.debounce": "^4.0.8",
"minimatch": "^9.0.0",
"node-fetch": "^2.6.9",
"ora": "^5.4.1",
"picocolors": "^1.0.0",
"picomatch": "^2.3.1",
Expand All @@ -74,7 +73,6 @@
"@types/jsesc": "^3.0.1",
"@types/lodash.debounce": "^4.0.6",
"@types/node": "^18.17.1",
"@types/node-fetch": "^2.5.7",
"@types/npmcli__package-json": "^4.0.0",
"@types/picomatch": "^2.3.0",
"@types/shelljs": "^0.8.11",
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployment-test/_shared.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import crypto from "node:crypto";
import { sync as spawnSync } from "cross-spawn";
import PackageJson from "@npmcli/package-json";
import jsonfile from "jsonfile";
import fetch from "node-fetch";
import { fetch } from "@remix-run/web-fetch";
import retry from "fetch-retry";

let fetchRetry = retry(fetch);
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployment-test/cf-pages.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "node:path";
import { sync as spawnSync } from "cross-spawn";
import fse from "fs-extra";
import fetch from "node-fetch";
import { fetch } from "@remix-run/web-fetch";
import PackageJson from "@npmcli/package-json";

import {
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployment-test/cf-workers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "node:path";
import { sync as spawnSync } from "cross-spawn";
import fse from "fs-extra";
import toml from "@iarna/toml";
import fetch from "node-fetch";
import { fetch } from "@remix-run/web-fetch";
import PackageJson from "@npmcli/package-json";

import {
Expand Down
10 changes: 1 addition & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2669,14 +2669,6 @@
resolved "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz"
integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==

"@types/node-fetch@^2.5.7":
version "2.5.12"
resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz"
integrity sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==
dependencies:
"@types/node" "*"
form-data "^3.0.0"

"@types/node@*", "@types/node@^18.17.1":
version "18.17.1"
resolved "https://registry.npmjs.org/@types/node/-/node-18.17.1.tgz#84c32903bf3a09f7878c391d31ff08f6fe7d8335"
Expand Down Expand Up @@ -9038,7 +9030,7 @@ nice-try@^1.0.4:
resolved "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==

node-fetch@^2.5.0, node-fetch@^2.6.7, node-fetch@^2.6.9:
node-fetch@^2.5.0, node-fetch@^2.6.7:
version "2.6.9"
resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz#7c7f744b5cc6eb5fd404e0c7a9fec630a55657e6"
integrity sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==
Expand Down

0 comments on commit 8d34c47

Please sign in to comment.