@contember/create 1.4.0-rc.8 → 2.0.0-alpha.8
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/dist/development/run.cjs +27 -0
- package/dist/development/run.cjs.map +1 -0
- package/dist/development/run.js +26 -0
- package/dist/development/run.js.map +1 -0
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +50 -0
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -0
- package/dist/development/src/commands/WorkspaceCreateCommand.js +50 -0
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -0
- package/dist/development/src/lib/FileSystem.cjs +48 -0
- package/dist/development/src/lib/FileSystem.cjs.map +1 -0
- package/dist/development/src/lib/FileSystem.js +32 -0
- package/dist/development/src/lib/FileSystem.js.map +1 -0
- package/dist/development/src/lib/PackageDownloader.cjs +33 -0
- package/dist/development/src/lib/PackageDownloader.cjs.map +1 -0
- package/dist/development/src/lib/PackageDownloader.js +33 -0
- package/dist/development/src/lib/PackageDownloader.js.map +1 -0
- package/dist/development/src/lib/TemplateInstaller.cjs +87 -0
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -0
- package/dist/development/src/lib/TemplateInstaller.js +87 -0
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -0
- package/dist/development/src/lib/version.cjs +10 -0
- package/dist/development/src/lib/version.cjs.map +1 -0
- package/dist/development/src/lib/version.js +10 -0
- package/dist/development/src/lib/version.js.map +1 -0
- package/dist/development/src/paths.cjs +10 -0
- package/dist/development/src/paths.cjs.map +1 -0
- package/dist/development/src/paths.js +9 -0
- package/dist/development/src/paths.js.map +1 -0
- package/dist/production/run.cjs +27 -0
- package/dist/production/run.cjs.map +1 -0
- package/dist/production/run.js +26 -0
- package/dist/production/run.js.map +1 -0
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +50 -0
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -0
- package/dist/production/src/commands/WorkspaceCreateCommand.js +50 -0
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -0
- package/dist/production/src/lib/FileSystem.cjs +48 -0
- package/dist/production/src/lib/FileSystem.cjs.map +1 -0
- package/dist/production/src/lib/FileSystem.js +32 -0
- package/dist/production/src/lib/FileSystem.js.map +1 -0
- package/dist/production/src/lib/PackageDownloader.cjs +33 -0
- package/dist/production/src/lib/PackageDownloader.cjs.map +1 -0
- package/dist/production/src/lib/PackageDownloader.js +33 -0
- package/dist/production/src/lib/PackageDownloader.js.map +1 -0
- package/dist/production/src/lib/TemplateInstaller.cjs +87 -0
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -0
- package/dist/production/src/lib/TemplateInstaller.js +87 -0
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -0
- package/dist/production/src/lib/version.cjs +10 -0
- package/dist/production/src/lib/version.cjs.map +1 -0
- package/dist/production/src/lib/version.js +10 -0
- package/dist/production/src/lib/version.js.map +1 -0
- package/dist/production/src/paths.cjs +10 -0
- package/dist/production/src/paths.cjs.map +1 -0
- package/dist/production/src/paths.js +9 -0
- package/dist/production/src/paths.js.map +1 -0
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -0
- package/dist/{src → types}/lib/FileSystem.d.ts +0 -1
- package/dist/types/lib/FileSystem.d.ts.map +1 -0
- package/dist/{src → types}/lib/PackageDownloader.d.ts.map +1 -1
- package/dist/{src → types}/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/lib/version.d.ts +2 -0
- package/dist/types/lib/version.d.ts.map +1 -0
- package/dist/{src/lib/pathUtils.d.ts → types/paths.d.ts} +1 -1
- package/dist/types/paths.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +26 -5
- package/resources/templates/template-workspace/admin/app/index.html +1 -1
- package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +64 -40
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +166 -33
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +23 -17
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +44 -35
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +21 -13
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +4 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +31 -24
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +51 -32
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +2 -10
- package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +17 -10
- package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +4 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/ui.tsx +4 -4
- package/resources/templates/template-workspace/admin/lib/dict.ts +64 -72
- package/resources/templates/template-workspace/admin/lib/dimensions/dimensions.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-canvas.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-editable-canvas.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-inline-toolbar.tsx +2 -5
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableElementRenderer.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/editor/editor-block.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/editor/rich-text.tsx +5 -5
- package/resources/templates/template-workspace/admin/lib/editor/sortable-block.tsx +3 -3
- package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/form/upload.tsx +119 -36
- package/resources/templates/template-workspace/admin/lib/formatting/formatting.ts +6 -8
- package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +3 -2
- package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +16 -8
- package/resources/templates/template-workspace/admin/lib/select/create-new.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/select/highlight.tsx +9 -9
- package/resources/templates/template-workspace/admin/lib/tenant/forms/common.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInvite.ts +3 -3
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInviteUser.tsx +19 -19
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-list.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +7 -7
- package/resources/templates/template-workspace/admin/lib/ui/input.tsx +4 -1
- package/resources/templates/template-workspace/admin/lib/ui/scroll-area.tsx +24 -24
- package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +0 -2
- package/resources/templates/template-workspace/admin/lib/upload/dropzone.tsx +13 -2
- package/resources/templates/template-workspace/admin/lib/upload/ui.tsx +1 -11
- package/resources/templates/template-workspace/admin/lib/upload/upload-progress.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +39 -26
- package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +6 -6
- package/resources/templates/template-workspace/admin/package.json +17 -17
- package/resources/templates/template-workspace/api/package.json +0 -3
- package/resources/templates/template-workspace/client/package.json +0 -3
- package/resources/templates/template-workspace/package.json +1 -1
- package/src/commands/WorkspaceCreateCommand.ts +3 -2
- package/src/lib/version.ts +7 -0
- package/src/{lib/pathUtils.ts → paths.ts} +3 -1
- package/src/run.ts +1 -1
- package/src/tsconfig.json +1 -1
- package/dist/src/commands/WorkspaceCreateCommand.d.ts.map +0 -1
- package/dist/src/commands/WorkspaceCreateCommand.js +0 -54
- package/dist/src/commands/WorkspaceCreateCommand.js.map +0 -1
- package/dist/src/commands/index.js +0 -18
- package/dist/src/commands/index.js.map +0 -1
- package/dist/src/lib/FileSystem.d.ts.map +0 -1
- package/dist/src/lib/FileSystem.js +0 -54
- package/dist/src/lib/FileSystem.js.map +0 -1
- package/dist/src/lib/PackageDownloader.js +0 -32
- package/dist/src/lib/PackageDownloader.js.map +0 -1
- package/dist/src/lib/TemplateInstaller.js +0 -75
- package/dist/src/lib/TemplateInstaller.js.map +0 -1
- package/dist/src/lib/pathUtils.d.ts.map +0 -1
- package/dist/src/lib/pathUtils.js +0 -7
- package/dist/src/lib/pathUtils.js.map +0 -1
- package/dist/src/run.js +0 -25
- package/dist/src/run.js.map +0 -1
- package/dist/src/tsconfig.tsbuildinfo +0 -1
- package/resources/templates/template-workspace/admin/lib/utils/dict-format.tsx +0 -3
- package/resources/templates/template-workspace/admin/lib/utils/format-image-resize-url.ts +0 -17
- package/resources/templates/template-workspace/admin/lib/utils/formatting.ts +0 -60
- package/resources/templates/template-workspace/admin/vite.config.ts +0 -39
- /package/dist/{src → types}/commands/WorkspaceCreateCommand.d.ts +0 -0
- /package/dist/{src → types}/commands/index.d.ts +0 -0
- /package/dist/{src → types}/commands/index.d.ts.map +0 -0
- /package/dist/{src → types}/lib/PackageDownloader.d.ts +0 -0
- /package/dist/{src → types}/lib/TemplateInstaller.d.ts +0 -0
- /package/dist/{src → types}/run.d.ts +0 -0
- /package/dist/{src → types}/run.d.ts.map +0 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { Loader } from '../ui/loader'
|
|
3
|
-
import { GripIcon
|
|
4
|
-
import { dict } from '../dict'
|
|
5
|
-
import { Button } from '../ui/button'
|
|
3
|
+
import { GripIcon } from 'lucide-react'
|
|
6
4
|
import { uic } from '../utils/uic'
|
|
7
5
|
|
|
8
6
|
export const UploaderDropzoneWrapperUI = uic('div', { baseClass: 'rounded border p-1 shadow' })
|
|
@@ -21,14 +19,6 @@ export const UploaderDropzoneAreaUI = uic('div', {
|
|
|
21
19
|
defaultVariants: {
|
|
22
20
|
size: 'square',
|
|
23
21
|
},
|
|
24
|
-
beforeChildren: <>
|
|
25
|
-
<UploadIcon className={'w-12 h-12 text-gray-400'} />
|
|
26
|
-
<div className={'font-semibold text-sm'}>{dict.uploader.dropFiles}</div>
|
|
27
|
-
<div className={'text-xs'}>{dict.uploader.or}</div>
|
|
28
|
-
<div className={'flex gap-2 items-center text-xs'}>
|
|
29
|
-
<Button size={'sm'} variant={'outline'}>{dict.uploader.browseFiles}</Button>
|
|
30
|
-
</div>
|
|
31
|
-
</>,
|
|
32
22
|
})
|
|
33
23
|
|
|
34
24
|
|
|
@@ -40,7 +40,7 @@ const UploadError = ({ state: { error } }: { state: UploaderFileStateError }) =>
|
|
|
40
40
|
return <div className="text-red-700 text-xs font-semibold">{formattedError}</div>
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export const UploaderFileProgressUI = ({ file, progress, info, actions }: { file: File
|
|
43
|
+
export const UploaderFileProgressUI = ({ file, progress, info, actions }: { file: File; progress?: number; actions?: ReactNode; info?: ReactNode }) => {
|
|
44
44
|
const fileName = file.name
|
|
45
45
|
const extension = file.name.split('.').pop()?.toUpperCase()
|
|
46
46
|
|
|
@@ -2,19 +2,19 @@ import * as React from 'react'
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react'
|
|
3
3
|
import { Component, Field, SugaredRelativeSingleField, useEntity, useField } from '@contember/interface'
|
|
4
4
|
import { AudioFileDataExtractorProps, FileUrlDataExtractorProps, GenericFileMetadataExtractorProps, ImageFileDataExtractorProps, VideoFileDataExtractorProps } from '@contember/react-uploader'
|
|
5
|
-
import { formatBytes, formatDate, formatDuration } from '../formatting
|
|
5
|
+
import { formatBytes, formatDate, formatDuration } from '../formatting'
|
|
6
6
|
import { Button } from '../ui/button'
|
|
7
7
|
import { FileIcon, InfoIcon, TrashIcon } from 'lucide-react'
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
|
|
9
|
-
import { formatImageResizeUrl } from '../images
|
|
9
|
+
import { formatImageResizeUrl } from '../images'
|
|
10
10
|
|
|
11
11
|
export type UploadedImageViewProps =
|
|
12
12
|
& FileUrlDataExtractorProps
|
|
13
13
|
& GenericFileMetadataExtractorProps
|
|
14
14
|
& ImageFileDataExtractorProps
|
|
15
15
|
& {
|
|
16
|
-
|
|
17
|
-
}
|
|
16
|
+
DestroyAction?: ComponentType<{ children: ReactNode }>
|
|
17
|
+
}
|
|
18
18
|
|
|
19
19
|
export const UploadedImageView = Component<UploadedImageViewProps>(({ DestroyAction, ...props }) => {
|
|
20
20
|
const url = useField<string>(props.urlField).value
|
|
@@ -22,22 +22,24 @@ export const UploadedImageView = Component<UploadedImageViewProps>(({ DestroyAct
|
|
|
22
22
|
<div className="flex items-center justify-center h-40 w-40 rounded-md group relative">
|
|
23
23
|
{url && <img src={formatImageResizeUrl(url)} className="max-w-full max-h-full" />}
|
|
24
24
|
<FileActions DestroyAction={DestroyAction}>
|
|
25
|
-
|
|
25
|
+
<ImageMetadata {...props} />
|
|
26
26
|
</FileActions>
|
|
27
27
|
</div>
|
|
28
28
|
)
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
}, props => {
|
|
30
|
+
return <>
|
|
31
|
+
<Field field={props.urlField} />
|
|
32
|
+
<ImageMetadata {...props} />
|
|
33
|
+
</>
|
|
32
34
|
})
|
|
33
35
|
|
|
34
|
-
const ImageMetadata = ({ heightField, widthField, ...props }: UploadedImageViewProps) => {
|
|
36
|
+
const ImageMetadata = Component(({ heightField, widthField, ...props }: UploadedImageViewProps) => {
|
|
35
37
|
return (
|
|
36
38
|
<Metadata {...props}>
|
|
37
39
|
<DimensionsMeta widthField={widthField} heightField={heightField} />
|
|
38
40
|
</Metadata>
|
|
39
41
|
)
|
|
40
|
-
}
|
|
42
|
+
})
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
export type UploadedAudioViewProps =
|
|
@@ -58,9 +60,11 @@ export const UploadedAudioView = Component<UploadedAudioViewProps>(({ DestroyAct
|
|
|
58
60
|
</FileActions>
|
|
59
61
|
</div>
|
|
60
62
|
)
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
}, props => {
|
|
64
|
+
return <>
|
|
65
|
+
<Field field={props.urlField} />
|
|
66
|
+
<AudioMetadata {...props} />
|
|
67
|
+
</>
|
|
64
68
|
})
|
|
65
69
|
|
|
66
70
|
const AudioMetadata = ({ durationField, ...props }: UploadedAudioViewProps) => {
|
|
@@ -90,19 +94,21 @@ export const UploadedVideoView = Component<UploadedVideoViewProps>(({ DestroyAct
|
|
|
90
94
|
</FileActions>
|
|
91
95
|
</div>
|
|
92
96
|
)
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
}, props => {
|
|
98
|
+
return <>
|
|
99
|
+
<Field field={props.urlField} />
|
|
100
|
+
<VideoMetadata {...props} />
|
|
101
|
+
</>
|
|
96
102
|
})
|
|
97
103
|
|
|
98
|
-
const VideoMetadata = ({ durationField, widthField, heightField, ...props }: UploadedVideoViewProps) => {
|
|
104
|
+
const VideoMetadata = Component(({ durationField, widthField, heightField, ...props }: UploadedVideoViewProps) => {
|
|
99
105
|
return (
|
|
100
106
|
<Metadata {...props}>
|
|
101
107
|
<MetaField field={durationField} label="Duration:" format={formatDuration} />
|
|
102
108
|
<DimensionsMeta widthField={widthField} heightField={heightField} />
|
|
103
109
|
</Metadata>
|
|
104
110
|
)
|
|
105
|
-
}
|
|
111
|
+
})
|
|
106
112
|
|
|
107
113
|
export type UploadedAnyViewProps =
|
|
108
114
|
& FileUrlDataExtractorProps
|
|
@@ -137,7 +143,7 @@ type MetadataProps =
|
|
|
137
143
|
children?: ReactNode
|
|
138
144
|
}
|
|
139
145
|
|
|
140
|
-
const Metadata = ({ children, urlField, fileSizeField, fileNameField, lastModifiedField, fileTypeField }: MetadataProps) => {
|
|
146
|
+
const Metadata = Component(({ children, urlField, fileSizeField, fileNameField, lastModifiedField, fileTypeField }: MetadataProps) => {
|
|
141
147
|
return (
|
|
142
148
|
<div className="grid grid-cols-[6rem_1fr] gap-2">
|
|
143
149
|
<MetaField field={fileSizeField} label="Size:" format={formatBytes} />
|
|
@@ -152,9 +158,9 @@ const Metadata = ({ children, urlField, fileSizeField, fileNameField, lastModifi
|
|
|
152
158
|
)} />
|
|
153
159
|
</div>
|
|
154
160
|
)
|
|
155
|
-
}
|
|
161
|
+
})
|
|
156
162
|
|
|
157
|
-
const DimensionsMeta = ({ widthField, heightField }: {
|
|
163
|
+
const DimensionsMeta = Component(({ widthField, heightField }: {
|
|
158
164
|
widthField?: SugaredRelativeSingleField['field']
|
|
159
165
|
heightField?: SugaredRelativeSingleField['field']
|
|
160
166
|
}) => {
|
|
@@ -171,14 +177,19 @@ const DimensionsMeta = ({ widthField, heightField }: {
|
|
|
171
177
|
<span>{width} x {height} px</span>
|
|
172
178
|
</>
|
|
173
179
|
)
|
|
180
|
+
}, ({ widthField, heightField }) => {
|
|
181
|
+
return <>
|
|
182
|
+
{widthField && <Field field={widthField} />}
|
|
183
|
+
{heightField && <Field field={heightField} />}
|
|
184
|
+
</>
|
|
185
|
+
})
|
|
174
186
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const MetaField = ({ field, label, format = it => it }: {
|
|
187
|
+
interface MetaFieldProps {
|
|
178
188
|
field?: SugaredRelativeSingleField['field']
|
|
179
189
|
label: ReactNode
|
|
180
190
|
format?: (value: any) => ReactNode
|
|
181
|
-
}
|
|
191
|
+
}
|
|
192
|
+
const MetaField = Component<MetaFieldProps>(({ field, label, format = it => it }) => {
|
|
182
193
|
const entity = useEntity()
|
|
183
194
|
return field ? (
|
|
184
195
|
<>
|
|
@@ -188,7 +199,9 @@ const MetaField = ({ field, label, format = it => it }: {
|
|
|
188
199
|
</span>
|
|
189
200
|
</>
|
|
190
201
|
) : null
|
|
191
|
-
}
|
|
202
|
+
}, ({ field }) => {
|
|
203
|
+
return field ? <Field field={field} /> : null
|
|
204
|
+
})
|
|
192
205
|
|
|
193
206
|
|
|
194
207
|
const FileActions = ({ DestroyAction, children }: {
|
|
@@ -5,8 +5,8 @@ import { Slot } from '@radix-ui/react-slot'
|
|
|
5
5
|
import { cva } from 'class-variance-authority'
|
|
6
6
|
import { twMerge } from 'tailwind-merge'
|
|
7
7
|
|
|
8
|
-
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T
|
|
9
|
-
type ConfigSchema = Record<string, Record<string, ClassValue
|
|
8
|
+
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T
|
|
9
|
+
type ConfigSchema = Record<string, Record<string, ClassValue>>
|
|
10
10
|
|
|
11
11
|
export type ConfigVariants<T extends ConfigSchema | undefined> = T extends ConfigSchema ? {
|
|
12
12
|
[Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;
|
|
@@ -18,12 +18,12 @@ type ConfigVariantsMulti<T extends ConfigSchema | undefined> = T extends ConfigS
|
|
|
18
18
|
|
|
19
19
|
type Config<T extends ConfigSchema | undefined, El extends React.ElementType> = {
|
|
20
20
|
baseClass?: ClassValue
|
|
21
|
-
variants?: T
|
|
21
|
+
variants?: T
|
|
22
22
|
passVariantProps?: string[]
|
|
23
23
|
defaultProps?: Partial<React.ComponentProps<El>>
|
|
24
|
-
defaultVariants?: ConfigVariants<T
|
|
25
|
-
compoundVariants?: ((ConfigVariants<T> | ConfigVariantsMulti<T>) & { className?: string })[]
|
|
26
|
-
displayName?: string
|
|
24
|
+
defaultVariants?: ConfigVariants<T>
|
|
25
|
+
compoundVariants?: ((ConfigVariants<T> | ConfigVariantsMulti<T>) & { className?: string })[]
|
|
26
|
+
displayName?: string
|
|
27
27
|
wrapOuter?: ComponentType<{ children?: ReactNode } & ConfigVariants<T>>
|
|
28
28
|
wrapInner?: ComponentType<{ children?: ReactNode } & ConfigVariants<T>>
|
|
29
29
|
beforeChildren?: ReactElement
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@contember/vite-plugin": "
|
|
11
|
+
"@contember/vite-plugin": "{version}",
|
|
12
12
|
"@types/react": "^18",
|
|
13
13
|
"@types/react-dom": "^18",
|
|
14
14
|
"@vitejs/plugin-react": "^4.2.1",
|
|
@@ -19,23 +19,23 @@
|
|
|
19
19
|
"vite": "^5"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@contember/client-content": "
|
|
23
|
-
"@contember/graphql-client": "
|
|
22
|
+
"@contember/client-content": "{version}",
|
|
23
|
+
"@contember/graphql-client": "{version}",
|
|
24
24
|
"@contember/graphql-client-tenant": "{version}",
|
|
25
|
-
"@contember/interface": "
|
|
26
|
-
"@contember/react-block-repeater": "
|
|
27
|
-
"@contember/react-board": "
|
|
28
|
-
"@contember/react-board-dnd-kit": "
|
|
29
|
-
"@contember/react-dataview": "
|
|
30
|
-
"@contember/react-form": "
|
|
31
|
-
"@contember/react-repeater": "
|
|
32
|
-
"@contember/react-repeater-dnd-kit": "
|
|
33
|
-
"@contember/react-select": "
|
|
34
|
-
"@contember/react-slate-editor": "
|
|
35
|
-
"@contember/react-slate-editor-base": "
|
|
36
|
-
"@contember/react-slots": "
|
|
37
|
-
"@contember/react-uploader": "
|
|
38
|
-
"@contember/react-uploader-dropzone": "
|
|
25
|
+
"@contember/interface": "{version}",
|
|
26
|
+
"@contember/react-block-repeater": "{version}",
|
|
27
|
+
"@contember/react-board": "{version}",
|
|
28
|
+
"@contember/react-board-dnd-kit": "{version}",
|
|
29
|
+
"@contember/react-dataview": "{version}",
|
|
30
|
+
"@contember/react-form": "{version}",
|
|
31
|
+
"@contember/react-repeater": "{version}",
|
|
32
|
+
"@contember/react-repeater-dnd-kit": "{version}",
|
|
33
|
+
"@contember/react-select": "{version}",
|
|
34
|
+
"@contember/react-slate-editor": "{version}",
|
|
35
|
+
"@contember/react-slate-editor-base": "{version}",
|
|
36
|
+
"@contember/react-slots": "{version}",
|
|
37
|
+
"@contember/react-uploader": "{version}",
|
|
38
|
+
"@contember/react-uploader-dropzone": "{version}",
|
|
39
39
|
"@radix-ui/react-alert-dialog": "^1.0.5",
|
|
40
40
|
"@radix-ui/react-checkbox": "^1.0.4",
|
|
41
41
|
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Command, CommandConfiguration,
|
|
1
|
+
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
import chalk from 'chalk'
|
|
4
4
|
import { TemplateInstaller } from '../lib/TemplateInstaller'
|
|
5
|
+
import { getPackageVersion } from '../lib/version'
|
|
5
6
|
|
|
6
7
|
type Args = {
|
|
7
8
|
workspaceName: string
|
|
@@ -26,7 +27,7 @@ export class WorkspaceCreateCommand extends Command<Args, Options> {
|
|
|
26
27
|
const workspaceName = input.getArgument('workspaceName')
|
|
27
28
|
const workspaceDirectory = join(process.cwd(), workspaceName)
|
|
28
29
|
await this.templateInstaller.installTemplate('@contember/template-workspace', workspaceDirectory, {
|
|
29
|
-
version: getPackageVersion(),
|
|
30
|
+
version: await getPackageVersion(),
|
|
30
31
|
projectName: workspaceName,
|
|
31
32
|
})
|
|
32
33
|
// eslint-disable-next-line no-console
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { join } from 'node:path'
|
|
2
|
+
import { dirname } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
2
4
|
|
|
3
|
-
export const packageRoot = process.env.CONTEMBER_CLI_PACKAGE_ROOT || join(
|
|
5
|
+
export const packageRoot = process.env.CONTEMBER_CLI_PACKAGE_ROOT || join(dirname(fileURLToPath(import.meta.url)), '../../')
|
|
4
6
|
export const resourcesDir = join(packageRoot, './resources')
|
package/src/run.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Application, CommandManager } from '@contember/cli-common'
|
|
3
3
|
import { WorkspaceCreateCommand } from './commands'
|
|
4
4
|
import { TemplateInstaller } from './lib/TemplateInstaller'
|
|
5
|
-
import { resourcesDir } from './
|
|
5
|
+
import { resourcesDir } from './paths'
|
|
6
6
|
import { PackageDownloader } from './lib/PackageDownloader'
|
|
7
7
|
import { FileSystem } from './lib/FileSystem'
|
|
8
8
|
|
package/src/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceCreateCommand.d.ts","sourceRoot":"","sources":["../../../src/commands/WorkspaceCreateCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAqB,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAG/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,KAAK,IAAI,GAAG;IACX,aAAa,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,OAAO,GAAG,EACd,CAAA;AAED,qBAAa,sBAAuB,SAAQ,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;IAEhE,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,iBAAiB;IAKtD,SAAS,CAAC,SAAS,CAAC,aAAa,EAAE,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI;cAK7D,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAUnE"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WorkspaceCreateCommand = void 0;
|
|
7
|
-
const cli_common_1 = require("@contember/cli-common");
|
|
8
|
-
const node_path_1 = require("node:path");
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
class WorkspaceCreateCommand extends cli_common_1.Command {
|
|
11
|
-
constructor(templateInstaller) {
|
|
12
|
-
super();
|
|
13
|
-
this.templateInstaller = templateInstaller;
|
|
14
|
-
}
|
|
15
|
-
configure(configuration) {
|
|
16
|
-
configuration.description('Creates a new Contember workspace');
|
|
17
|
-
configuration.argument('workspaceName');
|
|
18
|
-
}
|
|
19
|
-
async execute(input) {
|
|
20
|
-
const workspaceName = input.getArgument('workspaceName');
|
|
21
|
-
const workspaceDirectory = (0, node_path_1.join)(process.cwd(), workspaceName);
|
|
22
|
-
await this.templateInstaller.installTemplate('@contember/template-workspace', workspaceDirectory, {
|
|
23
|
-
version: (0, cli_common_1.getPackageVersion)(),
|
|
24
|
-
projectName: workspaceName,
|
|
25
|
-
});
|
|
26
|
-
// eslint-disable-next-line no-console
|
|
27
|
-
console.log(createDocs(workspaceDirectory, workspaceName));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.WorkspaceCreateCommand = WorkspaceCreateCommand;
|
|
31
|
-
const createDocs = (workspaceDirectory, workspaceName) => `
|
|
32
|
-
Contember workspace was successfully created inside the directory ${workspaceDirectory}
|
|
33
|
-
|
|
34
|
-
You can now enter this directory:
|
|
35
|
-
$ ${chalk_1.default.greenBright(`cd ${workspaceName}`)}
|
|
36
|
-
|
|
37
|
-
Install NPM dependencies:
|
|
38
|
-
$ ${chalk_1.default.greenBright(`yarn install`)}
|
|
39
|
-
|
|
40
|
-
And start the Contember stack:
|
|
41
|
-
$ ${chalk_1.default.greenBright('yarn start')}
|
|
42
|
-
|
|
43
|
-
The following services will be accessible:
|
|
44
|
-
|
|
45
|
-
- Contember Admin at http://localhost:1480
|
|
46
|
-
- Contember Engine endpoints at http://localhost:1481 (you can authorize with token 0000000000000000000000000000000000000000)
|
|
47
|
-
- Adminer database management tool at http://localhost:1485
|
|
48
|
-
- Minio local S3 provider at http://localhost:1483 (you can sign in with contember / contember credentials)
|
|
49
|
-
- MailHog testing SMTP at http://localhost:1484
|
|
50
|
-
- PostgreSQL database at localhost:1482 (you can sign in with contember / contember credentials)
|
|
51
|
-
|
|
52
|
-
If you have any issues or questions, just ask here: https://github.com/contember/engine/discussions
|
|
53
|
-
`;
|
|
54
|
-
//# sourceMappingURL=WorkspaceCreateCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceCreateCommand.js","sourceRoot":"","sources":["../../../src/commands/WorkspaceCreateCommand.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA+F;AAC/F,yCAAgC;AAChC,kDAAyB;AAUzB,MAAa,sBAAuB,SAAQ,oBAAsB;IACjE,YACkB,iBAAoC;QAErD,KAAK,EAAE,CAAA;QAFU,sBAAiB,GAAjB,iBAAiB,CAAmB;IAGtD,CAAC;IAES,SAAS,CAAC,aAAkD;QACrE,aAAa,CAAC,WAAW,CAAC,mCAAmC,CAAC,CAAA;QAC9D,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;IACxC,CAAC;IAES,KAAK,CAAC,OAAO,CAAC,KAA2B;QAClD,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QACxD,MAAM,kBAAkB,GAAG,IAAA,gBAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAA;QAC7D,MAAM,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,+BAA+B,EAAE,kBAAkB,EAAE;YACjG,OAAO,EAAE,IAAA,8BAAiB,GAAE;YAC5B,WAAW,EAAE,aAAa;SAC1B,CAAC,CAAA;QACF,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC,CAAA;IAC3D,CAAC;CACD;AAtBD,wDAsBC;AAED,MAAM,UAAU,GAAG,CAAC,kBAA0B,EAAE,aAAqB,EAAE,EAAE,CAAC;oEACN,kBAAkB;;;IAGlF,eAAK,CAAC,WAAW,CAAC,MAAM,aAAa,EAAE,CAAC;;;IAGxC,eAAK,CAAC,WAAW,CAAC,cAAc,CAAC;;;IAGjC,eAAK,CAAC,WAAW,CAAC,YAAY,CAAC;;;;;;;;;;;;CAYlC,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./WorkspaceCreateCommand"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/lib/FileSystem.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG/B,qBAAa,UAAU;IACtB,QAAQ,qBAAc;IACtB,SAAS,sBAAe;IACxB,MAAM,mBAAY;IAClB,OAAO,oBAAa;IACpB,IAAI,cAAO;IACX,MAAM,mBAAY;IAClB,UAAU,SAAgB,MAAM,sBAO/B;IACD,aAAa,wBAEZ;CACD"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.FileSystem = void 0;
|
|
27
|
-
const fs = __importStar(require("node:fs/promises"));
|
|
28
|
-
const promises_1 = require("node:fs/promises");
|
|
29
|
-
const fs_extra_1 = require("fs-extra");
|
|
30
|
-
const node_os_1 = require("node:os");
|
|
31
|
-
class FileSystem {
|
|
32
|
-
constructor() {
|
|
33
|
-
this.readFile = fs.readFile;
|
|
34
|
-
this.writeFile = fs.writeFile;
|
|
35
|
-
this.rename = fs.rename;
|
|
36
|
-
this.readDir = fs.readdir;
|
|
37
|
-
this.copy = fs_extra_1.copy;
|
|
38
|
-
this.unlink = fs.unlink;
|
|
39
|
-
this.pathExists = async (path) => {
|
|
40
|
-
try {
|
|
41
|
-
await (0, promises_1.access)(path);
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
catch (_a) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
this.createTempDir = async () => {
|
|
49
|
-
return await fs.mkdtemp((0, node_os_1.tmpdir)());
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.FileSystem = FileSystem;
|
|
54
|
-
//# sourceMappingURL=FileSystem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.js","sourceRoot":"","sources":["../../../src/lib/FileSystem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsC;AACtC,+CAAyC;AACzC,uCAA+B;AAC/B,qCAAgC;AAEhC,MAAa,UAAU;IAAvB;QACC,aAAQ,GAAG,EAAE,CAAC,QAAQ,CAAA;QACtB,cAAS,GAAG,EAAE,CAAC,SAAS,CAAA;QACxB,WAAM,GAAG,EAAE,CAAC,MAAM,CAAA;QAClB,YAAO,GAAG,EAAE,CAAC,OAAO,CAAA;QACpB,SAAI,GAAG,eAAI,CAAA;QACX,WAAM,GAAG,EAAE,CAAC,MAAM,CAAA;QAClB,eAAU,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;YACnC,IAAI;gBACH,MAAM,IAAA,iBAAM,EAAC,IAAI,CAAC,CAAA;gBAClB,OAAO,IAAI,CAAA;aACX;YAAC,WAAM;gBACP,OAAO,KAAK,CAAA;aACZ;QACF,CAAC,CAAA;QACD,kBAAa,GAAG,KAAK,IAAI,EAAE;YAC1B,OAAO,MAAM,EAAE,CAAC,OAAO,CAAC,IAAA,gBAAM,GAAE,CAAC,CAAA;QAClC,CAAC,CAAA;IACF,CAAC;CAAA;AAlBD,gCAkBC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PackageDownloader = void 0;
|
|
7
|
-
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
8
|
-
const registry_info_1 = __importDefault(require("registry-info"));
|
|
9
|
-
const get_package_json_from_registry_1 = __importDefault(require("get-package-json-from-registry"));
|
|
10
|
-
const node_path_1 = require("node:path");
|
|
11
|
-
const download_tarball_1 = __importDefault(require("download-tarball"));
|
|
12
|
-
class PackageDownloader {
|
|
13
|
-
constructor(fs) {
|
|
14
|
-
this.fs = fs;
|
|
15
|
-
this.downloadPackage = async (pkgName) => {
|
|
16
|
-
const { scope } = (0, npm_package_arg_1.default)(pkgName);
|
|
17
|
-
const { authorization } = (0, registry_info_1.default)(scope);
|
|
18
|
-
const headers = authorization ? { authorization } : {};
|
|
19
|
-
const pkg = await (0, get_package_json_from_registry_1.default)(pkgName);
|
|
20
|
-
const { dist: { tarball }, } = pkg;
|
|
21
|
-
const tmpDir = await this.fs.createTempDir();
|
|
22
|
-
await (0, download_tarball_1.default)({ url: tarball, gotOpts: { headers }, dir: tmpDir });
|
|
23
|
-
const dirContent = await this.fs.readDir(tmpDir);
|
|
24
|
-
if (dirContent.length !== 1 || dirContent[0] !== 'package') {
|
|
25
|
-
throw 'Invalid NPM package';
|
|
26
|
-
}
|
|
27
|
-
return (0, node_path_1.join)(tmpDir, 'package');
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.PackageDownloader = PackageDownloader;
|
|
32
|
-
//# sourceMappingURL=PackageDownloader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PackageDownlo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
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TemplateInstaller = void 0;
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
|
-
class TemplateInstaller {
|
|
10
|
-
constructor(resourceDir, packageDownloader, fs) {
|
|
11
|
-
this.resourceDir = resourceDir;
|
|
12
|
-
this.packageDownloader = packageDownloader;
|
|
13
|
-
this.fs = fs;
|
|
14
|
-
this.localTemplates = {
|
|
15
|
-
['@contember/template-workspace']: (0, node_path_1.join)(this.resourceDir, 'templates/template-workspace'),
|
|
16
|
-
};
|
|
17
|
-
this.installTemplate = async (template, targetDir, variables = {}) => {
|
|
18
|
-
let removeTemplate = () => {
|
|
19
|
-
};
|
|
20
|
-
if (this.localTemplates[template]) {
|
|
21
|
-
template = this.localTemplates[template];
|
|
22
|
-
}
|
|
23
|
-
if (!(0, node_path_1.isAbsolute)(template)) {
|
|
24
|
-
template = await this.packageDownloader.downloadPackage(template);
|
|
25
|
-
removeTemplate = async () => {
|
|
26
|
-
await this.fs.unlink(template);
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const templateConfigFile = (0, node_path_1.join)(template, 'contember.template.yaml');
|
|
30
|
-
if (!(await this.fs.pathExists(templateConfigFile))) {
|
|
31
|
-
throw `${template} is not a Contember template`;
|
|
32
|
-
}
|
|
33
|
-
const config = (await this.readYaml(templateConfigFile));
|
|
34
|
-
const nodeModulesDir = (0, node_path_1.join)(template, 'node_modules');
|
|
35
|
-
const skippedFiles = new Set([...(config.remove || []).map(it => (0, node_path_1.join)(template, it)), templateConfigFile]);
|
|
36
|
-
if (await this.fs.pathExists(targetDir)) {
|
|
37
|
-
throw `${targetDir} already exists`;
|
|
38
|
-
}
|
|
39
|
-
await this.fs.copy(template, targetDir, {
|
|
40
|
-
filter: src => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src),
|
|
41
|
-
});
|
|
42
|
-
await removeTemplate();
|
|
43
|
-
if (config.patchPackageJson) {
|
|
44
|
-
await this.replaceFileContent((0, node_path_1.join)(targetDir, 'package.json'), content => {
|
|
45
|
-
const { name, version, 'scripts-template': scripts, scripts: _nullScripts, license, ...json } = JSON.parse(content);
|
|
46
|
-
return JSON.stringify({ scripts, ...json }, null, ' ');
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
for (const [source, target] of Object.entries(config.rename || {})) {
|
|
50
|
-
await this.fs.rename((0, node_path_1.join)(targetDir, source), (0, node_path_1.join)(targetDir, target));
|
|
51
|
-
}
|
|
52
|
-
for (const [source, target] of Object.entries(config.copy || {})) {
|
|
53
|
-
await this.fs.copy((0, node_path_1.join)(targetDir, source), (0, node_path_1.join)(targetDir, target));
|
|
54
|
-
}
|
|
55
|
-
for (const file of config.replaceVariables || []) {
|
|
56
|
-
const path = (0, node_path_1.join)(targetDir, file);
|
|
57
|
-
if (!(await this.fs.pathExists(path))) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
await this.replaceFileContent(path, content => Object.entries(variables).reduce((content, [key, value]) => content.replace(new RegExp(`\{${key}\}`, 'g'), value), content));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
this.replaceFileContent = async (path, replacer) => {
|
|
64
|
-
const content = await this.fs.readFile(path, { encoding: 'utf8' });
|
|
65
|
-
const newContent = replacer(content);
|
|
66
|
-
await this.fs.writeFile(path, newContent, { encoding: 'utf8' });
|
|
67
|
-
};
|
|
68
|
-
this.readYaml = async (path) => {
|
|
69
|
-
const content = await this.fs.readFile(path, { encoding: 'utf8' });
|
|
70
|
-
return js_yaml_1.default.load(content);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.TemplateInstaller = TemplateInstaller;
|
|
75
|
-
//# sourceMappingURL=TemplateInst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CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;YAClE,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;YACpC,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;QAChE,CAAC,CAAA;QAEO,aAAQ,GAAG,KAAK,EAAe,IAAY,EAAc,EAAE;YAClE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;YAClE,OAAO,iBAAM,CAAC,IAAI,CAAC,OAAO,CAAiB,CAAA;QAC5C,CAAC,CAAA;IAnFD,CAAC;CAoFD;AA/FD,8CA+FC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../../src/lib/pathUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,QAAyH,CAAA;AACjJ,eAAO,MAAM,YAAY,QAAmC,CAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resourcesDir = exports.packageRoot = void 0;
|
|
4
|
-
const node_path_1 = require("node:path");
|
|
5
|
-
exports.packageRoot = process.env.CONTEMBER_CLI_PACKAGE_ROOT || (0, node_path_1.join)(__dirname, __dirname.endsWith('dist/src/lib') ? '../../../' : '../../');
|
|
6
|
-
exports.resourcesDir = (0, node_path_1.join)(exports.packageRoot, './resources');
|
|
7
|
-
//# sourceMappingURL=pathUtils.js.map
|