Skip to content

Commit 9cd1209

Browse files
authored
When publishing, check only the published project's dependencies, not all workspace dependencies (#1314)
1 parent ad5a1e3 commit 9cd1209

File tree

8 files changed

+73
-4
lines changed

8 files changed

+73
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Other improvements:
4343
- When the `publish.location` field is missing, `spago publish` will attempt to
4444
figure out the location from Git remotes and write it back to `spago.yaml`.
4545
- Internally Spago uses stricter-typed file paths.
46+
- `spago publish` no longer tries to validate all workspace dependencies, but
47+
only the (transitive) dependencies of the project being published.
4648

4749
## [0.21.0] - 2023-05-04
4850

src/Spago/Command/Publish.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ publish _args = do
9191
logDebug $ "Publishing package " <> strName
9292

9393
-- As first thing we run a build to make sure the package compiles at all
94-
built <- runBuild { selected, dependencies: env.dependencies }
94+
built <- runBuild { selected, dependencies }
9595
( Build.run
9696
{ depsOnly: false
9797
, pursArgs: []
@@ -103,8 +103,8 @@ publish _args = do
103103
Effect.liftEffect Process.exit
104104

105105
-- We then need to check that the dependency graph is accurate. If not, queue the errors
106-
let allCoreDependencies = Fetch.toAllDependencies $ dependencies <#> _ { test = Map.empty }
107-
let globs = Build.getBuildGlobs { rootPath, selected: NEA.singleton selected, withTests: false, dependencies: allCoreDependencies, depsOnly: false }
106+
let coreDependencies = dependencies # Map.lookup name <#> _.core # fromMaybe Map.empty
107+
let globs = Build.getBuildGlobs { rootPath, selected: NEA.singleton selected, withTests: false, dependencies: coreDependencies, depsOnly: false }
108108
eitherGraph <- Graph.runGraph rootPath globs []
109109
case eitherGraph of
110110
Right graph -> do
@@ -206,7 +206,7 @@ publish _args = do
206206
RegistryVersion v -> Right (Tuple pkgName v)
207207
_ -> Left pkgName
208208
)
209-
$ (Map.toUnfoldable allCoreDependencies :: Array _)
209+
$ (Map.toUnfoldable coreDependencies :: Array _)
210210
if Array.length fail > 0 then
211211
addError
212212
$ toDoc
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Reading Spago workspace configuration...
2+
3+
✓ Selecting package to build: root
4+
5+
Downloading dependencies...
6+
Building...
7+
Src Lib All
8+
Warnings 0 0 0
9+
Errors 0 0 0
10+
11+
✓ Build succeeded.
12+
13+
Passed preliminary checks.
14+
‼ Spago is in offline mode - not pushing the git tag v0.0.1
15+
Building again with the build plan from the solver...
16+
Building...
17+
Src Lib All
18+
Warnings 0 0 0
19+
Errors 0 0 0
20+
21+
✓ Build succeeded.
22+
23+
24+
✓ Ready for publishing. Calling the registry..
25+
26+
27+
✘ Spago is offline - not able to call the Registry.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package:
2+
name: root
3+
dependencies:
4+
- prelude: ">=6.0.1 <7.0.0"
5+
- effect: ">=4.0.0 <5.0.0"
6+
publish:
7+
version: 0.0.1
8+
license: MIT
9+
location:
10+
githubOwner: purescript
11+
githubRepo: aaa
12+
workspace:
13+
packageSet:
14+
registry: 62.2.5
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Root where
2+
3+
import Prelude
4+
import Effect (Effect)
5+
6+
main :: Effect Unit
7+
main = pure unit
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package:
2+
name: subdir
3+
dependencies:
4+
- root
5+
- prelude
6+
publish:
7+
version: 0.0.1
8+
license: MIT
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Subdir where
2+
3+
anExport :: String
4+
anExport = "Hello, World!"

test/Spago/Publish.purs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ spec = Spec.around withTempDir do
7878
spago [ "fetch" ] >>= shouldBeSuccess
7979
spago [ "publish", "--offline" ] >>= shouldBeFailureErr (fixture "publish/ready.txt")
8080

81+
Spec.it "#1307 allows other non-published projects to reference local project in the workspace" \{ spago, fixture, testCwd } -> do
82+
FS.copyTree { src: fixture "publish/1307-publish-dependencies", dst: testCwd }
83+
spago [ "build" ] >>= shouldBeSuccess
84+
doTheGitThing
85+
spago [ "fetch" ] >>= shouldBeSuccess
86+
spago [ "publish", "-p", "root", "--offline" ] >>= shouldBeFailureErr (fixture "publish/1307-publish-dependencies/expected-stderr.txt")
87+
8188
Spec.describe "transfer" do
8289

8390
Spec.it "fails if the publish config is not specified" \{ spago, fixture } -> do

0 commit comments

Comments
 (0)