osx-query 0.1.6 → 0.1.8
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 +3 -3
- package/bin/osx.js +68 -0
- package/lib/install.js +0 -61
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,16 +56,16 @@ If queries return nothing useful, grant Accessibility access to your terminal ap
|
|
|
56
56
|
|
|
57
57
|
## Optional Codex Skill
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
On first run, `osx` can optionally prompt to run:
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
62
|
npx skills add Moulik-Budhiraja/OSX-Query
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
That step is optional and only appears in an interactive terminal. If you skip it
|
|
65
|
+
That step is optional and only appears once in an interactive terminal. If you skip it, you can still run it later yourself.
|
|
66
66
|
|
|
67
67
|
To suppress the prompt entirely:
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
|
-
OSX_QUERY_SKIP_SKILLS_PROMPT=1
|
|
70
|
+
OSX_QUERY_SKIP_SKILLS_PROMPT=1 osx --help
|
|
71
71
|
```
|
package/bin/osx.js
CHANGED
|
@@ -4,6 +4,7 @@ const fs = require("node:fs");
|
|
|
4
4
|
const os = require("node:os");
|
|
5
5
|
const path = require("node:path");
|
|
6
6
|
const https = require("node:https");
|
|
7
|
+
const readline = require("node:readline/promises");
|
|
7
8
|
const { spawnSync } = require("node:child_process");
|
|
8
9
|
|
|
9
10
|
const pkg = require("../package.json");
|
|
@@ -53,6 +54,18 @@ function writeCache(cacheFile, payload) {
|
|
|
53
54
|
fs.writeFileSync(cacheFile, `${JSON.stringify(payload)}\n`);
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
function shouldPromptForSkills() {
|
|
58
|
+
if (process.env.CI) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (process.env.OSX_QUERY_SKIP_SKILLS_PROMPT === "1") {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
function fetchLatestVersion() {
|
|
57
70
|
return new Promise((resolve, reject) => {
|
|
58
71
|
const request = https.get(
|
|
@@ -137,6 +150,60 @@ async function maybeWarnAboutUpdate() {
|
|
|
137
150
|
}
|
|
138
151
|
}
|
|
139
152
|
|
|
153
|
+
async function maybePromptForSkills() {
|
|
154
|
+
if (!shouldPromptForSkills()) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const cacheFile = getCacheFilePath();
|
|
159
|
+
const cached = readCache(cacheFile) || {};
|
|
160
|
+
if (cached.skillsPromptedAt) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const rl = readline.createInterface({
|
|
165
|
+
input: process.stdin,
|
|
166
|
+
output: process.stdout,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
let answer = "";
|
|
170
|
+
try {
|
|
171
|
+
answer = await rl.question(
|
|
172
|
+
"Install the optional Codex skill now? This will run `npx skills add Moulik-Budhiraja/OSX-Query` [y/N]: "
|
|
173
|
+
);
|
|
174
|
+
} finally {
|
|
175
|
+
rl.close();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const nextCache = {
|
|
179
|
+
...cached,
|
|
180
|
+
skillsPromptedAt: Date.now(),
|
|
181
|
+
};
|
|
182
|
+
writeCache(cacheFile, nextCache);
|
|
183
|
+
|
|
184
|
+
if (!/^(y|yes)$/i.test(answer.trim())) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const command = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
189
|
+
const result = spawnSync(command, ["skills", "add", "Moulik-Budhiraja/OSX-Query"], {
|
|
190
|
+
stdio: "inherit",
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
if (result.error) {
|
|
194
|
+
console.warn(
|
|
195
|
+
"Skill installer could not be launched. Run `npx skills add Moulik-Budhiraja/OSX-Query` manually."
|
|
196
|
+
);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (result.status !== 0) {
|
|
201
|
+
console.warn(
|
|
202
|
+
"Skill install did not complete successfully. Run `npx skills add Moulik-Budhiraja/OSX-Query` manually."
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
140
207
|
if (!fs.existsSync(binaryPath)) {
|
|
141
208
|
console.error("osx-query is not installed correctly: native binary is missing");
|
|
142
209
|
console.error("Try reinstalling: npm i -g osx-query");
|
|
@@ -145,6 +212,7 @@ if (!fs.existsSync(binaryPath)) {
|
|
|
145
212
|
|
|
146
213
|
async function main() {
|
|
147
214
|
await maybeWarnAboutUpdate();
|
|
215
|
+
await maybePromptForSkills();
|
|
148
216
|
|
|
149
217
|
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
150
218
|
stdio: "inherit",
|
package/lib/install.js
CHANGED
|
@@ -4,7 +4,6 @@ const fs = require("node:fs");
|
|
|
4
4
|
const os = require("node:os");
|
|
5
5
|
const path = require("node:path");
|
|
6
6
|
const https = require("node:https");
|
|
7
|
-
const readline = require("node:readline/promises");
|
|
8
7
|
const { pipeline } = require("node:stream/promises");
|
|
9
8
|
const { createWriteStream } = require("node:fs");
|
|
10
9
|
const { spawnSync } = require("node:child_process");
|
|
@@ -91,65 +90,6 @@ function installBinary(extractedRoot, vendorDir) {
|
|
|
91
90
|
return targetBinary;
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
function shouldPromptForSkills() {
|
|
95
|
-
if (process.env.CI) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (process.env.OSX_QUERY_SKIP_SKILLS_PROMPT === "1") {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async function maybePromptForSkills() {
|
|
107
|
-
if (!shouldPromptForSkills()) {
|
|
108
|
-
console.log(
|
|
109
|
-
"Optional: run `npx skills add Moulik-Budhiraja/OSX-Query` to install the Codex skill."
|
|
110
|
-
);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const rl = readline.createInterface({
|
|
115
|
-
input: process.stdin,
|
|
116
|
-
output: process.stdout,
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
const answer = await rl.question(
|
|
121
|
-
"Install the optional Codex skill now? This will run `npx skills add Moulik-Budhiraja/OSX-Query` [y/N]: "
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
if (!/^(y|yes)$/i.test(answer.trim())) {
|
|
125
|
-
console.log(
|
|
126
|
-
"Skipped skill install. You can run `npx skills add Moulik-Budhiraja/OSX-Query` later."
|
|
127
|
-
);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
} finally {
|
|
131
|
-
rl.close();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const command = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
135
|
-
const result = spawnSync(command, ["skills", "add", "Moulik-Budhiraja/OSX-Query"], {
|
|
136
|
-
stdio: "inherit",
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
if (result.error) {
|
|
140
|
-
console.warn(
|
|
141
|
-
"Skill installer could not be launched. Run `npx skills add Moulik-Budhiraja/OSX-Query` manually."
|
|
142
|
-
);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (result.status !== 0) {
|
|
147
|
-
console.warn(
|
|
148
|
-
"Skill install did not complete successfully. Run `npx skills add Moulik-Budhiraja/OSX-Query` manually."
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
93
|
async function main() {
|
|
154
94
|
const binaryVersion = pkg.osxBinaryVersion || pkg.version;
|
|
155
95
|
const assetName = getAssetName(binaryVersion);
|
|
@@ -170,7 +110,6 @@ async function main() {
|
|
|
170
110
|
const installedBinary = installBinary(extractDir, vendorDir);
|
|
171
111
|
console.log(`Installed osx at ${installedBinary}`);
|
|
172
112
|
console.log("Run `osx --help` to get started.");
|
|
173
|
-
await maybePromptForSkills();
|
|
174
113
|
} finally {
|
|
175
114
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
176
115
|
}
|