Skip to content

Commit

Permalink
Merge pull request #20 from nexB/8-pypi
Browse files Browse the repository at this point in the history
Support lockfile generation for python project and drop `update-lockfile` mode for yarn
  • Loading branch information
keshav-space authored Jun 20, 2024
2 parents efafe5c + 05ac73e commit 5326acc
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Supported Ecosystems
- **yarn**: https://yarnpkg.com/
- **swift**: https://www.swift.org/documentation/package-manager/
- **cocoapods**: https://cocoapods.org/
- **pypi**: https://pypi.org/


Installation
Expand Down
45 changes: 45 additions & 0 deletions cmd/pypi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright (c) nexB Inc. and others. All rights reserved.
ScanCode is a trademark of nexB Inc.
SPDX-License-Identifier: Apache-2.0
See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
See https://github.com/nexB/dependency-inspector for support or download.
See https://aboutcode.org for more information about nexB OSS projects.
*/

package cmd

import (
"github.com/nexB/dependency-inspector/internal"
"github.com/spf13/cobra"
)

func pypiCmd() *cobra.Command {
pipFreezeFile := "requirements.deplock"
lockFiles := []string{"Pipfile.lock", pipFreezeFile}
lockGenCommand := []string{"pip", "freeze"}
forced := false

pypiCmd := &cobra.Command{
Use: "pypi [path]",
Short: "Generate lockfile for Python project",
Long: `Create lockfile for Python project if it doesn't exist in the specified [path].
If no path is provided, the command defaults to the current directory.`,
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
internal.CreateLockFile(
lockFiles,
args,
lockGenCommand,
pipFreezeFile,
forced,
)
},
}

pypiCmd.Flags().BoolVarP(&forced, "force", "f", false, "Generate lockfile forcibly, ignoring existing lockfiles")

return pypiCmd
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var ecosystems = []func() *cobra.Command{
yarnCmd,
swiftCmd,
cocoapodsCmd,
pypiCmd,
}

func NewRootCmd() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cmd/yarn.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

func yarnCmd() *cobra.Command {
lockFiles := []string{"yarn.lock"}
lockGenCommand := []string{"yarn", "install", "--mode", "update-lockfile"}
lockGenCommand := []string{"yarn", "install"}
forced := false

yarnCmd := &cobra.Command{
Expand Down

0 comments on commit 5326acc

Please sign in to comment.