Skip to content

Commit

Permalink
feat: add quartz
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippHeuer committed Sep 8, 2024
1 parent 61332e3 commit 398dee6
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions analyzer/scanners.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/cidverse/repoanalyzer/modules/nix"
"github.com/cidverse/repoanalyzer/modules/node"
"github.com/cidverse/repoanalyzer/modules/python"
"github.com/cidverse/repoanalyzer/modules/quartz"
)

// AllScanners contains all available scanners
Expand All @@ -38,4 +39,5 @@ var AllScanners = []analyzerapi.Scanner{
nix.Analyzer{},
node.Analyzer{},
python.Analyzer{},
quartz.Analyzer{},
}
1 change: 1 addition & 0 deletions analyzerapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const (
BuildSystemCargo ProjectBuildSystem = "cargo"
BuildSystemNix ProjectBuildSystem = "nix"
BuildSystemAnsible ProjectBuildSystem = "ansible"
BuildSystemQuartz ProjectBuildSystem = "quartz"
)

type ProjectBuildSystemSyntax string
Expand Down
1 change: 1 addition & 0 deletions modules/hugo/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/gosimple/slug"
)

// Analyzer for the Hugo Static Site Generator - https://gohugo.io/
type Analyzer struct{}

func (a Analyzer) GetName() string {
Expand Down
43 changes: 43 additions & 0 deletions modules/quartz/quartz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package quartz

import (
"path/filepath"

"github.com/cidverse/repoanalyzer/analyzerapi"
"github.com/gosimple/slug"
)

// Analyzer for the Quartz Static Site Generator - https://quartz.jzhao.xyz/
type Analyzer struct{}

func (a Analyzer) GetName() string {
return "quartz"
}

func (a Analyzer) Scan(ctx analyzerapi.AnalyzerContext) []*analyzerapi.ProjectModule {
var result []*analyzerapi.ProjectModule

for _, file := range ctx.Files {
filename := filepath.Base(file)
if filename == "quartz.config.ts" {
module := analyzerapi.ProjectModule{
RootDirectory: ctx.ProjectDir,
Directory: filepath.Dir(file),
Name: filepath.Base(filepath.Dir(file)),
Slug: slug.Make(filepath.Base(filepath.Dir(file))),
Discovery: []analyzerapi.ProjectModuleDiscovery{{File: file}},
Type: analyzerapi.ModuleTypeBuildSystem,
BuildSystem: analyzerapi.BuildSystemQuartz,
BuildSystemSyntax: analyzerapi.BuildSystemSyntaxDefault,
Language: nil,
Dependencies: nil,
Submodules: nil,
Files: ctx.Files,
FilesByExtension: ctx.FilesByExtension,
}
analyzerapi.AddModuleToResult(&result, &module)
}
}

return result
}
26 changes: 26 additions & 0 deletions modules/quartz/quartz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package quartz

import (
"testing"

"github.com/cidverse/repoanalyzer/analyzerapi"
"github.com/stretchr/testify/assert"
)

func TestAnalyzer_AnalyzeQuartz(t *testing.T) {
ctx := analyzerapi.GetAnalyzerContext(analyzerapi.GetTestDataDir(t, "quartz"))

analyzer := Analyzer{}
result := analyzer.Scan(ctx)

// module
assert.Len(t, result, 1)
assert.Equal(t, "quartz", result[0].Name)
assert.Equal(t, "quartz", string(result[0].BuildSystem))
assert.Equal(t, "default", string(result[0].BuildSystemSyntax))

// print result
for i, item := range result {
t.Logf("result[%d]: %+v", i, *item)
}
}
Empty file.
Empty file.

0 comments on commit 398dee6

Please sign in to comment.