@@ -6,13 +6,15 @@ import Data.Array.NonEmpty as NonEmptyArray
6
6
import Data.Foldable (traverse_ )
7
7
import Data.Map as Map
8
8
import Data.Set as Set
9
+ import Data.String as String
9
10
import Data.String.NonEmpty as NonEmptyString
10
11
import Effect.Aff as Aff
11
12
import Effect.Ref as Ref
12
13
import Node.FS.Aff as FS.Aff
13
14
import Node.Path as Path
14
15
import Node.Process as Process
15
16
import Registry.App.API as API
17
+ import Registry.App.CLI.Tar as Tar
16
18
import Registry.App.Effect.Env as Env
17
19
import Registry.App.Effect.Log as Log
18
20
import Registry.App.Effect.Pursuit as Pursuit
@@ -23,7 +25,10 @@ import Registry.Constants as Constants
23
25
import Registry.Foreign.FSExtra as FS.Extra
24
26
import Registry.Foreign.FastGlob as FastGlob
25
27
import Registry.Foreign.Tmp as Tmp
28
+ import Registry.Internal.Codec as Internal.Codec
29
+ import Registry.Manifest as Manifest
26
30
import Registry.PackageName as PackageName
31
+ import Registry.Range as Range
27
32
import Registry.Test.Assert as Assert
28
33
import Registry.Test.Assert.Run as Assert.Run
29
34
import Registry.Test.Utils as Utils
@@ -52,11 +57,24 @@ spec = do
52
57
removeIgnoredTarballFiles
53
58
copySourceFiles
54
59
60
+ Spec .describe " Parses installed paths" do
61
+ Spec .it " Parses install path <tmp>/my-package-1.0.0/..." do
62
+ tmp <- Tmp .mkTmpDir
63
+ let moduleA = Path .concat [ tmp, " my-package-1.0.0" , " src" , " ModuleA.purs" ]
64
+ case API .parseInstalledModulePath { prefix: tmp, path: moduleA } of
65
+ Left err -> Assert .fail $ " Expected to parse " <> moduleA <> " but got error: " <> err
66
+ Right { name, version } -> do
67
+ Assert .shouldEqual name (Utils .unsafePackageName " my-package" )
68
+ Assert .shouldEqual version (Utils .unsafeVersion " 1.0.0" )
69
+ FS.Extra .remove tmp
70
+
55
71
Spec .describe " API pipelines run correctly" $ Spec .around withCleanEnv do
56
- Spec .it " Publish" \{ workdir, index, metadata, storageDir, githubDir } -> do
72
+ Spec .it " Publish a legacy-converted package with unused deps " \{ workdir, index, metadata, storageDir, githubDir } -> do
57
73
let testEnv = { workdir, index, metadata, username: " jon" , storage: storageDir, github: githubDir }
58
74
Assert.Run .runTestEffects testEnv do
59
- -- We'll publish [email protected]
75
+ -- We'll publish [email protected] from the fixtures/github-packages
76
+ -- directory, which has an unnecessary dependency on 'type-equality'
77
+ -- inserted into it.
60
78
let
61
79
name = Utils .unsafePackageName " effect"
62
80
version = Utils .unsafeVersion " 4.0.0"
@@ -83,11 +101,28 @@ spec = do
83
101
unless (Set .member version versions) do
84
102
Except .throw $ " Expected " <> formatPackageVersion name version <> " to be published to registry storage."
85
103
104
+ -- Let's verify the manifest does not include the unnecessary
105
+ -- 'type-equality' dependency...
106
+ Storage .download name version " effect-result"
107
+ Tar .extract { cwd: workdir, archive: " effect-result" }
108
+ Run .liftAff (readJsonFile Manifest .codec (Path .concat [ " effect-4.0.0" , " purs.json" ])) >>= case _ of
109
+ Left err
-> Except .throw $
" Expected [email protected] to be downloaded to effect-4.0.0 with a purs.json but received error " <> err
110
+ Right (Manifest manifest) -> do
111
+ let expectedDeps = Map .singleton (Utils .unsafePackageName " prelude" ) (Utils .unsafeRange " >=6.0.0 <7.0.0" )
112
+ when (manifest.dependencies /= expectedDeps) do
113
+ Except .throw $ String .joinWith " \n "
114
+ [
" Expected [email protected] to have dependencies"
115
+ , printJson (Internal.Codec .packageMap Range .codec) expectedDeps
116
+ , " \n but got"
117
+ , printJson (Internal.Codec .packageMap Range .codec) manifest.dependencies
118
+ ]
119
+
86
120
-- Finally, we can verify that publishing the package again should fail
87
121
-- since it already exists.
88
122
Except .runExcept (API .publish CurrentPackage publishArgs) >>= case _ of
89
123
Left _ -> pure unit
90
124
Right _ -> Except .throw $ " Expected publishing " <> formatPackageVersion name version <> " twice to fail."
125
+
91
126
where
92
127
withCleanEnv :: (PipelineEnv -> Aff Unit ) -> Aff Unit
93
128
withCleanEnv action = do
0 commit comments