-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from seggewiss/1.0.0
Implement v1.0.0
- Loading branch information
Showing
7 changed files
with
397 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
package components | ||
|
||
type Component struct { | ||
Name string | ||
Model string | ||
Event string | ||
} | ||
|
||
func GetAutoFixableComponents() []Component { | ||
return []Component{ | ||
// src/app/component/form | ||
{ | ||
Name: "sw-url-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-textarea-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-text-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-text-editor", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-tagged-field", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-switch-field", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-select-number-field", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-select-field", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-radio-field", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-purchase-price-field", | ||
Model: "price", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-price-field", | ||
Model: "price", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-password-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-number-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-gtc-checkbox", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-form-field-renderer", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-file-input", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-email-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-dynamic-url-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-confirm-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-compact-colorpicker", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-colorpicker", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
{ | ||
Name: "sw-checkbox-field", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-boolean-radio-group", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-single-select", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-multi-tag-select", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-multi-tag-ip-select", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-multi-select", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-grouped-single-select", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-entity-single-select", | ||
Model: "value", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-entity-multi-select", | ||
Model: "entityCollection", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-entity-tag-select", | ||
Model: "entityCollection", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-entity-multi-id-select", | ||
Model: "ids", | ||
Event: "change", | ||
}, | ||
{ | ||
Name: "sw-entity-many-to-many-select", | ||
Model: "entityCollection", | ||
Event: "change", | ||
}, | ||
// src/app/component/base | ||
{ | ||
Name: "sw-button-process", | ||
Model: "processSuccess", // There should be no v-model for this but the event needs to be changed | ||
Event: "process-finish", | ||
}, | ||
{ | ||
Name: "sw-simple-search-field", | ||
Model: "value", | ||
Event: "input", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package options | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
) | ||
|
||
type Options struct { | ||
Auto bool | ||
WorkingDirectory string | ||
ComponentName string | ||
ModelName string | ||
EventName string | ||
FileExtension string | ||
} | ||
|
||
func GetOptions() Options { | ||
cwd, err := os.Getwd() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
autoPtr := flag.Bool("auto", false, "Automatically fix all base components. Overrides -component, -model and -event!") | ||
componentNamePtr := flag.String("component", "", "The name of the component to refactor") | ||
modelNamePtr := flag.String("model", "value", "The name of the model to use") | ||
eventNamePtr := flag.String("event", "input", "The name of the event to use") | ||
direcotryPtr := flag.String("directory", cwd, "The directory to search for components") | ||
extensionPtr := flag.String("extension", ".twig", "The file extension to search for") | ||
|
||
flag.Parse() | ||
|
||
return Options{ | ||
Auto: *autoPtr, | ||
WorkingDirectory: *direcotryPtr, | ||
ComponentName: *componentNamePtr, | ||
ModelName: *modelNamePtr, | ||
EventName: *eventNamePtr, | ||
FileExtension: *extensionPtr, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package processors | ||
|
||
import "regexp" | ||
|
||
type eventProcessor struct{} | ||
|
||
func (p *eventProcessor) Process(options *ProcessorOptions) string { | ||
// https://regex101.com/r/VkXBIA/1 | ||
eventRegex := regexp.MustCompile(`(<` + options.ComponentName + `\n( *)[a-zA-Z0-9.\-+*#:_$(')@!=>"{%}\[\]? \n|/` + "`" + `&]*)@` + options.EventName + `="(.*)"`) | ||
eventFixed := eventRegex.ReplaceAllString(options.Text, "${1}{% if VUE3 %}\n${2}@update:"+options.ModelName+"=\"${3}\"\n${2}{% else %}\n${2}@"+options.EventName+"=\"${3}\"\n${2}{% endif %}") | ||
|
||
return eventFixed | ||
} | ||
|
||
func NewEventProcessor() Processor { | ||
return &eventProcessor{} | ||
} |
Oops, something went wrong.