Skip to content

Commit

Permalink
fixups for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-olszewski committed Sep 8, 2022
1 parent d1f7137 commit 677bcb6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 48 deletions.
92 changes: 47 additions & 45 deletions cli/internal/lockfile/pnpm_lockfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,64 @@ import (
// PnpmLockfile Go representation of the contents of 'pnpm-lock.yaml'
// Reference https://github.com/pnpm/pnpm/blob/main/packages/lockfile-types/src/index.ts
type PnpmLockfile struct {
Version float32 `yaml:"lockfileVersion"`
Importers map[string]ProjectSnapshot `yaml:"importers"`
Packages map[string]PackageSnapshot `yaml:"packages,omitempty"`
NeverBuiltDeps []string `yaml:"neverBuiltDependencies,omitempty"`
OnlyBuiltDeps []string `yaml:"onlyBuiltDependencies,omitempty"`
Overrides map[string]string `yaml:"overrides,omitempty"`
PackageExtChecksum string `yaml:"packageExtensionsChecksum,omitempty"`
PatchedDeps map[string]PatchFile `yaml:"patchedDependencies,omitempty"`
Version float32 `yaml:"lockfileVersion"`
NeverBuiltDependencies []string `yaml:"neverBuiltDependencies,omitempty"`
OnlyBuiltDependencies []string `yaml:"onlyBuiltDependencies,omitempty"`
Overrides map[string]string `yaml:"overrides,omitempty"`
PackageExtensionsChecksum string `yaml:"packageExtensionsChecksum,omitempty"`
PatchedDependencies map[string]PatchFile `yaml:"patchedDependencies,omitempty"`
Importers map[string]ProjectSnapshot `yaml:"importers"`
Packages map[string]PackageSnapshot `yaml:"packages,omitempty"`
Time map[string]string `yaml:"time,omitempty"`
}

var _ Lockfile = (*PnpmLockfile)(nil)

// ProjectSnapshot Snapshot used to represent projects in the importers section
type ProjectSnapshot struct {
Specifiers map[string]string `yaml:"specifiers"`
Dependencies map[string]string `yaml:"dependencies,omitempty"`
OptionalDependencies map[string]string `yaml:"optionalDependencies,omitempty"`
DevDependencies map[string]string `yaml:"devDependencies,omitempty"`
DependenciesMeta map[string]DependencyMeta `yaml:"dependenciesMeta,omitempty"`
PublishDirectory string `yaml:"publishDirectory,omitempty"`
Specifiers map[string]string `yaml:"specifiers"`
Dependencies map[string]string `yaml:"dependencies,omitempty"`
OptionalDependencies map[string]string `yaml:"optionalDependencies,omitempty"`
DevDependencies map[string]string `yaml:"devDependencies,omitempty"`
DependenciesMeta map[string]DependenciesMeta `yaml:"dependenciesMeta,omitempty"`
PublishDirectory string `yaml:"publishDirectory,omitempty"`
}

// PackageSnapshot Snapshot used to represent a package in the packages setion
type PackageSnapshot struct {
ID string `yaml:"id,omitempty"`

Resolution PackageResolution `yaml:"resolution,flow"`
Engines struct {
ID string `yaml:"id,omitempty"`

// only needed for packages that aren't in npm
Name string `yaml:"name,omitempty"`
Version string `yaml:"version,omitempty"`

Engines struct {
Node string `yaml:"node"`
NPM string `yaml:"npm,omitempty"`
} `yaml:"engines,omitempty,flow"`
CPU []string `yaml:"cpu,omitempty,flow"`
Os []string `yaml:"os,omitempty,flow"`
HasBin bool `yaml:"hasBin,omitempty"`
RequiresBuild bool `yaml:"requiresBuild,omitempty"`
CPU []string `yaml:"cpu,omitempty,flow"`
Os []string `yaml:"os,omitempty,flow"`
LibC []string `yaml:"libc,omitempty"`

Deprecated string `yaml:"deprecated,omitempty"`
HasBin bool `yaml:"hasBin,omitempty"`
Prepare bool `yaml:"prepare,omitempty"`
RequiresBuild bool `yaml:"requiresBuild,omitempty"`

BundledDependencies []string `yaml:"bundledDependencies,omitempty"`
PeerDependencies map[string]string `yaml:"peerDependencies,omitempty"`
PeerDependenciesMeta map[string]struct {
Optional bool `yaml:"optional"`
} `yaml:"peerDependenciesMeta,omitempty"`

Dependencies map[string]string `yaml:"dependencies,omitempty"`
OptionalDependencies map[string]string `yaml:"optionalDependencies,omitempty"`
TransitivePeerDeps []string `yaml:"transitivePeerDependencies,omitempty"`
BundledDependencies []string `yaml:"bundledDependencies,omitempty"`

Dev bool `yaml:"dev"`
Optional bool `yaml:"optional,omitempty"`
Patched bool `yaml:"patched,omitempty"`
Prepare bool `yaml:"prepare,omitempty"`

// only needed for packages that aren't in npm
Name string `yaml:"name,omitempty"`
Version string `yaml:"version,omitempty"`

LibC []string `yaml:"libc,omitempty"`
Deprecated string `yaml:"deprecated,omitempty"`
TransitivePeerDependencies []string `yaml:"transitivePeerDependencies,omitempty"`
Dev bool `yaml:"dev"`
Optional bool `yaml:"optional,omitempty"`
Patched bool `yaml:"patched,omitempty"`
}

// PackageResolution Various resolution strategies for packages
Expand Down Expand Up @@ -102,11 +104,11 @@ func isSupportedVersion(version float32) error {
return errors.Errorf("Unable to generate pnpm-lock.yaml with lockfileVersion: %f. Supported lockfile versions are %v", version, supportedVersions)
}

// DependencyMeta metadata for dependencies
type DependencyMeta struct {
// DependenciesMeta metadata for dependencies
type DependenciesMeta struct {
Injected bool `yaml:"injected,omitempty"`
Node string `yaml:"node,omitempty"`
Patch string `yaml:"string,omitempty"`
Patch string `yaml:"patch,omitempty"`
}

// DecodePnpmLockfile parse a pnpm lockfile
Expand Down Expand Up @@ -179,14 +181,14 @@ func (p *PnpmLockfile) Subgraph(packages []string) (Lockfile, error) {
}

lockfile := PnpmLockfile{
Version: p.Version,
Importers: p.Importers,
Packages: lockfilePackages,
NeverBuiltDeps: p.NeverBuiltDeps,
OnlyBuiltDeps: p.OnlyBuiltDeps,
Overrides: p.Overrides,
PackageExtChecksum: p.PackageExtChecksum,
PatchedDeps: p.PatchedDeps,
Version: p.Version,
Importers: p.Importers,
Packages: lockfilePackages,
NeverBuiltDependencies: p.NeverBuiltDependencies,
OnlyBuiltDependencies: p.OnlyBuiltDependencies,
Overrides: p.Overrides,
PackageExtensionsChecksum: p.PackageExtensionsChecksum,
PatchedDependencies: p.PatchedDependencies,
}

return &lockfile, nil
Expand Down
3 changes: 0 additions & 3 deletions cli/scripts/e2e/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,6 @@ function runSmokeTests<T>(
// Test `turbo prune --scope=a`
// @todo refactor with other package managers
const installArgs = ["--frozen-lockfile"];
if (["pnpm6", "pnpm"].includes(npmClient)) {
installArgs.push("-r");
}
suite(
`${npmClient} + turbo prune${options.cwd ? " from " + options.cwd : ""}`,
async () => {
Expand Down

0 comments on commit 677bcb6

Please sign in to comment.