mirror of
https://github.com/anoma/juvix.git
synced 2024-12-21 05:41:49 +03:00
68d4314c78
This PR: * Modifies entry point `_entryPointBuildDir` to use the `BuildDir` type instead of `SomeBase Dir`. This allows delayed resolution of the default build directory which was useful for the Package -> Concrete translation point below. * Modifies `juvix dev root` to render the current package as a Package.juvix file. * Modifies the Package -> Concrete translation to recognise default arguments. So, for example, an empty `juvix.yaml` file will be translated into the following (instead of the `name`, `version`, and `dependencies` arguments being populated). module Package; import Stdlib.Prelude open; import PackageDescription.V1 open; package : Package := defaultPackage; * Adds a temporary command (removed when juvix.yaml support is removed) `juvix dev migrate-juvix-yaml` that translates `juvix.yaml` into an equivalent `Package.juvix` in the current project. * Adds a temporary script `migrate-juvix-yaml.sh` (removed when juvix.yaml support is removed) which can be run in the project to translate all Juvix projects in the repository. * Actually translate all of the `juvix.yaml` files to `Package.juvix` using the script. * Part of https://github.com/anoma/juvix/issues/2487
21 lines
800 B
Haskell
21 lines
800 B
Haskell
module Commands.Dev.MigrateJuvixYaml where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.MigrateJuvixYaml.Options
|
|
import Commands.Extra.Package
|
|
import Juvix.Extra.Paths
|
|
|
|
runCommand :: forall r. (Members '[Embed IO, Files, App] r) => MigrateJuvixYamlOptions -> Sem r ()
|
|
runCommand MigrateJuvixYamlOptions {..} = do
|
|
pkgDir <- askPkgDir
|
|
isGlobalPackage <- askPackageGlobal
|
|
let pkgFilePath = pkgDir <//> packageFilePath
|
|
pkgFileExists <- fileExists' pkgFilePath
|
|
pkg <- askPackage
|
|
if
|
|
| isGlobalPackage -> exitMsg (ExitFailure 1) "No Package file found"
|
|
| not pkgFileExists || _migrateJuvixYamlOptionsForce -> do
|
|
writePackageFile pkgDir pkg
|
|
removeFile' (pkgDir <//> juvixYamlFile)
|
|
| otherwise -> exitMsg (ExitFailure 1) (show pkgFilePath <> " already exists.")
|