Skip to content

Commit 3d8581b

Browse files
authored
Fix wasm build (#37)
Co-authored-by: Tony Meehan <tonymeehan@users.noreply.github.com>
1 parent 596018d commit 3d8581b

4 files changed

Lines changed: 27 additions & 28 deletions

File tree

internal/pkg/cli/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func InitAndExecute(ctx context.Context) error {
7676
var (
7777
c *config.Config
7878
token string
79-
rulesPaths []rules.RulePathT
79+
rulesPaths []utils.RulePathT
8080
err error
8181
)
8282

internal/pkg/engine/engine.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/Masterminds/semver"
1515
"github.com/prequel-dev/preq/internal/pkg/matchz"
1616
"github.com/prequel-dev/preq/internal/pkg/resolve"
17-
"github.com/prequel-dev/preq/internal/pkg/rules"
1817
"github.com/prequel-dev/preq/internal/pkg/utils"
1918
"github.com/prequel-dev/preq/internal/pkg/ux"
2019
"github.com/prequel-dev/prequel-compiler/pkg/compiler"
@@ -87,7 +86,7 @@ func compileRuleTree(cf compiler.RuntimeI, tree *parser.TreeT) (compiler.ObjsT,
8786
return nodeObjs, nil
8887
}
8988

90-
func compileRulePath(cf compiler.RuntimeI, rp rules.RulePathT) (compiler.ObjsT, *parser.RulesT, error) {
89+
func compileRulePath(cf compiler.RuntimeI, rp utils.RulePathT) (compiler.ObjsT, *parser.RulesT, error) {
9190
var (
9291
rs *parser.RulesT
9392
tree *parser.TreeT
@@ -100,9 +99,9 @@ func compileRulePath(cf compiler.RuntimeI, rp rules.RulePathT) (compiler.ObjsT,
10099
log.Info().Str("path", rp.Path).Msg("Parsing rules")
101100

102101
switch rp.Type {
103-
case rules.RuleTypeCre:
102+
case utils.RuleTypeCre:
104103
rdrOpts = append(rdrOpts, utils.WithMultiDoc())
105-
case rules.RuleTypeUser:
104+
case utils.RuleTypeUser:
106105
// Allow empty IDs in user generated content
107106
rdrOpts = append(rdrOpts, utils.WithGenIds())
108107
parseOpts = append(parseOpts, parser.WithGenIds())
@@ -196,7 +195,7 @@ func (r *RuntimeT) compileRules(cf compiler.RuntimeI, data []byte) (compiler.Obj
196195

197196
}
198197

199-
func (r *RuntimeT) compileRulesPaths(cf compiler.RuntimeI, paths []rules.RulePathT) (compiler.ObjsT, []*parser.RulesT, error) {
198+
func (r *RuntimeT) compileRulesPaths(cf compiler.RuntimeI, paths []utils.RulePathT) (compiler.ObjsT, []*parser.RulesT, error) {
200199
var (
201200
nodeObjs = make(compiler.ObjsT, 0)
202201
allRules = make([]*parser.RulesT, 0)
@@ -488,7 +487,7 @@ func (r *RuntimeT) getRuntimeCb(report *ux.ReportT) *runtimeT {
488487
return runtime
489488
}
490489

491-
func (r *RuntimeT) CompileRulesPath(rulesPaths []rules.RulePathT, report *ux.ReportT) (*RuleMatchersT, error) {
490+
func (r *RuntimeT) CompileRulesPath(rulesPaths []utils.RulePathT, report *ux.ReportT) (*RuleMatchersT, error) {
492491

493492
var (
494493
nodeObjs compiler.ObjsT
@@ -519,7 +518,7 @@ func (r *RuntimeT) CompileRulesPath(rulesPaths []rules.RulePathT, report *ux.Rep
519518
return matchers, nil
520519
}
521520

522-
func (r *RuntimeT) LoadRulesPaths(rep *ux.ReportT, rulesPaths []rules.RulePathT) (*RuleMatchersT, error) {
521+
func (r *RuntimeT) LoadRulesPaths(rep *ux.ReportT, rulesPaths []utils.RulePathT) (*RuleMatchersT, error) {
523522

524523
var (
525524
ruleMatchers *RuleMatchersT

internal/pkg/rules/rules.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,10 @@ const (
9494
maxResp = 1500 // typical MTU size
9595
)
9696

97-
type RuleTypeT string
98-
99-
const (
100-
RuleTypeCre RuleTypeT = "cre"
101-
RuleTypeUser RuleTypeT = "user"
102-
)
103-
104-
type RulePathT struct {
105-
Path string
106-
Type RuleTypeT
107-
}
108-
109-
func GetRules(ctx context.Context, conf *config.Config, configDir, cmdLineRules, token, ruleUpdateFile, baseAddr string, tlsPort, udpPort int) ([]RulePathT, error) {
97+
func GetRules(ctx context.Context, conf *config.Config, configDir, cmdLineRules, token, ruleUpdateFile, baseAddr string, tlsPort, udpPort int) ([]utils.RulePathT, error) {
11098
var (
11199
syncRulesPath string
112-
rulePaths = make([]RulePathT, 0)
100+
rulePaths = make([]utils.RulePathT, 0)
113101
err error
114102
)
115103

@@ -120,23 +108,23 @@ func GetRules(ctx context.Context, conf *config.Config, configDir, cmdLineRules,
120108
}
121109

122110
if syncRulesPath != "" && !conf.Rules.Disabled {
123-
rulePaths = append(rulePaths, RulePathT{
111+
rulePaths = append(rulePaths, utils.RulePathT{
124112
Path: syncRulesPath,
125-
Type: RuleTypeCre,
113+
Type: utils.RuleTypeCre,
126114
})
127115
}
128116

129117
if cmdLineRules != "" {
130-
rulePaths = append(rulePaths, RulePathT{
118+
rulePaths = append(rulePaths, utils.RulePathT{
131119
Path: cmdLineRules,
132-
Type: RuleTypeUser,
120+
Type: utils.RuleTypeUser,
133121
})
134122
}
135123

136124
for _, path := range conf.Rules.Paths {
137-
rulePaths = append(rulePaths, RulePathT{
125+
rulePaths = append(rulePaths, utils.RulePathT{
138126
Path: path,
139-
Type: RuleTypeUser,
127+
Type: utils.RuleTypeUser,
140128
})
141129
}
142130

internal/pkg/utils/utils.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ var (
3131
sectionRules = "rules"
3232
)
3333

34+
type RuleTypeT string
35+
36+
const (
37+
RuleTypeCre RuleTypeT = "cre"
38+
RuleTypeUser RuleTypeT = "user"
39+
)
40+
41+
type RulePathT struct {
42+
Path string
43+
Type RuleTypeT
44+
}
45+
3446
func GetStopTime() (ts int64) {
3547
return math.MaxInt64
3648
}

0 commit comments

Comments
 (0)