mac-helper 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > useful helper for macOS
4
4
 
5
- [![Build Status](https://img.shields.io/github/workflow/status/magicdawn/mac-helper/ci.yml?style=flat-square&branch=main)](https://github.com/magicdawn/mac-helper/actions/workflows/ci.yml)
5
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/magicdawn/mac-helper/ci.yml?style=flat-square&branch=main)](https://github.com/magicdawn/mac-helper/actions/workflows/ci.yml)
6
6
  [![Coverage Status](https://img.shields.io/codecov/c/github/magicdawn/mac-helper.svg?style=flat-square)](https://codecov.io/gh/magicdawn/mac-helper)
7
7
  [![npm version](https://img.shields.io/npm/v/mac-helper.svg?style=flat-square)](https://www.npmjs.com/package/mac-helper)
8
8
  [![npm downloads](https://img.shields.io/npm/dm/mac-helper.svg?style=flat-square)](https://www.npmjs.com/package/mac-helper)
package/lib/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import '@jxa/global-type';
2
- export declare function deprecated_getFinderSelectionViaAppleScript(): Promise<string>;
3
1
  export declare function getPathFinderSelect(): Promise<string | null>;
4
2
  export declare function getPathFinderSelects(): Promise<string[]>;
5
3
  export declare const PathFinder: {
package/lib/index.js CHANGED
@@ -1,24 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PathFinder = exports.getPathFinderSelects = exports.getPathFinderSelect = exports.deprecated_getFinderSelectionViaAppleScript = void 0;
7
- require("@jxa/global-type");
3
+ exports.PathFinder = exports.getPathFinderSelects = exports.getPathFinderSelect = void 0;
8
4
  const run_1 = require("@jxa/run");
9
- const applescript_1 = __importDefault(require("applescript"));
10
- const promise_ify_1 = __importDefault(require("promise.ify"));
11
- const SCRIPT_FI_SELECTION = `
12
- tell application "Path Finder"
13
- get POSIX path of (get item 1 of (get selection))
14
- end tell
15
- `;
16
- async function deprecated_getFinderSelectionViaAppleScript() {
17
- const result = (await (0, promise_ify_1.default)(applescript_1.default.execString, applescript_1.default)(SCRIPT_FI_SELECTION.trim()));
18
- const url = result && result[0];
19
- return url;
20
- }
21
- exports.deprecated_getFinderSelectionViaAppleScript = deprecated_getFinderSelectionViaAppleScript;
22
5
  async function getPathFinderSelect() {
23
6
  const filePath = await (0, run_1.run)(() => {
24
7
  const app = Application('Path Finder');
@@ -30,7 +13,7 @@ exports.getPathFinderSelect = getPathFinderSelect;
30
13
  async function getPathFinderSelects() {
31
14
  const filePaths = await (0, run_1.run)(() => {
32
15
  const app = Application('Path Finder');
33
- return (app.selection() || []).map((x) => x?.posixPath());
16
+ return (app.selection() || []).map((x) => x.posixPath());
34
17
  });
35
18
  return filePaths;
36
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mac-helper",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "useful helper for macOS",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -31,15 +31,24 @@
31
31
  "url": "https://github.com/magicdawn/mac-helper/issues"
32
32
  },
33
33
  "homepage": "https://github.com/magicdawn/mac-helper#readme",
34
+ "dependencies": {
35
+ "@jxa/run": "^1.3.6"
36
+ },
34
37
  "devDependencies": {
38
+ "@jxa/global-type": "^1.3.6",
39
+ "@jxa/sdef-to-dts": "^1.3.6",
40
+ "@jxa/types": "^1.3.6",
35
41
  "@magicdawn/prettier-config": "^0.0.2",
36
42
  "@swc/core": "^1.3.19",
43
+ "@types/fs-extra": "^11.0.1",
37
44
  "@types/node": "^18.11.9",
38
45
  "@typescript-eslint/eslint-plugin": "^5.44.0",
39
46
  "@typescript-eslint/parser": "^5.44.0",
40
47
  "eslint": "^8.28.0",
41
48
  "eslint-config-prettier": "^8.5.0",
49
+ "fs-extra": "^11.1.0",
42
50
  "husky": "^8.0.2",
51
+ "jxa-common-used": "^0.0.2",
43
52
  "lint-staged": "^13.0.3",
44
53
  "mocha": "^10.1.0",
45
54
  "nyc": "^15.1.0",
@@ -55,11 +64,5 @@
55
64
  "*.{js,jsx,ts,tsx,less,md}": [
56
65
  "prettier --write"
57
66
  ]
58
- },
59
- "dependencies": {
60
- "@jxa/global-type": "^1.3.6",
61
- "@jxa/run": "^1.3.6",
62
- "applescript": "^1.0.0",
63
- "promise.ify": "^0.4.0"
64
67
  }
65
68
  }
package/src/index.ts CHANGED
@@ -1,25 +1,9 @@
1
- import '@jxa/global-type'
2
1
  import { run as jxaRun } from '@jxa/run'
3
- import AppleScript from 'applescript'
4
- import pify from 'promise.ify'
5
-
6
- const SCRIPT_FI_SELECTION = `
7
- tell application "Path Finder"
8
- get POSIX path of (get item 1 of (get selection))
9
- end tell
10
- `
11
- export async function deprecated_getFinderSelectionViaAppleScript() {
12
- const result = (await pify(
13
- AppleScript.execString,
14
- AppleScript
15
- )(SCRIPT_FI_SELECTION.trim())) as string[]
16
- const url = result && result[0]
17
- return url
18
- }
2
+ import { type PathFinder as PathFinderType } from 'jxa-common-used'
19
3
 
20
4
  export async function getPathFinderSelect() {
21
5
  const filePath: string | null = await jxaRun(() => {
22
- const app = Application('Path Finder')
6
+ const app = Application<PathFinderType>('Path Finder')
23
7
  return app.selection()?.[0]?.posixPath() ?? null
24
8
  })
25
9
  return filePath
@@ -27,8 +11,8 @@ export async function getPathFinderSelect() {
27
11
 
28
12
  export async function getPathFinderSelects() {
29
13
  const filePaths: string[] = await jxaRun(() => {
30
- const app = Application('Path Finder')
31
- return (app.selection() || []).map((x: any) => x?.posixPath())
14
+ const app = Application<PathFinderType>('Path Finder')
15
+ return (app.selection() || []).map((x) => x.posixPath())
32
16
  })
33
17
  return filePaths
34
18
  }
@@ -41,7 +25,6 @@ export const PathFinder = {
41
25
  return getPathFinderSelects()
42
26
  },
43
27
  }
44
-
45
28
  // ;(async () => {
46
29
  // console.log(await getPathFinderSelect())
47
30
  // console.log(await getPathFinderSelects())