trackrev 0.1.0 → 0.2.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/README.md +874 -42
- package/package.json +14 -2
- package/src/commands/affiliates.js +162 -0
- package/src/commands/analytics.js +128 -0
- package/src/commands/attribution.js +55 -0
- package/src/commands/auth.js +41 -0
- package/src/commands/domains.js +60 -0
- package/src/commands/folders.js +69 -0
- package/src/commands/keys.js +54 -0
- package/src/commands/links.js +203 -0
- package/src/commands/me.js +25 -0
- package/src/commands/money.js +96 -0
- package/src/commands/people.js +94 -0
- package/src/commands/retargeting.js +49 -0
- package/src/commands/revenue.js +86 -0
- package/src/commands/settings.js +64 -0
- package/src/commands/webhooks.js +79 -0
- package/src/index.js +43 -294
- package/src/lib/api.js +87 -0
- package/src/lib/config.js +52 -0
- package/src/lib/output.js +72 -0
- package/src/lib/prompt.js +55 -0
- package/src/registry.d.ts +39 -0
- package/src/registry.js +840 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { EXIT, die } from "./api.js";
|
|
3
|
+
|
|
4
|
+
const CTRL_C = String.fromCharCode(3);
|
|
5
|
+
const BACKSPACE = String.fromCharCode(127);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Yes/no on stderr (stdout stays pipe-clean). `--yes` skips it; without a TTY
|
|
9
|
+
* and without --yes we refuse rather than hang a script waiting for a keypress.
|
|
10
|
+
*/
|
|
11
|
+
export async function confirm(question, { yes } = {}) {
|
|
12
|
+
if (yes) return true;
|
|
13
|
+
if (!process.stdin.isTTY) {
|
|
14
|
+
die(`${question}\nRefusing to run a destructive command non-interactively. Pass --yes.`, EXIT.USAGE);
|
|
15
|
+
}
|
|
16
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
17
|
+
const answer = await new Promise((resolve) => rl.question(`${question} [y/N] `, resolve));
|
|
18
|
+
rl.close();
|
|
19
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Read a secret without echoing it. */
|
|
23
|
+
export function promptSecret(label) {
|
|
24
|
+
if (!process.stdin.isTTY) {
|
|
25
|
+
die("No terminal to prompt on. Pass --key or set TRACKREV_KEY.", EXIT.USAGE);
|
|
26
|
+
}
|
|
27
|
+
process.stderr.write(`${label}: `);
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
const { stdin } = process;
|
|
30
|
+
stdin.setRawMode(true);
|
|
31
|
+
stdin.resume();
|
|
32
|
+
stdin.setEncoding("utf8");
|
|
33
|
+
let buf = "";
|
|
34
|
+
const onData = (ch) => {
|
|
35
|
+
if (ch === CTRL_C) {
|
|
36
|
+
process.stderr.write("\n");
|
|
37
|
+
process.exit(EXIT.USAGE);
|
|
38
|
+
}
|
|
39
|
+
if (ch === "\r" || ch === "\n") {
|
|
40
|
+
stdin.setRawMode(false);
|
|
41
|
+
stdin.pause();
|
|
42
|
+
stdin.off("data", onData);
|
|
43
|
+
process.stderr.write("\n");
|
|
44
|
+
resolve(buf);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (ch === BACKSPACE || ch === "\b") {
|
|
48
|
+
buf = buf.slice(0, -1);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
buf += ch;
|
|
52
|
+
};
|
|
53
|
+
stdin.on("data", onData);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface CliFlag {
|
|
2
|
+
name: string;
|
|
3
|
+
type: "string" | "boolean";
|
|
4
|
+
meaning: string;
|
|
5
|
+
/** Placeholder shown after the flag in help, e.g. "N", "ISO", "URL". */
|
|
6
|
+
arg?: string;
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
default?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CliCommand {
|
|
12
|
+
noun: string;
|
|
13
|
+
verb: string | null;
|
|
14
|
+
group: "Analytics" | "Links" | "Account";
|
|
15
|
+
summary: string;
|
|
16
|
+
example: string;
|
|
17
|
+
args: string[];
|
|
18
|
+
flags: CliFlag[];
|
|
19
|
+
module: string;
|
|
20
|
+
handler: string;
|
|
21
|
+
paid: boolean;
|
|
22
|
+
destructive?: boolean;
|
|
23
|
+
aliases?: string[];
|
|
24
|
+
bareNoun?: boolean;
|
|
25
|
+
note?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const VERSION: string;
|
|
29
|
+
export const GLOBAL_FLAGS: CliFlag[];
|
|
30
|
+
export const COMMANDS: CliCommand[];
|
|
31
|
+
export function usageOf(cmd: CliCommand): string;
|
|
32
|
+
export function flagLabel(f: CliFlag): string;
|
|
33
|
+
export function resolve(
|
|
34
|
+
noun: string | undefined,
|
|
35
|
+
verb: string | undefined,
|
|
36
|
+
): { command: CliCommand; consumed: number } | null;
|
|
37
|
+
export function optionsFor(cmd: CliCommand | null): Record<string, unknown>;
|
|
38
|
+
export function helpText(): string;
|
|
39
|
+
export function helpFor(cmd: CliCommand): string;
|