Skip to content

Commit

Permalink
Merge pull request #399 from atls/sync/yarn-test-utils
Browse files Browse the repository at this point in the history
sync(yarn-test-utils): dependencies, adjustments
  • Loading branch information
Nelfimov authored Aug 21, 2024
2 parents cf1e445 + 21bd60d commit 2571a3a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .yarn/releases/yarn.cjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1481,9 +1481,9 @@ __metadata:
version: 0.0.0-use.local
resolution: "@atls/yarn-test-utils@workspace:yarn/test-utils"
dependencies:
"@yarnpkg/core": "npm:^4.0.5"
"@yarnpkg/fslib": "npm:^3.1.0"
"@yarnpkg/plugin-pack": "npm:^4.0.0"
"@yarnpkg/core": "npm:4.1.2"
"@yarnpkg/fslib": "npm:3.1.0"
"@yarnpkg/plugin-pack": "npm:4.0.0"
pkg-tests-core: "file:./cache/pkg-tests-core.tgz"
pkg-tests-fixtures: "file:cache/pkg-tests-fixtures.tgz"
languageName: unknown
Expand Down
6 changes: 3 additions & 3 deletions yarn/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"yarn:download": "yarn node ./scripts/download-yarn-tests-packages.script.mjs"
},
"dependencies": {
"@yarnpkg/core": "^4.0.5",
"@yarnpkg/fslib": "^3.1.0",
"@yarnpkg/plugin-pack": "^4.0.0",
"@yarnpkg/core": "4.1.2",
"@yarnpkg/fslib": "3.1.0",
"@yarnpkg/plugin-pack": "4.0.0",
"pkg-tests-core": "file:./cache/pkg-tests-core.tgz",
"pkg-tests-fixtures": "file:cache/pkg-tests-fixtures.tgz"
},
Expand Down
14 changes: 12 additions & 2 deletions yarn/test-utils/src/package.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import type { PortablePath } from '@yarnpkg/fslib'
import type { Filename } from '@yarnpkg/fslib'

import { Configuration } from '@yarnpkg/core'
import { Manifest } from '@yarnpkg/core'
import { Project } from '@yarnpkg/core'
import { WorkspaceResolver } from '@yarnpkg/core'
import { ThrowReport } from '@yarnpkg/core'
import { scriptUtils } from '@yarnpkg/core'
import { xfs } from '@yarnpkg/fslib'
import { ppath } from '@yarnpkg/fslib'
import { packUtils } from '@yarnpkg/plugin-pack'
Expand Down Expand Up @@ -84,8 +86,16 @@ export class PackageUtils {
return target
}

await scriptUtils.maybeExecuteWorkspaceLifecycleScript(workspace, 'prepack', {
report: new ThrowReport(),
})

const manifestPath = ppath.join(workspace.cwd, Manifest.fileName)

if (await xfs.existsPromise(manifestPath))
await workspace.manifest.loadFile(manifestPath, { baseFs: xfs })
await packUtils.prepareForPack(workspace, { report: new ThrowReport() }, async () => {
for (const descriptor of workspace.manifest.dependencies.values()) {
for await (const descriptor of workspace.manifest.dependencies.values()) {
if (descriptor.range.startsWith(WorkspaceResolver.protocol)) {
const dependent = project.tryWorkspaceByDescriptor(descriptor)

Expand All @@ -101,7 +111,7 @@ export class PackageUtils {
}
}

for (const descriptor of workspace.manifest.devDependencies.values()) {
for await (const descriptor of workspace.manifest.devDependencies.values()) {
if (descriptor.range.startsWith(WorkspaceResolver.protocol)) {
const dependent = project.tryWorkspaceByDescriptor(descriptor)

Expand Down
4 changes: 2 additions & 2 deletions yarn/test-utils/src/tests.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const makeTemporaryEnv = (
const { devDependencies } = (packageJson as Record<string, Record<string, string>>) || {}

if (dependencies) {
for (const dep of Object.keys(dependencies)) {
for await (const dep of Object.keys(dependencies)) {
if (dependencies[dep].startsWith(WorkspaceResolver.protocol)) {
// eslint-disable-next-line no-await-in-loop
dependencies[dep] = await packageUtils.pack(dep)
Expand All @@ -25,7 +25,7 @@ export const makeTemporaryEnv = (
}

if (devDependencies) {
for (const dep of Object.keys(devDependencies)) {
for await (const dep of Object.keys(devDependencies)) {
if (devDependencies[dep].startsWith(WorkspaceResolver.protocol)) {
// eslint-disable-next-line no-await-in-loop
devDependencies[dep] = await packageUtils.pack(dep)
Expand Down

0 comments on commit 2571a3a

Please sign in to comment.