Skip to content

Commit a38bf75

Browse files
Add unpublished Safari build (refined-github#3677)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent 5b6b9c0 commit a38bf75

20 files changed

Lines changed: 972 additions & 18 deletions

File tree

.github/workflows/test.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Test
22

33
on:
44
pull_request:
5-
branches:
5+
branches:
66
- '*'
77
push:
8-
branches:
8+
branches:
99
- master
1010
- 'test/*'
1111

@@ -38,9 +38,23 @@ jobs:
3838
runs-on: ubuntu-latest
3939
steps:
4040
- uses: actions/checkout@v2
41+
- uses: actions/setup-node@v1
42+
with:
43+
node-version: 14
4144
- run: npm ci
4245
- run: npm run build
43-
- uses: actions/upload-artifact@v1
46+
- uses: actions/upload-artifact@v2
47+
with:
48+
name: refined-github
49+
path: distribution
50+
Safari:
51+
runs-on: macos-latest
52+
needs: Build
53+
steps:
54+
- uses: actions/checkout@v2
55+
- uses: actions/download-artifact@v2 # npm install+build seems slow and problematic on macOS
4456
with:
4557
name: refined-github
4658
path: distribution
59+
- uses: maxim-lobanov/setup-xcode@v1
60+
- run: npm run pack:safari

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
"lint": "run-p lint:* --continue-on-error",
1010
"lint:css": "stylelint 'source/**/*.css'",
1111
"lint:js": "xo",
12+
"pack:safari": "xcodebuild -project 'safari/Refined GitHub.xcodeproj'",
1213
"release": "VER=$(daily-version) run-s build version release:*",
1314
"release:amo": "web-ext-submit --source-dir distribution",
1415
"release:cws": "webstore upload --source=distribution --auto-publish",
1516
"start": "web-ext run --target=chromium",
1617
"start:firefox": "web-ext run",
18+
"start:safari": "open 'safari/build/Release/Refined GitHub.app'",
1719
"test": "run-p ava lint:* build:*",
1820
"version": "dot-json distribution/manifest.json version $VER",
1921
"watch": "run-p watch:* --continue-on-error",
@@ -53,8 +55,8 @@
5355
"github-url-detection": "^4.1.1",
5456
"image-promise": "^7.0.1",
5557
"indent-textarea": "^2.0.2",
56-
"linkify-issues": "^2.0.0",
57-
"linkify-urls": "^3.1.0",
58+
"linkify-issues": "2.0.0-nolookbehind",
59+
"linkify-urls": "3.1.0-nolookbehind",
5860
"mem": "^8.0.0",
5961
"onetime": "^5.1.2",
6062
"select-dom": "^6.0.2",
@@ -67,7 +69,7 @@
6769
"webext-base-css": "^1.2.0",
6870
"webext-domain-permission-toggle": "^1.0.1",
6971
"webext-dynamic-content-scripts": "^7.0.0",
70-
"webext-options-sync-per-domain": "^2.0.0",
72+
"webext-options-sync-per-domain": "^2.0.1",
7173
"webext-storage-cache": "^4.1.1",
7274
"webextension-polyfill": "^0.6.0",
7375
"zip-text-nodes": "^1.0.0"

safari/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
xcuserdata/
2+
*.xcworkspace
3+
build/
4+
fastlane/report.xml
5+
fastlane/Preview.html
6+
fastlane/screenshots/**/*.png
7+
fastlane/test_output
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>Refined GitHub Extension</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>LSMinimumSystemVersion</key>
24+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
25+
<key>NSExtension</key>
26+
<dict>
27+
<key>NSExtensionPointIdentifier</key>
28+
<string>com.apple.Safari.web-extension</string>
29+
<key>NSExtensionPrincipalClass</key>
30+
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string>
31+
</dict>
32+
</dict>
33+
</plist>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
</dict>
10+
</plist>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import SafariServices
2+
import os.log
3+
4+
let SFExtensionMessageKey = "message"
5+
6+
final class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
7+
func beginRequest(with context: NSExtensionContext) {
8+
let item = context.inputItems[0] as! NSExtensionItem
9+
let message = item.userInfo?[SFExtensionMessageKey]
10+
os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg)
11+
12+
let response = NSExtensionItem()
13+
response.userInfo = [SFExtensionMessageKey: ["Response to": message]]
14+
15+
context.completeRequest(returningItems: [response], completionHandler: nil)
16+
}
17+
}

0 commit comments

Comments
 (0)