@disposabl/cli 2.0.1 → 2.1.1
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 +2 -0
- package/dist/index.js +50 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,4 +39,6 @@ The command exits unsuccessfully while manual cleanup is pending. Rerun the same
|
|
|
39
39
|
|
|
40
40
|
When configured for a published release, Disposabl collects the command category, outcome, package version, operating system and package-manager category. A random ID stored in `~/.config/disposabl/telemetry.json` connects anonymous usage to the Disposabl user ID after login. Logout and account changes reset that ID. Prompts, arguments, paths, error messages, credentials and email addresses are not collected. Set `DO_NOT_TRACK=1` or `DISPOSABL_TELEMETRY_DISABLED=1` to opt out. Local source, development, CI and E2E runs do not send events. This is separate from a generated app's analytics.
|
|
41
41
|
|
|
42
|
+
Failed commands also send a fixed, coarse error-tracking event with no exception message or stack trace.
|
|
43
|
+
|
|
42
44
|
Release builds must supply the central public PostHog project token in `DISPOSABL_CLI_POSTHOG_PROJECT_TOKEN` and its ingestion host in `DISPOSABL_CLI_POSTHOG_HOST` (US or EU PostHog ingestion origin) at build time. The build embeds these public values and rejects a release without them. Set `DISPOSABL_CLI_TELEMETRY_REQUIRED=1` to enforce the same check on a development-version qualification build. Development builds without this configuration remain inert. Do not use a personal API key or an app owner's project token. Configure the central PostHog project to disable IP data capture.
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// auth.ts
|
|
4
4
|
import { lock } from "proper-lockfile";
|
|
5
5
|
// package.json
|
|
6
|
-
var version = "2.
|
|
6
|
+
var version = "2.1.1";
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@disposabl/cli",
|
|
9
9
|
version,
|
|
@@ -322,10 +322,13 @@ Sign in to Expo if needed and choose Delete project. Then rerun this command to
|
|
|
322
322
|
openUrl(url.href);
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
// commands.ts
|
|
326
|
+
import { CommanderError } from "commander";
|
|
327
|
+
|
|
325
328
|
// telemetry.ts
|
|
326
329
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
327
330
|
import { realpathSync } from "node:fs";
|
|
328
|
-
import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
331
|
+
import { mkdir as mkdir2, open, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
329
332
|
import { homedir as homedir2 } from "node:os";
|
|
330
333
|
import { dirname, join as join2 } from "node:path";
|
|
331
334
|
import { lock as lock2 } from "proper-lockfile";
|
|
@@ -391,6 +394,18 @@ async function send(config, event, distinctId, properties) {
|
|
|
391
394
|
});
|
|
392
395
|
return response.ok;
|
|
393
396
|
}
|
|
397
|
+
async function firstExecution(path, product, version) {
|
|
398
|
+
try {
|
|
399
|
+
const directory = join2(dirname(path), "activations");
|
|
400
|
+
await mkdir2(directory, { recursive: true, mode: 448 });
|
|
401
|
+
const name = createHash2("sha256").update(`${product}:${version}`).digest("hex");
|
|
402
|
+
const file = await open(join2(directory, name), "wx", 384);
|
|
403
|
+
await file.close();
|
|
404
|
+
return true;
|
|
405
|
+
} catch {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
394
409
|
async function capture(version, product, command, outcome, path) {
|
|
395
410
|
const config = telemetryConfig(version);
|
|
396
411
|
if (!config)
|
|
@@ -412,15 +427,29 @@ async function capture(version, product, command, outcome, path) {
|
|
|
412
427
|
"other",
|
|
413
428
|
"create"
|
|
414
429
|
];
|
|
415
|
-
|
|
430
|
+
const distinctId = current.userId ?? current.anonymousId;
|
|
431
|
+
const activation = outcome === "started" && await firstExecution(path, product, version);
|
|
432
|
+
const properties = {
|
|
416
433
|
product,
|
|
417
434
|
command: allowed.includes(command) ? command : "other",
|
|
418
435
|
outcome,
|
|
419
436
|
version,
|
|
437
|
+
...activation ? { first_execution: true } : {},
|
|
420
438
|
invocation: process.env.npm_command === "exec" ? "npx" : /^(npm|pnpm|yarn|bun)\//.exec(process.env.npm_config_user_agent ?? "")?.[1] ?? "direct",
|
|
421
439
|
platform: ["darwin", "linux", "win32"].includes(process.platform) ? process.platform : "other",
|
|
422
440
|
...!current.userId ? { $process_person_profile: false } : {}
|
|
423
|
-
}
|
|
441
|
+
};
|
|
442
|
+
const pending = [send(config, "cli_command", distinctId, properties)];
|
|
443
|
+
if (outcome === "failure") {
|
|
444
|
+
pending.push(send(config, "$exception", distinctId, {
|
|
445
|
+
...properties,
|
|
446
|
+
$exception_list: [
|
|
447
|
+
{ type: "CommandFailure", value: "Command failed" }
|
|
448
|
+
],
|
|
449
|
+
$exception_fingerprint: `disposabl-${product}-${properties.command}`
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
await Promise.allSettled(pending);
|
|
424
453
|
} catch {}
|
|
425
454
|
}
|
|
426
455
|
async function prepareLogin(path) {
|
|
@@ -515,6 +544,9 @@ function createProgram(serviceOrigin, centralAnalytics = false, dependencies = {
|
|
|
515
544
|
});
|
|
516
545
|
};
|
|
517
546
|
const program = new Command().name(Object.keys(package_default.bin)[0]).version(package_default.version);
|
|
547
|
+
program.addHelpText("after", `
|
|
548
|
+
API commands are loaded from the configured service. Use <command> --help for their options.
|
|
549
|
+
`);
|
|
518
550
|
if (centralAnalytics)
|
|
519
551
|
program.addHelpText("after", `
|
|
520
552
|
Disposabl collects limited CLI usage when configured. Set DO_NOT_TRACK=1 to opt out.
|
|
@@ -705,7 +737,7 @@ function needsContract(program, argv, origin) {
|
|
|
705
737
|
const args = argv.slice(2);
|
|
706
738
|
const { operands } = program.parseOptions(args);
|
|
707
739
|
const command = operands[0] === "help" ? operands[1] : operands[0];
|
|
708
|
-
return Boolean(origin) && !args.some((arg) => arg === "--version" || arg === "-V") && command !== "login" && command !== "logout";
|
|
740
|
+
return Boolean(origin) && command !== undefined && !args.some((arg) => arg === "--version" || arg === "-V") && command !== "login" && command !== "logout";
|
|
709
741
|
}
|
|
710
742
|
|
|
711
743
|
// commands.ts
|
|
@@ -900,6 +932,7 @@ function formatPreview(preview) {
|
|
|
900
932
|
// commands.ts
|
|
901
933
|
async function runCli(argv = process.argv, serviceOrigin = process.env.DISPOSABL_API_ORIGIN || SERVICE_ORIGIN) {
|
|
902
934
|
const program = createProgram(serviceOrigin, true);
|
|
935
|
+
program.exitOverride();
|
|
903
936
|
const origin = () => apiUrl(serviceOrigin);
|
|
904
937
|
async function main() {
|
|
905
938
|
if (needsContract(program, argv, serviceOrigin)) {
|
|
@@ -1012,20 +1045,26 @@ Waiting for connections. Press Ctrl+C to keep your files and finish later.`);
|
|
|
1012
1045
|
}
|
|
1013
1046
|
}
|
|
1014
1047
|
}
|
|
1015
|
-
|
|
1048
|
+
if (argv.length <= 2)
|
|
1049
|
+
program.outputHelp();
|
|
1050
|
+
else
|
|
1051
|
+
await program.parseAsync(argv);
|
|
1016
1052
|
}
|
|
1017
|
-
const command = argv[2] ?? "help";
|
|
1053
|
+
const command = ["--version", "-V"].includes(argv[2] ?? "") ? "version" : ["--help", "-h"].includes(argv[2] ?? "") ? "help" : argv[2] ?? "help";
|
|
1018
1054
|
const central = serviceOrigin === SERVICE_ORIGIN;
|
|
1019
|
-
|
|
1020
|
-
await capture(version, "cli", command, "started", telemetryStatePath());
|
|
1055
|
+
const started = central ? capture(version, "cli", command, "started", telemetryStatePath()) : undefined;
|
|
1021
1056
|
try {
|
|
1022
1057
|
await main();
|
|
1058
|
+
await started;
|
|
1023
1059
|
if (central)
|
|
1024
1060
|
await capture(version, "cli", command, "success", telemetryStatePath());
|
|
1025
1061
|
} catch (error) {
|
|
1062
|
+
await started;
|
|
1063
|
+
const success = error instanceof CommanderError && error.exitCode === 0;
|
|
1026
1064
|
if (central)
|
|
1027
|
-
await capture(version, "cli", command, "failure", telemetryStatePath());
|
|
1028
|
-
|
|
1065
|
+
await capture(version, "cli", command, success ? "success" : "failure", telemetryStatePath());
|
|
1066
|
+
if (!success)
|
|
1067
|
+
throw error;
|
|
1029
1068
|
}
|
|
1030
1069
|
}
|
|
1031
1070
|
|