-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpnpm6.go
63 lines (49 loc) · 1.67 KB
/
pnpm6.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package packagemanager
import (
"fmt"
"path/filepath"
"github.com/Masterminds/semver"
)
// Pnpm6Workspaces is a representation of workspace package globs found
// in pnpm-workspace.yaml
type Pnpm6Workspaces struct {
Packages []string `yaml:"packages,omitempty"`
}
var nodejsPnpm6 = PackageManager{
Name: "nodejs-pnpm6",
Slug: "pnpm",
Command: "pnpm",
Specfile: "package.json",
Lockfile: "pnpm-lock.yaml",
PackageDir: "node_modules",
ArgSeparator: []string{"--"},
WorkspaceConfigurationPath: "pnpm-workspace.yaml",
getWorkspaceGlobs: getPnpmWorkspaceGlobs,
getWorkspaceIgnores: getPnpmWorkspaceIgnores,
Matches: func(manager string, version string) (bool, error) {
if manager != "pnpm" {
return false, nil
}
v, err := semver.NewVersion(version)
if err != nil {
return false, fmt.Errorf("could not parse pnpm version: %w", err)
}
c, err := semver.NewConstraint("<7.0.0")
if err != nil {
return false, fmt.Errorf("could not create constraint: %w", err)
}
return c.Check(v), nil
},
detect: func(projectDirectory string, packageManager *PackageManager) (bool, error) {
specfileExists := FileExists(filepath.Join(projectDirectory, packageManager.Specfile))
lockfileExists := FileExists(filepath.Join(projectDirectory, packageManager.Lockfile))
return (specfileExists && lockfileExists), nil
},
canPrune: func(cwd string) (bool, error) {
return true, nil
},
// @FIXME unsuported lockfile
// UnmarshalLockfile: func(contents []byte) (lockfile.Lockfile, error) {
// return lockfile.DecodeNpmLockfile(contents)
// },
}