@sanity/cli-core 3.6.1 → 3.7.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.
@@ -35,7 +35,7 @@ declare abstract class SanityCommand<T extends typeof Command> extends Command i
35
35
  *
36
36
  * @deprecated use `getGlobalCliClient` function directly instead.
37
37
  */
38
- protected getGlobalApiClient: (args: GlobalCliClientOptions) => Promise<import("sanity").SanityClient>;
38
+ protected getGlobalApiClient: (args: GlobalCliClientOptions) => Promise<import("@sanity/client").SanityClient>;
39
39
  /**
40
40
  * Get the project API client.
41
41
  *
@@ -44,7 +44,7 @@ declare abstract class SanityCommand<T extends typeof Command> extends Command i
44
44
  *
45
45
  * @deprecated use `getProjectCliClient` function directly instead.
46
46
  */
47
- protected getProjectApiClient: (args: ProjectCliClientOptions) => Promise<import("sanity").SanityClient>;
47
+ protected getProjectApiClient: (args: ProjectCliClientOptions) => Promise<import("@sanity/client").SanityClient>;
48
48
  /**
49
49
  * Helper for outputting to the console.
50
50
  *
@@ -1,19 +1,31 @@
1
1
  /**
2
- * Formats a timestamp as `YYYY-MM-DD HH:mm:ss` in the local time zone. Unparseable
3
- * timestamps are returned as-is, so a bad value from the API doesn't fail the command.
2
+ * Formats a timestamp as `YYYY-MM-DD HH:mm:ss` in the local time zone. An unparseable
3
+ * string is returned as-is, so a bad value from the API doesn't fail the command. An
4
+ * invalid `Date` or a non-finite number formats as an empty string.
4
5
  *
5
- * @param timestamp - An ISO 8601 timestamp
6
+ * @param timestamp - An ISO 8601 timestamp, epoch milliseconds, or a `Date`
6
7
  * @internal
7
8
  */
8
- declare function formatDateTime(timestamp: string): string;
9
+ declare function formatDateTime(timestamp: Date | number | string): string;
9
10
  /**
10
11
  * Formats a duration in milliseconds as an approximate, human readable length of
11
- * time, eg `less than a minute`, `5 minutes` or `2 days`.
12
+ * time, eg `less than a minute`, `5 minutes` or `2 days`. Use {@link formatElapsed}
13
+ * where the exact length matters.
12
14
  *
13
15
  * @param ms - The duration in milliseconds
14
16
  * @internal
15
17
  */
16
18
  declare function formatDuration(ms: number): string;
19
+ /**
20
+ * Formats an elapsed time in milliseconds precisely, eg `450ms`, `12s`, `1m 30s` or
21
+ * `2h 5m`. Two adjacent units are shown once the time reaches a minute, so a column
22
+ * of values lines up. Use this for how long an operation took, where a second of
23
+ * difference is meaningful; use {@link formatDuration} for an approximate description.
24
+ *
25
+ * @param ms - The elapsed time in milliseconds
26
+ * @internal
27
+ */
28
+ declare function formatElapsed(ms: number): string;
17
29
  /**
18
30
  * Formats a date relative to now, eg `2 days ago` or `in 3 hours`.
19
31
  *
@@ -30,5 +42,5 @@ declare function formatTimeAgo(date: Date, now?: number): string;
30
42
  * @internal
31
43
  */
32
44
  declare function parseDateOnly(value: string): Date | undefined;
33
- export { formatDateTime, formatDuration, formatTimeAgo, parseDateOnly };
45
+ export { formatDateTime, formatDuration, formatElapsed, formatTimeAgo, parseDateOnly };
34
46
  //# sourceMappingURL=dates.d.ts.map
@@ -1,3 +1,3 @@
1
- export { formatDateTime, formatDuration, formatTimeAgo, parseDateOnly } from '../util/dates.js';
1
+ export { formatDateTime, formatDuration, formatElapsed, formatTimeAgo, parseDateOnly } from '../util/dates.js';
2
2
 
3
3
  //# sourceMappingURL=dates.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/dates.ts"],"sourcesContent":["export {formatDateTime, formatDuration, formatTimeAgo, parseDateOnly} from '../util/dates.js'\n"],"names":["formatDateTime","formatDuration","formatTimeAgo","parseDateOnly"],"mappings":"AAAA,SAAQA,cAAc,EAAEC,cAAc,EAAEC,aAAa,EAAEC,aAAa,QAAO,mBAAkB"}
1
+ {"version":3,"sources":["../../src/_exports/dates.ts"],"sourcesContent":["export {\n formatDateTime,\n formatDuration,\n formatElapsed,\n formatTimeAgo,\n parseDateOnly,\n} from '../util/dates.js'\n"],"names":["formatDateTime","formatDuration","formatElapsed","formatTimeAgo","parseDateOnly"],"mappings":"AAAA,SACEA,cAAc,EACdC,cAAc,EACdC,aAAa,EACbC,aAAa,EACbC,aAAa,QACR,mBAAkB"}
@@ -65,21 +65,23 @@ function pad(value, length = 2) {
65
65
  };
66
66
  }
67
67
  /**
68
- * Formats a timestamp as `YYYY-MM-DD HH:mm:ss` in the local time zone. Unparseable
69
- * timestamps are returned as-is, so a bad value from the API doesn't fail the command.
68
+ * Formats a timestamp as `YYYY-MM-DD HH:mm:ss` in the local time zone. An unparseable
69
+ * string is returned as-is, so a bad value from the API doesn't fail the command. An
70
+ * invalid `Date` or a non-finite number formats as an empty string.
70
71
  *
71
- * @param timestamp - An ISO 8601 timestamp
72
+ * @param timestamp - An ISO 8601 timestamp, epoch milliseconds, or a `Date`
72
73
  * @internal
73
74
  */ export function formatDateTime(timestamp) {
74
- const date = new Date(timestamp);
75
- if (!Number.isFinite(date.getTime())) return timestamp;
75
+ const date = timestamp instanceof Date ? timestamp : new Date(timestamp);
76
+ if (!Number.isFinite(date.getTime())) return typeof timestamp === 'string' ? timestamp : '';
76
77
  const day = `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
77
78
  const time = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
78
79
  return `${day} ${time}`;
79
80
  }
80
81
  /**
81
82
  * Formats a duration in milliseconds as an approximate, human readable length of
82
- * time, eg `less than a minute`, `5 minutes` or `2 days`.
83
+ * time, eg `less than a minute`, `5 minutes` or `2 days`. Use {@link formatElapsed}
84
+ * where the exact length matters.
83
85
  *
84
86
  * @param ms - The duration in milliseconds
85
87
  * @internal
@@ -90,6 +92,28 @@ function pad(value, length = 2) {
90
92
  const unit = selected.value === 1 ? selected.unit : `${selected.unit}s`;
91
93
  return `${selected.value} ${unit}`;
92
94
  }
95
+ /**
96
+ * Formats an elapsed time in milliseconds precisely, eg `450ms`, `12s`, `1m 30s` or
97
+ * `2h 5m`. Two adjacent units are shown once the time reaches a minute, so a column
98
+ * of values lines up. Use this for how long an operation took, where a second of
99
+ * difference is meaningful; use {@link formatDuration} for an approximate description.
100
+ *
101
+ * @param ms - The elapsed time in milliseconds
102
+ * @internal
103
+ */ export function formatElapsed(ms) {
104
+ if (!Number.isFinite(ms)) return '';
105
+ // Round to whole milliseconds first, so 999.6ms reads as `1s` rather than `1000ms`
106
+ const elapsed = Math.round(Math.abs(ms));
107
+ if (elapsed < MS_IN.second) return `${elapsed}ms`;
108
+ const seconds = Math.floor(elapsed / MS_IN.second);
109
+ if (elapsed < MS_IN.minute) return `${seconds}s`;
110
+ const minutes = Math.floor(elapsed / MS_IN.minute);
111
+ if (elapsed < MS_IN.hour) return `${minutes}m ${seconds % 60}s`;
112
+ const hours = Math.floor(elapsed / MS_IN.hour);
113
+ if (elapsed < MS_IN.day) return `${hours}h ${minutes % 60}m`;
114
+ const days = Math.floor(elapsed / MS_IN.day);
115
+ return `${days}d ${hours % 24}h`;
116
+ }
93
117
  /**
94
118
  * Formats a date relative to now, eg `2 days ago` or `in 3 hours`.
95
119
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/dates.ts"],"sourcesContent":["const MS_IN = {\n day: 86_400_000,\n hour: 3_600_000,\n minute: 60_000,\n month: 2_592_000_000, // 30 days\n second: 1000,\n week: 604_800_000,\n year: 31_536_000_000, // 365 days\n} as const\n\n/** Largest unit first, so the first unit the duration fills is the one we report. */\nconst UNITS: {ms: number; unit: Intl.RelativeTimeFormatUnit}[] = [\n {ms: MS_IN.year, unit: 'year'},\n {ms: MS_IN.month, unit: 'month'},\n {ms: MS_IN.week, unit: 'week'},\n {ms: MS_IN.day, unit: 'day'},\n {ms: MS_IN.hour, unit: 'hour'},\n {ms: MS_IN.minute, unit: 'minute'},\n {ms: MS_IN.second, unit: 'second'},\n]\n\nconst relativeTime = new Intl.RelativeTimeFormat('en', {numeric: 'always'})\n\nconst DATE_ONLY_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})$/\n\nfunction pad(value: number, length = 2): string {\n return String(value).padStart(length, '0')\n}\n\n/**\n * Returns the coarsest unit the elapsed time fills and the rounded number of those\n * units, or `undefined` below a second.\n *\n * Rounding can land the value on the boundary of the next unit up, so we promote\n * rather than report `60 minutes` where `1 hour` is meant. Units aren't all whole\n * multiples of each other, so the boundary is the rounded count we'd display, which\n * is why 25+ days reads as `1 month` rather than `4 weeks`.\n */\nfunction selectUnit(\n elapsed: number,\n): {unit: Intl.RelativeTimeFormatUnit; value: number} | undefined {\n let index = UNITS.findIndex(({ms}) => elapsed >= ms)\n if (index === -1) return undefined\n\n while (\n index > 0 &&\n Math.round(elapsed / UNITS[index].ms) >= Math.round(UNITS[index - 1].ms / UNITS[index].ms)\n ) {\n index -= 1\n }\n\n const {ms, unit} = UNITS[index]\n return {unit, value: Math.round(elapsed / ms)}\n}\n\n/**\n * Formats a timestamp as `YYYY-MM-DD HH:mm:ss` in the local time zone. Unparseable\n * timestamps are returned as-is, so a bad value from the API doesn't fail the command.\n *\n * @param timestamp - An ISO 8601 timestamp\n * @internal\n */\nexport function formatDateTime(timestamp: string): string {\n const date = new Date(timestamp)\n if (!Number.isFinite(date.getTime())) return timestamp\n\n const day = `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`\n const time = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`\n return `${day} ${time}`\n}\n\n/**\n * Formats a duration in milliseconds as an approximate, human readable length of\n * time, eg `less than a minute`, `5 minutes` or `2 days`.\n *\n * @param ms - The duration in milliseconds\n * @internal\n */\nexport function formatDuration(ms: number): string {\n if (!Number.isFinite(ms)) return ''\n\n const selected = selectUnit(Math.abs(ms))\n if (!selected || selected.unit === 'second') return 'less than a minute'\n\n const unit = selected.value === 1 ? selected.unit : `${selected.unit}s`\n return `${selected.value} ${unit}`\n}\n\n/**\n * Formats a date relative to now, eg `2 days ago` or `in 3 hours`.\n *\n * @param date - The date to describe\n * @param now - The reference point to compare against, defaults to the current time\n * @internal\n */\nexport function formatTimeAgo(date: Date, now: number = Date.now()): string {\n const delta = date.getTime() - now\n if (!Number.isFinite(delta)) return ''\n\n const selected = selectUnit(Math.abs(delta))\n if (!selected) return 'just now'\n\n return relativeTime.format(delta < 0 ? -selected.value : selected.value, selected.unit)\n}\n\n/**\n * Parses a `YYYY-MM-DD` date into a `Date` at local midnight. Returns `undefined`\n * for anything that isn't a real calendar date in that exact format.\n *\n * @param value - The date string to parse\n * @internal\n */\nexport function parseDateOnly(value: string): Date | undefined {\n const match = DATE_ONLY_PATTERN.exec(value)\n if (!match) return undefined\n\n const year = Number(match[1])\n const month = Number(match[2])\n const day = Number(match[3])\n const date = new Date(year, month - 1, day)\n\n // `new Date(2024, 1, 31)` silently rolls over into March, so reject anything\n // that didn't survive the round trip\n const isRoundTrip =\n date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day\n\n return isRoundTrip ? date : undefined\n}\n"],"names":["MS_IN","day","hour","minute","month","second","week","year","UNITS","ms","unit","relativeTime","Intl","RelativeTimeFormat","numeric","DATE_ONLY_PATTERN","pad","value","length","String","padStart","selectUnit","elapsed","index","findIndex","undefined","Math","round","formatDateTime","timestamp","date","Date","Number","isFinite","getTime","getFullYear","getMonth","getDate","time","getHours","getMinutes","getSeconds","formatDuration","selected","abs","formatTimeAgo","now","delta","format","parseDateOnly","match","exec","isRoundTrip"],"mappings":"AAAA,MAAMA,QAAQ;IACZC,KAAK;IACLC,MAAM;IACNC,QAAQ;IACRC,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNC,MAAM;AACR;AAEA,mFAAmF,GACnF,MAAMC,QAA2D;IAC/D;QAACC,IAAIT,MAAMO,IAAI;QAAEG,MAAM;IAAM;IAC7B;QAACD,IAAIT,MAAMI,KAAK;QAAEM,MAAM;IAAO;IAC/B;QAACD,IAAIT,MAAMM,IAAI;QAAEI,MAAM;IAAM;IAC7B;QAACD,IAAIT,MAAMC,GAAG;QAAES,MAAM;IAAK;IAC3B;QAACD,IAAIT,MAAME,IAAI;QAAEQ,MAAM;I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ACrC,MAAMmD,cACJtB,KAAKK,WAAW,OAAO5B,QAAQuB,KAAKM,QAAQ,OAAOhC,QAAQ,KAAK0B,KAAKO,OAAO,OAAOpC;IAErF,OAAOmD,cAActB,OAAOL;AAC9B"}
1
+ {"version":3,"sources":["../../src/util/dates.ts"],"sourcesContent":["const MS_IN = {\n day: 86_400_000,\n hour: 3_600_000,\n minute: 60_000,\n month: 2_592_000_000, // 30 days\n second: 1000,\n week: 604_800_000,\n year: 31_536_000_000, // 365 days\n} as const\n\n/** Largest unit first, so the first unit the duration fills is the one we report. */\nconst UNITS: {ms: number; unit: Intl.RelativeTimeFormatUnit}[] = [\n {ms: MS_IN.year, unit: 'year'},\n {ms: MS_IN.month, unit: 'month'},\n {ms: MS_IN.week, unit: 'week'},\n {ms: MS_IN.day, unit: 'day'},\n {ms: MS_IN.hour, unit: 'hour'},\n {ms: MS_IN.minute, unit: 'minute'},\n {ms: MS_IN.second, unit: 'second'},\n]\n\nconst relativeTime = new Intl.RelativeTimeFormat('en', {numeric: 'always'})\n\nconst DATE_ONLY_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})$/\n\nfunction pad(value: number, length = 2): string {\n return String(value).padStart(length, '0')\n}\n\n/**\n * Returns the coarsest unit the elapsed time fills and the rounded number of those\n * units, or `undefined` below a second.\n *\n * Rounding can land the value on the boundary of the next unit up, so we promote\n * rather than report `60 minutes` where `1 hour` is meant. Units aren't all whole\n * multiples of each other, so the boundary is the rounded count we'd display, which\n * is why 25+ days reads as `1 month` rather than `4 weeks`.\n */\nfunction selectUnit(\n elapsed: number,\n): {unit: Intl.RelativeTimeFormatUnit; value: number} | undefined {\n let index = UNITS.findIndex(({ms}) => elapsed >= ms)\n if (index === -1) return undefined\n\n while (\n index > 0 &&\n Math.round(elapsed / UNITS[index].ms) >= Math.round(UNITS[index - 1].ms / UNITS[index].ms)\n ) {\n index -= 1\n }\n\n const {ms, unit} = UNITS[index]\n return {unit, value: Math.round(elapsed / ms)}\n}\n\n/**\n * Formats a timestamp as `YYYY-MM-DD HH:mm:ss` in the local time zone. An unparseable\n * string is returned as-is, so a bad value from the API doesn't fail the command. An\n * invalid `Date` or a non-finite number formats as an empty string.\n *\n * @param timestamp - An ISO 8601 timestamp, epoch milliseconds, or a `Date`\n * @internal\n */\nexport function formatDateTime(timestamp: Date | number | string): string {\n const date = timestamp instanceof Date ? timestamp : new Date(timestamp)\n if (!Number.isFinite(date.getTime())) return typeof timestamp === 'string' ? timestamp : ''\n\n const day = `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`\n const time = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`\n return `${day} ${time}`\n}\n\n/**\n * Formats a duration in milliseconds as an approximate, human readable length of\n * time, eg `less than a minute`, `5 minutes` or `2 days`. Use {@link formatElapsed}\n * where the exact length matters.\n *\n * @param ms - The duration in milliseconds\n * @internal\n */\nexport function formatDuration(ms: number): string {\n if (!Number.isFinite(ms)) return ''\n\n const selected = selectUnit(Math.abs(ms))\n if (!selected || selected.unit === 'second') return 'less than a minute'\n\n const unit = selected.value === 1 ? selected.unit : `${selected.unit}s`\n return `${selected.value} ${unit}`\n}\n\n/**\n * Formats an elapsed time in milliseconds precisely, eg `450ms`, `12s`, `1m 30s` or\n * `2h 5m`. Two adjacent units are shown once the time reaches a minute, so a column\n * of values lines up. Use this for how long an operation took, where a second of\n * difference is meaningful; use {@link formatDuration} for an approximate description.\n *\n * @param ms - The elapsed time in milliseconds\n * @internal\n */\nexport function formatElapsed(ms: number): string {\n if (!Number.isFinite(ms)) return ''\n\n // Round to whole milliseconds first, so 999.6ms reads as `1s` rather than `1000ms`\n const elapsed = Math.round(Math.abs(ms))\n if (elapsed < MS_IN.second) return `${elapsed}ms`\n\n const seconds = Math.floor(elapsed / MS_IN.second)\n if (elapsed < MS_IN.minute) return `${seconds}s`\n\n const minutes = Math.floor(elapsed / MS_IN.minute)\n if (elapsed < MS_IN.hour) return `${minutes}m ${seconds % 60}s`\n\n const hours = Math.floor(elapsed / MS_IN.hour)\n if (elapsed < MS_IN.day) return `${hours}h ${minutes % 60}m`\n\n const days = Math.floor(elapsed / MS_IN.day)\n return `${days}d ${hours % 24}h`\n}\n\n/**\n * Formats a date relative to now, eg `2 days ago` or `in 3 hours`.\n *\n * @param date - The date to describe\n * @param now - The reference point to compare against, defaults to the current time\n * @internal\n */\nexport function formatTimeAgo(date: Date, now: number = Date.now()): string {\n const delta = date.getTime() - now\n if (!Number.isFinite(delta)) return ''\n\n const selected = selectUnit(Math.abs(delta))\n if (!selected) return 'just now'\n\n return relativeTime.format(delta < 0 ? -selected.value : selected.value, selected.unit)\n}\n\n/**\n * Parses a `YYYY-MM-DD` date into a `Date` at local midnight. Returns `undefined`\n * for anything that isn't a real calendar date in that exact format.\n *\n * @param value - The date string to parse\n * @internal\n */\nexport function parseDateOnly(value: string): Date | undefined {\n const match = DATE_ONLY_PATTERN.exec(value)\n if (!match) return undefined\n\n const year = Number(match[1])\n const month = Number(match[2])\n const day = Number(match[3])\n const date = new Date(year, month - 1, day)\n\n // `new Date(2024, 1, 31)` silently rolls over into March, so reject anything\n // that didn't survive the round trip\n const isRoundTrip =\n date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day\n\n return isRoundTrip ? date : undefined\n}\n"],"names":["MS_IN","day","hour","minute","month","second","week","year","UNITS","ms","unit","relativeTime","Intl","RelativeTimeFormat","numeric","DATE_ONLY_PATTERN","pad","value","length","String","padStart","selectUnit","elapsed","index","findIndex","undefined","Math","round","formatDateTime","timestamp","date","Date","Number","isFinite","getTime","getFullYear","getMonth","getDate","time","getHours","getMinutes","getSeconds","formatDuration","selected","abs","formatElapsed","seconds","floor","minutes","hours","days","formatTimeAgo","now","delta","format","parseDateOnly","match","exec","isRoundTrip"],"mappings":"AAAA,MAAMA,QAAQ;IACZC,KAAK;IACLC,MAAM;IACNC,QAAQ;IACRC,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNC,MAAM;AAC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J5B,KAAKK,WAAW,OAAO5B,QAAQuB,KAAKM,QAAQ,OAAOhC,QAAQ,KAAK0B,KAAKO,OAAO,OAAOpC;IAErF,OAAOyD,cAAc5B,OAAOL;AAC9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "3.6.1",
3
+ "version": "3.7.0",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",
@@ -117,7 +117,7 @@
117
117
  "dependencies": {
118
118
  "@inquirer/prompts": "^8.5.2",
119
119
  "@oclif/core": "^4.11.14",
120
- "@sanity/client": "^8.4.0",
120
+ "@sanity/client": "^8.5.0",
121
121
  "boxen": "^8.0.1",
122
122
  "empathic": "^2.0.1",
123
123
  "get-it": "^9.5.2",
@@ -149,7 +149,7 @@
149
149
  "eslint": "^10.7.0",
150
150
  "oxc-transform-react": "^0.147.0",
151
151
  "publint": "^0.3.21",
152
- "sanity": "^6.11.0",
152
+ "sanity": "^6.12.0",
153
153
  "typescript": "^6.0.3",
154
154
  "vitest": "^4.1.11"
155
155
  },