Skip to content

Commit

Permalink
chore: replace deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Nov 14, 2024
1 parent 06e6d3a commit 14c6bb6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/browser/src/node/commands/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { isFileServingAllowed } from 'vitest/node'

function assertFileAccess(path: string, project: WorkspaceProject) {
if (
!isFileServingAllowed(path, project.server)
&& !isFileServingAllowed(path, project.ctx.server)
!isFileServingAllowed(path, project.vite)
&& !isFileServingAllowed(path, project.vitest.server)
) {
throw new Error(
`Access denied to "${path}". See Vite config documentation for "server.fs": https://vitejs.dev/config/server-options.html#server-fs-strict.`,
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,14 @@ export class Vitest {
}
deps.add(filepath)

const mod = project.server.moduleGraph.getModuleById(filepath)
const mod = project.vite.moduleGraph.getModuleById(filepath)
const transformed = mod?.ssrTransformResult || await project.vitenode.transformRequest(filepath)
if (!transformed) {
return
}
const dependencies = [...transformed.deps || [], ...transformed.dynamicDeps || []]
await Promise.all(dependencies.map(async (dep) => {
const path = await project.server.pluginContainer.resolveId(dep, filepath, { ssr: true })
const path = await project.vite.pluginContainer.resolveId(dep, filepath, { ssr: true })
const fsPath = path && !path.external && path.id.split('?')[0]
if (fsPath && !fsPath.includes('node_modules') && !deps.has(fsPath) && existsSync(fsPath)) {
await addImports(project, fsPath)
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/node/pools/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export function createMethodsRPC(project: TestProject, options: MethodsOptions =
},
resolveSnapshotPath(testPath: string) {
return ctx.snapshot.resolvePath<ResolveSnapshotPathHandlerContext>(testPath, {
config: project.getSerializableConfig(),
config: project.serializedConfig,
})
},
async getSourceMap(id, force) {
if (force) {
const mod = project.server.moduleGraph.getModuleById(id)
const mod = project.vite.moduleGraph.getModuleById(id)
if (mod) {
project.server.moduleGraph.invalidateModule(mod)
project.vite.moduleGraph.invalidateModule(mod)
}
}
const r = await project.vitenode.transformRequest(id)
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/node/reporters/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class BlobReporter implements Reporter {
(project) => {
return [
project.getName(),
[...project.server.moduleGraph.idToModuleMap.entries()].map<SerializedModuleNode | null>((mod) => {
[...project.vite.moduleGraph.idToModuleMap.entries()].map<SerializedModuleNode | null>((mod) => {
if (!mod[1].file) {
return null
}
Expand Down Expand Up @@ -136,10 +136,10 @@ export async function readBlobs(
return
}
moduleIds.forEach(([moduleId, file, url]) => {
const moduleNode = project.server.moduleGraph.createFileOnlyEntry(file)
const moduleNode = project.vite.moduleGraph.createFileOnlyEntry(file)
moduleNode.url = url
moduleNode.id = moduleId
project.server.moduleGraph.idToModuleMap.set(moduleId, moduleNode)
project.vite.moduleGraph.idToModuleMap.set(moduleId, moduleNode)
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/workspace/resolveWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export async function resolveWorkspace(
: [' ']
throw new Error([
`Project name "${name}"`,
project.server.config.configFile ? ` from "${relative(vitest.config.root, project.server.config.configFile)}"` : '',
project.vite.config.configFile ? ` from "${relative(vitest.config.root, project.vite.config.configFile)}"` : '',
' is not unique.',
duplicate?.server.config.configFile ? ` The project is already defined by "${relative(vitest.config.root, duplicate.server.config.configFile)}".` : '',
duplicate?.vite.config.configFile ? ` The project is already defined by "${relative(vitest.config.root, duplicate.vite.config.configFile)}".` : '',
filesError,
'All projects in a workspace should have unique names. Make sure your configuration is correct.',
].join(''))
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/utils/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function getModuleGraph(
await get(project.browser.vite.moduleGraph.getModuleById(id))
}
else {
await get(project.server.moduleGraph.getModuleById(id))
await get(project.vite.moduleGraph.getModuleById(id))
}

return {
Expand Down

0 comments on commit 14c6bb6

Please sign in to comment.