Skip to content

Commit

Permalink
ext: add disable-apple-quarantine extension
Browse files Browse the repository at this point in the history
  • Loading branch information
HuakunShen committed Sep 4, 2024
1 parent 17d95dd commit 36d43c6
Show file tree
Hide file tree
Showing 8 changed files with 1,727 additions and 0 deletions.
13 changes: 13 additions & 0 deletions extensions/disable-apple-quarantine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Disable Apple Quarantine

Mac Apps made by developers not paying Apple's $99/year developer fee are marked as "damaged" by Apple. This is because they are not signed by an Apple Developer ID.

This extension allows you to disable Apple Quarantine on these apps.

There are 3 ways:

1. Drag and Drop damanged .app files here
2. Copy the .app file, this extension will automatically detect the copied file
3. Select the .app file in Finder, this extension will automatically detect the selected file

Method 2 and 3 require you to copy or select the file before entering this extension.
20 changes: 20 additions & 0 deletions extensions/disable-apple-quarantine/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { watch } from "fs"
import { join } from "path"
import { refreshTemplateWorkerExtension } from "@kksh/api/dev"
import { $ } from "bun"

async function build() {
await $`bun build --minify --target=browser --outdir=./dist ./src/index.ts`
await refreshTemplateWorkerExtension()
}

const srcDir = join(import.meta.dir, "src")

await build()

if (Bun.argv.includes("dev")) {
console.log(`Watching ${srcDir} for changes...`)
watch(srcDir, { recursive: true }, async (event, filename) => {
await build()
})
}
117 changes: 117 additions & 0 deletions extensions/disable-apple-quarantine/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import {
Action,
expose,
Form,
fs,
Icon,
IconEnum,
List,
path,
shell,
toast,
ui,
WorkerExtension
} from "@kksh/api/ui/worker"

shell.executeBashScript("echo 'Hello, World!'").then(console.log)

class ExtensionTemplate extends WorkerExtension {
async onFormSubmit(value: Record<string, any>): Promise<void> {
console.log("Form submitted", value)
toast.success(`Form submitted: ${JSON.stringify(value)}`)
}
async load() {
return ui.render(
new Form.Form({
key: "form1",
fields: [
new Form.NumberField({
key: "age",
label: "Age",
placeholder: "Enter your age"
})
// new Form.NumberField({
// key: "age"
// }),
// new Form.Form({
// key: "random",
// fields: [
// new Form.BooleanField({ key: "Server On" }),
// new Form.ArrayField({
// key: "birthday",
// content: new Form.DateField({ key: "birthday" })
// })
// ]
// })
]
})
)
return toast
.info("Worker Template Extension loaded")
.then(() => {
return ui.setSearchBarPlaceholder("Enter a search term, and press enter to search")
})
.then(() => {
return ui.render(
new List.List({
sections: [
new List.Section({
title: "Section 1",
items: [
new List.Item({
title: "Hello, World!",
value: "Section 1 Hello, World!",
icon: new Icon({ type: IconEnum.Iconify, value: "gg:hello" })
}),
new List.Item({ title: "Hello, World 2!", value: "Section 1 Hello, World 2!" })
]
}),
new List.Section({
title: "Section 2",
items: [
new List.Item({
title: "Hello, World!",
value: "Section 2 Hello, World!",
icon: new Icon({ type: IconEnum.Iconify, value: "gg:hello" })
}),
new List.Item({ title: "Hello, World 2!", value: "Section 2 Hello, World 2!" })
]
})
],
items: [
new List.Item({
title: "Hello, World!",
value: "Hello, World!",
icon: new Icon({ type: IconEnum.Iconify, value: "ri:star-s-fill" })
}),
new List.Item({
title: "Hello, World 2!",
value: "Hello, World 2!",
icon: new Icon({ type: IconEnum.Iconify, value: "gg:hello" }),
actions: new Action.ActionPanel({
items: [
new Action.Action({
title: "Open",
icon: new Icon({ type: IconEnum.Iconify, value: "ion:open-outline" })
})
]
})
})
]
})
)
})
}

onSearchTermChange(term: string): Promise<void> {
console.log("Search term changed to:", term)
return Promise.resolve()
}

onItemSelected(value: string): Promise<void> {
console.log("Item selected:", value)
return Promise.resolve()
}
}

expose(new ExtensionTemplate())
65 changes: 65 additions & 0 deletions extensions/disable-apple-quarantine/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "https://schema.kunkun.sh",
"name": "disable-apple-quarantine",
"version": "0.0.1",
"type": "module",
"kunkun": {
"name": "Disable Apple Quarantine",
"shortDescription": "Remove .app is damaged error",
"longDescription": "Mac apps created by developer who didn't pay Apple developer program fees will be displayed as damaged. This extension helps your bypass the error with xattr command.",
"identifier": "disable-apple-quarantine",
"permissions": [
"clipboard:read-files",
{
"permission": "shell:execute",
"allow": [
{
"cmd": {
"program": "xattr",
"args": [
"-cr",
".+"
]
}
}
]
},
"system:fs",
"event:drag-drop",
"dialog:all"
],
"demoImages": [],
"icon": {
"type": "iconify",
"value": "openmoji:hacker-cat"
},
"customUiCmds": [],
"templateUiCmds": [
{
"name": "Disable Apple Quarantine",
"main": "dist/index.js",
"cmds": [],
"platforms": [
"macos"
]
}
]
},
"scripts": {
"dev": "bun build.ts dev",
"build": "bun build.ts"
},
"dependencies": {
"@kksh/api": "0.0.9"
},
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"files": [
"./dist",
".gitignore"
]
}
Loading

0 comments on commit 36d43c6

Please sign in to comment.