@alook/cli 0.0.10 → 0.0.11
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/dist/index.js +49 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15823,6 +15823,10 @@ function pidFilePath(profile) {
|
|
|
15823
15823
|
const name = profile ? `daemon_${profile}.pid` : "daemon.pid";
|
|
15824
15824
|
return join3(configDir(), name);
|
|
15825
15825
|
}
|
|
15826
|
+
function lastUpdateMarkerPath(profile) {
|
|
15827
|
+
const name = profile ? `last_update_${profile}` : "last_update";
|
|
15828
|
+
return join3(configDir(), name);
|
|
15829
|
+
}
|
|
15826
15830
|
function daemonLogDir() {
|
|
15827
15831
|
return join3(configDir(), "daemon", "logs");
|
|
15828
15832
|
}
|
|
@@ -16104,6 +16108,9 @@ function releaseDaemonPid(profile) {
|
|
|
16104
16108
|
removePidFileIfMatches(process.pid, profile);
|
|
16105
16109
|
}
|
|
16106
16110
|
|
|
16111
|
+
// daemon/update-handler.ts
|
|
16112
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2 } from "fs";
|
|
16113
|
+
|
|
16107
16114
|
// lib/update.ts
|
|
16108
16115
|
import { spawn } from "child_process";
|
|
16109
16116
|
function fetchLatestVersion() {
|
|
@@ -16138,16 +16145,39 @@ var MAX_RETRIES = 3;
|
|
|
16138
16145
|
function isUpdating() {
|
|
16139
16146
|
return updating;
|
|
16140
16147
|
}
|
|
16141
|
-
|
|
16148
|
+
function readUpdateMarker(profile) {
|
|
16149
|
+
try {
|
|
16150
|
+
return readFileSync4(lastUpdateMarkerPath(profile), "utf-8").trim() || null;
|
|
16151
|
+
} catch {
|
|
16152
|
+
return null;
|
|
16153
|
+
}
|
|
16154
|
+
}
|
|
16155
|
+
function writeUpdateMarker(version3, profile) {
|
|
16156
|
+
try {
|
|
16157
|
+
writeFileSync3(lastUpdateMarkerPath(profile), version3, { mode: 384 });
|
|
16158
|
+
} catch {}
|
|
16159
|
+
}
|
|
16160
|
+
function clearUpdateMarker(profile) {
|
|
16161
|
+
try {
|
|
16162
|
+
unlinkSync2(lastUpdateMarkerPath(profile));
|
|
16163
|
+
} catch {}
|
|
16164
|
+
}
|
|
16165
|
+
async function handleCliUpdate(version3, onSuccess, profile) {
|
|
16142
16166
|
if (updating)
|
|
16143
16167
|
return;
|
|
16144
16168
|
if (retryCount >= MAX_RETRIES)
|
|
16145
16169
|
return;
|
|
16170
|
+
const marker = readUpdateMarker(profile);
|
|
16171
|
+
if (marker === version3) {
|
|
16172
|
+
log.info(`Skipping update to v${version3} — already attempted (marker exists)`);
|
|
16173
|
+
return;
|
|
16174
|
+
}
|
|
16146
16175
|
updating = true;
|
|
16147
16176
|
try {
|
|
16148
16177
|
log.info(`Updating CLI to v${version3}...`);
|
|
16149
16178
|
const result = await runNpmUpdate(version3);
|
|
16150
16179
|
if (result.success) {
|
|
16180
|
+
writeUpdateMarker(version3, profile);
|
|
16151
16181
|
log.info(`CLI updated to v${version3} — restarting`);
|
|
16152
16182
|
onSuccess();
|
|
16153
16183
|
} else {
|
|
@@ -16163,7 +16193,7 @@ async function handleCliUpdate(version3, onSuccess) {
|
|
|
16163
16193
|
}
|
|
16164
16194
|
|
|
16165
16195
|
// daemon/daemon.ts
|
|
16166
|
-
import { existsSync, mkdirSync as mkdirSync3, openSync, closeSync, renameSync, readdirSync, statSync, unlinkSync as
|
|
16196
|
+
import { existsSync, mkdirSync as mkdirSync3, openSync, closeSync, renameSync, readdirSync, statSync, unlinkSync as unlinkSync3 } from "fs";
|
|
16167
16197
|
import { execSync as execSync3, spawn as spawn2 } from "child_process";
|
|
16168
16198
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16169
16199
|
import { dirname as dirname3, join as join4 } from "path";
|
|
@@ -16200,7 +16230,7 @@ function pruneSessionRunnerLogs() {
|
|
|
16200
16230
|
withMtime.sort((a, b) => b.mtime - a.mtime);
|
|
16201
16231
|
for (const entry of withMtime.slice(MAX_SESSION_RUNNER_LOGS)) {
|
|
16202
16232
|
try {
|
|
16203
|
-
|
|
16233
|
+
unlinkSync3(join4(logDir, entry.name));
|
|
16204
16234
|
} catch {}
|
|
16205
16235
|
}
|
|
16206
16236
|
}
|
|
@@ -16220,6 +16250,11 @@ async function startDaemon(profile, serverUrl) {
|
|
|
16220
16250
|
const config2 = loadDaemonConfig(profile);
|
|
16221
16251
|
if (serverUrl)
|
|
16222
16252
|
config2.serverURL = serverUrl;
|
|
16253
|
+
const marker = readUpdateMarker(profile);
|
|
16254
|
+
if (marker && marker === config2.cliVersion) {
|
|
16255
|
+
clearUpdateMarker(profile);
|
|
16256
|
+
log.info(`Cleared update marker — now running v${config2.cliVersion}`);
|
|
16257
|
+
}
|
|
16223
16258
|
const cliConfig = loadCLIConfigForProfile(profile);
|
|
16224
16259
|
const workspaces = cliConfig.watched_workspaces || [];
|
|
16225
16260
|
if (workspaces.length === 0) {
|
|
@@ -16360,8 +16395,8 @@ async function startDaemon(profile, serverUrl) {
|
|
|
16360
16395
|
evictedIds.push(ws.workspaceId);
|
|
16361
16396
|
continue;
|
|
16362
16397
|
}
|
|
16363
|
-
if (pending_update && !isUpdating()) {
|
|
16364
|
-
handleCliUpdate(pending_update.version, () => requestRestart());
|
|
16398
|
+
if (pending_update && !isUpdating() && pending_update.version !== config2.cliVersion) {
|
|
16399
|
+
handleCliUpdate(pending_update.version, () => requestRestart(), profile);
|
|
16365
16400
|
}
|
|
16366
16401
|
for (const apiTask of apiTasks) {
|
|
16367
16402
|
const task = fromApiTask(apiTask);
|
|
@@ -16630,7 +16665,7 @@ function configCommand() {
|
|
|
16630
16665
|
|
|
16631
16666
|
// commands/email.ts
|
|
16632
16667
|
import { Command as Command5 } from "commander";
|
|
16633
|
-
import { writeFileSync as
|
|
16668
|
+
import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
|
|
16634
16669
|
import { basename, join as join5 } from "path";
|
|
16635
16670
|
import PostalMime from "postal-mime";
|
|
16636
16671
|
var VALID_STATUSES = ["unread", "read", "archived"];
|
|
@@ -16721,7 +16756,7 @@ function emailCommand() {
|
|
|
16721
16756
|
references: email3.references || ""
|
|
16722
16757
|
};
|
|
16723
16758
|
const metadataPath = join5(emailDir, "metadata.json");
|
|
16724
|
-
|
|
16759
|
+
writeFileSync4(metadataPath, JSON.stringify(metadata, null, 2));
|
|
16725
16760
|
downloadedPaths.push(metadataPath);
|
|
16726
16761
|
let rawMime;
|
|
16727
16762
|
try {
|
|
@@ -16737,12 +16772,12 @@ function emailCommand() {
|
|
|
16737
16772
|
const parsed = await new PostalMime().parse(rawMime);
|
|
16738
16773
|
if (parsed.text) {
|
|
16739
16774
|
const bodyPath = join5(emailDir, "body.txt");
|
|
16740
|
-
|
|
16775
|
+
writeFileSync4(bodyPath, parsed.text);
|
|
16741
16776
|
downloadedPaths.push(bodyPath);
|
|
16742
16777
|
}
|
|
16743
16778
|
if (parsed.html) {
|
|
16744
16779
|
const htmlPath = join5(emailDir, "body.html");
|
|
16745
|
-
|
|
16780
|
+
writeFileSync4(htmlPath, parsed.html);
|
|
16746
16781
|
downloadedPaths.push(htmlPath);
|
|
16747
16782
|
}
|
|
16748
16783
|
if (parsed.attachments && parsed.attachments.length > 0) {
|
|
@@ -16766,7 +16801,7 @@ function emailCommand() {
|
|
|
16766
16801
|
} else {
|
|
16767
16802
|
buf = Buffer.from(content);
|
|
16768
16803
|
}
|
|
16769
|
-
|
|
16804
|
+
writeFileSync4(attPath, buf);
|
|
16770
16805
|
downloadedPaths.push(attPath);
|
|
16771
16806
|
}
|
|
16772
16807
|
}
|
|
@@ -16805,7 +16840,7 @@ function emailCommand() {
|
|
|
16805
16840
|
const client = new APIClient(serverUrl, token, workspaceId);
|
|
16806
16841
|
let htmlBody;
|
|
16807
16842
|
try {
|
|
16808
|
-
htmlBody =
|
|
16843
|
+
htmlBody = readFileSync5(opts.bodyFile, "utf-8");
|
|
16809
16844
|
} catch (err) {
|
|
16810
16845
|
console.error(`Error: cannot read body file "${opts.bodyFile}": ${err instanceof Error ? err.message : err}`);
|
|
16811
16846
|
process.exit(1);
|
|
@@ -16821,7 +16856,7 @@ function emailCommand() {
|
|
|
16821
16856
|
let bytes;
|
|
16822
16857
|
let size;
|
|
16823
16858
|
try {
|
|
16824
|
-
bytes =
|
|
16859
|
+
bytes = readFileSync5(path);
|
|
16825
16860
|
size = statSync2(path).size;
|
|
16826
16861
|
} catch (err) {
|
|
16827
16862
|
console.error(`Error: cannot read attachment "${path}": ${err instanceof Error ? err.message : err}`);
|
|
@@ -17125,7 +17160,7 @@ ${result.output}`);
|
|
|
17125
17160
|
|
|
17126
17161
|
// commands/sync.ts
|
|
17127
17162
|
import { Command as Command9 } from "commander";
|
|
17128
|
-
import { readFileSync as
|
|
17163
|
+
import { readFileSync as readFileSync6, statSync as statSync3 } from "fs";
|
|
17129
17164
|
import { basename as basename2 } from "path";
|
|
17130
17165
|
var MIME_BY_EXT2 = {
|
|
17131
17166
|
".pdf": "application/pdf",
|
|
@@ -17176,7 +17211,7 @@ function syncCommand() {
|
|
|
17176
17211
|
try {
|
|
17177
17212
|
const stat = statSync3(opts.file);
|
|
17178
17213
|
size = stat.size;
|
|
17179
|
-
bytes =
|
|
17214
|
+
bytes = readFileSync6(opts.file);
|
|
17180
17215
|
} catch (err) {
|
|
17181
17216
|
console.error(`Error: cannot read file "${opts.file}": ${err.message}`);
|
|
17182
17217
|
process.exit(1);
|