Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bundle static assets #144

Merged
merged 12 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .depcheckrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"ignores": [
"@electron-forge/publisher-github",
"@electron-forge/maker-deb",
"@electron-forge/maker-deb",
"@electron-forge/maker-rpm",
"@electron-forge/maker-squirrel",
"@electron-forge/maker-zip",
"@electron-forge/*",
"@types/*",
"@kayahr/jest-electron-runner",
"@types/jest",
"electron-forge-maker-zip-all",
"ts-jest",
"ts-node"
"ts-node",
"concurrently",
"cross-env"
]
}
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module.exports = {
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:prettier/recommended'],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018,
project: './tsconfig.test.json',
},
env: {
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
cache: 'npm'
cache: npm
node-version: ${{ matrix.node-version }}

- name: Install deps
run: npm ci
- name: Install npm deps
run: npm ci && cd ./installer && npm ci

- name: Build assets
run: npm run build

- name: Commit linting
uses: wagoid/commitlint-github-action@v2
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
version:
description: 'Pre-release version (without "v" prefix)'
required: true
dashboard:
description: 'Bee Dashboard version/tag/commit if required'
required: false

jobs:
publish:
Expand All @@ -24,6 +27,10 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Install custom Bee Dashboard
if: github.event.inputs.dashboard != ''
run: npm install github:ethersphere/bee-dashboard#${{ github.event.inputs.dashboard }}

- name: Replace Version in package.json
uses: jossef/action-set-json-field@v1
with:
Expand Down
124 changes: 95 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,116 @@
# Bee Desktop
# Swarm Desktop

## Downloading the corresponding version
[![Tests](https://github.com/ethersphere/swarm-desktop/actions/workflows/tests.yaml/badge.svg)](https://github.com/ethersphere/swarm-desktop/actions/workflows/tests.yaml)
[![](https://img.shields.io/badge/made%20by-Swarm-blue.svg?style=flat-square)](https://swarm.ethereum.org/)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D6.9.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D14.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/runs%20on-macOS%20%7C%20Linux%20%7C%20Windows-orange)

Go to the [releases page](https://github.com/ethersphere/bee-desktop/releases/tag/v0.4.0)
> Electron Desktop app that helps you easily spin up and manage Swarm's Bee node

Windows: `bee-desktop-0.4.0.Setup.exe`
**Warning: This project is in beta state. There might (and most probably will) be changes in the future to its API and working. Also, no guarantees can be made about its stability, efficiency, and security at this stage.**

Mac OS: `bee-desktop-darwin-x64-0.4.0.zip`
Stay up to date by joining the [official Discord](https://discord.gg/GU22h2utj6) and by keeping an eye on the [releases tab](https://github.com/ethersphere/swarm-desktop/releases).

Linux: `bee-desktop-0.4.0-1.x86_64.rpm` or `bee-desktop_0.4.0_amd64.deb`
## Table of Contents

> You can alternatively clone this repository and run `npm install` and then `npm start`
- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [Development](#development)
- [Test](#test)
- [License](#license)

**Until 1.0 release, all our developer releases has enabled error tracking and reporting using [sentry.io](https://sentry.io/)!**
## Install

After the 1.0 release this will be changed to opt-in instead.
Go to the [releases page](https://github.com/ethersphere/swarm-desktop/releases/latest) and download the correct build for your operation system:

## Logs
- Windows: `Swarm.Desktop-***.Setup.exe`
- macOS: `Swarm.Desktop-darwin-x64-***.zip`
- Linux: `swarm-desktop_***_amd64.deb` or `swarm-desktop-***-1.x86_64.rpm`

If you run the build version you can access logs of Bee Desktop at:
> Until 1.0 release, all our developer releases has automatically enabled error tracking and reporting using sentry.io which is not possible to opt-out!

- macOS: `~/Library/Logs/Swarm Desktop/bee-desktop.log`
- Windows: `%LOCALAPPDATA%\Swarm Desktop\Log\bee-desktop.log` (for example, `C:\Users\USERNAME\AppData\Local\Swarm Desktop\Log\bee-desktop.log`)
- Linux: `~/.local/state/Swarm Desktop/bee-desktop.log`
### macOS

## If you have a previous installation
macOS may not allow you to run the .app after unzipping. To solve this, right click the .app and click Open. You will have an option to ignore the warning.

You need to delete the previous assets first to receive updates
## Usage

To do so, delete the `static` folder under the following location:
TODO

Windows: `%LOCALAPPDATA%\Swarm Desktop\Data` (for example,
`C:\Users\USERNAME\AppData\Local\Swarm Desktop\Data`)
## Contribute

Mac OS: `~/Library/Application Support/Swarm Desktop`
There are some ways you can make this module better:

Linux: `~/.local/share/Swarm Desktop` (or `$XDG_DATA_HOME/Swarm Desktop`)
- Consult our [open issues](https://github.com/ethersphere/swarm-desktop/issues) and take on one of them
- Help our tests reach 100% coverage!
- Join us in our [Discord chat](https://discord.gg/wdghaQsGq5) in the #develop-on-swarm channel if you have questions or want to give feedback

## Allow running on Mac OS
### Architecture

Mac OS may not allow you to run the `.app` after unzipping. To solve this, right click the `.app` and click Open. You
will have an option to ignore the warning.
Swarm Desktop consists of 3 components:

## Release process
1. Electron back-end that provides orchestration API that retrieve, spins, stops and manage the Bee node
2. Installer front-end that provides UI that walk user through installation of all the components
3. Bundled [Bee Dashboard](https://github.com/ethersphere/bee-dashboard) that provides UI to manage Bee node and provides access to Swarm network

1. have whatever to be released from the Installer and Dashboard in their `master`
2. trigger the [`bee-desktop-static-maker` release](https://github.com/ethersphere/bee-desktop-static-maker/actions/workflows/build.yaml)
3. sync the URL of the released ZIP to `/src/downloader.ts`
4. merge bee-desktop release please PR
The Electron back-end is placed in `src` folder and the Installer is placed in `installer` folder.

The Bee Desktop stores logs of both itself and Bee in the application's logs folder:

- macOS: `~/Library/Logs/Swarm Desktop/`
- Windows: `%LOCALAPPDATA%\Swarm Desktop\Log\` (for example, `C:\Users\USERNAME\AppData\Local\Swarm Desktop\Log\`)
- Linux: `~/.local/state/Swarm Desktop/`

It also stores configuration files, Bee assets and other things in application's data folder:

- Windows: `%LOCALAPPDATA%\Swarm Desktop\Data` (for example, `C:\Users\USERNAME\AppData\Local\Swarm Desktop\Data`)
- Mac OS: `~/Library/Application Support/Swarm Desktop`
- Linux: `~/.local/share/Swarm Desktop` (or `$XDG_DATA_HOME/Swarm Desktop`)

### Development

As there are several independent components it bit depends on what you want to develop.

#### Electron Desktop

To work on the Electron Desktop back-end you just need to do your work and then run `npm start`. This will launch the
Electron app and shows the Tray icon. No UI will be opened automatically. If you need to make more adjustment you have to exit
the process with `SIGINT (CTRL+C)` and relaunch.

#### Installer

To work on the Installer, run first `npm start` that will spin up the Electron Desktop back-end and also launches the `/installer` development
server. In order for the UI to be able to access the Desktop API it needs to have injected API token, which you can do by running `npm run open:installer`
that will open the Installer UI served by the development server with API key be passed in the URL. Changes to the Installer UI are automatically
hot-reloaded.

The UI served by the Desktop itself is updated only when you restart the `npm start`.

#### Dashboard

To work on the Dashboard, run first `npm start` that will spin up the Electron Desktop back-end. Then go to your locally cloned `bee-dashboard` repo and
in it start the development server with `npm start`. Similarly to Installer, the Dashboard also needs to have API key injected in order to use the
Desktop's API. You can inject it similarly by running `npm run desktop` in the Dashboard repo that will open the Dashboard UI with API key in the URL.
Changes to the Installer UI are automatically hot-reloaded.

The UI served by the Desktop itself is updated only when you update the `@ethersphere/bee-dashboard` NPM package in the Desktop repo.

#### Maintenance tasks

There are several handy scripts:

- `npm run purge:data` that purge's the Desktop's data folder
- `npm run purge:logs` that purge's the Dekstop's logs folder

## Maintainers

- [Cafe137](https://github.com/Cafe137)
- [vojtechsimetka](https://github.com/vojtechsimetka)

## License

[BSD-3-Clause](./LICENSE)
Binary file added assets/icon.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 assets/trayTemplate.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 assets/trayTemplate@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions devkit.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node

import envPaths from 'env-paths'
import open from 'open'

import { readFile, rm } from 'node:fs/promises'
import { join } from 'node:path'

const paths = envPaths('Swarm Desktop', { suffix: '' })
const requestedCommand = process.argv[2]

switch (requestedCommand) {
case 'open:installer':
await openInstaller()
break;
case 'purge:data':
await purgeData()
break;
case 'purge:logs':
await purgeLogs()
break;
default:
throw new Error(`Unknown command "${requestedCommand}"!`)

}

function purgeData () {
return rm(paths.data, {recursive: true, force: true})
}


function purgeLogs () {
return rm(paths.log, {recursive: true, force: true})
}

async function openInstaller () {
const apiKey = await readFile(join(paths.data, 'api-key.txt'), {encoding: 'utf-8'})
const url = `http://localhost:3002/?v=${apiKey}#/`

console.log('Opening: ' + url)
await open(url)
}
3 changes: 3 additions & 0 deletions installer/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PORT=3002
BROWSER=none
REACT_APP_BEE_DESKTOP_URL=http://localhost:3000
4 changes: 4 additions & 0 deletions installer/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['../.eslintrc.js'],
}
70 changes: 70 additions & 0 deletions installer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
Loading