diff --git a/cmd/ddev/cmd/commands.go b/cmd/ddev/cmd/commands.go index e5990f9a31a..9dc45cc24e9 100644 --- a/cmd/ddev/cmd/commands.go +++ b/cmd/ddev/cmd/commands.go @@ -3,6 +3,7 @@ package cmd import ( "bufio" "fmt" + "github.com/drud/ddev/pkg/nodeps" "io/ioutil" "os" "path" @@ -140,9 +141,11 @@ func addCustomCommands(rootCmd *cobra.Command) error { osTypes = val } - // If OSTypes is specified and we aren't this isn't a specified OS, skip - if osTypes != "" && !strings.Contains(osTypes, runtime.GOOS) { - continue + // If OSTypes is specified and we aren't on one of the specified OSes, skip + if osTypes != "" { + if !strings.Contains(osTypes, runtime.GOOS) && !(strings.Contains(osTypes, "wsl2") && nodeps.IsWSL2()) { + continue + } } // Import and handle HostBinaryExists @@ -151,8 +154,18 @@ func addCustomCommands(rootCmd *cobra.Command) error { } // If hostBinaryExists is specified it doesn't exist here, skip - if hostBinaryExists != "" && !fileutil.FileExists(hostBinaryExists) { - continue + if hostBinaryExists != "" { + binExists := false + bins := strings.Split(hostBinaryExists, ",") + for _, bin := range bins { + if fileutil.FileExists(bin) { + binExists = true + break + } + } + if !binExists { + continue + } } // Create proper description suffix @@ -284,7 +297,7 @@ func findDirectivesInScriptCommand(script string) map[string]string { if strings.HasPrefix(line, "## ") && strings.Contains(line, ":") { line = strings.Replace(line, "## ", "", 1) parts := strings.SplitN(line, ":", 2) - parts[1] = strings.Trim(parts[1], " ") + parts[1] = strings.Trim(parts[1], " \"'") directives[parts[0]] = parts[1] } } diff --git a/cmd/ddev/cmd/global_dotddev_assets/commands/host/heidisql b/cmd/ddev/cmd/global_dotddev_assets/commands/host/heidisql new file mode 100644 index 00000000000..93417488145 --- /dev/null +++ b/cmd/ddev/cmd/global_dotddev_assets/commands/host/heidisql @@ -0,0 +1,21 @@ +#!/bin/bash + +## #ddev-generated: If you want to edit and own this file, remove this line. +## Description: Run HeidiSQL against current db +## Usage: heidisql +## Example: "ddev heidisql" +## OSTypes: windows,wsl2 +## HostBinaryExists: "/mnt/c/Program Files/HeidiSQL/heidisql.exe,C:\Program Files\HeidiSQL\Heidisql.exe" + +arguments="--host=127.0.0.1 --port=${DDEV_HOST_DB_PORT} --user=root --password=root --description=${DDEV_SITENAME}" + +case $OSTYPE in + "win*"* | "msys"*) + '/c/Program Files/HeidiSQL/heidisql.exe' "$arguments" & + ;; + # linux-gnu in this case is only WSL2 as selected in OSTypes above + "linux-gnu") + # HeidiSQL is Microsoft only, but we want to start it from WSL2 + "/mnt/c/Program Files/HeidiSQL/heidisql.exe" "$arguments" & + ;; +esac diff --git a/cmd/ddev/cmd/packrd/packed-packr.go b/cmd/ddev/cmd/packrd/packed-packr.go index 60268ae27df..de35eaee8f7 100644 --- a/cmd/ddev/cmd/packrd/packed-packr.go +++ b/cmd/ddev/cmd/packrd/packed-packr.go @@ -45,6 +45,7 @@ var _ = func() error { "ced3c3f299b9250b01349709a89f2f3c": "1f8b08000000000000ff74cd3d8e83301086e1dea798c5db023dc56a8be408a910858d27c692b1cd8cc90fcae123a70952946aa4771ee9933fad76a1d58a2721a404690c5e6a8b01496534251d90477229bb183aa035c07ce7c59b754ee0025c51c31843562e20157e6265b1dba1feec95e5017a459687428e3735278f1d54656d478dae20d2478e7942faf2331a1e603797e0cfe88617dfd8ad12e20dea9562cc50a7d7f9fd17cf000000ffffd1f447b9f3000000", "d258b86cf4fdf7b0788e80173cf0b142": "1f8b08000000000000ff4ccf416e84300c85e17d4e6169d6907daf312708f19bc612d8c836747afb0a2a55ddffb6bef760c6397d42e12dc1e5d95df60c12a51c12c4e2e869fe4d5fb2aeb480f0463f124ca2210cca01e2a574d36ca2f0b994274023738f8f5aafffb3a3710eb0f598c52ab446b665453d021e15ef8472ed47a46d53b76d6bca511fd053dc7483e6743697eb24a6dded1406d3cb9c1aad1249f6a27f31fdc594a325f5a697fc885b7d8be377e75c7e020000ffffa4cb883301010000", "da6744b6a5a4428804fd54ed4a9d2bfa": "1f8b08000000000000ff8cca31aec2301045d1deab788a6b6707bff87ba04783fdc0232676e43111ec1e898a92eeeaea44c45278a41b1b874c961071ead8e44eccaa8eab1a2179ea41bcfa03591aa8b3728488bce3225ecf622a4e5ff9946d3762fdbe21a20f5843f25f74f804ccfe167324abff4b78070000ffff7a2f0a46a6000000", + "e0a7c313cc6cfebdd1c68244f696aea1": "1f8b08000000000000ff9492df6bdb3e14c5dffd579caf5cbe65258edbbc0c5cf2b02e1e29b44b56671b834250ac1b47604b99ae1c276cfddf87f2abec61b0bdd9ba1f9d7baece8dff4b17daa40bc9ab288a63c44ad126a9c890939e5486fb2576b645278d87b720a53da451b09d815f69c652d7d483a3c66ee870526b43fd2036222e9d5e7b6d4d86a7d6604c5ae9e2d3036425b5618fb2758e8c875a04fe33cb8a32ac02c5dfeb70946f65b3ae298308c6ce25116a9362b65b1367e8b451b6e35ec7f52014c696fd9d36d2edf2ad66cf1944da189f96e9d4d9cac9061f744d9c9eeca427d93e6da9f73e7bfe0d7b3e61878f2326a248baaa6dc8781e8a245959f6c39bc1dbfe75ffba7f8324595be787173f46a3fccb7c3c2966f3d1dd7c3a799abd20495a263774d6fac049e6ce3a75fa57af8f76ba5edccff28fef1ef3171145a564c2c5a4987d9be6d0260244a7cd95b8c24f8886772caede440070f977e35e425c9c0711f87f7ff7f63602e21064bb4d2ad3421fc3de77d70c6bea1dbe160f034806534da52715a86326900bbba160eeac210eb6e2d725d08c475d3acb76e9f78a3d2c5a8f8ecedbc65e3a0fedb174b6d9f7db6bfc439ae20fe311cb32fa150000ffffb92696dafd020000", "e0cd29906a22fdca23ce152b565b2412": "1f8b08000000000000ff8ccc3d4e2c311004e0dca728e9052f5a7306124e408e7aec02b7f0748fdccd2c7b7bb401120101e9573fff7ae77979a37149b297279d0ca8a1de8387e13ba5774d750b5c754e6c44f343d9a1968e1cc4951b9a5b8a1ad7ffc07d85ae8b2d7ddd6a298f067eca7e4c6293182f32558251bf5103c7f2533b3b06172b9e1dbbbc133934f0aa9390967a1237ff40130335075729edf8fdb2fed4e20bd37089bf74bf020000ffff76526b0213010000", "e28fdb901662d2de6aeffe41ce3c4ebd": "1f8b08000000000000ff74cd3d8e83301086e1dea798c5db023dc56a8be408a910858d27c692b1cd8cc90fcae123a70952946aa4771ee9933fad76a1d58a2721a404690c5e6a8b01496534251d90477229bb183aa035c07ce7c59b754ee0025c51c31843562e20157e6265b1dba1feec95e5017a459687428e3735278f1d54656d478dae20d2478e7942faf2331a1e603797e0cfe88617dfd8ad12e20dea9562cc50a7d7f9fd17cf000000ffffd1f447b9f3000000", "e885dda881636c9b933481140910b89c": "1f8b08000000000000ff548d3d0ec2300c46f79cc23473d4bd33488c08a907701b27b5489dc889a0c747415d58dff7f3ec655c58c605eb668cb560bda7b78b24a4d8c87774a5ba2a97c659267852cae861cd123842c80a12590e40f150b6e242d981a5b227f8d0d27b0d5948fbd15c31d2044ab5a136f71b767e3b702f892618bafc3f1f8c79714a9812b8fbfc386da7c97c030000ffff80a84502be000000", @@ -86,6 +87,7 @@ var _ = func() error { b.SetResolver("commands/db/README.txt", packr.Pointer{ForwardBox: gk, ForwardPath: "d258b86cf4fdf7b0788e80173cf0b142"}) b.SetResolver("commands/db/mysqldump.example", packr.Pointer{ForwardBox: gk, ForwardPath: "e28fdb901662d2de6aeffe41ce3c4ebd"}) b.SetResolver("commands/host/README.txt", packr.Pointer{ForwardBox: gk, ForwardPath: "0fc82d64f8cf13ea52a9080a2fc16752"}) + b.SetResolver("commands/host/heidisql", packr.Pointer{ForwardBox: gk, ForwardPath: "e0a7c313cc6cfebdd1c68244f696aea1"}) b.SetResolver("commands/host/phpstorm.example", packr.Pointer{ForwardBox: gk, ForwardPath: "ef4b402bf593682c6c4a55ffbce4978a"}) b.SetResolver("commands/host/sequelace", packr.Pointer{ForwardBox: gk, ForwardPath: "70e36634c16a7624fd589b024278291e"}) b.SetResolver("commands/host/sequelpro", packr.Pointer{ForwardBox: gk, ForwardPath: "ab8086424c88aa7dc60967d4c9b99439"}) diff --git a/docs/users/cli-usage.md b/docs/users/cli-usage.md index c81c24cecf0..bddfb110393 100644 --- a/docs/users/cli-usage.md +++ b/docs/users/cli-usage.md @@ -11,7 +11,8 @@ Each of these commands has full help. For example, `ddev start -h` or `ddev help * `ddev describe` or `ddev describe ` gives you full details about the project, what ports it uses, how to access them, etc. * `ddev list` shows running projects * `ddev mysql` gives direct access to the mysql client -* `ddev sequelpro` or `ddev sequelace` (macOS only, if installed) give access to the Sequel Pro or Sequel Ace database browser GUIs (if installed) +* `ddev sequelpro`, `ddev sequelace`, and `ddev tableplus` (macOS only, if the app is installed) give access to the Sequel Pro, Sequel Ace, or TablePlus database browser GUIs. +* `ddev heidisql` (Windows/WSL2 only, if installed) gives access to the HeidiSQL database browser GUI. * `ddev import-db` and `ddev export-db` let you import or export a sql or compressed sql file. * `ddev composer` lets you run composer (inside the container), for example `ddev composer install` will do a full composer install for you without even needing composer on your computer. See [developer tools](developer-tools.md#ddev-and-composer). * `ddev snapshot` makes a very fast snapshot of your database that can be easily and quickly restored with `ddev restore-snapshot`. diff --git a/pkg/ddevapp/instrumentation.go b/pkg/ddevapp/instrumentation.go index 4548091bbe2..3cd8d4c6ff8 100644 --- a/pkg/ddevapp/instrumentation.go +++ b/pkg/ddevapp/instrumentation.go @@ -29,7 +29,7 @@ func (n *SegmentNoopLogger) Errorf(format string, args ...interface{}) {} // ReportableEvents is the list of events that we choose to report specifically. // Excludes non-ddev custom commands. -var ReportableEvents = map[string]bool{"auth": true, "composer": true, "config": true, "debug": true, "delete": true, "describe": true, "exec": true, "export-db": true, "import-db": true, "import-files": true, "launch": true, "list": true, "logs": true, "mysql": true, "pause": true, "poweroff": true, "pull": true, "restart": true, "restore-snapshot": true, "sequelace": true, "sequelpro": true, "share": true, "snapshot": true, "ssh": true, "start": true, "stop": true, "tableplus": true, "xdebug": true} +var ReportableEvents = map[string]bool{"auth": true, "composer": true, "config": true, "debug": true, "delete": true, "describe": true, "exec": true, "export-db": true, "heidisql": true, "import-db": true, "import-files": true, "launch": true, "list": true, "logs": true, "mysql": true, "pause": true, "poweroff": true, "pull": true, "restart": true, "restore-snapshot": true, "sequelace": true, "sequelpro": true, "share": true, "snapshot": true, "ssh": true, "start": true, "stop": true, "tableplus": true, "xdebug": true} // GetInstrumentationUser normally gets just the hashed hostID but if // an explicit user is provided in global_config.yaml that will be prepended. diff --git a/pkg/globalconfig/global_config.go b/pkg/globalconfig/global_config.go index d92e9353807..104902404cd 100644 --- a/pkg/globalconfig/global_config.go +++ b/pkg/globalconfig/global_config.go @@ -12,7 +12,6 @@ import ( "net" "os" "os/exec" - "path" "path/filepath" "strconv" "strings" @@ -218,7 +217,7 @@ func GetGlobalDdevDir() string { if err != nil { logrus.Fatal("could not get home directory for current user. is it set?") } - ddevDir := path.Join(userHome, ".ddev") + ddevDir := filepath.Join(userHome, ".ddev") // Create the directory if it is not already present. if _, err := os.Stat(ddevDir); os.IsNotExist(err) { diff --git a/pkg/nodeps/utils.go b/pkg/nodeps/utils.go index df02539a17a..d66de966d10 100644 --- a/pkg/nodeps/utils.go +++ b/pkg/nodeps/utils.go @@ -53,6 +53,11 @@ func RandomString(length int) string { return string(b) } +// IsWSL2() returns true if running WSL2 +func IsWSL2() bool { + return GetWSLDistro() != "" +} + // GetWSLDistro returns the WSL2 distro name if on Linux func GetWSLDistro() string { wslDistro := ""