alfy 0.12.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cleanup.js +1 -1
- package/index.d.ts +2 -7
- package/index.js +32 -12
- package/init.js +1 -1
- package/lib/update-notification.js +2 -2
- package/package.json +13 -13
- package/readme.md +6 -10
package/cleanup.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import Conf from 'conf';
|
|
2
2
|
import {Options} from 'got';
|
|
3
3
|
|
|
4
|
-
export interface FetchOptions extends Options {
|
|
5
|
-
/**
|
|
6
|
-
URL search parameters.
|
|
7
|
-
*/
|
|
8
|
-
readonly query?: string | Record<string, string | number | boolean | null | undefined> | URLSearchParams | undefined;
|
|
9
|
-
|
|
4
|
+
export interface FetchOptions extends Partial<Options> {
|
|
10
5
|
/**
|
|
11
6
|
Number of milliseconds this request should be cached.
|
|
12
7
|
*/
|
|
@@ -232,7 +227,7 @@ export interface ScriptFilterItem {
|
|
|
232
227
|
|
|
233
228
|
You can now define the valid attribute to mark if the result is valid based on the modifier selection and set a different arg to be passed out if actioned with the modifier.
|
|
234
229
|
*/
|
|
235
|
-
readonly mods?: Record<PossibleModifiers, ModifierKeyItem
|
|
230
|
+
readonly mods?: Partial<Record<PossibleModifiers, ModifierKeyItem>>;
|
|
236
231
|
|
|
237
232
|
/**
|
|
238
233
|
This element defines the Universal Action items used when actioning the result, and overrides arg being used for actioning.
|
package/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import process from 'node:process';
|
|
|
3
3
|
import {createRequire} from 'node:module';
|
|
4
4
|
import Conf from 'conf';
|
|
5
5
|
import got from 'got';
|
|
6
|
-
import
|
|
6
|
+
import {hookStderr} from 'hook-std';
|
|
7
7
|
import loudRejection from 'loud-rejection';
|
|
8
8
|
import cleanStack from 'clean-stack';
|
|
9
|
-
import
|
|
9
|
+
import {getProperty} from 'dot-prop';
|
|
10
10
|
import AlfredConfig from 'alfred-config';
|
|
11
11
|
import updateNotification from './lib/update-notification.js';
|
|
12
12
|
|
|
@@ -50,11 +50,11 @@ alfy.matches = (input, list, item) => {
|
|
|
50
50
|
|
|
51
51
|
return list.filter(listItem => {
|
|
52
52
|
if (typeof item === 'string') {
|
|
53
|
-
listItem =
|
|
53
|
+
listItem = getProperty(listItem, item);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (typeof listItem === 'string') {
|
|
57
|
-
listItem = listItem.toLowerCase();
|
|
57
|
+
listItem = listItem.toLowerCase().normalize();
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (typeof item === 'function') {
|
|
@@ -116,25 +116,45 @@ alfy.fetch = async (url, options) => {
|
|
|
116
116
|
...options,
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
// TODO: Remove this in 2024.
|
|
120
|
+
if (options.query) {
|
|
121
|
+
throw new Error('The `query` option was renamed to `searchParams`.');
|
|
122
|
+
}
|
|
123
|
+
|
|
119
124
|
if (typeof url !== 'string') {
|
|
120
|
-
|
|
125
|
+
throw new TypeError(`Expected \`url\` to be a \`string\`, got \`${typeof url}\``);
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
if (options.transform && typeof options.transform !== 'function') {
|
|
124
|
-
|
|
129
|
+
throw new TypeError(`Expected \`transform\` to be a \`function\`, got \`${typeof options.transform}\``);
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
const rawKey = url + JSON.stringify(options);
|
|
133
|
+
|
|
134
|
+
// This must be below the cache key generation.
|
|
135
|
+
const {transform, maxAge} = options;
|
|
136
|
+
delete options.transform;
|
|
137
|
+
delete options.maxAge;
|
|
138
|
+
|
|
128
139
|
const key = rawKey.replace(/\./g, '\\.');
|
|
129
140
|
const cachedResponse = alfy.cache.get(key, {ignoreMaxAge: true});
|
|
130
141
|
|
|
131
142
|
if (cachedResponse && !alfy.cache.isExpired(key)) {
|
|
132
|
-
return
|
|
143
|
+
return cachedResponse;
|
|
133
144
|
}
|
|
134
145
|
|
|
146
|
+
if ('json' in options && options.json === false) {
|
|
147
|
+
delete options.json;
|
|
148
|
+
options.responseType = 'text';
|
|
149
|
+
} else {
|
|
150
|
+
options.responseType = 'json';
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
options.resolveBodyOnly = true;
|
|
154
|
+
|
|
135
155
|
let response;
|
|
136
156
|
try {
|
|
137
|
-
response = await got(url,
|
|
157
|
+
response = await got(url, options);
|
|
138
158
|
} catch (error) {
|
|
139
159
|
if (cachedResponse) {
|
|
140
160
|
return cachedResponse;
|
|
@@ -143,10 +163,10 @@ alfy.fetch = async (url, options) => {
|
|
|
143
163
|
throw error;
|
|
144
164
|
}
|
|
145
165
|
|
|
146
|
-
const data =
|
|
166
|
+
const data = transform ? transform(response) : response;
|
|
147
167
|
|
|
148
|
-
if (
|
|
149
|
-
alfy.cache.set(key, data, {maxAge
|
|
168
|
+
if (maxAge) {
|
|
169
|
+
alfy.cache.set(key, data, {maxAge});
|
|
150
170
|
}
|
|
151
171
|
|
|
152
172
|
return data;
|
|
@@ -166,6 +186,6 @@ alfy.icon = {
|
|
|
166
186
|
|
|
167
187
|
loudRejection(alfy.error);
|
|
168
188
|
process.on('uncaughtException', alfy.error);
|
|
169
|
-
|
|
189
|
+
hookStderr(alfy.error);
|
|
170
190
|
|
|
171
191
|
export default alfy;
|
package/init.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {readPackageUp} from 'read-pkg-up';
|
|
2
2
|
import alfredNotifier from 'alfred-notifier';
|
|
3
3
|
|
|
4
4
|
export default async function updateNotification() {
|
|
5
|
-
const {package: pkg} = await
|
|
5
|
+
const {package: pkg} = await readPackageUp();
|
|
6
6
|
const alfy = (pkg || {}).alfy || {};
|
|
7
7
|
|
|
8
8
|
if (alfy.updateNotification !== false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alfy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Create Alfred workflows with ease",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/alfy",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"mac"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"alfred-config": "^0.2.
|
|
40
|
+
"alfred-config": "^0.2.3",
|
|
41
41
|
"alfred-link": "^0.3.1",
|
|
42
42
|
"alfred-notifier": "^0.2.3",
|
|
43
43
|
"cache-conf": "^0.6.0",
|
|
44
44
|
"clean-stack": "^4.1.0",
|
|
45
|
-
"conf": "^10.
|
|
46
|
-
"dot-prop": "^
|
|
47
|
-
"execa": "^
|
|
48
|
-
"got": "^
|
|
49
|
-
"hook-std": "^
|
|
45
|
+
"conf": "^10.1.1",
|
|
46
|
+
"dot-prop": "^7.2.0",
|
|
47
|
+
"execa": "^6.1.0",
|
|
48
|
+
"got": "^12.0.3",
|
|
49
|
+
"hook-std": "^3.0.0",
|
|
50
50
|
"loud-rejection": "^2.2.0",
|
|
51
|
-
"read-pkg-up": "^
|
|
51
|
+
"read-pkg-up": "^9.1.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"ava": "^
|
|
54
|
+
"ava": "^4.1.0",
|
|
55
55
|
"delay": "^5.0.0",
|
|
56
|
-
"nock": "^13.
|
|
56
|
+
"nock": "^13.2.4",
|
|
57
57
|
"tempfile": "^4.0.0",
|
|
58
|
-
"tsd": "^0.
|
|
59
|
-
"typescript": "^4.3
|
|
60
|
-
"xo": "^0.
|
|
58
|
+
"tsd": "^0.19.1",
|
|
59
|
+
"typescript": "^4.6.3",
|
|
60
|
+
"xo": "^0.48.0"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/readme.md
CHANGED
|
@@ -21,8 +21,8 @@ You need [Node.js 14+](https://nodejs.org) and [Alfred 4](https://www.alfredapp.
|
|
|
21
21
|
|
|
22
22
|
## Install
|
|
23
23
|
|
|
24
|
-
```
|
|
25
|
-
|
|
24
|
+
```sh
|
|
25
|
+
npm install alfy
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
@@ -121,8 +121,8 @@ You can remove [these](https://github.com/samverschueren/alfred-link#infoplist)
|
|
|
121
121
|
|
|
122
122
|
After publishing your workflow to npm, your users can easily install or update the workflow.
|
|
123
123
|
|
|
124
|
-
```
|
|
125
|
-
|
|
124
|
+
```sh
|
|
125
|
+
npm install --global alfred-unicorn
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
> Tip: instead of manually updating every workflow yourself, use the [alfred-updater](https://github.com/SamVerschueren/alfred-updater) workflow to do that for you.
|
|
@@ -351,7 +351,7 @@ URL to fetch.
|
|
|
351
351
|
|
|
352
352
|
Type: `object`
|
|
353
353
|
|
|
354
|
-
Any of the [`got` options](https://github.com/sindresorhus/got#options
|
|
354
|
+
Any of the [`got` options](https://github.com/sindresorhus/got/tree/v12.0.3#api) and the below options.
|
|
355
355
|
|
|
356
356
|
###### json
|
|
357
357
|
|
|
@@ -608,20 +608,16 @@ Non-synced local preferences are stored within `Alfred.alfredpreferences` under
|
|
|
608
608
|
- [alfred-asana](https://github.com/adriantoine/alfred-asana) - Search your Asana tasks
|
|
609
609
|
- [alfred-cacher](https://github.com/CacherApp/alfred-cacher) - Find a code snippet from [Cacher](https://www.cacher.io) and copy it to the clipboard
|
|
610
610
|
- [alfred-loremipsum](https://github.com/AntonNiklasson/alfred-loremipsum) - Generate placeholder text
|
|
611
|
-
- [alfred-kaomoji](https://github.com/vinkla/alfred-kaomoji) - Find relevant kaomoji from text
|
|
612
611
|
- [alfred-packagist](https://github.com/vinkla/alfred-packagist) - Search for PHP packages with Packagist
|
|
613
612
|
- [alfred-vpn](https://github.com/stve/alfred-vpn) - Connect/disconnect from VPNs
|
|
614
|
-
- [alfred-clap](https://github.com/jacc/alfred-clap) - 👏🏻 Clap 👏🏻 stuff 👏🏻 out 👏🏻 in 👏🏻 Alfred! 👏🏻
|
|
615
613
|
- [alfred-yandex-translate](https://github.com/mkalygin/alfred-yandex-translate) - Translate words and text with Yandex Translate
|
|
616
614
|
- [alfred-now](https://github.com/lucaperret/alfred-now) - Use [Now](https://zeit.co/now) commands within Alfred to access deployments and aliases
|
|
617
615
|
- [alfred-chuck-norris-jokes](https://github.com/jeppestaerk/alfred-chuck-norris-jokes) - Get Chuck Norris jokes
|
|
618
616
|
- [alfred-show-network-info](https://github.com/jeppestaerk/alfred-show-network-info) - See network info and discover local devices
|
|
619
617
|
- [alfred-currency-conversion](https://github.com/jeppestaerk/alfred-currency-conversion) - See foreign exchange rates and currency conversion
|
|
620
|
-
- [alfred-reference](https://github.com/vinkla/alfred-reference) - Search for HTML elements and CSS properties
|
|
621
618
|
- [alfred-polyglot](https://github.com/nikersify/alfred-polyglot) - Translate text with Google Translate
|
|
622
619
|
- [alfred-stock-price](https://github.com/Wei-Xia/alfred-stock-price-workflow) - Show real time stock price in US market
|
|
623
620
|
- [alfred-jira](https://github.com/colinf/alfred-jira) - Convert clipboard text between Markdown and Jira markup
|
|
624
|
-
- [alfred-homebrew](https://github.com/vinkla/alfred-homebrew) - Search for macOS packages with Homebrew
|
|
625
621
|
- [alfred-network-location-switch](https://github.com/abdul/alfred-network-location-switch) - Switch macOS network location
|
|
626
622
|
- [alfred-cool](https://github.com/nguyenvanduocit/alfred-cool) - Find cool words
|
|
627
623
|
- [alfred-google-books](https://github.com/Dameck/alfred-google-books) - Search for Google Books
|
|
@@ -631,7 +627,6 @@ Non-synced local preferences are stored within `Alfred.alfredpreferences` under
|
|
|
631
627
|
- [alfred-title](https://github.com/Kikobeats/alfred-title) – Capitalize your titles
|
|
632
628
|
- [alfred-trello](https://github.com/mblode/alfred-trello) - Search your boards, quickly add cards, and view list of cards for Trello
|
|
633
629
|
- [alfred-npm-versions](https://github.com/mrmartineau/alfred-npm-versions) - Lookup the latest 15 versions for an npm package
|
|
634
|
-
- [alfred-travis-ci](https://github.com/adriantombu/alfred-travis-ci) - Check the status of your Travis CI builds
|
|
635
630
|
- [alfred-github-trending](https://github.com/mikqi/alfred-github-trending) - Search trending repositories on GitHub
|
|
636
631
|
- [alfred-elm](https://github.com/nicklayb/alfred-elm) - Browse Elm packages documentation
|
|
637
632
|
- [alfred-imagemin](https://github.com/kawamataryo/alfred-imagemin) - Minify images with Imagemin
|
|
@@ -643,6 +638,7 @@ Non-synced local preferences are stored within `Alfred.alfredpreferences` under
|
|
|
643
638
|
- [alfred-code](https://github.com/shaodahong/alfred-code) - Quickly open a file in Visual Studio Code
|
|
644
639
|
- [alfred-amphetamine](https://github.com/demartini/alfred-amphetamine) - Start and end sessions quickly in the Amphetamine app
|
|
645
640
|
- [alfred-ids](https://github.com/rizowski/alfred-ids) - Generate various types of IDs.
|
|
641
|
+
- [alfred-awesome-stars](https://github.com/jopemachine/alfred-awesome-stars) - Search starred GitHub repos through awesome-stars.
|
|
646
642
|
|
|
647
643
|
## Related
|
|
648
644
|
|