runcloud 0.2.227 → 0.2.228
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/commands/sandbox.js +32 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/runcloud-0.2.228.tgz +0 -0
- package/runcloud-0.2.227.tgz +0 -0
package/dist/commands/sandbox.js
CHANGED
|
@@ -238,6 +238,28 @@ function metricSparkline(values) {
|
|
|
238
238
|
.map((value) => blocks[Math.min(blocks.length - 1, Math.floor((Math.max(0, value) / max) * (blocks.length - 1)))])
|
|
239
239
|
.join('');
|
|
240
240
|
}
|
|
241
|
+
const COST_METER_LABELS = {
|
|
242
|
+
cpu: 'CPU',
|
|
243
|
+
cpu_burst: 'CPU (burst)',
|
|
244
|
+
memory: 'Memory',
|
|
245
|
+
};
|
|
246
|
+
const COST_UNIT_LABELS = { vcpu_second: 'vCPU-s', gib_second: 'GiB-s' };
|
|
247
|
+
export function renderSandboxCost(cost) {
|
|
248
|
+
const nanoUsd = (nanodollars) => {
|
|
249
|
+
const value = BigInt(nanodollars);
|
|
250
|
+
const fraction = (value % 1000000000n).toString().padStart(9, '0').replace(/0+$/, '');
|
|
251
|
+
return `$${value / 1000000000n}${fraction ? `.${fraction}` : ''}`;
|
|
252
|
+
};
|
|
253
|
+
const lines = cost.lines.map((line) => ` ${(COST_METER_LABELS[line.meter] ?? line.meter).padEnd(12)} ${nanoUsd(line.nanodollars).padStart(12)} ${line.quantity} ${COST_UNIT_LABELS[line.unit] ?? line.unit}`);
|
|
254
|
+
const state = cost.status === 'final'
|
|
255
|
+
? `final${cost.availableUntil ? ` · kept until ${cost.availableUntil}` : ''}`
|
|
256
|
+
: 'accruing (still running or being metered)';
|
|
257
|
+
return [
|
|
258
|
+
`Sandbox cost · ${cost.sandboxId} · ${state}`,
|
|
259
|
+
...lines,
|
|
260
|
+
` ${'Total'.padEnd(12)} ${nanoUsd(cost.totalNanodollars).padStart(12)}`,
|
|
261
|
+
].join('\n');
|
|
262
|
+
}
|
|
241
263
|
export function renderSandboxMetrics(id, metrics) {
|
|
242
264
|
const point = metrics.current;
|
|
243
265
|
if (!point)
|
|
@@ -523,6 +545,16 @@ export function registerSandbox(program) {
|
|
|
523
545
|
await new Promise((resolveDelay) => setTimeout(resolveDelay, opts.interval * 1_000));
|
|
524
546
|
}
|
|
525
547
|
}));
|
|
548
|
+
withOutput(sandbox
|
|
549
|
+
.command('cost')
|
|
550
|
+
.description('Show what a sandbox has been billed, per meter (kept 30 days after it ends)')
|
|
551
|
+
.argument('<id>', 'sandbox id')).action((id, opts) => run(async () => {
|
|
552
|
+
const cost = (await runCloudApi().get(`/run-cloud/sandboxes/${encodeURIComponent(id)}/cost`));
|
|
553
|
+
if (opts.json)
|
|
554
|
+
printJson(cost);
|
|
555
|
+
else
|
|
556
|
+
console.log(renderSandboxCost(cost));
|
|
557
|
+
}));
|
|
526
558
|
const secrets = withOutput(sandbox
|
|
527
559
|
.command('secrets')
|
|
528
560
|
.description('Show what secrets a sandbox holds (names and origins, never values)')
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.2.
|
|
1
|
+
export const CLI_VERSION = '0.2.228';
|
package/package.json
CHANGED
|
Binary file
|
package/runcloud-0.2.227.tgz
DELETED
|
Binary file
|