mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
Replace fuzzy matching (HasMatch) with exact file path checks (HasFile) in all providers where specific files are being checked. This prevents false positives from glob pattern matching when checking for specific file names. Changes: - PHP provider: index.php, composer.json, artisan - Go provider: main.go, go.mod, go.work, go.sum, go.work.sum - Ruby provider: Gemfile, rails, bin/rails, config/environment.rb, config.ru, Rakefile - Node providers: package.json, lock files, config files for Vite, Astro, Angular, React Router - Python providers: main.py, requirements.txt, pyproject.toml, Pipfile, poetry.lock, pdm.lock, uv.lock, manage.py - Rust provider: Cargo.toml, src/main.rs, src/lib.rs - Elixir provider: mix.exs - Deno provider: deno.json, deno.jsonc, main.ts/js/mjs/mts - Java providers: gradlew, mvnw, gradle/maven wrapper properties - Staticfile provider: index.html, Staticfile config - Core: template.go and mise_step_builder.go Directory checks (e.g. src/bin, node_modules, public, script) continue to use HasMatch as they need pattern/directory matching. Co-authored-by: Hanzo Dev <[email protected]>
71 lines
1.7 KiB
Go
71 lines
1.7 KiB
Go
package node
|
|
|
|
import (
|
|
"encoding/json"
|
|
"path"
|
|
"strings"
|
|
|
|
"github.com/railwayapp/railpack/core/generate"
|
|
)
|
|
|
|
const (
|
|
DefaultAngularStartCommand = "ng serve"
|
|
)
|
|
|
|
func (p *NodeProvider) isAngular(ctx *generate.GenerateContext) bool {
|
|
hasAngularDep := p.hasDependency("@angular/core")
|
|
hasAngularConfig := ctx.App.HasFile("angular.json")
|
|
hasAngularBuildCommand := strings.Contains(strings.ToLower(p.packageJson.GetScript("build")), "ng build")
|
|
|
|
return hasAngularDep && hasAngularConfig && hasAngularBuildCommand
|
|
}
|
|
|
|
type AngularConfig struct {
|
|
Projects map[string]struct {
|
|
Architect struct {
|
|
Build struct {
|
|
Builder string `json:"builder"`
|
|
Options struct {
|
|
OutputPath string `json:"outputPath"`
|
|
Browser string `json:"browser,omitempty"`
|
|
} `json:"options"`
|
|
} `json:"build"`
|
|
} `json:"architect"`
|
|
} `json:"projects"`
|
|
}
|
|
|
|
func (p *NodeProvider) getAngularOutputDirectory(ctx *generate.GenerateContext) string {
|
|
angularJson, err := ctx.App.ReadFile("angular.json")
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
var config AngularConfig
|
|
if err := json.Unmarshal([]byte(angularJson), &config); err != nil {
|
|
return ""
|
|
}
|
|
|
|
var projectName string
|
|
if name, _ := ctx.Env.GetConfigVariable("ANGULAR_PROJECT"); name != "" {
|
|
projectName = name
|
|
}
|
|
|
|
for name, project := range config.Projects {
|
|
if projectName != "" && projectName != name {
|
|
continue
|
|
}
|
|
|
|
outputPath := project.Architect.Build.Options.OutputPath
|
|
|
|
// Check if it's using the new application builder or has a browser field
|
|
if project.Architect.Build.Builder == "@angular-devkit/build-angular:application" ||
|
|
project.Architect.Build.Options.Browser != "" {
|
|
return path.Join(outputPath, "browser")
|
|
}
|
|
|
|
return outputPath
|
|
}
|
|
|
|
return ""
|
|
}
|