mac-helper 0.0.1 → 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,9 +1,13 @@
1
1
  {
2
2
  "name": "mac-helper",
3
- "version": "0.0.1",
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",
7
+ "files": [
8
+ "lib/",
9
+ "src/"
10
+ ],
7
11
  "scripts": {
8
12
  "test": "mocha",
9
13
  "prepare": "husky install",
@@ -27,15 +31,24 @@
27
31
  "url": "https://github.com/magicdawn/mac-helper/issues"
28
32
  },
29
33
  "homepage": "https://github.com/magicdawn/mac-helper#readme",
34
+ "dependencies": {
35
+ "@jxa/run": "^1.3.6"
36
+ },
30
37
  "devDependencies": {
38
+ "@jxa/global-type": "^1.3.6",
39
+ "@jxa/sdef-to-dts": "^1.3.6",
40
+ "@jxa/types": "^1.3.6",
31
41
  "@magicdawn/prettier-config": "^0.0.2",
32
42
  "@swc/core": "^1.3.19",
43
+ "@types/fs-extra": "^11.0.1",
33
44
  "@types/node": "^18.11.9",
34
45
  "@typescript-eslint/eslint-plugin": "^5.44.0",
35
46
  "@typescript-eslint/parser": "^5.44.0",
36
47
  "eslint": "^8.28.0",
37
48
  "eslint-config-prettier": "^8.5.0",
49
+ "fs-extra": "^11.1.0",
38
50
  "husky": "^8.0.2",
51
+ "jxa-common-used": "^0.0.2",
39
52
  "lint-staged": "^13.0.3",
40
53
  "mocha": "^10.1.0",
41
54
  "nyc": "^15.1.0",
@@ -51,11 +64,5 @@
51
64
  "*.{js,jsx,ts,tsx,less,md}": [
52
65
  "prettier --write"
53
66
  ]
54
- },
55
- "dependencies": {
56
- "@jxa/global-type": "^1.3.6",
57
- "@jxa/run": "^1.3.6",
58
- "applescript": "^1.0.0",
59
- "promise.ify": "^0.4.0"
60
67
  }
61
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())
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # EditorConfig is awesome: https://EditorConfig.org
2
-
3
- # top-most EditorConfig file
4
- root = true
5
-
6
- # Unix-style newlines with a newline ending every file
7
- [*]
8
- end_of_line = lf
9
- insert_final_newline = true
10
- charset = utf-8
11
- indent_style = space
12
- indent_size = 2
13
- trim_trailing_whitespace = true
package/.eslintignore DELETED
@@ -1,4 +0,0 @@
1
- node_modules
2
-
3
- lib
4
- dist
package/.eslintrc.yml DELETED
@@ -1,18 +0,0 @@
1
- # root
2
- root: true
3
- parser: '@typescript-eslint/parser'
4
- plugins: ['@typescript-eslint']
5
-
6
- env:
7
- mocha: true
8
- node: true
9
-
10
- extends:
11
- - 'eslint:recommended'
12
- - 'plugin:@typescript-eslint/recommended'
13
- - 'prettier'
14
-
15
- rules:
16
- '@typescript-eslint/ban-ts-comment': off
17
- '@typescript-eslint/no-unused-vars': off
18
- '@typescript-eslint/no-non-null-assertion': off
@@ -1,27 +0,0 @@
1
- name: ci
2
-
3
- on:
4
- - push
5
- - pull_request
6
-
7
- jobs:
8
- unit-test:
9
- runs-on: ubuntu-latest
10
- steps:
11
- - uses: actions/checkout@v3
12
-
13
- - uses: pnpm/action-setup@v2
14
- with: { version: 7 }
15
-
16
- - uses: actions/setup-node@v3
17
- with:
18
- node-version: 16
19
- cache: 'pnpm'
20
-
21
- - run: pnpm install
22
-
23
- # test
24
- - run: pnpm test-cover
25
-
26
- # test:report
27
- - uses: codecov/codecov-action@v3
package/.husky/pre-commit DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
- pnpm lint-staged
package/.mocharc.yml DELETED
@@ -1,4 +0,0 @@
1
- require: [should]
2
- reporter: spec
3
- timeout: 5000
4
- recursive: true
package/.prettierignore DELETED
@@ -1,4 +0,0 @@
1
- node_modules
2
-
3
- lib
4
- dist
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- # CHANGELOG
2
-
3
- ## v0.0.1 2023-03-01
4
-
5
- - first release
@@ -1 +0,0 @@
1
- module.exports = require('@magicdawn/prettier-config')
package/test/.gitkeep DELETED
File without changes
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "include": ["src/**/*"],
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "lib",
6
- "allowSyntheticDefaultImports": true,
7
- "esModuleInterop": true,
8
- "moduleResolution": "node",
9
- "resolveJsonModule": true,
10
- "target": "ES2020",
11
- "module": "CommonJS",
12
- "strictNullChecks": true,
13
- "skipLibCheck": true,
14
- "declaration": true
15
- },
16
- "ts-node": {
17
- "swc": true
18
- }
19
- }