cubelife 0.2.0 → 0.2.1
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/agents.js
CHANGED
|
@@ -6,7 +6,7 @@ import { table } from '../ui/table.js';
|
|
|
6
6
|
import { panel } from '../ui/panel.js';
|
|
7
7
|
import { CREATURE_TYPES, ID_DISPLAY_LENGTH } from '../lib/constants.js';
|
|
8
8
|
import { isCancel } from '../ui/helpers.js';
|
|
9
|
-
import { rootOpts, requireProject, handleCommandError, } from '../lib/command-helpers.js';
|
|
9
|
+
import { rootOpts, requireProject, handleCommandError, formatTimestamp, } from '../lib/command-helpers.js';
|
|
10
10
|
import * as agentService from '../lib/services/agent-service.js';
|
|
11
11
|
function maskKey(key) {
|
|
12
12
|
if (key.length <= 12)
|
|
@@ -51,7 +51,7 @@ export function registerAgentCommands(program) {
|
|
|
51
51
|
id: a.id.slice(0, ID_DISPLAY_LENGTH),
|
|
52
52
|
form: formatForm(a),
|
|
53
53
|
visibility: a.isPublic ? 'public' : 'private',
|
|
54
|
-
created:
|
|
54
|
+
created: formatTimestamp(a.createdAt),
|
|
55
55
|
}));
|
|
56
56
|
console.log(table([
|
|
57
57
|
{ label: '', key: 'linked', width: 2 },
|
package/dist/commands/billing.js
CHANGED
|
@@ -5,7 +5,7 @@ import { brand, label } from '../ui/theme.js';
|
|
|
5
5
|
import { panel } from '../ui/panel.js';
|
|
6
6
|
import { table } from '../ui/table.js';
|
|
7
7
|
import { isCancel } from '../ui/helpers.js';
|
|
8
|
-
import { rootOpts, handleCommandError } from '../lib/command-helpers.js';
|
|
8
|
+
import { rootOpts, handleCommandError, formatTimestamp } from '../lib/command-helpers.js';
|
|
9
9
|
import { openBrowser } from '../lib/browser.js';
|
|
10
10
|
import { pollVerification } from '../lib/poll.js';
|
|
11
11
|
const LIFE_CALLBACK_URL = 'https://life.cubeworld.co.za/';
|
|
@@ -160,7 +160,7 @@ export function registerBillingCommands(program) {
|
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
const rows = history.map((item) => ({
|
|
163
|
-
date:
|
|
163
|
+
date: formatTimestamp(item.createdAt),
|
|
164
164
|
type: item.type.replace(/_/g, ' '),
|
|
165
165
|
amount: formatCents(item.amount),
|
|
166
166
|
status: item.status,
|
|
@@ -4,7 +4,7 @@ import { ID_DISPLAY_LENGTH } from '../lib/constants.js';
|
|
|
4
4
|
import { brand, dot } from '../ui/theme.js';
|
|
5
5
|
import { table } from '../ui/table.js';
|
|
6
6
|
import { isCancel } from '../ui/helpers.js';
|
|
7
|
-
import { rootOpts, handleCommandError, } from '../lib/command-helpers.js';
|
|
7
|
+
import { rootOpts, handleCommandError, formatTimestamp, } from '../lib/command-helpers.js';
|
|
8
8
|
import * as projectService from '../lib/services/project-service.js';
|
|
9
9
|
export function registerProjectCommands(program) {
|
|
10
10
|
const projects = program
|
|
@@ -35,7 +35,7 @@ export function registerProjectCommands(program) {
|
|
|
35
35
|
id: proj.id.slice(0, ID_DISPLAY_LENGTH),
|
|
36
36
|
name: proj.name,
|
|
37
37
|
product: proj.product,
|
|
38
|
-
created:
|
|
38
|
+
created: formatTimestamp(proj.createdAt),
|
|
39
39
|
}));
|
|
40
40
|
console.log(table([
|
|
41
41
|
{ label: '', key: 'linked', width: 2 },
|
|
@@ -15,6 +15,7 @@ export interface CommandErrorOptions {
|
|
|
15
15
|
exitCode?: number;
|
|
16
16
|
}
|
|
17
17
|
export declare function handleCommandError(opts: CommandErrorOptions): never;
|
|
18
|
+
export declare function formatTimestamp(ts: unknown): string;
|
|
18
19
|
export interface ResolvedProject {
|
|
19
20
|
projectId: string;
|
|
20
21
|
}
|
|
@@ -24,6 +24,17 @@ export function handleCommandError(opts) {
|
|
|
24
24
|
}
|
|
25
25
|
process.exit(opts.exitCode ?? 1);
|
|
26
26
|
}
|
|
27
|
+
export function formatTimestamp(ts) {
|
|
28
|
+
if (!ts)
|
|
29
|
+
return '--';
|
|
30
|
+
if (typeof ts === 'number')
|
|
31
|
+
return new Date(ts).toLocaleDateString();
|
|
32
|
+
if (typeof ts === 'object' && ts !== null && '_seconds' in ts) {
|
|
33
|
+
return new Date(ts._seconds * 1000).toLocaleDateString();
|
|
34
|
+
}
|
|
35
|
+
const d = new Date(ts);
|
|
36
|
+
return isNaN(d.getTime()) ? '--' : d.toLocaleDateString();
|
|
37
|
+
}
|
|
27
38
|
export async function requireProject(cmd, json) {
|
|
28
39
|
const projectFlag = cmd.parent?.opts().project;
|
|
29
40
|
let projectId;
|