From 2582162cea2b3a59cd21c78f8b73cb03d0acad40 Mon Sep 17 00:00:00 2001 From: Pauline Date: Sat, 14 Oct 2023 22:27:27 -0400 Subject: refactor(trunk): refactor the entire project idk --- .cargo/config.toml.mustache | 23 + .cargo/readme.md | 3 + .editorconfig | 2 + .github/ISSUE_TEMPLATE/bug_report.yml | 61 + .github/ISSUE_TEMPLATE/config.yml | 13 + .github/actions/publish-artifacts/.gitignore | 2 + .github/actions/publish-artifacts/action.yaml | 14 + .github/actions/publish-artifacts/index.ts | 101 + .github/actions/publish-artifacts/package.json | 17 + .github/actions/publish-artifacts/tsconfig.json | 11 + .github/actions/setup-pnpm/action.yml | 28 + .github/actions/setup-rust/action.yaml | 52 + .github/actions/setup-system/action.yml | 36 + .github/scripts/setup.ps1 | 0 .github/scripts/setup.sh | 0 .github/workflows/cache-factory.yaml | 77 + .github/workflows/release.yaml | 102 + .github/workflows/testing.yaml | 142 + .gitignore | 1 + .prettierrc.js | 11 +- .vscode/extensions.json | 16 +- .vscode/settings.json | 48 +- .vscode/tailwind.json | 55 + CODE_OF_CONDUCT.md | 30 +- CONTRIBUTING.md | 51 +- README.md | 18 +- apps/website/.eslintrc.js | 8 + apps/website/astro.config.ts | 7 +- apps/website/config.ts | 158 +- apps/website/package.json | 4 +- apps/website/src/styles/global.css | 10 +- apps/website/src/types/Config.d.ts | 48 +- apps/website/tailwind.config.cjs | 53 + apps/website/tsconfig.json | 11 +- package.json | 77 +- packages/assets/README.md | 3 + packages/assets/package.json | 8 + packages/assets/scripts/generate.mjs | 62 + packages/config/.eslintrc.js | 4 + packages/config/app.tsconfig.json | 7 + packages/config/base.tsconfig.json | 22 + packages/config/eslint/base.js | 79 + packages/config/eslint/tailwind.js | 23 + packages/config/eslint/web.js | 22 + packages/config/index.js | 3 + packages/config/package.json | 29 + packages/config/vite/index.ts | 27 + packages/config/vite/relAlias.ts | 77 + packages/ui/.eslintrc.js | 8 + packages/ui/package.json | 51 + packages/ui/postcss.config.js | 3 + packages/ui/src/index.ts | 1 + packages/ui/src/keys.ts | 56 + packages/ui/src/utils.tsx | 28 + packages/ui/style/index.js | 1 + packages/ui/style/postcss.config.js | 1 + packages/ui/style/style.scss | 30 + packages/ui/style/tailwind.js | 119 + packages/ui/style/tailwind.pcss | 4 + packages/ui/tailwind.config.js | 2 + packages/ui/tsconfig.json | 8 + pkgs/ctjs/index.js | 3 - pkgs/ctjs/metadata.json | 9 - pkgs/ctjs/package.json | 4 - pkgs/ctjs/types/ctjs.d.ts | 14053 ---------------------- pkgs/ctjs/types/schema.json | 77 - pnpm-lock.yaml | 3041 ++++- pnpm-workspace.yaml | 9 +- tsconfig.json | 7 +- 69 files changed, 4568 insertions(+), 14603 deletions(-) create mode 100644 .cargo/config.toml.mustache create mode 100644 .cargo/readme.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/actions/publish-artifacts/.gitignore create mode 100644 .github/actions/publish-artifacts/action.yaml create mode 100644 .github/actions/publish-artifacts/index.ts create mode 100644 .github/actions/publish-artifacts/package.json create mode 100644 .github/actions/publish-artifacts/tsconfig.json create mode 100644 .github/actions/setup-pnpm/action.yml create mode 100644 .github/actions/setup-rust/action.yaml create mode 100644 .github/actions/setup-system/action.yml create mode 100644 .github/scripts/setup.ps1 create mode 100644 .github/scripts/setup.sh create mode 100644 .github/workflows/cache-factory.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/testing.yaml create mode 100644 .vscode/tailwind.json create mode 100644 apps/website/.eslintrc.js create mode 100644 apps/website/tailwind.config.cjs create mode 100644 packages/assets/README.md create mode 100644 packages/assets/package.json create mode 100644 packages/assets/scripts/generate.mjs create mode 100644 packages/config/.eslintrc.js create mode 100644 packages/config/app.tsconfig.json create mode 100644 packages/config/base.tsconfig.json create mode 100644 packages/config/eslint/base.js create mode 100644 packages/config/eslint/tailwind.js create mode 100644 packages/config/eslint/web.js create mode 100644 packages/config/index.js create mode 100644 packages/config/package.json create mode 100644 packages/config/vite/index.ts create mode 100644 packages/config/vite/relAlias.ts create mode 100644 packages/ui/.eslintrc.js create mode 100644 packages/ui/package.json create mode 100644 packages/ui/postcss.config.js create mode 100644 packages/ui/src/index.ts create mode 100644 packages/ui/src/keys.ts create mode 100644 packages/ui/src/utils.tsx create mode 100644 packages/ui/style/index.js create mode 100644 packages/ui/style/postcss.config.js create mode 100644 packages/ui/style/style.scss create mode 100644 packages/ui/style/tailwind.js create mode 100644 packages/ui/style/tailwind.pcss create mode 100644 packages/ui/tailwind.config.js create mode 100644 packages/ui/tsconfig.json delete mode 100644 pkgs/ctjs/index.js delete mode 100644 pkgs/ctjs/metadata.json delete mode 100644 pkgs/ctjs/package.json delete mode 100644 pkgs/ctjs/types/ctjs.d.ts delete mode 100644 pkgs/ctjs/types/schema.json diff --git a/.cargo/config.toml.mustache b/.cargo/config.toml.mustache new file mode 100644 index 0000000..8456e90 --- /dev/null +++ b/.cargo/config.toml.mustache @@ -0,0 +1,23 @@ +{{#isMacOS}} +[target.x86_64-apple-darwin] +rustflags = ["-L", "{{{nativeDeps}}}/lib"] + +[target.aarch64-apple-darwin] +rustflags = ["-L", "{{{nativeDeps}}}/lib"] +{{/isMacOS}} + +{{#isWin}} +[target.x86_64-pc-windows-msvc] +rustflags = ["-L", "{{{nativeDeps}}}\\lib"] +{{/isWin}} + +{{#isLinux}} +[target.x86_64-unknown-linux-gnu] +rustflags = ["-L", "{{{nativeDeps}}}/lib", "-C", "link-arg=-Wl,-rpath=${ORIGIN}/../lib/nexus"] + +[target.aarch64-unknown-linux-gnu] +rustflags = ["-L", "{{{nativeDeps}}}/lib", "-C", "link-arg=-Wl,-rpath=${ORIGIN}/../lib/nexus"] +{{/isLinux}} + +[alias] +prisma = "run -p prisma-cli --bin prisma --" diff --git a/.cargo/readme.md b/.cargo/readme.md new file mode 100644 index 0000000..1854eae --- /dev/null +++ b/.cargo/readme.md @@ -0,0 +1,3 @@ +# (i): note + +make sure to execute the `::setup` script after any modifications to `cargo.toml`. diff --git a/.editorconfig b/.editorconfig index 73f4fd2..2de35d8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -37,6 +37,8 @@ trim_trailing_whitespace = true # https://prettier.io [*.{cjs,js,json,jsx,mjs,ts,tsx}] indent_size = 4 +tab_width = 4 +indent_style = tab # Kotlin # https://android.github.io/kotlin-guides/style.html#indentation diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..31ba093 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,61 @@ +name: 🐞 Bug Report +description: Report a bug +labels: + - kind/bug + - status/needs-triage + +body: + - type: checkboxes + id: product + attributes: + label: Product name + description: What Polyfrost product are you using? + options: + - label: Website + - label: Launcher + - label: Installer + + - type: markdown + attributes: + value: | + ## First of all + 1. Please search for [existing issues](https://github.com/polyfrost/nexus/issues?q=is%3Aissue) about this problem first. + 2. Make sure it's an issue with our products and not something else you are using. + 3. Remember to follow our community guidelines and be friendly. + + - type: textarea + id: description + attributes: + label: Describe the bug + description: A clear description of what the bug is. Include screenshots if applicable. + placeholder: Bug description + validations: + required: true + + - type: textarea + id: reproduction + attributes: + label: Reproduction + description: Steps to reproduce the behavior. + placeholder: | + 1. Go to ... + 2. Click on ... + 3. See error + + - type: textarea + id: expected-behavior + attributes: + label: Expected behavior + description: A clear description of what you expected to happen. + + - type: textarea + id: logs + attributes: + label: Stack trace (optional) + render: Shell + + - type: textarea + id: context + attributes: + label: Additional context + description: Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..77fbf47 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,13 @@ +# tell yaml plugin that this is the config file and not a template of its own: +# yaml-language-server: $schema=https://json.schemastore.org/github-issue-config.json +blank_issues_enabled: false +contact_links: + - name: 🙏 Get Help + url: https://github.com/polyfrost/nexus/discussions/new?category=help + about: If you can't get something to work the way you expect, open a question in our discussion forums. + - name: 💡 Feature Request + url: https://github.com/polyfrost/nexus/discussions/new?category=ideas + about: Suggest any ideas you have using our discussion forums. + - name: 💬 Discord Chat + url: https://polyfrost.cc/discord + about: Ask questions and talk to other Polyfrost product users and the devs. diff --git a/.github/actions/publish-artifacts/.gitignore b/.github/actions/publish-artifacts/.gitignore new file mode 100644 index 0000000..5c4b4fd --- /dev/null +++ b/.github/actions/publish-artifacts/.gitignore @@ -0,0 +1,2 @@ +# pls tell me there is a better way +!dist diff --git a/.github/actions/publish-artifacts/action.yaml b/.github/actions/publish-artifacts/action.yaml new file mode 100644 index 0000000..c3679af --- /dev/null +++ b/.github/actions/publish-artifacts/action.yaml @@ -0,0 +1,14 @@ +name: Publish artifacts +description: Publishes artifacts after CI process +inputs: + target: + description: target triples for built artifact + profile: + description: "'debug' or 'release'" + os: + description: "'darwin', 'windows', or 'linux'" + arch: + description: "'x86_64' or 'aarch64'" +runs: + using: node20 + main: dist/index.js diff --git a/.github/actions/publish-artifacts/index.ts b/.github/actions/publish-artifacts/index.ts new file mode 100644 index 0000000..8509194 --- /dev/null +++ b/.github/actions/publish-artifacts/index.ts @@ -0,0 +1,101 @@ +import * as artifact from '@actions/artifact'; +import * as core from '@actions/core'; +import * as glob from '@actions/glob'; +import * as io from '@actions/io'; + +// script to build tauri bundles without pain + +type OS = 'darwin' | 'windows' | 'linux'; +type Arch = 'x64' | 'arm64'; // 'aarch64'; +// i could type this with tauri's config but idrc +type TargetConfig = { bundle: string; ext: string }; +type BuildTarget = { + updater: TargetConfig; + standalone: Array; +}; + +const OS_TARGETS = { + darwin: { + updater: { + bundle: 'macos', + ext: 'app.tar.gz' + }, + standalone: [{ ext: 'dmg', bundle: 'dmg' }] + }, + windows: { + updater: { + bundle: 'msi', + ext: 'msi.zip' + }, + standalone: [{ ext: 'msi', bundle: 'msi' }] + }, + linux: { + updater: { + bundle: 'appimage', + ext: 'AppImage.tar.gz' + }, + standalone: [ + { ext: 'deb', bundle: 'deb' }, + { ext: 'AppImage', bundle: 'appimage' } + ] + } +} satisfies Record; + +const OS: OS = core.getInput('os') as any; +const ARCH: Arch = core.getInput('arch') as any; +const TARGET = core.getInput('target'); +const PROFILE = core.getInput('profile'); + +const BUNDLE_DIR = `target/${TARGET}/${PROFILE}/bundle`; +const ARTIFACTS_DIR = '.artifacts'; +const ARTIFACT_BASE = `Nexus-${OS}-${ARCH}`; +const UPDATER_ARTIFACT_NAME = `Nexus-Updater-${OS}-${ARCH}`; + +const client = artifact.create(); + +// globby glob globber :3 +const globFiles = async (pattern: string) => { + const globber = await glob.create(pattern); + return await globber.glob(); +}; + +const uploadUpdater = async ({ bundle, ext }: TargetConfig) => { + const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${ext}*`); + const updaterPath = files.find((f) => f.endsWith(ext)); + + if (!updaterPath) return console.error(`updater path not found. ${files}`); + + const artifactPath = `${ARTIFACTS_DIR}/${UPDATER_ARTIFACT_NAME}.${ext}`; + + await io.cp(updaterPath, artifactPath); + await io.cp(`${updaterPath}.sig`, `${artifactPath}.sig`); + + await client.uploadArtifact( + UPDATER_ARTIFACT_NAME, + [artifactPath, `${artifactPath}.sig`], + ARTIFACTS_DIR + ); +}; + +const uploadStandalone = async ({ bundle, ext }: TargetConfig) => { + const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${ext}*`); + const standalonePath = files.find((f) => f.endsWith(ext)); + + if (!standalonePath) return console.error(`standalone path not found. ${files}`); + + const artifactName = `${ARTIFACT_BASE}.${ext}`; + const artifactPath = `${ARTIFACTS_DIR}/${artifactName}`; + + await io.cp(standalonePath, artifactPath, { recursive: true }); + await client.uploadArtifact(artifactName, [artifactPath], ARTIFACTS_DIR); +}; + +const run = async () => { + await io.mkdirP(ARTIFACTS_DIR); + const { updater, standalone } = OS_TARGETS[OS]; + + await uploadUpdater(updater); + for (const f of standalone) await uploadStandalone(f); +}; + +run(); diff --git a/.github/actions/publish-artifacts/package.json b/.github/actions/publish-artifacts/package.json new file mode 100644 index 0000000..a02cff9 --- /dev/null +++ b/.github/actions/publish-artifacts/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "scripts": { + "_build_comment": "there has to be a better way to do this lol", + "build": "ncc build index.ts --minify" + }, + "dependencies": { + "@actions/artifact": "^1.1.2", + "@actions/core": "^1.10.1", + "@actions/github": "^6.0.0", + "@actions/glob": "^0.4.0", + "@actions/io": "^1.1.3" + }, + "devDependencies": { + "@vercel/ncc": "^0.38.0" + } +} diff --git a/.github/actions/publish-artifacts/tsconfig.json b/.github/actions/publish-artifacts/tsconfig.json new file mode 100644 index 0000000..8b4fecf --- /dev/null +++ b/.github/actions/publish-artifacts/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2015", + "module": "ESNext", + "moduleResolution": "Node", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/.github/actions/setup-pnpm/action.yml b/.github/actions/setup-pnpm/action.yml new file mode 100644 index 0000000..97f462e --- /dev/null +++ b/.github/actions/setup-pnpm/action.yml @@ -0,0 +1,28 @@ +name: Setup Node.js, pnpm and dependencies +description: Setup Node.js, pnpm and dependencies +inputs: + token: + description: Github token + required: false + default: '' +runs: + using: 'composite' + steps: + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8.x.x + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + token: ${{ inputs.token }} + check-latest: true + node-version-file: '.nvmrc' + + - name: Install pnpm deps + shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }} + env: + NODE_ENV: debug + GITHUB_TOKEN: ${{ inputs.token }} + run: pnpm i --frozen-lockfile diff --git a/.github/actions/setup-rust/action.yaml b/.github/actions/setup-rust/action.yaml new file mode 100644 index 0000000..8cf9997 --- /dev/null +++ b/.github/actions/setup-rust/action.yaml @@ -0,0 +1,52 @@ +name: Setup Rust +description: Setup Rust +inputs: + target: + description: toolchain target triple + required: false + save-cache: + description: Whether to save the Rust cache + required: false + default: 'false' +runs: + using: 'composite' + steps: + - name: Install Rust + id: toolchain + uses: dtolnay/rust-toolchain@stable + with: + target: ${{ inputs.target }} + toolchain: stable + components: clippy, rustfmt + + - name: Cache Rust Dependencies + uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ inputs.save-cache }} + prefix-key: 'v0-rust-deps' + shared-key: ${{ inputs.target }} + + - name: Cargo config.toml + shell: bash + run: echo '{}' | npx -y mustache - .cargo/config.toml.mustache .cargo/config.toml + + - name: Restore cached Prisma codegen + id: cache-prisma-restore + uses: actions/cache/restore@v3 + with: + key: prisma-1-${{ runner.os }}-${{ hashFiles('./core/prisma/*', './Cargo.toml') }} + path: crates/prisma/src/**/*.rs + + - name: Generate Prisma client + working-directory: core + if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }} + shell: bash + run: cargo prisma generate + + - name: Save Prisma codegen + id: cache-prisma-save + if: ${{ inputs.save-cache == 'true' }} + uses: actions/cache/save@v3 + with: + key: ${{ steps.cache-prisma-restore.outputs.cache-primary-key }} + path: crates/prisma/src/**/*.rs diff --git a/.github/actions/setup-system/action.yml b/.github/actions/setup-system/action.yml new file mode 100644 index 0000000..3b33c82 --- /dev/null +++ b/.github/actions/setup-system/action.yml @@ -0,0 +1,36 @@ +name: Setup System and Rust +description: Setup System and Rust +inputs: + token: + description: Github token + required: false + default: '' + target: + description: toolchain target triple + required: false + setup-arg: + description: Argument for the system setup script + required: false + default: '' + save-cache: + description: Whether to save the System cache + required: false + default: 'false' +runs: + using: 'composite' + steps: + - name: Setup Rust and Dependencies + uses: ./.github/actions/setup-rust + with: + target: ${{ inputs.target }} + save-cache: ${{ inputs.save-cache }} + + - name: Run setup.sh script + shell: bash + if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} + run: ./.github/scripts/setup.sh ${{ inputs.setup-arg }} + + - name: Run setup.ps1 script + shell: powershell + if: ${{ runner.os == 'Windows' }} + run: ./.github/scripts/setup.ps1 diff --git a/.github/scripts/setup.ps1 b/.github/scripts/setup.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/.github/scripts/setup.sh b/.github/scripts/setup.sh new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/cache-factory.yaml b/.github/workflows/cache-factory.yaml new file mode 100644 index 0000000..d2535ab --- /dev/null +++ b/.github/workflows/cache-factory.yaml @@ -0,0 +1,77 @@ +# This workflow _produces_ caches which are used to speed up pull request builds. +# Originally from https://github.com/libp2p/rust-libp2p/blob/master/.github/workflows/cache-factory.yml + +name: Cache Factory + +on: + push: + paths: + - 'Cargo.lock' + - './scripts/setup.sh' + - './scripts/setup.ps1' + - '.github/workflows/cache-factory.yaml' + - '.github/actions/**/*.yml' + - '.github/actions/**/*.yaml' + - '**/build.rs' + - 'core/prisma/**' + branches: + - main + +# Cancel previous runs of the same workflow on the same branch. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + make_cache: + strategy: + fail-fast: true + matrix: + settings: + - host: macos-latest + target: x86_64-apple-darwin + - host: macos-latest + target: aarch64-apple-darwin + - host: windows-latest + target: x86_64-pc-windows-msvc + - host: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + name: 'Make Cache' + runs-on: ${{ matrix.settings.host }} + steps: + - name: Maximize build space + if: ${{ runner.os == 'Linux' }} + uses: easimon/maximize-build-space@master + with: + swap-size-mb: 3072 + root-reserve-mb: 6144 + remove-dotnet: 'true' + remove-codeql: 'true' + remove-haskell: 'true' + remove-docker-images: 'true' + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink target to C:\ + if: ${{ runner.os == 'Windows' }} + shell: powershell + run: | + New-Item -ItemType Directory -Force -Path C:\nexus_target + New-Item -Path target -ItemType Junction -Value C:\nexus_target + + - name: Setup System and Rust + uses: ./.github/actions/setup-system + with: + token: ${{ secrets.GITHUB_TOKEN }} + target: ${{ matrix.settings.target }} + save-cache: 'true' + + - name: Clippy + run: cargo clippy --workspace --all-features --target ${{ matrix.settings.target }} + + - name: Compile (debug) + run: cargo test --workspace --all-features --no-run --target ${{ matrix.settings.target }} + + - name: Compile (release) + run: cargo test --workspace --all-features --no-run --release --target ${{ matrix.settings.target }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4fbdbcd --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,102 @@ +name: Release + +on: + workflow_dispatch: + +# a lot of this isnt necessary but i'm designing ahead for tauri integration +jobs: + desktop-main: + strategy: + matrix: + settings: + - host: macos-latest + target: x86_64-apple-darwin + bundles: app,dmg + os: darwin + arch: x86_64 + - host: macos-latest + target: aarch64-apple-darwin + bundles: app,dmg + os: darwin + arch: aarch64 + - host: windows-latest + target: x86_64-pc-windows-msvc + bundles: msi + os: windows + arch: x86_64 + - host: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + bundles: deb,appimage + os: linux + arch: x86_64 + name: Desktop - Main ${{ matrix.settings.target }} + runs-on: ${{ matrix.settings.host }} + steps: + - name: Maximize build space + if: ${{ runner.os == 'Linux' }} + uses: easimon/maximize-build-space@master + with: + swap-size-mb: 3072 + root-reserve-mb: 6144 + remove-dotnet: 'true' + remove-codeql: 'true' + remove-haskell: 'true' + remove-docker-images: 'true' + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink target to C:\ + if: ${{ runner.os == 'Windows' }} + shell: powershell + run: | + New-Item -ItemType Directory -Force -Path C:\nexus_target + New-Item -Path target -ItemType Junction -Value C:\nexus_target + + - name: Remove 32-bit libs + if: ${{ runner.os == 'Linux' }} + run: | + dpkg -l | grep i386 + sudo apt-get purge --allow-remove-essential libc6-i386 ".*:i386" + sudo dpkg --remove-architecture i386 + + - name: Setup System and Rust + uses: ./.github/actions/setup-system + with: + token: ${{ secrets.GITHUB_TOKEN }} + target: ${{ matrix.settings.target }} + + - name: Setup Node.js, pnpm and dependencies + uses: ./.github/actions/setup-pnpm + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + run: | + pnpm tauri build --ci -v --target ${{ matrix.settings.target }} --bundles ${{ matrix.settings.bundles }},updater + + # this doesnt work rn so just uhh dont use it lol + - name: Publish Artifacts + uses: ./.github/actions/publish-artifacts + with: + os: ${{ matrix.settings.os }} + arch: ${{ matrix.settings.arch }} + target: ${{ matrix.settings.target }} + profile: release + + release: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + name: Create Release + needs: desktop-main + permissions: + contents: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + draft: true + files: '*/**' diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml new file mode 100644 index 0000000..b92345c --- /dev/null +++ b/.github/workflows/testing.yaml @@ -0,0 +1,142 @@ +name: CI + +on: + pull_request: + merge_group: + +# Cancel previous runs of the same workflow on the same branch. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + typescript: + name: TypeScript + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node.js, pnpm and dependencies + uses: ./.github/actions/setup-pnpm + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Perform typechecks + run: pnpm typecheck + + eslint: + name: ESLint + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node.js, pnpm and dependencies + uses: ./.github/actions/setup-pnpm + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Perform linting + run: pnpm lint + + rustfmt: + name: Rust Formatting + runs-on: ubuntu-20.04 + steps: + - name: Maximize build space + if: ${{ runner.os == 'Linux' }} + uses: easimon/maximize-build-space@master + with: + swap-size-mb: 3072 + root-reserve-mb: 6144 + remove-dotnet: 'true' + remove-codeql: 'true' + remove-haskell: 'true' + remove-docker-images: 'true' + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink target to C:\ + if: ${{ runner.os == 'Windows' }} + shell: powershell + run: | + New-Item -ItemType Directory -Force -Path C:\nexus_target + New-Item -Path target -ItemType Junction -Value C:\nexus_target + + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + changes: + - 'apps/cli/*/**' + - 'apps/desktop/crates/*/**' + - 'apps/desktop/src-tauri/*/**' + - 'core/**' + - 'crates/*/**' + - 'Cargo.toml' + - 'Cargo.lock' + + - name: Setup Rust + if: steps.filter.outputs.changes == 'true' + uses: ./.github/actions/setup-rust + + - name: Run rustfmt + if: steps.filter.outputs.changes == 'true' + run: cargo fmt --all -- --check + + clippy: + name: Clippy (${{ matrix.platform }}) + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [ubuntu-20.04, macos-latest, windows-latest] + steps: + - name: Maximize build space + if: ${{ runner.os == 'Linux' }} + uses: easimon/maximize-build-space@master + with: + swap-size-mb: 3072 + root-reserve-mb: 6144 + remove-dotnet: 'true' + remove-codeql: 'true' + remove-haskell: 'true' + remove-docker-images: 'true' + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink target to C:\ + if: ${{ runner.os == 'Windows' }} + shell: powershell + run: | + New-Item -ItemType Directory -Force -Path C:\nexus_target + New-Item -Path target -ItemType Junction -Value C:\nexus_target + + - uses: dorny/paths-filter@v2 + id: filter + with: + # this is also designing ahead for tauri + filters: | + changes: + - 'apps/cli/*/**' + - 'apps/desktop/crates/*/**' + - 'apps/desktop/src-tauri/*/**' + - 'core/**' + - 'crates/*/**' + - 'Cargo.toml' + - 'Cargo.lock' + + - name: Setup System and Rust + if: steps.filter.outputs.changes == 'true' + uses: ./.github/actions/setup-system + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run Clippy + if: steps.filter.outputs.changes == 'true' + uses: actions-rs/clippy-check@v1 + with: + args: --workspace --all-features + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 3504d58..2fd4ac2 100644 --- a/.gitignore +++ b/.gitignore @@ -642,6 +642,7 @@ iOSInjectionProject/ !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +!.vscode/tailwind.json !.vscode/*.code-snippets # Local History for Visual Studio Code diff --git a/.prettierrc.js b/.prettierrc.js index c223c9b..5eaa8c7 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -7,10 +7,13 @@ module.exports = { bracketSameLine: false, semi: true, quoteProps: 'consistent', - importOrder: ['', '^@polyfrost/(interface|client|ui)(/.*)?$', '^~/', '^\\.'], - importOrderSortSpecifiers: true, + importOrder: [ + '', + '^@polyfrost/(interface|client|ui)(/.*)?$', + '^~/', + '^\\.' + ], importOrderParserPlugins: ['importAssertions', 'typescript', 'jsx'], - pluginSearchDirs: false, plugins: ['@ianvs/prettier-plugin-sort-imports', 'prettier-plugin-tailwindcss'], tailwindConfig: './packages/ui/tailwind.config.js' -} +}; diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 412a742..7ecfae2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,8 +1,10 @@ { - "recommendations": [ - "tauri-apps.tauri-vscode", - "rust-lang.rust-analyzer", - "oscarbeaumont.rspc-vscode", - "EditorConfig.EditorConfig" - ] -} \ No newline at end of file + "recommendations": [ + "tauri-apps.tauri-vscode", + "rust-lang.rust-analyzer", + "oscarbeaumont.rspc-vscode", + "EditorConfig.EditorConfig", + "prisma.prisma", + "bradlc.vscode-tailwindcss" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 795cf25..1987dec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,28 +1,28 @@ { - "[rust]": { - "editor.defaultFormatter": "rust-lang.rust-analyzer" - }, - "rust-analyzer.procMacro.enable": true, - "rust-analyzer.diagnostics.experimental.enable": false, - "tailwindCSS.experimental.classRegex": [ - ["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"], // cva(....)`...` + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer" + }, + "rust-analyzer.procMacro.enable": true, + "rust-analyzer.diagnostics.experimental.enable": false, + "tailwindCSS.experimental.classRegex": [ + ["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"], // cva(....)`...` "tw\\.[^`]+`([^`]*)`", // tw.xxx`...` - "tw\\(.*?\\).*?`([^`]*)", // tw(....)`...` - ], - "search.exclude": { - "**/node_modules": true, - "**/bower_components": true, - "**/*.code-search": true, + "tw\\(.*?\\).*?`([^`]*)" // tw(....)`...` + ], + "search.exclude": { + "**/node_modules": true, + "**/bower_components": true, + "**/*.code-search": true, "**/pnpm-lock.yaml": true, - "**/.gitignore": true - }, - "eslint.lintTask.enable": true, - "eslint.workingDirectories": [ - - ], - "explorer.fileNesting.enabled": true, - "explorer.fileNesting.patterns": { - "*.ts": "${capture}.js", + "**/.gitignore": true, + "/packages/ctjs/types/*": true + }, + "css.customData": [".vscode/tailwind.json"], + "eslint.lintTask.enable": true, + "eslint.workingDirectories": [], + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + "*.ts": "${capture}.js", "*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts", "*.jsx": "${capture}.js", "*.tsx": "${capture}.ts", @@ -31,9 +31,9 @@ "README.md": "CONTRIBUTING.md, CODE_OF_CONDUCT.md, LICENSE", "Cargo.toml": "Cargo.lock", ".eslintrc.js": ".eslintcache", - ".prettierrc.*": ".rustfmt.toml, .gitattributes, .editorconfig, .clippy.toml", + ".prettierrc.*": ".rustfmt.toml, .gitattributes, .editorconfig, .clippy.toml", "package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, pnpm-workspace.yaml, .pnp.cjs, .pnp.loader.mjs", "tsconfig.json": "tsconfig.*.json", "flake.nix": "shell.nix, flake.lock, Cargo.nix" - } + } } diff --git a/.vscode/tailwind.json b/.vscode/tailwind.json new file mode 100644 index 0000000..a45bccc --- /dev/null +++ b/.vscode/tailwind.json @@ -0,0 +1,55 @@ +{ + "version": 1.1, + "atDirectives": [ + { + "name": "@tailwind", + "description": "Use the `@tailwind` directive to insert Tailwind's `base`, `components`, `utilities` and `screens` styles into your CSS.", + "references": [ + { + "name": "Tailwind Documentation", + "url": "https://tailwindcss.com/docs/functions-and-directives#tailwind" + } + ] + }, + { + "name": "@apply", + "description": "Use the `@apply` directive to inline any existing utility classes into your own custom CSS. This is useful when you find a common utility pattern in your HTML that you’d like to extract to a new component.", + "references": [ + { + "name": "Tailwind Documentation", + "url": "https://tailwindcss.com/docs/functions-and-directives#apply" + } + ] + }, + { + "name": "@responsive", + "description": "You can generate responsive variants of your own classes by wrapping their definitions in the `@responsive` directive:\n```css\n@responsive {\n .alert {\n background-color: #E53E3E;\n }\n}\n```\n", + "references": [ + { + "name": "Tailwind Documentation", + "url": "https://tailwindcss.com/docs/functions-and-directives#responsive" + } + ] + }, + { + "name": "@screen", + "description": "The `@screen` directive allows you to create media queries that reference your breakpoints by **name** instead of duplicating their values in your own CSS:\n```css\n@screen sm {\n /* ... */\n}\n```\n…gets transformed into this:\n```css\n@media (min-width: 640px) {\n /* ... */\n}\n```\n", + "references": [ + { + "name": "Tailwind Documentation", + "url": "https://tailwindcss.com/docs/functions-and-directives#screen" + } + ] + }, + { + "name": "@variants", + "description": "Generate `hover`, `focus`, `active` and other **variants** of your own utilities by wrapping their definitions in the `@variants` directive:\n```css\n@variants hover, focus {\n .btn-brand {\n background-color: #3182CE;\n }\n}\n```\n", + "references": [ + { + "name": "Tailwind Documentation", + "url": "https://tailwindcss.com/docs/functions-and-directives#variants" + } + ] + } + ] +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c029a2a..e1ea5d3 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -17,24 +17,24 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -- Demonstrating empathy and kindness toward other people -- Being respectful of differing opinions, viewpoints, and experiences -- Giving and gracefully accepting constructive feedback -- Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -- Focusing on what is best not just for us as individuals, but for the - overall community +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the + overall community Examples of unacceptable behavior include: -- The use of sexualized language or imagery, and sexual attention or - advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or email - address, without their explicit permission -- Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery, and sexual attention or + advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email + address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ## Enforcement Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0555dc9..d0bccb7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,12 +10,12 @@ This guide will provide an overview of the contribution workflow, including open To familiarize yourself with the project, please read the [README](README.md). Here are some resources to help you get started with open-source contributions: -- [Finding ways to contribute to open-source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github) -- [Setting up Git](https://docs.github.com/en/get-started/quickstart/set-up-git) -- [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow) -- [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests) -- [Getting started with Tauri](https://tauri.app/v1/guides/getting-started/prerequisites) -- [pnpm CLI](https://pnpm.io/pnpm-cli) +- [Finding ways to contribute to open-source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github) +- [Setting up Git](https://docs.github.com/en/get-started/quickstart/set-up-git) +- [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow) +- [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests) +- [Getting started with Tauri](https://tauri.app/v1/guides/getting-started/prerequisites) +- [pnpm CLI](https://pnpm.io/pnpm-cli) ## Getting Started @@ -39,29 +39,30 @@ To make changes locally, follow these steps: 1. Clone the repository: `git clone https://github.com/Polyfrost/Nexus` 2. Navigate to the project directory: `cd Nexus` -3. For Linux or MacOS users, run: `./.github/scripts/setup-system.sh` - - This will install all required dependencies for Nexus to build. -4. For Windows users, run the following command in PowerShell: `.\.github\scripts\setup-system.ps1` - - This will install pnpm and any other required dependencies for Nexus to build. +3. For Linux or MacOS users, run: `./.github/scripts/setup.sh` + - This will install all required dependencies for Nexus to build. +4. For Windows users, run the following command in PowerShell: `.\.github\scripts\setup.ps1` + - This will install pnpm and any other required dependencies for Nexus to build. + - Soon, this will be deprecated in favor of a build CLI system. 5. Install dependencies: `pnpm i` 6. Prepare the build: `pnpm prep` (This will run all necessary codegen and build required dependencies) To quickly run only the launcher after `prep`, you can use: -- `pnpm desktop dev` +- `pnpm desktop dev` - If necessary, react-devtools can be launched using `pnpm react-devtools`. - However, it must be executed before starting the desktop app for it to connect. + If necessary, react-devtools can be launched using `pnpm react-devtools`. + However, it must be executed before starting the desktop app for it to connect. To run the website app: -- `pnpm website dev` +- `pnpm website dev` If you encounter any issues, ensure that you are using the following versions of Rust, Node and Pnpm: -- Rust version: **1.70+** -- Node version: **18+** -- Pnpm version: **8.0+** +- Rust version: **1.70+** +- Node version: **18+** +- Pnpm version: **8.0+** After cleaning out your build artifacts using `pnpm clean`, `git clean`, or `cargo clean`, it is necessary to re-run the `setup-system` script. @@ -71,13 +72,13 @@ Make sure to read the [guidelines](https://docs.polyfrost.org/nexus/developers/p Once you have finished making your changes, create a pull request (PR) to submit them. -- Fill out the "Ready for review" template to help reviewers understand your changes and the purpose of your PR. -- If you are addressing an existing issue, don't forget to [link your PR to the issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue). -- Enable the checkbox to [allow maintainer edits](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork) so that the branch can be updated for merging. -- Once you submit your PR, a team member will review your proposal. They may ask questions or request additional information. -- You may be asked to make changes before the PR can be merged, either through [suggested changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request) or pull request comments. You can apply suggested changes directly through the UI. For other changes, you can make them in your fork and commit them to your branch. -- As you update your PR and apply changes, mark each conversation as [resolved](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations). -- If you run into any merge issues, refer to this [git tutorial](https://lab.github.com/githubtraining/managing-merge-conflicts) to help you resolve merge conflicts and other issues. +- Fill out the "Ready for review" template to help reviewers understand your changes and the purpose of your PR. +- If you are addressing an existing issue, don't forget to [link your PR to the issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue). +- Enable the checkbox to [allow maintainer edits](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork) so that the branch can be updated for merging. +- Once you submit your PR, a team member will review your proposal. They may ask questions or request additional information. +- You may be asked to make changes before the PR can be merged, either through [suggested changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request) or pull request comments. You can apply suggested changes directly through the UI. For other changes, you can make them in your fork and commit them to your branch. +- As you update your PR and apply changes, mark each conversation as [resolved](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations). +- If you run into any merge issues, refer to this [git tutorial](https://lab.github.com/githubtraining/managing-merge-conflicts) to help you resolve merge conflicts and other issues. ### Your PR is Merged @@ -91,4 +92,4 @@ to be added ### Credits -This CONTRIBUTING.md file was inspired by the [github/docs CONTRIBUTING.md](https://github.com/github/docs/blob/main/CONTRIBUTING.md) file, and we extend our gratitude to the original author. +This CONTRIBUTING.md file was inspired by the [github/docs CONTRIBUTING.md](https://github.com/github/docs/blob/main/CONTRIBUTING.md) file, and we extend our gratitude to the original authors. diff --git a/README.md b/README.md index 7a59bfa..e93b948 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # **Nexus** -![Logo](pkgs/assets/images/NexusLogo.png) +![Logo](packages/assets/images/NexusLogo.png) A monorepo containing our website, launcher, and tools used by Polyfrost. @@ -8,14 +8,14 @@ A monorepo containing our website, launcher, and tools used by Polyfrost. ## Apps -- [**`apps/desktop`**](apps/launcher): The Polyfrost launcher. -- [**`apps/website`**](apps/website): The Polyfrost website. -- [**`apps/cli`**](apps/cli): Our launcher's CLI. +- [**`apps/desktop`**](apps/launcher): The Polyfrost launcher. +- [**`apps/website`**](apps/website): The Polyfrost website. +- [**`apps/cli`**](apps/cli): Our launcher's CLI. ## Packages -- [**`core`**](core) The core of our launcher, written in Rust. -- [**`pkgs/client`**](pkgs/client) A TypeScript client library to handle dataflow via RPC between UIs and our Rust core. -- [**`pkgs/ui`**](pkgs/ui) A shared React component library for our UIs. -- [**`pkgs/interface`**](pkgs/interface) The complete user interface for our Launcher. -- [**`pkgs/config`**](pkgs/config) A TypeScript library to handle configuration files. +- [**`core`**](core) The core of our launcher, written in Rust. +- [**`packages/client`**](packages/client) A TypeScript client library to handle dataflow via RPC between UIs and our Rust core. +- [**`packages/ui`**](packages/ui) A shared React component library for our UIs. +- [**`packages/interface`**](packages/interface) The complete user interface for our Launcher. +- [**`packages/config`**](packages/config) A TypeScript library to handle configuration files. diff --git a/apps/website/.eslintrc.js b/apps/website/.eslintrc.js new file mode 100644 index 0000000..f80eaa9 --- /dev/null +++ b/apps/website/.eslintrc.js @@ -0,0 +1,8 @@ +/** @type {import('eslint').ESLint.ConfigData} */ +module.exports = { + extends: [require.resolve('@polyfrost/config/eslint/web.js')], + parserOptions: { + tsconfigRootDir: __dirname, + project: './tsconfig.json' + } +}; diff --git a/apps/website/astro.config.ts b/apps/website/astro.config.ts index c929648..98351a4 100644 --- a/apps/website/astro.config.ts +++ b/apps/website/astro.config.ts @@ -1,10 +1,7 @@ -import { defineConfig } from 'astro/config'; - import tailwind from '@astrojs/tailwind'; +import { defineConfig } from 'astro/config'; // https://astro.build/config export default defineConfig({ - integrations: [ - tailwind(), - ] + integrations: [tailwind()] }); diff --git a/apps/website/config.ts b/apps/website/config.ts index 1b45557..19c92a4 100644 --- a/apps/website/config.ts +++ b/apps/website/config.ts @@ -1,93 +1,83 @@ -import type { Config, NavbarDropdown, NavbarElement, Project } from "@webtypes/Config"; +import type { Config, NavbarDropdown, NavbarElement, Project } from '@webtypes/Config'; export const configConst = { - projects: getProjects(), - logos: [ - "oneconfig.minimal", - "polyfrost.full", - "polyfrost.minimal", - "polyfrost.minimal_bg", - ], - navbar: { - left: [ - { - logo: ["polyfrost.full", -1], - path: "/", - } - ], - right: [ - { - text: "Home", - path: "/", - }, - { - text: "Projects", - dropdown: (getProjects().map((project) => { - (project as any).path = `/projects/${project.name.toLowerCase()}`; - return project; - }) as unknown as NavbarDropdown[]) - } - ] - } + projects: getProjects(), + logos: ['oneconfig.minimal', 'polyfrost.full', 'polyfrost.minimal', 'polyfrost.minimal_bg'], + navbar: { + left: [ + { + logo: ['polyfrost.full', -1], + path: '/' + } + ], + right: [ + { + text: 'Home', + path: '/' + }, + { + text: 'Projects', + dropdown: getProjects().map((project) => { + (project as any).path = `/projects/${project.name.toLowerCase()}`; + return project; + }) as unknown as NavbarDropdown[] + } + ] + } } as const satisfies Config; function getProjects(): Project[] { - return [ - { - name: "OneConfig", - description: "The next-generation config library for Forge and Fabric", - logo: "oneconfig.minimal", - tag: "BETA" - }, - { - name: "OneLauncher", - description: "The next-generation launcher for Forge and Fabric", - logo: "polyfrost.minimal", - tag: "SOON" - }, - { - name: "OneConfig", - description: "The next-generation config library for Forge and Fabric", - logo: "oneconfig.minimal", - tag: "BETA" - }, - { - name: "OneLauncher", - description: "The next-generation launcher for Forge and Fabric", - logo: "polyfrost.minimal", - tag: "SOON" - }, - { - name: "OneConfig", - description: "The next-generation config library for Forge and Fabric", - logo: "oneconfig.minimal", - tag: "BETA" - }, - { - name: "OneLauncher", - description: "The next-generation launcher for Forge and Fabric", - logo: "polyfrost.minimal", - tag: "SOON" - }, - { - name: "OneConfig", - description: "The next-generation config library for Forge and Fabric", - logo: "oneconfig.minimal", - tag: "BETA" - }, - { - name: "OneLauncher", - description: "The next-generation launcher for Forge and Fabric", - logo: "polyfrost.minimal", - tag: "SOON" - }, - ] + return [ + { + name: 'OneConfig', + description: 'The next-generation config library for Forge and Fabric', + logo: 'oneconfig.minimal', + tag: 'BETA' + }, + { + name: 'OneLauncher', + description: 'The next-generation launcher for Forge and Fabric', + logo: 'polyfrost.minimal', + tag: 'SOON' + }, + { + name: 'OneConfig', + description: 'The next-generation config library for Forge and Fabric', + logo: 'oneconfig.minimal', + tag: 'BETA' + }, + { + name: 'OneLauncher', + description: 'The next-generation launcher for Forge and Fabric', + logo: 'polyfrost.minimal', + tag: 'SOON' + }, + { + name: 'OneConfig', + description: 'The next-generation config library for Forge and Fabric', + logo: 'oneconfig.minimal', + tag: 'BETA' + }, + { + name: 'OneLauncher', + description: 'The next-generation launcher for Forge and Fabric', + logo: 'polyfrost.minimal', + tag: 'SOON' + }, + { + name: 'OneConfig', + description: 'The next-generation config library for Forge and Fabric', + logo: 'oneconfig.minimal', + tag: 'BETA' + }, + { + name: 'OneLauncher', + description: 'The next-generation launcher for Forge and Fabric', + logo: 'polyfrost.minimal', + tag: 'SOON' + } + ]; } - - - - - // -------------------- NO TOUCH --------------------- // export default configConst as unknown as Config; diff --git a/apps/website/package.json b/apps/website/package.json index 556cae9..214a306 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -1,7 +1,7 @@ { "name": "@polyfrost/website", "type": "module", - "private": true, + "private": true, "scripts": { "dev": "astro dev", "start": "astro start", @@ -14,6 +14,8 @@ "tailwindcss": "^3.3.3" }, "devDependencies": { + "@polyfrost/config": "workspace:*", + "@types/node": "~18.17.19", "typescript": "^5.2.2" } } diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css index 51f3c19..6520592 100644 --- a/apps/website/src/styles/global.css +++ b/apps/website/src/styles/global.css @@ -1,11 +1,11 @@ @tailwind base; * { - font-family: 'Poppins', sans-serif; + font-family: 'Poppins', sans-serif; } @layer base { - :focus-visible { - @apply outline-none ring ring-blue-500; - } -} \ No newline at end of file + :focus-visible { + @apply outline-none ring ring-blue-500; + } +} diff --git a/apps/website/src/types/Config.d.ts b/apps/website/src/types/Config.d.ts index 82eb4d7..2781b1b 100644 --- a/apps/website/src/types/Config.d.ts +++ b/apps/website/src/types/Config.d.ts @@ -1,34 +1,34 @@ -import { type configConst } from "config"; +import { type configConst } from 'config'; -export type LogoType = typeof configConst.logos[number]; +export type LogoType = (typeof configConst.logos)[number]; export interface Project { - name: string, - description: string, - logo?: LogoType, - tag?: string, + name: string; + description: string; + logo?: LogoType; + tag?: string; } export type NavbarDropdown = { - name: string, - description: string, - path: string, - logo?: LogoType, - tag?: string -} + name: string; + description: string; + path: string; + logo?: LogoType; + tag?: string; +}; export type NavbarElement = { - text?: string, - logo?: [string, number], - path?: string, - dropdown?: NavbarDropdown[], -} + text?: string; + logo?: [string, number]; + path?: string; + dropdown?: NavbarDropdown[]; +}; export interface Config { - projects: Project[], - logos: string[], - navbar: { - left: NavbarElement[], - right: NavbarElement[], - }, -} \ No newline at end of file + projects: Project[]; + logos: string[]; + navbar: { + left: NavbarElement[]; + right: NavbarElement[]; + }; +} diff --git a/apps/website/tailwind.config.cjs b/apps/website/tailwind.config.cjs new file mode 100644 index 0000000..3cf5259 --- /dev/null +++ b/apps/website/tailwind.config.cjs @@ -0,0 +1,53 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'], + theme: { + colors: { + blue: { + 500: 'rgba(31, 101, 214, 1)' + }, + gray: { + 50: 'rgba(240, 242, 244, 1)', + 400: 'rgba(138, 150, 168, 1)', + 700: 'rgba(65, 74, 88, 1)', + 800: 'rgba(42, 47, 55, 1)' + }, + white: { + DEFAULT: 'rgba(255, 255, 255, 1)', + secondary: 'rgba(238, 241, 254, 1)', + hover: 'rgba(231, 235, 252, 1)' + }, + black: { + DEFAULT: 'rgba(0, 0, 0, 1)' + }, + text: { + DEFAULT: 'rgba(2, 3, 7, 1)', + primary: 'rgba(2, 3, 7, 1)' + } + }, + borderRadius: { + none: '0', + sm: '3px', + md: '5px', + lg: '8px', + xl: '12px', + full: '100vw' + }, + fontSize: { + 'xs': '12px', + 'sm': '14px', + 'md': '16px', + 'lg': '18px', + + 'header-sm': '24px', + 'header': '28px', + 'header-lg': '32px', + + 'body-sm': '15px', + 'body': '16px', + 'body-lg': '17px' + }, + extend: {} + }, + plugins: [] +}; diff --git a/apps/website/tsconfig.json b/apps/website/tsconfig.json index 17881e6..dbadc64 100644 --- a/apps/website/tsconfig.json +++ b/apps/website/tsconfig.json @@ -1,10 +1,15 @@ { - "extends": "astro/tsconfigs/base", + "extends": "astro/tsconfigs/strict", "compilerOptions": { + "baseUrl": ".", + "composite": true, "paths": { - "@layouts/*": ["src/layouts/*"], "@components/*": ["src/components/*"], - "@pages/*": ["src/pages/*"] + "@layouts/*": ["src/layouts/*"], + "@webtypes/*": ["src/types/*"], + "@lib/*": ["src/lib/*"], + "@public/*": ["public/*"], + "@config": ["config.ts"] } } } diff --git a/package.json b/package.json index a8163aa..ca76bd2 100644 --- a/package.json +++ b/package.json @@ -1,31 +1,50 @@ { - "name": "@polyfrost/nexus", - "version": "0.0.0", - "private": true, - "scripts": { - "website": "pnpm --filter @polyfrost/website" - }, - "devDependencies": { - "@babel/plugin-syntax-import-assertions": "^7.22.5", - "@ianvs/prettier-plugin-sort-imports": "^4.1.1", - "@storybook/react-vite": "^7.4.6", - "prettier": "^3.0.3", - "prettier-plugin-tailwindcss": "^0.5.6", - "turbo": "^1.10.15", - "turbo-ignore": "^1.10.15", - "typescript": "^5.2.2", - "vite": "^4.4.11" - }, - "overrides": { - "@types/node": "~18.17.19" - }, - "engines": { - "pnpm": ">=8.0.0", - "npm": "pnpm", - "yarn": "pnpm", - "node": ">=18.17 <19 || >=20.1" - }, - "eslintConfig": { - "root": true - } + "name": "@polyfrost/nexus", + "version": "0.0.0", + "private": true, + "scripts": { + "build": "turbo run build", + "typecheck": "pnpm -r typecheck", + "format": "prettier --write .", + "lint": "turbo run lint", + "lint:fix": "turbo run lint -- --fix", + "clean": "git clean -qfX .", + "prisma": "cd core && cargo prisma", + "tauri": "pnpm desktop tauri", + "desktop": "pnpm --filter @polyfrost/desktop -- ", + "website": "pnpm --filter @polyfrost/website -- ", + "interface": "pnpm --filter @polyfrost/interface -- ", + "assets": "pnpm --filter @polyfrost/assets -- ", + "client": "pnpm --filter @polyfrost/client -- ", + "storybook": "pnpm --filter @polyfrost/storybook -- ", + "ui": "pnpm --filter @polyfrost/ui -- ", + "prep": "pnpm gen:prisma", + "postprep": "pnpm codegen", + "gen:migrations": "cd core && cargo prisma migrate dev", + "gen:prisma": "cd core && cargo prisma generate", + "codegen": "cargo test -p nexus-core api::tests::gen -- --exact" + }, + "devDependencies": { + "@babel/plugin-syntax-import-assertions": "^7.22.5", + "@ianvs/prettier-plugin-sort-imports": "^4.1.1", + "@storybook/react-vite": "^7.4.6", + "prettier": "^3.0.3", + "prettier-plugin-tailwindcss": "^0.5.6", + "turbo": "^1.10.15", + "turbo-ignore": "^1.10.15", + "typescript": "^5.2.2", + "vite": "^4.4.11" + }, + "overrides": { + "@types/node": "~18.17.19" + }, + "engines": { + "pnpm": ">=8.0.0", + "npm": "pnpm", + "yarn": "pnpm", + "node": ">=18.17 <19 || >=20.1" + }, + "eslintConfig": { + "root": true + } } diff --git a/packages/assets/README.md b/packages/assets/README.md new file mode 100644 index 0000000..bbe042c --- /dev/null +++ b/packages/assets/README.md @@ -0,0 +1,3 @@ +# shared assets + +all svgs and other shared assets put here diff --git a/packages/assets/package.json b/packages/assets/package.json new file mode 100644 index 0000000..cc29174 --- /dev/null +++ b/packages/assets/package.json @@ -0,0 +1,8 @@ +{ + "name": "@polyfrost/assets", + "version": "0.0.0", + "private": true, + "scripts": { + "gen": "node ./scripts/generate.mjs" + } +} diff --git a/packages/assets/scripts/generate.mjs b/packages/assets/scripts/generate.mjs new file mode 100644 index 0000000..44ba4e4 --- /dev/null +++ b/packages/assets/scripts/generate.mjs @@ -0,0 +1,62 @@ +import fs from 'node:fs/promises'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import prettier from 'prettier'; + +const assetFolders = ['icons', 'images', 'svgs/brands', 'svgs/ext/Extras', 'svgs/ext/Code']; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +prettier.resolveConfig(join(__dirname, '..', '..', '..', '.prettierrc.js')).then((options) => + Promise.all( + assetFolders.map(async (folder) => { + const indexFilePath = join(__dirname, '..', folder, 'index.ts'); + const assetsFolderPath = join(__dirname, '..', folder); + + if ( + await fs.access(indexFilePath).then( + () => true, + () => false + ) + ) { + await fs.unlink(indexFilePath); + } + + const fileNames = await fs.readdir(assetsFolderPath); + + const assetImports = fileNames + .filter((fileName) => fileName !== 'index.ts' && !/(^|\/)\.[^\/\.]/g.test(fileName)) + .map((fileName) => { + const variableName = fileName.split('.')[0].replace(/-/g, ''); + if (folder.startsWith('svgs')) { + return `import { ReactComponent as ${variableName} } from './${fileName}';`; + } + return `import ${variableName} from './${fileName}';`; + }) + .join('\n'); + + const assetExports = fileNames + .filter((fileName) => fileName !== 'index.ts' && !/(^|\/)\.[^\/\.]/g.test(fileName)) + .map((fileName) => `${fileName.split('.')[0].replace(/-/g, '')}`) + .join(',\n'); + + const indexFileContent = await prettier.format( + ` + /* + * This file was automatically generated by a script. + * To regenerate this file, run: pnpm assets gen + */ + + ${assetImports} + + export { + ${assetExports} + };`, + { ...options, parser: 'typescript' } + ); + + await fs.writeFile(indexFilePath, indexFileContent); + }) + ) +); diff --git a/packages/config/.eslintrc.js b/packages/config/.eslintrc.js new file mode 100644 index 0000000..93a0c63 --- /dev/null +++ b/pac