Skip to content

Commit

Permalink
feat: add access key (#151)
Browse files Browse the repository at this point in the history
* feat: add access key

* feat: save generated access key to vault and set cookies

* chore: rename isVaultReadyStore to isAppReadyStore

* feat: add access key page

* feat: check access key on every request

* chore: general cleanup

* fix: remove URL protocol override

* chore: more syntax cleanup

* chore: remove unused store props

* feat: add status bar notification after setting access key

* test: fix sync tests

* test: increase visual diff ratio

* chore: remove unused imports

* fix: skip checks when /devTools is requested in dev and tests

* fix: update environment variables for tests

* test: add accessKey tests

* test: add more tests

* test: add test for /vault

* test: add more assertions

* fix: cleanup redundant syntax

* fix: update Linux Prisma engines

* test: add statusBar assertion

* test: add statusBar assertion on reset

* test: reset access key before continuing

* test: improve assertion resilience

* chore: rename helpers/test.server.ts

* test: don't reload, go to /devTools

* test: add TEST_ACCESS_KEY check

* docs: add comment

* feat: add server only release (#153)

* chore: remove unused script

svelte-kit package has been removed. It now lives in its own npm package. See the PR on how to migrate: sveltejs/kit#5730

* feat: add Linux server release

* feat: remove builds for all except ubuntu

This is a test for building and releasing a Linux server version of Canutin

* Revert "feat: remove builds for all except ubuntu"

This reverts commit 01481ba.

* fix: get previous tag

* fix: rename ELECTRON_SWITCHED_VAULT to SHOULD_CHECK_VAULT

* fix: replace semantic-release package with GH action

* fix: add Linux server package script

* fix: typo
  • Loading branch information
fmaclen authored Dec 6, 2022
1 parent 895941d commit 20bd7fb
Show file tree
Hide file tree
Showing 40 changed files with 9,686 additions and 17,591 deletions.
49 changes: 39 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,57 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3

- name: Bump version and push tag
id: tag_version
uses: cycjimmy/semantic-release-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Only continue with these steps if the commit is tagged

- name: Install Electron dependencies
if: ${{ steps.tag_version.outputs.new_release_git_tag }}
run: npm ci

- name: Install SvelteKit dependencies
if: ${{ steps.tag_version.outputs.new_release_git_tag }}
working-directory: ./sveltekit
run: npm ci

- name: Install Prisma's dependencies
if: ${{ steps.tag_version.outputs.new_release_git_tag }}
working-directory: ./sveltekit
run: npx prisma generate

- name: Install Electron dependencies
run: npm ci
- name: "Generate Sveltekit build"
if: ${{ steps.tag_version.outputs.new_release_git_tag }}
run: npm run build:sveltekit

- name: Run semantic release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare package.json for release
- name: Update package.json's with app version
if: ${{ steps.tag_version.outputs.new_release_git_tag }}
run: npm run package:github
env:
APP_VERSION: ${{ steps.tag_version.outputs.new_release_git_tag }}

- name: Build & release Electron app
if: ${{ steps.tag_version.outputs.new_release_git_tag }}
uses: samuelmeuli/[email protected]
with:
github_token: ${{ secrets.github_token }}
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
build_script_name: "build:all"
build_script_name: "build:electron"
release: true

- name: Package Linux server
# - Needs to run after the Electron build because it relies on the files and directories created in that step.
# - Only create a release for the Linux server when action runs in Ubuntu.
if: ${{ matrix.os == 'ubuntu-latest' && steps.tag_version.outputs.new_release_git_tag }}
run: npm run package:linux-server
env:
APP_VERSION: ${{ steps.tag_version.outputs.new_release_git_tag }}

- name: Release Linux server
if: ${{ matrix.os == 'ubuntu-latest' && steps.tag_version.outputs.new_release_git_tag }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_version.outputs.new_release_git_tag }}
files: ./dist/canutin-server_*.tar.gz
2 changes: 1 addition & 1 deletion electron/__tests__/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Server", () => {
HOST: "127.0.0.1",
SVELTEKIT_PATH: fakePathToSvelteKitIndex,
DATABASE_URL: `file:${fakePathToVault}`,
ELECTRON_SWITCHED_VAULT: "true",
SHOULD_CHECK_VAULT: "true",
APP_VERSION: require("../../package.json").version,
};

Expand Down
2 changes: 1 addition & 1 deletion electron/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Server {
PORT: this.port,
SVELTEKIT_PATH: svelteKitPath,
DATABASE_URL: `file:${newVaultPath ? newVaultPath : this.vaultPath}`,
ELECTRON_SWITCHED_VAULT: "true",
SHOULD_CHECK_VAULT: "true",
APP_VERSION: isDev
? require("../package.json").version
: app.getVersion(),
Expand Down
4 changes: 4 additions & 0 deletions linux-server/canutin/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
HOST="localhost"
PORT="42069"
DATABASE_URL="file:../Canutin.vault"
SHOULD_CHECK_VAULT="true"
13 changes: 13 additions & 0 deletions linux-server/canutin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Canutin: server

## Setting up the server

1. Download the [latest version](https://github.com/Canutin/desktop/releases) of **Canutin server** for Linux and extract it to a folder.
2. Install [Node.js](https://nodejs.org/) (v18+) if you don't have it already.

```bash
sudo apt-get install nodejs
```

3. Edit the `.env` file to set the vault `path`, `hostname` and `port`.
4. Run the server with `./start`
36 changes: 36 additions & 0 deletions linux-server/canutin/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

echo "
..,;:;,..
.':lkKNWWWNKxc.
.'oKNWNkoccld0WWO;.
.'oKWWW0:. ..oXM0,
.'oKWMMXOc. .kWNl.
.'oKWMMMMNKl. 'OMNc.
.'oKWMMMMMMMWKo'. ..;kWWx.
.'oKWMMMMMMMMMMMWXkxdx0NWKl.
.:0WMMMMMMMMMMMMMMMMMMMWKo'.
;KMMMMMMMMMMMMMMMMMMMWKo'.
.oNMMMMMMMMMMMMMMMMMWKo'.
.cXMMMMMMMMMMMMMMMWKo'.
.dNMMMMMMMMMMMWNKo'.
.cONMMMMMMMN0o:'.
.;ldkkkxo:..
...
"

echo "-> Loading environment variables from `.env` file"
export $(xargs <.env)

echo "----> HOST: $HOST"
echo "----> PORT: $PORT"
echo "----> DATABASE_URL: $DATABASE_URL"
echo "----> SHOULD_CHECK_VAULT: $SHOULD_CHECK_VAULT"

echo ""
echo "-> Starting server"
node index.js
Loading

0 comments on commit 20bd7fb

Please sign in to comment.