Skip to content

Commit

Permalink
Merge pull request #8 from thulasi-ram/main
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
thulasi-ram authored Aug 30, 2023
2 parents 1a9c62b + 6ef7392 commit d3a4cf4
Show file tree
Hide file tree
Showing 44 changed files with 1,725 additions and 210 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/discussions_dump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Dump Discussions Workflow

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

jobs:
discussions_dump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd ./scripts
npm ci
ls -lahtr
node ./discussions_dump.js
- uses: actions/[email protected]
with:
name: discussions_dump.json
path: ./scripts/discussions_dump.json
if-no-files-found: error
upload_dump_to_s3:
runs-on: ubuntu-latest
needs: [discussions_dump]
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- uses: actions/[email protected]
- run: ls -lahtr
- run: pwd
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_SAD_UPLOADER_ROLE }}
# use recursive: https://github.com/aws/aws-cli/issues/2929
- run: aws s3 cp discussions_dump.json s3://simple-android-debloater --recursive
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'publish'
name: 'Publish Cross Platform Builds'
on:
push:
branches:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-*
*.db
*.db-shm
*.db-wal
*.db-wal
discussions_dump.json
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,27 @@ Unlike UAD, this tool is aimed to be beginner friendly so as to not uninstall ap



## Features

### Standard features
- Disabling and Enabling a package
- Auto detect devices and heartbeats
- Customizable prompt settings
- Search and Filter Packages

## Download
### Features over UAD
- Labels and Discussions powered by Github Discussions
- Can be crowdsourced and moderated
- Refreshed automatically once a day and can be triggered manually
- ![Discussion Screenshot](./static/screenshots/discussion.png)
- Bulk Enable and Disable
- ![Bulk Disable Screenshot](./static/screenshots/bulk_disable_packages.png)
- Export and Import Settings, Results and Other data
- ![Export Screenshot](./static/screenshots/export_packages.png)
- ![Import Screenshot](./static/screenshots/import_packages.png)


## Download

Goto the latest [Releases Page](https://github.com/thulasi-ram/simple_android_debloater/releases) click on assets and download the installers applicable for your OS.

Expand All @@ -33,6 +51,9 @@ Screenshots are available in [static](./static/screenshots) directory.
- This requires one to enable developer options
- In the PC
- Make sure to download [ADB Tools](https://developer.android.com/tools/releases/platform-tools#downloads) for your PC.
- ADB need not be in Path. Setting path is tedious in windows.
- Use settings -> custom_adb_path pointing to the downloaded folder
- - ![Settings Screenshot](./static/screenshots/settings.png)

[Read More from XDA On Setting up USB Debugging and ABD](https://www.xda-developers.com/install-adb-windows-macos-linux/)

Expand Down Expand Up @@ -83,8 +104,16 @@ Run rust and node at once:

- [x] Adb track device

- [ ] Github discussion for package
- [x] Github discussion for package

- [x] ~Prepackage ADB~ Custom ADB Path Instead

- [x] Persist Settings
- [x] Persist Settings

- [x] Dark Mode

- [x] Export Packages in CSV / JSON

- [x] Import CSV and Bulk Enable / Disable

- [ ] SDK Compatability checks
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@sveltejs/adapter-static": "^1.0.0-next.50",
"@sveltejs/kit": "^1.20.4",
"@tauri-apps/cli": "^1.4.0",
"@types/papaparse": "^5.3.8",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"autoprefixer": "^10.4.14",
Expand All @@ -42,6 +43,7 @@
"flowbite-svelte": "^0.40.2",
"flowbite-svelte-icons": "^0.3.6",
"lru-cache": "^10.0.1",
"papaparse": "^5.4.1",
"tailwind-merge": "^1.14.0",
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log"
}
Expand Down
131 changes: 131 additions & 0 deletions scripts/discussions_dump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// https://stepzen.com/blog/consume-graphql-in-javascript
// https://stackoverflow.com/questions/42938472/what-is-the-reason-for-having-edges-and-nodes-in-a-connection-in-your-graphql-sc
// https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions
import fetch from 'node-fetch';
import fs from 'fs';

async function getDiscussions(no_of_discussions, next_cursor) {
const reqData = JSON.stringify({
query: `query($no_of_discussions:Int!, $next_cursor: String) {
repository(owner: "thulasi-ram", name: "simple_android_debloater") {
discussions(first: $no_of_discussions, after: $next_cursor) {
# type: DiscussionConnection
totalCount # Int!
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
nodes {
# type: Discussion
id
title
closed
body
bodyHTML
url
answer {
body
bodyHTML
}
labels(first: 100) {
totalCount
nodes {
name
description
}
}
}
}
}
}`,
variables: `{
"no_of_discussions": ${no_of_discussions},
"next_cursor": ${next_cursor == null ? null : `"${next_cursor}"`}
}`
});

const response = await fetch('https://api.github.com/graphql', {
method: 'post',
body: reqData,
headers: {
'Content-Type': 'application/json',
'Content-Length': reqData.length,
Authorization: 'bearer ' + process.env.GH_TOKEN,
'User-Agent': 'Node'
}
});
const json = await response.json();

let data = json.data;

if (!data) {
console.log(response);
console.log(json);
throw new Error('Error in response json');
}

const discussions = data?.repository?.discussions;

if (!discussions) {
console.log(JSON.stringify(data));
}

return discussions;
}

async function getAllDiscussions() {
// https://stackoverflow.com/questions/71952373/how-to-run-graphql-query-in-a-loop-until-condition-is-not-matched

let hasNext = true;
let nextCursor = null;
let allDiscussions = [];
while (hasNext) {
let discussionsData = await getDiscussions(1, nextCursor);
if (!discussionsData) {
break;
}
hasNext = discussionsData.pageInfo.hasNextPage;
nextCursor = discussionsData.pageInfo.endCursor;
allDiscussions.push(...discussionsData.nodes);
}

allDiscussions = allDiscussions.map((d) => parseDiscussion(d)).filter((d) => d != null);
let discussionsDump = JSON.stringify(allDiscussions);
console.log(discussionsDump);

fs.writeFile('discussions_dump.json', discussionsDump, 'utf8', function (err) {
if (err) throw err;
console.log('Dumped json');
});
}

const FILTER_BY_PACKAGE_LABEL = 'pkg';

function parseDiscussion(discussion) {
if (!discussion) {
return null;
}

const labelCount = discussion.labels?.totalCount;
if (labelCount && labelCount > 100) {
console.error(`"discussoon ${discussion} has more than 100 labels"`);
}
const labels = discussion.labels?.nodes;
if (!labels) {
return null;
}

let matched = labels.filter((l) => l.name === FILTER_BY_PACKAGE_LABEL);
if (!matched) {
return null;
}
discussion.labels = labels;
return discussion;
}

getAllDiscussions();
Loading

0 comments on commit d3a4cf4

Please sign in to comment.