alfy 1.1.0 → 2.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
@@ -6,14 +6,12 @@ import {execa} from 'execa';
6
6
 
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
8
 
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
+ }
package/index.d.ts CHANGED
@@ -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';
3
3
 
4
- export interface FetchOptions extends Partial<Options> {
4
+ export type FetchOptions = {
5
5
  /**
6
6
  Number of milliseconds this request should be cached.
7
7
  */
@@ -11,33 +11,33 @@ export interface FetchOptions extends Partial<Options> {
11
11
  Transform the response before it gets cached.
12
12
  */
13
13
  readonly transform?: (body: unknown) => unknown;
14
- }
14
+ } & Partial<Options>;
15
15
 
16
- export interface OutputOptions {
16
+ export type OutputOptions = {
17
17
  /**
18
18
  A script can be set to re-run automatically after some interval.
19
19
 
20
20
  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:
21
21
  */
22
22
  readonly rerunInterval?: number;
23
- }
23
+ };
24
24
 
25
- export interface CacheConfGetOptions {
25
+ export type CacheConfGetOptions = {
26
26
  /**
27
27
  Get the item for the key provided without taking the `maxAge` of the item into account.
28
28
  */
29
29
  readonly ignoreMaxAge?: boolean;
30
- }
30
+ };
31
31
 
32
- export interface CacheConfSetOptions {
32
+ export type CacheConfSetOptions = {
33
33
  /**
34
34
  Number of milliseconds the cached value is valid.
35
35
  */
36
36
  readonly maxAge?: number;
37
- }
37
+ };
38
38
 
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;
41
41
 
42
42
  get<Key extends keyof T>(key: Key, options?: CacheConfGetOptions): T[Key];
43
43
  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> {
48
48
  set(key: string, value: unknown, options: CacheConfSetOptions): void;
49
49
  set(object: Partial<T>, options: CacheConfSetOptions): void;
50
50
  set<Key extends keyof T>(key: Partial<T> | Key | string, value?: T[Key] | unknown, options?: CacheConfSetOptions): void;
51
- }
51
+ } & Conf<T>;
52
52
 
53
53
  /**
54
54
  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.
59
59
 
60
60
  Finally, by using `{type: 'filetype'}`, you can get the icon of a specific file. For example, `{path: 'public.png'}`.
61
61
  */
62
- export interface IconElement {
62
+ export type IconElement = {
63
63
  readonly path?: string;
64
64
  readonly type?: 'fileicon' | 'filetype';
65
- }
65
+ };
66
66
 
67
67
  /**
68
68
  The text element defines the text the user will get when copying the selected result row with `⌘C` or displaying large type with `⌘L`.
69
69
 
70
70
  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.
71
71
  */
72
- export interface TextElement {
72
+ export type TextElement = {
73
73
  /**
74
74
  User will get when copying the selected result row with `⌘C`.
75
75
  */
@@ -79,28 +79,28 @@ export interface TextElement {
79
79
  User will get displaying large type with `⌘L`.
80
80
  */
81
81
  readonly largetype?: string;
82
- }
82
+ };
83
83
 
84
84
  /**
85
85
  Defines what to change when the modifier key is pressed.
86
86
 
87
87
  When you release the modifier key, it returns to the original item.
88
88
  */
89
- export interface ModifierKeyItem {
89
+ export type ModifierKeyItem = {
90
90
  readonly valid?: boolean;
91
91
  readonly title?: string;
92
92
  readonly subtitle?: string;
93
93
  readonly arg?: string;
94
94
  readonly icon?: string;
95
95
  readonly variables?: Record<string, string>;
96
- }
96
+ };
97
97
 
98
98
  /**
99
99
  This element defines the Universal Action items used when actioning the result, and overrides arg being used for actioning.
100
100
 
101
101
  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.
102
102
  */
103
- export interface ActionElement {
103
+ export type ActionElement = {
104
104
  /**
105
105
  Forward text to Alfred.
106
106
  */
@@ -120,14 +120,14 @@ export interface ActionElement {
120
120
  Forward some value and let the value type be infered from Alfred.
121
121
  */
122
122
  readonly auto?: string | string[];
123
- }
123
+ };
124
124
 
125
125
  type PossibleModifiers = 'fn' | 'ctrl' | 'opt' | 'cmd' | 'shift';
126
126
 
127
127
  /**
128
128
  Each item describes a result row displayed in Alfred.
129
129
  */
130
- export interface ScriptFilterItem {
130
+ export type ScriptFilterItem = {
131
131
  /**
132
132
  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.
133
133
 
@@ -289,7 +289,7 @@ export interface ScriptFilterItem {
289
289
  Variables can be passed out of the script filter within a variables object.
290
290
  */
291
291
  readonly variables?: Record<string, string>;
292
- }
292
+ };
293
293
 
294
294
  /**
295
295
  Create Alfred workflows with ease
@@ -311,7 +311,7 @@ const items = alfy
311
311
  alfy.output(items);
312
312
  ```
313
313
  */
314
- export interface Alfy {
314
+ export type Alfy = {
315
315
  /**
316
316
  Return output to Alfred.
317
317
 
@@ -433,7 +433,7 @@ export interface Alfy {
433
433
  //=> '🦄'
434
434
  ```
435
435
  */
436
- config: Conf<Record<string, unknown>>;
436
+ config: Conf;
437
437
 
438
438
  /**
439
439
  Persist cache data.
@@ -450,7 +450,7 @@ export interface Alfy {
450
450
  //=> '🦄'
451
451
  ```
452
452
  */
453
- cache: CacheConf<unknown>;
453
+ cache: CacheConf;
454
454
 
455
455
  /**
456
456
  Get various default system icons.
@@ -542,7 +542,7 @@ export interface Alfy {
542
542
  ```
543
543
  */
544
544
  userConfig: Map<string, string>;
545
- }
545
+ };
546
546
 
547
547
  declare const alfy: Alfy;
548
548
 
package/index.js CHANGED
@@ -8,7 +8,7 @@ import loudRejection from 'loud-rejection';
8
8
  import cleanStack from 'clean-stack';
9
9
  import {getProperty} from 'dot-prop';
10
10
  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
12
12
 
13
13
  const require = createRequire(import.meta.url);
14
14
  const CacheConf = require('cache-conf');
@@ -100,6 +100,7 @@ ${process.platform} ${os.release()}
100
100
  };
101
101
 
102
102
  alfy.config = new Conf({
103
+ projectName: 'alfy',
103
104
  cwd: alfy.alfred.data,
104
105
  });
105
106
 
@@ -137,7 +138,7 @@ alfy.fetch = async (url, options) => {
137
138
  delete options.transform;
138
139
  delete options.maxAge;
139
140
 
140
- const key = rawKey.replace(/\./g, '\\.');
141
+ const key = rawKey.replaceAll('.', '\\.');
141
142
  const cachedResponse = alfy.cache.get(key, {ignoreMaxAge: true});
142
143
 
143
144
  if (cachedResponse && !alfy.cache.isExpired(key)) {
package/init.js CHANGED
@@ -6,21 +6,18 @@ import {execa} from 'execa';
6
6
 
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
8
 
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
+ });
26
14
 
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
+ }
@@ -1,4 +1,4 @@
1
- import {readPackageUp} from 'read-pkg-up';
1
+ import {readPackageUp} from 'read-package-up';
2
2
  import alfredNotifier from 'alfred-notifier';
3
3
 
4
4
  export default async function updateNotification() {
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "alfy",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Create Alfred workflows with ease",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/alfy",
7
7
  "type": "module",
8
- "exports": "./index.js",
9
8
  "bin": {
10
9
  "run-node": "./run-node.sh",
11
10
  "alfy-init": "./init.js",
12
11
  "alfy-cleanup": "./cleanup.js"
13
12
  },
13
+ "exports": {
14
+ "types": "./index.d.ts",
15
+ "default": "./index.js"
16
+ },
14
17
  "engines": {
15
- "node": ">=14.13.1"
18
+ "node": ">=18"
16
19
  },
17
20
  "scripts": {
18
21
  "test": "xo && ava && tsd"
@@ -41,22 +44,26 @@
41
44
  "alfred-link": "^0.3.1",
42
45
  "alfred-notifier": "^0.2.3",
43
46
  "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",
49
52
  "hook-std": "^3.0.0",
50
53
  "loud-rejection": "^2.2.0",
51
- "read-pkg-up": "^9.1.0"
54
+ "read-package-up": "^11.0.0"
52
55
  },
53
56
  "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
+ }
61
68
  }
62
69
  }
package/readme.md CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  ## Prerequisites
19
19
 
20
- You need [Node.js 14+](https://nodejs.org) and [Alfred 4](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.
21
21
 
22
22
  ## Install
23
23