alfy 0.12.3 → 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 CHANGED
@@ -2,7 +2,7 @@
2
2
  import process from 'node:process';
3
3
  import {fileURLToPath} from 'node:url';
4
4
  import path from 'node:path';
5
- import execa from 'execa';
5
+ import {execa} from 'execa';
6
6
 
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
8
 
package/index.d.ts CHANGED
@@ -1,13 +1,7 @@
1
1
  import Conf from 'conf';
2
2
  import {Options} from 'got';
3
3
 
4
- export interface FetchOptions extends Options {
5
- // Deprecated, but left for backwards-compatibility.
6
- /**
7
- URL search parameters.
8
- */
9
- readonly query?: string | Record<string, string | number | boolean | null | undefined> | URLSearchParams | undefined;
10
-
4
+ export interface FetchOptions extends Partial<Options> {
11
5
  /**
12
6
  Number of milliseconds this request should be cached.
13
7
  */
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 hookStd from 'hook-std';
6
+ import {hookStderr} from 'hook-std';
7
7
  import loudRejection from 'loud-rejection';
8
8
  import cleanStack from 'clean-stack';
9
- import dotProp from 'dot-prop';
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,7 +50,7 @@ alfy.matches = (input, list, item) => {
50
50
 
51
51
  return list.filter(listItem => {
52
52
  if (typeof item === 'string') {
53
- listItem = dotProp.get(listItem, item);
53
+ listItem = getProperty(listItem, item);
54
54
  }
55
55
 
56
56
  if (typeof listItem === 'string') {
@@ -116,9 +116,9 @@ alfy.fetch = async (url, options) => {
116
116
  ...options,
117
117
  };
118
118
 
119
- // Deprecated, but left for backwards-compatibility.
119
+ // TODO: Remove this in 2024.
120
120
  if (options.query) {
121
- options.searchParams = options.query;
121
+ throw new Error('The `query` option was renamed to `searchParams`.');
122
122
  }
123
123
 
124
124
  if (typeof url !== 'string') {
@@ -130,6 +130,12 @@ alfy.fetch = async (url, options) => {
130
130
  }
131
131
 
132
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
+
133
139
  const key = rawKey.replace(/\./g, '\\.');
134
140
  const cachedResponse = alfy.cache.get(key, {ignoreMaxAge: true});
135
141
 
@@ -137,9 +143,18 @@ alfy.fetch = async (url, options) => {
137
143
  return cachedResponse;
138
144
  }
139
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
+
140
155
  let response;
141
156
  try {
142
- response = await got(url, options).json();
157
+ response = await got(url, options);
143
158
  } catch (error) {
144
159
  if (cachedResponse) {
145
160
  return cachedResponse;
@@ -148,10 +163,10 @@ alfy.fetch = async (url, options) => {
148
163
  throw error;
149
164
  }
150
165
 
151
- const data = options.transform ? options.transform(response) : response;
166
+ const data = transform ? transform(response) : response;
152
167
 
153
- if (options.maxAge) {
154
- alfy.cache.set(key, data, {maxAge: options.maxAge});
168
+ if (maxAge) {
169
+ alfy.cache.set(key, data, {maxAge});
155
170
  }
156
171
 
157
172
  return data;
@@ -171,6 +186,6 @@ alfy.icon = {
171
186
 
172
187
  loudRejection(alfy.error);
173
188
  process.on('uncaughtException', alfy.error);
174
- hookStd.stderr(alfy.error);
189
+ hookStderr(alfy.error);
175
190
 
176
191
  export default alfy;
package/init.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import process from 'node:process';
3
3
  import path from 'node:path';
4
4
  import {fileURLToPath} from 'node:url';
5
- import execa from 'execa';
5
+ import {execa} from 'execa';
6
6
 
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
8
 
@@ -1,8 +1,8 @@
1
- import {readPackageUpAsync} from 'read-pkg-up';
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 readPackageUpAsync();
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.12.3",
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.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.0.1",
46
- "dot-prop": "^6.0.1",
47
- "execa": "^5.1.1",
48
- "got": "^11.8.2",
49
- "hook-std": "^2.0.0",
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": "^8.0.0"
51
+ "read-pkg-up": "^9.1.0"
52
52
  },
53
53
  "devDependencies": {
54
- "ava": "^3.15.0",
54
+ "ava": "^4.1.0",
55
55
  "delay": "^5.0.0",
56
- "nock": "^13.1.1",
56
+ "nock": "^13.2.4",
57
57
  "tempfile": "^4.0.0",
58
- "tsd": "^0.17.0",
59
- "typescript": "^4.3.5",
60
- "xo": "^0.43.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
- $ npm install alfy
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
- $ npm install --global alfred-unicorn
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/tree/v11.8.3#api) and the below 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