@contember/create 2.1.0-rc.3 → 2.2.0-alpha.10
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.
- package/CLAUDE.md +22 -0
- package/dist/development/run.cjs +7 -7
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +8 -8
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/FileSystem.cjs +1 -2
- package/dist/development/src/lib/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/FileSystem.js +1 -2
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +79 -67
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +72 -60
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/development/src/lib/version.cjs +2 -2
- package/dist/development/src/lib/version.cjs.map +1 -1
- package/dist/development/src/lib/version.js.map +1 -1
- package/dist/development/src/paths.cjs +3 -3
- package/dist/development/src/paths.cjs.map +1 -1
- package/dist/production/run.cjs +7 -7
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +8 -8
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/FileSystem.cjs +1 -2
- package/dist/production/src/lib/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/FileSystem.js +1 -2
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +79 -67
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +72 -60
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/production/src/lib/version.cjs +2 -2
- package/dist/production/src/lib/version.cjs.map +1 -1
- package/dist/production/src/lib/version.js.map +1 -1
- package/dist/production/src/paths.cjs +3 -3
- package/dist/production/src/paths.cjs.map +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +16 -4
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/index.d.ts.map +1 -1
- package/dist/types/lib/FileSystem.d.ts +3 -2
- package/dist/types/lib/FileSystem.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +10 -2
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/resources/templates/default/README.md +3 -1
- package/resources/templates/default/admin/app/components/navigation.tsx +95 -8
- package/resources/templates/default/admin/app/pages/tenant.tsx +328 -77
- package/resources/templates/default/admin/entrypoint/components/login.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLinkSent.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +1 -1
- package/resources/templates/default/admin/lib/binding/binding.tsx +19 -4
- package/resources/templates/default/admin/lib/binding/delete.tsx +37 -3
- package/resources/templates/default/admin/lib/binding/hooks.tsx +65 -3
- package/resources/templates/default/admin/lib/binding/identity.tsx +17 -4
- package/resources/templates/default/admin/lib/binding/index.ts +5 -5
- package/resources/templates/default/admin/lib/binding/navigation-guard-dialog.tsx +15 -3
- package/resources/templates/default/admin/lib/binding/persist.tsx +27 -5
- package/resources/templates/default/admin/lib/block-repeater/block-repeater.tsx +15 -11
- package/resources/templates/default/admin/lib/block-repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/board/board.tsx +2 -2
- package/resources/templates/default/admin/lib/board/index.ts +1 -1
- package/resources/templates/default/admin/lib/buttons/back-button.tsx +22 -2
- package/resources/templates/default/admin/lib/buttons/index.ts +2 -2
- package/resources/templates/default/admin/lib/buttons/link-back-button.tsx +11 -2
- package/resources/templates/default/admin/lib/datagrid/cells.tsx +3 -3
- package/resources/templates/default/admin/lib/datagrid/column-header.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/columns.tsx +28 -14
- package/resources/templates/default/admin/lib/datagrid/elements.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/empty.tsx +1 -1
- package/resources/templates/default/admin/lib/datagrid/export.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/boolean.tsx +13 -13
- package/resources/templates/default/admin/lib/datagrid/filters/common.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/date.tsx +37 -16
- package/resources/templates/default/admin/lib/datagrid/filters/defined.tsx +13 -12
- package/resources/templates/default/admin/lib/datagrid/filters/enum.tsx +56 -22
- package/resources/templates/default/admin/lib/datagrid/filters/index.ts +7 -7
- package/resources/templates/default/admin/lib/datagrid/filters/mobile.tsx +18 -0
- package/resources/templates/default/admin/lib/datagrid/filters/number.tsx +10 -13
- package/resources/templates/default/admin/lib/datagrid/filters/relation.tsx +8 -8
- package/resources/templates/default/admin/lib/datagrid/filters/text.tsx +9 -9
- package/resources/templates/default/admin/lib/datagrid/grid.tsx +31 -23
- package/resources/templates/default/admin/lib/datagrid/index.ts +12 -12
- package/resources/templates/default/admin/lib/datagrid/labels.tsx +22 -4
- package/resources/templates/default/admin/lib/datagrid/layout-switcher.tsx +10 -4
- package/resources/templates/default/admin/lib/datagrid/loader.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/pagination.tsx +16 -6
- package/resources/templates/default/admin/lib/datagrid/table.tsx +8 -6
- package/resources/templates/default/admin/lib/datagrid/tiles.tsx +6 -5
- package/resources/templates/default/admin/lib/datagrid/toolbar.tsx +15 -19
- package/resources/templates/default/admin/lib/datagrid/ui.tsx +3 -3
- package/resources/templates/default/admin/lib/dev/index.ts +2 -2
- package/resources/templates/default/admin/lib/dev/login-panel.tsx +12 -3
- package/resources/templates/default/admin/lib/dev/todo.tsx +12 -0
- package/resources/templates/default/admin/lib/dict.ts +0 -261
- package/resources/templates/default/admin/lib/dimensions/dimensions.tsx +85 -4
- package/resources/templates/default/admin/lib/dimensions/index.ts +1 -1
- package/resources/templates/default/admin/lib/editor/block-editor.tsx +72 -3
- package/resources/templates/default/admin/lib/editor/common/baseEditorPlugins.tsx +54 -11
- package/resources/templates/default/admin/lib/editor/common/buttons.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/editor-block-toolbar.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HeadingRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/ListItemRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/OrderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/TableElementRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/editor-block.tsx +54 -3
- package/resources/templates/default/admin/lib/editor/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/plugins.tsx +46 -2
- package/resources/templates/default/admin/lib/editor/rich-text-view.tsx +44 -0
- package/resources/templates/default/admin/lib/editor/rich-text.tsx +31 -3
- package/resources/templates/default/admin/lib/editor/sortable-block.tsx +34 -2
- package/resources/templates/default/admin/lib/errors/index.ts +1 -1
- package/resources/templates/default/admin/lib/errors/use-error-formatter.ts +22 -1
- package/resources/templates/default/admin/lib/field/formatted-field.tsx +16 -1
- package/resources/templates/default/admin/lib/field/index.ts +2 -1
- package/resources/templates/default/admin/lib/field/list-field.tsx +56 -0
- package/resources/templates/default/admin/lib/form/container.tsx +33 -3
- package/resources/templates/default/admin/lib/form/index.ts +6 -5
- package/resources/templates/default/admin/lib/form/inputs.tsx +105 -6
- package/resources/templates/default/admin/lib/form/labels.tsx +1 -1
- package/resources/templates/default/admin/lib/form/select.tsx +162 -5
- package/resources/templates/default/admin/lib/form/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/form/upload-repeaters.tsx +159 -5
- package/resources/templates/default/admin/lib/form/upload.tsx +116 -3
- package/resources/templates/default/admin/lib/formatting/formatting.ts +106 -1
- package/resources/templates/default/admin/lib/formatting/index.ts +1 -1
- package/resources/templates/default/admin/lib/images/formatImageResizeUrl.ts +19 -0
- package/resources/templates/default/admin/lib/images/index.ts +1 -1
- package/resources/templates/default/admin/lib/index.ts +54 -0
- package/resources/templates/default/admin/lib/labels/index.ts +2 -2
- package/resources/templates/default/admin/lib/layout/index.ts +3 -3
- package/resources/templates/default/admin/lib/layout/layout-boxed.tsx +5 -5
- package/resources/templates/default/admin/lib/layout/layout.tsx +3 -3
- package/resources/templates/default/admin/lib/outdated-application-dialog/index.ts +1 -1
- package/resources/templates/default/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/repeater/repeater.tsx +26 -9
- package/resources/templates/default/admin/lib/select/create-new.tsx +19 -3
- package/resources/templates/default/admin/lib/select/filter.tsx +8 -2
- package/resources/templates/default/admin/lib/select/highlight.tsx +16 -0
- package/resources/templates/default/admin/lib/select/index.ts +6 -6
- package/resources/templates/default/admin/lib/select/list.tsx +30 -6
- package/resources/templates/default/admin/lib/select/multi-select.tsx +41 -4
- package/resources/templates/default/admin/lib/select/select.tsx +44 -6
- package/resources/templates/default/admin/lib/select/sortable-select.tsx +15 -6
- package/resources/templates/default/admin/lib/select/ui.tsx +100 -4
- package/resources/templates/default/admin/lib/tenant/config/auth-policy-list.tsx +86 -0
- package/resources/templates/default/admin/lib/tenant/config/common.tsx +71 -0
- package/resources/templates/default/admin/lib/tenant/config/identity-provider-list.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/config/index.ts +5 -0
- package/resources/templates/default/admin/lib/tenant/config/mail-template-list.tsx +108 -0
- package/resources/templates/default/admin/lib/tenant/config/tenant-config-view.tsx +182 -0
- package/resources/templates/default/admin/lib/tenant/dict.ts +770 -0
- package/resources/templates/default/admin/lib/tenant/errors.ts +10 -0
- package/resources/templates/default/admin/lib/tenant/forms/add-project-member.tsx +57 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-password.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/change-my-profile.tsx +40 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-profile.tsx +55 -0
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +12 -5
- package/resources/templates/default/admin/lib/tenant/forms/confirm-email-change.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/forms/create-api-key.tsx +5 -5
- package/resources/templates/default/admin/lib/tenant/forms/create-global-api-key.tsx +69 -0
- package/resources/templates/default/admin/lib/tenant/forms/global-roles-control.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +23 -8
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +46 -8
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +8 -14
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +7 -5
- package/resources/templates/default/admin/lib/tenant/forms/mfa-code-fields.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/forms/password-reset-request.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/password-reset.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin-init.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +8 -14
- package/resources/templates/default/admin/lib/tenant/forms/request-email-verification.tsx +35 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-person-password.tsx +58 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-project-secret.tsx +59 -0
- package/resources/templates/default/admin/lib/tenant/forms/sign-up.tsx +73 -0
- package/resources/templates/default/admin/lib/tenant/forms/update-project-member.tsx +14 -5
- package/resources/templates/default/admin/lib/tenant/forms/verify-email.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/hooks/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInvite.ts +41 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInviteUser.tsx +32 -3
- package/resources/templates/default/admin/lib/tenant/idp/identity-provider-connections.tsx +124 -0
- package/resources/templates/default/admin/lib/tenant/idp/index.ts +1 -0
- package/resources/templates/default/admin/lib/tenant/index.ts +10 -3
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +161 -23
- package/resources/templates/default/admin/lib/tenant/listing/auth-log-list.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/global-api-key-list.tsx +149 -0
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +11 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +28 -19
- package/resources/templates/default/admin/lib/tenant/listing/mfa.tsx +29 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-actions.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-detail.tsx +141 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +17 -6
- package/resources/templates/default/admin/lib/tenant/listing/persons-list.tsx +128 -0
- package/resources/templates/default/admin/lib/tenant/listing/project-secret-list.tsx +82 -0
- package/resources/templates/default/admin/lib/tenant/otp/backup-codes.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/otp/email-otp-setup.tsx +133 -0
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +3 -1
- package/resources/templates/default/admin/lib/tenant/otp/otp-setup.tsx +6 -6
- package/resources/templates/default/admin/lib/tenant/security/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/passwordless-toggle.tsx +63 -0
- package/resources/templates/default/admin/lib/tenant/security/session-list.tsx +143 -0
- package/resources/templates/default/admin/lib/toast/index.ts +2 -2
- package/resources/templates/default/admin/lib/toast/toast.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/alert-dialog.tsx +114 -3
- package/resources/templates/default/admin/lib/ui/avatar.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/button.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/card.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/collapsible.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/dimension.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/divider.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dropdown.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/input.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/label.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/loader.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/menu.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/overlay.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/popover.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/progress.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/property-list.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/scroll-area.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/select.tsx +44 -2
- package/resources/templates/default/admin/lib/ui/separator.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sheet.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/sidebar.tsx +8 -8
- package/resources/templates/default/admin/lib/ui/skeleton.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sortable.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/switch.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/table.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/textarea.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/toggle-group.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/toggle.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/tooltip.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/dropzone.tsx +20 -3
- package/resources/templates/default/admin/lib/upload/index.ts +3 -3
- package/resources/templates/default/admin/lib/upload/repeater.tsx +5 -1
- package/resources/templates/default/admin/lib/upload/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/upload-progress.tsx +6 -6
- package/resources/templates/default/admin/lib/upload/view.tsx +4 -4
- package/resources/templates/default/admin/lib/utils/cn.ts +18 -0
- package/resources/templates/default/admin/lib/utils/createComponentOpenHooks.tsx +33 -0
- package/resources/templates/default/admin/lib/utils/index.ts +2 -2
- package/resources/templates/default/admin/lib/utils/uic.tsx +59 -0
- package/resources/templates/default/admin/lib/utils/use-mobile.ts +19 -0
- package/resources/templates/default/admin/package.json +1 -0
- package/resources/templates/default/docker/object-storage/README.md +13 -0
- package/resources/templates/default/docker/object-storage/identities.json +13 -0
- package/resources/templates/default/docker-compose.yaml +29 -7
- package/resources/templates/default/scripts/assemble-ui-lib.mjs +132 -0
- package/resources/templates/default/scripts/update-ui-lib.sh +101 -185
- package/src/commands/WorkspaceCreateCommand.ts +45 -17
- package/src/commands/index.ts +1 -1
- package/src/lib/FileSystem.ts +2 -2
- package/src/lib/TemplateInstaller.ts +87 -69
- package/src/lib/version.ts +1 -1
- package/src/run.ts +11 -10
- package/tests/cases/unit/create-process.test.ts +66 -0
- package/tests/cases/unit/template-installer-cleanup.test.ts +150 -0
- package/tests/cases/unit/workspace-create.test.ts +81 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Assembles the admin UI library (`admin/lib`) from the Contember UI packages.
|
|
3
|
+
//
|
|
4
|
+
// Since v2, `@contember/react-ui-lib` is split into three layered packages:
|
|
5
|
+
// - react-ui-lib-base ui primitives, utils, toast, form primitives, base dict
|
|
6
|
+
// - react-ui-lib-tenant tenant forms/listing/otp (+ tenant dict)
|
|
7
|
+
// - react-ui-lib the remaining high-level UI, depending on the two above
|
|
8
|
+
//
|
|
9
|
+
// The project template ships these merged back into a single, fully-owned
|
|
10
|
+
// `admin/lib` source tree (so the user can freely customise it). This script is
|
|
11
|
+
// the single source of truth for that merge and is used both at package
|
|
12
|
+
// pre-build time and by `scripts/update-ui-lib.sh` when updating an existing
|
|
13
|
+
// project. It also handles the legacy single-package layout for back-compat.
|
|
14
|
+
//
|
|
15
|
+
// Layout produced:
|
|
16
|
+
// base/src/* -> <target>/* (flat)
|
|
17
|
+
// tenant/src/* -> <target>/tenant/*
|
|
18
|
+
// main/src/* -> <target>/* (flat)
|
|
19
|
+
// with the colliding `index.ts` and `form/index.ts` barrels merged, and the
|
|
20
|
+
// `@contember/react-ui-lib-base|tenant` imports rewritten to `~/lib`-relative
|
|
21
|
+
// paths. `tsconfig.json` files are stripped.
|
|
22
|
+
import { existsSync, rmSync, mkdirSync, cpSync, readFileSync, writeFileSync, readdirSync, statSync } from 'node:fs'
|
|
23
|
+
import { join } from 'node:path'
|
|
24
|
+
|
|
25
|
+
const args = process.argv.slice(2)
|
|
26
|
+
const getArg = name => {
|
|
27
|
+
const i = args.indexOf(name)
|
|
28
|
+
return i === -1 ? undefined : args[i + 1]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const packagesDir = getArg('--packages-dir')
|
|
32
|
+
const target = getArg('--target')
|
|
33
|
+
if (!packagesDir || !target) {
|
|
34
|
+
console.error('Usage: assemble-ui-lib.mjs --packages-dir <dir> --target <dir>')
|
|
35
|
+
process.exit(1)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const mainSrc = join(packagesDir, 'react-ui-lib', 'src')
|
|
39
|
+
const baseSrc = join(packagesDir, 'react-ui-lib-base', 'src')
|
|
40
|
+
const tenantSrc = join(packagesDir, 'react-ui-lib-tenant', 'src')
|
|
41
|
+
|
|
42
|
+
if (!existsSync(mainSrc)) {
|
|
43
|
+
console.error(`Source not found: ${mainSrc}`)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const isSourceFile = name => name.endsWith('.ts') || name.endsWith('.tsx')
|
|
48
|
+
|
|
49
|
+
const walk = function* (dir) {
|
|
50
|
+
for (const entry of readdirSync(dir)) {
|
|
51
|
+
const full = join(dir, entry)
|
|
52
|
+
if (statSync(full).isDirectory()) {
|
|
53
|
+
yield* walk(full)
|
|
54
|
+
} else {
|
|
55
|
+
yield full
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const rewriteImports = content =>
|
|
61
|
+
content
|
|
62
|
+
.replaceAll('@contember/react-ui-lib-tenant', '~/lib/tenant')
|
|
63
|
+
.replaceAll('@contember/react-ui-lib-base', '~/lib')
|
|
64
|
+
|
|
65
|
+
// Reset target.
|
|
66
|
+
rmSync(target, { recursive: true, force: true })
|
|
67
|
+
mkdirSync(target, { recursive: true })
|
|
68
|
+
|
|
69
|
+
const split = existsSync(baseSrc) && existsSync(tenantSrc)
|
|
70
|
+
|
|
71
|
+
if (!split) {
|
|
72
|
+
// Legacy single-package layout: copy the source tree, dropping the package
|
|
73
|
+
// barrel (the project consumes granular `~/lib/*` paths, not a root barrel).
|
|
74
|
+
cpSync(mainSrc, target, { recursive: true })
|
|
75
|
+
rmSync(join(target, 'index.ts'), { force: true })
|
|
76
|
+
} else {
|
|
77
|
+
// Base flat into the root, tenant under tenant/, main flat into the root.
|
|
78
|
+
// Main overwrites the colliding `index.ts` and `form/index.ts`; we rebuild
|
|
79
|
+
// those barrels below.
|
|
80
|
+
cpSync(baseSrc, target, { recursive: true })
|
|
81
|
+
cpSync(tenantSrc, join(target, 'tenant'), { recursive: true })
|
|
82
|
+
cpSync(mainSrc, target, { recursive: true })
|
|
83
|
+
|
|
84
|
+
// Merge the top-level barrel: inline base's exports and point tenant at the
|
|
85
|
+
// local tenant/ directory, then drop duplicate re-exports.
|
|
86
|
+
const baseIndex = readFileSync(join(baseSrc, 'index.ts'), 'utf8').trim()
|
|
87
|
+
const mainIndex = readFileSync(join(mainSrc, 'index.ts'), 'utf8')
|
|
88
|
+
const mergedIndex = mainIndex
|
|
89
|
+
.replace(/^export \* from '@contember\/react-ui-lib-base'$/m, baseIndex)
|
|
90
|
+
.replace(/^export \* from '@contember\/react-ui-lib-tenant'$/m, "export * from './tenant'")
|
|
91
|
+
const seen = new Set()
|
|
92
|
+
const dedupedIndex = mergedIndex
|
|
93
|
+
.split('\n')
|
|
94
|
+
.filter(line => {
|
|
95
|
+
const trimmed = line.trim()
|
|
96
|
+
if (trimmed.startsWith('export * from') && seen.has(trimmed)) {
|
|
97
|
+
return false
|
|
98
|
+
}
|
|
99
|
+
if (trimmed.startsWith('export * from')) {
|
|
100
|
+
seen.add(trimmed)
|
|
101
|
+
}
|
|
102
|
+
return true
|
|
103
|
+
})
|
|
104
|
+
.join('\n')
|
|
105
|
+
writeFileSync(join(target, 'index.ts'), dedupedIndex)
|
|
106
|
+
|
|
107
|
+
// Merge the form barrel: base's form primitives live in form/ui after the
|
|
108
|
+
// flat copy, so re-export them via the local ./ui module.
|
|
109
|
+
const mainFormIndex = readFileSync(join(mainSrc, 'form', 'index.ts'), 'utf8')
|
|
110
|
+
const mergedFormIndex = mainFormIndex.replace(
|
|
111
|
+
/^export \{[^}]*\} from '@contember\/react-ui-lib-base'$/m,
|
|
112
|
+
"export * from './ui'",
|
|
113
|
+
)
|
|
114
|
+
writeFileSync(join(target, 'form', 'index.ts'), mergedFormIndex)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Rewrite package imports to local `~/lib` paths and strip tsconfig files.
|
|
118
|
+
for (const file of walk(target)) {
|
|
119
|
+
if (file.endsWith('tsconfig.json')) {
|
|
120
|
+
rmSync(file)
|
|
121
|
+
continue
|
|
122
|
+
}
|
|
123
|
+
if (isSourceFile(file)) {
|
|
124
|
+
const content = readFileSync(file, 'utf8')
|
|
125
|
+
const rewritten = rewriteImports(content)
|
|
126
|
+
if (rewritten !== content) {
|
|
127
|
+
writeFileSync(file, rewritten)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log(`Assembled admin UI library into ${target} (${split ? 'split' : 'legacy'} layout)`)
|
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
git
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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: $
|
|
154
|
-
git fetch origin "$
|
|
154
|
+
echo "Fetching commit/branch: $ref"
|
|
155
|
+
git -C "$CLONE_DIR" fetch origin "$ref" --depth=1
|
|
155
156
|
fi
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
|
168
|
-
|
|
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
|
-
|
|
179
|
-
git
|
|
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
|
-
#
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
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
|
-
|
|
247
|
-
|
|
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
|
-
|
|
250
|
-
|
|
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
|
-
#
|
|
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 "
|
|
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
|
-
|
|
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/$
|
|
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
|
|
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
|
-
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
1
|
+
import { Command, CommandConfiguration, escapeTerminalText, Input, Output } 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
|
|
@@ -13,9 +13,29 @@ type Options = {
|
|
|
13
13
|
template: string
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
export interface WorkspaceCreateResult {
|
|
17
|
+
projectName: string
|
|
18
|
+
projectDirectory: string
|
|
19
|
+
template: string
|
|
20
|
+
packageManager: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface WorkspaceCreateRuntime {
|
|
24
|
+
cwd(): string
|
|
25
|
+
getPackageVersion(): Promise<string>
|
|
26
|
+
detectPackageManager(): string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const defaultRuntime: WorkspaceCreateRuntime = {
|
|
30
|
+
cwd: () => process.cwd(),
|
|
31
|
+
getPackageVersion,
|
|
32
|
+
detectPackageManager,
|
|
33
|
+
}
|
|
34
|
+
|
|
16
35
|
export class WorkspaceCreateCommand extends Command<Args, Options> {
|
|
17
36
|
constructor(
|
|
18
|
-
private readonly templateInstaller: TemplateInstaller,
|
|
37
|
+
private readonly templateInstaller: Pick<TemplateInstaller, 'installTemplate'>,
|
|
38
|
+
private readonly runtime: WorkspaceCreateRuntime = defaultRuntime,
|
|
19
39
|
) {
|
|
20
40
|
super()
|
|
21
41
|
}
|
|
@@ -26,35 +46,43 @@ export class WorkspaceCreateCommand extends Command<Args, Options> {
|
|
|
26
46
|
configuration.option('template').shortcut('t').valueRequired().description('Template name or remote source')
|
|
27
47
|
}
|
|
28
48
|
|
|
29
|
-
protected async execute(input: Input<Args, Options
|
|
49
|
+
protected async execute(input: Input<Args, Options>, output: Output): Promise<void> {
|
|
30
50
|
const projectName = input.getArgument('projectName')
|
|
31
|
-
const projectDirectory = join(
|
|
32
|
-
const packageManager = detectPackageManager()
|
|
51
|
+
const projectDirectory = join(this.runtime.cwd(), projectName)
|
|
52
|
+
const packageManager = this.runtime.detectPackageManager()
|
|
33
53
|
const template = input.getOption('template') ?? 'default'
|
|
34
54
|
|
|
35
55
|
await this.templateInstaller.installTemplate(template, projectDirectory, {
|
|
36
|
-
version: await getPackageVersion(),
|
|
56
|
+
version: await this.runtime.getPackageVersion(),
|
|
37
57
|
projectName: projectName,
|
|
38
58
|
packageManager: packageManager,
|
|
39
59
|
})
|
|
40
60
|
|
|
41
|
-
|
|
61
|
+
const result: WorkspaceCreateResult = { projectName, projectDirectory, template, packageManager }
|
|
62
|
+
output.data(result, {
|
|
63
|
+
human: value => createDocs(value),
|
|
64
|
+
quiet: value => value.projectDirectory,
|
|
65
|
+
})
|
|
42
66
|
}
|
|
43
67
|
}
|
|
44
68
|
|
|
45
|
-
const createDocs = (projectDirectory
|
|
46
|
-
|
|
69
|
+
const createDocs = ({ projectDirectory, projectName, packageManager }: WorkspaceCreateResult) => {
|
|
70
|
+
const safeProjectDirectory = escapeTerminalText(projectDirectory)
|
|
71
|
+
const safeProjectName = escapeTerminalText(projectName)
|
|
72
|
+
const safePackageManager = escapeTerminalText(packageManager)
|
|
73
|
+
return `
|
|
74
|
+
Contember project successfully created in ${safeProjectDirectory}
|
|
47
75
|
|
|
48
76
|
Next steps:
|
|
49
77
|
|
|
50
78
|
1. Navigate to the project directory:
|
|
51
|
-
$ ${chalk.green(`cd ${
|
|
79
|
+
$ ${chalk.green(`cd ${safeProjectName}`)}
|
|
52
80
|
|
|
53
81
|
2. Install dependencies:
|
|
54
|
-
$ ${chalk.green(`${
|
|
82
|
+
$ ${chalk.green(`${safePackageManager} install`)}
|
|
55
83
|
|
|
56
84
|
3. Start the Contember stack:
|
|
57
|
-
$ ${chalk.green(`${
|
|
85
|
+
$ ${chalk.green(`${safePackageManager} start`)}
|
|
58
86
|
|
|
59
87
|
Available services:
|
|
60
88
|
|
|
@@ -67,10 +95,10 @@ ${chalk.bold('API & Backend')}
|
|
|
67
95
|
|
|
68
96
|
${chalk.bold('Development Tools')}
|
|
69
97
|
- PostgreSQL database ${chalk.blue('http://localhost:1482')} ${chalk.grey('credentials: contember / contember')}
|
|
70
|
-
-
|
|
98
|
+
- S3 object storage ${chalk.blue('http://localhost:1483')} ${chalk.grey('credentials: contember / contember')}
|
|
71
99
|
- Mailpit SMTP testing ${chalk.blue('http://localhost:1484')}
|
|
72
100
|
- Adminer DB manager ${chalk.blue('http://localhost:1485')}
|
|
73
|
-
- Minio Dashboard ${chalk.blue('http://localhost:1486')} ${chalk.grey('credentials: contember / contember')}
|
|
74
101
|
|
|
75
102
|
${chalk.bold('Need help?')} Ask the community: https://github.com/orgs/contember/discussions
|
|
76
103
|
`
|
|
104
|
+
}
|
package/src/commands/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './WorkspaceCreateCommand'
|
|
1
|
+
export * from './WorkspaceCreateCommand.js'
|
package/src/lib/FileSystem.ts
CHANGED
|
@@ -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 =
|
|
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) => {
|