mac-helper 0.4.0 → 0.5.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/lib/finder.d.ts +6 -0
- package/lib/finder.js +30 -0
- package/package.json +17 -15
- package/src/finder.ts +33 -0
package/lib/finder.d.ts
CHANGED
|
@@ -20,3 +20,9 @@ export type QSpaceFileItem = {
|
|
|
20
20
|
name: () => string;
|
|
21
21
|
urlstr: () => string;
|
|
22
22
|
};
|
|
23
|
+
export declare function isRepresentPF(file: string): boolean;
|
|
24
|
+
export declare function isRepresentQS(file: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 处理 $PF $QS, ignore case
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeInputFileList(fileList: string[]): Promise<string[]>;
|
package/lib/finder.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.QSpace = exports.Finder = exports.PathFinder = void 0;
|
|
7
|
+
exports.isRepresentPF = isRepresentPF;
|
|
8
|
+
exports.isRepresentQS = isRepresentQS;
|
|
9
|
+
exports.normalizeInputFileList = normalizeInputFileList;
|
|
10
|
+
const node_os_1 = require("node:os");
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
4
12
|
const node_url_1 = require("node:url");
|
|
5
13
|
const run_1 = require("@jxa/run");
|
|
14
|
+
const es_toolkit_1 = require("es-toolkit");
|
|
15
|
+
const promise_map_1 = __importDefault(require("promise.map"));
|
|
6
16
|
const app_1 = require("./app");
|
|
7
17
|
/**
|
|
8
18
|
* `App` named epxorts
|
|
@@ -97,6 +107,26 @@ async function QSpace_allSelected() {
|
|
|
97
107
|
return urls.map((u) => (0, node_url_1.fileURLToPath)(u));
|
|
98
108
|
}
|
|
99
109
|
/* #endregion */
|
|
110
|
+
/* #region Top Level Helper */
|
|
111
|
+
function isRepresentPF(file) {
|
|
112
|
+
return /^\$?pf$/i.test(file);
|
|
113
|
+
}
|
|
114
|
+
function isRepresentQS(file) {
|
|
115
|
+
return /^\$?qs$/i.test(file);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 处理 $PF $QS, ignore case
|
|
119
|
+
*/
|
|
120
|
+
async function normalizeInputFileList(fileList) {
|
|
121
|
+
return (0, es_toolkit_1.uniq)((await (0, promise_map_1.default)(fileList, async (f) => {
|
|
122
|
+
if (isRepresentPF(f))
|
|
123
|
+
return await exports.PathFinder.allSelected();
|
|
124
|
+
if (isRepresentQS(f))
|
|
125
|
+
return await exports.QSpace.allSelected();
|
|
126
|
+
return node_path_1.default.resolve(f);
|
|
127
|
+
}, (0, node_os_1.availableParallelism)())).flat());
|
|
128
|
+
}
|
|
129
|
+
/* #endregion */
|
|
100
130
|
// ;(async () => {
|
|
101
131
|
// console.log(await getQSpaceSelected())
|
|
102
132
|
// })()
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mac-helper",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"packageManager": "pnpm@10.
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"packageManager": "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501",
|
|
5
5
|
"description": "useful helper for macOS",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mac",
|
|
@@ -34,32 +34,34 @@
|
|
|
34
34
|
"test-cover": "vitest run --globals --coverage --testTimeout=30000",
|
|
35
35
|
"dev": "tsc -w --incremental",
|
|
36
36
|
"typecheck": "tsc --noEmit",
|
|
37
|
-
"build": "rm -rf lib; rm
|
|
37
|
+
"build": "rm -rf lib; rm *.tsbuildinfo; tsc",
|
|
38
38
|
"prepublishOnly": "pnpm test && pnpm build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jxa/run": "^1.4.0"
|
|
41
|
+
"@jxa/run": "^1.4.0",
|
|
42
|
+
"es-toolkit": "^1.43.0",
|
|
43
|
+
"promise.map": "^1.1.3"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@jxa/global-type": "^1.4.0",
|
|
45
47
|
"@jxa/sdef-to-dts": "^1.4.0",
|
|
46
48
|
"@jxa/types": "^1.4.0",
|
|
47
|
-
"@magicdawn/eslint-config": "^1.5.
|
|
49
|
+
"@magicdawn/eslint-config": "^1.5.14",
|
|
48
50
|
"@magicdawn/prettier-config": "^0.1.0",
|
|
49
51
|
"@types/fs-extra": "^11.0.4",
|
|
50
|
-
"@types/node": "^
|
|
51
|
-
"@vitest/coverage-v8": "^
|
|
52
|
-
"delay": "^
|
|
53
|
-
"eslint": "^9.
|
|
54
|
-
"eslint-config-prettier": "^10.1.
|
|
55
|
-
"fs-extra": "^11.3.
|
|
52
|
+
"@types/node": "^25.0.2",
|
|
53
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
54
|
+
"delay": "^7.0.0",
|
|
55
|
+
"eslint": "^9.39.2",
|
|
56
|
+
"eslint-config-prettier": "^10.1.8",
|
|
57
|
+
"fs-extra": "^11.3.2",
|
|
56
58
|
"husky": "^9.1.7",
|
|
57
59
|
"jxa-common-used": "^0.0.3",
|
|
58
|
-
"lint-staged": "^16.
|
|
59
|
-
"prettier": "^3.
|
|
60
|
+
"lint-staged": "^16.2.7",
|
|
61
|
+
"prettier": "^3.7.4",
|
|
60
62
|
"should": "^13.2.3",
|
|
61
|
-
"typescript": "^5.
|
|
62
|
-
"vitest": "^
|
|
63
|
+
"typescript": "^5.9.3",
|
|
64
|
+
"vitest": "^4.0.15"
|
|
63
65
|
},
|
|
64
66
|
"pnpm": {
|
|
65
67
|
"onlyBuiltDependencies": [
|
package/src/finder.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { availableParallelism } from 'node:os'
|
|
2
|
+
import path from 'node:path'
|
|
1
3
|
import { fileURLToPath } from 'node:url'
|
|
2
4
|
import { run as jxaRun } from '@jxa/run'
|
|
5
|
+
import { uniq } from 'es-toolkit'
|
|
6
|
+
import pmap from 'promise.map'
|
|
3
7
|
import { isAppRunning } from './app'
|
|
4
8
|
import type { PathFinder as PathFinderType } from 'jxa-common-used'
|
|
5
9
|
|
|
@@ -118,6 +122,35 @@ async function QSpace_allSelected() {
|
|
|
118
122
|
}
|
|
119
123
|
/* #endregion */
|
|
120
124
|
|
|
125
|
+
/* #region Top Level Helper */
|
|
126
|
+
export function isRepresentPF(file: string) {
|
|
127
|
+
return /^\$?pf$/i.test(file)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function isRepresentQS(file: string) {
|
|
131
|
+
return /^\$?qs$/i.test(file)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 处理 $PF $QS, ignore case
|
|
136
|
+
*/
|
|
137
|
+
export async function normalizeInputFileList(fileList: string[]) {
|
|
138
|
+
return uniq(
|
|
139
|
+
(
|
|
140
|
+
await pmap(
|
|
141
|
+
fileList,
|
|
142
|
+
async (f) => {
|
|
143
|
+
if (isRepresentPF(f)) return await PathFinder.allSelected()
|
|
144
|
+
if (isRepresentQS(f)) return await QSpace.allSelected()
|
|
145
|
+
return path.resolve(f)
|
|
146
|
+
},
|
|
147
|
+
availableParallelism(),
|
|
148
|
+
)
|
|
149
|
+
).flat(),
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
/* #endregion */
|
|
153
|
+
|
|
121
154
|
// ;(async () => {
|
|
122
155
|
// console.log(await getQSpaceSelected())
|
|
123
156
|
// })()
|