Skip to content

Commit

Permalink
feat: Ensure Windows & Ubuntu compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
wottpal committed Oct 28, 2023
1 parent aa6d9a7 commit c2cfbe4
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 369 deletions.
6 changes: 6 additions & 0 deletions .changeset/early-islands-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@inkathon/contracts': minor
'@inkathon/frontend': minor
---

Ensure & document Windows, Ubuntu, and macOS compatibility. 🌈
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,29 @@ The frontend works out of the box, without a local node running, as the sample c

> **Pre-requisites:**
>
> - Setup Node.js v16+ (recommended via [nvm](https://github.com/nvm-sh/nvm))
> - Install [pnpm](https://pnpm.io/installation) (recommended via [Node.js Corepack](https://nodejs.org/api/corepack.html))
> - Setup Node.js v18+ (recommended via [nvm](https://github.com/nvm-sh/nvm) with `nvm install 18`)
> - Install [pnpm](https://pnpm.io/installation) (recommended via [Node.js Corepack](https://nodejs.org/api/corepack.html) or `npm i -g pnpm`)
> - Clone this repository
<details>
<summary><strong>Special Instructions for Windows Users</strong></summary>

> [!IMPORTANT]
> Windows users must either use [WSL](https://learn.microsoft.com/windows/wsl/install) (recommended) or a custom shell like [Git Bash](https://git-scm.com/downloads). PowerShell is not supported.
> **Pre-requisites when using WSL for Linux:**
>
> - Install [WSL](https://learn.microsoft.com/windows/wsl/install) and execute _all_ commands in the WSL terminal
> - Setup Node.js v18+ (recommended via [nvm](https://github.com/nvm-sh/nvm) with `nvm install 18`)
> - Install the following npm packages globally:
> - `npm i -g npm`
> - `npm i -g pnpm node-gyp make`
> - Clone this repository into the WSL file system (e.g. `/home/<user>/inkathon`).
>
> **Tip:** You can enter `\\wsl$\` in the top bar of the Windows Explorer to access the WSL file system visually.
</details>

```bash
# Install dependencies (once)
# NOTE: This automatically creates an `.env.local` file
Expand Down
6 changes: 3 additions & 3 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"private": true,
"version": "0.1.3",
"scripts": {
"postinstall": "echo \"Creating empty 'development.ts' it does not exist…\" && [[ ! -e deployments/greeter/development.ts ]] && (command -v touch &> /dev/null && touch deployments/greeter/development.ts || copy /b deployments/greeter/development.ts +,,); true",
"test": "./test-all.sh",
"build": "./build-all.sh",
"postinstall": "bash postinstall.sh",
"test": "bash test-all.sh",
"build": "bash build-all.sh",
"node": "substrate-contracts-node --dev --port 9944 --base-path ./.node-data",
"script": "ts-node --cwd=scripts",
"deploy": "pnpm run script deploy",
Expand Down
17 changes: 17 additions & 0 deletions contracts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -eu

# The script creates an empty 'development.ts' file if it doesn't exist yet.
# This is kind of a hack to prevent a nasty Next.js error when running the frontend
# for the first time after deploying to a local node which forces to clear `frontend/.next`.

if [[ ! -e deployments/greeter/development.ts ]]; then
echo "Creating empty 'development.ts'…"
if command -v touch &> /dev/null; then
touch deployments/greeter/development.ts
else
copy /b deployments/greeter/development.ts +,,
fi
else
echo "Great, 'development.ts' already exists! Skipping…"
fi
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
}
},
"scripts": {
"postinstall": "echo \"Creating default '.env.local' it does not exist…\" && [[ ! -e .env.local ]] && CP_CMD=$(command -v cp &> /dev/null && echo \"cp\" || echo \"copy\") && $CP_CMD .env.local.example .env.local; true",
"postinstall": "bash postinstall.sh",
"dev": "NODE_ENV=development next dev",
"node": "pnpm run --filter contracts node",
"node": "pnpm run -F contracts node",
"dev-and-node": "concurrently \"pnpm dev\" \"pnpm node\" --names \"Next,Node\" --kill-others",
"build": "NODE_ENV=production next build",
"start": "NODE_ENV=production next start",
Expand Down
13 changes: 13 additions & 0 deletions frontend/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eu

# This script creates a default '.env.local' file if it doesn't exist yet.
# More information about environment variables: https://github.com/scio-labs/inkathon#environment-variables

if [[ ! -e .env.local ]]; then
echo "Creating default '.env.local'…"
CP_CMD=$(command -v cp &> /dev/null && echo "cp" || echo "copy")
$CP_CMD .env.local.example .env.local
else
echo "Great, '.env.local' already exists! Skipping…"
fi
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dev": "pnpm run -F frontend dev",
"build": "pnpm run -F frontend build",
"start": "pnpm run -F frontend start",
"node": "pnpm run -F contracts node",
"lint": "pnpm run -F '*' lint",
"lint:fix": "pnpm run -F '*' lint:fix",
"lint:format": "pnpm run -F '*' lint:format",
Expand Down
Loading

1 comment on commit c2cfbe4

@vercel
Copy link

@vercel vercel bot commented on c2cfbe4 Oct 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.