@cedarjs/cli 6.0.3-next.227 → 6.0.3-next.275

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.
@@ -11,10 +11,36 @@ import {
11
11
  } from '@cedarjs/forms'
12
12
 
13
13
  <% if (fieldsToImport.includes('DatetimeLocalField')) { %>
14
- const formatDatetime = (value) => {
15
- if (value) {
16
- return value.replace(/:\d{2}\.\d{3}\w/, '')
14
+ /**
15
+ * Formats a DateTime string from the API, which is a UTC timestamp, for use as
16
+ * the value of a `datetime-local` input. The input takes `YYYY-MM-DDTHH:mm` in
17
+ * the user's local time, with no seconds, milliseconds or timezone, and the
18
+ * form reads its value back as local time when it is submitted.
19
+ */
20
+ function formatDatetime(value: string | undefined | null) {
21
+ if (!value) {
22
+ return undefined
17
23
  }
24
+
25
+ const date = new Date(value)
26
+
27
+ if (Number.isNaN(date.getTime())) {
28
+ return undefined
29
+ }
30
+
31
+ const pad = (n: number) => String(n).padStart(2, '0')
32
+
33
+ return (
34
+ date.getFullYear() +
35
+ '-' +
36
+ pad(date.getMonth() + 1) +
37
+ '-' +
38
+ pad(date.getDate()) +
39
+ 'T' +
40
+ pad(date.getHours()) +
41
+ ':' +
42
+ pad(date.getMinutes())
43
+ )
18
44
  }
19
45
  <% } %>
20
46
 
@@ -30,6 +56,19 @@ interface ${singularPascalName}FormProps {
30
56
  const ${singularPascalName}Form = (props: ${singularPascalName}FormProps) => {
31
57
  const onSubmit = (data: Form${singularPascalName}) => {
32
58
  <% editableColumns.forEach(column => { %>
59
+ <% if (column.type === 'DateTime' && !column.isList) { %>
60
+ // The input only holds minutes, so an untouched field is sent back as the
61
+ // stored value, keeping its seconds, milliseconds and, when daylight
62
+ // saving time ends, which of the two repeated hours it was in
63
+ if (
64
+ data.${column.name} &&
65
+ props.${singularCamelName}?.${column.name} &&
66
+ formatDatetime(data.${column.name}) ===
67
+ formatDatetime(props.${singularCamelName}.${column.name})
68
+ ) {
69
+ data.${column.name} = props.${singularCamelName}.${column.name}
70
+ }
71
+ <% } %>
33
72
  <% if (column.isEnum && !column.isList && !column.isRequired) { %>
34
73
  if (data.${column.name} === '') {
35
74
  data.${column.name} = null
@@ -39,7 +39,7 @@ export const jsonTruncate = (obj: unknown) => {
39
39
  return truncate(JSON.stringify(obj, null, 2))
40
40
  }
41
41
 
42
- export const timeTag = (dateTime?: string) => {
42
+ export function timeTag(dateTime: string | undefined | null) {
43
43
  let output: string | React.JSX.Element = ''
44
44
 
45
45
  if (dateTime) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "6.0.3-next.227",
3
+ "version": "6.0.3-next.275",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,17 +36,17 @@
36
36
  "@babel/preset-typescript": "7.29.7",
37
37
  "@babel/traverse": "7.29.8",
38
38
  "@babel/types": "7.29.8",
39
- "@cedarjs/api-server": "6.0.3-next.227",
40
- "@cedarjs/babel-config": "6.0.3-next.227",
41
- "@cedarjs/cli-helpers": "6.0.3-next.227",
42
- "@cedarjs/internal": "6.0.3-next.227",
43
- "@cedarjs/prerender": "6.0.3-next.227",
44
- "@cedarjs/project-config": "6.0.3-next.227",
45
- "@cedarjs/structure": "6.0.3-next.227",
46
- "@cedarjs/telemetry": "6.0.3-next.227",
47
- "@cedarjs/utils": "6.0.3-next.227",
48
- "@cedarjs/vite": "6.0.3-next.227",
49
- "@cedarjs/web-server": "6.0.3-next.227",
39
+ "@cedarjs/api-server": "6.0.3-next.275",
40
+ "@cedarjs/babel-config": "6.0.3-next.275",
41
+ "@cedarjs/cli-helpers": "6.0.3-next.275",
42
+ "@cedarjs/internal": "6.0.3-next.275",
43
+ "@cedarjs/prerender": "6.0.3-next.275",
44
+ "@cedarjs/project-config": "6.0.3-next.275",
45
+ "@cedarjs/structure": "6.0.3-next.275",
46
+ "@cedarjs/telemetry": "6.0.3-next.275",
47
+ "@cedarjs/utils": "6.0.3-next.275",
48
+ "@cedarjs/vite": "6.0.3-next.275",
49
+ "@cedarjs/web-server": "6.0.3-next.275",
50
50
  "@listr2/prompt-adapter-enquirer": "4.3.2",
51
51
  "@opentelemetry/api": "1.9.1",
52
52
  "@opentelemetry/core": "2.11.0",
@@ -55,7 +55,7 @@
55
55
  "@opentelemetry/sdk-trace-node": "2.11.0",
56
56
  "@opentelemetry/semantic-conventions": "1.43.0",
57
57
  "@prisma/internals": "7.10.0",
58
- "ansis": "4.3.1",
58
+ "ansis": "4.4.0",
59
59
  "archiver": "7.0.1",
60
60
  "boxen": "5.1.2",
61
61
  "camel-case": "4.1.2",
@@ -79,13 +79,13 @@
79
79
  "pascalcase": "1.0.0",
80
80
  "pluralize": "8.0.0",
81
81
  "portfinder": "1.0.38",
82
- "prettier": "3.9.6",
82
+ "prettier": "3.9.8",
83
83
  "prisma": "7.10.0",
84
84
  "prompts": "2.4.2",
85
85
  "smol-toml": "1.8.0",
86
86
  "srvx": "0.12.8",
87
87
  "string-env-interpolation": "1.0.1",
88
- "systeminformation": "5.33.10",
88
+ "systeminformation": "5.33.11",
89
89
  "termi-link": "1.1.0",
90
90
  "title-case": "3.0.3",
91
91
  "unionfs": "4.6.0",
@@ -94,10 +94,10 @@
94
94
  "yargs": "17.7.3"
95
95
  },
96
96
  "devDependencies": {
97
- "@cedarjs/framework-tools": "6.0.3-next.227",
97
+ "@cedarjs/framework-tools": "6.0.3-next.275",
98
98
  "@prisma/dmmf": "7.10.0",
99
99
  "@types/archiver": "^7.0.0",
100
- "memfs": "4.76.0",
100
+ "memfs": "4.78.1",
101
101
  "node-ssh": "13.2.1",
102
102
  "ts-dedent": "2.3.0",
103
103
  "typescript": "5.9.3",