@sandblocks/cli 0.3.0 → 0.4.0-b.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.js +37 -11
- package/dist/cli.js.map +7 -7
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -11117,7 +11117,7 @@ var EnvironmentValueSchema = exports_external.object({
|
|
|
11117
11117
|
routing: exports_external.object({
|
|
11118
11118
|
baseDomain: exports_external.string().min(1).max(253).default("sandblocks.dev"),
|
|
11119
11119
|
domains: exports_external.record(id, exports_external.string().min(1).max(253)).default({}),
|
|
11120
|
-
stableDomains: exports_external.record(id, exports_external.string().min(1).max(253)).default({}),
|
|
11120
|
+
stableDomains: exports_external.record(id, exports_external.union([exports_external.string().min(1).max(253), exports_external.array(exports_external.string().min(1).max(253)).min(1)])).default({}),
|
|
11121
11121
|
sso: exports_external.boolean().optional()
|
|
11122
11122
|
}).strict().default({})
|
|
11123
11123
|
}).strict();
|
|
@@ -11153,17 +11153,19 @@ function validateReferences(manifest, ctx) {
|
|
|
11153
11153
|
validateReferencesTo(ctx, environment.checks, checkIds, ["environments", index, "checks"], "check");
|
|
11154
11154
|
validateReferencesTo(ctx, Object.keys(environment.routing.domains), new Set(environment.services), ["environments", index, "routing", "domains"], "environment service");
|
|
11155
11155
|
validateReferencesTo(ctx, Object.keys(environment.routing.stableDomains), new Set(environment.services), ["environments", index, "routing", "stableDomains"], "environment service");
|
|
11156
|
-
for (const [service,
|
|
11156
|
+
for (const [service, configured] of Object.entries({
|
|
11157
11157
|
...environment.routing.domains,
|
|
11158
11158
|
...environment.routing.stableDomains
|
|
11159
11159
|
})) {
|
|
11160
|
-
const
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11160
|
+
for (const template of Array.isArray(configured) ? configured : [configured]) {
|
|
11161
|
+
const expanded = template.replaceAll(/\{(?:sandbox|revision|service)\}/g, "preview");
|
|
11162
|
+
if (expanded.includes("{") || !/^[a-z0-9.-]+$/.test(expanded.toLowerCase())) {
|
|
11163
|
+
ctx.addIssue({
|
|
11164
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11165
|
+
path: ["environments", index, "routing", "domains", service],
|
|
11166
|
+
message: "domain template may use only {sandbox}, {revision}, and {service}"
|
|
11167
|
+
});
|
|
11168
|
+
}
|
|
11167
11169
|
}
|
|
11168
11170
|
}
|
|
11169
11171
|
}
|
|
@@ -12338,7 +12340,8 @@ function expectedPreviewServiceUrls(sandboxId, deploymentId, stack, preview) {
|
|
|
12338
12340
|
return [];
|
|
12339
12341
|
const name = service.id.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
12340
12342
|
const host = resolvedServiceDomain(sandboxId, deploymentId, service.id, preview);
|
|
12341
|
-
const
|
|
12343
|
+
const configuredStableHosts = preview.stableDomains[service.id];
|
|
12344
|
+
const stableHost = (Array.isArray(configuredStableHosts) ? configuredStableHosts[0] : configuredStableHosts) ?? `${preview.deploymentType}-${stack}-${service.id}.${preview.baseDomain}`;
|
|
12342
12345
|
return [
|
|
12343
12346
|
[`SANDBLOCKS_SERVICE_${name}_URL`, `https://${host}`],
|
|
12344
12347
|
[`SANDBLOCKS_STABLE_SERVICE_${name}_URL`, `https://${stableHost}`]
|
|
@@ -14333,6 +14336,7 @@ var HELP = `Sandblocks CLI
|
|
|
14333
14336
|
sandblocks sandbox deploy [directory] [--environment <id>]
|
|
14334
14337
|
sandblocks sandbox redeploy [directory] [--environment <id>]
|
|
14335
14338
|
sandblocks sandbox status [directory] [--environment <id>] [--json]
|
|
14339
|
+
sandblocks sandbox promote --project <id> --sandbox <id> [--json]
|
|
14336
14340
|
sandblocks sandbox renew [directory] [--environment <id>] [--ttl-seconds <n>]
|
|
14337
14341
|
sandblocks sandbox exec [directory] [--environment <id>] -- <typed-command>
|
|
14338
14342
|
sandblocks sandbox git [directory] [--environment <id>] <status|diff|stage|checkout>
|
|
@@ -14518,6 +14522,8 @@ async function sandbox(args) {
|
|
|
14518
14522
|
}
|
|
14519
14523
|
if (subcommand === "deploy")
|
|
14520
14524
|
return sandboxDeploy(rest);
|
|
14525
|
+
if (subcommand === "promote")
|
|
14526
|
+
return sandboxPromote(rest);
|
|
14521
14527
|
if (subcommand !== "import")
|
|
14522
14528
|
throw new Error("unsupported sandbox command");
|
|
14523
14529
|
const options = parse(rest);
|
|
@@ -14562,6 +14568,26 @@ async function sandbox(args) {
|
|
|
14562
14568
|
console.log(`container ${operation.result.container}`);
|
|
14563
14569
|
}
|
|
14564
14570
|
}
|
|
14571
|
+
async function sandboxPromote(args) {
|
|
14572
|
+
const options = parse(args);
|
|
14573
|
+
const projectId = option(options, "project");
|
|
14574
|
+
const sandboxId = option(options, "sandbox");
|
|
14575
|
+
const apiUrl = (option(options, "api-url") ?? process.env.SANDBLOCKS_API_URL ?? "").replace(/\/$/, "");
|
|
14576
|
+
const apiKey = option(options, "api-key") ?? process.env.SANDBLOCKS_API_KEY;
|
|
14577
|
+
if (!projectId)
|
|
14578
|
+
throw new Error("sandbox promote requires --project");
|
|
14579
|
+
if (!sandboxId)
|
|
14580
|
+
throw new Error("sandbox promote requires --sandbox");
|
|
14581
|
+
if (!apiUrl)
|
|
14582
|
+
throw new Error("sandbox promote requires --api-url or SANDBLOCKS_API_URL");
|
|
14583
|
+
if (!apiKey)
|
|
14584
|
+
throw new Error("sandbox promote requires --api-key or SANDBLOCKS_API_KEY");
|
|
14585
|
+
const result = await sandblocksRequest(apiUrl, apiKey, `/v1/projects/${encodeURIComponent(projectId)}/routing-aliases/promote`, { method: "POST", body: JSON.stringify({ sandboxId }) });
|
|
14586
|
+
if (options.json)
|
|
14587
|
+
console.log(JSON.stringify(result, null, 2));
|
|
14588
|
+
else
|
|
14589
|
+
console.log(`promoted ${sandboxId} to production`);
|
|
14590
|
+
}
|
|
14565
14591
|
var sourceFileCount = 0;
|
|
14566
14592
|
async function createSourceTar(root) {
|
|
14567
14593
|
const process2 = Bun.spawn(["git", "ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
@@ -14873,4 +14899,4 @@ export {
|
|
|
14873
14899
|
parse
|
|
14874
14900
|
};
|
|
14875
14901
|
|
|
14876
|
-
//# debugId=
|
|
14902
|
+
//# debugId=D1104053F8254F7864756E2164756E21
|