1module Spago.Messages where 2 3import Spago.Prelude 4 5import qualified Data.List.NonEmpty as NonEmpty 6import qualified Data.Text as Text 7 8failedToParseLocalRepo :: Text -> Text 9failedToParseLocalRepo spagoConfigPath = makeMessage 10 [ "ERROR: when importing local packages you should point to their `spago.dhall` file." 11 , "However, the following local package points to: " <> surroundQuote spagoConfigPath 12 ] 13 14cannotFindConfigLocalPackage :: Text -> Text 15cannotFindConfigLocalPackage spagoConfigPath 16 = "ERROR: it was not possible to find a `spago.dhall` file at the following location: " 17 <> surroundQuote spagoConfigPath 18 19failedToParsePackage :: Text -> Text 20failedToParsePackage expr = makeMessage 21 [ "ERROR: could not read a Package configuration." 22 , "For remote packages, this is the expected type of the Package configuration:" 23 , "" 24 , "{ repo : Text, version : Text, dependencies : List Text }" 25 , "" 26 , "For local packages, this is how you should import them:" 27 , "" 28 , "./path/to/some/local/package/spago.dhall as Location" 29 , "" 30 , "..but your package declaration didn't match any of them, and was the following expression instead:" 31 , "" 32 , expr 33 ] 34 35failedToParseRepoString :: Text -> Text 36failedToParseRepoString repo = makeMessage 37 [ "ERROR: was not able to parse the address to the remote repo: " <> surroundQuote repo 38 , "" 39 , "This might be for one of the following reasons:" 40 , "" 41 , "- you're including a local path as a 'repo address', but that's not supported anymore, and you should switch to the new syntax for importing local packages, e.g.:" 42 , "" 43 , " let overrides = { some-package = ./some/local/path/spago.dhall as Location }" 44 , "" 45 , "- you're trying to use a URL which doesn't conform to RFC 3986, e.g. in the form of `git@foo.com:bar/baz.git`." 46 , " The above example can be rewritten in a valid form as \"ssh://git@foo.com/bar/baz.git\"" 47 , "" 48 ] 49 50cannotFindConfig :: Text -> Text 51cannotFindConfig configPath = makeMessage 52 [ "There's no " <> surroundQuote configPath <> " in your current location." 53 , "" 54 , "If you already have a spago project you might be in the wrong subdirectory," 55 , "otherwise you might want to run `spago init` to initialize a new project." 56 ] 57 58cannotFindPackages :: Text 59cannotFindPackages = makeMessage 60 [ "There's no " <> surroundQuote "packages.dhall" <> " in your current location." 61 , "" 62 , "If you already have a spago project you might be in the wrong subdirectory," 63 , "otherwise you might want to run `spago init` to initialize a new package set file." 64 ] 65 66cannotFindPackageImport :: Text 67cannotFindPackageImport = makeMessage 68 [ "Cannot find a package set import in your " <> surroundQuote "packages.dhall" <> "." 69 ] 70 71foundExistingProject :: Text -> Text 72foundExistingProject pathText = makeMessage 73 [ "Found a " <> surroundQuote pathText <> " file, skipping copy. Run `spago init --force` if you wish to overwrite it." 74 ] 75 76foundExistingDirectory :: Text -> Text 77foundExistingDirectory dir 78 = "Found existing directory " <> surroundQuote dir <> ", skipping copy of sample sources" 79 80foundExistingFile :: Text -> Text 81foundExistingFile file 82 = "Found existing file " <> surroundQuote file <> ", not overwriting it" 83 84foundLocalPackage :: Text -> Text -> Text 85foundLocalPackage package path 86 = "Skipping package " <> surroundQuote package <> ", using local path: " <> surroundQuote path 87 88failedToInstallDep :: Text -> Text -> Text 89failedToInstallDep dep err = makeMessage 90 [ "" 91 , "Failed to install dependency " <> dep 92 , "Git output:" 93 , "" 94 , err 95 , "" 96 , "Aborting installation.." 97 ] 98 99failedToReadFile :: Text -> Text 100failedToReadFile file = makeMessage 101 [ "Failed to read " <> surroundQuote file ] 102 103failedToReadPscFile :: Show a => a -> Text 104failedToReadPscFile err = makeMessage 105 [ "WARNING: found a \"psc-package.json\" file, but was not" 106 , "able to read it, skipping the automatic import.." 107 , "This is the error we got:" 108 , "" 109 , tshow err 110 , "" 111 ] 112 113failedToParseFile :: Show a => Text -> a -> Text 114failedToParseFile file err = makeMessage 115 [ "Error while trying to parse " <> surroundQuote file 116 , "Details:" 117 , "" 118 , tshow err 119 ] 120 121failedToParseCommandOutput :: Text -> Text -> Text 122failedToParseCommandOutput command outputText = makeMessage 123 [ "Failed to parse '" <> command <> "' output: " 124 , surroundQuote outputText 125 ] 126 127failedToReachGitHub :: Show a => a -> Text 128failedToReachGitHub err = makeMessage 129 [ "Could not reach GitHub. Error:" 130 , "" 131 , tshow err 132 ] 133 134failedToAddDeps :: NonEmpty Text -> Text 135failedToAddDeps pkgs = makeMessage $ 136 [ "Some of the dependencies you tried to add were not found in the package-set." 137 , "Not adding any new dependencies to your new spago config." 138 , "We didn't find:" 139 ] 140 <> map ("- " <>) (NonEmpty.toList pkgs) 141 <> [""] 142 143updatingPackageSet :: Text -> Text 144updatingPackageSet newTag = makeMessage 145 [ "Updating package-set tag to " <> surroundQuote newTag 146 , "Fetching the new one and generating hashes.. (this might take some time)" 147 ] 148 149nonExistentPackageSet :: Text -> Text -> Text -> Text -> Text 150nonExistentPackageSet org repo oldTag newTag = makeMessage 151 [ "Package-set tag " <> surroundQuote newTag <> " in the repo " <> surroundQuote (org <> "/" <> repo) <> " does not exist." 152 , "Will ignore user-specified tag and continue using current tag: " <> surroundQuote oldTag 153 ] 154 155freezePackageSet :: Text 156freezePackageSet = makeMessage 157 [ "Generating new hashes for the package set file so it will be cached.. (this might take some time)" 158 ] 159 160failedToCheckPackageSetFrozen :: Text 161failedToCheckPackageSetFrozen = makeMessage 162 [ "WARNING: wasn't able to check if your package set import is frozen" 163 ] 164 165failedToCopyToGlobalCache :: Show a => a -> Text 166failedToCopyToGlobalCache err = makeMessage 167 [ "WARNING: was not able to copy the download to the global cache." 168 , "Most likely this comes from permissions not being right, so you could try setting the `XDG_CACHE_HOME` env variable (which determines where the global cache is) to a location which is writable by your user." 169 , "Error was:" 170 , tshow err 171 ] 172 173incompatiblePurs :: [Text] -> Text 174incompatiblePurs versions = makeMessage $ 175 [ "It seems that you're using a compiler version that is not supported by package-sets at the moment." 176 , "Please install one of the following versions of the compiler and try again: " 177 ] 178 <> map ("- " <>) versions 179 <> [""] 180 181pursVersionMismatch :: Text -> Text -> Text 182pursVersionMismatch currentVersion minVersion = makeMessage 183 [ "Oh noes! It looks like the PureScript version installed on your system is not compatible with the package-set you're using." 184 , "" 185 , "installed `purs` version: " <> currentVersion 186 , "minimum package-set version: " <> minVersion 187 , "" 188 , "There are a few ways to solve this:" 189 , "- install a compatible `purs` version (i.e. in the same 'semver range' as the one in the package set)" 190 , "- if the `purs` version is 'too new', you can try using `spago upgrade-set` to upgrade to the latest package set" 191 , "- if you know what you're doing and you want to disable this check, you can override the `version` of the `metadata` package in the packages.dhall, e.g.:" 192 , "" 193 , " let upstream = <package-set url here>" 194 , " in upstream" 195 , " with metadata.version = \"v" <> currentVersion <> "\"" 196 , "" 197 ] 198 199getNewGitHubToken :: Text 200getNewGitHubToken = makeMessage 201 [ "Please obtain a GitHub personal access token at:" 202 , " https://github.com/settings/tokens/new" 203 , "No scopes are required, so don't check any of the boxes." 204 , "" 205 , "After you've done that, assign it to the " <> githubTokenEnvVar <> " environment variable," 206 , "and then call `spago login` again so Spago can pick it up and save it to cache" 207 ] 208 209couldNotVerifySet :: Text 210couldNotVerifySet = "Could not find a valid \"spago.dhall\" or \"packages.dhall\"" 211 212verifying :: Show a => a -> Text 213verifying len = "Verifying " <> tshow len <> " packages, this might take a while.." 214 215bundleCommandRenamed :: Text 216bundleCommandRenamed = 217 "The `bundle` command has been replaced with `bundle-app`, so use that instead." 218 219makeModuleCommandRenamed :: Text 220makeModuleCommandRenamed = 221 "The `make-module` command has been replaced with `bundle-module`, so use that instead." 222 223listPackagesCommandRenamed :: Text 224listPackagesCommandRenamed = 225 "The `list-packages` command has been replaced with `ls packages`, so use that instead." 226 227globsDoNotMatchWhenWatching :: NonEmpty Text -> Text 228globsDoNotMatchWhenWatching patterns = makeMessage $ 229 "WARNING: No matches found when trying to watch the following directories: " : NonEmpty.toList patterns 230 231makeMessage :: [Text] -> Text 232makeMessage = Text.intercalate "\n" 233 234unusedDependency :: [Text] -> Text 235unusedDependency unused = makeMessage $ 236 [ "None of your project files import modules from some projects that are in the direct dependencies of your project." 237 , "These dependencies are unused. To fix this warning, remove the following packages from the list of dependencies in your config:" 238 ] <> map (\package -> "- " <> package) unused 239 240sourceImportsTransitiveDependency :: [Text] -> Text 241sourceImportsTransitiveDependency transitive = makeMessage $ 242 [ "Some of your project files import modules from packages that are not in the direct dependencies of your project." 243 , "To fix this error add the following packages to the list of dependencies in your config:" 244 ] <> map (\package -> "- " <> package) transitive 245 <> [ "You may add these dependencies by running the following command:" 246 , "spago install " <> Text.intercalate " " transitive ] 247