diff --git a/CHANGELOG.md b/CHANGELOG.md index 82e513f55..c1239f3c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ Other improvements: - When the `publish.location` field is missing, `spago publish` will attempt to figure out the location from Git remotes and write it back to `spago.yaml`. - Internally Spago uses stricter-typed file paths. +- `spago publish` no longer tries to validate all workspace dependencies, but + only the (transitive) dependencies of the project being published. ## [0.21.0] - 2023-05-04 diff --git a/src/Spago/Command/Publish.purs b/src/Spago/Command/Publish.purs index 91ef2a596..58477124f 100644 --- a/src/Spago/Command/Publish.purs +++ b/src/Spago/Command/Publish.purs @@ -91,7 +91,7 @@ publish _args = do logDebug $ "Publishing package " <> strName -- As first thing we run a build to make sure the package compiles at all - built <- runBuild { selected, dependencies: env.dependencies } + built <- runBuild { selected, dependencies } ( Build.run { depsOnly: false , pursArgs: [] @@ -103,8 +103,8 @@ publish _args = do Effect.liftEffect Process.exit -- We then need to check that the dependency graph is accurate. If not, queue the errors - let allCoreDependencies = Fetch.toAllDependencies $ dependencies <#> _ { test = Map.empty } - let globs = Build.getBuildGlobs { rootPath, selected: NEA.singleton selected, withTests: false, dependencies: allCoreDependencies, depsOnly: false } + let coreDependencies = dependencies # Map.lookup name <#> _.core # fromMaybe Map.empty + let globs = Build.getBuildGlobs { rootPath, selected: NEA.singleton selected, withTests: false, dependencies: coreDependencies, depsOnly: false } eitherGraph <- Graph.runGraph rootPath globs [] case eitherGraph of Right graph -> do @@ -206,7 +206,7 @@ publish _args = do RegistryVersion v -> Right (Tuple pkgName v) _ -> Left pkgName ) - $ (Map.toUnfoldable allCoreDependencies :: Array _) + $ (Map.toUnfoldable coreDependencies :: Array _) if Array.length fail > 0 then addError $ toDoc diff --git a/test-fixtures/publish/1307-publish-dependencies/expected-stderr.txt b/test-fixtures/publish/1307-publish-dependencies/expected-stderr.txt new file mode 100644 index 000000000..adbef385b --- /dev/null +++ b/test-fixtures/publish/1307-publish-dependencies/expected-stderr.txt @@ -0,0 +1,27 @@ +Reading Spago workspace configuration... + +✓ Selecting package to build: root + +Downloading dependencies... +Building... + Src Lib All +Warnings 0 0 0 +Errors 0 0 0 + +✓ Build succeeded. + +Passed preliminary checks. +‼ Spago is in offline mode - not pushing the git tag v0.0.1 +Building again with the build plan from the solver... +Building... + Src Lib All +Warnings 0 0 0 +Errors 0 0 0 + +✓ Build succeeded. + + +✓ Ready for publishing. Calling the registry.. + + +✘ Spago is offline - not able to call the Registry. diff --git a/test-fixtures/publish/1307-publish-dependencies/spago.yaml b/test-fixtures/publish/1307-publish-dependencies/spago.yaml new file mode 100644 index 000000000..a4a237fbc --- /dev/null +++ b/test-fixtures/publish/1307-publish-dependencies/spago.yaml @@ -0,0 +1,14 @@ +package: + name: root + dependencies: + - prelude: ">=6.0.1 <7.0.0" + - effect: ">=4.0.0 <5.0.0" + publish: + version: 0.0.1 + license: MIT + location: + githubOwner: purescript + githubRepo: aaa +workspace: + packageSet: + registry: 62.2.5 diff --git a/test-fixtures/publish/1307-publish-dependencies/src/Main.purs b/test-fixtures/publish/1307-publish-dependencies/src/Main.purs new file mode 100644 index 000000000..27535aacf --- /dev/null +++ b/test-fixtures/publish/1307-publish-dependencies/src/Main.purs @@ -0,0 +1,7 @@ +module Root where + +import Prelude +import Effect (Effect) + +main :: Effect Unit +main = pure unit diff --git a/test-fixtures/publish/1307-publish-dependencies/subdir/spago.yaml b/test-fixtures/publish/1307-publish-dependencies/subdir/spago.yaml new file mode 100644 index 000000000..a8578e017 --- /dev/null +++ b/test-fixtures/publish/1307-publish-dependencies/subdir/spago.yaml @@ -0,0 +1,8 @@ +package: + name: subdir + dependencies: + - root + - prelude + publish: + version: 0.0.1 + license: MIT diff --git a/test-fixtures/publish/1307-publish-dependencies/subdir/src/Main.purs b/test-fixtures/publish/1307-publish-dependencies/subdir/src/Main.purs new file mode 100644 index 000000000..b3f79c73a --- /dev/null +++ b/test-fixtures/publish/1307-publish-dependencies/subdir/src/Main.purs @@ -0,0 +1,4 @@ +module Subdir where + +anExport :: String +anExport = "Hello, World!" diff --git a/test/Spago/Publish.purs b/test/Spago/Publish.purs index b6f15cf00..7d319ab55 100644 --- a/test/Spago/Publish.purs +++ b/test/Spago/Publish.purs @@ -78,6 +78,13 @@ spec = Spec.around withTempDir do spago [ "fetch" ] >>= shouldBeSuccess spago [ "publish", "--offline" ] >>= shouldBeFailureErr (fixture "publish/ready.txt") + Spec.it "#1307 allows other non-published projects to reference local project in the workspace" \{ spago, fixture, testCwd } -> do + FS.copyTree { src: fixture "publish/1307-publish-dependencies", dst: testCwd } + spago [ "build" ] >>= shouldBeSuccess + doTheGitThing + spago [ "fetch" ] >>= shouldBeSuccess + spago [ "publish", "-p", "root", "--offline" ] >>= shouldBeFailureErr (fixture "publish/1307-publish-dependencies/expected-stderr.txt") + Spec.describe "transfer" do Spec.it "fails if the publish config is not specified" \{ spago, fixture } -> do