deepspace 0.6.2 → 0.7.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/CHANGELOG.md +14 -0
- package/dist/cli.js +353 -80
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +124 -1
- package/dist/index.js +148 -0
- package/dist/index.js.map +1 -1
- package/dist/worker.d.ts +146 -1
- package/dist/worker.js +105 -0
- package/dist/worker.js.map +1 -1
- package/features/ai-chat/src/ChatPanel.tsx +56 -18
- package/package.json +1 -1
- package/dist/testing.d.ts +0 -115
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli/cli.ts
|
|
4
|
-
import { defineCommand as
|
|
4
|
+
import { defineCommand as defineCommand24, runMain } from "citty";
|
|
5
5
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
6
6
|
import { readFileSync as readFileSync17, existsSync as existsSync15 } from "fs";
|
|
7
7
|
import { dirname as dirname5, join as join16 } from "path";
|
|
@@ -3822,8 +3822,280 @@ var apps_default = defineCommand11({
|
|
|
3822
3822
|
}
|
|
3823
3823
|
});
|
|
3824
3824
|
|
|
3825
|
-
// src/cli/commands/
|
|
3825
|
+
// src/cli/commands/logs.ts
|
|
3826
3826
|
import { defineCommand as defineCommand12 } from "citty";
|
|
3827
|
+
|
|
3828
|
+
// src/shared/log-events.ts
|
|
3829
|
+
var LOG_LEVELS = ["debug", "log", "info", "warn", "error"];
|
|
3830
|
+
|
|
3831
|
+
// src/cli/commands/logs.ts
|
|
3832
|
+
var DEPLOY_URL6 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
3833
|
+
var RETENTION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
3834
|
+
var DEFAULT_WINDOW_MS = 15 * 60 * 1e3;
|
|
3835
|
+
var MIN_POLL_MS = 2500;
|
|
3836
|
+
var FOLLOW_LAG_MS = 9e4;
|
|
3837
|
+
function followInitialLimit(limit, maxLimit) {
|
|
3838
|
+
return limit ?? maxLimit;
|
|
3839
|
+
}
|
|
3840
|
+
function nextPollSince(cursor, floor, lagMs = FOLLOW_LAG_MS) {
|
|
3841
|
+
return Math.max(cursor - lagMs, floor);
|
|
3842
|
+
}
|
|
3843
|
+
function parseSince(input, now = Date.now()) {
|
|
3844
|
+
const trimmed = input.trim();
|
|
3845
|
+
const rel = /^(\d+)([smhd])$/.exec(trimmed);
|
|
3846
|
+
let ts;
|
|
3847
|
+
if (rel) {
|
|
3848
|
+
const unit = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 }[rel[2]];
|
|
3849
|
+
ts = now - Number(rel[1]) * unit;
|
|
3850
|
+
} else {
|
|
3851
|
+
ts = Date.parse(trimmed);
|
|
3852
|
+
if (Number.isNaN(ts)) {
|
|
3853
|
+
throw new Error(`Invalid --since "${input}" \u2014 use 30s, 15m, 2h, 7d, or an ISO timestamp.`);
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
if (now - ts > RETENTION_MS) {
|
|
3857
|
+
throw new Error("Logs are retained for 7 days \u2014 --since can reach back at most 7d.");
|
|
3858
|
+
}
|
|
3859
|
+
return ts;
|
|
3860
|
+
}
|
|
3861
|
+
var SeenEvents = class {
|
|
3862
|
+
constructor(cap = 5e3) {
|
|
3863
|
+
this.cap = cap;
|
|
3864
|
+
}
|
|
3865
|
+
ids = /* @__PURE__ */ new Set();
|
|
3866
|
+
order = [];
|
|
3867
|
+
/** Returns only the events not seen before, recording them. */
|
|
3868
|
+
fresh(events) {
|
|
3869
|
+
const out = [];
|
|
3870
|
+
for (const e of events) {
|
|
3871
|
+
if (this.ids.has(e.id)) continue;
|
|
3872
|
+
this.ids.add(e.id);
|
|
3873
|
+
this.order.push(e.id);
|
|
3874
|
+
out.push(e);
|
|
3875
|
+
}
|
|
3876
|
+
while (this.order.length > this.cap) {
|
|
3877
|
+
this.ids.delete(this.order.shift());
|
|
3878
|
+
}
|
|
3879
|
+
return out;
|
|
3880
|
+
}
|
|
3881
|
+
};
|
|
3882
|
+
var stdoutColor = () => process.stdout.isTTY && !process.env.NO_COLOR;
|
|
3883
|
+
var stderrColor = () => process.stderr.isTTY && !process.env.NO_COLOR;
|
|
3884
|
+
var paint = (code, s, on) => on ? `\x1B[${code}m${s}\x1B[0m` : s;
|
|
3885
|
+
var LEVEL_STYLE = {
|
|
3886
|
+
error: "31",
|
|
3887
|
+
// red
|
|
3888
|
+
warn: "33",
|
|
3889
|
+
// yellow
|
|
3890
|
+
debug: "2",
|
|
3891
|
+
// dim
|
|
3892
|
+
info: null,
|
|
3893
|
+
log: null
|
|
3894
|
+
};
|
|
3895
|
+
function formatTime(ts, now) {
|
|
3896
|
+
const d = new Date(ts);
|
|
3897
|
+
const ref = new Date(now);
|
|
3898
|
+
const hms = `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}:${String(d.getSeconds()).padStart(2, "0")}.${String(d.getMilliseconds()).padStart(3, "0")}`;
|
|
3899
|
+
if (d.toDateString() === ref.toDateString()) return hms;
|
|
3900
|
+
const ymd = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
3901
|
+
return `${ymd} ${hms}`;
|
|
3902
|
+
}
|
|
3903
|
+
function formatEvent(e, color, now = Date.now()) {
|
|
3904
|
+
const time = paint("2", formatTime(e.timestamp, now), color);
|
|
3905
|
+
let tag;
|
|
3906
|
+
let body;
|
|
3907
|
+
if (e.eventType === "exception" && e.exception) {
|
|
3908
|
+
tag = paint("31", "ERROR", color);
|
|
3909
|
+
const where = e.request ? ` \u2014 ${e.request.method} ${e.request.path}` : "";
|
|
3910
|
+
body = `${e.exception.name}: ${e.exception.message}${where}`;
|
|
3911
|
+
if (e.exception.stack) {
|
|
3912
|
+
const lines = e.exception.stack.split("\n");
|
|
3913
|
+
const firstIsHeader = lines.length > 0 && !/^\s*at\s/.test(lines[0]) && lines[0].includes(e.exception.message);
|
|
3914
|
+
const frames = (firstIsHeader ? lines.slice(1) : lines).map((l) => " " + l.trim()).filter((l) => l.trim().length > 0);
|
|
3915
|
+
if (frames.length) body += "\n" + paint("2", frames.join("\n"), color);
|
|
3916
|
+
}
|
|
3917
|
+
} else if (e.eventType === "request" && e.request) {
|
|
3918
|
+
tag = paint("36", "REQ ", color);
|
|
3919
|
+
const status3 = e.request.status !== void 0 ? ` ${e.request.status}` : "";
|
|
3920
|
+
const outcome = e.outcome && e.outcome !== "ok" ? ` (${e.outcome})` : "";
|
|
3921
|
+
body = `${e.request.method} ${e.request.path}${status3}${outcome}`;
|
|
3922
|
+
} else {
|
|
3923
|
+
const style = LEVEL_STYLE[e.level];
|
|
3924
|
+
tag = (e.level.toUpperCase() + " ").slice(0, 5);
|
|
3925
|
+
if (style) tag = paint(style, tag, color);
|
|
3926
|
+
body = style ? paint(style, e.message, color) : e.message;
|
|
3927
|
+
}
|
|
3928
|
+
const client = e.source === "client" ? paint("35", "CLIENT", color) + " " : "";
|
|
3929
|
+
return `${time} ${client}${tag} ${body}`;
|
|
3930
|
+
}
|
|
3931
|
+
var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
3932
|
+
var logs_default = defineCommand12({
|
|
3933
|
+
meta: {
|
|
3934
|
+
name: "logs",
|
|
3935
|
+
description: "Show production logs for a deployed app (add --follow to tail)"
|
|
3936
|
+
},
|
|
3937
|
+
args: {
|
|
3938
|
+
app: {
|
|
3939
|
+
type: "string",
|
|
3940
|
+
alias: "a",
|
|
3941
|
+
description: "App id or name (default: DEEPSPACE_APP_ID from the nearest wrangler.toml)",
|
|
3942
|
+
required: false
|
|
3943
|
+
},
|
|
3944
|
+
env: {
|
|
3945
|
+
type: "string",
|
|
3946
|
+
alias: "e",
|
|
3947
|
+
description: "wrangler.toml [env.<name>] slot \u2014 reads that env\u2019s own app id",
|
|
3948
|
+
required: false
|
|
3949
|
+
},
|
|
3950
|
+
follow: {
|
|
3951
|
+
type: "boolean",
|
|
3952
|
+
alias: "f",
|
|
3953
|
+
description: "Keep polling for new logs until Ctrl+C (~3s cadence)",
|
|
3954
|
+
default: false
|
|
3955
|
+
},
|
|
3956
|
+
since: {
|
|
3957
|
+
type: "string",
|
|
3958
|
+
description: "Window start: 30s, 15m, 2h, 24h, 7d, or an ISO timestamp (default 15m)",
|
|
3959
|
+
required: false
|
|
3960
|
+
},
|
|
3961
|
+
level: {
|
|
3962
|
+
type: "string",
|
|
3963
|
+
description: `Only events at a level: ${LOG_LEVELS.join(", ")}`,
|
|
3964
|
+
required: false
|
|
3965
|
+
},
|
|
3966
|
+
search: {
|
|
3967
|
+
type: "string",
|
|
3968
|
+
description: "Only events whose message contains this text",
|
|
3969
|
+
required: false
|
|
3970
|
+
},
|
|
3971
|
+
limit: {
|
|
3972
|
+
type: "string",
|
|
3973
|
+
description: "Max events per fetch (default 100, max 500)",
|
|
3974
|
+
required: false
|
|
3975
|
+
},
|
|
3976
|
+
json: {
|
|
3977
|
+
type: "boolean",
|
|
3978
|
+
description: "Emit NDJSON \u2014 one event object per line (for agents/pipes)",
|
|
3979
|
+
default: false
|
|
3980
|
+
}
|
|
3981
|
+
},
|
|
3982
|
+
async run({ args }) {
|
|
3983
|
+
const token = await ensureToken();
|
|
3984
|
+
const wranglerEnv = args.env?.trim() || void 0;
|
|
3985
|
+
if (args.app && wranglerEnv) {
|
|
3986
|
+
throw new Error(
|
|
3987
|
+
"Pass either --app or --env, not both \u2014 --env reads the [env.<name>] block\u2019s own app id, --app names an app directly."
|
|
3988
|
+
);
|
|
3989
|
+
}
|
|
3990
|
+
let appId;
|
|
3991
|
+
if (!args.app && wranglerEnv) {
|
|
3992
|
+
const appDir = findAppDir();
|
|
3993
|
+
const id = appDir ? readAppId(appDir, wranglerEnv) : null;
|
|
3994
|
+
if (!id) {
|
|
3995
|
+
throw new Error(
|
|
3996
|
+
`No app id for env "${wranglerEnv}" \u2014 wrangler.toml has no [env.${wranglerEnv}] block with its own DEEPSPACE_APP_ID.`
|
|
3997
|
+
);
|
|
3998
|
+
}
|
|
3999
|
+
appId = id;
|
|
4000
|
+
} else {
|
|
4001
|
+
appId = await resolveAppTarget(DEPLOY_URL6, token, args.app);
|
|
4002
|
+
}
|
|
4003
|
+
if (args.level && !LOG_LEVELS.includes(args.level)) {
|
|
4004
|
+
throw new Error(`Invalid --level "${args.level}". Use: ${LOG_LEVELS.join(", ")}`);
|
|
4005
|
+
}
|
|
4006
|
+
let limit;
|
|
4007
|
+
if (args.limit !== void 0) {
|
|
4008
|
+
limit = Number(args.limit);
|
|
4009
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 500) {
|
|
4010
|
+
throw new Error("Invalid --limit \u2014 expected an integer between 1 and 500.");
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
const initialSince = args.since ? parseSince(args.since) : Date.now() - DEFAULT_WINDOW_MS;
|
|
4014
|
+
const windowLabel = args.since?.trim() || "15m";
|
|
4015
|
+
const MAX_LIMIT = 500;
|
|
4016
|
+
const followLimit = followInitialLimit(limit, MAX_LIMIT);
|
|
4017
|
+
const fetchPage = async (since, pageLimit, token2) => {
|
|
4018
|
+
const params = new URLSearchParams({ since: String(since) });
|
|
4019
|
+
if (pageLimit !== void 0) params.set("limit", String(pageLimit));
|
|
4020
|
+
if (args.level) params.set("level", args.level);
|
|
4021
|
+
if (args.search) params.set("search", args.search);
|
|
4022
|
+
return apiFetch(DEPLOY_URL6, token2, `/api/apps/${appId}/logs?${params}`);
|
|
4023
|
+
};
|
|
4024
|
+
const print = (events) => {
|
|
4025
|
+
for (const e of events) {
|
|
4026
|
+
process.stdout.write(args.json ? JSON.stringify(e) + "\n" : formatEvent(e, stdoutColor()) + "\n");
|
|
4027
|
+
}
|
|
4028
|
+
};
|
|
4029
|
+
const first = await fetchPage(initialSince, args.follow ? followLimit : limit, token);
|
|
4030
|
+
print(first.events);
|
|
4031
|
+
if (!args.follow) {
|
|
4032
|
+
if (first.events.length === 0 && !args.json) {
|
|
4033
|
+
console.log(
|
|
4034
|
+
`No logs in the last ${windowLabel} for ${appId}. New logs can take up to a minute to appear; retention is 7 days.`
|
|
4035
|
+
);
|
|
4036
|
+
} else if (first.truncated) {
|
|
4037
|
+
if (args.json) process.stdout.write(JSON.stringify({ type: "meta", truncated: true }) + "\n");
|
|
4038
|
+
else console.error(`(showing the newest ${first.events.length} events \u2014 narrow with --since/--level/--search)`);
|
|
4039
|
+
}
|
|
4040
|
+
return;
|
|
4041
|
+
}
|
|
4042
|
+
process.on("SIGINT", () => process.exit(0));
|
|
4043
|
+
if (!args.json) {
|
|
4044
|
+
console.error(`Tailing logs for ${appId} \u2014 Ctrl+C to stop.`);
|
|
4045
|
+
}
|
|
4046
|
+
const seen = new SeenEvents();
|
|
4047
|
+
seen.fresh(first.events);
|
|
4048
|
+
let cursor = first.cursor ?? initialSince;
|
|
4049
|
+
let interval = Math.max(first.pollIntervalMs || 0, MIN_POLL_MS);
|
|
4050
|
+
let backoff = 0;
|
|
4051
|
+
let warnedTruncated = false;
|
|
4052
|
+
if (first.truncated) {
|
|
4053
|
+
warnedTruncated = true;
|
|
4054
|
+
if (args.json) {
|
|
4055
|
+
process.stdout.write(JSON.stringify({ type: "meta", truncated: true }) + "\n");
|
|
4056
|
+
} else {
|
|
4057
|
+
console.error(
|
|
4058
|
+
paint("33", `(more than ${followLimit} events in the initial ${windowLabel} window \u2014 some older events not shown; narrow with --since/--level/--search)`, stderrColor())
|
|
4059
|
+
);
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
for (; ; ) {
|
|
4063
|
+
await sleep2(backoff || interval);
|
|
4064
|
+
const freshToken = await ensureToken();
|
|
4065
|
+
let page;
|
|
4066
|
+
try {
|
|
4067
|
+
page = await fetchPage(nextPollSince(cursor, initialSince), followLimit, freshToken);
|
|
4068
|
+
} catch (err) {
|
|
4069
|
+
if (err instanceof ApiError && [401, 403, 404].includes(err.status)) throw err;
|
|
4070
|
+
backoff = Math.min(backoff ? backoff * 2 : MIN_POLL_MS, 3e4);
|
|
4071
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
4072
|
+
console.error(paint("2", `(logs fetch failed: ${msg} \u2014 retrying in ${backoff / 1e3}s)`, stderrColor()));
|
|
4073
|
+
continue;
|
|
4074
|
+
}
|
|
4075
|
+
backoff = 0;
|
|
4076
|
+
interval = Math.max(page.pollIntervalMs || 0, MIN_POLL_MS);
|
|
4077
|
+
const fresh = seen.fresh(page.events);
|
|
4078
|
+
print(fresh);
|
|
4079
|
+
const realDrop = fresh.length >= followLimit;
|
|
4080
|
+
if (realDrop && !warnedTruncated) {
|
|
4081
|
+
warnedTruncated = true;
|
|
4082
|
+
if (args.json) {
|
|
4083
|
+
process.stdout.write(JSON.stringify({ type: "meta", truncated: true }) + "\n");
|
|
4084
|
+
} else {
|
|
4085
|
+
console.error(
|
|
4086
|
+
paint("33", `(burst exceeded ${followLimit} events/poll \u2014 some may be dropped; narrow with --level/--search)`, stderrColor())
|
|
4087
|
+
);
|
|
4088
|
+
}
|
|
4089
|
+
} else if (!realDrop) {
|
|
4090
|
+
warnedTruncated = false;
|
|
4091
|
+
}
|
|
4092
|
+
if (page.cursor !== null) cursor = page.cursor;
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
});
|
|
4096
|
+
|
|
4097
|
+
// src/cli/commands/usage.ts
|
|
4098
|
+
import { defineCommand as defineCommand13 } from "citty";
|
|
3827
4099
|
var API_URL3 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
3828
4100
|
function formatCredits(value) {
|
|
3829
4101
|
if (value > 0 && value < 1) return "<1";
|
|
@@ -3879,7 +4151,7 @@ function renderSummary(summary) {
|
|
|
3879
4151
|
lines.push(`Dashboard: ${DASHBOARD_URL}`);
|
|
3880
4152
|
return lines.join("\n");
|
|
3881
4153
|
}
|
|
3882
|
-
var usage_default =
|
|
4154
|
+
var usage_default = defineCommand13({
|
|
3883
4155
|
meta: {
|
|
3884
4156
|
name: "usage",
|
|
3885
4157
|
description: "Show credit balance, quota headroom, and per-integration spend"
|
|
@@ -3903,7 +4175,7 @@ var usage_default = defineCommand12({
|
|
|
3903
4175
|
});
|
|
3904
4176
|
|
|
3905
4177
|
// src/cli/commands/add.ts
|
|
3906
|
-
import { defineCommand as
|
|
4178
|
+
import { defineCommand as defineCommand14 } from "citty";
|
|
3907
4179
|
import { existsSync as existsSync12, readFileSync as readFileSync12 } from "fs";
|
|
3908
4180
|
import { resolve as resolve8, join as join13, dirname as dirname3 } from "path";
|
|
3909
4181
|
import { fileURLToPath } from "url";
|
|
@@ -3939,7 +4211,7 @@ function runInstaller(script, passArgs, cwd) {
|
|
|
3939
4211
|
}
|
|
3940
4212
|
process.exit(res.status ?? 1);
|
|
3941
4213
|
}
|
|
3942
|
-
var add_default =
|
|
4214
|
+
var add_default = defineCommand14({
|
|
3943
4215
|
meta: {
|
|
3944
4216
|
name: "add",
|
|
3945
4217
|
description: "Add a feature to your DeepSpace app"
|
|
@@ -4012,7 +4284,7 @@ var add_default = defineCommand13({
|
|
|
4012
4284
|
});
|
|
4013
4285
|
|
|
4014
4286
|
// src/cli/commands/domain.ts
|
|
4015
|
-
import { defineCommand as
|
|
4287
|
+
import { defineCommand as defineCommand15 } from "citty";
|
|
4016
4288
|
var API_URL4 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4017
4289
|
var api = (token, path, init) => apiFetch(API_URL4, token, path, init);
|
|
4018
4290
|
function scrubInternal(value) {
|
|
@@ -4048,7 +4320,7 @@ async function confirm3(message) {
|
|
|
4048
4320
|
});
|
|
4049
4321
|
});
|
|
4050
4322
|
}
|
|
4051
|
-
var search =
|
|
4323
|
+
var search = defineCommand15({
|
|
4052
4324
|
meta: { name: "search", description: "Search for available domains" },
|
|
4053
4325
|
args: {
|
|
4054
4326
|
query: { type: "positional", description: "Domain or keyword", required: true },
|
|
@@ -4078,7 +4350,7 @@ var search = defineCommand14({
|
|
|
4078
4350
|
}
|
|
4079
4351
|
}
|
|
4080
4352
|
});
|
|
4081
|
-
var buy =
|
|
4353
|
+
var buy = defineCommand15({
|
|
4082
4354
|
meta: { name: "buy", description: "Buy a domain and attach it to an app" },
|
|
4083
4355
|
args: {
|
|
4084
4356
|
domain: { type: "positional", description: "Domain to buy", required: true },
|
|
@@ -4188,7 +4460,7 @@ var buy = defineCommand14({
|
|
|
4188
4460
|
process.exit(1);
|
|
4189
4461
|
}
|
|
4190
4462
|
});
|
|
4191
|
-
var list2 =
|
|
4463
|
+
var list2 = defineCommand15({
|
|
4192
4464
|
meta: { name: "list", description: "List your domains" },
|
|
4193
4465
|
args: {
|
|
4194
4466
|
json: { type: "boolean", description: "Emit JSON" }
|
|
@@ -4214,7 +4486,7 @@ var list2 = defineCommand14({
|
|
|
4214
4486
|
}
|
|
4215
4487
|
}
|
|
4216
4488
|
});
|
|
4217
|
-
var status =
|
|
4489
|
+
var status = defineCommand15({
|
|
4218
4490
|
meta: { name: "status", description: "Show details for one domain" },
|
|
4219
4491
|
args: {
|
|
4220
4492
|
domain: { type: "positional", description: "Domain", required: true },
|
|
@@ -4244,7 +4516,7 @@ var status = defineCommand14({
|
|
|
4244
4516
|
console.log(`Charged: ${fmtCents(found.chargedCents)}/yr`);
|
|
4245
4517
|
}
|
|
4246
4518
|
});
|
|
4247
|
-
var attach =
|
|
4519
|
+
var attach = defineCommand15({
|
|
4248
4520
|
meta: { name: "attach", description: "Re-point a domain at a different app" },
|
|
4249
4521
|
args: {
|
|
4250
4522
|
domain: { type: "positional", description: "Domain to re-point", required: true },
|
|
@@ -4275,7 +4547,7 @@ var attach = defineCommand14({
|
|
|
4275
4547
|
console.log(`\u2713 ${args.domain} now points at ${targetApp}`);
|
|
4276
4548
|
}
|
|
4277
4549
|
});
|
|
4278
|
-
var detach =
|
|
4550
|
+
var detach = defineCommand15({
|
|
4279
4551
|
meta: {
|
|
4280
4552
|
name: "detach",
|
|
4281
4553
|
description: "Stop routing the domain (keeps the registration; auto-renew unchanged)"
|
|
@@ -4307,7 +4579,7 @@ var detach = defineCommand14({
|
|
|
4307
4579
|
);
|
|
4308
4580
|
}
|
|
4309
4581
|
});
|
|
4310
|
-
var renew =
|
|
4582
|
+
var renew = defineCommand15({
|
|
4311
4583
|
meta: { name: "renew", description: "Toggle auto-renewal at the registrar" },
|
|
4312
4584
|
args: {
|
|
4313
4585
|
domain: { type: "positional", description: "Domain", required: true },
|
|
@@ -4333,13 +4605,13 @@ var renew = defineCommand14({
|
|
|
4333
4605
|
console.log(`\u2713 ${args.domain} auto-renew ${enabled ? "enabled" : "disabled"}`);
|
|
4334
4606
|
}
|
|
4335
4607
|
});
|
|
4336
|
-
var domain_default =
|
|
4608
|
+
var domain_default = defineCommand15({
|
|
4337
4609
|
meta: { name: "domain", description: "Buy and manage custom domains" },
|
|
4338
4610
|
subCommands: { search, buy, list: list2, status, attach, detach, renew }
|
|
4339
4611
|
});
|
|
4340
4612
|
|
|
4341
4613
|
// src/cli/commands/collaborators.ts
|
|
4342
|
-
import { defineCommand as
|
|
4614
|
+
import { defineCommand as defineCommand16 } from "citty";
|
|
4343
4615
|
|
|
4344
4616
|
// src/server/auth/testAccounts.ts
|
|
4345
4617
|
var TEST_ACCOUNT_EMAIL_SUFFIX = "@deepspace.test";
|
|
@@ -4349,11 +4621,11 @@ function isTestAccountEmail(email) {
|
|
|
4349
4621
|
|
|
4350
4622
|
// src/cli/commands/collaborators.ts
|
|
4351
4623
|
var API_URL5 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4352
|
-
var
|
|
4624
|
+
var DEPLOY_URL7 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
4353
4625
|
function api2(token, path, init) {
|
|
4354
4626
|
return apiFetch(API_URL5, token, path, init);
|
|
4355
4627
|
}
|
|
4356
|
-
var list3 =
|
|
4628
|
+
var list3 = defineCommand16({
|
|
4357
4629
|
meta: { name: "list", description: "List collaborators on your app" },
|
|
4358
4630
|
args: {
|
|
4359
4631
|
app: { type: "string", alias: "a", description: "App id or name (defaults to ./wrangler.toml)" },
|
|
@@ -4361,7 +4633,7 @@ var list3 = defineCommand15({
|
|
|
4361
4633
|
},
|
|
4362
4634
|
async run({ args }) {
|
|
4363
4635
|
const token = await ensureToken();
|
|
4364
|
-
const app = await resolveAppTarget(
|
|
4636
|
+
const app = await resolveAppTarget(DEPLOY_URL7, token, args.app);
|
|
4365
4637
|
const { collaborators, pending = [] } = await api2(token, `/api/app-collaborators/${encodeURIComponent(app)}`);
|
|
4366
4638
|
if (args.json) {
|
|
4367
4639
|
process.stdout.write(JSON.stringify({ collaborators, pending }, null, 2) + "\n");
|
|
@@ -4385,7 +4657,7 @@ var list3 = defineCommand15({
|
|
|
4385
4657
|
}
|
|
4386
4658
|
}
|
|
4387
4659
|
});
|
|
4388
|
-
var add =
|
|
4660
|
+
var add = defineCommand16({
|
|
4389
4661
|
meta: { name: "add", description: "Authorize someone to deploy your app" },
|
|
4390
4662
|
args: {
|
|
4391
4663
|
email: {
|
|
@@ -4398,7 +4670,7 @@ var add = defineCommand15({
|
|
|
4398
4670
|
},
|
|
4399
4671
|
async run({ args }) {
|
|
4400
4672
|
const token = await ensureToken();
|
|
4401
|
-
const app = await resolveAppTarget(
|
|
4673
|
+
const app = await resolveAppTarget(DEPLOY_URL7, token, args.app);
|
|
4402
4674
|
if (isTestAccountEmail(args.email)) {
|
|
4403
4675
|
console.error(
|
|
4404
4676
|
"Test accounts (@deepspace.test) cannot be added as collaborators. Use a real DeepSpace account."
|
|
@@ -4430,7 +4702,7 @@ var add = defineCommand15({
|
|
|
4430
4702
|
console.log(`\u2713 ${res.collaborator.emailDisplay} can now deploy ${app}`);
|
|
4431
4703
|
}
|
|
4432
4704
|
});
|
|
4433
|
-
var remove =
|
|
4705
|
+
var remove = defineCommand16({
|
|
4434
4706
|
meta: { name: "remove", description: "Remove a collaborator from your app" },
|
|
4435
4707
|
args: {
|
|
4436
4708
|
email: { type: "positional", description: "Collaborator email", required: true },
|
|
@@ -4439,7 +4711,7 @@ var remove = defineCommand15({
|
|
|
4439
4711
|
},
|
|
4440
4712
|
async run({ args }) {
|
|
4441
4713
|
const token = await ensureToken();
|
|
4442
|
-
const app = await resolveAppTarget(
|
|
4714
|
+
const app = await resolveAppTarget(DEPLOY_URL7, token, args.app);
|
|
4443
4715
|
const { collaborators } = await api2(
|
|
4444
4716
|
token,
|
|
4445
4717
|
`/api/app-collaborators/${encodeURIComponent(app)}`
|
|
@@ -4462,7 +4734,7 @@ var remove = defineCommand15({
|
|
|
4462
4734
|
console.log(`\u2713 ${found.emailDisplay} can no longer deploy ${app}`);
|
|
4463
4735
|
}
|
|
4464
4736
|
});
|
|
4465
|
-
var cancel4 =
|
|
4737
|
+
var cancel4 = defineCommand16({
|
|
4466
4738
|
meta: { name: "cancel", description: "Cancel a pending (un-accepted) email invite" },
|
|
4467
4739
|
args: {
|
|
4468
4740
|
email: { type: "positional", description: "Invited email", required: true },
|
|
@@ -4471,7 +4743,7 @@ var cancel4 = defineCommand15({
|
|
|
4471
4743
|
},
|
|
4472
4744
|
async run({ args }) {
|
|
4473
4745
|
const token = await ensureToken();
|
|
4474
|
-
const app = await resolveAppTarget(
|
|
4746
|
+
const app = await resolveAppTarget(DEPLOY_URL7, token, args.app);
|
|
4475
4747
|
const { pending = [] } = await api2(
|
|
4476
4748
|
token,
|
|
4477
4749
|
`/api/app-collaborators/${encodeURIComponent(app)}`
|
|
@@ -4494,17 +4766,17 @@ var cancel4 = defineCommand15({
|
|
|
4494
4766
|
console.log(`\u2713 Cancelled the pending invite to ${found.email} on ${app}`);
|
|
4495
4767
|
}
|
|
4496
4768
|
});
|
|
4497
|
-
var collaborators_default =
|
|
4769
|
+
var collaborators_default = defineCommand16({
|
|
4498
4770
|
meta: { name: "collaborators", description: "Manage who can deploy your app" },
|
|
4499
4771
|
subCommands: { list: list3, add, remove, cancel: cancel4 }
|
|
4500
4772
|
});
|
|
4501
4773
|
|
|
4502
4774
|
// src/cli/commands/transfer.ts
|
|
4503
|
-
import { defineCommand as
|
|
4775
|
+
import { defineCommand as defineCommand17 } from "citty";
|
|
4504
4776
|
import * as p6 from "@clack/prompts";
|
|
4505
4777
|
var API_URL6 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4506
|
-
var
|
|
4507
|
-
var offer =
|
|
4778
|
+
var DEPLOY_URL8 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
4779
|
+
var offer = defineCommand17({
|
|
4508
4780
|
meta: { name: "offer", description: "Offer this app to another DeepSpace user" },
|
|
4509
4781
|
args: {
|
|
4510
4782
|
email: { type: "positional", description: "Recipient email", required: true },
|
|
@@ -4516,7 +4788,7 @@ var offer = defineCommand16({
|
|
|
4516
4788
|
},
|
|
4517
4789
|
async run({ args }) {
|
|
4518
4790
|
const token = await ensureToken();
|
|
4519
|
-
const app = await resolveAppTarget(
|
|
4791
|
+
const app = await resolveAppTarget(DEPLOY_URL8, token, args.app);
|
|
4520
4792
|
const pending = await apiFetch(
|
|
4521
4793
|
API_URL6,
|
|
4522
4794
|
token,
|
|
@@ -4553,14 +4825,14 @@ var offer = defineCommand16({
|
|
|
4553
4825
|
);
|
|
4554
4826
|
}
|
|
4555
4827
|
});
|
|
4556
|
-
var status2 =
|
|
4828
|
+
var status2 = defineCommand17({
|
|
4557
4829
|
meta: { name: "status", description: "Show the pending transfer offer, if any" },
|
|
4558
4830
|
args: {
|
|
4559
4831
|
app: { type: "string", alias: "a", description: "App id or name (defaults to ./wrangler.toml)" }
|
|
4560
4832
|
},
|
|
4561
4833
|
async run({ args }) {
|
|
4562
4834
|
const token = await ensureToken();
|
|
4563
|
-
const app = await resolveAppTarget(
|
|
4835
|
+
const app = await resolveAppTarget(DEPLOY_URL8, token, args.app);
|
|
4564
4836
|
const { transfer } = await apiFetch(API_URL6, token, `/api/app-transfers/${encodeURIComponent(app)}`);
|
|
4565
4837
|
if (!transfer) {
|
|
4566
4838
|
console.log(`No pending transfer for ${app}.`);
|
|
@@ -4569,7 +4841,7 @@ var status2 = defineCommand16({
|
|
|
4569
4841
|
console.log(`Pending: ${app} \u2192 ${transfer.toEmailDisplay} (expires ${transfer.expiresAt}).`);
|
|
4570
4842
|
}
|
|
4571
4843
|
});
|
|
4572
|
-
var accept =
|
|
4844
|
+
var accept = defineCommand17({
|
|
4573
4845
|
meta: { name: "accept", description: "Accept a transfer offered to you" },
|
|
4574
4846
|
args: {
|
|
4575
4847
|
app: { type: "string", alias: "a", description: "App id of the offered app", required: true }
|
|
@@ -4577,7 +4849,7 @@ var accept = defineCommand16({
|
|
|
4577
4849
|
async run({ args }) {
|
|
4578
4850
|
const token = await ensureToken();
|
|
4579
4851
|
const app = requireAppIdArg(args.app);
|
|
4580
|
-
await apiFetch(
|
|
4852
|
+
await apiFetch(DEPLOY_URL8, token, `/api/apps/${encodeURIComponent(app)}/transfer/accept`, {
|
|
4581
4853
|
method: "POST"
|
|
4582
4854
|
});
|
|
4583
4855
|
console.log(
|
|
@@ -4585,25 +4857,25 @@ var accept = defineCommand16({
|
|
|
4585
4857
|
);
|
|
4586
4858
|
}
|
|
4587
4859
|
});
|
|
4588
|
-
var cancel5 =
|
|
4860
|
+
var cancel5 = defineCommand17({
|
|
4589
4861
|
meta: { name: "cancel", description: "Cancel/decline the pending offer (either party)" },
|
|
4590
4862
|
args: {
|
|
4591
4863
|
app: { type: "string", alias: "a", description: "App id or name (defaults to ./wrangler.toml)" }
|
|
4592
4864
|
},
|
|
4593
4865
|
async run({ args }) {
|
|
4594
4866
|
const token = await ensureToken();
|
|
4595
|
-
const app = await resolveAppTarget(
|
|
4867
|
+
const app = await resolveAppTarget(DEPLOY_URL8, token, args.app);
|
|
4596
4868
|
await apiFetch(API_URL6, token, `/api/app-transfers/${encodeURIComponent(app)}`, { method: "DELETE" });
|
|
4597
4869
|
console.log(`\u2713 Transfer offer for ${app} cancelled.`);
|
|
4598
4870
|
}
|
|
4599
4871
|
});
|
|
4600
|
-
var transfer_default =
|
|
4872
|
+
var transfer_default = defineCommand17({
|
|
4601
4873
|
meta: { name: "transfer", description: "Transfer app ownership to another user" },
|
|
4602
4874
|
subCommands: { offer, status: status2, accept, cancel: cancel5 }
|
|
4603
4875
|
});
|
|
4604
4876
|
|
|
4605
4877
|
// src/cli/commands/integrations.ts
|
|
4606
|
-
import { defineCommand as
|
|
4878
|
+
import { defineCommand as defineCommand18 } from "citty";
|
|
4607
4879
|
|
|
4608
4880
|
// src/cli/commands/_invoke-impl.ts
|
|
4609
4881
|
import { readFileSync as readFileSync13 } from "fs";
|
|
@@ -4825,7 +5097,7 @@ async function runInvoke(args) {
|
|
|
4825
5097
|
}
|
|
4826
5098
|
|
|
4827
5099
|
// src/cli/commands/integrations.ts
|
|
4828
|
-
var list4 =
|
|
5100
|
+
var list4 = defineCommand18({
|
|
4829
5101
|
meta: {
|
|
4830
5102
|
name: "list",
|
|
4831
5103
|
description: "List all available integrations"
|
|
@@ -4846,7 +5118,7 @@ var list4 = defineCommand17({
|
|
|
4846
5118
|
}
|
|
4847
5119
|
}
|
|
4848
5120
|
});
|
|
4849
|
-
var info =
|
|
5121
|
+
var info = defineCommand18({
|
|
4850
5122
|
meta: {
|
|
4851
5123
|
name: "info",
|
|
4852
5124
|
description: "Print schema + example body for an integration endpoint"
|
|
@@ -4872,7 +5144,7 @@ var info = defineCommand17({
|
|
|
4872
5144
|
}
|
|
4873
5145
|
}
|
|
4874
5146
|
});
|
|
4875
|
-
var invoke =
|
|
5147
|
+
var invoke = defineCommand18({
|
|
4876
5148
|
meta: {
|
|
4877
5149
|
name: "invoke",
|
|
4878
5150
|
description: "Invoke a platform integration as the logged-in user"
|
|
@@ -4932,7 +5204,7 @@ var invoke = defineCommand17({
|
|
|
4932
5204
|
}
|
|
4933
5205
|
}
|
|
4934
5206
|
});
|
|
4935
|
-
var integrations_default =
|
|
5207
|
+
var integrations_default = defineCommand18({
|
|
4936
5208
|
meta: {
|
|
4937
5209
|
name: "integrations",
|
|
4938
5210
|
description: "List, inspect, and invoke platform integrations"
|
|
@@ -4945,8 +5217,8 @@ var integrations_default = defineCommand17({
|
|
|
4945
5217
|
});
|
|
4946
5218
|
|
|
4947
5219
|
// src/cli/commands/invoke.ts
|
|
4948
|
-
import { defineCommand as
|
|
4949
|
-
var invoke_default =
|
|
5220
|
+
import { defineCommand as defineCommand19 } from "citty";
|
|
5221
|
+
var invoke_default = defineCommand19({
|
|
4950
5222
|
meta: {
|
|
4951
5223
|
name: "invoke",
|
|
4952
5224
|
description: "Invoke a platform integration as the logged-in user"
|
|
@@ -5026,13 +5298,13 @@ var invoke_default = defineCommand18({
|
|
|
5026
5298
|
});
|
|
5027
5299
|
|
|
5028
5300
|
// src/cli/commands/library.ts
|
|
5029
|
-
import { defineCommand as
|
|
5301
|
+
import { defineCommand as defineCommand20 } from "citty";
|
|
5030
5302
|
import { existsSync as existsSync13, readFileSync as readFileSync14 } from "fs";
|
|
5031
5303
|
import { join as join14, resolve as resolve9 } from "path";
|
|
5032
5304
|
import { parse as parseToml4 } from "smol-toml";
|
|
5033
5305
|
import * as p8 from "@clack/prompts";
|
|
5034
5306
|
var DEFAULT_LIBRARY_APP = "deepdotspace-site";
|
|
5035
|
-
var publish =
|
|
5307
|
+
var publish = defineCommand20({
|
|
5036
5308
|
meta: {
|
|
5037
5309
|
name: "publish",
|
|
5038
5310
|
description: "Publish the current app to the DeepSpace library"
|
|
@@ -5171,7 +5443,7 @@ var publish = defineCommand19({
|
|
|
5171
5443
|
p8.outro("Done");
|
|
5172
5444
|
}
|
|
5173
5445
|
});
|
|
5174
|
-
var unpublish =
|
|
5446
|
+
var unpublish = defineCommand20({
|
|
5175
5447
|
meta: {
|
|
5176
5448
|
name: "unpublish",
|
|
5177
5449
|
description: "Remove a library entry (owner or admin only)"
|
|
@@ -5230,7 +5502,7 @@ var unpublish = defineCommand19({
|
|
|
5230
5502
|
p8.outro("Done");
|
|
5231
5503
|
}
|
|
5232
5504
|
});
|
|
5233
|
-
var library_default =
|
|
5505
|
+
var library_default = defineCommand20({
|
|
5234
5506
|
meta: {
|
|
5235
5507
|
name: "library",
|
|
5236
5508
|
description: "Manage your DeepSpace library entries"
|
|
@@ -5242,7 +5514,7 @@ var library_default = defineCommand19({
|
|
|
5242
5514
|
});
|
|
5243
5515
|
|
|
5244
5516
|
// src/cli/commands/feedback.ts
|
|
5245
|
-
import { defineCommand as
|
|
5517
|
+
import { defineCommand as defineCommand21 } from "citty";
|
|
5246
5518
|
import * as p9 from "@clack/prompts";
|
|
5247
5519
|
import { existsSync as existsSync14, readFileSync as readFileSync15 } from "fs";
|
|
5248
5520
|
import { dirname as dirname4, join as join15 } from "path";
|
|
@@ -5320,7 +5592,7 @@ function buildFeedbackPayload(input) {
|
|
|
5320
5592
|
...input.context
|
|
5321
5593
|
};
|
|
5322
5594
|
}
|
|
5323
|
-
var feedback_default =
|
|
5595
|
+
var feedback_default = defineCommand21({
|
|
5324
5596
|
meta: {
|
|
5325
5597
|
name: "feedback",
|
|
5326
5598
|
description: "Submit a bug report, feature request, or feedback to DeepSpace"
|
|
@@ -5482,7 +5754,7 @@ Context: deepspace ${payload.cliVersion} \xB7 ${payload.nodeVersion} \xB7 ${payl
|
|
|
5482
5754
|
});
|
|
5483
5755
|
|
|
5484
5756
|
// src/cli/commands/secrets.ts
|
|
5485
|
-
import { defineCommand as
|
|
5757
|
+
import { defineCommand as defineCommand22 } from "citty";
|
|
5486
5758
|
import { readFileSync as readFileSync16 } from "fs";
|
|
5487
5759
|
|
|
5488
5760
|
// src/cli/lib/citty-args.ts
|
|
@@ -5494,7 +5766,7 @@ function dedupePositionals(bound, rest) {
|
|
|
5494
5766
|
}
|
|
5495
5767
|
|
|
5496
5768
|
// src/cli/commands/secrets.ts
|
|
5497
|
-
var
|
|
5769
|
+
var DEPLOY_URL9 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
5498
5770
|
var COMMON_ARGS = {
|
|
5499
5771
|
app: {
|
|
5500
5772
|
type: "string",
|
|
@@ -5552,7 +5824,7 @@ function warnIfDebugRoutesEnabled(secrets) {
|
|
|
5552
5824
|
}
|
|
5553
5825
|
var APPLY_HINT = "Run `deepspace deploy` to apply \u2014 secrets take effect at deploy time.";
|
|
5554
5826
|
var LOCAL_DEV_HINT = "Running `deepspace dev`? Restart it to load the change locally.";
|
|
5555
|
-
var list5 =
|
|
5827
|
+
var list5 = defineCommand22({
|
|
5556
5828
|
meta: { name: "list", description: "List masked secrets in a config" },
|
|
5557
5829
|
args: {
|
|
5558
5830
|
...COMMON_ARGS,
|
|
@@ -5566,7 +5838,7 @@ var list5 = defineCommand21({
|
|
|
5566
5838
|
async run({ args }) {
|
|
5567
5839
|
try {
|
|
5568
5840
|
const t = await resolveTarget(args);
|
|
5569
|
-
const { secrets } = await listSecrets(
|
|
5841
|
+
const { secrets } = await listSecrets(DEPLOY_URL9, t.token, t.appId, t.configName);
|
|
5570
5842
|
if (args.json) {
|
|
5571
5843
|
console.log(JSON.stringify({ appId: t.appId, config: t.configName, secrets }, null, 2));
|
|
5572
5844
|
return;
|
|
@@ -5583,7 +5855,7 @@ var list5 = defineCommand21({
|
|
|
5583
5855
|
}
|
|
5584
5856
|
}
|
|
5585
5857
|
});
|
|
5586
|
-
var set =
|
|
5858
|
+
var set = defineCommand22({
|
|
5587
5859
|
meta: { name: "set", description: "Set secrets from KEY=value pairs" },
|
|
5588
5860
|
args: {
|
|
5589
5861
|
...COMMON_ARGS,
|
|
@@ -5611,9 +5883,9 @@ var set = defineCommand21({
|
|
|
5611
5883
|
}
|
|
5612
5884
|
if (Object.keys(secrets).length === 1) {
|
|
5613
5885
|
const [[k, v]] = Object.entries(secrets);
|
|
5614
|
-
await setSecret(
|
|
5886
|
+
await setSecret(DEPLOY_URL9, t.token, t.appId, t.configName, k, v);
|
|
5615
5887
|
} else {
|
|
5616
|
-
await uploadSecrets(
|
|
5888
|
+
await uploadSecrets(DEPLOY_URL9, t.token, t.appId, t.configName, secrets, false);
|
|
5617
5889
|
}
|
|
5618
5890
|
console.log(`Set ${Object.keys(secrets).length} secret${Object.keys(secrets).length === 1 ? "" : "s"} in ${t.configName}.`);
|
|
5619
5891
|
if (!warnIfDebugRoutesEnabled(secrets)) {
|
|
@@ -5625,7 +5897,7 @@ var set = defineCommand21({
|
|
|
5625
5897
|
}
|
|
5626
5898
|
}
|
|
5627
5899
|
});
|
|
5628
|
-
var get =
|
|
5900
|
+
var get = defineCommand22({
|
|
5629
5901
|
meta: { name: "get", description: "Get a secret; pass --plain to print the value" },
|
|
5630
5902
|
args: {
|
|
5631
5903
|
...COMMON_ARGS,
|
|
@@ -5637,11 +5909,11 @@ var get = defineCommand21({
|
|
|
5637
5909
|
const t = await resolveTarget(args);
|
|
5638
5910
|
const key = validateSecretName(args.key);
|
|
5639
5911
|
if (args.plain) {
|
|
5640
|
-
const { value } = await getSecretPlain(
|
|
5912
|
+
const { value } = await getSecretPlain(DEPLOY_URL9, t.token, t.appId, t.configName, key);
|
|
5641
5913
|
process.stdout.write(process.stdout.isTTY ? value + "\n" : value);
|
|
5642
5914
|
return;
|
|
5643
5915
|
}
|
|
5644
|
-
const { secrets } = await listSecrets(
|
|
5916
|
+
const { secrets } = await listSecrets(DEPLOY_URL9, t.token, t.appId, t.configName);
|
|
5645
5917
|
const item = secrets.find((s) => s.key === key);
|
|
5646
5918
|
if (!item) fail(new Error(`Secret "${key}" not found in ${t.configName}`));
|
|
5647
5919
|
console.log(`${item.key} (v${item.version}, ${item.updatedAt})`);
|
|
@@ -5650,7 +5922,7 @@ var get = defineCommand21({
|
|
|
5650
5922
|
}
|
|
5651
5923
|
}
|
|
5652
5924
|
});
|
|
5653
|
-
var del2 =
|
|
5925
|
+
var del2 = defineCommand22({
|
|
5654
5926
|
meta: { name: "delete", description: "Delete one or more secrets" },
|
|
5655
5927
|
args: {
|
|
5656
5928
|
...COMMON_ARGS,
|
|
@@ -5665,7 +5937,7 @@ var del2 = defineCommand21({
|
|
|
5665
5937
|
for (const key of keys) {
|
|
5666
5938
|
const name = validateSecretName(key);
|
|
5667
5939
|
try {
|
|
5668
|
-
await deleteSecret(
|
|
5940
|
+
await deleteSecret(DEPLOY_URL9, t.token, t.appId, t.configName, name);
|
|
5669
5941
|
deleted++;
|
|
5670
5942
|
} catch (err) {
|
|
5671
5943
|
if (err?.status === 404) absent++;
|
|
@@ -5680,7 +5952,7 @@ var del2 = defineCommand21({
|
|
|
5680
5952
|
}
|
|
5681
5953
|
}
|
|
5682
5954
|
});
|
|
5683
|
-
var upload =
|
|
5955
|
+
var upload = defineCommand22({
|
|
5684
5956
|
meta: { name: "upload", description: "Upload secrets from a dotenv or JSON file" },
|
|
5685
5957
|
args: {
|
|
5686
5958
|
...COMMON_ARGS,
|
|
@@ -5697,7 +5969,7 @@ var upload = defineCommand21({
|
|
|
5697
5969
|
const content = args.file === "-" ? readFileSync16(0, "utf-8") : readFileSync16(args.file, "utf-8");
|
|
5698
5970
|
const secrets = parseSecretsUpload(content);
|
|
5699
5971
|
if (Object.keys(secrets).length === 0) fail(new Error("No secrets found in the input."));
|
|
5700
|
-
await uploadSecrets(
|
|
5972
|
+
await uploadSecrets(DEPLOY_URL9, t.token, t.appId, t.configName, secrets, args.replace);
|
|
5701
5973
|
console.log(`Uploaded ${Object.keys(secrets).length} secrets to ${t.configName}.`);
|
|
5702
5974
|
if (!warnIfDebugRoutesEnabled(secrets)) console.log(APPLY_HINT);
|
|
5703
5975
|
} catch (err) {
|
|
@@ -5705,7 +5977,7 @@ var upload = defineCommand21({
|
|
|
5705
5977
|
}
|
|
5706
5978
|
}
|
|
5707
5979
|
});
|
|
5708
|
-
var download =
|
|
5980
|
+
var download = defineCommand22({
|
|
5709
5981
|
meta: { name: "download", description: "Download a config\u2019s secrets (dotenv/json/shell)" },
|
|
5710
5982
|
args: {
|
|
5711
5983
|
...COMMON_ARGS,
|
|
@@ -5722,14 +5994,14 @@ var download = defineCommand21({
|
|
|
5722
5994
|
if (!["dotenv", "json", "shell"].includes(format)) {
|
|
5723
5995
|
fail(new Error(`Unknown format "${args.format}" \u2014 use dotenv, json, or shell.`));
|
|
5724
5996
|
}
|
|
5725
|
-
const { secrets } = await fetchSecretsValues(
|
|
5997
|
+
const { secrets } = await fetchSecretsValues(DEPLOY_URL9, t.token, t.appId, t.configName);
|
|
5726
5998
|
process.stdout.write(formatSecretsDownload(secrets, format));
|
|
5727
5999
|
} catch (err) {
|
|
5728
6000
|
fail(err);
|
|
5729
6001
|
}
|
|
5730
6002
|
}
|
|
5731
6003
|
});
|
|
5732
|
-
var pull =
|
|
6004
|
+
var pull = defineCommand22({
|
|
5733
6005
|
meta: { name: "pull", description: "Refresh the .dev.vars cache from the app store" },
|
|
5734
6006
|
args: { ...COMMON_ARGS },
|
|
5735
6007
|
async run({ args }) {
|
|
@@ -5739,7 +6011,7 @@ var pull = defineCommand21({
|
|
|
5739
6011
|
if (!appDir) fail(new Error("Run from a DeepSpace app directory (one containing wrangler.toml)."));
|
|
5740
6012
|
const t = await resolveTarget(args);
|
|
5741
6013
|
const ownerId = decodeJwtPayload(t.token).sub;
|
|
5742
|
-
const pulled = await pullAppSecretsCache(
|
|
6014
|
+
const pulled = await pullAppSecretsCache(DEPLOY_URL9, t.token, t.appId, t.configName);
|
|
5743
6015
|
if (!pulled) {
|
|
5744
6016
|
console.log(`No secrets in ${t.configName} yet \u2014 nothing to pull.`);
|
|
5745
6017
|
return;
|
|
@@ -5757,13 +6029,13 @@ var pull = defineCommand21({
|
|
|
5757
6029
|
}
|
|
5758
6030
|
}
|
|
5759
6031
|
});
|
|
5760
|
-
var configsList =
|
|
6032
|
+
var configsList = defineCommand22({
|
|
5761
6033
|
meta: { name: "list", description: "List the app\u2019s configs" },
|
|
5762
6034
|
args: { ...COMMON_ARGS },
|
|
5763
6035
|
async run({ args }) {
|
|
5764
6036
|
try {
|
|
5765
6037
|
const t = await resolveTarget(args);
|
|
5766
|
-
const { configs: configs2 } = await listConfigs(
|
|
6038
|
+
const { configs: configs2 } = await listConfigs(DEPLOY_URL9, t.token, t.appId);
|
|
5767
6039
|
if (configs2.length === 0) {
|
|
5768
6040
|
console.log("No configs yet \u2014 the first `secrets set` creates one.");
|
|
5769
6041
|
return;
|
|
@@ -5776,7 +6048,7 @@ var configsList = defineCommand21({
|
|
|
5776
6048
|
}
|
|
5777
6049
|
}
|
|
5778
6050
|
});
|
|
5779
|
-
var configsCreate =
|
|
6051
|
+
var configsCreate = defineCommand22({
|
|
5780
6052
|
meta: { name: "create", description: "Create a config (optionally copying another)" },
|
|
5781
6053
|
args: {
|
|
5782
6054
|
...COMMON_ARGS,
|
|
@@ -5788,7 +6060,7 @@ var configsCreate = defineCommand21({
|
|
|
5788
6060
|
const t = await resolveTarget(args);
|
|
5789
6061
|
const name = validateConfigName(args.name);
|
|
5790
6062
|
const copyFrom = args["copy-from"] || void 0;
|
|
5791
|
-
const { configs: configs2 } = await listConfigs(
|
|
6063
|
+
const { configs: configs2 } = await listConfigs(DEPLOY_URL9, t.token, t.appId);
|
|
5792
6064
|
if (configs2.some((c) => c.name === name)) {
|
|
5793
6065
|
if (copyFrom) {
|
|
5794
6066
|
fail(
|
|
@@ -5800,14 +6072,14 @@ var configsCreate = defineCommand21({
|
|
|
5800
6072
|
console.log(`Config ${name} already exists.`);
|
|
5801
6073
|
return;
|
|
5802
6074
|
}
|
|
5803
|
-
await createConfig(
|
|
6075
|
+
await createConfig(DEPLOY_URL9, t.token, t.appId, name, copyFrom);
|
|
5804
6076
|
console.log(`Created ${name}.`);
|
|
5805
6077
|
} catch (err) {
|
|
5806
6078
|
fail(err);
|
|
5807
6079
|
}
|
|
5808
6080
|
}
|
|
5809
6081
|
});
|
|
5810
|
-
var configsDelete =
|
|
6082
|
+
var configsDelete = defineCommand22({
|
|
5811
6083
|
meta: { name: "delete", description: "Delete a config and all of its secrets" },
|
|
5812
6084
|
args: {
|
|
5813
6085
|
...COMMON_ARGS,
|
|
@@ -5817,18 +6089,18 @@ var configsDelete = defineCommand21({
|
|
|
5817
6089
|
try {
|
|
5818
6090
|
const t = await resolveTarget(args);
|
|
5819
6091
|
const name = validateConfigName(args.name);
|
|
5820
|
-
await deleteConfig(
|
|
6092
|
+
await deleteConfig(DEPLOY_URL9, t.token, t.appId, name);
|
|
5821
6093
|
console.log(`Deleted ${name}.`);
|
|
5822
6094
|
} catch (err) {
|
|
5823
6095
|
fail(err);
|
|
5824
6096
|
}
|
|
5825
6097
|
}
|
|
5826
6098
|
});
|
|
5827
|
-
var configs =
|
|
6099
|
+
var configs = defineCommand22({
|
|
5828
6100
|
meta: { name: "configs", description: "Manage the app\u2019s secrets configs" },
|
|
5829
6101
|
subCommands: { list: configsList, create: configsCreate, delete: configsDelete }
|
|
5830
6102
|
});
|
|
5831
|
-
var secrets_default =
|
|
6103
|
+
var secrets_default = defineCommand22({
|
|
5832
6104
|
meta: { name: "secrets", description: "Manage the app\u2019s secrets store" },
|
|
5833
6105
|
subCommands: {
|
|
5834
6106
|
list: list5,
|
|
@@ -5843,8 +6115,8 @@ var secrets_default = defineCommand21({
|
|
|
5843
6115
|
});
|
|
5844
6116
|
|
|
5845
6117
|
// src/cli/commands/init.ts
|
|
5846
|
-
import { defineCommand as
|
|
5847
|
-
var init_default =
|
|
6118
|
+
import { defineCommand as defineCommand23 } from "citty";
|
|
6119
|
+
var init_default = defineCommand23({
|
|
5848
6120
|
meta: {
|
|
5849
6121
|
name: "init",
|
|
5850
6122
|
description: "Mint this app\u2019s immutable DEEPSPACE_APP_ID into wrangler.toml"
|
|
@@ -5894,7 +6166,7 @@ var pkg = JSON.parse(readFileSync17(join16(__dirname, "..", "package.json"), "ut
|
|
|
5894
6166
|
if (process.platform === "linux" && !process.env.SSL_CERT_FILE && existsSync15("/etc/ssl/certs/ca-certificates.crt")) {
|
|
5895
6167
|
process.env.SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt";
|
|
5896
6168
|
}
|
|
5897
|
-
var create2 =
|
|
6169
|
+
var create2 = defineCommand24({
|
|
5898
6170
|
meta: {
|
|
5899
6171
|
name: "create",
|
|
5900
6172
|
description: "Create a new DeepSpace app (runs create-deepspace; all flags are forwarded)"
|
|
@@ -5921,7 +6193,7 @@ var create2 = defineCommand23({
|
|
|
5921
6193
|
process.exit(res.status ?? 1);
|
|
5922
6194
|
}
|
|
5923
6195
|
});
|
|
5924
|
-
var main =
|
|
6196
|
+
var main = defineCommand24({
|
|
5925
6197
|
meta: {
|
|
5926
6198
|
name: "deepspace",
|
|
5927
6199
|
version: pkg.version,
|
|
@@ -5934,6 +6206,7 @@ var main = defineCommand23({
|
|
|
5934
6206
|
logout: logout_default,
|
|
5935
6207
|
whoami: whoami_default,
|
|
5936
6208
|
apps: apps_default,
|
|
6209
|
+
logs: logs_default,
|
|
5937
6210
|
usage: usage_default,
|
|
5938
6211
|
dev: dev_default,
|
|
5939
6212
|
kill: kill_default,
|