-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,114 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
test -f alfredenv.sh && { | ||
source alfredenv.sh | ||
} || { | ||
echo ./alfredenv.sh not found >&2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
unset alfred_workflow_bundleid | ||
unset alfred_workflow_version | ||
unset alfred_workflow_name | ||
unset alfred_workflow_data | ||
unset alfred_workflow_cache | ||
|
||
unset INTERVAL_FIND | ||
unset INTERVAL_MDFIND | ||
unset INTERVAL_LOCATE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
# Gopkg.toml example | ||
# | ||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
|
||
|
||
[[constraint]] | ||
name = "github.com/BurntSushi/toml" | ||
version = "0.3.0" | ||
|
||
[[constraint]] | ||
name = "github.com/deanishe/awgo" | ||
version = "0.13.2" | ||
|
||
[[constraint]] | ||
name = "github.com/docopt/docopt.go" | ||
# version = "0.6.2" | ||
revision = "ee0de3bc6815ee19d4a46c7eb90f829db0e014b1" | ||
|
||
[[constraint]] | ||
name = "github.com/gobwas/glob" | ||
version = "0.2.2" | ||
|
||
# [[override]] | ||
# name = "github.com/docopt/docopt-go" | ||
# revision = "ee0de3bc6815ee19d4a46c7eb90f829db0e014b1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Dean Jackson <[email protected]> | ||
Copyright (c) 2014–2018 Dean Jackson <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# When sourced, creates an Alfred-like environment needed by modd | ||
# and ./bin/build (which sources the file itself) | ||
|
||
# getvar <name> | Read a value from info.plist | ||
getvar() { | ||
local v="$1" | ||
/usr/libexec/PlistBuddy -c "Print :$v" info.plist | ||
} | ||
|
||
# stuff in info.plist | ||
export alfred_workflow_bundleid=$( getvar "bundleid" ) | ||
export alfred_workflow_version=$( getvar "version" ) | ||
export alfred_workflow_name=$( getvar "name" ) | ||
|
||
export INTERVAL_FIND=$( getvar "variables:INTERVAL_FIND" ) | ||
export INTERVAL_MDFIND=$( getvar "variables:INTERVAL_MDFIND" ) | ||
export INTERVAL_LOCATE=$( getvar "variables:INTERVAL_LOCATE" ) | ||
|
||
# workflow data and cache directories | ||
export alfred_workflow_data="${HOME}/Library/Application Support/Alfred 3/Workflow Data/${alfred_workflow_bundleid}" | ||
export alfred_workflow_cache="${HOME}/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/${alfred_workflow_bundleid}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
#!/usr/bin/env zsh | ||
|
||
# Path to this script's directory (i.e. workflow root) | ||
here="$( cd "$( dirname "$0" )"; pwd )" | ||
root="$( cd "$here/../"; pwd )" | ||
builddir="${root}/build" | ||
distdir="${root}/dist" | ||
|
||
source "${root}/alfredenv.sh" | ||
|
||
verbose=false | ||
devmode=true | ||
runtests=false | ||
force=false | ||
|
||
# log <arg>... | Echo arguments to STDERR | ||
log() { | ||
echo "$@" >&2 | ||
} | ||
|
||
# info <arg>.. | Write args to STDERR if VERBOSE is true | ||
info() { | ||
$verbose && log $(print -P "%F{blue}.. %f") "$@" | ||
return 0 | ||
} | ||
|
||
# success <arg>.. | Write green "ok" and args to STDERR if VERBOSE is true | ||
success() { | ||
$verbose && log $(print -P "%F{green}ok %f") "$@" | ||
return 0 | ||
} | ||
|
||
# error <arg>.. | Write red "error" and args to STDERR | ||
error() { | ||
log $(print -P '%F{red}err%f') "$@" | ||
} | ||
|
||
# fail <arg>.. | Write red "error" and args to STDERR, then exit with status 1 | ||
fail() { | ||
error "$@" | ||
exit 1 | ||
} | ||
|
||
# cleanup | Delete build files | ||
cleanup() { | ||
info "cleaning up ..." | ||
test -d "$builddir" && rm -rf $verbose "${builddir}/"* | ||
} | ||
|
||
# usage | Show usage message | ||
usage() { | ||
cat <<EOS | ||
build [-h] [-d] [-t] [-f] [-v] | ||
Build workflow in ./build directory from source code. | ||
Use -d to also build an .alfredworkflow file in ./dist. | ||
Usage: | ||
build [-d] [-t] [-f] [-v] | ||
build -h | ||
Options: | ||
-d Distribution. Also build .alfredworkflow file. | ||
-f Force. Overwrite existing files. | ||
-t Also run unit tests. | ||
-h Show this message and exit. | ||
-v Verbose. | ||
EOS | ||
} | ||
|
||
# ------------------------------------------------------- | ||
# CLI options | ||
while getopts ":dfhtv" opt; do | ||
case $opt in | ||
d) | ||
devmode=false | ||
;; | ||
f) | ||
force=true | ||
;; | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
t) | ||
runtests=true | ||
;; | ||
v) | ||
verbose=true | ||
;; | ||
\?) | ||
log "Invalid option: -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
test -z "$root" && fatal "couldn't find workflow directory" | ||
|
||
$verbose && v=-v | ||
|
||
pushd "$root" &> /dev/null | ||
# ------------------------------------------------------- | ||
# Run unit tests | ||
$runtests && { | ||
info "running unit tests ..." | ||
go test $v . || exit 1 | ||
success "unit tests" | ||
} | ||
|
||
# ------------------------------------------------------- | ||
# Build | ||
test -d "${builddir}" && { | ||
info "cleaning build directory ..." | ||
cleanup | ||
success "cleaned build" | ||
} | ||
|
||
info "building executable(s) ..." | ||
|
||
go build $v -o ./alfsubl . | ||
|
||
# $devmode && { sym="-s" } | ||
|
||
info "linking assets to build directory ..." | ||
# mkdir -vp "$builddir" | ||
# mkdir -p $v "${builddir}/scripts/"{tab,url} | ||
mkdir -p $v "${builddir}/icons" | ||
|
||
pushd "$builddir" &> /dev/null | ||
|
||
ln $v ../*.html . | ||
ln $v ../info.plist . | ||
ln $v ../icons/icon.png . | ||
ln $v ../alfsubl . | ||
ln $v ../README.md . | ||
ln $v ../LICENCE.txt . | ||
ln $v ../icons/*.png ./icons/ | ||
# ln $v scripts/tab/* "${builddir}/scripts/tab/" | ||
# ln $v scripts/url/* "${builddir}/scripts/url/" | ||
popd &> /dev/null | ||
|
||
# ------------------------------------------------------- | ||
# Build .alfredworkflow file | ||
$devmode || { | ||
test -f "${outpath}" && { | ||
$force && { | ||
rm $v "${outpath}" | ||
} || { | ||
fatal "destination file already exists (use --force to overwrite)" | ||
} | ||
} | ||
|
||
test -d "$distdir" || mkdir -p "$distdir" | ||
|
||
info "building .alfredworkflow file ..." | ||
|
||
zipname="Google-Calendar-View-${alfred_workflow_version}.alfredworkflow" | ||
outpath="${distdir}/${zipname}" | ||
|
||
pushd "$builddir" &> /dev/null | ||
|
||
zip -9 -r "${outpath}" ./* | ||
ST_ZIP=$? | ||
test "$ST_ZIP" -ne 0 && { | ||
error "zip failed (${ST_ZIP}) while creating .alfredworkflow file." | ||
popd &> /dev/null | ||
popd &> /dev/null | ||
exit $ST_ZIP | ||
} | ||
|
||
popd &> /dev/null | ||
success "wrote '${zipname}' file in '${distdir}'" | ||
} | ||
|
||
popd &> /dev/null |
Oops, something went wrong.