@dropthis/cli 0.36.0 → 0.37.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/cli.cjs +92 -2
- package/dist/cli.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/edge.cjs +34 -1
- package/node_modules/@dropthis/node/dist/edge.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/edge.d.cts +1 -1
- package/node_modules/@dropthis/node/dist/edge.d.ts +1 -1
- package/node_modules/@dropthis/node/dist/edge.mjs +34 -1
- package/node_modules/@dropthis/node/dist/edge.mjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.cjs +34 -1
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.d.cts +2 -2
- package/node_modules/@dropthis/node/dist/index.d.ts +2 -2
- package/node_modules/@dropthis/node/dist/index.mjs +34 -1
- package/node_modules/@dropthis/node/dist/index.mjs.map +1 -1
- package/node_modules/@dropthis/node/dist/{workspaces-Cq705UM6.d.cts → workspaces-CfwVerjp.d.cts} +45 -5
- package/node_modules/@dropthis/node/dist/{workspaces-Cq705UM6.d.ts → workspaces-CfwVerjp.d.ts} +45 -5
- package/node_modules/@dropthis/node/package.json +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -684,6 +684,36 @@ async function runAccountDelete(input, deps) {
|
|
|
684
684
|
return { exitCode: 0 };
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
+
// src/commands/analytics.ts
|
|
688
|
+
async function runAnalytics(dropId, _input, deps) {
|
|
689
|
+
try {
|
|
690
|
+
await requireCredential({
|
|
691
|
+
...deps.apiKey ? { apiKey: deps.apiKey } : {},
|
|
692
|
+
env: deps.env,
|
|
693
|
+
store: deps.store
|
|
694
|
+
});
|
|
695
|
+
} catch {
|
|
696
|
+
return writeAuthError(deps);
|
|
697
|
+
}
|
|
698
|
+
const result = await deps.client.drops.analytics(dropId);
|
|
699
|
+
if (result.error) {
|
|
700
|
+
return writeApiError(deps, result.error);
|
|
701
|
+
}
|
|
702
|
+
const data = result.data;
|
|
703
|
+
const pairs = [];
|
|
704
|
+
if (data.views !== void 0) pairs.push(["Views", String(data.views)]);
|
|
705
|
+
if (data.truncated) pairs.push(["Truncated", "yes (lower bound)"]);
|
|
706
|
+
pushBreakdown(pairs, "Top country", data.byCountry);
|
|
707
|
+
pushBreakdown(pairs, "Top referer", data.byReferer);
|
|
708
|
+
writeKv(deps, pairs, { ok: true, analytics: result.data });
|
|
709
|
+
return { exitCode: 0 };
|
|
710
|
+
}
|
|
711
|
+
function pushBreakdown(pairs, label, value) {
|
|
712
|
+
if (!Array.isArray(value) || value.length === 0) return;
|
|
713
|
+
const top = value[0];
|
|
714
|
+
pairs.push([label, `${top.key ?? "?"} (${top.views ?? 0})`]);
|
|
715
|
+
}
|
|
716
|
+
|
|
687
717
|
// src/commands/api-keys.ts
|
|
688
718
|
var prompts2 = __toESM(require("@clack/prompts"), 1);
|
|
689
719
|
|
|
@@ -1168,13 +1198,40 @@ async function runDeploymentsGet(dropId, deploymentId, _input, deps) {
|
|
|
1168
1198
|
writeKv(deps, pairs, { ok: true, deployment: result.data });
|
|
1169
1199
|
return { exitCode: 0 };
|
|
1170
1200
|
}
|
|
1201
|
+
async function runDeploymentsRestore(dropId, deploymentId, _input, deps) {
|
|
1202
|
+
try {
|
|
1203
|
+
await requireCredential({
|
|
1204
|
+
...deps.apiKey ? { apiKey: deps.apiKey } : {},
|
|
1205
|
+
env: deps.env,
|
|
1206
|
+
store: deps.store
|
|
1207
|
+
});
|
|
1208
|
+
} catch {
|
|
1209
|
+
return writeAuthError(deps);
|
|
1210
|
+
}
|
|
1211
|
+
const result = await deps.client.deployments.restore(dropId, deploymentId);
|
|
1212
|
+
if (result.error) {
|
|
1213
|
+
return writeApiError(deps, result.error);
|
|
1214
|
+
}
|
|
1215
|
+
const data = result.data;
|
|
1216
|
+
if (deps.outputMode === "human") {
|
|
1217
|
+
deps.stdout(`${success(`Restored to deployment ${deploymentId}.`)}
|
|
1218
|
+
`);
|
|
1219
|
+
}
|
|
1220
|
+
const pairs = [];
|
|
1221
|
+
if (data.id) pairs.push(["ID", String(data.id)]);
|
|
1222
|
+
if (data.url) pairs.push(["URL", url(String(data.url))]);
|
|
1223
|
+
if (data.revision !== void 0)
|
|
1224
|
+
pairs.push(["Revision", String(data.revision)]);
|
|
1225
|
+
writeKv(deps, pairs, { ok: true, drop: result.data });
|
|
1226
|
+
return { exitCode: 0 };
|
|
1227
|
+
}
|
|
1171
1228
|
function spreadData(data) {
|
|
1172
1229
|
return data && typeof data === "object" ? data : { data };
|
|
1173
1230
|
}
|
|
1174
1231
|
|
|
1175
1232
|
// src/version.ts
|
|
1176
|
-
var CLI_VERSION = true ? "0.
|
|
1177
|
-
var SDK_VERSION = true ? "0.
|
|
1233
|
+
var CLI_VERSION = true ? "0.37.0" : "0.0.0-dev";
|
|
1234
|
+
var SDK_VERSION = true ? "0.33.0" : "0.0.0-dev";
|
|
1178
1235
|
|
|
1179
1236
|
// src/commands/doctor.ts
|
|
1180
1237
|
async function onlineChecks(deps, hasCredential) {
|
|
@@ -3948,6 +4005,39 @@ ${import_picocolors6.default.bold("Canonical vs raw URLs:")}`,
|
|
|
3948
4005
|
process.exitCode = result.exitCode;
|
|
3949
4006
|
}
|
|
3950
4007
|
);
|
|
4008
|
+
deployments.command("restore <dropId> <deploymentId>").description(
|
|
4009
|
+
"Roll a drop back to a prior deployment's content (Pro+ version history).\nMints a new deployment copying that one and makes it current; the URL is unchanged."
|
|
4010
|
+
).option("--json", "Force JSON output").addHelpText(
|
|
4011
|
+
"after",
|
|
4012
|
+
examplesBlock([
|
|
4013
|
+
"dropthis deployments list drop_abc # find the deployment id to restore",
|
|
4014
|
+
"dropthis deployments restore drop_abc dep_1 # make dep_1's content current again"
|
|
4015
|
+
])
|
|
4016
|
+
).action(
|
|
4017
|
+
async (dropId, deploymentId, commandOptions) => {
|
|
4018
|
+
const deps = await commandDeps(program, options, store, commandOptions);
|
|
4019
|
+
const result = await runDeploymentsRestore(
|
|
4020
|
+
dropId,
|
|
4021
|
+
deploymentId,
|
|
4022
|
+
commandOptions,
|
|
4023
|
+
deps
|
|
4024
|
+
);
|
|
4025
|
+
process.exitCode = result.exitCode;
|
|
4026
|
+
}
|
|
4027
|
+
);
|
|
4028
|
+
program.command("analytics <dropId>").description(
|
|
4029
|
+
"Show a drop's approximate view analytics (Keep+ for counts, Pro for breakdowns)"
|
|
4030
|
+
).option("--json", "Force JSON output").addHelpText(
|
|
4031
|
+
"after",
|
|
4032
|
+
examplesBlock([
|
|
4033
|
+
"dropthis analytics drop_abc",
|
|
4034
|
+
"dropthis analytics drop_abc --json | jq .analytics.views"
|
|
4035
|
+
])
|
|
4036
|
+
).action(async (dropId, commandOptions) => {
|
|
4037
|
+
const deps = await commandDeps(program, options, store, commandOptions);
|
|
4038
|
+
const result = await runAnalytics(dropId, commandOptions, deps);
|
|
4039
|
+
process.exitCode = result.exitCode;
|
|
4040
|
+
});
|
|
3951
4041
|
const domains = program.command("domains").description(
|
|
3952
4042
|
"Manage custom domains. Loop: connect \u2192 create the CNAME at your DNS provider \u2192 verify --wait \u2192 publish --domain"
|
|
3953
4043
|
);
|