@contember/create 2.1.0-beta.1 → 2.2.0-alpha.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.
Files changed (223) hide show
  1. package/dist/development/run.cjs.map +1 -1
  2. package/dist/development/run.js.map +1 -1
  3. package/dist/development/src/commands/WorkspaceCreateCommand.cjs +2 -2
  4. package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
  5. package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
  6. package/dist/development/src/lib/FileSystem.cjs +1 -2
  7. package/dist/development/src/lib/FileSystem.cjs.map +1 -1
  8. package/dist/development/src/lib/FileSystem.js +1 -2
  9. package/dist/development/src/lib/FileSystem.js.map +1 -1
  10. package/dist/development/src/lib/TemplateInstaller.cjs +16 -16
  11. package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
  12. package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
  13. package/dist/development/src/lib/packageManagerDetector.cjs +6 -6
  14. package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -1
  15. package/dist/development/src/lib/version.cjs +2 -2
  16. package/dist/development/src/lib/version.cjs.map +1 -1
  17. package/dist/development/src/lib/version.js.map +1 -1
  18. package/dist/development/src/paths.cjs +3 -3
  19. package/dist/development/src/paths.cjs.map +1 -1
  20. package/dist/production/run.cjs.map +1 -1
  21. package/dist/production/run.js.map +1 -1
  22. package/dist/production/src/commands/WorkspaceCreateCommand.cjs +2 -2
  23. package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
  24. package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
  25. package/dist/production/src/lib/FileSystem.cjs +1 -2
  26. package/dist/production/src/lib/FileSystem.cjs.map +1 -1
  27. package/dist/production/src/lib/FileSystem.js +1 -2
  28. package/dist/production/src/lib/FileSystem.js.map +1 -1
  29. package/dist/production/src/lib/TemplateInstaller.cjs +16 -16
  30. package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
  31. package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
  32. package/dist/production/src/lib/packageManagerDetector.cjs +6 -6
  33. package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -1
  34. package/dist/production/src/lib/version.cjs +2 -2
  35. package/dist/production/src/lib/version.cjs.map +1 -1
  36. package/dist/production/src/lib/version.js.map +1 -1
  37. package/dist/production/src/paths.cjs +3 -3
  38. package/dist/production/src/paths.cjs.map +1 -1
  39. package/dist/types/commands/WorkspaceCreateCommand.d.ts +1 -1
  40. package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
  41. package/dist/types/commands/index.d.ts +1 -1
  42. package/dist/types/commands/index.d.ts.map +1 -1
  43. package/dist/types/lib/FileSystem.d.ts +3 -2
  44. package/dist/types/lib/FileSystem.d.ts.map +1 -1
  45. package/dist/types/lib/TemplateInstaller.d.ts +1 -1
  46. package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
  47. package/dist/types/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +3 -4
  49. package/resources/templates/default/admin/lib/binding/binding.tsx +19 -4
  50. package/resources/templates/default/admin/lib/binding/delete.tsx +37 -3
  51. package/resources/templates/default/admin/lib/binding/hooks.tsx +65 -3
  52. package/resources/templates/default/admin/lib/binding/identity.tsx +17 -4
  53. package/resources/templates/default/admin/lib/binding/index.ts +5 -5
  54. package/resources/templates/default/admin/lib/binding/navigation-guard-dialog.tsx +15 -3
  55. package/resources/templates/default/admin/lib/binding/persist.tsx +27 -5
  56. package/resources/templates/default/admin/lib/block-repeater/block-repeater.tsx +15 -11
  57. package/resources/templates/default/admin/lib/block-repeater/index.ts +1 -1
  58. package/resources/templates/default/admin/lib/board/board.tsx +2 -2
  59. package/resources/templates/default/admin/lib/board/index.ts +1 -1
  60. package/resources/templates/default/admin/lib/buttons/back-button.tsx +22 -2
  61. package/resources/templates/default/admin/lib/buttons/index.ts +2 -2
  62. package/resources/templates/default/admin/lib/buttons/link-back-button.tsx +11 -2
  63. package/resources/templates/default/admin/lib/datagrid/cells.tsx +3 -3
  64. package/resources/templates/default/admin/lib/datagrid/column-header.tsx +4 -4
  65. package/resources/templates/default/admin/lib/datagrid/columns.tsx +28 -14
  66. package/resources/templates/default/admin/lib/datagrid/elements.tsx +2 -2
  67. package/resources/templates/default/admin/lib/datagrid/empty.tsx +1 -1
  68. package/resources/templates/default/admin/lib/datagrid/export.tsx +2 -2
  69. package/resources/templates/default/admin/lib/datagrid/filters/boolean.tsx +13 -13
  70. package/resources/templates/default/admin/lib/datagrid/filters/common.tsx +2 -2
  71. package/resources/templates/default/admin/lib/datagrid/filters/date.tsx +37 -16
  72. package/resources/templates/default/admin/lib/datagrid/filters/defined.tsx +13 -12
  73. package/resources/templates/default/admin/lib/datagrid/filters/enum.tsx +56 -22
  74. package/resources/templates/default/admin/lib/datagrid/filters/index.ts +7 -7
  75. package/resources/templates/default/admin/lib/datagrid/filters/mobile.tsx +18 -0
  76. package/resources/templates/default/admin/lib/datagrid/filters/number.tsx +10 -13
  77. package/resources/templates/default/admin/lib/datagrid/filters/relation.tsx +8 -8
  78. package/resources/templates/default/admin/lib/datagrid/filters/text.tsx +9 -9
  79. package/resources/templates/default/admin/lib/datagrid/grid.tsx +31 -23
  80. package/resources/templates/default/admin/lib/datagrid/index.ts +12 -12
  81. package/resources/templates/default/admin/lib/datagrid/labels.tsx +22 -4
  82. package/resources/templates/default/admin/lib/datagrid/layout-switcher.tsx +10 -4
  83. package/resources/templates/default/admin/lib/datagrid/loader.tsx +4 -4
  84. package/resources/templates/default/admin/lib/datagrid/pagination.tsx +16 -6
  85. package/resources/templates/default/admin/lib/datagrid/table.tsx +8 -6
  86. package/resources/templates/default/admin/lib/datagrid/tiles.tsx +6 -5
  87. package/resources/templates/default/admin/lib/datagrid/toolbar.tsx +15 -19
  88. package/resources/templates/default/admin/lib/datagrid/ui.tsx +3 -3
  89. package/resources/templates/default/admin/lib/dev/index.ts +2 -2
  90. package/resources/templates/default/admin/lib/dev/login-panel.tsx +12 -3
  91. package/resources/templates/default/admin/lib/dev/todo.tsx +12 -0
  92. package/resources/templates/default/admin/lib/dict.ts +0 -261
  93. package/resources/templates/default/admin/lib/dimensions/dimensions.tsx +85 -4
  94. package/resources/templates/default/admin/lib/dimensions/index.ts +1 -1
  95. package/resources/templates/default/admin/lib/editor/block-editor.tsx +72 -3
  96. package/resources/templates/default/admin/lib/editor/common/baseEditorPlugins.tsx +54 -11
  97. package/resources/templates/default/admin/lib/editor/common/buttons.tsx +1 -1
  98. package/resources/templates/default/admin/lib/editor/common/editor-block-toolbar.tsx +1 -1
  99. package/resources/templates/default/admin/lib/editor/common/elements/HeadingRenderer.tsx +1 -1
  100. package/resources/templates/default/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +1 -1
  101. package/resources/templates/default/admin/lib/editor/common/elements/ListItemRenderer.tsx +1 -1
  102. package/resources/templates/default/admin/lib/editor/common/elements/OrderedListRenderer.tsx +1 -1
  103. package/resources/templates/default/admin/lib/editor/common/elements/TableElementRenderer.tsx +1 -1
  104. package/resources/templates/default/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +1 -1
  105. package/resources/templates/default/admin/lib/editor/common/index.ts +6 -6
  106. package/resources/templates/default/admin/lib/editor/editor-block.tsx +54 -3
  107. package/resources/templates/default/admin/lib/editor/index.ts +6 -6
  108. package/resources/templates/default/admin/lib/editor/plugins.tsx +46 -2
  109. package/resources/templates/default/admin/lib/editor/rich-text-view.tsx +44 -0
  110. package/resources/templates/default/admin/lib/editor/rich-text.tsx +31 -3
  111. package/resources/templates/default/admin/lib/editor/sortable-block.tsx +34 -2
  112. package/resources/templates/default/admin/lib/errors/index.ts +1 -1
  113. package/resources/templates/default/admin/lib/errors/use-error-formatter.ts +22 -1
  114. package/resources/templates/default/admin/lib/field/formatted-field.tsx +16 -1
  115. package/resources/templates/default/admin/lib/field/index.ts +2 -1
  116. package/resources/templates/default/admin/lib/field/list-field.tsx +56 -0
  117. package/resources/templates/default/admin/lib/form/container.tsx +33 -3
  118. package/resources/templates/default/admin/lib/form/index.ts +6 -5
  119. package/resources/templates/default/admin/lib/form/inputs.tsx +105 -6
  120. package/resources/templates/default/admin/lib/form/labels.tsx +1 -1
  121. package/resources/templates/default/admin/lib/form/select.tsx +162 -5
  122. package/resources/templates/default/admin/lib/form/ui.tsx +2 -2
  123. package/resources/templates/default/admin/lib/form/upload-repeaters.tsx +159 -5
  124. package/resources/templates/default/admin/lib/form/upload.tsx +116 -3
  125. package/resources/templates/default/admin/lib/formatting/formatting.ts +106 -1
  126. package/resources/templates/default/admin/lib/formatting/index.ts +1 -1
  127. package/resources/templates/default/admin/lib/images/formatImageResizeUrl.ts +19 -0
  128. package/resources/templates/default/admin/lib/images/index.ts +1 -1
  129. package/resources/templates/default/admin/lib/index.ts +54 -0
  130. package/resources/templates/default/admin/lib/labels/index.ts +2 -2
  131. package/resources/templates/default/admin/lib/layout/index.ts +3 -3
  132. package/resources/templates/default/admin/lib/layout/layout-boxed.tsx +5 -5
  133. package/resources/templates/default/admin/lib/layout/layout.tsx +3 -3
  134. package/resources/templates/default/admin/lib/outdated-application-dialog/index.ts +1 -1
  135. package/resources/templates/default/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +2 -2
  136. package/resources/templates/default/admin/lib/repeater/index.ts +1 -1
  137. package/resources/templates/default/admin/lib/repeater/repeater.tsx +26 -9
  138. package/resources/templates/default/admin/lib/select/create-new.tsx +19 -3
  139. package/resources/templates/default/admin/lib/select/filter.tsx +8 -2
  140. package/resources/templates/default/admin/lib/select/highlight.tsx +16 -0
  141. package/resources/templates/default/admin/lib/select/index.ts +6 -6
  142. package/resources/templates/default/admin/lib/select/list.tsx +30 -6
  143. package/resources/templates/default/admin/lib/select/multi-select.tsx +41 -4
  144. package/resources/templates/default/admin/lib/select/select.tsx +44 -6
  145. package/resources/templates/default/admin/lib/select/sortable-select.tsx +15 -6
  146. package/resources/templates/default/admin/lib/select/ui.tsx +100 -4
  147. package/resources/templates/default/admin/lib/tenant/dict.ts +324 -0
  148. package/resources/templates/default/admin/lib/tenant/forms/change-my-password.tsx +4 -4
  149. package/resources/templates/default/admin/lib/tenant/forms/common.tsx +3 -3
  150. package/resources/templates/default/admin/lib/tenant/forms/confirm-email-change.tsx +38 -0
  151. package/resources/templates/default/admin/lib/tenant/forms/create-api-key.tsx +5 -5
  152. package/resources/templates/default/admin/lib/tenant/forms/index.ts +12 -8
  153. package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +5 -5
  154. package/resources/templates/default/admin/lib/tenant/forms/login.tsx +4 -4
  155. package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +4 -4
  156. package/resources/templates/default/admin/lib/tenant/forms/password-reset-request.tsx +4 -4
  157. package/resources/templates/default/admin/lib/tenant/forms/password-reset.tsx +4 -4
  158. package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin-init.tsx +4 -4
  159. package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +4 -4
  160. package/resources/templates/default/admin/lib/tenant/forms/request-email-verification.tsx +35 -0
  161. package/resources/templates/default/admin/lib/tenant/forms/update-project-member.tsx +14 -5
  162. package/resources/templates/default/admin/lib/tenant/forms/verify-email.tsx +38 -0
  163. package/resources/templates/default/admin/lib/tenant/hooks/useInvite.ts +41 -0
  164. package/resources/templates/default/admin/lib/tenant/hooks/useInviteUser.tsx +32 -3
  165. package/resources/templates/default/admin/lib/tenant/index.ts +3 -3
  166. package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +3 -3
  167. package/resources/templates/default/admin/lib/tenant/listing/index.ts +4 -4
  168. package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +3 -3
  169. package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +8 -8
  170. package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +4 -4
  171. package/resources/templates/default/admin/lib/tenant/otp/index.ts +1 -1
  172. package/resources/templates/default/admin/lib/tenant/otp/otp-setup.tsx +6 -6
  173. package/resources/templates/default/admin/lib/toast/index.ts +2 -2
  174. package/resources/templates/default/admin/lib/toast/toast.tsx +3 -3
  175. package/resources/templates/default/admin/lib/ui/alert-dialog.tsx +114 -3
  176. package/resources/templates/default/admin/lib/ui/avatar.tsx +1 -1
  177. package/resources/templates/default/admin/lib/ui/button.tsx +1 -1
  178. package/resources/templates/default/admin/lib/ui/card.tsx +1 -1
  179. package/resources/templates/default/admin/lib/ui/collapsible.tsx +1 -1
  180. package/resources/templates/default/admin/lib/ui/dialog.tsx +2 -2
  181. package/resources/templates/default/admin/lib/ui/dimension.tsx +1 -1
  182. package/resources/templates/default/admin/lib/ui/divider.tsx +1 -1
  183. package/resources/templates/default/admin/lib/ui/dropdown.tsx +3 -3
  184. package/resources/templates/default/admin/lib/ui/input.tsx +1 -1
  185. package/resources/templates/default/admin/lib/ui/label.tsx +1 -1
  186. package/resources/templates/default/admin/lib/ui/loader.tsx +2 -2
  187. package/resources/templates/default/admin/lib/ui/menu.tsx +2 -2
  188. package/resources/templates/default/admin/lib/ui/overlay.tsx +1 -1
  189. package/resources/templates/default/admin/lib/ui/popover.tsx +2 -2
  190. package/resources/templates/default/admin/lib/ui/progress.tsx +1 -1
  191. package/resources/templates/default/admin/lib/ui/property-list.tsx +1 -1
  192. package/resources/templates/default/admin/lib/ui/scroll-area.tsx +1 -1
  193. package/resources/templates/default/admin/lib/ui/select.tsx +44 -2
  194. package/resources/templates/default/admin/lib/ui/separator.tsx +1 -1
  195. package/resources/templates/default/admin/lib/ui/sheet.tsx +2 -2
  196. package/resources/templates/default/admin/lib/ui/sidebar.tsx +8 -8
  197. package/resources/templates/default/admin/lib/ui/skeleton.tsx +1 -1
  198. package/resources/templates/default/admin/lib/ui/sortable.tsx +1 -1
  199. package/resources/templates/default/admin/lib/ui/switch.tsx +1 -1
  200. package/resources/templates/default/admin/lib/ui/table.tsx +1 -1
  201. package/resources/templates/default/admin/lib/ui/textarea.tsx +1 -1
  202. package/resources/templates/default/admin/lib/ui/toggle-group.tsx +2 -2
  203. package/resources/templates/default/admin/lib/ui/toggle.tsx +1 -1
  204. package/resources/templates/default/admin/lib/ui/tooltip.tsx +2 -2
  205. package/resources/templates/default/admin/lib/upload/dropzone.tsx +20 -3
  206. package/resources/templates/default/admin/lib/upload/index.ts +3 -3
  207. package/resources/templates/default/admin/lib/upload/repeater.tsx +5 -1
  208. package/resources/templates/default/admin/lib/upload/ui.tsx +2 -2
  209. package/resources/templates/default/admin/lib/upload/upload-progress.tsx +6 -6
  210. package/resources/templates/default/admin/lib/upload/view.tsx +4 -4
  211. package/resources/templates/default/admin/lib/utils/cn.ts +18 -0
  212. package/resources/templates/default/admin/lib/utils/createComponentOpenHooks.tsx +33 -0
  213. package/resources/templates/default/admin/lib/utils/index.ts +2 -2
  214. package/resources/templates/default/admin/lib/utils/uic.tsx +59 -0
  215. package/resources/templates/default/admin/lib/utils/use-mobile.ts +19 -0
  216. package/resources/templates/default/scripts/assemble-ui-lib.mjs +132 -0
  217. package/resources/templates/default/scripts/update-ui-lib.sh +101 -185
  218. package/src/commands/WorkspaceCreateCommand.ts +3 -3
  219. package/src/commands/index.ts +1 -1
  220. package/src/lib/FileSystem.ts +2 -2
  221. package/src/lib/TemplateInstaller.ts +1 -1
  222. package/src/lib/version.ts +1 -1
  223. package/src/run.ts +4 -4
@@ -3,26 +3,37 @@ set -euo pipefail
3
3
 
4
4
  ### Default Configuration ###
5
5
  TEMPLATE_REPO_URL="git@github.com:contember/contember.git" # Template repository URL
6
- TEMPLATE_DIR="packages/react-ui-lib/src" # Directory to filter from template repo
6
+ PACKAGES_SUBDIR="packages" # Where the UI-lib packages live in the repo
7
7
  OLD_COMMIT="9fc76ce46eb9d9196a88eeb01c7305b182dde7dd" # Default base commit or tag
8
8
  NEW_COMMIT="main" # Default branch or commit with latest changes
9
- TARGET_DIR="admin/lib" # Directory to map the filtered content into
10
- CLONE_DIR=".tmp-ui-lib-update" # Temporary clone directory
9
+ TARGET_DIR="admin/lib" # Directory to map the assembled content into
10
+ CLONE_DIR=".tmp-ui-lib-update" # Temporary clone directory (source packages)
11
+ BUILD_DIR=".tmp-ui-lib-build" # Temporary git repo holding the assembled lib
11
12
  REMOTE_NAME="ui-lib-update-temp" # Temporary remote name
12
13
  COMMIT_FILE="$TARGET_DIR/COMMIT" # File to store the new commit hash
13
14
  FORCE_MODE=false # Default to non-force mode
14
15
  ### End Default Configuration ###
15
16
 
17
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18
+ ASSEMBLE="$SCRIPT_DIR/assemble-ui-lib.mjs"
19
+
20
+ # The UI lib is assembled from these packages (base + tenant + the high-level lib).
21
+ # Older revisions only had the single react-ui-lib package; assemble-ui-lib.mjs
22
+ # detects that and falls back to the legacy single-package layout.
23
+ UI_LIB_PACKAGES=("react-ui-lib" "react-ui-lib-base" "react-ui-lib-tenant")
24
+
16
25
  # Function to show help message
17
26
  show_help() {
18
27
  echo "Usage: $0 [options]"
19
28
  echo ""
29
+ echo "Updates admin/lib by assembling the Contember UI-lib packages and"
30
+ echo "cherry-picking the upstream changes onto your (possibly customised) copy."
31
+ echo ""
20
32
  echo "Options:"
21
33
  echo " --force Replace target directory without cherry-picking"
22
34
  echo " --from COMMIT Specify base commit, tag, or branch (default: from COMMIT file or $OLD_COMMIT)"
23
35
  echo " --to COMMIT Specify target commit, tag, or branch (default: $NEW_COMMIT)"
24
36
  echo " --repo URL Specify template repository URL (default: $TEMPLATE_REPO_URL)"
25
- echo " --template-dir DIR Specify template directory within repo (default: $TEMPLATE_DIR)"
26
37
  echo " --target-dir DIR Specify target directory in this project (default: $TARGET_DIR)"
27
38
  echo " --help Show this help message"
28
39
  echo ""
@@ -63,14 +74,6 @@ while [[ $# -gt 0 ]]; do
63
74
  TEMPLATE_REPO_URL="$2"
64
75
  shift 2
65
76
  ;;
66
- --template-dir)
67
- if [ -z "${2:-}" ]; then
68
- echo "Error: --template-dir requires a directory path"
69
- exit 1
70
- fi
71
- TEMPLATE_DIR="$2"
72
- shift 2
73
- ;;
74
77
  --target-dir)
75
78
  if [ -z "${2:-}" ]; then
76
79
  echo "Error: --target-dir requires a directory path"
@@ -92,15 +95,20 @@ while [[ $# -gt 0 ]]; do
92
95
  esac
93
96
  done
94
97
 
98
+ if [ ! -f "$ASSEMBLE" ]; then
99
+ echo "Error: assembler not found at $ASSEMBLE"
100
+ echo "Make sure scripts/assemble-ui-lib.mjs is present (it ships next to this script)."
101
+ exit 1
102
+ fi
103
+
95
104
  echo "Running in $([ "$FORCE_MODE" = true ] && echo "FORCE" || echo "normal") mode"
96
105
  echo "Using repository: $TEMPLATE_REPO_URL"
97
- echo "Template directory: $TEMPLATE_DIR"
98
106
  echo "Target directory: $TARGET_DIR"
99
107
 
100
108
  # Ensure cleanup on exit
101
109
  cleanup() {
102
110
  echo "Cleaning up temporary files..."
103
- rm -rf "$CLONE_DIR"
111
+ rm -rf "$CLONE_DIR" "$BUILD_DIR"
104
112
  git remote remove "$REMOTE_NAME" 2>/dev/null || true
105
113
  }
106
114
  trap cleanup EXIT
@@ -120,68 +128,50 @@ fi
120
128
  echo "Updating from: $OLD_COMMIT"
121
129
  echo "Updating to: $NEW_COMMIT"
122
130
 
123
- # Step 1: Clone the template repository with sparse checkout
131
+ # Step 1: Clone the template repository with sparse checkout of the UI-lib package sources
124
132
  echo "Cloning the template repository into $CLONE_DIR..."
125
133
  rm -rf "$CLONE_DIR"
126
134
  mkdir -p "$CLONE_DIR"
127
- cd "$CLONE_DIR"
128
- git init --quiet
129
- git remote add origin "$TEMPLATE_REPO_URL"
130
-
131
- echo "Configuring sparse checkout for $TEMPLATE_DIR..."
132
- git sparse-checkout init --cone
133
- git sparse-checkout set "$TEMPLATE_DIR"
134
-
135
- # Step 2: Fetch specific references more efficiently
136
- echo "Fetching specific references..."
137
-
138
- # Check if inputs look like tags (starting with 'v' is a common convention)
139
- if [[ "$OLD_COMMIT" =~ ^v[0-9] ]] || [[ "$NEW_COMMIT" =~ ^v[0-9] ]]; then
140
- # If either reference looks like a tag, fetch only the specific tags needed
141
- if [[ "$OLD_COMMIT" =~ ^v[0-9] ]]; then
142
- echo "Fetching tag: $OLD_COMMIT"
143
- git fetch origin "refs/tags/$OLD_COMMIT:refs/tags/$OLD_COMMIT" --depth=1
144
- else
145
- echo "Fetching commit/branch: $OLD_COMMIT"
146
- git fetch origin "$OLD_COMMIT" --depth=1
147
- fi
148
-
149
- if [[ "$NEW_COMMIT" =~ ^v[0-9] ]]; then
150
- echo "Fetching tag: $NEW_COMMIT"
151
- git fetch origin "refs/tags/$NEW_COMMIT:refs/tags/$NEW_COMMIT" --depth=1
135
+ (
136
+ cd "$CLONE_DIR"
137
+ git init --quiet
138
+ git remote add origin "$TEMPLATE_REPO_URL"
139
+ git sparse-checkout init --cone
140
+ SPARSE_PATHS=()
141
+ for pkg in "${UI_LIB_PACKAGES[@]}"; do
142
+ SPARSE_PATHS+=("$PACKAGES_SUBDIR/$pkg/src")
143
+ done
144
+ git sparse-checkout set "${SPARSE_PATHS[@]}"
145
+ )
146
+
147
+ # Step 2: Fetch the references
148
+ fetch_ref() {
149
+ local ref="$1"
150
+ if [[ "$ref" =~ ^v[0-9] ]]; then
151
+ echo "Fetching tag: $ref"
152
+ git -C "$CLONE_DIR" fetch origin "refs/tags/$ref:refs/tags/$ref" --depth=1
152
153
  else
153
- echo "Fetching commit/branch: $NEW_COMMIT"
154
- git fetch origin "$NEW_COMMIT" --depth=1
154
+ echo "Fetching commit/branch: $ref"
155
+ git -C "$CLONE_DIR" fetch origin "$ref" --depth=1
155
156
  fi
156
- else
157
- # If they don't look like tags, just fetch them directly
158
- echo "Fetching commits/branches: $OLD_COMMIT and $NEW_COMMIT"
159
- git fetch origin "$OLD_COMMIT" "$NEW_COMMIT" --depth=1
160
- fi
157
+ }
158
+ fetch_ref "$OLD_COMMIT"
159
+ fetch_ref "$NEW_COMMIT"
161
160
 
162
161
  # Step 3: Resolve the references to actual commit hashes
163
- echo "Resolving commit references..."
164
-
165
- # Function to resolve a reference to a commit hash
166
162
  resolve_ref() {
167
- local ref=$1
168
- local hash
169
-
170
- # Try different ways to resolve the reference
171
- if hash=$(git rev-parse --quiet --verify "$ref" 2>/dev/null); then
163
+ local ref="$1" hash
164
+ if hash=$(git -C "$CLONE_DIR" rev-parse --quiet --verify "$ref" 2>/dev/null); then
172
165
  echo "$hash"
173
- elif hash=$(git rev-parse --quiet --verify "origin/$ref" 2>/dev/null); then
166
+ elif hash=$(git -C "$CLONE_DIR" rev-parse --quiet --verify "origin/$ref" 2>/dev/null); then
174
167
  echo "$hash"
175
- elif [[ "$ref" =~ ^v[0-9] ]] && hash=$(git rev-parse --quiet --verify "refs/tags/$ref" 2>/dev/null); then
168
+ elif [[ "$ref" =~ ^v[0-9] ]] && hash=$(git -C "$CLONE_DIR" rev-parse --quiet --verify "refs/tags/$ref" 2>/dev/null); then
176
169
  echo "$hash"
177
170
  else
178
- # If we still can't resolve it, try to fetch it directly as a tag
179
- git fetch origin "refs/tags/$ref:refs/tags/$ref" --depth=1 2>/dev/null || true
180
-
181
- if hash=$(git rev-parse --quiet --verify "refs/tags/$ref" 2>/dev/null); then
171
+ git -C "$CLONE_DIR" fetch origin "refs/tags/$ref:refs/tags/$ref" --depth=1 2>/dev/null || true
172
+ if hash=$(git -C "$CLONE_DIR" rev-parse --quiet --verify "refs/tags/$ref" 2>/dev/null); then
182
173
  echo "$hash"
183
174
  else
184
- # If all else fails, return the input (might be a direct hash)
185
175
  echo "$ref"
186
176
  fi
187
177
  fi
@@ -189,154 +179,80 @@ resolve_ref() {
189
179
 
190
180
  OLD_COMMIT_HASH=$(resolve_ref "$OLD_COMMIT")
191
181
  NEW_COMMIT_HASH=$(resolve_ref "$NEW_COMMIT")
192
-
193
182
  echo "Resolved OLD_COMMIT to: $OLD_COMMIT_HASH"
194
183
  echo "Resolved NEW_COMMIT to: $NEW_COMMIT_HASH"
184
+ NEW_COMMIT_REF="$NEW_COMMIT_HASH"
185
+
186
+ # Helper: check out the UI-lib package sources at a given commit into CLONE_DIR
187
+ checkout_packages() {
188
+ local commit="$1"
189
+ rm -rf "${CLONE_DIR:?}/$PACKAGES_SUBDIR"
190
+ for pkg in "${UI_LIB_PACKAGES[@]}"; do
191
+ local path="$PACKAGES_SUBDIR/$pkg/src"
192
+ if git -C "$CLONE_DIR" cat-file -e "$commit:$path" 2>/dev/null; then
193
+ git -C "$CLONE_DIR" checkout -q "$commit" -- "$path"
194
+ fi
195
+ done
196
+ }
195
197
 
196
- # Step 4: Check out the resolved commits
197
- echo "Checking out the old code..."
198
- if ! git checkout "$OLD_COMMIT_HASH" -- "$TEMPLATE_DIR"; then
199
- echo "Error: Failed to checkout $OLD_COMMIT_HASH"
200
- exit 1
201
- fi
202
-
203
- # Try formatting, but don't fail if biome is not available or nothing changes
204
- if command -v biome &> /dev/null; then
205
- echo "Formatting code with biome..."
206
- biome check --write "$TEMPLATE_DIR" 2>/dev/null || true
207
-
208
- # Only commit if there are actual changes
209
- if [[ -n $(git status --porcelain "$TEMPLATE_DIR") ]]; then
210
- git add "$TEMPLATE_DIR"
211
- git commit -m "Format code base at $OLD_COMMIT"
212
- FORMAT_COMMIT=$(git rev-parse HEAD)
213
- echo "Formatting commit created: $FORMAT_COMMIT"
214
- else
215
- echo "No formatting changes detected, using $OLD_COMMIT_HASH directly"
216
- FORMAT_COMMIT=$OLD_COMMIT_HASH
198
+ # Helper: assemble admin/lib for a given commit into an absolute output directory
199
+ assemble_at() {
200
+ local commit="$1" out="$2"
201
+ checkout_packages "$commit"
202
+ node "$ASSEMBLE" --packages-dir "$PWD/$CLONE_DIR/$PACKAGES_SUBDIR" --target "$out"
203
+ if command -v biome &>/dev/null; then
204
+ biome check --write "$out" >/dev/null 2>&1 || true
217
205
  fi
218
- else
219
- echo "Biome not found, skipping formatting step"
220
- FORMAT_COMMIT=$OLD_COMMIT_HASH
221
- fi
222
-
223
- # Step 5: Checkout the new commit
224
- echo "Checking out the new code..."
225
- if ! git checkout "$NEW_COMMIT_HASH" -- "$TEMPLATE_DIR"; then
226
- echo "Error: Failed to checkout $NEW_COMMIT_HASH"
227
- exit 1
228
- fi
229
-
230
- # Capture the actual commit hash of the new commit for the COMMIT file
231
- NEW_COMMIT_REF=$NEW_COMMIT_HASH
232
- echo "New commit reference: $NEW_COMMIT_REF"
233
-
234
- # Step 6: Reset and stage only the sparse directory
235
- echo "Preparing changes..."
236
- git reset "$FORMAT_COMMIT" -- "$TEMPLATE_DIR"
206
+ }
237
207
 
238
- # Format new code if biome is available
239
- if command -v biome &> /dev/null; then
240
- echo "Formatting new code with biome..."
241
- biome check --write "$TEMPLATE_DIR" 2>/dev/null || true
242
- fi
208
+ # Step 4: Build a temporary git repo with two commits: assembled OLD, then assembled NEW.
209
+ echo "Assembling UI lib for both revisions..."
210
+ rm -rf "$BUILD_DIR"
211
+ mkdir -p "$BUILD_DIR/$(dirname "$TARGET_DIR")"
212
+ git -C "$BUILD_DIR" init --quiet
213
+ git -C "$BUILD_DIR" config user.email "noreply@contember.com"
214
+ git -C "$BUILD_DIR" config user.name "Contember UI lib update"
243
215
 
244
- git add "$TEMPLATE_DIR" # Stage only the files in the sparse directory
216
+ assemble_at "$OLD_COMMIT_HASH" "$PWD/$BUILD_DIR/$TARGET_DIR"
217
+ git -C "$BUILD_DIR" add -A
218
+ git -C "$BUILD_DIR" commit -q --allow-empty -m "UI lib at $OLD_COMMIT"
245
219
 
246
- # Step 7: Create the squashed commit
247
- echo "Creating a commit with changes..."
220
+ rm -rf "${BUILD_DIR:?}/$TARGET_DIR"
221
+ assemble_at "$NEW_COMMIT_HASH" "$PWD/$BUILD_DIR/$TARGET_DIR"
222
+ git -C "$BUILD_DIR" add -A
248
223
 
249
- # Only commit if there are actual changes
250
- if [[ -n $(git status --porcelain "$TEMPLATE_DIR") ]]; then
251
- git commit -m "Update UI lib to $NEW_COMMIT"
252
- else
253
- echo "No changes detected between $OLD_COMMIT and $NEW_COMMIT in $TEMPLATE_DIR"
224
+ if git -C "$BUILD_DIR" diff --cached --quiet; then
225
+ echo "No changes detected between $OLD_COMMIT and $NEW_COMMIT in $TARGET_DIR"
254
226
  exit 0
255
227
  fi
228
+ git -C "$BUILD_DIR" commit -q -m "Update UI lib to $NEW_COMMIT"
229
+ SQUASHED_COMMIT=$(git -C "$BUILD_DIR" rev-parse HEAD)
230
+ echo "Assembled change commit: $SQUASHED_COMMIT"
256
231
 
257
- # Capture the squashed commit hash for normal mode
258
- SQUASHED_COMMIT=$(git rev-parse HEAD)
259
- echo "Commit created: $SQUASHED_COMMIT"
260
-
261
- # Return to the main repository
262
- cd - # Return to the main repository
263
-
232
+ # Step 5: Apply the change to the current project
264
233
  if [ "$FORCE_MODE" = true ]; then
265
- # FORCE MODE: directly replace the target directory
266
234
  echo "Force mode: directly replacing $TARGET_DIR..."
267
-
268
- # Remove the target directory if it exists
269
- if [ -d "$TARGET_DIR" ]; then
270
- echo "Removing existing $TARGET_DIR directory"
271
- rm -rf "$TARGET_DIR"
272
- fi
273
-
274
- # Create target parent directory if needed
235
+ rm -rf "$TARGET_DIR"
275
236
  mkdir -p "$(dirname "$TARGET_DIR")"
276
-
277
- # Copy files directly from source template directory in temporary repo
278
- echo "Copying new files from template to target directory"
279
- cp -r "$CLONE_DIR/$TEMPLATE_DIR" "$TARGET_DIR"
280
-
281
- # Remove files that should not be included
282
- if [ -f "$TARGET_DIR/index.ts" ]; then
283
- echo "Removing $TARGET_DIR/index.ts"
284
- rm "$TARGET_DIR/index.ts"
285
- fi
286
- if [ -f "$TARGET_DIR/tsconfig.json" ]; then
287
- echo "Removing $TARGET_DIR/tsconfig.json"
288
- rm "$TARGET_DIR/tsconfig.json"
289
- fi
290
-
291
- # Write the new commit hash to the COMMIT file
292
- echo "Writing new commit reference to $COMMIT_FILE"
237
+ cp -r "$BUILD_DIR/$TARGET_DIR" "$TARGET_DIR"
293
238
  echo "$NEW_COMMIT_REF" > "$COMMIT_FILE"
294
-
295
- echo "Force update complete. You'll need to manually add and commit the changes."
296
- echo "To review and commit changes: git add $TARGET_DIR && git commit -m \"Update UI lib to $NEW_COMMIT\""
239
+ echo "Force update complete. Review and commit the changes:"
240
+ echo " git add $TARGET_DIR && git commit -m \"Update UI lib to $NEW_COMMIT\""
297
241
  else
298
- # NORMAL MODE: first perform the directory move in the temp repo
299
- echo "Moving files in temporary repository..."
300
- cd "$CLONE_DIR"
301
- mkdir -p "$(dirname "$TARGET_DIR")"
302
- cp -r "$TEMPLATE_DIR" "$TARGET_DIR"
303
-
304
- # Remove files that should not be included
305
- if [ -f "$TARGET_DIR/index.ts" ]; then
306
- rm "$TARGET_DIR/index.ts"
307
- fi
308
- if [ -f "$TARGET_DIR/tsconfig.json" ]; then
309
- rm "$TARGET_DIR/tsconfig.json"
310
- fi
311
-
312
- # Add the changes
313
- git add "$TARGET_DIR"
314
- git commit --amend --no-edit
315
-
316
- # Update the squashed commit reference
317
- SQUASHED_COMMIT=$(git rev-parse HEAD)
318
- cd - # Return to main repository
319
-
320
- # NORMAL MODE: use cherry-pick to merge changes
321
- echo "Adding the temporary repository as a remote to the main repository..."
242
+ echo "Cherry-picking the assembled change onto $TARGET_DIR..."
322
243
  git remote remove "$REMOTE_NAME" 2>/dev/null || true
323
- git remote add "$REMOTE_NAME" "file://$PWD/$CLONE_DIR"
244
+ git remote add "$REMOTE_NAME" "file://$PWD/$BUILD_DIR"
324
245
  git fetch "$REMOTE_NAME" "$SQUASHED_COMMIT"
325
246
 
326
- # Cherry-pick the squashed commit
327
- echo "Cherry-picking the squashed commit into the current branch..."
328
247
  if git cherry-pick "$SQUASHED_COMMIT" --no-commit; then
329
248
  echo "Cherry-pick completed successfully."
330
249
  else
331
- echo "Cherry-pick encountered conflicts. Please resolve them and run:"
332
- echo " git cherry-pick --continue"
250
+ echo "Cherry-pick encountered conflicts. Please resolve them, then run:"
251
+ echo " git cherry-pick --continue (or stage the resolved files)"
252
+ echo "$NEW_COMMIT_REF" > "$COMMIT_FILE"
333
253
  exit 1
334
254
  fi
335
-
336
- # Write the new commit hash to admin/lib/COMMIT
337
- echo "Writing new commit reference to $COMMIT_FILE"
338
255
  echo "$NEW_COMMIT_REF" > "$COMMIT_FILE"
339
-
340
256
  echo "Process completed successfully. Review the changes and commit them."
341
257
  fi
342
258
 
@@ -1,9 +1,9 @@
1
1
  import { Command, CommandConfiguration, Input } from '@contember/cli-common'
2
2
  import { join } from 'node:path'
3
3
  import chalk from 'chalk'
4
- import { TemplateInstaller } from '../lib/TemplateInstaller'
5
- import { getPackageVersion } from '../lib/version'
6
- import { detectPackageManager } from '../lib/packageManagerDetector'
4
+ import { TemplateInstaller } from '../lib/TemplateInstaller.js'
5
+ import { getPackageVersion } from '../lib/version.js'
6
+ import { detectPackageManager } from '../lib/packageManagerDetector.js'
7
7
 
8
8
  type Args = {
9
9
  projectName: string
@@ -1 +1 @@
1
- export * from './WorkspaceCreateCommand'
1
+ export * from './WorkspaceCreateCommand.js'
@@ -1,6 +1,5 @@
1
1
  import * as fs from 'node:fs/promises'
2
2
  import { access } from 'node:fs/promises'
3
- import { copy } from 'fs-extra'
4
3
  import { tmpdir } from 'node:os'
5
4
 
6
5
  export class FileSystem {
@@ -8,7 +7,8 @@ export class FileSystem {
8
7
  writeFile = fs.writeFile
9
8
  rename = fs.rename
10
9
  readDir = fs.readdir
11
- copy = copy
10
+ copy = (source: string, destination: string, options?: { filter?: (source: string, destination: string) => boolean }) =>
11
+ fs.cp(source, destination, { recursive: true, ...options })
12
12
  unlink = fs.unlink
13
13
  remove = fs.rm
14
14
  pathExists = async (path: string) => {
@@ -1,5 +1,5 @@
1
1
  import { join } from 'node:path'
2
- import { FileSystem } from './FileSystem'
2
+ import { FileSystem } from './FileSystem.js'
3
3
  import jsyaml from 'js-yaml'
4
4
  import degit from 'degit'
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path'
2
2
  import fs from 'node:fs/promises'
3
- import { packageRoot } from '../paths'
3
+ import { packageRoot } from '../paths.js'
4
4
 
5
5
  export const getPackageVersion = async () => {
6
6
  return JSON.parse(await fs.readFile(join(packageRoot, 'package.json'), 'utf-8')).version
package/src/run.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { Application, CommandManager } from '@contember/cli-common'
3
- import { WorkspaceCreateCommand } from './commands'
4
- import { TemplateInstaller } from './lib/TemplateInstaller'
5
- import { resourcesDir } from './paths'
6
- import { FileSystem } from './lib/FileSystem'
3
+ import { WorkspaceCreateCommand } from './commands/index.js'
4
+ import { TemplateInstaller } from './lib/TemplateInstaller.js'
5
+ import { resourcesDir } from './paths.js'
6
+ import { FileSystem } from './lib/FileSystem.js'
7
7
  ;(async () => {
8
8
  const commandManager = new CommandManager({
9
9
  ['workspace']: () =>