diff --git a/.github/scripts/setup-system.sh b/.github/scripts/setup-system.sh index 83c90ae1b..433f73112 100755 --- a/.github/scripts/setup-system.sh +++ b/.github/scripts/setup-system.sh @@ -2,17 +2,23 @@ set -e +script_failure() { + echo "An error occurred while performing the task on line $1" >&2 + echo "Setup for Spacedrive development failed" >&2 +} + +trap 'script_failure $LINENO' ERR + echo "Setting up your system for Spacedrive development!" -which cargo &> /dev/null -if [ $? -eq 1 ]; then +if ! which cargo &> /dev/null; then echo "Rust was not detected on your system. Ensure the 'rustc' and 'cargo' binaries are in your \$PATH." exit 1 fi if [ "${SPACEDRIVE_SKIP_PNPM_CHECK:-}" != "true" ]; then - which pnpm &> /dev/null - if [ $? -eq 1 ]; then + + if ! which pnpm &> /dev/null; then echo "PNPM was not detected on your system. Ensure the 'pnpm' command is in your \$PATH. You are not able to use Yarn or NPM." exit 1 fi @@ -20,6 +26,42 @@ else echo "Skipped PNPM check!" fi +if [ "$1" == "mobile" ]; then + echo "Setting up for mobile development!" + + # IOS targets + if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Installing IOS Rust targets..." + + if ! /usr/bin/xcodebuild -version; then + echo "Xcode is not installed! Ensure you have it installed!" + exit 1 + fi + + rustup target add aarch64-apple-ios + fi + + # Android requires python + if ! command -v python3 &> /dev/null + then + echo "Python3 could not be found. This is required for Android mobile development!" + exit 1 + fi + + # Android targets + echo "Installing Android Rust targets..." + rustup target add armv7-linux-androideabi # for arm + rustup target add i686-linux-android # for x86 + rustup target add aarch64-linux-android # for arm64 + rustup target add x86_64-linux-android # for x86_64 + rustup target add x86_64-unknown-linux-gnu # for linux-x86-64 + rustup target add x86_64-apple-darwin # for darwin x86_64 (if you have an Intel MacOS) + rustup target add aarch64-apple-darwin # for darwin arm64 (if you have a M1 MacOS) + rustup target add x86_64-pc-windows-gnu # for win32-x86-64-gnu + rustup target add x86_64-pc-windows-msvc # for win32-x86-64-msvc +fi + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then if which apt-get &> /dev/null; then echo "Detected 'apt' based distro!" @@ -29,7 +71,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then else DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavresample-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg" # FFMPEG dependencies fi - DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libappindicator3-dev librsvg2-dev" # Tauri dependencies + DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev" # Tauri dependencies DEBIAN_BINDGEN_DEPS="pkg-config clang" # Bindgen dependencies - it's used by a dependency of Spacedrive sudo apt-get -y update diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index f2c039e33..3de8c04df 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -48,10 +48,6 @@ jobs: working-directory: core if: steps.cache-prisma.outputs.cache-hit != 'true' run: cargo run -p prisma-cli --release -- generate - - # This is do the proc-macro `tauri::generate_context!()` doesn't panic - - name: Create fake `dist` folder - run: mkdir ./apps/desktop/dist - name: Run Clippy uses: actions-rs/clippy-check@v1 diff --git a/.gitignore b/.gitignore index 53da2a22b..500449750 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules .next dist +!apps/desktop/dist *.tsbuildinfo package-lock.json .eslintcache @@ -15,7 +16,6 @@ storybook-static/ cache .env vendor/ -dist data node_modules packages/turbo-server/data/ @@ -61,4 +61,4 @@ todos.md examples/*/*.lock /target -/sdserver_data \ No newline at end of file +/sdserver_data diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee1475ee3..26e2000ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,39 +37,43 @@ This project uses [Cargo](https://doc.rust-lang.org/cargo/getting-started/instal > Note: MacOS M1 users should choose the customize option in the rustup init script and enter `x86_64-apple-darwin` as the default host triple instead of the default `aarch64-apple-darwin` -- `$ git clone https://github.com/spacedriveapp/spacedrive` -- `$ cd spacedrive` +- `git clone https://github.com/spacedriveapp/spacedrive` +- `cd spacedrive` - For Linux or MacOS users run: `./.github/scripts/setup-system.sh` - This will install FFMPEG and any other required dependencies for Spacedrive to build. - For Windows users run using PowerShell: `.\.github\scripts\setup-system.ps1` - This will install pnpm, LLVM, FFMPEG and any other required dependencies for Spacedrive to build. - Ensure you run it like documented above as it expects it is executed from the root of the repository. -- `$ pnpm i` -- `$ pnpm prep` - Runs all necessary codegen & builds required dependencies. +- `pnpm i` +- `pnpm prep` - Runs all necessary codegen & builds required dependencies. To quickly run only the desktop app after `prep` you can use: -- `$ pnpm desktop dev` +- `pnpm desktop dev` To run the landing page -- `$ pnpm web dev` - runs the web app for the embed -- `$ pnpm landing dev` - -To run mobile app - -- `$ cd apps/mobile && pnpm i` - As this is a seperated workspace, you need to do this! -- `$ pnpm android` - runs on Android Emulator -- `$ pnpm ios` - runs on iOS Emulator -- `$ pnpm dev` - For already bundled app - -You also need `expo-cli` installed globally. +- `pnpm web dev` - runs the web app for the embed +- `pnpm landing dev` If you are having issues ensure you are using the following versions of Rust and Node: -- Rust version: **1.62.0** +- Rust version: **1.63.0** - Node version: **17** +##### Mobile app + +To run mobile app + +- Install [Android Studio](https://developer.android.com/studio) for Android and [Xcode](https://apps.apple.com/au/app/xcode/id497799835) for IOS development +- `./.github/scripts/setup-system.sh mobile` + - The should setup most of the dependencies for the mobile app to build. +- You must also ensure [you must have NDK 24.0.8215888 and CMake](https://developer.android.com/studio/projects/install-ndk#default-version) in Android Studio +- `cd apps/mobile && pnpm i` - This is a separate workspace, you need to do this! +- `pnpm android` - runs on Android Emulator +- `pnpm ios` - runs on iOS Emulator +- `pnpm dev` - For already bundled app - This is only temporarily supported. The final app will require the Spacedrive Rust code which isn't included in Expo Go. + ### Pull Request When you're finished with the changes, create a pull request, also known as a PR. diff --git a/Cargo.lock b/Cargo.lock index d4285c8fe..a61940408 100644 Binary files a/Cargo.lock and b/Cargo.lock differ diff --git a/Cargo.toml b/Cargo.toml index 5b06d38b2..507f92891 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,13 @@ [workspace] +resolver = "2" members = [ "apps/desktop/src-tauri", + "apps/mobile/rust", "core", "core/prisma", - "core/derive", "apps/server" ] + +[patch.crates-io] +# We use this patch so we can compile for the IOS simulator on M1 +openssl-sys = { git = "https://github.com/spacedriveapp/rust-openssl" } \ No newline at end of file diff --git a/apps/desktop/dist/.gitignore b/apps/desktop/dist/.gitignore new file mode 100644 index 000000000..c53272268 --- /dev/null +++ b/apps/desktop/dist/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore +# This is done so that Tauri never complains that '../dist does not exist' diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index edf6c13bb..9bbcfb57c 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -11,6 +11,7 @@ build = "build.rs" [dependencies] tauri = { version = "1.0.4", features = ["api-all", "macos-private-api"] } +rspc = { version = "0.0.4", features = ["tauri"] } sdcore = { path = "../../../core" } tokio = { version = "1.17.0", features = ["sync"] } window-shadows = "0.1.2" diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index 5916fddf5..8ae8ba8e3 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -23,7 +23,7 @@ async fn main() { let (node, router) = Node::new(data_dir).await; let app = tauri::Builder::default() - .plugin(sdcore::rspc::integrations::tauri::plugin(router, { + .plugin(rspc::integrations::tauri::plugin(router, { let node = node.clone(); move || node.get_request_context() })) diff --git a/apps/landing/package.json b/apps/landing/package.json index 0a41ad7a9..3f8f28596 100644 --- a/apps/landing/package.json +++ b/apps/landing/package.json @@ -4,7 +4,7 @@ "dev": "pnpm run server", "prod": "pnpm run build && pnpm run server:prod", "vercel-build": "./vercel/deploy.sh", - "build": "vite build && vite build --ssr && vite-plugin-ssr prerender", + "build": "vite build && vite build", "server": "ts-node ./server", "server:prod": "cross-env NODE_ENV=production ts-node ./server", "lint": "eslint src/**/*.{ts,tsx} && tsc --noEmit" @@ -14,6 +14,7 @@ "@icons-pack/react-simple-icons": "^5.2.0", "@sd/interface": "link:../../packages/interface", "@sd/ui": "link:../../packages/ui", + "@sd/assets": "link:../../packages/assets", "@tryghost/content-api": "^1.11.0", "@types/compression": "^1.7.2", "@types/express": "^4.17.13", diff --git a/apps/landing/src/components/Footer.tsx b/apps/landing/src/components/Footer.tsx index a0a74210d..4aab03454 100644 --- a/apps/landing/src/components/Footer.tsx +++ b/apps/landing/src/components/Footer.tsx @@ -6,10 +6,9 @@ import { Twitch, Twitter } from '@icons-pack/react-simple-icons'; +import AppLogo from '@sd/assets/images/logo.png'; import React from 'react'; -import AppLogo from '../assets/images/logo.png'; - function FooterLink(props: { children: string | JSX.Element; link: string; blank?: boolean }) { return ( { Prism.highlightAll(); }, []); @@ -72,4 +72,4 @@ function MarkdownPage({ post }: { post: PostOrPage }) { ); } -export { MarkdownPage }; +export { Page }; diff --git a/apps/landing/src/pages/index.page.tsx b/apps/landing/src/pages/index.page.tsx index 650e3cc3f..045c83fe2 100644 --- a/apps/landing/src/pages/index.page.tsx +++ b/apps/landing/src/pages/index.page.tsx @@ -100,13 +100,11 @@ function Page() {