Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 committed Sep 19, 2023
2 parents 202e914 + 97eb873 commit b39fdf4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
33 changes: 12 additions & 21 deletions artifactory/commands/yarn/yarn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package yarn
import (
"bufio"
"encoding/json"
"fmt"
"errors"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -60,33 +60,32 @@ func (yc *YarnCommand) SetArgs(args []string) *YarnCommand {
return yc
}

func (yc *YarnCommand) Run() error {
func (yc *YarnCommand) Run() (err error) {
log.Info("Running Yarn...")
var err error
if err = yc.validateSupportedCommand(); err != nil {
return err
return
}

if err = yc.readConfigFile(); err != nil {
return err
return
}

var filteredYarnArgs []string
yc.threads, _, _, _, filteredYarnArgs, yc.buildConfiguration, err = commandUtils.ExtractYarnOptionsFromArgs(yc.yarnArgs)
if err != nil {
return err
return
}

if err = yc.preparePrerequisites(); err != nil {
return err
return
}

var missingDepsChan chan string
var missingDependencies []string
if yc.collectBuildInfo {
missingDepsChan, err = yc.prepareBuildInfo()
if err != nil {
return err
return
}
go func() {
for depId := range missingDepsChan {
Expand All @@ -97,17 +96,16 @@ func (yc *YarnCommand) Run() error {

restoreYarnrcFunc, err := commandUtils.BackupFile(filepath.Join(yc.workingDirectory, YarnrcFileName), YarnrcBackupFileName)
if err != nil {
return RestoreConfigurationsAndError(nil, restoreYarnrcFunc, err)
return errors.Join(err, restoreYarnrcFunc())
}

backupEnvMap, err := ModifyYarnConfigurations(yc.executablePath, yc.registry, yc.npmAuthIdent)
if err != nil {
return RestoreConfigurationsAndError(nil, restoreYarnrcFunc, err)
return errors.Join(err, restoreYarnrcFunc())
}

yc.buildInfoModule.SetArgs(filteredYarnArgs)
if err = yc.buildInfoModule.Build(); err != nil {
return RestoreConfigurationsAndError(nil, restoreYarnrcFunc, err)
return errors.Join(err, restoreYarnrcFunc())
}

if yc.collectBuildInfo {
Expand All @@ -116,11 +114,11 @@ func (yc *YarnCommand) Run() error {
}

if err = RestoreConfigurationsFromBackup(backupEnvMap, restoreYarnrcFunc); err != nil {
return err
return
}

log.Info("Yarn finished successfully.")
return nil
return
}

func (yc *YarnCommand) ServerDetails() (*config.ServerDetails, error) {
Expand Down Expand Up @@ -165,13 +163,6 @@ func (yc *YarnCommand) readConfigFile() error {
return err
}

func RestoreConfigurationsAndError(envVarsBackup map[string]*string, restoreNpmrcFunc func() error, err error) error {
if restoreErr := RestoreConfigurationsFromBackup(envVarsBackup, restoreNpmrcFunc); restoreErr != nil {
return fmt.Errorf("two errors occurred:\n%s\n%s", restoreErr.Error(), err.Error())
}
return err
}

func (yc *YarnCommand) preparePrerequisites() error {
log.Debug("Preparing prerequisites.")
var err error
Expand Down
2 changes: 1 addition & 1 deletion xray/utils/analyzermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
EntitlementsMinVersion = "3.66.5"
ApplicabilityFeatureId = "contextual_analysis"
AnalyzerManagerZipName = "analyzerManager.zip"
defaultAnalyzerManagerVersion = "1.3.2.2006984"
defaultAnalyzerManagerVersion = "1.3.2.2019257"
minAnalyzerManagerVersionForSast = "1.3"
analyzerManagerDownloadPath = "xsc-gen-exe-analyzer-manager-local/v1"
analyzerManagerDirName = "analyzerManager"
Expand Down

0 comments on commit b39fdf4

Please sign in to comment.