Skip to content

Commit

Permalink
fix(frontend): update and document packages scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
horacioh committed Jan 19, 2023
1 parent 15a8813 commit 0abe5ce
Show file tree
Hide file tree
Showing 20 changed files with 580 additions and 383 deletions.
6 changes: 3 additions & 3 deletions dev
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ def main():
@cmd(cmds, "run-frontend", "Run frontend web app for development.")
def run_frontend(args):
run("plz build //:pnpm")
return run("cd frontend/app && exec pnpm dev", args=args)
return run("exec pnpm app:dev", args=args)

@cmd(cmds, "run-gw-frontend", "Run frontend web app for development.")
def run_frontend(args):
run("plz build //:pnpm")
return run("cd frontend/gateway && exec pnpm dev", args=args)
return run("exec pnpm gw:dev", args=args)

@cmd(cmds, "run-desktop", "Run Tauri desktop app for development.")
def run_desktop(args):
run("plz build //backend:mintterd //:pnpm")
return run("cd desktop/app && cargo tauri dev", args=args)
return run("pnpm tauri:dev", args=args)

@cmd(cmds, "release", "Cut a new release.")
def release(args):
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Because the Mintter Data structure is not production-ready yet, we are creating

## Frontend Technical Documentation

- [Frontend Development Setup](./frontend-dev-setup.md)
- [Frontend App Architecture](./frontend-app.md)
- [Frontend Gateway Architecture](./frontend-gateway.md)
- [Frontend Shared Packages Architecture](./frontend-shared-packages.md)
Expand Down
Binary file added docs/assets/dev-setup-local-run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/dev-setup-root-terminal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions docs/frontend-dev-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Frontend Development Setup

The Mintter Frontend architecture is based on a [pnpm](https://pnpm.io) workspace. Currently we have this packages:

1. App Package: for the desktop app code lives
2. Gateway: for the gateway code
3. Shared: for the shared API-related code
4. UI (soon): for all the design system/common UI building blocks for all the Mintter applications

After you [setup the project](./dev-setup.md) on your local machine, you should have `pnpm` available, so no need to install it globally.

## Prerequisites

Please make sure that after you enter the repo root path, you see something similar to this showing the necessary Environment variables set:

![dev-setup-root-terminal.png](./assets/dev-setup-root-terminal.png)

After this is correct, you should run `pnpm install` (or `pnpm i`) to install all the frontend packages.

## Run the Desktop app locally

because we are using [Nix](./nix.md), we are able to create custom orchestrated commands in order to setup everything properly for any situation. To run the desktop app locally, you just need to run:

```bash
./dev run-desktop
```

This command should trigger a set of processes that eventually should launch the app in dev mode

![Locally running the Desktop app](./assets/dev-setup-local-run.png)

> you can also run `./dev` to print the stript's readme and see all the possible commands/options. You can checkout all the commands [here](../dev)
Keep in mind that `./dev run-desktop` runs both the desktop app **and the go backend**. This is setup this way for convenience and ease of use. You are able to run _just_ the desktop frontend code by running:

```bash
./dev run-frontend
```

> You can also run _just_ the backend with `./dev run-backend`
## Run the Gateway app locally

The same way we can run the desktop app with a `./dev` command, you have access to gateway-specific commands:

```bash
./dev run-gw-frontend # run the gateway frontend _only_ (dev mode)
./dev run-gw-bacend # run the gateway backend _only_ (dev mode)
```

## Shared package

The frontend shared package is wrapping all the API/Backend related code that is shared between both the desktop app and the web gateway. You don't have to manually run any command for this, but you can check the specific commands defined for this package in the [root `package.json`](../package.json).

## Per-package scripts overview

For every frontend package, there's a set of required scripts in order to keep consistency inside all the project:

1. `dev`: run the current package in dev mode.
2. `build`: build the current package.
3. `test`: run all the possible tests inside the current package.
4. `lint`: run all the possible linters inside the current package.
5. `format`: format the code for the current package.
6. `validate`: lint + test the current package.

> if you are creating a new frontend package, please make sure you create this scripts properly and connect them with the appropiate `./dev` script.

21 changes: 9 additions & 12 deletions frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,23 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"dev": "vite",
"typegen": "xstate typegen \"src/**/*.(ts|tsx)\"",
"typegen:w": "pnpm run typegen --watch",
"build": "pnpm run typegen && vite build --outDir dist",
"lint": "pnpm run lint:prettier && pnpm run lint:eslint",
"dev": "concurrently --kill-others --kill-others-on-fail -n APP,TYPEGEN -c bgGreen,bgMagenta 'vite' 'pnpm typegen --watch'",
"build": "pnpm typegen && vite build --outDir dist",
"test": "NODE_ENV=test cypress run --component",
"test:watch": "NODE_ENV=test cypress open --component",
"lint": "pnpm lint:prettier && pnpm lint:eslint",
"lint:eslint": "eslint .",
"lint:prettier": "prettier --check \"**/*.{css,md,js,jsx,json,ts,tsx}\"",
"format": "prettier --write .",
"docs": "typedoc",
"test": "NODE_ENV=test pnpm run test:ui:run",
"test:watch": "pnpm run test:unit:watch && pnpm run test:ui:watch",
"test:ui": "cypress",
"test:ui:run": "pnpm run test:ui run --component",
"test:ui:open": "pnpm run test:ui open --component"
"validate": "pnpm lint && pnpm test",
"typegen": "xstate typegen \"src/**/*.(ts|tsx)\""
},
"dependencies": {
"@mintter/shared": "workspace:*",
"@floating-ui/react-dom": "1.0.1",
"@floating-ui/react-dom-interactions": "0.13.3",
"@improbable-eng/grpc-web": "0.15.0",
"@juggle/resize-observer": "^3.4.0",
"@mintter/shared": "workspace:*",
"@radix-ui/colors": "0.1.8",
"@radix-ui/react-accessible-icon": "1.0.1",
"@radix-ui/react-alert-dialog": "1.0.2",
Expand Down Expand Up @@ -129,6 +125,7 @@
"@xstate/inspect": "0.7.0",
"@xstate/test": "0.5.1",
"clipboardy": "3.0.0",
"concurrently": "7.6.0",
"copy-text-to-clipboard": "3.0.1",
"covector": "0.7.3",
"cypress": "10.11.0",
Expand Down
2 changes: 2 additions & 0 deletions frontend/gateway/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.next
public
85 changes: 46 additions & 39 deletions frontend/gateway/burger-menu.typegen.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
// This file was automatically generated. Edits will be overwritten

// This file was automatically generated. Edits will be overwritten

export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
"done.invoke.resizeObserver": { type: "done.invoke.resizeObserver"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"error.platform.resizeObserver": { type: "error.platform.resizeObserver"; data: unknown };
"xstate.init": { type: "xstate.init" };
};
invokeSrcNameMap: {
"resizeObserver": "done.invoke.resizeObserver";
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
"removeTabIndexToElements": "MENU.DISABLE" | "MENU.OPEN" | "MENU.TOGGLE";
"setElementRef": "MENU.INIT";
"setFocusableElements": "MENU.INIT";
"setObserver": "MENU.OBSERVER.READY";
"setTabIndexToElements": "MENU.CLOSE" | "MENU.ENABLE" | "MENU.TOGGLE";
"startObserver": "MENU.INIT";
};
eventsCausingDelays: {

};
eventsCausingGuards: {

};
eventsCausingServices: {
"resizeObserver": "xstate.init";
};
matchesStates: "disabled" | "enabled" | "enabled.closed" | "enabled.opened" | "idle" | { "enabled"?: "closed" | "opened"; };
tags: never;
}

export interface Typegen0 {
'@@xstate/typegen': true
internalEvents: {
'done.invoke.resizeObserver': {
type: 'done.invoke.resizeObserver'
data: unknown
__tip: 'See the XState TS docs to learn how to strongly type this.'
}
'error.platform.resizeObserver': {
type: 'error.platform.resizeObserver'
data: unknown
}
'xstate.init': {type: 'xstate.init'}
}
invokeSrcNameMap: {
resizeObserver: 'done.invoke.resizeObserver'
}
missingImplementations: {
actions: never
delays: never
guards: never
services: never
}
eventsCausingActions: {
removeTabIndexToElements: 'MENU.DISABLE' | 'MENU.OPEN' | 'MENU.TOGGLE'
setElementRef: 'MENU.INIT'
setFocusableElements: 'MENU.INIT'
setObserver: 'MENU.OBSERVER.READY'
setTabIndexToElements: 'MENU.CLOSE' | 'MENU.ENABLE' | 'MENU.TOGGLE'
startObserver: 'MENU.INIT'
}
eventsCausingDelays: {}
eventsCausingGuards: {}
eventsCausingServices: {
resizeObserver: 'xstate.init'
}
matchesStates:
| 'disabled'
| 'enabled'
| 'enabled.closed'
| 'enabled.opened'
| 'idle'
| {enabled?: 'closed' | 'opened'}
tags: never
}
71 changes: 36 additions & 35 deletions frontend/gateway/machines/publication-machine.typegen.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
// This file was automatically generated. Edits will be overwritten

// This file was automatically generated. Edits will be overwritten

export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
"done.invoke.transformPublication": { type: "done.invoke.transformPublication"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"error.platform.transformPublication": { type: "error.platform.transformPublication"; data: unknown };
"xstate.init": { type: "xstate.init" };
};
invokeSrcNameMap: {
"transformPublication": "done.invoke.transformPublication";
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
"setEditorValue": "PUBLICATION.TRANSFORM.SUCCESS";
"setPublication": "PUBLICATION.FETCH.SUCCESS";
};
eventsCausingDelays: {
};
eventsCausingGuards: {
};
eventsCausingServices: {
"transformPublication": "PUBLICATION.FETCH.SUCCESS";
};
matchesStates: "fetching" | "idle" | "settled" | "transforming";
tags: never;
}
export interface Typegen0 {
'@@xstate/typegen': true
internalEvents: {
'done.invoke.transformPublication': {
type: 'done.invoke.transformPublication'
data: unknown
__tip: 'See the XState TS docs to learn how to strongly type this.'
}
'error.platform.transformPublication': {
type: 'error.platform.transformPublication'
data: unknown
}
'xstate.init': {type: 'xstate.init'}
}
invokeSrcNameMap: {
transformPublication: 'done.invoke.transformPublication'
}
missingImplementations: {
actions: never
delays: never
guards: never
services: never
}
eventsCausingActions: {
setEditorValue: 'PUBLICATION.TRANSFORM.SUCCESS'
setPublication: 'PUBLICATION.FETCH.SUCCESS'
}
eventsCausingDelays: {}
eventsCausingGuards: {}
eventsCausingServices: {
transformPublication: 'PUBLICATION.FETCH.SUCCESS'
}
matchesStates: 'fetching' | 'idle' | 'settled' | 'transforming'
tags: never
}
13 changes: 7 additions & 6 deletions frontend/gateway/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "gateway",
"name": "@mintter/gateway",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "concurrently -n POSTCSS,NEXT -c bgGreen,bgMagenta 'pnpm dev:styles' 'pnpm dev:front'",
"dev": "concurrently --kill-others --kill-others-on-fail -n POSTCSS,NEXT -c bgGreen,bgMagenta 'pnpm dev:styles' 'pnpm dev:front'",
"dev:styles": "nodemon css-props-generator.js",
"dev:front": "next dev",
"build": "concurrently -n POSTCSS,NEXT -c bgGreen,bgMagenta 'pnpm build:styles' 'pnpm build:front'",
"build": "pnpm build:styles && pnpm build:front",
"build:styles": "node css-props-generator.js",
"build:front": "next build",
"start": "next start",
"lint": "next lint",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
"format": "prettier --write .",
"test": "echo 'NO TESTS YET';",
"validate": "pnpm lint && pnpm test",
"start": "next start"
},
"dependencies": {
"@mintter/shared": "workspace:*",
Expand Down
Loading

0 comments on commit 0abe5ce

Please sign in to comment.