@intactfile/cli 0.1.1 → 0.3.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/dist/index.js +47 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7,13 +7,13 @@ import { mkdirSync, writeFileSync } from "node:fs";
|
|
|
7
7
|
import { basename, dirname, extname, join, parse } from "node:path";
|
|
8
8
|
import { createInterface } from "node:readline";
|
|
9
9
|
import { Command } from "commander";
|
|
10
|
-
import { ApiError, balance, clearAuth, consume, EntitlementError, getToken, login as apiLogin, magic as apiMagic, recover as apiRecover, repairPath, diagnosePath, requireBusiness, setToken, UnsupportedError, } from "@intactfile/node-core";
|
|
10
|
+
import { ApiError, balance, clearAuth, consume, EntitlementError, ensureLicense, getLicenseStatus, getToken, login as apiLogin, magic as apiMagic, recover as apiRecover, repairPath, diagnosePath, requireBusiness, setToken, UnsupportedError, } from "@intactfile/node-core";
|
|
11
11
|
import { generateRepairReportPdf } from "@intactfile/report";
|
|
12
12
|
const program = new Command();
|
|
13
13
|
program
|
|
14
14
|
.name("intactfile")
|
|
15
15
|
.description("Repair corrupted files locally — your files never leave your machine.")
|
|
16
|
-
.version("0.
|
|
16
|
+
.version("0.2.0");
|
|
17
17
|
/* ------------------------------- helpers ------------------------------- */
|
|
18
18
|
function ask(query) {
|
|
19
19
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -43,7 +43,27 @@ const OUT_EXT = {
|
|
|
43
43
|
png: ".png",
|
|
44
44
|
sqlite: ".sqlite",
|
|
45
45
|
archive: "",
|
|
46
|
+
audio: ".wav",
|
|
47
|
+
avi: ".avi",
|
|
48
|
+
raw: ".dng",
|
|
49
|
+
psd: ".psd",
|
|
50
|
+
"office-legacy": ".doc",
|
|
46
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* When the returned bytes are a salvaged preview (not the native container),
|
|
54
|
+
* name the file honestly. RAW → embedded JPEG; PSD thumbnail-only → JPEG.
|
|
55
|
+
*/
|
|
56
|
+
function previewName(input, r) {
|
|
57
|
+
if (r.kind !== "file")
|
|
58
|
+
return null;
|
|
59
|
+
const rep = r.report;
|
|
60
|
+
const p = parse(input);
|
|
61
|
+
if (r.family === "raw" && rep.previewSource != null)
|
|
62
|
+
return join(p.dir, `${p.name}.preview.jpg`);
|
|
63
|
+
if (r.family === "psd" && rep.output === "jpeg")
|
|
64
|
+
return join(p.dir, `${p.name}.thumbnail.jpg`);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
47
67
|
function defaultOut(input, family) {
|
|
48
68
|
const p = parse(input);
|
|
49
69
|
const ext = p.ext || OUT_EXT[family];
|
|
@@ -82,7 +102,10 @@ function writeResult(input, out, r) {
|
|
|
82
102
|
}
|
|
83
103
|
return written;
|
|
84
104
|
}
|
|
85
|
-
|
|
105
|
+
// A salvaged preview (RAW embedded JPEG, PSD thumbnail) is not the native
|
|
106
|
+
// container — name it honestly instead of dressing it up.
|
|
107
|
+
const preview = out ? null : previewName(input, r);
|
|
108
|
+
const dest = preview ?? out ?? defaultOut(input, r.family);
|
|
86
109
|
writeFileSync(dest, r.bytes);
|
|
87
110
|
return [dest];
|
|
88
111
|
}
|
|
@@ -176,6 +199,27 @@ program
|
|
|
176
199
|
handle(e);
|
|
177
200
|
}
|
|
178
201
|
});
|
|
202
|
+
program
|
|
203
|
+
.command("license")
|
|
204
|
+
.description("Fetch and apply your offline Business license (used by repair and the SDK).")
|
|
205
|
+
.option("--refresh", "force a fresh license even if the cached one is still valid")
|
|
206
|
+
.action(async (opts) => {
|
|
207
|
+
try {
|
|
208
|
+
await requireBusiness();
|
|
209
|
+
const token = getToken();
|
|
210
|
+
if (token)
|
|
211
|
+
await ensureLicense(token, { force: !!opts.refresh });
|
|
212
|
+
const status = await getLicenseStatus();
|
|
213
|
+
if (!status.licensed) {
|
|
214
|
+
return die(`Couldn't apply a license (${status.reason ?? "unknown"}).`);
|
|
215
|
+
}
|
|
216
|
+
console.log(`✓ License active (${status.tier}) — valid until ${status.expiresAt?.slice(0, 10)}.`);
|
|
217
|
+
console.log(" The CLI, MCP server, and SDK use it automatically; it works offline until then.");
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
handle(e);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
179
223
|
function summarize(sub) {
|
|
180
224
|
if (!sub)
|
|
181
225
|
return console.log("Plan: none (no active subscription).");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intactfile/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "IntactFile CLI — repair corrupted files locally (video, ZIP/Office, PDF, JPEG, PNG, SQLite, RAR/7z). Your files never leave your machine. Business plan for repairs; diagnosis is free.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"commander": "^12.1.0",
|
|
18
|
-
"@intactfile/node-core": "0.
|
|
18
|
+
"@intactfile/node-core": "0.3.0",
|
|
19
19
|
"@intactfile/report": "0.1.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|