@liquidmetal-ai/raindrop 0.4.11 → 0.4.13

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.
Files changed (50) hide show
  1. package/README.md +209 -53
  2. package/dist/base-command.d.ts +6 -0
  3. package/dist/base-command.d.ts.map +1 -1
  4. package/dist/base-command.js +16 -1
  5. package/dist/codegen.js +3 -3
  6. package/dist/codegen.test.js +6 -6
  7. package/dist/commands/bucket/create-credential.d.ts +25 -0
  8. package/dist/commands/bucket/create-credential.d.ts.map +1 -0
  9. package/dist/commands/bucket/create-credential.js +171 -0
  10. package/dist/commands/bucket/delete-credential.d.ts +24 -0
  11. package/dist/commands/bucket/delete-credential.d.ts.map +1 -0
  12. package/dist/commands/bucket/delete-credential.js +140 -0
  13. package/dist/commands/bucket/get-credential.d.ts +24 -0
  14. package/dist/commands/bucket/get-credential.d.ts.map +1 -0
  15. package/dist/commands/bucket/get-credential.js +149 -0
  16. package/dist/commands/bucket/list-credentials.d.ts +23 -0
  17. package/dist/commands/bucket/list-credentials.d.ts.map +1 -0
  18. package/dist/commands/bucket/list-credentials.js +146 -0
  19. package/dist/commands/build/branch.d.ts +1 -0
  20. package/dist/commands/build/branch.d.ts.map +1 -1
  21. package/dist/commands/build/branch.js +17 -0
  22. package/dist/commands/build/deploy.d.ts +1 -0
  23. package/dist/commands/build/deploy.d.ts.map +1 -1
  24. package/dist/commands/build/deploy.js +17 -0
  25. package/dist/commands/build/find.d.ts +2 -0
  26. package/dist/commands/build/find.d.ts.map +1 -1
  27. package/dist/commands/build/find.js +181 -16
  28. package/dist/commands/build/list.d.ts +6 -0
  29. package/dist/commands/build/list.d.ts.map +1 -1
  30. package/dist/commands/build/list.js +280 -99
  31. package/dist/commands/build/status.d.ts +0 -4
  32. package/dist/commands/build/status.d.ts.map +1 -1
  33. package/dist/commands/build/status.js +32 -82
  34. package/dist/commands/object/delete.d.ts.map +1 -1
  35. package/dist/commands/object/delete.js +10 -8
  36. package/dist/commands/object/get.d.ts.map +1 -1
  37. package/dist/commands/object/get.js +9 -8
  38. package/dist/commands/object/list.d.ts.map +1 -1
  39. package/dist/commands/object/list.js +8 -6
  40. package/dist/commands/object/put.d.ts.map +1 -1
  41. package/dist/commands/object/put.js +12 -10
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +4 -0
  45. package/dist/status.d.ts +21 -0
  46. package/dist/status.d.ts.map +1 -0
  47. package/dist/status.js +137 -0
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/oclif.manifest.json +2214 -1199
  50. package/package.json +4 -3
@@ -1,9 +1,10 @@
1
- import { ApplicationsResponseSchema, UnitState, } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_pb';
1
+ import { toJsonString } from '@bufbuild/protobuf';
2
2
  import { timestampDate } from '@bufbuild/protobuf/wkt';
3
+ import { ApplicationsResponseSchema, UnitState, } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_pb';
3
4
  import { Flags } from '@oclif/core';
5
+ import chalk from 'chalk';
4
6
  import { BaseCommand } from '../../base-command.js';
5
7
  import { EPOCH_TS } from '../../index.js';
6
- import { toJsonString } from '@bufbuild/protobuf';
7
8
  export const statusString = {
8
9
  [UnitState.UNSPECIFIED]: '<unknown>',
9
10
  [UnitState.PENDING]: 'pending...',
@@ -18,8 +19,20 @@ export default class List extends BaseCommand {
18
19
  static args = {};
19
20
  static description = 'list Raindrop catalog resources';
20
21
  static examples = [
21
- `<%= config.bin %> <%= command.id %> .
22
- List Raindrop catalog resources.
22
+ `<%= config.bin %> <%= command.id %>
23
+ List applications in compact view (default).
24
+
25
+ <%= config.bin %> <%= command.id %> -o tree
26
+ Show applications in tree view with version hierarchy.
27
+
28
+ <%= config.bin %> <%= command.id %> -o log
29
+ Show git-log style view with branch visualization.
30
+
31
+ <%= config.bin %> <%= command.id %> --app demo-fts --limit 5
32
+ Show only demo-fts application, limited to 5 versions.
33
+
34
+ <%= config.bin %> <%= command.id %> --active
35
+ Show only running/active versions.
23
36
  `,
24
37
  ];
25
38
  static flags = {
@@ -28,8 +41,21 @@ List Raindrop catalog resources.
28
41
  output: Flags.string({
29
42
  char: 'o',
30
43
  description: 'output format',
31
- default: 'table',
32
- options: ['text', 'table', 'json', 'log'],
44
+ default: 'compact',
45
+ options: ['text', 'table', 'json', 'log', 'compact', 'tree'],
46
+ }),
47
+ app: Flags.string({
48
+ description: 'filter by application name',
49
+ required: false,
50
+ }),
51
+ limit: Flags.integer({
52
+ char: 'n',
53
+ description: 'limit number of versions shown per application',
54
+ required: false,
55
+ }),
56
+ active: Flags.boolean({
57
+ description: 'show only running/active versions',
58
+ default: false,
33
59
  }),
34
60
  impersonate: Flags.string({
35
61
  char: 'i',
@@ -77,121 +103,277 @@ List Raindrop catalog resources.
77
103
  }
78
104
  // Render the version tree in git-log style with branch lines
79
105
  renderGitLogStyle(applications) {
80
- // Build the version tree first
81
- const { rootNodes } = this.buildVersionTree(applications);
82
- // Track columns for each branch in the graph
83
- const columnMap = new Map();
84
- let maxColumn = 0;
85
- // Function to assign columns to each node in the tree
86
- const assignColumns = (node, parentColumn) => {
87
- if (columnMap.has(node.versionId))
88
- return;
89
- // If parent has a column, try to use the same column
90
- if (parentColumn !== undefined) {
91
- columnMap.set(node.versionId, parentColumn);
106
+ const groups = this.groupApplicationsByName(applications);
107
+ const result = [];
108
+ // Process each application group separately
109
+ for (const [appName, appVersions] of groups) {
110
+ result.push('');
111
+ result.push(chalk.bold.underline(`=== ${appName} ===`));
112
+ result.push('');
113
+ // Build the version tree for this app
114
+ const { rootNodes } = this.buildVersionTree(appVersions);
115
+ // Track columns for each branch in the graph
116
+ const columnMap = new Map();
117
+ let maxColumn = 0;
118
+ // Function to assign columns to each node in the tree
119
+ const assignColumns = (node, parentColumn) => {
120
+ if (columnMap.has(node.versionId))
121
+ return;
122
+ // If parent has a column, try to use the same column
123
+ if (parentColumn !== undefined) {
124
+ columnMap.set(node.versionId, parentColumn);
125
+ }
126
+ else {
127
+ // Assign a new column for this branch
128
+ columnMap.set(node.versionId, maxColumn++);
129
+ }
130
+ // Recursively assign columns to children
131
+ node.children.forEach((child) => {
132
+ assignColumns(child, columnMap.get(node.versionId));
133
+ });
134
+ };
135
+ // Assign columns to all nodes starting from roots
136
+ rootNodes.forEach((root) => assignColumns(root));
137
+ // Flatten tree for display in chronological order
138
+ const flattenedNodes = [];
139
+ const flatten = (node) => {
140
+ flattenedNodes.push(node);
141
+ node.children.forEach((child) => flatten(child));
142
+ };
143
+ rootNodes.forEach((root) => flatten(root));
144
+ // Sort flattened nodes by timestamp (newest first)
145
+ flattenedNodes.sort((a, b) => {
146
+ const aTime = timestampDate(a.application.createdAt || EPOCH_TS).getTime() || 0;
147
+ const bTime = timestampDate(b.application.createdAt || EPOCH_TS).getTime() || 0;
148
+ return bTime - aTime;
149
+ });
150
+ // Generate graph lines
151
+ const processed = new Set();
152
+ const linesInUse = new Set();
153
+ for (const node of flattenedNodes) {
154
+ if (processed.has(node.versionId))
155
+ continue;
156
+ processed.add(node.versionId);
157
+ const app = node.application;
158
+ const column = columnMap.get(node.versionId) || 0;
159
+ linesInUse.add(column);
160
+ // Format timestamp like git
161
+ const date = timestampDate(app.createdAt || EPOCH_TS);
162
+ const timestamp = date.toLocaleString('en-US', {
163
+ weekday: 'short',
164
+ month: 'short',
165
+ day: 'numeric',
166
+ year: 'numeric',
167
+ hour: 'numeric',
168
+ minute: 'numeric',
169
+ second: 'numeric',
170
+ hour12: false,
171
+ timeZoneName: 'short',
172
+ });
173
+ // Create graph line with asterisk at current position
174
+ let graphLine = '';
175
+ for (let i = 0; i <= maxColumn; i++) {
176
+ if (i === column) {
177
+ graphLine += '*';
178
+ }
179
+ else if (linesInUse.has(i)) {
180
+ graphLine += '|';
181
+ }
182
+ else {
183
+ graphLine += ' ';
184
+ }
185
+ }
186
+ // Add branch indicator if available
187
+ let branchInfo = '';
188
+ if (app.branch) {
189
+ branchInfo = ` (${app.branch})`;
190
+ }
191
+ // Add previous version info if available
192
+ let parentInfo = '';
193
+ if (app.previousVersionId) {
194
+ parentInfo = ` [parent: ${app.previousVersionId}]`;
195
+ }
196
+ // Format output lines with color
197
+ const versionLine = `${graphLine} ${chalk.yellow('version')} ${chalk.yellow(app.versionId)}${chalk.cyan(branchInfo)}${chalk.dim(parentInfo)}`;
198
+ result.push(versionLine);
199
+ // Replace asterisk with pipe for continuation lines
200
+ graphLine = graphLine.replace('*', '|');
201
+ // Show additional metadata indented like git log
202
+ let statusColor;
203
+ if (app.state === UnitState.RUNNING) {
204
+ statusColor = chalk.green;
205
+ }
206
+ else if (app.state === UnitState.DELETING) {
207
+ statusColor = chalk.yellow;
208
+ }
209
+ else if (app.state === UnitState.DELETED) {
210
+ statusColor = chalk.red;
211
+ }
212
+ else {
213
+ statusColor = chalk.gray;
214
+ }
215
+ result.push(`${graphLine} ${chalk.bold('Status:')} ${statusColor(statusString[app.state])}`);
216
+ result.push(`${graphLine} ${chalk.bold('Date:')} ${chalk.dim(timestamp)}`);
217
+ result.push(`${graphLine} `);
218
+ result.push(`${graphLine} ${chalk.bold(app.name)}`);
219
+ result.push(`${graphLine}`);
92
220
  }
93
- else {
94
- // Assign a new column for this branch
95
- columnMap.set(node.versionId, maxColumn++);
221
+ }
222
+ return result.join('\n');
223
+ }
224
+ // Group applications by name
225
+ groupApplicationsByName(applications) {
226
+ const groups = new Map();
227
+ for (const app of applications) {
228
+ const name = app.name;
229
+ if (!groups.has(name)) {
230
+ groups.set(name, []);
96
231
  }
97
- // Recursively assign columns to children
98
- node.children.forEach((child) => {
99
- assignColumns(child, columnMap.get(node.versionId));
232
+ groups.get(name).push(app);
233
+ }
234
+ // Sort each group by date (newest first)
235
+ for (const apps of groups.values()) {
236
+ apps.sort((a, b) => {
237
+ const aTime = timestampDate(a.createdAt || EPOCH_TS).getTime();
238
+ const bTime = timestampDate(b.createdAt || EPOCH_TS).getTime();
239
+ return bTime - aTime;
100
240
  });
101
- };
102
- // Assign columns to all nodes starting from roots
103
- rootNodes.forEach((root) => assignColumns(root));
104
- // Generate the graph output
241
+ }
242
+ return groups;
243
+ }
244
+ // Render compact view
245
+ renderCompactView(applications) {
246
+ const groups = this.groupApplicationsByName(applications);
105
247
  const result = [];
106
- // Flatten tree for display in chronological order
107
- const flattenedNodes = [];
108
- const flatten = (node) => {
109
- flattenedNodes.push(node);
110
- node.children.forEach((child) => flatten(child));
111
- };
112
- rootNodes.forEach((root) => flatten(root));
113
- // Sort flattened nodes by timestamp (newest first)
114
- flattenedNodes.sort((a, b) => {
115
- const aTime = timestampDate(a.application.createdAt || EPOCH_TS).getTime() || 0;
116
- const bTime = timestampDate(b.application.createdAt || EPOCH_TS).getTime() || 0;
248
+ // Sort groups by most recent activity
249
+ const sortedGroups = Array.from(groups.entries()).sort((a, b) => {
250
+ const aLatest = a[1][0];
251
+ const bLatest = b[1][0];
252
+ if (!aLatest || !bLatest)
253
+ return 0;
254
+ const aTime = timestampDate(aLatest.createdAt || EPOCH_TS).getTime();
255
+ const bTime = timestampDate(bLatest.createdAt || EPOCH_TS).getTime();
117
256
  return bTime - aTime;
118
257
  });
119
- // Generate graph lines
120
- const processed = new Set();
121
- const linesInUse = new Set();
122
- for (const node of flattenedNodes) {
123
- if (processed.has(node.versionId))
124
- continue;
125
- processed.add(node.versionId);
126
- const app = node.application;
127
- const column = columnMap.get(node.versionId) || 0;
128
- linesInUse.add(column);
129
- // Format timestamp like git
130
- const date = timestampDate(app.createdAt || EPOCH_TS);
131
- const timestamp = date.toLocaleString('en-US', {
132
- weekday: 'short',
133
- month: 'short',
134
- day: 'numeric',
135
- year: 'numeric',
136
- hour: 'numeric',
137
- minute: 'numeric',
138
- second: 'numeric',
139
- hour12: false,
140
- timeZoneName: 'short',
141
- });
142
- // Create graph line with asterisk at current position
143
- let graphLine = '';
144
- for (let i = 0; i <= maxColumn; i++) {
145
- if (i === column) {
146
- graphLine += '*';
258
+ for (const [appName, versions] of sortedGroups) {
259
+ const activeVersions = versions.filter(v => v.state === UnitState.RUNNING);
260
+ const deletedVersions = versions.filter(v => v.state === UnitState.DELETED || v.state === UnitState.DELETING);
261
+ result.push(`\n${chalk.bold(appName)} ${chalk.dim(`(${versions.length} version${versions.length !== 1 ? 's' : ''})`)}`);
262
+ // Show active versions first
263
+ let shown = 0;
264
+ for (const version of activeVersions) {
265
+ if (this.flags.limit && shown >= this.flags.limit)
266
+ break;
267
+ const date = timestampDate(version.createdAt || EPOCH_TS).toLocaleDateString();
268
+ const branch = version.branch ? chalk.cyan(` (${version.branch})`) : '';
269
+ const status = chalk.green(statusString[version.state]);
270
+ result.push(` └─ ${chalk.yellow(version.versionId)}...${branch} - ${status} - ${chalk.dim(date)}`);
271
+ shown++;
272
+ }
273
+ // Show some deleted versions if not --active flag
274
+ if (!this.flags.active && deletedVersions.length > 0) {
275
+ const remaining = this.flags.limit ? Math.max(0, this.flags.limit - shown) : deletedVersions.length;
276
+ const toShow = Math.min(remaining, deletedVersions.length);
277
+ for (let i = 0; i < toShow && i < 3; i++) {
278
+ const version = deletedVersions[i];
279
+ if (!version)
280
+ continue;
281
+ const date = timestampDate(version.createdAt || EPOCH_TS).toLocaleDateString();
282
+ const status = version.state === UnitState.DELETING ? chalk.yellow(statusString[version.state]) : chalk.red(statusString[version.state]);
283
+ result.push(` └─ ${chalk.gray(version.versionId)}... - ${status} - ${chalk.dim(date)}`);
284
+ }
285
+ if (deletedVersions.length > toShow) {
286
+ result.push(chalk.dim(` ... ${deletedVersions.length - toShow} more deleted versions`));
287
+ }
288
+ }
289
+ }
290
+ // Add summary at the end
291
+ const totalApps = sortedGroups.length;
292
+ const totalVersions = applications.length;
293
+ const activeVersions = applications.filter(app => app.state === UnitState.RUNNING).length;
294
+ result.push('');
295
+ result.push(chalk.dim('─'.repeat(50)));
296
+ result.push(chalk.dim(`Total: ${totalApps} applications, ${totalVersions} versions (${activeVersions} active)`));
297
+ return result.join('\n');
298
+ }
299
+ // Render tree view for a specific application
300
+ renderTreeView(applications) {
301
+ const groups = this.groupApplicationsByName(applications);
302
+ const result = [];
303
+ for (const [appName, versions] of groups) {
304
+ result.push(`\n${chalk.bold.underline(`=== ${appName} ===`)}`);
305
+ // Build version tree for this app
306
+ const { rootNodes } = this.buildVersionTree(versions);
307
+ // Render each root and its descendants
308
+ const renderNode = (node, prefix = '', isLast = true) => {
309
+ const app = node.application;
310
+ const date = timestampDate(app.createdAt || EPOCH_TS).toLocaleDateString();
311
+ const branch = app.branch ? chalk.cyan(` (${app.branch})`) : '';
312
+ let status;
313
+ if (app.state === UnitState.RUNNING) {
314
+ status = chalk.green(statusString[app.state]);
315
+ }
316
+ else if (app.state === UnitState.DELETING) {
317
+ status = chalk.yellow(statusString[app.state]);
147
318
  }
148
- else if (linesInUse.has(i)) {
149
- graphLine += '|';
319
+ else if (app.state === UnitState.DELETED) {
320
+ status = chalk.red(statusString[app.state]);
150
321
  }
151
322
  else {
152
- graphLine += ' ';
323
+ status = chalk.gray(statusString[app.state]);
153
324
  }
154
- }
155
- // Add branch indicator if available
156
- let branchInfo = '';
157
- if (app.branch) {
158
- branchInfo = ` (${app.branch})`;
159
- }
160
- // Add previous version info if available
161
- let parentInfo = '';
162
- if (app.previousVersionId) {
163
- const parentShortId = app.previousVersionId.substring(0, 8);
164
- parentInfo = ` [parent: ${parentShortId}]`;
165
- }
166
- // Format output lines
167
- result.push(`${graphLine} version ${app.versionId}${branchInfo}${parentInfo}`);
168
- // Replace asterisk with pipe for continuation lines
169
- graphLine = graphLine.replace('*', '|');
170
- // Show additional metadata indented like git log
171
- const status = statusString[app.state];
172
- result.push(`${graphLine} Status: ${status}`);
173
- result.push(`${graphLine} Date: ${timestamp}`);
174
- result.push(`${graphLine} `);
175
- result.push(`${graphLine} ${app.name}`);
176
- result.push(`${graphLine}`);
325
+ const current = app.state === UnitState.RUNNING && app.branch === 'main' ? chalk.bold.green(' ← current') : '';
326
+ const connector = isLast ? '└─' : '├─';
327
+ const shortId = chalk.yellow(app.versionId);
328
+ result.push(`${prefix}${connector} ${shortId}...${branch} - ${status} - ${chalk.dim(date)}${current}`);
329
+ // Render children
330
+ const childPrefix = prefix + (isLast ? ' ' : '│ ');
331
+ node.children.forEach((child, index) => {
332
+ renderNode(child, childPrefix, index === node.children.length - 1);
333
+ });
334
+ };
335
+ rootNodes.forEach((root, index) => {
336
+ renderNode(root, '', index === rootNodes.length - 1);
337
+ });
177
338
  }
178
339
  return result.join('\n');
179
340
  }
180
341
  async listApplications() {
181
342
  const { client: catalogService, organizationId: defaultOrganizationId, userId } = await this.catalogService();
182
343
  const organizationId = this.flags.impersonate ?? defaultOrganizationId;
183
- this.log(`Listing applications for organization ${organizationId}`);
344
+ // Only show the "Listing applications..." message for certain outputs
345
+ if (this.flags.output === 'log' || this.flags.output === 'table') {
346
+ this.log(chalk.dim(`Listing applications for organization ${organizationId}`));
347
+ }
184
348
  const resp = await catalogService.applications({
185
349
  userId,
186
350
  organizationId,
187
351
  showDeleted: this.flags.all,
188
352
  });
353
+ // Apply filters
354
+ let applications = resp.applications;
355
+ // Filter by app name if specified
356
+ if (this.flags.app) {
357
+ applications = applications.filter(app => app.name === this.flags.app);
358
+ }
359
+ // Filter by active status if specified
360
+ if (this.flags.active) {
361
+ applications = applications.filter(app => app.state === UnitState.RUNNING);
362
+ }
189
363
  if (this.flags.output === 'log') {
190
364
  // Process and display in git-log style with branch lines
191
- this.log(this.renderGitLogStyle(resp.applications));
365
+ this.log(this.renderGitLogStyle(applications));
366
+ }
367
+ else if (this.flags.output === 'compact') {
368
+ // Display compact view
369
+ this.log(this.renderCompactView(applications));
370
+ }
371
+ else if (this.flags.output === 'tree') {
372
+ // Display tree view
373
+ this.log(this.renderTreeView(applications));
192
374
  }
193
375
  else if (this.flags.output === 'table') {
194
- console.table(resp.applications.reduce(
376
+ console.table(applications.reduce(
195
377
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
196
378
  (acc, a) => {
197
379
  const dateStr = a.createdAt ? timestampDate(a.createdAt).toISOString() : '';
@@ -209,9 +391,8 @@ List Raindrop catalog resources.
209
391
  console.log(toJsonString(ApplicationsResponseSchema, resp, { prettySpaces: 2 }));
210
392
  }
211
393
  else {
212
- for (const a of resp.applications) {
213
- console.log(`${timestampDate(a.createdAt || EPOCH_TS).toISOString()} ${a.organizationId} ${a.versionId} ${a.name} (${a.isActive ? 'active' : 'inactive'}, ${statusString[a.state]}, ${a.lock ? 'locked' : 'unlocked'})`);
214
- }
394
+ // Default to compact view
395
+ this.log(this.renderCompactView(applications));
215
396
  }
216
397
  }
217
398
  async run() {
@@ -1,6 +1,4 @@
1
- import { StatusResponse, UnitState } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_pb';
2
1
  import { BaseCommand } from '../../base-command.js';
3
- export declare const statusString: Record<UnitState, string>;
4
2
  export default class Status extends BaseCommand<typeof Status> {
5
3
  static args: {};
6
4
  static description: string;
@@ -22,7 +20,5 @@ export default class Status extends BaseCommand<typeof Status> {
22
20
  sendVersionMetadata: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
23
21
  };
24
22
  run(): Promise<void>;
25
- linesLastRendered: number;
26
- renderLive(status: StatusResponse): Promise<void>;
27
23
  }
28
24
  //# sourceMappingURL=status.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/build/status.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EAEd,SAAS,EACV,MAAM,yDAAyD,CAAC;AAKjE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CASzC,CAAC;AAEX,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW,CAAC,OAAO,MAAM,CAAC;IAC5D,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAAmD;IAErE,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;;;;;MAsCV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAgE1B,iBAAiB,SAAK;IAEhB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA6BxD"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/build/status.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW,CAAC,OAAO,MAAM,CAAC;IAC5D,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAAmD;IAErE,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;;;;;MAsCV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAoD3B"}
@@ -1,20 +1,9 @@
1
- import { valueOf } from '@liquidmetal-ai/drizzle/appify/build';
2
- import { StatusResponseSchema, UnitState, } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_pb';
3
- import { Flags, ux } from '@oclif/core';
4
- import Table from 'cli-table3';
5
- import * as readline from 'readline';
6
1
  import { toJsonString } from '@bufbuild/protobuf';
2
+ import { StatusResponseSchema } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_pb';
3
+ import { Flags } from '@oclif/core';
4
+ import Table from 'cli-table3';
7
5
  import { BaseCommand } from '../../base-command.js';
8
- export const statusString = {
9
- [UnitState.UNSPECIFIED]: '<unknown>',
10
- [UnitState.PENDING]: 'pending...',
11
- [UnitState.STARTING]: 'starting...',
12
- [UnitState.RUNNING]: 'running',
13
- [UnitState.STOPPING]: 'stopping...',
14
- [UnitState.STOPPED]: 'stopped',
15
- [UnitState.DELETING]: 'deleting...',
16
- [UnitState.DELETED]: 'deleted',
17
- };
6
+ import { getStatus, StatusRenderer, statusString, watchStatus } from '../../status.js';
18
7
  export default class Status extends BaseCommand {
19
8
  static args = {};
20
9
  static description = 'show the status of an application in Raindrop';
@@ -44,8 +33,8 @@ export default class Status extends BaseCommand {
44
33
  output: Flags.string({
45
34
  char: 'o',
46
35
  description: 'output format',
47
- default: 'table',
48
- options: ['watch', 'table', 'json'],
36
+ default: 'compact',
37
+ options: ['watch', 'table', 'json', 'compact'],
49
38
  }),
50
39
  sudo: Flags.boolean({
51
40
  char: 's',
@@ -62,89 +51,50 @@ export default class Status extends BaseCommand {
62
51
  }),
63
52
  };
64
53
  async run() {
65
- const { flags } = await this.parse(Status);
66
- if (!flags.version) {
67
- const config = await this.loadConfig();
68
- flags.version = config.versionId;
69
- }
70
- if (!flags.application) {
71
- const apps = await this.loadManifest();
72
- const app = apps[0];
73
- if (app === undefined) {
74
- this.error('No application provided or found in manifest', { exit: 1 });
75
- }
76
- flags.application = valueOf(app.name);
77
- }
78
- const { client: catalogService, userId, organizationId: defaultOrganizationId } = await this.catalogService();
79
- const organizationId = flags.impersonate ?? defaultOrganizationId;
80
- const applicationStatus = await catalogService.status({
81
- userId,
82
- organizationId,
54
+ const flags = (await this.parse(Status)).flags;
55
+ const status = await getStatus({
56
+ command: this,
57
+ root: flags.root,
58
+ manifest: flags.manifest,
83
59
  applicationName: flags.application,
84
- currentVersionId: flags.version || '',
60
+ versionId: flags.version,
61
+ impersonate: flags.impersonate,
85
62
  });
86
- if (applicationStatus === undefined) {
87
- this.error(`Application ${flags.application} not found`, { exit: 1 });
63
+ if (flags.output === 'compact') {
64
+ // Get application name and version for display
65
+ const applicationName = flags.application || (await this.loadManifest())[0]?.name.value || 'unknown';
66
+ const versionId = flags.version || (await this.loadConfig()).versionId;
67
+ const renderer = new StatusRenderer();
68
+ renderer.renderCompact(status, applicationName, versionId);
69
+ return;
88
70
  }
89
71
  if (flags.output === 'table') {
90
72
  // Display the status of each module in the application using console.table
91
- const statusTable = applicationStatus.modules.map((module) => ({
73
+ const statusTable = status.modules.map((module) => ({
92
74
  module: module.name,
93
75
  status: statusString[module.state],
94
- urls: module.urls.join(', '),
76
+ message: module.notification || ''
95
77
  }));
96
78
  const table = new Table({
97
79
  head: ['Module', 'Status', 'URLs'],
98
80
  });
99
- table.push(...statusTable.map((row) => [row.module, row.status, row.urls]));
81
+ table.push(...statusTable.map((row) => [row.module, row.status, row.message || '']));
100
82
  console.log(table.toString());
101
83
  return;
102
84
  }
103
85
  if (flags.output === 'json') {
104
- console.log(toJsonString(StatusResponseSchema, applicationStatus, { prettySpaces: 2 }));
86
+ console.log(toJsonString(StatusResponseSchema, status, { prettySpaces: 2 }));
105
87
  return;
106
88
  }
107
- let watchStatus = applicationStatus;
108
89
  if (flags.output === 'watch') {
109
- while (true) {
110
- await this.renderLive(watchStatus);
111
- if (watchStatus.state === UnitState.RUNNING || watchStatus.state === UnitState.STOPPED) {
112
- break;
113
- }
114
- await new Promise((resolve) => setTimeout(resolve, 1000));
115
- watchStatus = await catalogService.status({
116
- userId,
117
- organizationId,
118
- applicationName: flags.application,
119
- currentVersionId: flags.version || '',
120
- });
121
- }
122
- }
123
- }
124
- linesLastRendered = 0;
125
- async renderLive(status) {
126
- if (this.linesLastRendered > 0) {
127
- readline.moveCursor(process.stdout, 0, -this.linesLastRendered);
128
- readline.clearScreenDown(process.stdout);
129
- }
130
- const lines = [];
131
- const statusStateString = (state) => ux.colorize({
132
- [UnitState.UNSPECIFIED]: 'gray',
133
- [UnitState.PENDING]: 'gray',
134
- [UnitState.STARTING]: 'yellow',
135
- [UnitState.RUNNING]: 'green',
136
- [UnitState.STOPPING]: 'yellow',
137
- [UnitState.STOPPED]: 'red',
138
- [UnitState.DELETING]: 'gray',
139
- [UnitState.DELETED]: 'gray',
140
- }[state], statusString[state]);
141
- for (const module of status.modules) {
142
- const padding = ' '.repeat(32 - module.name.length);
143
- lines.push(`${padding}${module.name}: ${statusStateString(module.state)} ${module.urls.join(', ')}`);
144
- }
145
- for (const line of lines) {
146
- console.log(line);
90
+ await watchStatus({
91
+ command: this,
92
+ root: flags.root,
93
+ manifest: flags.manifest,
94
+ applicationName: flags.application,
95
+ versionId: flags.version,
96
+ impersonate: flags.impersonate,
97
+ });
147
98
  }
148
- this.linesLastRendered = lines.length;
149
99
  }
150
100
  }
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/object/delete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW,CAAC,OAAO,YAAY,CAAC;IACxE,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,WAAW,SAA2C;IAE7D,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;;;MA+BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA0C3B"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/object/delete.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW,CAAC,OAAO,YAAY,CAAC;IACxE,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,WAAW,SAA2C;IAE7D,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;;;MA+BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2C3B"}