@@ -207,28 +207,28 @@ func (pm *PackageManager) Create(opts PackageCreateOpts) (string, error) {
207
207
if opts .PushContent {
208
208
for _ , contentPath := range opts .ContentPaths {
209
209
if pathx .IsDir (contentPath ) {
210
- _ , after , _ := strings . Cut (contentPath , content . JCRRoot )
211
- if err = pathx .Ensure (filepath .Join (tmpDir , content .JCRRoot , after )); err != nil {
210
+ jcrPath := content . DetermineJcrPath (contentPath )
211
+ if err = pathx .Ensure (filepath .Join (tmpDir , content .JCRRoot , jcrPath )); err != nil {
212
212
return "" , err
213
213
}
214
- if err = filex .CopyDir (contentPath , filepath .Join (tmpDir , content .JCRRoot , after )); err != nil {
214
+ if err = filex .CopyDir (contentPath , filepath .Join (tmpDir , content .JCRRoot , jcrPath )); err != nil {
215
215
return "" , err
216
216
}
217
217
} else if pathx .IsFile (contentPath ) {
218
218
dir := filepath .Dir (contentPath )
219
- _ , after , _ := strings . Cut (dir , content . JCRRoot )
220
- if err = pathx .Ensure (filepath .Join (tmpDir , content .JCRRoot , after )); err != nil {
219
+ jcrPath := content . DetermineJcrPath (dir )
220
+ if err = pathx .Ensure (filepath .Join (tmpDir , content .JCRRoot , jcrPath )); err != nil {
221
221
return "" , err
222
222
}
223
- _ , after , _ = strings . Cut (contentPath , content . JCRRoot )
224
- if err = filex .Copy (contentPath , filepath .Join (tmpDir , content .JCRRoot , after ), true ); err != nil {
223
+ jcrPath = content . DetermineJcrPath (contentPath )
224
+ if err = filex .Copy (contentPath , filepath .Join (tmpDir , content .JCRRoot , jcrPath ), true ); err != nil {
225
225
return "" , err
226
226
}
227
227
if strings .HasSuffix (contentPath , content .JCRContentFile ) {
228
228
dir = strings .ReplaceAll (contentPath , content .JCRContentNode , content .JCRContentDirName )
229
- _ , after , _ = strings .Cut (dir , content .JCRRoot )
230
229
if pathx .Exists (dir ) {
231
- if err = filex .CopyDir (dir , filepath .Join (tmpDir , content .JCRRoot , after )); err != nil {
230
+ jcrPath := content .DetermineJcrPath (dir )
231
+ if err = filex .CopyDir (dir , filepath .Join (tmpDir , content .JCRRoot , jcrPath )); err != nil {
232
232
return "" , err
233
233
}
234
234
}
@@ -262,22 +262,17 @@ func (pm *PackageManager) Create(opts PackageCreateOpts) (string, error) {
262
262
func determineFilterRoots (opts PackageCreateOpts ) []string {
263
263
var filterRoots []string
264
264
for _ , contentPath := range opts .ContentPaths {
265
- if pathx .IsDir (contentPath ) {
266
- filterRoots = append (filterRoots , strings .Split (contentPath , content .JCRRoot )[1 ])
267
- } else if pathx .IsFile (contentPath ) {
268
- contentFile := strings .Split (contentPath , content .JCRRoot )[1 ]
269
- if content .IsContentFile (contentPath ) {
270
- filterRoots = append (filterRoots , strings .ReplaceAll (contentFile , content .JCRContentFile , content .JCRContentNode ))
271
- } else if strings .HasSuffix (contentFile , content .JCRContentFile ) {
272
- contentFile = namespacePatternRegex .ReplaceAllString (contentFile , "$1:" )
273
- filterRoots = append (filterRoots , filepath .Dir (contentFile ))
274
- } else if strings .HasSuffix (contentFile , content .JCRContentFileSuffix ) {
275
- contentFile = namespacePatternRegex .ReplaceAllString (contentFile , "$1:" )
276
- filterRoots = append (filterRoots , strings .ReplaceAll (contentFile , content .JCRContentFileSuffix , "" ))
277
- } else {
278
- filterRoots = append (filterRoots , contentFile )
279
- }
265
+ filterRoot := content .DetermineJcrPath (contentPath )
266
+ if content .IsContentFile (contentPath ) {
267
+ filterRoot = strings .ReplaceAll (filterRoot , content .JCRContentFile , content .JCRContentNode )
268
+ } else if strings .HasSuffix (filterRoot , content .JCRContentFile ) {
269
+ filterRoot = namespacePatternRegex .ReplaceAllString (filterRoot , "$1:" )
270
+ filterRoot = filepath .Dir (filterRoot )
271
+ } else if strings .HasSuffix (filterRoot , content .JCRContentFileSuffix ) {
272
+ filterRoot = namespacePatternRegex .ReplaceAllString (filterRoot , "$1:" )
273
+ filterRoot = strings .ReplaceAll (filterRoot , content .JCRContentFileSuffix , "" )
280
274
}
275
+ filterRoots = append (filterRoots , filterRoot )
281
276
}
282
277
return filterRoots
283
278
}
@@ -301,6 +296,9 @@ func (pm *PackageManager) Copy(remotePath string, destInstance *Instance) error
301
296
}
302
297
303
298
func (pm * PackageManager ) tmpDir () string {
299
+ if ! pm .instance .manager .aem .config .TemplateFileExists () {
300
+ return os .TempDir ()
301
+ }
304
302
return pm .instance .manager .aem .baseOpts .TmpDir
305
303
}
306
304
0 commit comments