Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
62 changes: 62 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Checks

on:
pull_request:
push:
branches:
- main

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Read Node version from mise.toml
id: node
run: echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >> "$GITHUB_OUTPUT"

- name: Install package manager (from package.json)
run: |
corepack enable
corepack install

- uses: actions/setup-node@v4
with:
node-version: ${{ steps.node.outputs.version }}

- name: Resolve yarn cache folder
id: yarn-config
run: echo "cacheFolder=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"

- name: Restore yarn install cache (node_modules + cacheFolder + install-state)
id: yarn-cache
uses: actions/cache@v4
with:
path: |
node_modules
${{ steps.yarn-config.outputs.cacheFolder }}
.yarn/install-state.gz
key: yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-

- name: Install deps
env:
YARN_ENABLE_HARDENED_MODE: 'false'
run: |
case "$(yarn --version)" in 1.*) echo 'expected up-to-date yarn version'; exit 1 ;; esac
yarn install --immutable

- name: Format
run: yarn format:check

- name: Lint
run: yarn lint

- name: Typecheck
run: yarn typecheck

- name: Test
run: yarn coverage
57 changes: 14 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@ jobs:
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install rust deps
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable

- name: Cache
uses: swatinem/rust-cache@v2
Expand All @@ -36,10 +32,7 @@ jobs:
shared-key: ${{ runner.os }}-base

- name: Cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --manifest-path ./src-tauri/Cargo.toml
run: cargo check --manifest-path ./src-tauri/Cargo.toml

testRust:
name: Test Rust
Expand All @@ -48,19 +41,15 @@ jobs:
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install rust deps
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable

- name: Cache
uses: swatinem/rust-cache@v2
Expand All @@ -69,22 +58,18 @@ jobs:
shared-key: ${{ runner.os }}-test

- name: Cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path ./src-tauri/Cargo.toml
run: cargo test --manifest-path ./src-tauri/Cargo.toml

testTypescript:
name: Test Typescript
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Read Node version from mise.toml
id: node
run:
echo "version=$(grep -E '^node\\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\\1/')" >>
run: echo "version=$(grep -E '^node\\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\\1/')" >>
"$GITHUB_OUTPUT"

- name: Install package manager (from package.json)
Expand Down Expand Up @@ -130,28 +115,21 @@ jobs:
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install rust deps
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable

- name: Install rustfmt
run: rustup component add rustfmt

- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ./src-tauri/Cargo.toml --all -- --check
run: cargo fmt --manifest-path ./src-tauri/Cargo.toml --all -- --check

clippy:
name: Clippy
Expand All @@ -160,19 +138,15 @@ jobs:
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install rust deps
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable

- name: Install clippy
run: rustup component add clippy
Expand All @@ -184,7 +158,4 @@ jobs:
shared-key: ${{ runner.os }}-base

- name: Cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path ./src-tauri/Cargo.toml -- -D warnings
run: cargo clippy --manifest-path ./src-tauri/Cargo.toml -- -D warnings
9 changes: 3 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Read Node version from mise.toml
id: node
shell: bash
run:
echo "version=$(grep -E '^node\\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\\1/')" >>
run: echo "version=$(grep -E '^node\\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\\1/')" >>
"$GITHUB_OUTPUT"

- name: Install package manager (from package.json)
Expand All @@ -33,9 +32,7 @@ jobs:
node-version: ${{ steps.node.outputs.version }}

- name: Rust setup
uses: actions-rs/toolchain@v1
with:
toolchain: stable
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
Expand Down
14 changes: 14 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env sh
yarn lint-staged
yarn typecheck

# Tauri/Rust check only when src-tauri files are staged.
if git diff --cached --name-only --diff-filter=ACM | grep -qE '^src-tauri/.+\.(rs|toml)$|^src-tauri/Cargo\.lock$'; then
if command -v cargo >/dev/null 2>&1; then
(cd src-tauri && cargo check)
fi
fi

if command -v gitleaks >/dev/null 2>&1; then
gitleaks protect --staged --no-banner --redact
fi
16 changes: 16 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"proseWrap": "preserve",
"sortPackageJson": false,
"ignorePatterns": [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/coverage/**",
"**/.yarn/**",
"src-tauri/target/**"
]
}
58 changes: 58 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["typescript", "react", "vitest", "jsx-a11y", "unicorn", "oxc"],
"categories": {
"correctness": "error",
"suspicious": "error",
"perf": "error"
},
"rules": {
"vitest/require-mock-type-parameters": "off",
"vitest/valid-title": "off",
"typescript/no-explicit-any": "warn",
"typescript/ban-ts-comment": "off",
"typescript/no-extraneous-class": "off",
"react/react-in-jsx-scope": "off",
"no-bitwise": "off",
"no-shadow": "off",
"no-empty-pattern": "off",
"no-await-in-loop": "off",
"unicorn/consistent-function-scoping": "off",
"unicorn/no-array-sort": "off",
"unicorn/prefer-set-has": "off",
"oxc/no-map-spread": "warn",
"react-hooks/exhaustive-deps": "warn",
"jsx-a11y/no-static-element-interactions": "warn",
"jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/anchor-is-valid": "warn"
},
"overrides": [
{
"files": ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"],
"rules": {
"typescript/no-explicit-any": "off",
"no-unused-vars": "off"
}
},
{
"files": ["src/init.ts"],
"rules": {
"no-extend-native": "off"
}
}
],
"env": {
"browser": true,
"node": true,
"es2024": true,
"vitest/globals": true
},
"ignorePatterns": [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/coverage/**",
"**/.yarn/**",
"src-tauri/**"
]
}
3 changes: 1 addition & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
approvedGitRepositories:
- "**"
- '**'

compressionLevel: mixed

enableGlobalCache: false

enableHardenedMode: false


nodeLinker: node-modules
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Webber's Map Editor 2D

- Load or create a new map
- Select your sprites' folder (recursively).
- Select your sprites' folder (recursively).
- Drag your sprites to the canvas to create instances.
- On the canvas, adjust instances:
- 📛 Name
- 📛 Name
- 🪧 Position (x, y)
- 🔝 Z-Index
- 🛞 Rotation
- 🔛 Scale
- Save map as a JSON file (includes relative paths to the files).

[//]: # ( Possible future features )
[//]: # ( - Flip)
[//]: # ( - Color)
[//]: # ( - Opacity)
[//]: # ( - Blend mode)
[//]: # ' Possible future features '
[//]: # ' - Flip'
[//]: # ' - Color'
[//]: # ' - Opacity'
[//]: # ' - Blend mode'

## Demo

https://user-images.githubusercontent.com/20756439/198751508-4094773d-8660-42f8-a48e-ab8489b30068.mp4

## Limitations

- Currently only works with files in your home directory, for your own security.
- Currently only works with files in your home directory, for your own security.

_Limitations will be lifted in [v2](https://github.com/webbertakken/map-editor-2d/issues/10)._

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-150">
<head>
<meta charset="UTF-8" />
Expand Down
3 changes: 3 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[tools]
node = "20.11.1"
yarn = "4.14.1"
actionlint = "latest"
shellcheck = "latest"
gitleaks = "latest"
Loading
Loading