LionWeb-io / lionweb-typescript

Implements (select parts of) the LionWeb specification, and tooling around that - all in TypeScript.
Apache License 2.0
10 stars 4 forks source link

README

license

CI

npm npm npm npm

This repository contains a TypeScript implementation for (parts of) the LionWeb specification – specifically: release version 2023.1 of the LionWeb specification.

Note that this repo doesn't implement the specification completely. In particular:

The implementation of the JSON serialization format, serialization from in-memory representations to that format, and vice versa, are all pretty solid.

Repo org

The implementation is divided up in a number of NPM packages in the directory packages (in order of importance):

Each of these packages have their own README.md. The core, utilities, cli, and validation packages are published in the scope of the lionweb organization, meaning that they're all prefixed with @lionweb/. The other packages are for internal use only. All these packages declare their own NPM semver identification, which isn't directly related to the release version of the LionWeb specification.

Environment dependencies

This repo relies on the following tools being installed:

Note that development tends to be done against the latest LTS (or even more recent) versions of Node.js and NPM.

Development

Commands

Run the following command to setup the project:

npm run clean
npm install
npm run setup

Run the following command to build each of the packages:

# Build the project
npm run build

This includes cleaning up and installing any NPM (dev) dependencies.

The preceding commands can also be run as follows:

npm run initialize

The following command statically style-checks the source code in all the packages:

# Run lint
npm run lint

Note that this does not catch TypeScript compilation errors! (That's because linting only does parsing, not full compilation.)

Run the following command to run the tests:

# Run the tests
npm run test


The output should look similar to this (but much longer):

test

Updating version numbers

To keep the version numbers of the various packages under packages/ aligned throughout this repository, you can use the Node.js script update-package-versions.js. You execute this script as follows from the repo's root:

node update-package-versions.js

This reads the file packages/versions.json and updates the package.json files of all packages under packages/ according to it. This script runs npm install afterward to update the package-lock.json. Inspect the resulting diffs to ensure correctness, and don't forget to run npm install to update the package-lock.json in case you made corrections.

Releasing/publishing packages

Packages are released to the npm registry (website): see the badges at the top of this document. We'll use the terms “release/releasing” from now on, instead of “publication/publishing” as npm itself does. We only release the following packages: core, validation, utilities, cli.

Releasing a package involves the following steps:

  1. Update the version of the package to release in its own package.json.
    1. Also update all references to that package in any package.json in the other packages.
    2. Ensure that the Changelog section of the package to release has been updated properly and fully.
    3. Run npm run initialize to update package-lock.json and catch any (potential) problems.
    4. Commit all changes to the main branch — if necessary, through a PR.
  2. Run the release script of the package:
    npm run release

    This requires access as a member of the lionweb organization on the npm registry — check whether you can access the packages overview page. This step also requires a means of authenticating with npm, e.g. using the Google Authenticator app.

  3. Tag the commit from the 1st step as <package>-<version>, and push the tag.
  4. Update the version of the released package to its next expected beta version, e.g. to 0.7.0-beta.0.
    1. Run npm run initialize to update package-lock.json again.
    2. Commit all changes to the main branch — if necessary, through a PR.

Note that beta releases are different in a couple of ways:

Releasing all (releasable) packages at the same time can be done through the top-level release script. If you do that, you can perform the manual steps above all at the same time, which might save time and commits.

Future work

Currently, we're not using a tool like changesets – including its CLI tool – to manage the versioning and release/publication. That might change in the (near-)future, based on experience with using changesets for the LionWeb repository implementation.

Code style

All the code in this repository is written in TypeScript, with the following code style conventions:

We use prettier with parameters defined in .prettierrc. Note that currently we don't automatically run prettier over the source code.

Containerized development environment

If you prefer not to install the development dependencies on your machine, you can use our containerized development environment for the LionCore TypeScript project. This environment provides a consistent and isolated development environment that is easy to set up and use. To get started, follow the instructions in our containerized development environment guide. However, you can streamline the process by running the following command:

docker run -it --rm --net host --name working-container -v ${PWD}:/work indamutsa/lionweb-devenv:v1.0.0 /bin/zsh

Contributing

We're happy to receive feedback in the form of