Skip to content

Commit

Permalink
fix: make project admin-build working shopware/shopware
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Feb 11, 2024
1 parent 9f80fe3 commit a8f1283
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/project/project_admin_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var projectAdminBuildCmd = &cobra.Command{
DisableStorefrontBuild: true,
ShopwareRoot: projectRoot,
NPMForceInstall: forceInstall,
ContributeProject: extension.IsContributeProject(projectRoot),
}

if err := extension.BuildAssetsForExtensions(cmd.Context(), sources, assetCfg); err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/project/project_storefront_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var projectStorefrontBuildCmd = &cobra.Command{
DisableAdminBuild: true,
ShopwareRoot: projectRoot,
NPMForceInstall: forceInstall,
ContributeProject: extension.IsContributeProject(projectRoot),
}

if err := extension.BuildAssetsForExtensions(cmd.Context(), sources, assetCfg); err != nil {
Expand Down
9 changes: 8 additions & 1 deletion extension/asset_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type AssetBuildConfig struct {
Browserslist string
SkipExtensionsWithBuildFiles bool
NPMForceInstall bool
ContributeProject bool
}

func BuildAssetsForExtensions(ctx context.Context, sources []asset.Source, assetConfig AssetBuildConfig) error { // nolint:gocyclo
Expand Down Expand Up @@ -107,10 +108,16 @@ func BuildAssetsForExtensions(ctx context.Context, sources []asset.Source, asset
}
}

envList := []string{fmt.Sprintf("PROJECT_ROOT=%s", shopwareRoot)}

if !assetConfig.ContributeProject {
envList = append(envList, "SHOPWARE_ADMIN_BUILD_ONLY_EXTENSIONS=1", "SHOPWARE_ADMIN_SKIP_SOURCEMAP_GENERATION=1")
}

err = npmRunBuild(
administrationRoot,
"build",
[]string{fmt.Sprintf("PROJECT_ROOT=%s", shopwareRoot), "SHOPWARE_ADMIN_BUILD_ONLY_EXTENSIONS=1", "SHOPWARE_ADMIN_SKIP_SOURCEMAP_GENERATION=1"},
envList,
)

if assetConfig.CleanupNodeModules {
Expand Down
9 changes: 9 additions & 0 deletions extension/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ func PlatformPath(projectRoot, component, path string) string {

return filepath.Join(projectRoot, "vendor", "shopware", strings.ToLower(component), path)
}

// IsContributeProject checks if the project is a contribution project aka shopware/shopware
func IsContributeProject(projectRoot string) bool {
if _, err := os.Stat(filepath.Join(projectRoot, "src", "Core", "composer.json")); err == nil {
return true
}

return false
}

0 comments on commit a8f1283

Please sign in to comment.