Skip to content

Commit

Permalink
feat: move esbuild compatible to asset source
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Nov 3, 2023
1 parent c16e601 commit a916b56
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
12 changes: 8 additions & 4 deletions extension/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ func ConvertExtensionsToSources(ctx context.Context, extensions []Extension) []a
}

sources = append(sources, asset.Source{
Name: name,
Path: ext.GetRootDir(),
Name: name,
Path: ext.GetRootDir(),
AdminEsbuildCompatible: ext.GetExtensionConfig().Build.Zip.Assets.EnableESBuildForAdmin,
StorefrontEsbuildCompatible: ext.GetExtensionConfig().Build.Zip.Assets.EnableESBuildForStorefront,
})

extConfig := ext.GetExtensionConfig()
Expand All @@ -35,8 +37,10 @@ func ConvertExtensionsToSources(ctx context.Context, extensions []Extension) []a
}

sources = append(sources, asset.Source{
Name: bundleName,
Path: path.Join(ext.GetRootDir(), bundle.Path),
Name: bundleName,
Path: path.Join(ext.GetRootDir(), bundle.Path),
AdminEsbuildCompatible: ext.GetExtensionConfig().Build.Zip.Assets.EnableESBuildForAdmin,
StorefrontEsbuildCompatible: ext.GetExtensionConfig().Build.Zip.Assets.EnableESBuildForStorefront,
})
}
}
Expand Down
6 changes: 4 additions & 2 deletions extension/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

func TestConvertPlugin(t *testing.T) {
plugin := PlatformPlugin{
path: t.TempDir(),
path: t.TempDir(),
config: &Config{},
composer: platformComposerJson{
Extra: platformComposerJsonExtra{
ShopwarePluginClass: "FroshTools\\FroshTools",
Expand All @@ -28,7 +29,8 @@ func TestConvertPlugin(t *testing.T) {

func TestConvertApp(t *testing.T) {
app := App{
path: t.TempDir(),
path: t.TempDir(),
config: &Config{},
manifest: appManifest{
Meta: appManifestMeta{
Name: "TestApp",
Expand Down
13 changes: 11 additions & 2 deletions extension/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,18 @@ func FindAssetSourcesOfProject(ctx context.Context, project string) []asset.Sour

logging.FromContext(ctx).Infof("Found bundle in project: %s (path: %s)", name, bundlePath)

bundleConfig, err := readExtensionConfig(bundlePath)

if err != nil {
logging.FromContext(ctx).Errorf("Cannot read bundle config: %s", err.Error())
continue
}

sources = append(sources, asset.Source{
Name: name,
Path: path.Join(project, bundlePath),
Name: name,
Path: path.Join(project, bundlePath),
AdminEsbuildCompatible: bundleConfig.Build.Zip.Assets.EnableESBuildForAdmin,
StorefrontEsbuildCompatible: bundleConfig.Build.Zip.Assets.EnableESBuildForStorefront,
})
}

Expand Down
6 changes: 4 additions & 2 deletions internal/asset/source.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package asset

type Source struct {
Name string
Path string
Name string
Path string
AdminEsbuildCompatible bool
StorefrontEsbuildCompatible bool
}

0 comments on commit a916b56

Please sign in to comment.