/frontend-npm-lib-core

MOV.AI npm core library

Primary LanguageTypeScriptOtherNOASSERTION

MOV.AI Core

Movai

The Mov.AI's core frontend library. Here we place all reusable/common code regarding frontend, such as communication with database, authentication, etc. Its main use will be to build Mov.AI applications.

Table of Content

Setting Up Your Development Environment

You can set up your development environment in two ways:

  • In a DevContainer (recommended)
  • Locally

Common Configuration

Configure ~/.npmrc

Ensure that your ~/.npmrc file is configured with the necessary access tokens. The file should look like this:

//npm.pkg.github.com/mov-ai/:_authToken=GITHUB_TOKEN
@mov-ai:registry=https://npm.pkg.github.com/mov-ai/
always-auth=false
engine-strict=true
//registry.npmjs.org/:_authToken=GITHUB_TOKEN
//npm.pkg.github.com/:_authToken=GITHUB_TOKEN

Replace GITHUB_TOKEN with your actual token.

Using a DevContainer (recommended)

  1. Clone the app and libraries (if needed) to $HOME/movai/src/feapps

  2. Open the project in VS Code and reopen in container:

    Open the project directory in VS Code. You should be prompted to reopen the project in a container. Accept this prompt.

Using a Local Setup

Tools Required

Install Node with NVM

To install Node.js using nvm (Node Version Manager), follow these steps:

  1. Install nvm:

    Open your terminal and run the following command to install nvm:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
  2. Load nvm:

    After installing nvm, you need to load it. Close and reopen your terminal, or run:

    source ~/.nvm/nvm.sh
  3. Install the required Node.js version:

    With nvm installed and loaded, run the following command to use the required Node.js version:

    nvm install && nvm use # uses the node version specify in the .nvmrc file
  4. Set the used Node.js as the default version:

    nvm current # prints the node.js version being used
    nvm alias default xx.xx.x # sets xx.xx.x as default
  5. Verify the installation:

    node -v

    This should output the node version specified in .nvmrc file.

Install PNPM

To install pnpm, follow these steps:

  1. Using the required pnpm version:

    The pnpm version required is specify in the package.json file as:

    {
      "packageManager": "pnpm@x.x.x"
    }

    In order to have Node.js use the specified version, run:

    corepack enable

    Upon first use, Corepack downloads the latest version from the network and uses it when running pnpm commands.

Using a DevContainer Setup

Tools Required

Development

How to install this library to an app

    • Install package:
    "pnpm install @mov-ai/mov-fe-lib-core"

How to Link this library locally to an App

You might want to work with this library while seeing the changes in an app. In order to do so, you'll have to provide a path to a local directory that contains this library package. Here's how it can be done:

  1. In the app, identify this library in the package.json:

    "@mov-ai/mov-fe-lib-core": "^x.x.x-X",
    
  2. Replace the library version with the path of this local library:

    "@mov-ai/mov-fe-lib-core": "file:/home/username/path/to/library/frontend-npm-lib-core"
    
  3. Build this local library:

    pnpm install  # installs dependencies
    pnpm buildDev # builds the app and watches for changes
  4. Install and build the app:

    pnpm install  # installs dependencies including the local library
    pnpm start    # runs the app

Testing

Running tests

pnpm run test

Running test on html

A developer can test a build version of this library using the static test html in test/index.html, by running

pnpm run testStatic

Then open the browser at http://localhost:3030/test/index.html