publishing-elm-package
This document describes how maintainers can push new releases of morphir-elm into NPM and the Elm package repo.
Publishing the Elm package
The latest elm tooling (0.19.1) has some issues with large docs which impacts finos/morphir-elm. Because of this we had to turn-off the automation so the publishing can only be done manually by a maintainer.
Here are the steps:
- Clone the
finos/morphir-elmrepo to a local workspace. Make sure that it's not a clone of your fork but a clone of the main repo. - Make sure that the clone is up-to-date and you are on the
mainbranch. - Run
elm bump. - If this fails with the
PROBLEM LOADING DOCSerror you will have to use an older version of Elm. - You can install the previous version using
npm install -g elm@0.19.0-no-deps. - Run
elm bumpagain. - This will update the
elm.jsonso you need to add an commit it:git add elm.jsongit commit -m "Bump Elm package version"
- Now you need to create a tag that matches the Elm package version:
git tag -a <elm_package_version> -m "new Elm package release"git push origin <elm_package_version>
- Now you are ready to publish the Elm package:
elm publish
Publishing the NPM package
- Clone the
finos/morphir-elmgithub repo or pull the latest from the master branch if you have a clone already.orgit clone https://github.com/finos/morphir-elm.gitgit pull origin master - Build the CLI.
npm run build - Run
npfor publishing.- If you don't have
npinstalled yet, install it withnpm install -g np
- If you don't have
npwill propmpt you to select the next semantic version number so you'll have to decide if your changes are major, minor or patch.- Note:
npmight say that there has not been any commits. This is normal if you just published the Elm package since it picks up the tag from that one. It is safe to respondyto that question because the rest of the process will use the version number from thepackage.jsonand push a tag with a prefixvso it does not collide with Elm which does not use a prefix.
- Note:
npwill also ask you for credentials.
Verification Instructions
The purpose of this document is to provide a detailed explanation of how to verify a new released version of morphir-elm. The following instructions are to be followed after every release in order to make sure that the release is valid.
Who this Guide is Designed For​
- Business users of Morphir who would want to update the morphir-elm version to the latest release
- Developers who would want to verify the validity of a release
Upgrading morphir-elm to the latest version​
- Run
npm install morphir-elmto upgrade to the latest version. This is the only step you need as a business user to upgrade to a new release ofmorphir-elm
Verifying a morphir-elm release​
After upgrade, a series of commands must be run on a model to verify the release, below are steps to create a minimal model.
Creating a Model​
This is to create a sample model to validate the release. The sample model is called schedule
Create a directory:
mkdir schedule
cd schedule
Next setup the Morphir project and configuration file, morphir.json
mkdir src
echo '{ "name": "Morphir.Example.App", "sourceDirectory": "src", "exposedModules": [ ] }' > morphir.json
Next create the Elm file we would be working with
mkdir src/Morphir
mkdir src/Morphir/Example
touch src/Morphir/Example/Schedule.elm
Next update the morphir.json to reflect the current module.
{
"name": "Morphir.Example",
"sourceDirectory": "src",
"exposedModules": [
"Schedule"
]
}
Finally, to finish up the model paste the following logic in Schedule.elm
module Morphir.Example.Schedule exposing (..)
plan : String -> String
plan day =
"Work Day"
Now we have minimal model to run commands on. Run the following commands to verify a release.
Run
Run morphir-elm maketo verify that an IR(morphir-ir.json) is created.- Use the
-o,--outputflag to specify the location where the Morphir IR will be saved (default:morphir-ir.json) - Use
-p,--project-dirflag to specify the root directory where themorphir.jsonis located.
- Use the
Create
morphir-tests.jsonin the same directory asmorphir-ir.json. This would contain tests generated from the Morphir Develop UI.Run
morphir-elm develop -o localhostand in your browser navigate tohttp://localhost:3000to access the UICreate and save tests using the Morphir develop UI
Run
morphir-elm testtests in your terminal to validate that all tests pass.Run
morphir-elm gento generate target code. Default code generated is Scala. To change the target language generated use the-toption. Eg.morhir-elm gen -t TypeScript.Run
morphir-elm gen -c trueto copy the dependencies used by the generated code to the output pathRun
morphir-statsto generate feature statistics. This command generates a folderstatswhich contains information about features available in the IR
Rollback Instructions​
In the case where an invalid version is published , the developer has to rollback to a previous working version on npm. This involves changing the latest tag on npm to point to a previous working version.
Go to Morphir Elm , click on the versions tab. The last working version is usually a version behind the latest version released. You can find version numbers under
Version HistoryRun the command
npm dist-tag add morphir-elm@<version> latest
This command tags the version specified as the latest