@wujiland/cli 1.0.1 → 1.0.2

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.
@@ -19,3 +19,5 @@ export declare function versions(ctx: Ctx): Promise<Outcome>;
19
19
  export declare function rollback(ctx: Ctx): Promise<Outcome>;
20
20
  export declare function logs(ctx: Ctx): Promise<Outcome>;
21
21
  export declare function accessShow(ctx: Ctx): Promise<Outcome>;
22
+ /** `--since 30m`, `2h`, `1d` or an ISO time → the ISO time the manager takes (04-manager.md §11). */
23
+ export declare function logTime(ctx: Ctx, flag: "since" | "until"): string | undefined;
@@ -134,11 +134,12 @@ export async function logs(ctx) {
134
134
  const interval = Number(str(ctx.flags, "interval") ?? "15");
135
135
  if (!Number.isFinite(interval) || interval < 5)
136
136
  throw usage("--interval is at least 5 seconds.");
137
+ const times = { since: logTime(ctx, "since"), until: logTime(ctx, "until") };
137
138
  const m = await managerClient(ctx.deps);
138
139
  const q = (since) => {
139
140
  const p = new URLSearchParams({ env });
140
141
  for (const k of ["since", "until", "level", "request"]) {
141
- const v = k === "since" && since ? since : str(ctx.flags, k);
142
+ const v = k === "since" && since ? since : k === "since" || k === "until" ? times[k] : str(ctx.flags, k);
142
143
  if (v !== undefined)
143
144
  p.set(k, v);
144
145
  }
@@ -176,3 +177,18 @@ export async function accessShow(ctx) {
176
177
  }
177
178
  return { data: { slug, workers: r.workers }, human, pending };
178
179
  }
180
+ /** `--since 30m`, `2h`, `1d` or an ISO time → the ISO time the manager takes (04-manager.md §11). */
181
+ export function logTime(ctx, flag) {
182
+ const raw = str(ctx.flags, flag);
183
+ if (raw === undefined)
184
+ return undefined;
185
+ const rel = /^(\d+)(s|m|h|d)$/.exec(raw);
186
+ if (rel) {
187
+ const unit = { s: 1, m: 60, h: 3600, d: 86400 }[rel[2]];
188
+ return new Date(ctx.deps.now() - Number(rel[1]) * unit * 1000).toISOString();
189
+ }
190
+ const t = Date.parse(raw);
191
+ if (Number.isNaN(t))
192
+ throw usage(`--${flag} takes a duration (30m, 2h, 1d) or an ISO time, not ${JSON.stringify(raw)}.`);
193
+ return new Date(t).toISOString();
194
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CLI_VERSION = "1.0.1";
1
+ export declare const CLI_VERSION = "1.0.2";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Equals cli/package.json "version"; a test keeps them in step.
2
- export const CLI_VERSION = "1.0.1";
2
+ export const CLI_VERSION = "1.0.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wujiland/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "inca: the command line for the whole life of an Inca app.",
5
5
  "license": "MIT",
6
6
  "type": "module",