Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade envalid to 7.3.0 #29

Merged
merged 9 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"chalk": "^5.0.0",
"dedent": "^0.7.0",
"dotenv-flow": "^3.2.0",
"envalid": "^7.2.2",
"envalid": "7.3.0-beta.1",
"eslint": "^8.8.0",
"execa": "^6.0.0",
"fs-extra": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/2-sources/osm/tiles/fetch-images.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AxiosInstance } from "axios";
import chalk from "chalk";
import * as envalid from "envalid";
import envalid from "envalid";
import fs from "fs-extra";
import path from "node:path";
import stream from "node:stream";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AxiosResponse } from "axios";
import chalk from "chalk";
import * as envalid from "envalid";
import envalid from "envalid";
import sortKeys from "sort-keys";

import { cleanEnv } from "../../../shared/cleanEnv";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as turf from "@turf/turf";
import axios, { AxiosError, AxiosInstance } from "axios";
import axiosRetry from "axios-retry";
import chalk from "chalk";
import * as envalid from "envalid";
import envalid from "envalid";
import fs from "fs-extra";
import http from "node:http";
import https from "node:https";
Expand Down
8 changes: 3 additions & 5 deletions src/scripts/4-results/generate-geosemantica-layer-styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from "chalk";
import clipboardy from "clipboardy";
import { color as d3Color } from "d3-color";
import * as envalid from "envalid";
import envalid from "envalid";
import fs from "fs-extra";
import _ from "lodash";
import path from "node:path";
Expand Down Expand Up @@ -432,10 +432,8 @@ const script = async () => {
output.write(` Done.\n`);

const { COPY_TO_CLIPBOARD: layerStyleToCopy } = cleanEnv({
COPY_TO_CLIPBOARD: envalid.str<
"background" | "buildings" | "foreground" | ""
>({
choices: ["background", "buildings", "foreground", ""],
COPY_TO_CLIPBOARD: envalid.str({
choices: ["background", "buildings", "foreground", ""] as const,
default: "",
Comment on lines +435 to 437
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@af 🎉

}),
});
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/4-results/generate-poster.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from "chalk";
import * as envalid from "envalid";
import envalid from "envalid";
import path from "node:path";
import puppeteer from "puppeteer";

Expand Down Expand Up @@ -33,8 +33,8 @@ const script = async () => {
);

const { EXTENSION: extension } = cleanEnv({
EXTENSION: envalid.str<"pdf" | "jpg" | "png">({
choices: ["pdf", "jpg", "png"],
EXTENSION: envalid.str({
choices: ["pdf", "jpg", "png"] as const,
default: "pdf",
}),
});
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/format-data-files.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from "chalk";
import * as envalid from "envalid";
import envalid from "envalid";
import fs from "fs-extra";
import path from "node:path";

Expand Down
2 changes: 1 addition & 1 deletion src/shared/cleanEnv.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config } from "dotenv-flow";
import * as envalid from "envalid";
import envalid from "envalid";

import { defaultReporter } from "./envalidDefaultReporter";

Expand Down
8 changes: 5 additions & 3 deletions src/shared/envalidDefaultReporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Origin: https://github.com/af/envalid/blob/a694876d3fe5f8a8316d15ce4e26e895f41966f6/src/reporter.ts

import { EnvMissingError, ReporterOptions } from "envalid";
import envalid from "envalid";

import { ScriptError } from "./helpersForScripts";

Expand All @@ -17,15 +17,17 @@ const colors = {

const rule = colors.white("================================");

export const defaultReporter = ({ errors = {} }: ReporterOptions<any>) => {
export const defaultReporter = ({
errors = {},
}: envalid.ReporterOptions<any>) => {
if (Object.keys(errors).length === 0) {
return;
}

const missingVarsOutput: string[] = [];
const invalidVarsOutput: string[] = [];
for (const [key, error] of Object.entries(errors)) {
if (error instanceof EnvMissingError) {
if (error instanceof envalid.EnvMissingError) {
missingVarsOutput.push(
` ${colors.blue(key)}: ${error.message || "(required)"}`,
);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/geocoding/debugAddressNormalizationIfEnabled.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from "chalk";
import * as envalid from "envalid";
import envalid from "envalid";
import { WriteStream } from "node:tty";

import { AddressNormalizationConfig, normalizeAddress } from "../addresses";
Expand Down
6 changes: 3 additions & 3 deletions src/shared/results/getLocaleFromEnv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as envalid from "envalid";
import envalid from "envalid";

import { cleanEnv } from "../cleanEnv";

Expand All @@ -7,10 +7,10 @@ export type Locale = "en" | "ru";
export const getLocaleFromEnv = (): Locale => {
const env = cleanEnv({
LOCALE: envalid.str({
choices: ["ru", "en"] as const,
default: "ru",
choices: ["ru", "en"],
}),
});

return env.LOCALE as Locale;
return env.LOCALE;
};
2 changes: 1 addition & 1 deletion src/shared/sources/mkrf/helpersForPaths.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as envalid from "envalid";
import envalid from "envalid";
import path from "node:path";

import { cleanEnv } from "../../cleanEnv";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as envalid from "envalid";
import envalid from "envalid";
import _ from "lodash";
import sleep from "sleep-promise";

Expand Down
2 changes: 1 addition & 1 deletion src/shared/territory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as turf from "@turf/turf";
import chalk from "chalk";
import * as envalid from "envalid";
import envalid from "envalid";
import fs from "fs-extra";
import { load } from "js-yaml";
import _ from "lodash";
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3400,10 +3400,10 @@ entities@~2.1.0:
resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5"
integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==

envalid@^7.2.2:
version "7.2.2"
resolved "https://registry.yarnpkg.com/envalid/-/envalid-7.2.2.tgz#f3219f85e692002dca0f28076740227d30c817e3"
integrity sha512-bl/3VF5PhoF26HlDWiE0NRRHUbKT/+UDP/+0JtOFmhUwK3cUPS7JgWYGbE8ArvA61T+SyNquxscLCS6y4Wnpdw==
envalid@7.3.0-beta.1:
version "7.3.0-beta.1"
resolved "https://registry.yarnpkg.com/envalid/-/envalid-7.3.0-beta.1.tgz#ecaec571bab91b613af4d7e4620b79b1f5fd613b"
integrity sha512-fvMuSe7fPj4aRCaZ/lZdE6bHap+i0s33SMcLuVg4KZMVUhfCajjue/XV1KKxJD2ZVuafB/INCpw6hUWRXvya2A==
dependencies:
tslib "2.3.1"

Expand Down