Skip to content

Commit

Permalink
feat: facilitate webview dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Infi <[email protected]>
  • Loading branch information
infi committed Jan 1, 2025
1 parent d95c0ef commit 628d17d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ local.properties
revoltbuild.properties
sentry.properties
/.kotlin/sessions
app/src/main/assets/embedded
24 changes: 17 additions & 7 deletions docs/src/content/docs/contributing/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,34 @@ import { Tabs, TabItem, Steps } from "@astrojs/starlight/components"

</Tabs>

3. Clone the repository.
3. Download [Deno](https://deno.com).

_Please see the [Deno Runtime Manual](https://docs.deno.com/runtime/getting_started/installation/) for installation guidance._

4. Clone the repository.

```sh
git clone --recursive https://github.com/revoltchat/android.git
```

Specify `--recursive` to ensure that submodules are cloned as well.

4. Open the project in Android Studio.
5. Open the project in Android Studio.

5. Install the required dependencies.
6. Install the required dependencies.

- Android SDK, latest version
- Android NDK, latest version

You can install these from the SDK Manager in Android Studio.

6. Copy the `revoltbuild.properties.example` file to `revoltbuild.properties` and fill in the required values.
7. Download required additional, embedded dependencies using the provided script.

```sh
deno run -A scripts/download_deps.ts
```

8. Copy the `revoltbuild.properties.example` file to `revoltbuild.properties` and fill in the required values.

```sh
cp revoltbuild.properties.example revoltbuild.properties
Expand All @@ -110,7 +120,7 @@ import { Tabs, TabItem, Steps } from "@astrojs/starlight/components"
| `build.debug.app_name` | The name of the app in debug builds, arbitrary |
| `build.flavour_id` | Leave as `ZZUU` |

7. Copy the `sentry.properties.example` file to `sentry.properties` and fill in the required values.
9. Copy the `sentry.properties.example` file to `sentry.properties` and fill in the required values.

```sh
cp sentry.properties.example sentry.properties
Expand All @@ -127,11 +137,11 @@ import { Tabs, TabItem, Steps } from "@astrojs/starlight/components"

You can get these values from the Sentry dashboard.

8. Build the project.
10. Build the project.

You can build the project by clicking on the 'Run' button in Android Studio.
If asked, build the `:app` module.

9. **You're all set!** You can now start contributing to Revolt on Android.
11. **You're all set!** You can now start contributing to Revolt on Android.

</Steps>
71 changes: 71 additions & 0 deletions scripts/download_deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { resolve } from "jsr:@std/path"

const outputFolderParent = resolve(Deno.cwd(), "app", "src", "main", "assets")

try {
Deno.statSync(outputFolderParent)
} catch (_) {
console.error(
"\x1b[31m" + // red
"Did you run this script from the correct directory?" +
"\x1b[0m"
)
console.error(
"Usage: " +
"\x1b[35m" + // magenta
"deno run -A scripts/download_deps.ts" +
"\x1b[0m" +
" from the " +
"\x1b[1;31;4m" + // bold red underline
"root" +
"\x1b[0m" +
" directory of the project."
)
Deno.exit(1)
}

const outputFolder = resolve(outputFolderParent, "embedded")

// If it exists, delete it
try {
Deno.removeSync(outputFolder, { recursive: true })
} catch (_) {
// Ignore, might not exist
}

// Create the output folder
Deno.mkdirSync(outputFolder, { recursive: true })

const deps = [
{
file: "katex.min.css",
url: "https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css",
},
{
file: "katex.min.js",
url: "https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js",
},
{
file: "micromark.bundle.js",
url: "https://esm.sh/v135/[email protected]/es2022/micromark.bundle.mjs",
},
]

console.log("Will download the following files:")
for (const dep of deps) {
console.log(`- ${dep.file} from ${dep.url}`)
}
if (!confirm("Continue?")) {
console.log("Aborted.")
Deno.exit(0)
}

for (const dep of deps) {
const response = await fetch(dep.url)
const data = await response.arrayBuffer()
const file = resolve(outputFolder, dep.file)
Deno.writeFileSync(file, new Uint8Array(data))
console.log(`Downloaded ${dep.file} to ${file}`)
}

console.log("Done.")

0 comments on commit 628d17d

Please sign in to comment.