diff --git a/NOTICE.txt b/NOTICE.txt index a86c2b0b491..62ccee28057 100755 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -28607,7 +28607,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --------------------------------------------------------- -github.com%2Fburntsushi/toml v0.3.1 - MIT +github.com%2FBurntsushi/toml v1.4.0 - MIT Copyright 2010 The Go Authors @@ -28615,14 +28615,13 @@ Copyright (c) 2013 TOML authors MIT License -Copyright (c) +Copyright (c) 2013 TOML authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - --------------------------------------------------------- --------------------------------------------------------- diff --git a/cli/azd/.vscode/cspell-azd-dictionary.txt b/cli/azd/.vscode/cspell-azd-dictionary.txt index 54c8e9fe0f9..86a2a9f1d0a 100644 --- a/cli/azd/.vscode/cspell-azd-dictionary.txt +++ b/cli/azd/.vscode/cspell-azd-dictionary.txt @@ -1,6 +1,7 @@ AADSTS ABRT ACCESSTOKEN +actix aiomysql aiopg alphafeatures @@ -30,6 +31,7 @@ aspnet aspnetcore asyncmy asyncpg +axum azapi azblob AZCLI @@ -234,5 +236,6 @@ westus2 wireinject yacspin yamlnode +yew ymlt zerr diff --git a/cli/azd/internal/appdetect/appdetect.go b/cli/azd/internal/appdetect/appdetect.go index 90cdf3297c4..0526f43e33c 100644 --- a/cli/azd/internal/appdetect/appdetect.go +++ b/cli/azd/internal/appdetect/appdetect.go @@ -26,6 +26,7 @@ const ( JavaScript Language = "js" TypeScript Language = "ts" Python Language = "python" + Rust Language = "rust" ) func (pt Language) Display() string { @@ -42,6 +43,8 @@ func (pt Language) Display() string { return "TypeScript" case Python: return "Python" + case Rust: + return "Rust" } return "" @@ -59,6 +62,10 @@ const ( PyFlask Dependency = "flask" PyDjango Dependency = "django" PyFastApi Dependency = "fastapi" + + RsYew Dependency = "yew" + RsActix Dependency = "actix" + RsAxum Dependency = "axum" ) var WebUIFrameworks = map[Dependency]struct{}{ @@ -66,6 +73,8 @@ var WebUIFrameworks = map[Dependency]struct{}{ JsAngular: {}, JsJQuery: {}, JsVite: {}, + + RsYew: {}, } func (f Dependency) Language() Language { @@ -89,6 +98,13 @@ func (f Dependency) Display() string { return "Vite" case JsNext: return "Next.js" + + case RsActix: + return "Actix" + case RsAxum: + return "Axum" + case RsYew: + return "Yew" } return "" @@ -189,6 +205,7 @@ var allDetectors = []projectDetector{ }, &pythonDetector{}, &javaScriptDetector{}, + &rustDetector{}, } // Detect detects projects located under a directory. diff --git a/cli/azd/internal/appdetect/appdetect_test.go b/cli/azd/internal/appdetect/appdetect_test.go index b356a151ace..7f2974a5392 100644 --- a/cli/azd/internal/appdetect/appdetect_test.go +++ b/cli/azd/internal/appdetect/appdetect_test.go @@ -99,6 +99,15 @@ func TestDetect(t *testing.T) { DbRedis, }, }, + { + Language: Rust, + Path: "rust", + DetectionRule: "Inferred by presence of: Cargo.toml", + Dependencies: []Dependency{ + RsActix, + RsYew, + }, + }, { Language: TypeScript, Path: "typescript", @@ -146,6 +155,7 @@ func TestDetect(t *testing.T) { []DetectOption{ WithoutJavaScript(), WithoutPython(), + WithoutRust(), }, []Project{ { @@ -213,6 +223,15 @@ func TestDetect(t *testing.T) { Path: "python", DetectionRule: "Inferred by presence of: requirements.txt", }, + { + Language: Rust, + Path: "rust", + DetectionRule: "Inferred by presence of: Cargo.toml", + Dependencies: []Dependency{ + RsActix, + RsYew, + }, + }, }, }, } diff --git a/cli/azd/internal/appdetect/config.go b/cli/azd/internal/appdetect/config.go index f0b7bcfa37b..2c78c83572d 100644 --- a/cli/azd/internal/appdetect/config.go +++ b/cli/azd/internal/appdetect/config.go @@ -252,3 +252,37 @@ func (o *excludeJavaScript) applyLang(c languageConfig) languageConfig { func WithoutJavaScript() LanguageOption { return &excludeJavaScript{} } + +type includeRust struct { +} + +func (o *includeRust) apply(c detectConfig) detectConfig { + c.IncludeLanguages = append(c.IncludeLanguages, Rust) + return c +} + +func (o *includeRust) applyLang(c languageConfig) languageConfig { + c.IncludeLanguages = append(c.IncludeLanguages, Rust) + return c +} + +func WithRust() LanguageOption { + return &includeRust{} +} + +type excludeRust struct { +} + +func (o *excludeRust) apply(c detectConfig) detectConfig { + c.ExcludeLanguages = append(c.ExcludeLanguages, Rust) + return c +} + +func (o *excludeRust) applyLang(c languageConfig) languageConfig { + c.ExcludeLanguages = append(c.ExcludeLanguages, Rust) + return c +} + +func WithoutRust() LanguageOption { + return &excludeRust{} +} diff --git a/cli/azd/internal/appdetect/rust.go b/cli/azd/internal/appdetect/rust.go new file mode 100644 index 00000000000..b13e167525a --- /dev/null +++ b/cli/azd/internal/appdetect/rust.go @@ -0,0 +1,57 @@ +package appdetect + +import ( + "context" + "io/fs" + "os" + "path/filepath" + "strings" + + "github.com/BurntSushi/toml" +) + +type rustDetector struct{} + +func (rd *rustDetector) Language() Language { + return Rust +} + +func (rd *rustDetector) DetectProject(ctx context.Context, path string, entries []fs.DirEntry) (*Project, error) { + for _, entry := range entries { + if strings.ToLower(entry.Name()) == "cargo.toml" { + project := &Project{ + Language: Rust, + Path: path, + DetectionRule: "Inferred by presence of: " + entry.Name(), + } + + contents, err := os.ReadFile(filepath.Join(path, entry.Name())) + if err != nil { + return nil, err + } + + var cargoToml struct { + Dependencies map[string]toml.Primitive `toml:"dependencies"` + } + err = toml.Unmarshal(contents, &cargoToml) + if err != nil { + return nil, err + } + + for k := range cargoToml.Dependencies { + switch k { + case string(RsActix): + project.Dependencies = append(project.Dependencies, RsActix) + case string(RsAxum): + project.Dependencies = append(project.Dependencies, RsAxum) + case string(RsYew): + project.Dependencies = append(project.Dependencies, RsYew) + } + } + + return project, nil + } + } + + return nil, nil +} diff --git a/cli/azd/internal/appdetect/testdata/rust/Cargo.toml b/cli/azd/internal/appdetect/testdata/rust/Cargo.toml new file mode 100644 index 00000000000..6d898cce011 --- /dev/null +++ b/cli/azd/internal/appdetect/testdata/rust/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "testdata" +version = "0.1.0" +publish = false + +[dependencies] +actix = "0.13.5" +yew = "0.21.0" diff --git a/go.mod b/go.mod index 48ecfb0398f..51d09a05955 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azfile v1.2.2 github.com/Azure/azure-storage-file-go v0.8.0 github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 + github.com/BurntSushi/toml v1.4.0 github.com/MakeNowJust/heredoc/v2 v2.0.1 github.com/adam-lavrik/go-imath v0.0.0-20210910152346-265a42a96f0b github.com/benbjohnson/clock v1.3.0 diff --git a/go.sum b/go.sum index 1fa3b2b49d0..52eb0b961c3 100644 --- a/go.sum +++ b/go.sum @@ -51,16 +51,10 @@ github.com/AlecAivazis/survey/v2 v2.3.2 h1:TqTB+aDDCLYhf9/bD2TwSO8u8jDSmMUd2SUVO github.com/AlecAivazis/survey/v2 v2.3.2/go.mod h1:TH2kPCDU3Kqq7pLbnCWwZXDBjnhZtmsCle5EiYDJ2fg= github.com/Azure/azure-pipeline-go v0.2.1 h1:OLBdZJ3yvOn2MezlWvbrBMTEUQC72zAftRZOMdj5HYo= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 h1:1nGuui+4POelzDwI7RG56yfQJHCnKvwfMoU7VsEp+Zg= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0/go.mod h1:99EvauvlcJ1U06amZiksfYz/3aFGyIhWGHVyiZXtBAI= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0 h1:U2rTu3Ef+7w9FHKIAXM6ZyqF3UOWJZ12zIm8zECAFfg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 h1:H+U3Gk9zY56G3u872L82bk4thcsy2Gghb9ExT4Zvm1o= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0/go.mod h1:mgrmMSgaLp9hmax62XQTd0N4aAqSE5E0DulSpVYK7vc= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement v1.0.0 h1:Ai3+BE11JvwQ2PxLGNKAfMNSceYXjeijReLJiCouO6o= @@ -120,6 +114,8 @@ github.com/Azure/azure-storage-file-go v0.8.0/go.mod h1:3w3mufGcMjcOJ3w+4Gs+5wsS github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/MakeNowJust/heredoc/v2 v2.0.1 h1:rlCHh70XXXv7toz95ajQWOWQnN4WNLt0TdpZYIR/J6A= @@ -572,8 +568,6 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -654,8 +648,6 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -759,14 +751,10 @@ golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= -golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -778,8 +766,6 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=