Skip to content

Commit

Permalink
refactor: migrate from upath to pathe (nuxt#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Sep 27, 2021
1 parent 3bf8568 commit 6329a68
Show file tree
Hide file tree
Showing 89 changed files with 112 additions and 103 deletions.
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"rimraf": "^3.0.2",
"scule": "^0.2.1",
"untyped": "^0.2.9",
"upath": "^2.0.1",
"pathe": "^0.2.0",
"vue-plausible": "^1.2.1"
}
}
2 changes: 1 addition & 1 deletion docs/scripts/gen-docs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { rm, writeFile } from 'fs/promises'
import mkdirp from 'mkdirp'
import type { Schema } from 'untyped'
import { join, resolve } from 'upath'
import { join, resolve } from 'pathe'
import { kebabCase, upperFirst } from 'scule'

export async function main () {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"lerna": "^4.0.0",
"mocha": "^9.1.1",
"object-hash": "^2.2.0",
"pathe": "^0.2.0",
"typescript": "^4.4.3",
"unbuild": "^0.5.4",
"upath": "^2.0.1"
"unbuild": "^0.5.4"
},
"packageManager": "[email protected]"
}
4 changes: 2 additions & 2 deletions packages/bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"nuxi": "^0.10.0",
"nuxt-swc": "^0.1.0",
"nuxt-vite": "^0.2.4",
"ufo": "^0.7.9",
"upath": "^2.0.1"
"pathe": "^0.2.0",
"ufo": "^0.7.9"
},
"devDependencies": {
"@types/fs-extra": "^9.0.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNuxt, resolveModule } from '@nuxt/kit'
import { resolve } from 'upath'
import { resolve } from 'pathe'
import { distDir } from './dirs'

export function setupAppBridge (_options: any) {
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge/src/capi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNuxt, addPlugin, addPluginTemplate } from '@nuxt/kit'
import { resolve } from 'upath'
import { useNuxt, addPluginTemplate, addPlugin } from '@nuxt/kit'
import { resolve } from 'pathe'
import { distDir } from './dirs'

export function setupCAPIBridge (_options: any) {
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/src/dirs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'upath'
import { resolve } from 'pathe'

export const distDir = __dirname
export const pkgDir = resolve(distDir, '..')
2 changes: 1 addition & 1 deletion packages/bridge/src/nitro.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fetch from 'node-fetch'
import { addPluginTemplate, useNuxt } from '@nuxt/kit'
import { stringifyQuery } from 'ufo'
import { resolve } from 'upath'
import { resolve } from 'pathe'
import { readFile, writeFile } from 'fs-extra'
import { build, generate, prepare, getNitroContext, NitroContext, createDevServer, wpfs, resolveMiddleware } from '@nuxt/nitro'
import { AsyncLoadingPlugin } from './async-loading'
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"hash-sum": "^2.0.0",
"hookable": "^5.0.0",
"jiti": "^1.12.3",
"pathe": "^0.2.0",
"rc9": "^1.2.0",
"scule": "^0.2.1",
"std-env": "^2.3.0",
"ufo": "^0.7.9",
"unctx": "^1.0.2",
"untyped": "^0.2.9",
"upath": "^2.0.1"
"untyped": "^0.2.9"
}
}
2 changes: 1 addition & 1 deletion packages/kit/src/config/env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, promises as fsp } from 'fs'
import { resolve } from 'upath'
import { resolve } from 'pathe'
import dotenv from 'dotenv'
import { LoadNuxtConfigOptions } from './load'

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/config/load.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync } from 'fs'
import { resolve } from 'upath'
import { resolve } from 'pathe'
import defu from 'defu'
import { applyDefaults } from 'untyped'
import * as rc from 'rc9'
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/config/schema/_app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, join } from 'upath'
import { resolve, join } from 'pathe'
import { existsSync, readdirSync } from 'fs'
import defu from 'defu'
import { isRelative, joinURL, hasProtocol } from 'ufo'
Expand Down
6 changes: 3 additions & 3 deletions packages/kit/src/config/schema/_common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, resolve } from 'upath'
import { join, resolve } from 'pathe'
import env from 'std-env'
import createRequire from 'create-require'
import { pascalCase } from 'scule'
Expand Down Expand Up @@ -478,7 +478,7 @@ export default {
*
* @example
* ```js
* import { resolve } from 'path'
* import { resolve } from 'pathe'
* export default {
* alias: {
* 'images': resolve(__dirname, './assets/images'),
Expand Down Expand Up @@ -627,7 +627,7 @@ export default {
* @example
* ```js
* import fs from 'fs'
* import path from 'path'
* import path from 'pathe'
* export default {
* hooks: {
* build: {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/config/schema/generate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'upath'
import { resolve } from 'pathe'
import { joinURL } from 'ufo'

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/module/container.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'upath'
import path from 'pathe'
import consola from 'consola'
import type { Nuxt, NuxtPluginTemplate, NuxtTemplate } from '../types/nuxt'
import { chainFn } from '../utils/task'
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/module/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs'
import { basename, parse, resolve } from 'upath'
import { basename, parse, resolve } from 'pathe'
import hash from 'hash-sum'
import type { WebpackPluginInstance, Configuration as WebpackConfig } from 'webpack'
import type { Plugin as VitePlugin, UserConfig as ViteConfig } from 'vite'
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/utils/cjs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, normalize } from 'upath'
import { join, normalize } from 'pathe'
import jiti from 'jiti'

// TODO: use create-require for jest environment
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/utils/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, lstatSync, readdirSync } from 'fs'
import { basename, dirname, resolve, join } from 'upath'
import { basename, dirname, resolve, join } from 'pathe'
import globby from 'globby'

export interface ResolveOptions {
Expand Down
1 change: 1 addition & 0 deletions packages/nitro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"node-fetch": "^3.0.0",
"ohmyfetch": "^0.3.1",
"ora": "^6.0.1",
"pathe": "^0.2.0",
"pretty-bytes": "^5.6.0",
"rollup": "^2.57.0",
"rollup-plugin-analyzer": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/nitro/src/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, join } from 'upath'
import { resolve, join } from 'pathe'
import consola from 'consola'
import { rollup, watch as rollupWatch } from 'rollup'
import { readFile, emptyDir, copy } from 'fs-extra'
Expand Down Expand Up @@ -75,7 +75,7 @@ async function _build (nitroContext: NitroContext) {
await nitroContext._internal.hooks.callHook('nitro:compiled', nitroContext)

return {
entry: resolve(nitroContext.rollupConfig.output.dir, nitroContext.rollupConfig.output.entryFileNames)
entry: resolve(nitroContext.rollupConfig.output.dir, nitroContext.rollupConfig.output.entryFileNames as string)
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-use-before-define */

import { resolve, dirname } from 'upath'
import { resolve, dirname } from 'pathe'
import defu from 'defu'
import { createHooks, Hookable, NestedHooks } from 'hookable'
import type { Preset } from 'unenv'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/presets/azure.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import consola from 'consola'
import fse from 'fs-extra'
import globby from 'globby'
import { join, resolve } from 'upath'
import { join, resolve } from 'pathe'
import { writeFile } from '../utils'
import { NitroPreset, NitroContext } from '../context'

Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/presets/azure_functions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import archiver from 'archiver'
import consola from 'consola'
import { createWriteStream } from 'fs-extra'
import { join, resolve } from 'upath'
import { join, resolve } from 'pathe'
import { prettyPath, writeFile } from '../utils'
import { NitroPreset, NitroContext } from '../context'

Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/presets/browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, writeFile } from 'fs-extra'
import { resolve } from 'upath'
import { resolve } from 'pathe'
import consola from 'consola'
import { extendPreset, prettyPath } from '../utils'
import { NitroPreset, NitroContext, NitroInput } from '../context'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/presets/cloudflare.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'upath'
import { resolve } from 'pathe'
import consola from 'consola'
import { extendPreset, writeFile, prettyPath } from '../utils'
import { NitroContext, NitroPreset } from '../context'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/presets/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, relative, resolve } from 'upath'
import { join, relative, resolve } from 'pathe'
import { existsSync, readJSONSync } from 'fs-extra'
import consola from 'consola'
import globby from 'globby'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/presets/netlify.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'upath'
import { join } from 'pathe'
import { existsSync, readFile, writeFile } from 'fs-extra'
import consola from 'consola'
import { extendPreset } from '../utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/presets/vercel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'upath'
import { resolve } from 'pathe'
import { extendPreset, writeFile } from '../utils'
import { NitroPreset, NitroContext } from '../context'
import { node } from './node'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pathToFileURL } from 'url'
import { dirname, join, normalize, relative, resolve } from 'upath'
import { dirname, join, normalize, relative, resolve } from 'pathe'
import type { InputOptions, OutputOptions } from 'rollup'
import defu from 'defu'
import { terser } from 'rollup-plugin-terser'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { promises as fsp } from 'fs'
import type { Plugin } from 'rollup'
import createEtag from 'etag'
import mime from 'mime'
import { resolve } from 'upath'
import { resolve } from 'pathe'
import globby from 'globby'
import virtual from './virtual'

Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/dynamic-require.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'upath'
import { resolve } from 'pathe'
import globby from 'globby'
import type { Plugin } from 'rollup'
import { serializeImportName } from '../../utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/esbuild.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Based on https://github.com/egoist/rollup-plugin-esbuild (MIT)

import { extname, relative } from 'upath'
import { extname, relative } from 'pathe'
import type { Plugin, PluginContext } from 'rollup'
import { Loader, TransformResult, transform } from 'esbuild'
import { createFilter } from '@rollup/pluginutils'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/externals.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, dirname } from 'upath'
import { resolve, dirname } from 'pathe'
import { copyFile, mkdirp } from 'fs-extra'
import { nodeFileTrace, NodeFileTraceOptions } from '@vercel/nft'
import type { Plugin } from 'rollup'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hasha from 'hasha'
import { relative } from 'upath'
import { relative } from 'pathe'
import { table, getBorderCharacters } from 'table'
import isPrimitive from 'is-primitive'
import stdenv from 'std-env'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/raw.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extname } from 'upath'
import { extname } from 'pathe'
import type { Plugin } from 'rollup'

export interface RawOptions {
Expand Down
6 changes: 3 additions & 3 deletions packages/nitro/src/rollup/plugins/static.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import createEtag from 'etag'
import { readFileSync, statSync } from 'fs-extra'
import mime from 'mime'
import { relative, resolve } from 'upath'
import { relative, resolve } from 'pathe'
import virtual from '@rollup/plugin-virtual'
import globby from 'globby'
import type { Plugin } from 'rollup'
Expand Down Expand Up @@ -31,8 +31,8 @@ export function staticAssets (context: NitroContext) {
'#static-assets': `export default ${JSON.stringify(assets, null, 2)};`,
'#static': `
import { promises } from 'fs'
import { resolve } from 'path'
import { dirname } from 'path'
import { resolve } from 'pathe'
import { dirname } from 'pathe'
import { fileURLToPath } from 'url'
import assets from '#static-assets'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/timing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extname } from 'upath'
import { extname } from 'pathe'
import type { Plugin, RenderedChunk } from 'rollup'

export interface Options { }
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/virtual.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from 'upath'
import * as path from 'pathe'
import type { Plugin } from 'rollup'

// Based on https://github.com/rollup/plugins/blob/master/packages/virtual/src/index.ts
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/server/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { createProxy } from 'http-proxy'
import { listen, Listener, ListenOptions } from 'listhen'
import servePlaceholder from 'serve-placeholder'
import serveStatic from 'serve-static'
import { resolve } from 'upath'
import { resolve } from 'pathe'
import type { Server } from 'connect'
import type { NitroContext } from '../context'
import { handleVfs } from './vfs'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/server/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, join, extname } from 'upath'
import { resolve, join, extname } from 'pathe'
import { joinURL } from 'ufo'
import globby from 'globby'
import { watch } from 'chokidar'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { relative, dirname, resolve } from 'upath'
import { relative, dirname, resolve } from 'pathe'
import fse from 'fs-extra'
import jiti from 'jiti'
import defu from 'defu'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/utils/tree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, dirname, relative } from 'upath'
import { resolve, dirname, relative } from 'pathe'
import globby from 'globby'
import prettyBytes from 'pretty-bytes'
import gzipSize from 'gzip-size'
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/utils/wpfs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'upath'
import { join } from 'pathe'
import fsExtra from 'fs-extra'

export const wpfs = {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"jiti": "^1.12.3",
"listhen": "^0.2.4",
"mri": "^1.2.0",
"pathe": "^0.2.0",
"scule": "^0.2.1",
"unbuild": "latest",
"upath": "^2.0.1",
"v8-compile-cache": "^2.3.0"
}
}
2 changes: 1 addition & 1 deletion packages/nuxi/src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'upath'
import { resolve } from 'pathe'
import { requireModule } from '../utils/cjs'
import { error } from '../utils/log'

Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/src/commands/dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, relative } from 'upath'
import { resolve, relative } from 'pathe'
import chokidar from 'chokidar'
import debounce from 'debounce-promise'
import type { Nuxt } from '@nuxt/kit'
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/src/commands/info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os from 'os'
import { existsSync, readFileSync } from 'fs'
import { resolve, dirname } from 'upath'
import { resolve, dirname } from 'pathe'
import jiti from 'jiti'
import destr from 'destr'
import { splitByCase } from 'scule'
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/src/commands/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { promises as fsp } from 'fs'
import { relative, resolve } from 'upath'
import { relative, resolve } from 'pathe'
import { cyan } from 'colorette'
import type { TSReference } from '@nuxt/kit'
import { requireModule, getModulePaths, getNearestPackage } from '../utils/cjs'
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/src/utils/cjs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { normalize, dirname } from 'upath'
import { normalize, dirname } from 'pathe'

export function getModulePaths (paths?: string | string[]): string[] {
return [].concat(
Expand Down
Loading

0 comments on commit 6329a68

Please sign in to comment.