Skip to content

Commit

Permalink
Merge pull request #1266 from AmpersandTarski/release/v4.6.2
Browse files Browse the repository at this point in the history
Release/v4.6.2
  • Loading branch information
hanjoosten authored Dec 2, 2021
2 parents fd2e112 + 40ecb03 commit 51c3de2
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 222 deletions.
7 changes: 6 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Release notes of Ampersand
# Release notes of Ampersand

## Unreleased changes

## v4.6.2 (2 December 2021)

* Upgrade devcontainer to work with ghc-8.10.7 as well. Also some other enhancements like autoformat.
* [Issue #1261](https://github.com/AmpersandTarski/Ampersand/issues/1261) Fix bug on SQL generation, that got broken during the upgrade in version v4.6.1
* [Issue #1262](https://github.com/AmpersandTarski/Ampersand/issues/1262) Fix merge conflicts that unintendedly reintroduced CLI options --force-reinstall-framework, --prototype-framework-version, --customizations

## v4.6.1 (26 November 2021)

Expand Down
4 changes: 2 additions & 2 deletions ampersand.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 2.0
-- see: https://github.com/sol/hpack

name: ampersand
version: 4.6.1
version: 4.6.2
synopsis: Toolsuite for automated design of enterprise information systems.
description: You can define your business processes by means of rules, written in Relation Algebra.
category: Database Design
Expand Down Expand Up @@ -508,7 +508,7 @@ library
Ampersand.Prototype.GenAngularFrontend
Ampersand.Prototype.GenAngularJSFrontend
Ampersand.Prototype.GenBackend
Ampersand.Prototype.GenFramework
Ampersand.Prototype.GenFrontend
Ampersand.Prototype.PHP
Ampersand.Prototype.ProtoUtil
Ampersand.Prototype.TableSpec
Expand Down
4 changes: 2 additions & 2 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ampersand
version: 4.6.1
version: 4.6.2
author: Stef Joosten
maintainer: [email protected]
synopsis: Toolsuite for automated design of enterprise information systems.
Expand Down Expand Up @@ -181,7 +181,7 @@ library:
- Ampersand.Prototype.GenAngularFrontend
- Ampersand.Prototype.GenAngularJSFrontend
- Ampersand.Prototype.GenBackend
- Ampersand.Prototype.GenFramework
- Ampersand.Prototype.GenFrontend
- Ampersand.Prototype.PHP
- Ampersand.Prototype.ProtoUtil
- Ampersand.Prototype.TableSpec
Expand Down
5 changes: 3 additions & 2 deletions src/Ampersand/Commands/Proto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ import Ampersand.Basics
import Ampersand.Core.ShowAStruct
import Ampersand.FSpec
import Ampersand.Misc.HasClasses
import Ampersand.Prototype.GenFramework
import Ampersand.Prototype.GenBackend (doGenBackend)
import Ampersand.Prototype.GenFrontend
import Ampersand.Types.Config
import qualified RIO.Text as T
import System.Directory
import System.FilePath

-- | Builds a prototype of the current project.
proto ::
(Show env, HasRunner env, HasFSpecGenOpts env, HasZwolleVersion env, HasDirPrototype env, HasGenerateFrontend env, HasGenerateBackend env, HasGenerateMetamodel env) =>
(Show env, HasRunner env, HasFSpecGenOpts env, HasDirPrototype env, HasGenerateFrontend env, HasGenerateBackend env, HasGenerateMetamodel env) =>
FSpec ->
RIO env ()
proto fSpec = do
Expand Down
26 changes: 2 additions & 24 deletions src/Ampersand/Misc/HasClasses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,6 @@ class HasShowWarnings a where
instance HasDaemonOpts a => HasShowWarnings a where
showWarningsL = daemonOptsL . lens xshowWarnings (\x y -> x {xshowWarnings = y})

class HasDirCustomizations a where
dirCustomizationsL :: Lens' a (Maybe [FilePath]) -- the directories that are copied after generating the prototype

instance HasDirCustomizations ProtoOpts where
dirCustomizationsL = lens xdirCustomizations (\x y -> x {xdirCustomizations = y})

class HasZwolleVersion a where
zwolleVersionL :: Lens' a FilePath -- the version in github of the prototypeFramework. can be a tagname, a branchname or a SHA

instance HasZwolleVersion ProtoOpts where
zwolleVersionL = lens xzwolleVersion (\x y -> x {xzwolleVersion = y})

class HasDirOutput a where
dirOutputL :: Lens' a FilePath -- the directory to generate the output in.

Expand Down Expand Up @@ -203,9 +191,6 @@ class HasVersion a where

class HasProtoOpts env where
protoOptsL :: Lens' env ProtoOpts
forceReinstallFrameworkL :: Lens' env Bool
forceReinstallFrameworkL =
protoOptsL . lens xforceReinstallFramework (\x y -> x {xforceReinstallFramework = y})
frontendVersionL :: Lens' env FrontendVersion
frontendVersionL = protoOptsL . lens xfrontendVersion (\x y -> x {xfrontendVersion = y})

Expand Down Expand Up @@ -355,13 +340,9 @@ instance HasOptions InputOutputOpts where

-- | Options for @ampersand proto@.
data ProtoOpts = ProtoOpts
{ -- | when true, an existing prototype directory will be destroyed and re-installed
xforceReinstallFramework :: !Bool,
x1OutputLanguage :: !(Maybe Lang),
{ x1OutputLanguage :: !(Maybe Lang),
x1fSpecGenOpts :: !FSpecGenOpts,
xdirPrototype :: !(Maybe FilePath),
xdirCustomizations :: !(Maybe [FilePath]),
xzwolleVersion :: !FilePath,
xgenerateFrontend :: !Bool,
xgenerateBackend :: !Bool,
xfrontendVersion :: !FrontendVersion,
Expand All @@ -371,13 +352,10 @@ data ProtoOpts = ProtoOpts

instance HasOptions ProtoOpts where
optsList opts =
[ ("--force-reinstall-framework", tshow $ xforceReinstallFramework opts),
("--language", tshow $ x1OutputLanguage opts)
[ ("--language", tshow $ x1OutputLanguage opts)
]
<> optsList (x1fSpecGenOpts opts)
<> [ ("--proto-dir", maybe "" tshow $ xdirPrototype opts),
("--customizations", maybe "" (T.intercalate "; " . fmap T.pack) $ xdirCustomizations opts),
("--prototype-framework-version", tshow $ xzwolleVersion opts),
("--[no-]frontend", tshow $ xgenerateFrontend opts),
("--[no-]backend", tshow $ xgenerateBackend opts),
("--frontend-version", tshow $ xfrontendVersion opts),
Expand Down
39 changes: 1 addition & 38 deletions src/Ampersand/Options/ProtoOptsParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Ampersand.Misc.Defaults (defaultDirPrototype)
import Ampersand.Misc.HasClasses
import Ampersand.Options.FSpecGenOptsParser
import Ampersand.Options.Utils
import Data.List.Split (splitWhen)
import Options.Applicative
import Options.Applicative.Builder.Extra
import RIO.Char (toLower)
Expand All @@ -14,12 +13,9 @@ protoOptsParser :: Parser ProtoOpts
protoOptsParser =
standardToProtoType
<$> ( ProtoOpts
<$> forceReinstallP
<*> outputLanguageP
<$> outputLanguageP
<*> fSpecGenOptsParser False
<*> optional dirPrototypeP
<*> optional dirCustomizationsP
<*> zwolleVersionP
<*> generateFrontendP
<*> generateBackendP
<*> frontendVersionP
Expand All @@ -32,16 +28,6 @@ protoOptsParser =
Standard -> set recipeL Prototype opts
_ -> opts

forceReinstallP :: Parser Bool
forceReinstallP =
switch
( long "force-reinstall-framework"
<> help
( "Re-install the prototype framework. This discards any previously "
<> "installed version."
)
)

dirPrototypeP :: Parser String
dirPrototypeP =
strOption
Expand All @@ -52,29 +38,6 @@ protoOptsParser =
<> help "Specify the directory where the prototype will be generated"
)

dirCustomizationsP :: Parser [String]
dirCustomizationsP =
splitWhen (== ';')
<$> strOption
( long "customizations"
<> metavar "DIR;DIR;.."
<> help "Copy one or more directories into the generated prototype. "
)

zwolleVersionP :: Parser String
zwolleVersionP =
strOption
( long "prototype-framework-version"
<> metavar "VERSION"
<> value "v1.6.0"
<> showDefault
<> help
( "Tag, branch or SHA of the prototype framework on Github. "
<> "Normally you shouldn't need to use anohter version "
<> "than the default. Only a developer of the framework "
<> "can make good use of it. "
)
)
frontendVersionP :: Parser FrontendVersion
frontendVersionP =
toFrontendVersion
Expand Down
29 changes: 5 additions & 24 deletions src/Ampersand/Prototype/GenAngularJSFrontend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Ampersand.Prototype.GenAngularJSFrontend
( genViewInterfaces,
genControllerInterfaces,
genRouteProvider,
copyCustomizations,
)
where

Expand All @@ -20,7 +19,6 @@ import Ampersand.Runners (logLevel)
import Ampersand.Types.Config
import qualified RIO.List as L
import qualified RIO.Text as T
import System.Directory
import System.FilePath
import Text.StringTemplate
( StringTemplate,
Expand All @@ -33,28 +31,11 @@ import Text.StringTemplate
)
import Text.StringTemplate.GenericStandard ()

copyCustomizations ::
(HasDirPrototype env, HasFSpecGenOpts env, HasDirCustomizations env, HasLogFunc env) =>
RIO env ()
copyCustomizations = do
env <- ask
dirCustomizations <- view dirCustomizationsL
let dirPrototype = getDirPrototype env
let custDirs = maybe [] (map (dirSource env </>)) dirCustomizations
mapM_ (copyDir dirPrototype) custDirs
where
copyDir ::
(HasLogFunc env) =>
FilePath ->
FilePath ->
RIO env ()
copyDir targetDir sourceDir = do
sourceDirExists <- liftIO $ doesDirectoryExist sourceDir
if sourceDirExists
then do
logDebug $ "Copying customizations from " <> display (T.pack sourceDir) <> " -> " <> display (T.pack targetDir)
copyDirRecursively sourceDir targetDir -- recursively copy all customizations
else logDebug $ "No customizations (there is no directory " <> display (T.pack sourceDir) <> ")"
-- For useful info on the template language, see
-- https://theantlrguy.atlassian.net/wiki/spaces/ST/pages/1409038/StringTemplate+cheat+sheet
-- NOTE: due to a bug in HStringTemplate's checkTemplateDeep, non-existent attribute names on
-- composite attributes in anonymous templates will hang the generator :-(
-- Eg. "$subObjects:{subObj| .. $subObj.nonExistentField$ .. }$"

------ Generate RouteProvider.js

Expand Down
Loading

0 comments on commit 51c3de2

Please sign in to comment.