Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version to v2.0.0 #27

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ Next Release

-


v2.0.0 (2024-07-02)
----------------

- Add support for generating lockfile and dumping manifest in ``Package.swift.deplock`` for Swift projects.
- Implement lockfile generation for CocoaPods projects.
- Implement lockfile generation for NuGet projects.
- Generate dependency relationships for Swift projects.
- Generate Python dependency relationships using ``pip inspect``.


v1.0.0 (2024-06-13)
-------------------

Expand Down
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ configured to run the project build, with all required package management tools
pre-installed and configured.

The main usage is to run as a front command before a ScanCode.io or ScanCode Toolkit scan
but it is generic and can be used with any other tool.
but it is generic and can be used with any other tool.

See this tutorial on how to Analyze Codebase End-to-End with DepLock, ScanCode.io and DejaCode
https://scancodeio.readthedocs.io/en/latest/tutorial_cli_end_to_end_scanning_to_dejacode.html.

Supported Ecosystems
=====================
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func rootCmd() *cobra.Command {
rootCmd := &cobra.Command{
Use: "deplock",
Short: "DepLock: Dependency Locker CLI",
Version: "1.0.0",
Version: "2.0.0",
}

initConfig(rootCmd)
Expand Down
26 changes: 26 additions & 0 deletions internal/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
"github.com/bmatcuk/doublestar/v4"
)

// CreateLockFile generates lockfile using lockGenCmd command.
//
// If forced is false and any of the specified lockFiles already exist, skip lockfile generation.
// Otherwise, generate the lockfile using lockGenCmd.
func CreateLockFile(lockFiles []string, cmdArgs []string, lockGenCmd []string, outputFileName string, forced bool) {
absPath := getAbsPath(cmdArgs)
if absPath == "" {
Expand All @@ -41,6 +45,10 @@ func CreateLockFile(lockFiles []string, cmdArgs []string, lockGenCmd []string, o

}

// DoesFileExists checks if the file exists at the given absolute path.
//
// If the file exists, print its relative path and return true.
// If the file does not exist, return false.
func DoesFileExists(absPath string) bool {
if _, err := os.Stat(absPath); err == nil {

Expand All @@ -62,6 +70,12 @@ func DoesFileExists(absPath string) bool {
return false
}

// getAbsPath returns the absolute path of a given directory.
//
// If cmdArgs is empty, return the absolute path of the current directory.
// Otherwise, return the absolute path of first arg in cmdArgs.
// If there is an error while retrieving the absolute path, print an error
// message to the standard error and return an empty string.
func getAbsPath(cmdArgs []string) string {
path := "."
if len(cmdArgs) > 0 {
Expand All @@ -77,6 +91,11 @@ func getAbsPath(cmdArgs []string) string {
return absPath
}

// genLock generates a lockfile at absPath using the lockGenCmd command.
//
// Execute lockGenCmd command in the absPath directory.
// If outputFileName is specified, create an output file in absPath and redirect the command's
// output to that file. Print an error message and exit with status 1 if creating the output file fails.
func genLock(lockGenCmd []string, absPath string, outputFileName string) {
fmt.Printf("Generating lockfile at '%s' using '%s'\n", absPath, lockGenCmd)

Expand Down Expand Up @@ -108,6 +127,13 @@ func genLock(lockGenCmd []string, absPath string, outputFileName string) {
fmt.Println("Lock file generated successfully.")
}

// CreateLockFileNuGet generates NuGet lockfile for all NuGet projects found in the directory.
//
// Search for all .csproj files recursively in the project_path.
// If no .csproj files are found, print an error message to standard error and return.
//
// For each .csproj file found, generate corresponding lockfile if force is true or the lockfile
// does not already exist.
func CreateLockFileNuGet(cmdArgs []string, force bool) {
nuGetLockFileName := "packages.lock.json"
nuGetLockFileGenCmd := []string{"dotnet", "restore", "--use-lock-file"}
Expand Down