Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Mar 9, 2022
1 parent c764fef commit 3034e59
Show file tree
Hide file tree
Showing 46 changed files with 1,059 additions and 677 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build/
node_modules/
/src/server_manager/messages/
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"bracketSpacing": false,
"printWidth": 100
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ again.
All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.
information on using pull requests.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@ The system comprises the following components:

See [`src/metrics_server`](src/metrics_server)


## Code Prerequisites

In order to build and run the code, you need the following installed:
- [Node](https://nodejs.org/en/download/) LTS (`lts/gallium`, version `16.13.0`)
- [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) (version `8.1.0`)
- Manager-specic
- [Wine](https://www.winehq.org/download), if you would like to generate binaries for Windows.
- Server-specific
- [Docker](https://docs.docker.com/engine/install/), to build the Docker image and to run the integration test.
- [docker-compose](https://docs.docker.com/compose/install/), to run the integration test.

- [Node](https://nodejs.org/en/download/) LTS (`lts/gallium`, version `16.13.0`)
- [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) (version `8.1.0`)
- Manager-specic
- [Wine](https://www.winehq.org/download), if you would like to generate binaries for Windows.
- Server-specific
- [Docker](https://docs.docker.com/engine/install/), to build the Docker image and to run the integration test.
- [docker-compose](https://docs.docker.com/compose/install/), to run the integration test.

> 💡 NOTE: if you have `nvm` installed, run `nvm use` to switch to the correct node version!
Install dependencies with:

```sh
npm install
```

This project uses [NPM workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces/).


## Build System

We have a very simple build system based on package.json scripts that are called using `npm run`
and a thin wrapper for what we call build "actions".

We've defined a package.json script called `action` whose parameter is a relative path:

```shell
npm run action $ACTION
```
Expand All @@ -77,6 +77,7 @@ It also defines two environmental variables:
### Build output

Building creates the following directories under `build/`:

- `web_app/`: The Manager web app.
- `static/`: The standalone web app static files. This is what one deploys to a web server or runs with Electron.
- `electron_app/`: The launcher desktop Electron app
Expand All @@ -88,11 +89,13 @@ Building creates the following directories under `build/`:
- `shadowbox`: The Proxy Server

The directories have subdirectories for intermediate output:

- `ts/`: Autogenerated Typescript files
- `js/`: The output from compiling Typescript code
- `browserified/`: The output of browserifying the JavaScript code

To clean up:

```
npm run clean
```
Expand Down
4 changes: 1 addition & 3 deletions jasmine.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"spec_dir": ".",
"spec_files": [
"build/js/**/*.spec.js"
],
"spec_files": ["build/js/**/*.spec.js"],
"stopSpecOnExpectationFailure": false,
"random": false
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"action:help": "npm run action",
"action:list": "npm run action",
"clean": "rm -rf src/*/node_modules/ build/ node_modules/ src/server_manager/install_scripts/do_install_script.ts src/server_manager/install_scripts/gcp_install_script.ts third_party/shellcheck/download/",
"format": "prettier \"**/*.{cjs,html,js,json,md,ts}\" --write",
"lint": "npm run lint:sh && npm run lint:ts",
"lint:sh": "bash ./scripts/shellcheck.sh",
"lint:ts": "npx tslint 'src/**/*.ts' -e '**/node_modules/**'",
Expand All @@ -31,7 +32,7 @@
],
"husky": {
"hooks": {
"pre-commit": "npm run lint && npx git-clang-format && npx pretty-quick --staged --pattern '**/*.html'"
"pre-commit": "npm run lint && npx git-clang-format && npx pretty-quick --staged --pattern \"**/*.{cjs,html,js,json,md,ts}\""
}
}
}
41 changes: 21 additions & 20 deletions src/metrics_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The metrics server deploys two services: `dev`, used for development testing and

The metrics server supports two URL paths:

* `POST /connections`: report server data usage broken down by user.
- `POST /connections`: report server data usage broken down by user.

```
{
Expand All @@ -26,23 +26,24 @@ The metrics server supports two URL paths:
}]
}
```
* `POST /features`: report feature usage.

```
{
serverId: string,
serverVersion: string,
timestampUtcMs: number,
dataLimit: {
enabled: boolean
perKeyLimitCount: number
}
}
```

- `POST /features`: report feature usage.

```
{
serverId: string,
serverVersion: string,
timestampUtcMs: number,
dataLimit: {
enabled: boolean
perKeyLimitCount: number
}
}
```

## Requirements

* [Google Cloud SDK](https://cloud.google.com/sdk/)
- [Google Cloud SDK](https://cloud.google.com/sdk/)

## Build

Expand All @@ -60,26 +61,26 @@ npm run action metrics_server/start

## Deploy

* Authenticate with `gcloud`:
- Authenticate with `gcloud`:
```sh
gcloud auth login
```
* To deploy to dev:
- To deploy to dev:
```sh
npm run action metrics_server/deploy_dev
```
* To deploy to prod:
- To deploy to prod:
```sh
npm run action metrics_server/deploy_prod
```

## Test

* Unit test
- Unit test
```sh
npm run action metrics_server/test
```
* Integration test
- Integration test
```sh
npm run action metrics_server/test_integration
```
Loading

0 comments on commit 3034e59

Please sign in to comment.