diff --git a/bin/src/Main.purs b/bin/src/Main.purs index bd54c5a76..e0ba9c832 100644 --- a/bin/src/Main.purs +++ b/bin/src/Main.purs @@ -860,6 +860,7 @@ mkBuildEnv buildArgs dependencies = do newWorkspace = workspace { buildOptions { output = buildArgs.output <|> workspace.buildOptions.output + , statVerbosity = buildArgs.statVerbosity <|> workspace.buildOptions.statVerbosity } -- Override the backend args from the config if they are passed in through a flag , backend = map @@ -876,10 +877,7 @@ mkBuildEnv buildArgs dependencies = do , git , dependencies , workspace: newWorkspace - , psaCliFlags: - { statVerbosity: buildArgs.statVerbosity - , strict: buildArgs.strict - } + , strictWarnings: buildArgs.strict , pedanticPackages: buildArgs.pedanticPackages } diff --git a/src/Spago/Command/Build.purs b/src/Spago/Command/Build.purs index 26ec89672..4c818494a 100644 --- a/src/Spago/Command/Build.purs +++ b/src/Spago/Command/Build.purs @@ -22,7 +22,6 @@ import Spago.Config as Config import Spago.Git (Git) import Spago.Log (prepareToDie) import Spago.Psa as Psa -import Spago.Psa.Types as PsaTypes import Spago.Purs (Purs) import Spago.Purs.Graph as Graph @@ -32,7 +31,7 @@ type BuildEnv a = , dependencies :: Fetch.PackageTransitiveDeps , logOptions :: LogOptions , workspace :: Workspace - , psaCliFlags :: PsaTypes.PsaOutputOptions + , strictWarnings :: Maybe Boolean , pedanticPackages :: Boolean | a } @@ -49,7 +48,7 @@ run opts = do { dependencies , workspace , logOptions - , psaCliFlags + , strictWarnings , pedanticPackages } <- ask @@ -113,7 +112,7 @@ run opts = do pathDecisions <- liftEffect $ sequence $ Psa.toPathDecisions { allDependencies , selectedPackages: NEA.toArray selectedPackages - , psaCliFlags + , psaCliFlags: { strict: strictWarnings, statVerbosity: workspace.buildOptions.statVerbosity } , censorLibWarnings: workspace.buildOptions.censorLibWarnings } let diff --git a/src/Spago/Command/Publish.purs b/src/Spago/Command/Publish.purs index cf56491e3..271d407b2 100644 --- a/src/Spago/Command/Publish.purs +++ b/src/Spago/Command/Publish.purs @@ -37,7 +37,6 @@ import Spago.Command.Build as Build import Spago.Command.Fetch as Fetch import Spago.Config (Package(..), Workspace, WorkspacePackage) import Spago.Config as Config -import Spago.Config as Core import Spago.Db (Db) import Spago.Git (Git) import Spago.Git as Git @@ -382,10 +381,7 @@ publish _args = do , dependencies: dependencies , logOptions: env.logOptions , workspace: env.workspace { selected = Just selected } - , psaCliFlags: - { statVerbosity: (Nothing :: Maybe Core.StatVerbosity) - , strict: (Nothing :: Maybe Boolean) - } + , strictWarnings: (Nothing :: Maybe Boolean) , pedanticPackages: false } action diff --git a/src/Spago/Config.purs b/src/Spago/Config.purs index 12cdea56b..e0f0444fb 100644 --- a/src/Spago/Config.purs +++ b/src/Spago/Config.purs @@ -1,11 +1,11 @@ module Spago.Config - ( BuildOptions - , BuildType(..) + ( BuildType(..) , Package(..) , PackageSet(..) , PackageMap , WithTestGlobs(..) , Workspace + , WorkspaceBuildOptions , WorkspacePackage , addPackagesToConfig , addRangesToConfig @@ -72,13 +72,13 @@ type Workspace = , packageSet :: PackageSet , compatibleCompiler :: Range , backend :: Maybe Core.BackendConfig - , buildOptions :: BuildOptions + , buildOptions :: WorkspaceBuildOptions , doc :: YamlDoc Core.Config , workspaceConfig :: Core.WorkspaceConfig , rootPackage :: Maybe Core.PackageConfig } -type BuildOptions = +type WorkspaceBuildOptions = { output :: Maybe FilePath , censorLibWarnings :: Maybe Core.CensorBuildWarnings , statVerbosity :: Maybe Core.StatVerbosity @@ -414,7 +414,7 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do ] let - buildOptions :: BuildOptions + buildOptions :: WorkspaceBuildOptions buildOptions = { output: _.output =<< workspace.buildOpts , censorLibWarnings: _.censorLibraryWarnings =<< workspace.buildOpts diff --git a/test-fixtures/censor-stats-output.txt b/test-fixtures/censor-stats-output.txt new file mode 100644 index 000000000..fffe123d7 --- /dev/null +++ b/test-fixtures/censor-stats-output.txt @@ -0,0 +1,9 @@ +Reading Spago workspace configuration... + +✅ Selecting package to build: aaa + +Downloading dependencies... +Building... + + +✅ Build succeeded. diff --git a/test/Spago/Build.purs b/test/Spago/Build.purs index 1e83acdb2..2d6a912a0 100644 --- a/test/Spago/Build.purs +++ b/test/Spago/Build.purs @@ -101,23 +101,30 @@ spec = Spec.around withTempDir do , dst: spagoYaml } spago [ "build" ] >>= shouldBeFailure - - Spec.it "should censor warnings with given errorcode and prefix messsage" \{spago, fixture} -> do + Spec.itOnly "respects the --censor-stats flag" \{ spago, fixture } -> do + spago [ "init", "--name", "aaa" ] >>= shouldBeSuccess + spago [ "build" ] >>= shouldBeSuccess + spago [ "build", "--censor-stats" ] >>= shouldBeSuccessErr (fixture "censor-stats-output.txt") + + Spec.it "should censor warnings with given errorcode and prefix messsage" \{ spago, fixture } -> do FS.copyTree { src: fixture "build/censor-warnings", dst: "." } - - let remainingWarningPath = [ escapePathInErrMsg [ "src", "Main.purs:5:1" ] ] - filteredWarningPath = [ escapePathInErrMsg [ "src", "Main.purs:3:1" ] - , escapePathInErrMsg [ "src", "Main.purs:10:6" ] - ] - - shouldHaveWarning = assertWarning remainingWarningPath true - shouldNotHaveWarning = assertWarning filteredWarningPath false - - spago [ "build" ] >>= check { stdout: mempty - , stderr: fold <<< flap [shouldHaveWarning, shouldNotHaveWarning] - , result: isRight - } + + let + remainingWarningPath = [ escapePathInErrMsg [ "src", "Main.purs:5:1" ] ] + filteredWarningPath = + [ escapePathInErrMsg [ "src", "Main.purs:3:1" ] + , escapePathInErrMsg [ "src", "Main.purs:10:6" ] + ] + + shouldHaveWarning = assertWarning remainingWarningPath true + shouldNotHaveWarning = assertWarning filteredWarningPath false + + spago [ "build" ] >>= check + { stdout: mempty + , stderr: fold <<< flap [ shouldHaveWarning, shouldNotHaveWarning ] + , result: isRight + } Spec.describe "lockfile" do Spec.it "building with a lockfile doesn't need the Registry repo" \{ spago, fixture } -> do @@ -132,7 +139,6 @@ spec = Spec.around withTempDir do -- And that we still don't have the registry FS.exists Paths.registryPath `Assert.shouldReturn` false - Spec.it "using the --pure flag does not refresh the lockfile" \{ spago, fixture } -> do spago [ "init", "--name", "aaa", "--package-set", "33.0.0" ] >>= shouldBeSuccess spago [ "build" ] >>= shouldBeSuccess