Ready for release
This commit is contained in:
parent
31d29253ab
commit
d0124cef8a
3 changed files with 121 additions and 105 deletions
22
README.md
Normal file
22
README.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Kernel Package Downloader
|
||||
|
||||
A package for the [kernel client mod](https://github.com/kernel-mod/) to download other packages from the #packages-link channel with a single click. (Compatable with openasar)
|
||||
|
||||

|
||||
|
||||
## Prerequisites
|
||||
|
||||
### [Webpack Package](https://github.com/strencher-kernel/webpack)
|
||||
|
||||
To install the webpack package:
|
||||
|
||||
1. `cd <your kernel packages folder>`
|
||||
2. `git clone https://github.com/strencher-kernel/webpack`
|
||||
|
||||
## Installation
|
||||
|
||||
**Before you follow this make sure you have the prerequisites.**
|
||||
|
||||
1. `cd <your kernel packages folder>`
|
||||
2. `git clone https://github.com/Henry-Hiles/kernel-package-downloader`
|
||||
3. Restart discord with `Ctrl+R`
|
|
@ -9,8 +9,7 @@ const execWithPromise = async (command, options) =>
|
|||
)
|
||||
)
|
||||
|
||||
contextBridge.exposeInMainWorld("package", {
|
||||
install: async (link) => {
|
||||
contextBridge.exposeInMainWorld("installPackage", async (link) => {
|
||||
const packagesPath = resolve(__dirname, "..")
|
||||
try {
|
||||
await execWithPromise(`git clone ${link[0]}`, {
|
||||
|
@ -24,5 +23,4 @@ contextBridge.exposeInMainWorld("package", {
|
|||
console.error(error)
|
||||
return true
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
42
renderer.js
42
renderer.js
|
@ -2,8 +2,13 @@
|
|||
|
||||
export default new (class PackageDownloader {
|
||||
async start() {
|
||||
const pluginLog = (msg, logFunc = console.info) =>
|
||||
logFunc(`%c[${this.constructor.name}] `, "color:#14bbaa", msg)
|
||||
|
||||
pluginLog("Started successfully")
|
||||
|
||||
await Webpack.whenReady
|
||||
const { React } = window.Webpack.common
|
||||
const { React } = Webpack.common
|
||||
const MiniPopover = Webpack.findByDisplayName("MiniPopover", {
|
||||
default: true,
|
||||
})
|
||||
|
@ -27,16 +32,11 @@ export default new (class PackageDownloader {
|
|||
props.channel.id == "899717501120806963"
|
||||
)
|
||||
args[0].children.unshift(
|
||||
React.createElement(
|
||||
(componentProps) => {
|
||||
const [disabled, setDisabled] =
|
||||
React.useState(false)
|
||||
const props = componentProps.props
|
||||
React.createElement(() => {
|
||||
const [disabled, setDisabled] = React.useState(false)
|
||||
|
||||
const gitURL = props.message.content
|
||||
.slice(
|
||||
props.message.content.indexOf("Repository")
|
||||
)
|
||||
.slice(props.message.content.indexOf("Repository"))
|
||||
.match(
|
||||
/((git@|http(s)?:\/\/)([\w\.@]+)(\/|:))([\w,\-,\_]+)\/([\w,\-,\_]+)(.git){0,1}((\/){0,1})/
|
||||
)
|
||||
|
@ -67,7 +67,7 @@ export default new (class PackageDownloader {
|
|||
onClick: async () => {
|
||||
setDisabled(true)
|
||||
const failed =
|
||||
await window.package.install(
|
||||
await window.installPackage(
|
||||
gitURL
|
||||
)
|
||||
|
||||
|
@ -79,9 +79,9 @@ export default new (class PackageDownloader {
|
|||
.ERROR
|
||||
)
|
||||
)
|
||||
console.error(
|
||||
`[${this.constructor.name}]`,
|
||||
"Package installation failed, error above."
|
||||
pluginLog(
|
||||
"Package installation failed, error above.",
|
||||
console.error
|
||||
)
|
||||
setDisabled(false)
|
||||
} else {
|
||||
|
@ -92,9 +92,7 @@ export default new (class PackageDownloader {
|
|||
.SUCCESS
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
`%c[${this.constructor.name}]`,
|
||||
"color:#14bbaa",
|
||||
pluginLog(
|
||||
"Successfully installed package! Please reload discord with Ctrl+R."
|
||||
)
|
||||
}
|
||||
|
@ -116,14 +114,9 @@ export default new (class PackageDownloader {
|
|||
)
|
||||
)
|
||||
),
|
||||
React.createElement(
|
||||
MiniPopover.Separator,
|
||||
null
|
||||
),
|
||||
React.createElement(MiniPopover.Separator),
|
||||
]
|
||||
},
|
||||
{ props }
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
return funcCopy.apply(this, args)
|
||||
|
@ -131,8 +124,11 @@ export default new (class PackageDownloader {
|
|||
|
||||
Object.assign(MiniPopover.default, funcCopy)
|
||||
|
||||
pluginLog("Patched, ready to download packages!")
|
||||
|
||||
this.stop = () => {
|
||||
MiniPopover.default = funcCopy
|
||||
pluginLog("Stopped successfully")
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
|
Reference in a new issue