Skip to content

Commit

Permalink
feat: update pnpm to v10
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Dec 18, 2024
1 parent 2299d25 commit 35b49e5
Show file tree
Hide file tree
Showing 7 changed files with 1,878 additions and 2,267 deletions.
4 changes: 2 additions & 2 deletions e2e/harmony/deps-graph.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
import { generateRandomStr } from '@teambit/toolbox.string.random';
import { DEPS_GRAPH } from '@teambit/harmony.modules.feature-toggle';
import { addDistTag } from '@pnpm/registry-mock';
import { type LockfileFileV9 } from '@pnpm/lockfile.types';
import { type LockfileFile } from '@pnpm/lockfile.types';
import path from 'path';
import chai, { expect } from 'chai';
import stripAnsi from 'strip-ansi';
Expand Down Expand Up @@ -158,7 +158,7 @@ chai.use(require('chai-fs'));
});
describe('sign component and use dependency graph to generate a lockfile', () => {
let signOutput: string;
let lockfile: LockfileFileV9;
let lockfile: LockfileFile;
let signRemote;
before(async () => {
helper.command.export();
Expand Down
3,704 changes: 1,658 additions & 2,046 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'path';
import { DependenciesGraph } from '@teambit/scope.objects';
import { type LockfileFileV9 } from '@pnpm/lockfile.types';
import { type LockfileFile } from '@pnpm/lockfile.types';
import { convertLockfileToGraph, convertGraphToLockfile } from './lockfile-deps-graph-converter';
import { expect } from 'chai';

describe('convertLockfileToGraph simple case', () => {
const lockfile: LockfileFileV9 = {
const lockfile: LockfileFile = {
importers: {
'.': {},
'node_modules/.bit_roots/env': {
Expand Down
16 changes: 8 additions & 8 deletions scopes/dependencies/pnpm/lockfile-deps-graph-converter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ProjectManifest } from '@pnpm/types';
import { type LockfileFileV9, type InlineSpecifiersResolvedDependencies } from '@pnpm/lockfile.types';
import { type LockfileFile, type LockfileFileProjectResolvedDependencies } from '@pnpm/lockfile.types';
import * as dp from '@pnpm/dependency-path';
import { pick, partition } from 'lodash';
import {
Expand All @@ -13,7 +13,7 @@ import { type CalcDepsGraphOptions, type ComponentIdByPkgName } from '@teambit/d
import { getLockfileImporterId } from '@pnpm/lockfile.fs';

function convertLockfileToGraphFromCapsule(
lockfile: LockfileFileV9,
lockfile: LockfileFile,
{
componentRelativeDir,
componentIdByPkgName,
Expand All @@ -32,7 +32,7 @@ function convertLockfileToGraphFromCapsule(
}

function importerDepsToNeighbours(
importerDependencies: InlineSpecifiersResolvedDependencies,
importerDependencies: LockfileFileProjectResolvedDependencies,
lifecycle: 'dev' | 'runtime',
optional: boolean
): DependencyNeighbour[] {
Expand All @@ -45,7 +45,7 @@ function importerDepsToNeighbours(
}

export function convertLockfileToGraph(
lockfile: LockfileFileV9,
lockfile: LockfileFile,
{ pkgName, componentRootDir, componentRelativeDir, componentIdByPkgName }: Omit<CalcDepsGraphOptions, 'rootDir'>
): DependenciesGraph {
if (componentRootDir == null || pkgName == null) {
Expand Down Expand Up @@ -75,7 +75,7 @@ export function convertLockfileToGraph(
}

function _convertLockfileToGraph(
lockfile: LockfileFileV9,
lockfile: LockfileFile,
{
componentIdByPkgName,
directDependencies,
Expand All @@ -92,7 +92,7 @@ function _convertLockfileToGraph(
}

function buildEdges(
lockfile: LockfileFileV9,
lockfile: LockfileFile,
{ directDependencies }: { directDependencies: DependencyNeighbour[] }
): DependencyEdge[] {
const edges: DependencyEdge[] = [];
Expand Down Expand Up @@ -142,7 +142,7 @@ function extractDependenciesFromSnapshot(snapshot: any): DependencyNeighbour[] {
}

function buildPackages(
lockfile: LockfileFileV9,
lockfile: LockfileFile,
{ componentIdByPkgName }: { componentIdByPkgName: ComponentIdByPkgName }
): PackagesMap {
const packages: PackagesMap = new Map();
Expand Down Expand Up @@ -184,7 +184,7 @@ export function convertGraphToLockfile(
graph: DependenciesGraph,
manifests: Record<string, ProjectManifest>,
rootDir: string
): LockfileFileV9 {
): LockfileFile {
const packages = {};
const snapshots = {};
const allEdgeIds = new Set(graph.edges.map(({ id }) => id));
Expand Down
7 changes: 3 additions & 4 deletions scopes/dependencies/pnpm/pnpm.package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { VIRTUAL_STORE_DIR_MAX_LENGTH } from '@teambit/dependencies.pnpm.dep-path';
import { DEPS_GRAPH, isFeatureEnabled } from '@teambit/harmony.modules.feature-toggle';
import { Logger } from '@teambit/logger';
import { type LockfileFileV9 } from '@pnpm/lockfile.types';
import { type LockfileFile } from '@pnpm/lockfile.types';
import fs from 'fs';
import { memoize, omit } from 'lodash';
import { PeerDependencyIssuesByProjects } from '@pnpm/core';
Expand Down Expand Up @@ -85,7 +85,7 @@ export class PnpmPackageManager implements PackageManager {
manifests: Record<string, ProjectManifest>,
rootDir: string
) {
const lockfile: LockfileFileV9 = convertGraphToLockfile(dependenciesGraph, manifests, rootDir);
const lockfile: LockfileFile = convertGraphToLockfile(dependenciesGraph, manifests, rootDir);
Object.assign(lockfile, {
bit: {
restoredFromModel: true,
Expand Down Expand Up @@ -408,8 +408,7 @@ export class PnpmPackageManager implements PackageManager {
},
failOnMissingDependencies: false,
skipped: new Set(),
}),
{ forceSharedFormat: true }
})
);
const graph = convertLockfileToGraph(partialLockfile, opts);
return graph;
Expand Down
4 changes: 2 additions & 2 deletions scopes/scope/objects/models/dependencies-graph.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import semver from 'semver';
import { PackageInfo } from '@pnpm/lockfile.types';
import { LockfilePackageInfo } from '@pnpm/lockfile.types';
import * as dp from '@pnpm/dependency-path';

export type PackagesMap = Map<string, PackageAttributes>;

export type PackageAttributes = PackageInfo & {
export type PackageAttributes = LockfilePackageInfo & {
component?: {
scope: string;
name: string;
Expand Down
Loading

0 comments on commit 35b49e5

Please sign in to comment.