diff --git a/Makefile b/Makefile index e09f834..f634819 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ MAINTAINER_NAME = Jose Diaz-Gonzalez REPOSITORY = procfile-util HARDWARE = $(shell uname -m) SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]') -BASE_VERSION ?= 0.17.0 +BASE_VERSION ?= 0.17.1 IMAGE_NAME ?= $(MAINTAINER)/$(REPOSITORY) PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish diff --git a/fixtures/comments.Procfile b/fixtures/comments.Procfile index af4deb0..f569854 100644 --- a/fixtures/comments.Procfile +++ b/fixtures/comments.Procfile @@ -4,7 +4,7 @@ # Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job) cron: node worker.js -web: node web.js # testing inline comment +web : node web.js # testing inline comment wor-ker: node worker.js # -wor-ker2: node worker.js # -wor-ker_2: node worker.js diff --git a/go.mod b/go.mod index fc5a1e7..bac7b05 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 github.com/joho/godotenv v1.5.1 - github.com/josegonzalez/cli-skeleton v0.15.0 + github.com/josegonzalez/cli-skeleton v0.16.0 github.com/mitchellh/cli v1.1.5 github.com/posener/complete v1.2.3 github.com/spf13/pflag v1.0.5 @@ -33,7 +33,7 @@ require ( github.com/rs/zerolog v1.32.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/term v0.16.0 // indirect + golang.org/x/crypto v0.19.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/term v0.17.0 // indirect ) diff --git a/go.sum b/go.sum index dd75e69..f073ed4 100644 --- a/go.sum +++ b/go.sum @@ -42,8 +42,8 @@ github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -github.com/josegonzalez/cli-skeleton v0.15.0 h1:8AuxPC+KioDnBf9K+ZIE+1tYbayOUBJAluoUnCyHdIc= -github.com/josegonzalez/cli-skeleton v0.15.0/go.mod h1:iCpaNFH5JS8kk8VfEsa+Ml6VNw/3oIIPYV7XDXaBypA= +github.com/josegonzalez/cli-skeleton v0.16.0 h1:IKt/d42bCswjL4KfYMTMZPZHcBgKzc4etawi/8hYk2o= +github.com/josegonzalez/cli-skeleton v0.16.0/go.mod h1:Ct2h/SppcOOPkarLPk6LNmMSCDzCQRv9bpNv1oeRXZI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -93,8 +93,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -104,10 +104,10 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61 h1:8ajkpB4hXVftY5ko905id+dOnmorcS2CHNxxHLLDcFM= gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61/go.mod h1:IfMagxm39Ys4ybJrDb7W3Ob8RwxftP0Yy+or/NVz1O8= diff --git a/procfile/parse.go b/procfile/parse.go index 5f8900b..88b9c42 100644 --- a/procfile/parse.go +++ b/procfile/parse.go @@ -34,8 +34,8 @@ func ParseFormation(formation string) (map[string]FormationEntry, error) { // ParseProcfile parses text as a procfile and returns a list of procfile entries func ParseProcfile(text string, delimiter string, strict bool) ([]ProcfileEntry, error) { var entries []ProcfileEntry - reCmd, _ := regexp.Compile(`^([a-z0-9]([-a-z0-9]*[a-z0-9])?)` + delimiter + `\s*(.+)$`) - reOldCmd, _ := regexp.Compile(`^([A-Za-z0-9_-]+)` + delimiter + `\s*(.+)$`) + reCmd, _ := regexp.Compile(`^([a-z0-9]([-a-z0-9]*[a-z0-9])?)\s*` + delimiter + `\s*(.+)$`) + reOldCmd, _ := regexp.Compile(`^([A-Za-z0-9_-]+)\s*` + delimiter + `\s*(.+)$`) reComment, _ := regexp.Compile(`^(.*)\s#.+$`) reForwardslashComment, _ := regexp.Compile(`^(.*)\s//.+$`) diff --git a/test.bats b/test.bats index 81edc96..fc12ffc 100644 --- a/test.bats +++ b/test.bats @@ -16,7 +16,24 @@ teardown_file() { echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "valid procfile detected 2custom, cron, custom, release, web, wor-ker" + assert_output "valid procfile detected 2custom, cron, custom, release, web, wor-ker" + + run $PROCFILE_BIN list -P fixtures/comments.Procfile + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "2custom +cron +custom +release +web +wor-ker" + + run $PROCFILE_BIN show -P fixtures/comments.Procfile -p web + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "node web.js" } @test "[lax] forwardslash-comments" { @@ -24,13 +41,21 @@ teardown_file() { echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "valid procfile detected web, worker, worker-2" + assert_output "valid procfile detected web, worker, worker-2" run $PROCFILE_BIN show -P fixtures/forwardslash-comments.Procfile -p worker echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "node worker.js" + assert_output "node worker.js" + + run $PROCFILE_BIN list -P fixtures/forwardslash-comments.Procfile + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "web +worker +worker-2" } @test "[lax] multiple" { @@ -38,7 +63,16 @@ teardown_file() { echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "valid procfile detected release, web, webpacker, worker" + assert_output "valid procfile detected release, web, webpacker, worker" + + run $PROCFILE_BIN list -P fixtures/multiple.Procfile + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "release +web +webpacker +worker" } @test "[lax] port" { @@ -46,13 +80,20 @@ teardown_file() { echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "valid procfile detected web, worker" + assert_output "valid procfile detected web, worker" run $PROCFILE_BIN show -P fixtures/port.Procfile -p web echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "node web.js --port 5000" + assert_output "node web.js --port 5000" + + run $PROCFILE_BIN list -P fixtures/port.Procfile + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "web +worker" } @test "[strict] comments" { @@ -60,7 +101,18 @@ teardown_file() { echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "valid procfile detected 2custom, cron, custom, release, web, wor-ker" + assert_output "valid procfile detected 2custom, cron, custom, release, web, wor-ker" + + run $PROCFILE_BIN list -S -P fixtures/comments.Procfile + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "2custom +cron +custom +release +web +wor-ker" } @test "[strict] forwardslash-comments" { @@ -68,13 +120,21 @@ teardown_file() { echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "valid procfile detected web, worker, worker-2" + assert_output "valid procfile detected web, worker, worker-2" run $PROCFILE_BIN show -S -P fixtures/forwardslash-comments.Procfile -p worker echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "node worker.js" + assert_output "node worker.js" + + run $PROCFILE_BIN list -S -P fixtures/forwardslash-comments.Procfile + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "web +worker +worker-2" } @test "[strict] multiple" { @@ -82,7 +142,16 @@ teardown_file() { echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "valid procfile detected release, web, webpacker, worker" + assert_output "valid procfile detected release, web, webpacker, worker" + + run $PROCFILE_BIN list -S -P fixtures/multiple.Procfile + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "release +web +webpacker +worker" } @test "[strict] port" { @@ -90,13 +159,20 @@ teardown_file() { echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "valid procfile detected web, worker" + assert_output "valid procfile detected web, worker" run $PROCFILE_BIN show -S -P fixtures/port.Procfile -p web echo "output: $output" echo "status: $status" [[ "$status" -eq 0 ]] - assert_output_contains "node web.js --port 5000" + assert_output "node web.js --port 5000" + + run $PROCFILE_BIN list -S -P fixtures/port.Procfile + echo "output: $output" + echo "status: $status" + [[ "$status" -eq 0 ]] + assert_output "web +worker" } flunk() {