From 0dc98c29bc1bd00fc6862ea986e0ec7d5b92d0ea Mon Sep 17 00:00:00 2001
From: Artem Makarov <132329+artemy@users.noreply.github.com>
Date: Mon, 14 Aug 2023 15:30:40 +0200
Subject: [PATCH] #9: Open apps via bundle identifiers to avoid renaming
issues; move away from makefile builds
---
.github/workflows/ci.yml | 2 +-
Makefile | 33 ------------------------------
README.md | 1 -
alfred/info.plist | 2 +-
build.py | 44 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 46 insertions(+), 36 deletions(-)
delete mode 100644 Makefile
create mode 100644 build.py
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a95406b..a821ad2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build artifacts
- run: make
+ run: python3 build.py
- name: Create release
uses: softprops/action-gh-release@v1
with:
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 19cc8bc..0000000
--- a/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-ANDROIDSTUDIO_KEYWORD='androidstudio'
-ANDROIDSTUDIO_NAME='Android\ Studio'
-APPCODE_KEYWORD='appcode'
-APPCODE_NAME='AppCode'
-CLION_KEYWORD='clion'
-CLION_NAME='CLion'
-DATAGRIP_KEYWORD='datagrip'
-DATAGRIP_NAME='DataGrip'
-GOLAND_KEYWORD='goland'
-GOLAND_NAME='GoLand'
-INTELLIJ_KEYWORD='idea'
-INTELLIJ_NAME='IntelliJ\ IDEA'
-PYCHARM_KEYWORD='pycharm'
-PYCHARM_NAME='PyCharm'
-WEBSTORM_KEYWORD='webstorm'
-WEBSTORM_NAME='WebStorm'
-APPS=ANDROIDSTUDIO APPCODE CLION DATAGRIP GOLAND INTELLIJ PYCHARM WEBSTORM
-
-.PHONY: clean build
-
-all: clean build
-
-clean:
- rm -fr out *.alfredworkflow
-
-build: $(APPS)
-
-$(APPS):%:
- mkdir -p out/$($@_KEYWORD)
- cp icons/$($@_KEYWORD).png ./out/$($@_KEYWORD)/icon.png
- cp icons/$($@_KEYWORD).png ./out/$($@_KEYWORD)/36E4312B-0CAB-4AE7-A8B6-E30EAF07B766.png
- sed -e 's/%APPNAME%/$($@_NAME)/g;s/%KEYWORD%/$($@_KEYWORD)/g' alfred/info.plist > out/$($@_KEYWORD)/info.plist
- zip -j -r $($@_KEYWORD).alfredworkflow out/$($@_KEYWORD)/* recent_projects.py products.json
diff --git a/README.md b/README.md
index 4f33dc7..99785fa 100644
--- a/README.md
+++ b/README.md
@@ -68,7 +68,6 @@ coverage report -m # display coverage figures
## Built With
* [Python 3.9](https://docs.python.org/3.9/)
-* [GNU Make](https://www.gnu.org/software/make/manual/make.html) - Build scripting
* [coverage.py](https://coverage.readthedocs.io/) - Code coverage measurement
## Contributing
diff --git a/alfred/info.plist b/alfred/info.plist
index 103ce5f..90246aa 100644
--- a/alfred/info.plist
+++ b/alfred/info.plist
@@ -89,7 +89,7 @@
escaping
102
script
- open -na "%APPNAME%.app" --args $@
+ open -nb "%BUNDLE%" --args $@
scriptargtype
1
scriptfile
diff --git a/build.py b/build.py
new file mode 100644
index 0000000..d0dc9a7
--- /dev/null
+++ b/build.py
@@ -0,0 +1,44 @@
+import os
+
+APPS = [
+ ['Android Studio', 'androidstudio', 'com.google.android.studio'],
+ ['AppCode', 'appcode', 'com.jetbrains.appcode'],
+ ['CLion', 'clion', 'com.jetbrains.clion'],
+ ['DataGrip', 'datagrip', 'com.jetbrains.datagrip'],
+ ['GoLand', 'goland', 'com.jetbrains.goland'],
+ ['IntelliJ IDEA', 'idea', 'com.jetbrains.intellij'],
+ ['PyCharm', 'pycharm', 'com.jetbrains.pycharm'],
+ ['WebStorm', 'webstorm', 'com.jetbrains.webstorm'],
+]
+
+
+def prepare_workflow(app):
+ app_name, keyword, bundle = app
+ print(f"Building {app_name}")
+ os.system(f'mkdir -p out/{keyword}')
+ os.system(f'cp icons/{keyword}.png ./out/{keyword}/icon.png')
+ os.system(f'cp icons/{keyword}.png ./out/{keyword}/36E4312B-0CAB-4AE7-A8B6-E30EAF07B766.png')
+ os.system('sed '
+ f'-e "s/%APPNAME%/{app_name}/g" '
+ f'-e "s/%KEYWORD%/{keyword}/g" '
+ f'-e "s/%BUNDLE%/{bundle}/g" '
+ f' alfred/info.plist > out/{keyword}/info.plist')
+ os.system(f'zip -j -r {keyword}.alfredworkflow out/{keyword}/* recent_projects.py products.json')
+
+
+def build():
+ for app in APPS:
+ prepare_workflow(app)
+
+
+def clean():
+ os.system("rm *.alfredworkflow")
+
+
+def main():
+ clean()
+ build()
+
+
+if __name__ == '__main__':
+ main()