aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauline <git@ethanlibs.co>2023-10-14 22:27:27 -0400
committerPauline <git@ethanlibs.co>2023-10-14 22:27:27 -0400
commit2582162cea2b3a59cd21c78f8b73cb03d0acad40 (patch)
tree432057475f3b51850a85e2cba9969bcb79f3a8e6
parent06f51ccdc496a6581d098edc424f3973e550221d (diff)
downloadNexus-2582162cea2b3a59cd21c78f8b73cb03d0acad40.tar.gz
Nexus-2582162cea2b3a59cd21c78f8b73cb03d0acad40.tar.bz2
Nexus-2582162cea2b3a59cd21c78f8b73cb03d0acad40.zip
refactor(trunk): refactor the entire project idk
-rw-r--r--.cargo/config.toml.mustache23
-rw-r--r--.cargo/readme.md3
-rw-r--r--.editorconfig2
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.yml61
-rw-r--r--.github/ISSUE_TEMPLATE/config.yml13
-rw-r--r--.github/actions/publish-artifacts/.gitignore2
-rw-r--r--.github/actions/publish-artifacts/action.yaml14
-rw-r--r--.github/actions/publish-artifacts/index.ts101
-rw-r--r--.github/actions/publish-artifacts/package.json17
-rw-r--r--.github/actions/publish-artifacts/tsconfig.json11
-rw-r--r--.github/actions/setup-pnpm/action.yml28
-rw-r--r--.github/actions/setup-rust/action.yaml52
-rw-r--r--.github/actions/setup-system/action.yml36
-rw-r--r--.github/scripts/setup.ps10
-rw-r--r--.github/scripts/setup.sh0
-rw-r--r--.github/workflows/cache-factory.yaml77
-rw-r--r--.github/workflows/release.yaml102
-rw-r--r--.github/workflows/testing.yaml142
-rw-r--r--.gitignore1
-rw-r--r--.prettierrc.js11
-rw-r--r--.vscode/extensions.json16
-rw-r--r--.vscode/settings.json48
-rw-r--r--.vscode/tailwind.json55
-rw-r--r--CODE_OF_CONDUCT.md30
-rw-r--r--CONTRIBUTING.md51
-rw-r--r--README.md18
-rw-r--r--apps/website/.eslintrc.js8
-rw-r--r--apps/website/astro.config.ts7
-rw-r--r--apps/website/config.ts158
-rw-r--r--apps/website/package.json4
-rw-r--r--apps/website/src/styles/global.css10
-rw-r--r--apps/website/src/types/Config.d.ts48
-rw-r--r--apps/website/tailwind.config.cjs53
-rw-r--r--apps/website/tsconfig.json11
-rw-r--r--package.json77
-rw-r--r--packages/assets/README.md3
-rw-r--r--packages/assets/package.json8
-rw-r--r--packages/assets/scripts/generate.mjs62
-rw-r--r--packages/config/.eslintrc.js4
-rw-r--r--packages/config/app.tsconfig.json7
-rw-r--r--packages/config/base.tsconfig.json22
-rw-r--r--packages/config/eslint/base.js79
-rw-r--r--packages/config/eslint/tailwind.js23
-rw-r--r--packages/config/eslint/web.js22
-rw-r--r--packages/config/index.js3
-rw-r--r--packages/config/package.json29
-rw-r--r--packages/config/vite/index.ts27
-rw-r--r--packages/config/vite/relAlias.ts77
-rw-r--r--packages/ui/.eslintrc.js8
-rw-r--r--packages/ui/package.json51
-rw-r--r--packages/ui/postcss.config.js3
-rw-r--r--packages/ui/src/index.ts1
-rw-r--r--packages/ui/src/keys.ts56
-rw-r--r--packages/ui/src/utils.tsx28
-rw-r--r--packages/ui/style/index.js1
-rw-r--r--packages/ui/style/postcss.config.js1
-rw-r--r--packages/ui/style/style.scss30
-rw-r--r--packages/ui/style/tailwind.js119
-rw-r--r--packages/ui/style/tailwind.pcss4
-rw-r--r--packages/ui/tailwind.config.js2
-rw-r--r--packages/ui/tsconfig.json8
-rw-r--r--pkgs/ctjs/index.js3
-rw-r--r--pkgs/ctjs/metadata.json9
-rw-r--r--pkgs/ctjs/package.json4
-rw-r--r--pkgs/ctjs/types/ctjs.d.ts14053
-rw-r--r--pkgs/ctjs/types/schema.json77
-rw-r--r--pnpm-lock.yaml2955
-rw-r--r--pnpm-workspace.yaml9
-rw-r--r--tsconfig.json7
69 files changed, 4525 insertions, 14560 deletions
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<TargetConfig>;
+};
+
+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<OS, BuildTarget>;
+
+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
--- /dev/null
+++ b/.github/scripts/setup.ps1
diff --git a/.github/scripts/setup.sh b/.github/scripts/setup.sh
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.github/scripts/setup.sh
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