Skip to content

Commit

Permalink
Remove punycode deprecation warnings
Browse files Browse the repository at this point in the history
This project's package.json engines field declared support all the way
back to node 10, but we've taken dependencies that are incompatible with
anything older than node 18! After updating the engines field, I did
some digging and realized that native nodeJS fetch landed in v18, so we
have an opportunity here to formalize our support boundary as node 18
and throw out the several fetch implementations we had lying around (one
of which was responsible for the punycode deprecation warnings).

Also includes a .nvmrc to pin to v18 so we don't accidentally include
libraries that require v19+ in the future.

Previous error installing on node v17:
> yarn install
error [email protected]: The engine "node" is incompatible with this module. Expected version "^14.17.0 || ^16.13.0 || >=18.0.0". Got "17.9.1"
error Found incompatible module.

Previous error running on node v17:
> ./bin/run eval "Database.all()"
 ›   Error: fetch is not defined:
  • Loading branch information
echo-bravo-yahoo committed Jul 12, 2024
1 parent 2761566 commit 4c0010c
Show file tree
Hide file tree
Showing 12 changed files with 1,129 additions and 1,379 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@
"chalk": "^4.1.2",
"cli-table": "^0.3.1",
"cli-ux": "^4.8.0",
"cross-fetch": "^3.1.4",
"csv-parse": "^5.0.4",
"csv-stream": "^0.2.0",
"dotenv": "^8.2.0",
"escodegen": "^1.12.0",
"esprima": "^4.0.1",
"exponential-backoff": "^3.1.0",
"faunadb": "^4.5.4",
"form-data": "^4.0.0",
"globby": "^11.0.0",
"ini": "^1.3.5",
"inquirer": "^8.1.1",
"moment": "^2.29.1",
"node-fetch": "^2.6.7",
"object-sizeof": "^1.6.1",
"prettier": "^2.3.0",
"rate-limiter-flexible": "^2.3.6",
Expand All @@ -41,7 +38,6 @@
"@types/chai": "^4.3.6",
"@types/mocha": "^10.0.1",
"@types/node": "^20.6.0",
"@types/node-fetch": "^2.6.6",
"@typescript-eslint/parser": "6.7.3",
"c8": "^8.0.1",
"chai": "^4.2.0",
Expand All @@ -62,7 +58,7 @@
"word-wrap": "^1.2.3"
},
"engines": {
"node": ">=10.0.0"
"node": ">=18.0.0"
},
"files": [
"/bin",
Expand Down
1 change: 0 additions & 1 deletion src/commands/cloud-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Endpoint, ShellConfig } from "../lib/config";
import { hostname } from "os";
import { Command } from "@oclif/core";
import { underline, blue } from "chalk";
import fetch from "node-fetch";
import { Secret } from "../lib/secret";

const DEFAULT_NAME = "cloud";
Expand Down
1 change: 0 additions & 1 deletion src/commands/schema/diff.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SchemaCommand from "../../lib/schema-command";
import fetch from "node-fetch";

export default class DiffSchemaCommand extends SchemaCommand {
static flags = {
Expand Down
1 change: 0 additions & 1 deletion src/commands/schema/pull.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { confirm } from "@inquirer/prompts";
import SchemaCommand from "../../lib/schema-command";
import fetch from "node-fetch";
import fs from "fs";
import path from "path";
import { Flags } from "@oclif/core";
Expand Down
1 change: 0 additions & 1 deletion src/commands/schema/push.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { confirm } from "@inquirer/prompts";
import SchemaCommand from "../../lib/schema-command";
import fetch from "node-fetch";
import { Flags } from "@oclif/core";

export default class PushSchemaCommand extends SchemaCommand {
Expand Down
1 change: 0 additions & 1 deletion src/commands/upload-graphql-schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const FaunaCommand = require("../lib/fauna-command.js").default;
const { Flags, Args } = require("@oclif/core");
const fetch = require("node-fetch");
const fs = require("fs");
const path = require("path");

Expand Down
2 changes: 0 additions & 2 deletions src/lib/fauna-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fetch from "node-fetch";

export type QueryResponse<T> = QuerySuccess<T> | QueryFailure;

export type QuerySuccess<T> = {
Expand Down
1 change: 0 additions & 1 deletion src/lib/fauna-command.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Command, Flags } from "@oclif/core";
import { green } from "chalk";
import { Client, errors, query as q } from "faunadb";
import fetch from "node-fetch";
import { ShellConfig } from "./config";
import FaunaClient from "./fauna-client";

Expand Down
10 changes: 6 additions & 4 deletions src/lib/schema-command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import FaunaCommand from "./fauna-command";
import * as fs from "fs";
import * as path from "path";
import FormData from "form-data";
import { Flags } from "@oclif/core";
import { dirExists, dirIsWriteable } from "./file-util";

Expand Down Expand Up @@ -60,11 +59,14 @@ export default abstract class SchemaCommand extends FaunaCommand {
// Helper to construct form data for a collection of files, as
// returned by `gather`.
body(files: File[]) {
const fd = new FormData();
const fd: Record<string, string> = {}
for (const file of files) {
fd.append(file.name, Buffer.from(file.content));
fd[file.name] = file.content.toString()
}
return fd;
const Readable = require('stream').Readable
const s = new Readable()
s.push(JSON.stringify(fd))
return s;
}

// Reads the files using their relative-to-`basedir` paths and returns their
Expand Down
1 change: 0 additions & 1 deletion test/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from "node-fetch";
const url = require("url");
const { query: q } = require("faunadb");
const env = process.env;
Expand Down
Loading

0 comments on commit 4c0010c

Please sign in to comment.