From c7ea13ea9fe10cfb7687ede9456b246f9f9afaa2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 3 Nov 2021 18:46:49 +0100 Subject: [PATCH] feat: update `std-env` to v3 (#10012) [release] Co-authored-by: Pooya Parsa --- packages/cli/package.json | 2 +- packages/cli/src/utils/banner.js | 6 +++--- packages/cli/src/utils/index.js | 4 ++-- .../cli/test/unit/utils-minimalcli.test.js | 4 ++-- packages/cli/test/unit/utils.test.js | 4 ++-- packages/config/package.json | 2 +- packages/config/src/config/_common.js | 6 +++--- packages/config/src/config/build.js | 4 ++-- packages/config/test/config/index.test.js | 18 +++++++++--------- packages/config/test/options.test.js | 18 +++++++++--------- packages/generator/test/__utils__/index.js | 6 ++---- packages/webpack/package.json | 2 +- packages/webpack/src/config/base.js | 6 +++--- test/utils/setup-env.js | 14 ++++++-------- yarn.lock | 7 ++++++- 15 files changed, 52 insertions(+), 51 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 59909fbe31..eeedc2a605 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -33,7 +33,7 @@ "pretty-bytes": "^5.6.0", "semver": "^7.3.5", "serve-static": "^1.14.1", - "std-env": "^2.3.1", + "std-env": "^3.0.0", "upath": "^2.0.1", "wrap-ansi": "^7.0.0" }, diff --git a/packages/cli/src/utils/banner.js b/packages/cli/src/utils/banner.js index e35d79b31c..f74150ac37 100644 --- a/packages/cli/src/utils/banner.js +++ b/packages/cli/src/utils/banner.js @@ -1,15 +1,15 @@ import consola from 'consola' -import env from 'std-env' +import { isTest, isMinimal } from 'std-env' import chalk from 'chalk' import { successBox } from './formatting' import { getFormattedMemoryUsage } from './memory' export function showBanner (nuxt, showMemoryUsage = true) { - if (env.test) { + if (isTest) { return } - if (env.minimalCLI) { + if (isMinimal) { for (const listener of nuxt.server.listeners) { consola.info('Listening on: ' + listener.url) } diff --git a/packages/cli/src/utils/index.js b/packages/cli/src/utils/index.js index 95fd870491..15b4144c40 100644 --- a/packages/cli/src/utils/index.js +++ b/packages/cli/src/utils/index.js @@ -3,12 +3,12 @@ import exit from 'exit' import { lock } from '@nuxt/utils' import chalk from 'chalk' -import env from 'std-env' +import { isWindows } from 'std-env' import { warningBox } from './formatting' export const eventsMapping = { add: { icon: '+', color: 'green', action: 'Created' }, - change: { icon: env.windows ? '»' : '↻', color: 'blue', action: 'Updated' }, + change: { icon: isWindows ? '»' : '↻', color: 'blue', action: 'Updated' }, unlink: { icon: '-', color: 'red', action: 'Removed' } } diff --git a/packages/cli/test/unit/utils-minimalcli.test.js b/packages/cli/test/unit/utils-minimalcli.test.js index 42427da11e..f9bb475d86 100644 --- a/packages/cli/test/unit/utils-minimalcli.test.js +++ b/packages/cli/test/unit/utils-minimalcli.test.js @@ -2,8 +2,8 @@ import { consola } from '../utils' import { showBanner } from '../../src/utils/banner' jest.mock('std-env', () => ({ - test: false, - minimalCLI: true + isTest: false, + isMinimal: true })) describe('cli/utils', () => { diff --git a/packages/cli/test/unit/utils.test.js b/packages/cli/test/unit/utils.test.js index 90a5a049a8..79d9cc7abc 100644 --- a/packages/cli/test/unit/utils.test.js +++ b/packages/cli/test/unit/utils.test.js @@ -8,8 +8,8 @@ import { showMemoryUsage } from '../../src/utils/memory' import * as fmt from '../../src/utils/formatting' jest.mock('std-env', () => ({ - test: false, - minimalCLI: false + isTest: false, + isMinimal: false })) jest.mock('boxen', () => text => `[boxen] ${text}`) diff --git a/packages/config/package.json b/packages/config/package.json index aba7e0ea0b..dee848547e 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -17,7 +17,7 @@ "dotenv": "^10.0.0", "lodash": "^4.17.21", "rc9": "^1.2.0", - "std-env": "^2.3.1", + "std-env": "^3.0.0", "ufo": "^0.7.9" }, "publishConfig": { diff --git a/packages/config/src/config/_common.js b/packages/config/src/config/_common.js index 1e26379360..7e09a0d8cb 100644 --- a/packages/config/src/config/_common.js +++ b/packages/config/src/config/_common.js @@ -1,11 +1,11 @@ import { capitalize } from 'lodash' -import env from 'std-env' +import { isDevelopment, isTest } from 'std-env' import { TARGETS } from '@nuxt/utils' export default () => ({ // Env - dev: Boolean(env.dev), - test: Boolean(env.test), + dev: Boolean(isDevelopment), + test: Boolean(isTest), debug: undefined, // = dev env: {}, diff --git a/packages/config/src/config/build.js b/packages/config/src/config/build.js index 739ca30b1f..94eba89546 100644 --- a/packages/config/src/config/build.js +++ b/packages/config/src/config/build.js @@ -1,7 +1,7 @@ -import env from 'std-env' +import { isCI, isTest } from 'std-env' export default () => ({ - quiet: Boolean(env.ci || env.test), + quiet: Boolean(isCI || isTest), analyze: false, profile: process.argv.includes('--profile'), extractCSS: false, diff --git a/packages/config/test/config/index.test.js b/packages/config/test/config/index.test.js index d32c809aa4..7f02d7a4e7 100644 --- a/packages/config/test/config/index.test.js +++ b/packages/config/test/config/index.test.js @@ -1,15 +1,15 @@ import { getDefaultNuxtConfig } from '../../src/config' jest.mock('std-env', () => ({ - browser: false, - test: 'test', - dev: false, - production: true, - debug: false, - ci: true, - windows: false, - darwin: false, - linux: true + isBrowser: false, + isTest: true, + isDevelopment: false, + isProduction: true, + isDebug: false, + isCI: true, + isWindows: false, + isMacOS: false, + isLinux: true })) describe('config', () => { diff --git a/packages/config/test/options.test.js b/packages/config/test/options.test.js index 3c135ffca6..593e5f45c9 100644 --- a/packages/config/test/options.test.js +++ b/packages/config/test/options.test.js @@ -3,15 +3,15 @@ import consola from 'consola' import { getNuxtConfig } from '../src/options' jest.mock('std-env', () => ({ - browser: false, - test: 'test', - dev: false, - production: true, - debug: false, - ci: true, - windows: false, - darwin: false, - linux: true + isBrowser: false, + isTest: true, + isDevelopment: false, + isProduction: true, + isDebug: false, + isCI: true, + isWindows: false, + isMacOS: false, + isLinux: true })) jest.mock('@nuxt/utils', () => ({ diff --git a/packages/generator/test/__utils__/index.js b/packages/generator/test/__utils__/index.js index 24768ec1eb..ea53c4f76c 100644 --- a/packages/generator/test/__utils__/index.js +++ b/packages/generator/test/__utils__/index.js @@ -1,9 +1,7 @@ import { resolve } from 'path' -import env from 'std-env' +import { isWindows } from 'std-env' -const isWin = env.windows - -const rootDir = isWin ? 'C:\\nuxt' : '/var/nuxt' +const rootDir = isWindows ? 'C:\\nuxt' : '/var/nuxt' export const createNuxt = () => ({ ready: jest.fn(), diff --git a/packages/webpack/package.json b/packages/webpack/package.json index e085496aba..fb1e5c8640 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -37,7 +37,7 @@ "postcss-preset-env": "^6.7.0", "postcss-url": "^8.0.0", "semver": "^7.3.5", - "std-env": "^2.3.1", + "std-env": "^3.0.0", "style-resources-loader": "^1.4.1", "terser-webpack-plugin": "^4.2.3", "thread-loader": "^3.0.4", diff --git a/packages/webpack/src/config/base.js b/packages/webpack/src/config/base.js index 4d835f713d..35a184c6a4 100644 --- a/packages/webpack/src/config/base.js +++ b/packages/webpack/src/config/base.js @@ -8,7 +8,7 @@ import * as PnpWebpackPlugin from 'pnp-webpack-plugin' import HardSourcePlugin from 'hard-source-webpack-plugin' import TerserWebpackPlugin from 'terser-webpack-plugin' import WebpackBar from 'webpackbar' -import env from 'std-env' +import { isMinimal } from 'std-env' import semver from 'semver' import { isRelative } from 'ufo' @@ -446,8 +446,8 @@ export default class WebpackBaseConfig { 'profile', 'stats' ], - basic: !buildOptions.quiet && env.minimalCLI, - fancy: !buildOptions.quiet && !env.minimalCLI, + basic: !buildOptions.quiet && isMinimal, + fancy: !buildOptions.quiet && isMinimal, profile: !buildOptions.quiet && buildOptions.profile, stats: !buildOptions.quiet && !this.dev && buildOptions.stats, reporter: { diff --git a/test/utils/setup-env.js b/test/utils/setup-env.js index 89d1192093..b5d187ca1c 100644 --- a/test/utils/setup-env.js +++ b/test/utils/setup-env.js @@ -1,14 +1,12 @@ import consola from 'consola' -import env from 'std-env' +import { isWindows } from 'std-env' import exit from 'exit' -const isWin = env.windows +describe.win = isWindows ? describe : describe.skip +test.win = isWindows ? test : test.skip -describe.win = isWin ? describe : describe.skip -test.win = isWin ? test : test.skip - -describe.posix = !isWin ? describe : describe.skip -test.posix = !isWin ? test : test.skip +describe.posix = !isWindows ? describe : describe.skip +test.posix = !isWindows ? test : test.skip jest.setTimeout(60000) @@ -24,7 +22,7 @@ process.on('uncaughtException', errorTrap) expect.extend({ toBePath (received, posixPath, winPath) { - const expectedPath = isWin ? winPath : posixPath + const expectedPath = isWindows ? winPath : posixPath const pass = received === expectedPath return { pass, diff --git a/yarn.lock b/yarn.lock index ab848a5631..98bb6329b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12257,13 +12257,18 @@ static-extend@^0.1.1: resolved "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= -std-env@^2.2.1, std-env@^2.3.0, std-env@^2.3.1: +std-env@^2.2.1, std-env@^2.3.0: version "2.3.1" resolved "https://registry.npmjs.org/std-env/-/std-env-2.3.1.tgz#d42271908819c243f8defc77a140fc1fcee336a1" integrity sha512-eOsoKTWnr6C8aWrqJJ2KAReXoa7Vn5Ywyw6uCXgA/xDhxPoaIsBa5aNJmISY04dLwXPBnDHW4diGM7Sn5K4R/g== dependencies: ci-info "^3.1.1" +std-env@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/std-env/-/std-env-3.0.0.tgz#8dbd16bd2aadc18992072e2f5839e897f4ee2733" + integrity sha512-GoFEqAGzhaexp/T01rIiLOK9LHa6HmVwEUyeU4cwdSnOhfxpw9IMeAFi44SHWbCErEs29qEh7vAOUbtUmoycjA== + stream-browserify@^2.0.1: version "2.0.2" resolved "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz#87521d38a44aa7ee91ce1cd2a47df0cb49dd660b"