Skip to content

Commit 277214c

Browse files
committed
Require Node.js 18
1 parent 1da2609 commit 277214c

File tree

8 files changed

+79
-76
lines changed

8 files changed

+79
-76
lines changed

cleanup.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ import {execa} from 'execa';
66

77
const __dirname = path.dirname(fileURLToPath(import.meta.url));
88

9-
(async () => {
10-
try {
11-
await execa('alfred-unlink', {
12-
preferLocal: true,
13-
localDir: __dirname,
14-
});
15-
} catch (error) {
16-
console.error(error);
17-
process.exit(1);
18-
}
19-
})();
9+
try {
10+
await execa('alfred-unlink', {
11+
preferLocal: true,
12+
localDir: __dirname,
13+
});
14+
} catch (error) {
15+
console.error(error);
16+
process.exit(1);
17+
}

index.d.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Conf from 'conf';
2-
import {Options} from 'got';
1+
import type Conf from 'conf';
2+
import {type Options} from 'got';
33

4-
export interface FetchOptions extends Partial<Options> {
4+
export type FetchOptions = {
55
/**
66
Number of milliseconds this request should be cached.
77
*/
@@ -11,33 +11,33 @@ export interface FetchOptions extends Partial<Options> {
1111
Transform the response before it gets cached.
1212
*/
1313
readonly transform?: (body: unknown) => unknown;
14-
}
14+
} & Partial<Options>;
1515

16-
export interface OutputOptions {
16+
export type OutputOptions = {
1717
/**
1818
A script can be set to re-run automatically after some interval.
1919
2020
The script will only be re-run if the script filter is still active and the user hasn't changed the state of the filter by typing and triggering a re-run. For example, it could be used to update the progress of a particular task:
2121
*/
2222
readonly rerunInterval?: number;
23-
}
23+
};
2424

25-
export interface CacheConfGetOptions {
25+
export type CacheConfGetOptions = {
2626
/**
2727
Get the item for the key provided without taking the `maxAge` of the item into account.
2828
*/
2929
readonly ignoreMaxAge?: boolean;
30-
}
30+
};
3131

32-
export interface CacheConfSetOptions {
32+
export type CacheConfSetOptions = {
3333
/**
3434
Number of milliseconds the cached value is valid.
3535
*/
3636
readonly maxAge?: number;
37-
}
37+
};
3838

39-
export interface CacheConf<T> extends Conf<T> {
40-
isExpired: (key: T) => boolean;
39+
export type CacheConf<T extends Record<string, any> = Record<string, unknown>> = {
40+
isExpired: (key: keyof T) => boolean;
4141

4242
get<Key extends keyof T>(key: Key, options?: CacheConfGetOptions): T[Key];
4343
get<Key extends keyof T>(key: Key, defaultValue: Required<T>[Key], options?: CacheConfGetOptions): Required<T>[Key];
@@ -48,7 +48,7 @@ export interface CacheConf<T> extends Conf<T> {
4848
set(key: string, value: unknown, options: CacheConfSetOptions): void;
4949
set(object: Partial<T>, options: CacheConfSetOptions): void;
5050
set<Key extends keyof T>(key: Partial<T> | Key | string, value?: T[Key] | unknown, options?: CacheConfSetOptions): void;
51-
}
51+
} & Conf<T>;
5252

5353
/**
5454
The icon displayed in the result row. Workflows are run from their workflow folder, so you can reference icons stored in your workflow relatively.
@@ -59,17 +59,17 @@ By using `{type: 'fileicon}`, Alfred will get the icon for the specified path.
5959
6060
Finally, by using `{type: 'filetype'}`, you can get the icon of a specific file. For example, `{path: 'public.png'}`.
6161
*/
62-
export interface IconElement {
62+
export type IconElement = {
6363
readonly path?: string;
6464
readonly type?: 'fileicon' | 'filetype';
65-
}
65+
};
6666

6767
/**
6868
The text element defines the text the user will get when copying the selected result row with `⌘C` or displaying large type with `⌘L`.
6969
7070
If these are not defined, you will inherit Alfred's standard behaviour where the argument is copied to the Clipboard or used for Large Type.
7171
*/
72-
export interface TextElement {
72+
export type TextElement = {
7373
/**
7474
User will get when copying the selected result row with `⌘C`.
7575
*/
@@ -79,28 +79,28 @@ export interface TextElement {
7979
User will get displaying large type with `⌘L`.
8080
*/
8181
readonly largetype?: string;
82-
}
82+
};
8383

8484
/**
8585
Defines what to change when the modifier key is pressed.
8686
8787
When you release the modifier key, it returns to the original item.
8888
*/
89-
export interface ModifierKeyItem {
89+
export type ModifierKeyItem = {
9090
readonly valid?: boolean;
9191
readonly title?: string;
9292
readonly subtitle?: string;
9393
readonly arg?: string;
9494
readonly icon?: string;
9595
readonly variables?: Record<string, string>;
96-
}
96+
};
9797

9898
/**
9999
This element defines the Universal Action items used when actioning the result, and overrides arg being used for actioning.
100100
101101
The action key can take a string or array for simple types, and the content type will automatically be derived by Alfred to file, URL or text.
102102
*/
103-
export interface ActionElement {
103+
export type ActionElement = {
104104
/**
105105
Forward text to Alfred.
106106
*/
@@ -120,14 +120,14 @@ export interface ActionElement {
120120
Forward some value and let the value type be infered from Alfred.
121121
*/
122122
readonly auto?: string | string[];
123-
}
123+
};
124124

125125
type PossibleModifiers = 'fn' | 'ctrl' | 'opt' | 'cmd' | 'shift';
126126

127127
/**
128128
Each item describes a result row displayed in Alfred.
129129
*/
130-
export interface ScriptFilterItem {
130+
export type ScriptFilterItem = {
131131
/**
132132
This is a unique identifier for the item which allows help Alfred to learn about this item for subsequent sorting and ordering of the user's actioned results.
133133
@@ -289,7 +289,7 @@ export interface ScriptFilterItem {
289289
Variables can be passed out of the script filter within a variables object.
290290
*/
291291
readonly variables?: Record<string, string>;
292-
}
292+
};
293293

294294
/**
295295
Create Alfred workflows with ease
@@ -311,7 +311,7 @@ const items = alfy
311311
alfy.output(items);
312312
```
313313
*/
314-
export interface Alfy {
314+
export type Alfy = {
315315
/**
316316
Return output to Alfred.
317317
@@ -433,7 +433,7 @@ export interface Alfy {
433433
//=> '🦄'
434434
```
435435
*/
436-
config: Conf<Record<string, unknown>>;
436+
config: Conf;
437437

438438
/**
439439
Persist cache data.
@@ -450,7 +450,7 @@ export interface Alfy {
450450
//=> '🦄'
451451
```
452452
*/
453-
cache: CacheConf<unknown>;
453+
cache: CacheConf;
454454

455455
/**
456456
Get various default system icons.
@@ -542,7 +542,7 @@ export interface Alfy {
542542
```
543543
*/
544544
userConfig: Map<string, string>;
545-
}
545+
};
546546

547547
declare const alfy: Alfy;
548548

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import loudRejection from 'loud-rejection';
88
import cleanStack from 'clean-stack';
99
import {getProperty} from 'dot-prop';
1010
import AlfredConfig from 'alfred-config';
11-
import updateNotification from './lib/update-notification.js';
11+
import updateNotification from './lib/update-notification.js'; // eslint-disable-line import/order
1212

1313
const require = createRequire(import.meta.url);
1414
const CacheConf = require('cache-conf');
@@ -100,6 +100,7 @@ ${process.platform} ${os.release()}
100100
};
101101

102102
alfy.config = new Conf({
103+
projectName: 'alfy',
103104
cwd: alfy.alfred.data,
104105
});
105106

@@ -137,7 +138,7 @@ alfy.fetch = async (url, options) => {
137138
delete options.transform;
138139
delete options.maxAge;
139140

140-
const key = rawKey.replace(/\./g, '\\.');
141+
const key = rawKey.replaceAll('.', '\\.');
141142
const cachedResponse = alfy.cache.get(key, {ignoreMaxAge: true});
142143

143144
if (cachedResponse && !alfy.cache.isExpired(key)) {

index.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {expectType} from 'tsd';
2-
import alfy, {ScriptFilterItem} from './index.js';
2+
import alfy, {type ScriptFilterItem} from './index.js';
33

44
const mockItems: ScriptFilterItem[] = [
55
{
@@ -25,5 +25,5 @@ expectType<void>(alfy.error(new Error('some error')));
2525
expectType<void>(alfy.log('some message'));
2626

2727
expectType<Promise<unknown>>(alfy.fetch('https://foo.bar', {
28-
transform: body => body,
28+
transform: body => body, // eslint-disable-line @typescript-eslint/no-unsafe-return
2929
}));

init.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@ import {execa} from 'execa';
66

77
const __dirname = path.dirname(fileURLToPath(import.meta.url));
88

9-
(async () => {
10-
try {
11-
await execa('alfred-link', {
12-
preferLocal: true,
13-
localDir: __dirname,
14-
});
15-
16-
await execa('alfred-config', {
17-
preferLocal: true,
18-
localDir: __dirname,
19-
stdio: 'inherit',
20-
});
21-
} catch (error) {
22-
console.error(error);
23-
process.exit(1);
24-
}
25-
})();
9+
try {
10+
await execa('alfred-link', {
11+
preferLocal: true,
12+
localDir: __dirname,
13+
});
2614

15+
await execa('alfred-config', {
16+
preferLocal: true,
17+
localDir: __dirname,
18+
stdio: 'inherit',
19+
});
20+
} catch (error) {
21+
console.error(error);
22+
process.exit(1);
23+
}

lib/update-notification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {readPackageUp} from 'read-pkg-up';
1+
import {readPackageUp} from 'read-package-up';
22
import alfredNotifier from 'alfred-notifier';
33

44
export default async function updateNotification() {

package.json

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
"license": "MIT",
66
"repository": "sindresorhus/alfy",
77
"type": "module",
8-
"exports": "./index.js",
98
"bin": {
109
"run-node": "./run-node.sh",
1110
"alfy-init": "./init.js",
1211
"alfy-cleanup": "./cleanup.js"
1312
},
13+
"exports": {
14+
"types": "./index.d.ts",
15+
"default": "./index.js"
16+
},
1417
"engines": {
15-
"node": ">=14.13.1"
18+
"node": ">=18"
1619
},
1720
"scripts": {
1821
"test": "xo && ava && tsd"
@@ -41,22 +44,26 @@
4144
"alfred-link": "^0.3.1",
4245
"alfred-notifier": "^0.2.3",
4346
"cache-conf": "^0.6.0",
44-
"clean-stack": "^4.1.0",
45-
"conf": "^10.1.1",
46-
"dot-prop": "^7.2.0",
47-
"execa": "^6.1.0",
48-
"got": "^12.0.3",
47+
"clean-stack": "^5.2.0",
48+
"conf": "^12.0.0",
49+
"dot-prop": "^8.0.2",
50+
"execa": "^8.0.1",
51+
"got": "^13.0.0",
4952
"hook-std": "^3.0.0",
5053
"loud-rejection": "^2.2.0",
51-
"read-pkg-up": "^9.1.0"
54+
"read-package-up": "^11.0.0"
5255
},
5356
"devDependencies": {
54-
"ava": "^4.1.0",
55-
"delay": "^5.0.0",
56-
"nock": "^13.2.4",
57-
"tempfile": "^4.0.0",
58-
"tsd": "^0.19.1",
59-
"typescript": "^4.6.3",
60-
"xo": "^0.48.0"
57+
"ava": "^5.3.1",
58+
"delay": "^6.0.0",
59+
"nock": "^13.3.8",
60+
"tempfile": "^5.0.0",
61+
"tsd": "^0.29.0",
62+
"xo": "^0.56.0"
63+
},
64+
"tsd": {
65+
"compilerOptions": {
66+
"module": "node16"
67+
}
6168
}
6269
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
## Prerequisites
1919

20-
You need [Node.js 14+](https://nodejs.org) and [Alfred 4 or later](https://www.alfredapp.com) with the paid [Powerpack](https://www.alfredapp.com/powerpack/) upgrade.
20+
You need [Node.js 18+](https://nodejs.org) and [Alfred 4 or later](https://www.alfredapp.com) with the paid [Powerpack](https://www.alfredapp.com/powerpack/) upgrade.
2121

2222
## Install
2323

0 commit comments

Comments
 (0)