From 44d34512047bdd5a52a45642996c05dd3b46ab93 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Fri, 27 Sep 2024 21:20:19 -0700 Subject: [PATCH 01/23] refactor: drop Pro from Aspect CLI versioning by making Aspect CLI OSS the exception from Aspect CLI (standard) (#6930) Aspect CLI Pro is now just Aspect CLI and the open-source, open-core Aspect CLI is now Aspect CLI OSS. Also drop the ability to specify the version in `.aspect/cli/config.yaml` as this is not documented and not used anywhere currently. Aspect CLI versioning outside of `.bazeliskrc` needs more thought before we bring it back. --- - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: yes Drop "Pro" from Aspect CLI name. The open-source Aspect CLI OSS now has the specifier. - Covered by existing test cases - Manual testing; please provide instructions so we can reproduce: ``` $ bazel-bin/cli/core/cmd/aspect/aspect_/aspect version Aspect CLI OSS version: unknown [not built with --stamp] $ bazel-bin/cli/core/cmd/aspect/aspect_/aspect --version aspect oss unknown [not built with --stamp] $ ./bazel-bin/cli/pro/pro_/pro version Aspect CLI version: unknown [not built with --stamp] $ ./bazel-bin/cli/pro/pro_/pro --version aspect unknown [not built with --stamp] ``` GitOrigin-RevId: eec53a03fdaa90a8e7401510e50059904de2b349 --- bazel/BUILD.bazel | 19 +++ buildinfo/BUILD.bazel | 2 +- buildinfo/build_info.go | 36 ++--- buildinfo/build_info_test.go | 24 +-- buildinfo/stamp.go | 4 +- cmd/aspect/BUILD.bazel | 1 + cmd/aspect/root/root.go | 9 +- cmd/docgen/BUILD.bazel | 1 + go.mod | 2 +- integration_tests/aspect/BUILD.bazel | 1 + integration_tests/aspect/flags_test.bats | 14 -- integration_tests/aspect/version_test.bats | 6 +- pkg/aspect/init/init.go | 16 -- pkg/aspect/license/license.go | 16 +- pkg/aspect/outputs/hash_test.go | 2 +- pkg/aspect/pro/BUILD.bazel | 15 -- pkg/aspect/pro/pro.go | 145 ------------------ pkg/aspect/root/config/BUILD.bazel | 9 +- pkg/aspect/root/config/aspect_base_url.go | 25 +++ pkg/aspect/root/config/version_config.go | 141 ----------------- pkg/aspect/root/config/version_config_test.go | 43 ------ pkg/bazel/bazelisk.go | 18 +-- pkg/plugin/system/besproxy/bes_proxy.go | 2 +- 23 files changed, 102 insertions(+), 449 deletions(-) create mode 100644 bazel/BUILD.bazel delete mode 100644 pkg/aspect/pro/BUILD.bazel delete mode 100644 pkg/aspect/pro/pro.go create mode 100644 pkg/aspect/root/config/aspect_base_url.go delete mode 100644 pkg/aspect/root/config/version_config.go delete mode 100644 pkg/aspect/root/config/version_config_test.go diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel new file mode 100644 index 000000000..a591e15ce --- /dev/null +++ b/bazel/BUILD.bazel @@ -0,0 +1,19 @@ +load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") + +# gazelle:exclude **/*.d.ts + +write_source_files( + name = "write_pb_go", + additional_update_targets = [ + "//bazel/action_cache:write_pb_go", + "//bazel/analysis:write_pb_go", + "//bazel/buildeventstream:write_pb_go", + "//bazel/command_line:write_pb_go", + "//bazel/failure_details:write_pb_go", + "//bazel/flags:write_pb_go", + "//bazel/invocation_policy:write_pb_go", + "//bazel/options:write_pb_go", + "//bazel/packages_metrics:write_pb_go", + "//bazel/query:write_pb_go", + ], +) diff --git a/buildinfo/BUILD.bazel b/buildinfo/BUILD.bazel index 9a7dac3c3..9999dd372 100644 --- a/buildinfo/BUILD.bazel +++ b/buildinfo/BUILD.bazel @@ -7,7 +7,7 @@ _GO_STAMP_X_DEFS = { "GitCommit": "{STABLE_BUILD_SCM_SHA}", "GitStatus": "{STABLE_BUILD_SCM_LOCAL_CHANGES}", "HostName": "{BUILD_HOST}", - "Release": "{STABLE_ASPECT_CLI_VERSION}", + "Release": "{STABLE_BUILD_SCM_TAG}", } go_library( diff --git a/buildinfo/build_info.go b/buildinfo/build_info.go index 8544d2161..3372f6d3c 100644 --- a/buildinfo/build_info.go +++ b/buildinfo/build_info.go @@ -42,12 +42,12 @@ const ( ) type BuildInfo struct { - BuildTime string - HostName string - GitCommit string - GitStatus string - Release string - IsAspectPro bool + BuildTime string + HostName string + GitCommit string + GitStatus string + Release string + OpenSource bool } func New( @@ -56,15 +56,15 @@ func New( gitCommit string, gitStatus string, release string, - pro bool, + oss bool, ) *BuildInfo { return &BuildInfo{ - BuildTime: buildTime, - HostName: hostName, - GitCommit: gitCommit, - GitStatus: gitStatus, - Release: release, - IsAspectPro: pro, + BuildTime: buildTime, + HostName: hostName, + GitCommit: gitCommit, + GitStatus: gitStatus, + Release: release, + OpenSource: oss, } } @@ -75,7 +75,7 @@ func Current() *BuildInfo { GitCommit, GitStatus, Release, - IsAspectPro != "", + OpenSource != "", ) } @@ -101,16 +101,16 @@ func (bi BuildInfo) Version() string { } func (bi BuildInfo) Name() string { - if bi.IsAspectPro { - return "Aspect CLI Pro" + if bi.OpenSource { + return "Aspect CLI OSS" } else { return "Aspect CLI" } } func (bi BuildInfo) GnuName() string { - if bi.IsAspectPro { - return "aspect pro" + if bi.OpenSource { + return "aspect oss" } else { return "aspect" } diff --git a/buildinfo/build_info_test.go b/buildinfo/build_info_test.go index 8aba64248..93e0d98c0 100644 --- a/buildinfo/build_info_test.go +++ b/buildinfo/build_info_test.go @@ -37,12 +37,12 @@ func TestNew(t *testing.T) { g := NewGomegaWithT(t) actual := buildinfo.New(buildTime, hostName, gitCommit, gitStatus, release, false) expected := &buildinfo.BuildInfo{ - BuildTime: buildTime, - HostName: hostName, - GitCommit: gitCommit, - GitStatus: gitStatus, - Release: release, - IsAspectPro: false, + BuildTime: buildTime, + HostName: hostName, + GitCommit: gitCommit, + GitStatus: gitStatus, + Release: release, + OpenSource: false, } g.Expect(actual).To(Equal(expected)) } @@ -51,12 +51,12 @@ func TestCurrent(t *testing.T) { g := NewGomegaWithT(t) actual := buildinfo.Current() expected := &buildinfo.BuildInfo{ - BuildTime: buildinfo.BuildTime, - HostName: buildinfo.HostName, - GitCommit: buildinfo.GitCommit, - GitStatus: buildinfo.GitStatus, - Release: buildinfo.Release, - IsAspectPro: buildinfo.IsAspectPro != "", + BuildTime: buildinfo.BuildTime, + HostName: buildinfo.HostName, + GitCommit: buildinfo.GitCommit, + GitStatus: buildinfo.GitStatus, + Release: buildinfo.Release, + OpenSource: buildinfo.OpenSource != "", } g.Expect(actual).To(Equal(expected)) } diff --git a/buildinfo/stamp.go b/buildinfo/stamp.go index 706a6cc3c..033660d7f 100644 --- a/buildinfo/stamp.go +++ b/buildinfo/stamp.go @@ -35,8 +35,8 @@ var GitStatus = "unknown" // Release is the revision number, if any. var Release = "no release" -// IsAspectPro indicates if this is an Aspect CLI Pro build -var IsAspectPro = "" +// OpenSource indicates if this is an Aspect CLI OSS build +var OpenSource = "" func IsStamped() bool { return BuildTime != "{BUILD_TIMESTAMP}" diff --git a/cmd/aspect/BUILD.bazel b/cmd/aspect/BUILD.bazel index ace1d326f..ecd07a2c7 100644 --- a/cmd/aspect/BUILD.bazel +++ b/cmd/aspect/BUILD.bazel @@ -9,6 +9,7 @@ go_library( "//cmd:__subpackages__", "//release:__pkg__", # For https://github.com/aspect-build/aspect-cli release ], + x_defs = {"aspect.build/cli/buildinfo.OpenSource": "true"}, deps = [ "//cmd/aspect/root", "//pkg/aspect/root/config", diff --git a/cmd/aspect/root/root.go b/cmd/aspect/root/root.go index c1f913cf6..2fb40be6d 100644 --- a/cmd/aspect/root/root.go +++ b/cmd/aspect/root/root.go @@ -114,10 +114,10 @@ func NewCmd( ) *cobra.Command { cmd := &cobra.Command{ Use: "aspect", - Short: buildinfo.Current().Name(), + Short: "Aspect CLI", SilenceUsage: true, SilenceErrors: true, - Long: boldCyan.Sprintf(buildinfo.Current().Name()) + ` is a better frontend for running bazel`, + Long: boldCyan.Sprintf("Aspect CLI is a better frontend for running bazel"), // Suppress timestamps in generated Markdown, for determinism DisableAutoGenTag: true, Version: buildinfo.Current().Version(), @@ -129,7 +129,6 @@ func NewCmd( flags.AddGlobalFlags(cmd, defaultInteractive) cmd.AddGroup(&cobra.Group{ID: "common", Title: "Common Bazel Commands:"}) cmd.AddGroup(&cobra.Group{ID: "aspect", Title: "Commands only in Aspect CLI:"}) - cmd.AddGroup(&cobra.Group{ID: "aspect-pro", Title: "Commands only in Aspect CLI Pro:"}) cmd.AddGroup(&cobra.Group{ID: "plugin", Title: "Custom Commands from Plugins:"}) cmd.AddGroup(&cobra.Group{ID: "built-in", Title: "Other Bazel Built-in Commands:"}) @@ -161,8 +160,8 @@ func NewCmd( cmd.AddCommand(outputs.NewDefaultCmd()) cmd.SetHelpCommand(help.NewCmd()) - if !buildinfo.Current().IsAspectPro { - // Aspect CLI only commands + if buildinfo.Current().OpenSource { + // Aspect CLI OSS command configurations cmd.AddCommand(lint.NewDefaultCmd(pluginSystem)) cmd.AddCommand(license.NewDefaultCmd()) cmd.AddCommand(configure.NewDefaultCmd()) diff --git a/cmd/docgen/BUILD.bazel b/cmd/docgen/BUILD.bazel index c26338cb9..2f01f01f0 100644 --- a/cmd/docgen/BUILD.bazel +++ b/cmd/docgen/BUILD.bazel @@ -5,6 +5,7 @@ go_library( srcs = ["main.go"], importpath = "aspect.build/cli/cmd/docgen", visibility = ["//visibility:private"], + x_defs = {"aspect.build/cli/buildinfo.OpenSource": "true"}, deps = [ "//cmd/aspect/root", "//pkg/bazel", diff --git a/go.mod b/go.mod index 53eda8df7..1fdc907ff 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/twmb/murmur3 v1.1.8 github.com/yargevad/filepathx v1.0.0 go.starlark.net v0.0.0-20240725214946-42030a7cedce - golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7 + golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7 // indirect golang.org/x/sync v0.8.0 google.golang.org/genproto v0.0.0-20240528184218-531527333157 google.golang.org/grpc v1.64.1 diff --git a/integration_tests/aspect/BUILD.bazel b/integration_tests/aspect/BUILD.bazel index cf17a892e..9979c2f3b 100644 --- a/integration_tests/aspect/BUILD.bazel +++ b/integration_tests/aspect/BUILD.bazel @@ -41,6 +41,7 @@ data = [ ) for test in [ "configure", + "help", "info", "version", ] diff --git a/integration_tests/aspect/flags_test.bats b/integration_tests/aspect/flags_test.bats index 56051fcb2..fc8b6d9e2 100644 --- a/integration_tests/aspect/flags_test.bats +++ b/integration_tests/aspect/flags_test.bats @@ -55,20 +55,6 @@ EOF assert_output --partial "Aspect CLI is a better frontend for running bazel" } -@test 'lock_version flag should prevent downloading and running config version' { - cat >version-config.yaml <<'EOF' -version: 1.2.3 -EOF - - run aspect --aspect:config="version-config.yaml" --aspect:lock_version=false - assert_failure - assert_output --partial "could not download Bazel" - - run aspect --aspect:config="version-config.yaml" --aspect:lock_version - assert_success - assert_output --partial "Aspect CLI is a better frontend for running bazel" -} - @test '--[no]able flags should work' { cat >BUILD.bazel <<'EOF' genrule( diff --git a/integration_tests/aspect/version_test.bats b/integration_tests/aspect/version_test.bats index 29ddd7391..a1367ab8f 100644 --- a/integration_tests/aspect/version_test.bats +++ b/integration_tests/aspect/version_test.bats @@ -7,19 +7,19 @@ setup() { @test 'aspect version' { run aspect version # Should print our own version - assert_output --partial "Aspect CLI version: unknown [not built with --stamp]" + assert_output --partial "Aspect CLI OSS version: unknown [not built with --stamp]" # Should also call through to `bazel version` assert_output --partial "Build label: 6.4.0" } @test '--version flag should work' { run aspect_vanilla --version - assert_output --partial "aspect unknown [not built with --stamp]" + assert_output --partial "aspect oss unknown [not built with --stamp]" } @test '-v flag should work' { run aspect_vanilla -v - assert_output --partial "aspect unknown [not built with --stamp]" + assert_output --partial "aspect oss unknown [not built with --stamp]" } @test '--bazel-version flag should work' { diff --git a/pkg/aspect/init/init.go b/pkg/aspect/init/init.go index ec11adaa7..4dff8935c 100644 --- a/pkg/aspect/init/init.go +++ b/pkg/aspect/init/init.go @@ -1,19 +1,3 @@ -/* - * Copyright 2023 Aspect Build Systems, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - /* * Copyright 2022 Aspect Build Systems, Inc. * diff --git a/pkg/aspect/license/license.go b/pkg/aspect/license/license.go index 38015879b..3187f4f90 100644 --- a/pkg/aspect/license/license.go +++ b/pkg/aspect/license/license.go @@ -50,17 +50,17 @@ func New(streams ioutils.Streams, bzl bazel.Bazel, licenseText string) *License func (runner *License) Run(ctx context.Context, _ *cobra.Command, args []string) error { // ASCII art generated with https://patorjk.com/software/taag/ "ANSI Shadow" font - if buildinfo.Current().IsAspectPro { + if buildinfo.Current().OpenSource { fmt.Printf(` ===================================================================================================== - █████╗ ███████╗██████╗ ███████╗ ██████╗████████╗ ██████╗██╗ ██╗ ██████╗ ██████╗ ██████╗ -██╔══██╗██╔════╝██╔══██╗██╔════╝██╔════╝╚══██╔══╝ ██╔════╝██║ ██║ ██╔══██╗██╔══██╗██╔═══██╗ -███████║███████╗██████╔╝█████╗ ██║ ██║ ██║ ██║ ██║ ██████╔╝██████╔╝██║ ██║ -██╔══██║╚════██║██╔═══╝ ██╔══╝ ██║ ██║ ██║ ██║ ██║ ██╔═══╝ ██╔══██╗██║ ██║ -██║ ██║███████║██║ ███████╗╚██████╗ ██║ ╚██████╗███████╗██║ ██║ ██║ ██║╚██████╔╝ -╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ - + █████╗ ███████╗██████╗ ███████╗ ██████╗████████╗ ██████╗██╗ ██╗ ██████╗ ███████╗███████╗ +██╔══██╗██╔════╝██╔══██╗██╔════╝██╔════╝╚══██╔══╝ ██╔════╝██║ ██║ ██╔═══██╗██╔════╝██╔════╝ +███████║███████╗██████╔╝█████╗ ██║ ██║ ██║ ██║ ██║ ██║ ██║███████╗███████╗ +██╔══██║╚════██║██╔═══╝ ██╔══╝ ██║ ██║ ██║ ██║ ██║ ██║ ██║╚════██║╚════██║ +██║ ██║███████║██║ ███████╗╚██████╗ ██║ ╚██████╗███████╗██║ ╚██████╔╝███████║███████║ +╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═════╝ ╚══════╝╚══════╝ + ===================================================================================================== `) diff --git a/pkg/aspect/outputs/hash_test.go b/pkg/aspect/outputs/hash_test.go index b831dd0b3..467564b1b 100644 --- a/pkg/aspect/outputs/hash_test.go +++ b/pkg/aspect/outputs/hash_test.go @@ -1,5 +1,5 @@ /* - * Copyright 2022 Aspect Build Systems, Inc. + * Copyright 2023 Aspect Build Systems, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/aspect/pro/BUILD.bazel b/pkg/aspect/pro/BUILD.bazel deleted file mode 100644 index 293b6f120..000000000 --- a/pkg/aspect/pro/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "pro", - srcs = ["pro.go"], - importpath = "aspect.build/cli/pkg/aspect/pro", - visibility = ["//visibility:public"], - deps = [ - "//pkg/aspect/root/config", - "//pkg/bazel/workspace", - "//pkg/ioutils", - "@com_github_manifoldco_promptui//:promptui", - "@com_github_spf13_cobra//:cobra", - ], -) diff --git a/pkg/aspect/pro/pro.go b/pkg/aspect/pro/pro.go deleted file mode 100644 index b17fd4297..000000000 --- a/pkg/aspect/pro/pro.go +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2022 Aspect Build Systems, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pro - -import ( - "context" - "fmt" - - "aspect.build/cli/pkg/aspect/root/config" - "aspect.build/cli/pkg/bazel/workspace" - "aspect.build/cli/pkg/ioutils" - "github.com/manifoldco/promptui" - "github.com/spf13/cobra" -) - -type Pro struct { - ioutils.Streams -} - -func New(streams ioutils.Streams) *Pro { - return &Pro{ - Streams: streams, - } -} - -func (runner *Pro) Run(ctx context.Context, _ *cobra.Command, args []string) error { - if err := enableProForUser(); err != nil { - return err - } - if err := enableProForWorkspace(); err != nil { - return err - } - return nil -} - -// TODO: move promptui helpers to shared library -type ConfirmationRunner interface { - Run() (string, error) -} - -func Confirmation(question string) ConfirmationRunner { - return &promptui.Prompt{ - Label: question, - IsConfirm: true, - } -} - -func enableProForUser() error { - homeConfig, err := config.LoadHomeConfig() - if err != nil { - return err - } - - version, err := config.ParseConfigVersion(homeConfig.GetString("version")) - proTier := config.IsProTier(version.Tier) - if !proTier { - _, err = Confirmation("Enable Aspect CLI Pro features for user").Run() - if err == nil { - // TODO: show Aspect commercial license when it is finalized and/or send user to a "Sign up for free trial period" page - configFile, created, err := config.SetInHomeConfig("version", toProVersion(version.Version)) - if err != nil { - return err - } - if created { - fmt.Printf("Created %s\n", configFile) - } else { - fmt.Printf("Updated %s\n", configFile) - } - } - } else { - configFile, _ := config.HomeConfigFile() - if configFile == "" { - fmt.Println("Aspect CLI Pro features already enabled for user") - } else { - fmt.Printf("Aspect CLI Pro features already enabled for user in %s\n", configFile) - } - } - - return nil -} - -func enableProForWorkspace() error { - workspaceConfig, err := config.LoadWorkspaceConfig() - if err != nil { - // Ignore err if it is a workspace.NotFoundError - if _, ok := err.(*workspace.NotFoundError); !ok { - return err - } - } - - if workspaceConfig == nil { - // We're are not currently in a Bazel workspace - fmt.Println("Run 'aspect pro' in a Bazel workspace to enable Aspect CLI Pro features for that workspace") - return nil - } - - version, err := config.ParseConfigVersion(workspaceConfig.GetString("version")) - proTier := config.IsProTier(version.Tier) - if !proTier { - _, err = Confirmation("Enable Aspect CLI Pro features for workspace").Run() - if err == nil { - // TODO: show Aspect commercial license when it is finalized and/or send user to a "Sign up for free trial period" page - configFile, created, err := config.SetInWorkspaceConfig("version", toProVersion(version.Version)) - if err != nil { - return err - } - if created { - fmt.Printf("Created %s\n", configFile) - } else { - fmt.Printf("Updated %s\n", configFile) - } - } - } else { - configFile, _ := config.WorkspaceConfigFile() - if configFile == "" { - fmt.Println("Aspect CLI Pro features already enabled for workspace") - } else { - fmt.Printf("Aspect CLI Pro features already enabled for workspace in %s\n", configFile) - } - } - - return nil -} - -func toProVersion(version string) string { - if len(version) == 0 { - return "pro" - } else { - return fmt.Sprintf("pro/%s", version) - } -} diff --git a/pkg/aspect/root/config/BUILD.bazel b/pkg/aspect/root/config/BUILD.bazel index ecd0d85ec..08da2db02 100644 --- a/pkg/aspect/root/config/BUILD.bazel +++ b/pkg/aspect/root/config/BUILD.bazel @@ -3,31 +3,26 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "config", srcs = [ + "aspect_base_url.go", "config.go", "root.go", - "version_config.go", "write.go", ], importpath = "aspect.build/cli/pkg/aspect/root/config", visibility = ["//visibility:public"], deps = [ - "//buildinfo", "//pkg/aspect/root/flags", "//pkg/bazel/workspace", "//pkg/plugin/types", "@com_github_mitchellh_go_homedir//:go-homedir", "@com_github_spf13_pflag//:pflag", "@com_github_spf13_viper//:viper", - "@org_golang_x_exp//maps", ], ) go_test( name = "config_test", - srcs = [ - "config_test.go", - "version_config_test.go", - ], + srcs = ["config_test.go"], deps = [ ":config", "@com_github_onsi_gomega//:gomega", diff --git a/pkg/aspect/root/config/aspect_base_url.go b/pkg/aspect/root/config/aspect_base_url.go new file mode 100644 index 000000000..daf0e9f5b --- /dev/null +++ b/pkg/aspect/root/config/aspect_base_url.go @@ -0,0 +1,25 @@ +/* + * Copyright 2022 Aspect Build Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package config + +func AspectBaseUrl(isOss bool) string { + if isOss { + return "https://github.com/aspect-build/aspect-cli/releases/download" + } else { + return "https://static.aspect.build/aspect" + } +} diff --git a/pkg/aspect/root/config/version_config.go b/pkg/aspect/root/config/version_config.go deleted file mode 100644 index 5a1f4f5c2..000000000 --- a/pkg/aspect/root/config/version_config.go +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2022 Aspect Build Systems, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "fmt" - "os" - "strings" - - "aspect.build/cli/buildinfo" - "github.com/spf13/viper" - "golang.org/x/exp/maps" -) - -var aspectProTiers = map[string]struct{}{ - "community": {}, - "pro": {}, -} - -var validTiersCommaList = strings.Join(maps.Keys(aspectProTiers), ", ") - -func IsValidTier(tier string) bool { - if len(tier) == 0 { - return true - } - _, ok := aspectProTiers[tier] - return ok -} - -func IsProTier(tier string) bool { - if len(tier) == 0 { - return false - } - _, ok := aspectProTiers[tier] - return ok -} - -func AspectBaseUrl(isProTier bool) string { - if isProTier { - return "https://static.aspect.build/aspect" - } else { - return "https://github.com/aspect-build/aspect-cli/releases/download" - } -} - -type VersionTuple struct { - Tier string - Version string -} - -type VersionConfig struct { - VersionTuple - Configured bool - AutoTier bool - BaseUrl string - IsProTier bool -} - -func GetVersionConfig() (*VersionConfig, error) { - versionString := viper.GetString("version") - - // If USE_ASPECT_VERSION is set on the environment then that takes precedence - useAspectVersion := os.Getenv("USE_ASPECT_VERSION") - if len(useAspectVersion) != 0 { - versionString = useAspectVersion - } - - versionTuple, err := ParseConfigVersion(versionString) - if err != nil { - return nil, fmt.Errorf("Unrecognized Aspect CLI tier in version in configuration: '%s'. Version should be [/] with an optional tier set to one of: %s. Please fix your Aspect CLI configuration and try again.", versionString, validTiersCommaList) - } - - result := VersionConfig{ - VersionTuple: versionTuple, - Configured: versionTuple.Version != "" || versionTuple.Tier != "", - } - - if versionTuple.Tier == "" { - if buildinfo.Current().IsAspectPro { - result.Tier = "pro" - result.IsProTier = true - } - } else { - if !IsValidTier(versionTuple.Tier) { - return nil, fmt.Errorf("Unrecognized Aspect CLI tier in version in configuration: '%s'. Version should be [/] with an optional tier set to one of: %s. Please fix your Aspect CLI configuration and try again.", versionTuple.Tier, validTiersCommaList) - } - result.IsProTier = IsProTier(versionTuple.Tier) - } - - if result.Version == "" { - result.Version = buildinfo.Current().Version() - } - - result.BaseUrl = viper.GetString("base_url") - if len(result.BaseUrl) == 0 { - result.BaseUrl = AspectBaseUrl(result.IsProTier) - } - - return &result, nil -} - -func ParseConfigVersion(version string) (VersionTuple, error) { - result := VersionTuple{"", ""} - if len(version) == 0 { - return result, nil - } - - if version[0] >= '0' && version[0] <= '9' { - // Version is numeric with no tier component - result.Version = version - } else { - // There is a tier component to the version: or /1.2.3 - splits := strings.Split(version, "/") - if len(splits) == 1 { - result.Tier = splits[0] - // Only tier is specified; version is derived above from running version - } else if len(splits) == 2 { - // Both tier and version are specified in the Aspect CLI config - result.Tier = splits[0] - result.Version = splits[1] - } else { - return result, fmt.Errorf("Invalid Aspect CLI version: '%s'. Version should be [/].", version) - } - } - - return result, nil -} diff --git a/pkg/aspect/root/config/version_config_test.go b/pkg/aspect/root/config/version_config_test.go deleted file mode 100644 index 7e8321032..000000000 --- a/pkg/aspect/root/config/version_config_test.go +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 Aspect Build Systems, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config_test - -import ( - "fmt" - "testing" - - "aspect.build/cli/pkg/aspect/root/config" - . "github.com/onsi/gomega" -) - -func TestParseConfigVersion(t *testing.T) { - g := NewGomegaWithT(t) - g.Expect(config.ParseConfigVersion("")).To(Equal(config.VersionTuple{Tier: "", Version: ""})) - g.Expect(config.ParseConfigVersion("/")).To(Equal(config.VersionTuple{Tier: "", Version: ""})) - g.Expect(config.ParseConfigVersion("1.2.3")).To(Equal(config.VersionTuple{Tier: "", Version: "1.2.3"})) - g.Expect(config.ParseConfigVersion("/1.2.3")).To(Equal(config.VersionTuple{Tier: "", Version: "1.2.3"})) - g.Expect(config.ParseConfigVersion("pro/1.2.3")).To(Equal(config.VersionTuple{Tier: "pro", Version: "1.2.3"})) - g.Expect(config.ParseConfigVersion("foobar/1.2.3")).To(Equal(config.VersionTuple{Tier: "foobar", Version: "1.2.3"})) - g.Expect(config.ParseConfigVersion("pro")).To(Equal(config.VersionTuple{Tier: "pro", Version: ""})) - g.Expect(config.ParseConfigVersion("foobar")).To(Equal(config.VersionTuple{Tier: "foobar", Version: ""})) - g.Expect(config.ParseConfigVersion("pro/")).To(Equal(config.VersionTuple{Tier: "pro", Version: ""})) - g.Expect(config.ParseConfigVersion("foobar/")).To(Equal(config.VersionTuple{Tier: "foobar", Version: ""})) - - expectedError := fmt.Errorf("Invalid Aspect CLI version: 'in/valid/1.2.3'. Version should be [/].") - _, err := config.ParseConfigVersion("in/valid/1.2.3") - g.Expect(err).To(MatchError(expectedError)) -} diff --git a/pkg/bazel/bazelisk.go b/pkg/bazel/bazelisk.go index efe18618c..18cc1dab0 100644 --- a/pkg/bazel/bazelisk.go +++ b/pkg/bazel/bazelisk.go @@ -312,21 +312,7 @@ func (bazelisk *Bazelisk) getBazelVersion() (string, string, error) { Reentrant: len(os.Getenv(aspectReentrantEnv)) != 0, Version: buildinfo.Current().Version(), DevBuild: strings.HasPrefix(buildinfo.Current().Version(), "unknown"), - BaseUrl: config.AspectBaseUrl(buildinfo.Current().IsAspectPro), - } - - // Get the Aspect CLI version configuration from the Aspect CLI config.yaml or from - // USE_ASPECT_VERSION - aspectConfig, err := config.GetVersionConfig() - if err != nil { - return "", "", fmt.Errorf("could not get aspect config: %w", err) - } - - // If an Aspect CLI version is configured and does not match the running version then re-enter - // that version if we are allowed to re-enter and have not already re-entered. - if bazelisk.allowReenter && !aspectRuntime.Reentrant && aspectConfig.Configured && isAspectVersionMismatch(aspectRuntime, aspectConfig.Version, aspectConfig.BaseUrl) { - bazelisk.AspectShouldReenter = true - return aspectConfig.Version, aspectConfig.BaseUrl, nil + BaseUrl: config.AspectBaseUrl(buildinfo.Current().OpenSource), } // Get the bazelisk version config from the USE_BAZEL_VERSION and BAZELISK_BASE_URL env vars @@ -344,7 +330,7 @@ func (bazelisk *Bazelisk) getBazelVersion() (string, string, error) { // For example, "aspect/1.2.3" => "1.2.3". s := strings.Split(bazeliskConfig.UseBazelVersion, "/") sanitizedUseBazelVersion := s[len(s)-1] - if bazelisk.allowReenter && !aspectRuntime.Reentrant && !aspectConfig.Configured && isAspectVersionMismatch(aspectRuntime, sanitizedUseBazelVersion, bazeliskConfig.BazeliskBaseUrl) { + if bazelisk.allowReenter && !aspectRuntime.Reentrant && isAspectVersionMismatch(aspectRuntime, sanitizedUseBazelVersion, bazeliskConfig.BazeliskBaseUrl) { // If bazelisk is configured to bootstrap the CLI and the Aspect CLI config is not then // re-enter that version if we are allowed to re-enter and have not already re-entered. bazelisk.AspectShouldReenter = true diff --git a/pkg/plugin/system/besproxy/bes_proxy.go b/pkg/plugin/system/besproxy/bes_proxy.go index 6bbcba267..576632c53 100644 --- a/pkg/plugin/system/besproxy/bes_proxy.go +++ b/pkg/plugin/system/besproxy/bes_proxy.go @@ -93,7 +93,7 @@ func (bp *besProxy) Send(req *buildv1.PublishBuildToolEventStreamRequest) error } // If we want to mutate the BES events in the future before they are sent out to external consumers, this is the place - // to do it. See https://github.com/aspect-build/silo/blob/7f13ab16fa10ffcec71b09737f0370f22a508823/cli/core/pkg/plugin/system/besproxy/bes_proxy.go#L103 + // to do it. See https://github.com/aspect-build/silo/blob/7f13ab16fa10ffcec71b09737f0370f22a508823/pkg/plugin/system/besproxy/bes_proxy.go#L103 // as an example. return bp.stream.Send(req) From a40ba8e789154c55d1aeb2ca58a2162fd56fbb5f Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Fri, 27 Sep 2024 21:47:55 -0700 Subject: [PATCH 02/23] refactor: stamp Aspect CLI with monorepo version scheme ..- (#6932) Aspect CLI will now be versioned independently from Workflows. --- ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: yes Aspect CLI will now be versioned independently from Workflows. Version stamp will follow monorepo versioning scheme `..-`. ### Test plan - Covered by existing test cases - Manual testing; please provide instructions so we can reproduce: ``` $ bazel-bin/cli/pro/pro_/pro version --aspect:lock_version Aspect CLI version: 2024.39.51-a6b3d0c7b $ bazel-bin/cli/pro/pro_/pro --version aspect 2024.39.51-a6b3d0c7b $ bazel-bin/cli/core/cmd/aspect/aspect_/aspect version --aspect:lock_version Aspect CLI OSS version: 2024.39.51-a6b3d0c7b $ bazel-bin/cli/core/cmd/aspect/aspect_/aspect --version aspect oss 2024.39.51-a6b3d0c7b ``` GitOrigin-RevId: cc67e6d0d579babe40b8eb43bad3f8d711556914 --- buildinfo/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildinfo/BUILD.bazel b/buildinfo/BUILD.bazel index 9999dd372..9a7dac3c3 100644 --- a/buildinfo/BUILD.bazel +++ b/buildinfo/BUILD.bazel @@ -7,7 +7,7 @@ _GO_STAMP_X_DEFS = { "GitCommit": "{STABLE_BUILD_SCM_SHA}", "GitStatus": "{STABLE_BUILD_SCM_LOCAL_CHANGES}", "HostName": "{BUILD_HOST}", - "Release": "{STABLE_BUILD_SCM_TAG}", + "Release": "{STABLE_ASPECT_CLI_VERSION}", } go_library( From 63059f60d28cca978362a35a07c607af43a83456 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Tue, 1 Oct 2024 11:46:05 -0700 Subject: [PATCH 03/23] fix(cli): support .gitignore ignoring of directories (#6880) Minor enhancement to support the .gitignore trailing-/ so it only matches directories. --- ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases - New test cases added GitOrigin-RevId: 2711ceec5d8d5ffe9ec2f045b7c0994d4b0c5d6c --- gazelle/common/git/gitignore.go | 8 +++-- gazelle/common/git/gitignore_test.go | 24 +++++++++++++-- .../tests/ignore_config_files/.test-gitignore | 3 ++ .../js/tests/ignore_config_files/BUILD.out | 1 + .../tests/ignore_config_files/modules.ts/a.ts | 1 + .../subdir/modules.ts/a.ts | 1 + .../subdir/nested/modules.ts/a.ts | 1 + .../ignore_config_files/subdir2/modules.ts | 0 ...build_bazel-gazelle_aspect-gitignore.patch | 29 ++++++++++++++----- 9 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 gazelle/js/tests/ignore_config_files/modules.ts/a.ts create mode 100644 gazelle/js/tests/ignore_config_files/subdir/modules.ts/a.ts create mode 100644 gazelle/js/tests/ignore_config_files/subdir/nested/modules.ts/a.ts create mode 100644 gazelle/js/tests/ignore_config_files/subdir2/modules.ts diff --git a/gazelle/common/git/gitignore.go b/gazelle/common/git/gitignore.go index 546acb00e..ed2e4e34d 100644 --- a/gazelle/common/git/gitignore.go +++ b/gazelle/common/git/gitignore.go @@ -15,6 +15,8 @@ import ( // Must align with patched bazel-gazelle const ASPECT_GITIGNORE = "__aspect:gitignore" +type isGitIgnoredFunc = func(string, bool) bool + // Directive to enable/disable gitignore support const Directive_GitIgnore = "gitignore" @@ -97,14 +99,14 @@ func parseIgnore(rel string, ignoreReader io.Reader) []gitignore.Pattern { return matcherPatterns } -func createMatcherFunc(c *config.Config) func(string) bool { +func createMatcherFunc(c *config.Config) isGitIgnoredFunc { patterns, patternsFound := c.Exts[ignorePatternsExt] if !patternsFound { return nil } matcher := gitignore.NewMatcher(patterns.([]gitignore.Pattern)) - return func(s string) bool { - return matcher.Match(strings.Split(s, "/"), false) + return func(s string, isDir bool) bool { + return matcher.Match(strings.Split(s, "/"), isDir) } } diff --git a/gazelle/common/git/gitignore_test.go b/gazelle/common/git/gitignore_test.go index edbdc3d53..9a06ea684 100644 --- a/gazelle/common/git/gitignore_test.go +++ b/gazelle/common/git/gitignore_test.go @@ -12,7 +12,11 @@ func TestGitIgnore(t *testing.T) { shouldMatch := func(what string, c *config.Config, matches ...string) { matcher := createMatcherFunc(c) for _, m := range matches { - if !(matcher != nil && matcher(m)) { + // Use trailing slash in test data to indicate directory + isDir := strings.HasSuffix(m, "/") + m = strings.TrimSuffix(m, "/") + + if !(matcher != nil && matcher(m, isDir)) { t.Error(fmt.Sprintf("%s should match '%s'", what, m)) } } @@ -20,7 +24,11 @@ func TestGitIgnore(t *testing.T) { shouldNotMatch := func(what string, c *config.Config, matches ...string) { matcher := createMatcherFunc(c) for _, m := range matches { - if matcher != nil && matcher(m) { + // Use trailing slash in test data to indicate directory + isDir := strings.HasSuffix(m, "/") + m = strings.TrimSuffix(m, "/") + + if matcher != nil && matcher(m, isDir) { t.Error(fmt.Sprintf("%s should NOT match '%s'", what, m)) } } @@ -183,6 +191,18 @@ func TestGitIgnore(t *testing.T) { shouldMatch("double wildcard", c, "subdir/x.starstar.ts", "subdir/a/b/c/x.starstar.ts", "subdir/a/.starstar.ts") shouldNotMatch("double wildcard different subdir", c, "startstar.ts", ".startstar.ts", "a/starstar.ts") }) + + t.Run("dir specific matches", func(t *testing.T) { + c := config.New() + addIgnoreFileContent(c, "", ` + **/node_modules/ + **/foo.js/ + `) + + shouldMatch("dir pattern", c, "node_modules/", "a/b/node_modules/") + shouldMatch("dir pattern that looks like a file", c, "foo.js/", "a/b/foo.js/") + shouldNotMatch("ending file that looks like dir", c, "node_modules", "x/node_modules", "foo.js", "x/foo.js") + }) } // Util method to invoke GitIgnore.AddIgnore() with the trimmed string diff --git a/gazelle/js/tests/ignore_config_files/.test-gitignore b/gazelle/js/tests/ignore_config_files/.test-gitignore index 5b45bcae9..ccb854e63 100644 --- a/gazelle/js/tests/ignore_config_files/.test-gitignore +++ b/gazelle/js/tests/ignore_config_files/.test-gitignore @@ -16,3 +16,6 @@ subtarget/generated.ts # A global glob configured from the root with no slash **-wild.ts + +# An ignore pattern exclusively matching directories +**/modules.ts/ diff --git a/gazelle/js/tests/ignore_config_files/BUILD.out b/gazelle/js/tests/ignore_config_files/BUILD.out index d80631d29..cdb65b617 100644 --- a/gazelle/js/tests/ignore_config_files/BUILD.out +++ b/gazelle/js/tests/ignore_config_files/BUILD.out @@ -24,6 +24,7 @@ ts_project( "subdir/nested/index.ts", "subdir/not.nested-ig.ts", "subdir2/direct-ig.ts", + "subdir2/modules.ts", "subdir2/not.nested-ig.ts", ], deps = [ diff --git a/gazelle/js/tests/ignore_config_files/modules.ts/a.ts b/gazelle/js/tests/ignore_config_files/modules.ts/a.ts new file mode 100644 index 000000000..a407072bb --- /dev/null +++ b/gazelle/js/tests/ignore_config_files/modules.ts/a.ts @@ -0,0 +1 @@ +import 'bad-import-but-this-dir-is-ignored'; diff --git a/gazelle/js/tests/ignore_config_files/subdir/modules.ts/a.ts b/gazelle/js/tests/ignore_config_files/subdir/modules.ts/a.ts new file mode 100644 index 000000000..a407072bb --- /dev/null +++ b/gazelle/js/tests/ignore_config_files/subdir/modules.ts/a.ts @@ -0,0 +1 @@ +import 'bad-import-but-this-dir-is-ignored'; diff --git a/gazelle/js/tests/ignore_config_files/subdir/nested/modules.ts/a.ts b/gazelle/js/tests/ignore_config_files/subdir/nested/modules.ts/a.ts new file mode 100644 index 000000000..a407072bb --- /dev/null +++ b/gazelle/js/tests/ignore_config_files/subdir/nested/modules.ts/a.ts @@ -0,0 +1 @@ +import 'bad-import-but-this-dir-is-ignored'; diff --git a/gazelle/js/tests/ignore_config_files/subdir2/modules.ts b/gazelle/js/tests/ignore_config_files/subdir2/modules.ts new file mode 100644 index 000000000..e69de29bb diff --git a/patches/bazelbuild_bazel-gazelle_aspect-gitignore.patch b/patches/bazelbuild_bazel-gazelle_aspect-gitignore.patch index 6d010a045..95069a59b 100644 --- a/patches/bazelbuild_bazel-gazelle_aspect-gitignore.patch +++ b/patches/bazelbuild_bazel-gazelle_aspect-gitignore.patch @@ -10,30 +10,45 @@ index 23b1083..1841650 100644 func New() *Config { return &Config{ +diff --git a/walk/config.go b/walk/config.go +index 1292146..07cdb3d 100644 +--- a/walk/config.go ++++ b/walk/config.go +@@ -109,6 +109,7 @@ func (cr *Configurer) Configure(c *config.Config, rel string, f *rule.File) { + } + + type isIgnoredFunc = func(string) bool ++type isGitIgnoredFunc = func(string, bool) bool + + var nothingIgnored isIgnoredFunc = func(string) bool { return false } + diff --git a/walk/walk.go b/walk/walk.go -index 7814088..8ebb086 100644 +index 7814088..1ba1b47 100644 --- a/walk/walk.go +++ b/walk/walk.go -@@ -165,6 +165,13 @@ func visit(c *config.Config, cexts []config.Configurer, knownDirectives map[stri +@@ -165,6 +165,14 @@ func visit(c *config.Config, cexts []config.Configurer, knownDirectives map[stri return nil, false } + // PATCH(gitignore) --- -+ isGitIgnored, hasGitIgnore := c.Exts[config.ASPECT_GITIGNORE].(isIgnoredFunc) -+ if !hasGitIgnore || isGitIgnored == nil { -+ isGitIgnored = nothingIgnored ++ var isGitIgnored isGitIgnoredFunc ++ isGitIgnoredExt, hasGitIgnore := c.Exts[config.ASPECT_GITIGNORE] ++ if hasGitIgnore && isGitIgnoredExt != nil { ++ isGitIgnored = isGitIgnoredExt.(isGitIgnoredFunc) + } + // END PATCH(gitignore) --- + var dirs, subdirs, regularFiles []string for _, ent := range ents { base := ent.Name() -@@ -172,6 +179,11 @@ func visit(c *config.Config, cexts []config.Configurer, knownDirectives map[stri +@@ -172,6 +180,13 @@ func visit(c *config.Config, cexts []config.Configurer, knownDirectives map[stri if wc.isExcluded(entRel) { continue } + // PATCH(gitignore) --- -+ if isGitIgnored(entRel) { ++ // NOTE: .gitignore must be applied *before* symlinks are followed ++ // See notes on symlink examples at https://git-scm.com/docs/gitignore#_examples ++ if isGitIgnored != nil && isGitIgnored(entRel, ent.IsDir()) { + continue + } + // END PATCH(gitignore) --- From caf2b613f0bff867494bf351f61c261835960b55 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 2 Oct 2024 09:15:16 -0700 Subject: [PATCH 04/23] fix(cli): support package.json exports/main references to outputted .js/.d.ts (#6967) The package.json `main`, `exports` and `types` normally reference the transpiled js or dts. Normally imports between .ts are all relative to the source ts so the `rootDir` and `outDir` aren't taken into account. When the package.json imports the transpioled .js/dts we must make the transpiled files available as well. --- ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases - New test cases added GitOrigin-RevId: 0613758a33636c5c8fb1f55425fa7f15ba1b5a04 --- gazelle/js/resolve.go | 26 +++++++++--- .../tests/npm_package_deps_tsconfig/BUILD.in | 5 +++ .../tests/npm_package_deps_tsconfig/BUILD.out | 21 ++++++++++ .../tests/npm_package_deps_tsconfig/WORKSPACE | 1 + .../exports/BUILD.in | 0 .../exports/BUILD.out | 27 +++++++++++++ .../exports/package.json | 7 ++++ .../exports/src/main.ts | 0 .../exports/tsconfig.json | 6 +++ .../main-custom_ts/BUILD.in | 1 + .../main-custom_ts/BUILD.out | 24 +++++++++++ .../main-custom_ts/package.json | 5 +++ .../main-custom_ts/start.ts | 0 .../main-custom_ts/tsconfig.json | 1 + .../main-inherit-tsconfig/BUILD.in | 0 .../main-inherit-tsconfig/BUILD.out | 21 ++++++++++ .../main-inherit-tsconfig/package.json | 5 +++ .../main-inherit-tsconfig/start.ts | 0 .../npm_package_deps_tsconfig/main/BUILD.in | 0 .../npm_package_deps_tsconfig/main/BUILD.out | 26 ++++++++++++ .../main/package.json | 5 +++ .../npm_package_deps_tsconfig/main/start.ts | 0 .../main/tsconfig.json | 5 +++ .../npm_package_deps_tsconfig/package.json | 3 ++ .../npm_package_deps_tsconfig/pnpm-lock.yaml | 17 ++++++++ .../pnpm-workspace.yaml | 3 ++ .../npm_package_deps_tsconfig/tsconfig.json | 5 +++ gazelle/js/typescript/tsconfig.go | 14 +++++++ gazelle/js/typescript/tsconfig_test.go | 40 +++++++++++++++++++ 29 files changed, 262 insertions(+), 6 deletions(-) create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/WORKSPACE create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/exports/package.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/exports/src/main.ts create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/exports/tsconfig.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/package.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/start.ts create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/tsconfig.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/package.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/start.ts create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main/package.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main/start.ts create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/main/tsconfig.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/package.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/pnpm-lock.yaml create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/pnpm-workspace.yaml create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/tsconfig.json diff --git a/gazelle/js/resolve.go b/gazelle/js/resolve.go index ef854e60c..a25a34ddb 100644 --- a/gazelle/js/resolve.go +++ b/gazelle/js/resolve.go @@ -79,17 +79,31 @@ func (ts *typeScriptLang) sourceFileImports(c *config.Config, r *rule.Rule, f *r srcs = expandedSrcs } + _, tsconfig := ts.tsconfig.FindConfig(f.Pkg) + provides := make([]resolve.ImportSpec, 0, len(srcs)+1) // Sources that produce importable paths. for _, src := range srcs { - src = path.Clean(path.Join(f.Pkg, src)) + // The raw source path + srcs = []string{path.Join(f.Pkg, src)} + + // Also add tsconfig-mapped directories for references + // to the output files of the ts_project rule. + if tsconfig != nil { + outSrc := tsconfig.ToOutDir(src) + if outSrc != src { + srcs = append(srcs, path.Join(f.Pkg, outSrc)) + } + } - for _, impt := range toImportPaths(src) { - provides = append(provides, resolve.ImportSpec{ - Lang: LanguageName, - Imp: impt, - }) + for _, src := range srcs { + for _, impt := range toImportPaths(src) { + provides = append(provides, resolve.ImportSpec{ + Lang: LanguageName, + Imp: impt, + }) + } } } diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.in b/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.in new file mode 100644 index 000000000..befc1995a --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.in @@ -0,0 +1,5 @@ +# gazelle:generation_mode update +# gazelle:js_tsconfig enabled +# gazelle:js_npm_package_target_name pkg +# gazelle:js_project_naming_convention tsc +# gazelle:js_npm_package enabled diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out new file mode 100644 index 000000000..7229163d9 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out @@ -0,0 +1,21 @@ +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@aspect_rules_ts//ts:defs.bzl", "ts_config") +load("@npm//:defs.bzl", "npm_link_all_packages") + +# gazelle:generation_mode update +# gazelle:js_tsconfig enabled +# gazelle:js_npm_package_target_name pkg +# gazelle:js_project_naming_convention tsc +# gazelle:js_npm_package enabled + +npm_link_all_packages(name = "node_modules") + +npm_package( + name = "pkg", + srcs = ["package.json"], +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", +) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/WORKSPACE b/gazelle/js/tests/npm_package_deps_tsconfig/WORKSPACE new file mode 100644 index 000000000..ce564330d --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/WORKSPACE @@ -0,0 +1 @@ +workspace(name = "npm_package_deps_tsconfig") diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.in b/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out new file mode 100644 index 000000000..1e6bf3afc --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out @@ -0,0 +1,27 @@ +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +ts_project( + name = "tsc", + srcs = ["src/main.ts"], + out_dir = "dist", + root_dir = "src", + tsconfig = ":tsconfig", +) + +npm_package( + name = "pkg", + srcs = [ + "package.json", + ":tsc", + ], + deps = [":tsc"], +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", +) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/exports/package.json b/gazelle/js/tests/npm_package_deps_tsconfig/exports/package.json new file mode 100644 index 000000000..7fb7ebf1f --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/exports/package.json @@ -0,0 +1,7 @@ +{ + "name": "pkg-with-exports", + "private": true, + "exports": { + ".": "./dist/main.js" + } +} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/exports/src/main.ts b/gazelle/js/tests/npm_package_deps_tsconfig/exports/src/main.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/exports/tsconfig.json b/gazelle/js/tests/npm_package_deps_tsconfig/exports/tsconfig.json new file mode 100644 index 000000000..006c671c9 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/exports/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + } +} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.in b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.in new file mode 100644 index 000000000..68617f8af --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.in @@ -0,0 +1 @@ +# gazelle:js_files m start.ts diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out new file mode 100644 index 000000000..d5b8059ff --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out @@ -0,0 +1,24 @@ +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project") +load("@npm//:defs.bzl", "npm_link_all_packages") + +# gazelle:js_files m start.ts + +npm_link_all_packages(name = "node_modules") + +ts_project( + name = "m", + srcs = ["start.ts"], + tsconfig = ":tsconfig", +) + +npm_package( + name = "pkg", + srcs = ["package.json"], + deps = [":m"], +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", +) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/package.json b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/package.json new file mode 100644 index 000000000..509c6767b --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-with-main", + "private": true, + "main": "start.js" +} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/start.ts b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/start.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/tsconfig.json b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/tsconfig.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/tsconfig.json @@ -0,0 +1 @@ +{} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.in b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out new file mode 100644 index 000000000..c03ac3973 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out @@ -0,0 +1,21 @@ +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +ts_project( + name = "tsc", + srcs = ["start.ts"], + out_dir = "dist", + tsconfig = "//:tsconfig", +) + +npm_package( + name = "pkg", + srcs = [ + "package.json", + ":tsc", + ], + deps = [":tsc"], +) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/package.json b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/package.json new file mode 100644 index 000000000..e6a8b639f --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-with-main2", + "private": true, + "main": "dist/start.js" +} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/start.ts b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/start.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.in b/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out new file mode 100644 index 000000000..fae96df82 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out @@ -0,0 +1,26 @@ +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +ts_project( + name = "tsc", + srcs = ["start.ts"], + out_dir = "dist", + tsconfig = ":tsconfig", +) + +npm_package( + name = "pkg", + srcs = [ + "package.json", + ":tsc", + ], + deps = [":tsc"], +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", +) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main/package.json b/gazelle/js/tests/npm_package_deps_tsconfig/main/package.json new file mode 100644 index 000000000..09a340cd1 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-with-main", + "private": true, + "main": "dist/start.js" +} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main/start.ts b/gazelle/js/tests/npm_package_deps_tsconfig/main/start.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main/tsconfig.json b/gazelle/js/tests/npm_package_deps_tsconfig/main/tsconfig.json new file mode 100644 index 000000000..b3e6e6e06 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "outDir": "dist" + } +} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/package.json b/gazelle/js/tests/npm_package_deps_tsconfig/package.json new file mode 100644 index 000000000..352055cdf --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/package.json @@ -0,0 +1,3 @@ +{ + "private": true +} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-lock.yaml b/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-lock.yaml new file mode 100644 index 000000000..af01040db --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-lock.yaml @@ -0,0 +1,17 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: {} + + exports: {} + + main: {} + + main-custom_ts: {} + + main-inherit-tsconfig: {} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-workspace.yaml b/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-workspace.yaml new file mode 100644 index 000000000..1065f5306 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +packages: + - '.' + - '*' diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/tsconfig.json b/gazelle/js/tests/npm_package_deps_tsconfig/tsconfig.json new file mode 100644 index 000000000..7d075d357 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "outDir": "dist", + } +} diff --git a/gazelle/js/typescript/tsconfig.go b/gazelle/js/typescript/tsconfig.go index 41aa68d4b..7d4cd0bf5 100644 --- a/gazelle/js/typescript/tsconfig.go +++ b/gazelle/js/typescript/tsconfig.go @@ -332,6 +332,20 @@ func parseTsConfigJSON(parsed map[string]*TsConfig, resolver TsConfigResolver, r return &config, nil } +func (c TsConfig) ToOutDir(f string) string { + if c.RootDir != "." { + if strings.HasPrefix(f, c.RootDir) && f[len(c.RootDir)] == '/' { + f = f[len(c.RootDir)+1:] + } + } + + if c.OutDir != "." { + f = path.Join(c.OutDir, f) + } + + return f +} + // Returns the path from the project base to the active tsconfig.json file // This is used to build the path from the project base to the file being imported // because gazelle seems to resolve files relative to the project base diff --git a/gazelle/js/typescript/tsconfig_test.go b/gazelle/js/typescript/tsconfig_test.go index 77fe63c54..2b9bfe9c1 100644 --- a/gazelle/js/typescript/tsconfig_test.go +++ b/gazelle/js/typescript/tsconfig_test.go @@ -425,3 +425,43 @@ func TestTsconfigParse(t *testing.T) { } }) } + +func TestTsconfigOutRootDirs(t *testing.T) { + t.Run("empty config", func(t *testing.T) { + o1 := parseTest(t, ".", `{}`) + assertEqual(t, o1.ToOutDir("foo.ts"), "foo.ts", "empty config") + + o2 := parseTest(t, ".", `{"compilerOptions": {"rootDir": "./"}}`) + assertEqual(t, o2.ToOutDir("foo.ts"), "foo.ts", "empty rel config") + }) + + t.Run("rootDir config", func(t *testing.T) { + o1 := parseTest(t, ".", `{"compilerOptions": {"rootDir": "./src"}}`) + assertEqual(t, o1.ToOutDir("src/foo.ts"), "foo.ts", "empty config") + + o2 := parseTest(t, ".", `{"compilerOptions": {"rootDir": "src"}}`) + assertEqual(t, o2.ToOutDir("src/foo.ts"), "foo.ts", "empty config") + + o3 := parseTest(t, ".", `{"compilerOptions": {"rootDir": "src/foo/.."}}`) + assertEqual(t, o3.ToOutDir("src/foo.ts"), "foo.ts", "empty config") + }) + + t.Run("outDir config", func(t *testing.T) { + o1 := parseTest(t, ".", `{"compilerOptions": {"outDir": "dist"}}`) + assertEqual(t, o1.ToOutDir("foo.ts"), "dist/foo.ts", "empty config") + + o2 := parseTest(t, ".", `{"compilerOptions": {"outDir": "./dist"}}`) + assertEqual(t, o2.ToOutDir("foo.ts"), "dist/foo.ts", "empty config") + + o3 := parseTest(t, ".", `{"compilerOptions": {"outDir": "./dist/"}}`) + assertEqual(t, o3.ToOutDir("foo.ts"), "dist/foo.ts", "empty config") + + o4 := parseTest(t, ".", `{"compilerOptions": {"outDir": "./dist/foo/.."}}`) + assertEqual(t, o4.ToOutDir("foo.ts"), "dist/foo.ts", "empty config") + }) + + t.Run("rootDir + outDir config", func(t *testing.T) { + options := parseTest(t, ".", `{"compilerOptions": {"rootDir": "./src", "outDir": "dist"}}`) + assertEqual(t, options.ToOutDir("src/foo.ts"), "dist/foo.ts", "empty config") + }) +} From 2a597893caa1c93d8eae08063ed687f4c481c4aa Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 2 Oct 2024 09:19:45 -0700 Subject: [PATCH 05/23] fix(cli): generated npm package srcs vs deps attributes (#6965) The `js_library` and `npm_package` targets representing npm packages were sharing too much code and mixing `npm_package(srcs)` and `js_library(deps)`. --- - Covered by existing test cases - New test cases added GitOrigin-RevId: 9c03adbceff31bf1aecff18c9ca3373c71513262 --- gazelle/js/generate.go | 10 +---- gazelle/js/resolve.go | 38 ++++++++++++++++++- gazelle/js/target.go | 17 +++++++++ .../npm_package_deps/exports-gen/BUILD.out | 6 ++- .../npm_package_deps/exports-ignore/BUILD.out | 13 +++++++ .../npm_package_deps/exports-js/BUILD.out | 4 +- .../npm_package_deps/exports-single/BUILD.out | 12 ++++++ .../npm_package_deps/exports-ts/BUILD.out | 6 ++- .../npm_package_deps/main-custom_ts/BUILD.out | 6 ++- .../npm_package_deps/main-js-gen/BUILD.out | 6 ++- .../tests/npm_package_deps/main-ts/BUILD.out | 1 - .../js/tests/npm_package_deps/pnpm-lock.yaml | 4 ++ .../js/tests/npm_package_deps_lib/BUILD.in | 5 +++ .../js/tests/npm_package_deps_lib/BUILD.out | 15 ++++++++ .../js/tests/npm_package_deps_lib/WORKSPACE | 1 + .../npm_package_deps_lib/exports-gen/BUILD.in | 6 +++ .../exports-gen/BUILD.out | 17 +++++++++ .../exports-gen/package.json | 7 ++++ .../exports-ignore/BUILD.in | 1 + .../exports-ignore/BUILD.out | 20 ++++++++++ .../exports-ignore/lib1.js | 0 .../exports-ignore/package.json | 12 ++++++ .../npm_package_deps_lib/exports-js/BUILD.in | 0 .../npm_package_deps_lib/exports-js/BUILD.out | 14 +++++++ .../exports-js/bin/BUILD.in | 0 .../exports-js/bin/BUILD.out | 6 +++ .../exports-js/bin/main.js | 0 .../exports-js/lib/BUILD.in | 0 .../exports-js/lib/BUILD.out | 6 +++ .../exports-js/lib/lib.js | 0 .../exports-js/lib2/BUILD.in | 0 .../exports-js/lib2/BUILD.out | 6 +++ .../exports-js/lib2/lib2.js | 0 .../exports-js/package.json | 12 ++++++ .../exports-single/BUILD.in | 0 .../exports-single/BUILD.out | 10 +++++ .../exports-single/bin/BUILD.in | 0 .../exports-single/bin/BUILD.out | 6 +++ .../exports-single/bin/main.js | 0 .../exports-single/package.json | 5 +++ .../npm_package_deps_lib/exports-ts/BUILD.in | 0 .../npm_package_deps_lib/exports-ts/BUILD.out | 10 +++++ .../exports-ts/package.json | 8 ++++ .../exports-ts/src/BUILD.in | 0 .../exports-ts/src/BUILD.out | 6 +++ .../exports-ts/src/main.ts | 0 .../main-custom_ts/BUILD.in | 1 + .../main-custom_ts/BUILD.out | 18 +++++++++ .../main-custom_ts/package.json | 5 +++ .../main-custom_ts/start.ts | 0 .../npm_package_deps_lib/main-js-gen/BUILD.in | 6 +++ .../main-js-gen/BUILD.out | 17 +++++++++ .../main-js-gen/package.json | 5 +++ .../npm_package_deps_lib/main-js/BUILD.in | 0 .../npm_package_deps_lib/main-js/BUILD.out | 18 +++++++++ .../npm_package_deps_lib/main-js/package.json | 5 +++ .../npm_package_deps_lib/main-js/start.js | 0 .../npm_package_deps_lib/main-ts/BUILD.in | 0 .../npm_package_deps_lib/main-ts/BUILD.out | 16 ++++++++ .../npm_package_deps_lib/main-ts/package.json | 5 +++ .../npm_package_deps_lib/main-ts/start.ts | 0 .../tests/npm_package_deps_lib/package.json | 3 ++ .../tests/npm_package_deps_lib/pnpm-lock.yaml | 27 +++++++++++++ .../npm_package_deps_lib/pnpm-workspace.yaml | 3 ++ .../exports/BUILD.out | 1 - .../main-custom_ts/BUILD.out | 6 ++- .../main-inherit-tsconfig/BUILD.out | 1 - .../npm_package_deps_tsconfig/main/BUILD.out | 1 - 68 files changed, 407 insertions(+), 27 deletions(-) create mode 100644 gazelle/js/tests/npm_package_deps_lib/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/WORKSPACE create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-gen/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ignore/lib1.js create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ignore/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/bin/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/bin/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/bin/main.js create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/lib/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/lib/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/lib/lib.js create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/lib2.js create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-js/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-single/bin/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-single/bin/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-single/bin/main.js create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-single/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ts/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ts/src/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ts/src/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/exports-ts/src/main.ts create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-custom_ts/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-custom_ts/start.ts create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-js-gen/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-js/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-js/start.js create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-ts/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/main-ts/start.ts create mode 100644 gazelle/js/tests/npm_package_deps_lib/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/pnpm-lock.yaml create mode 100644 gazelle/js/tests/npm_package_deps_lib/pnpm-workspace.yaml diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index 1ebcb8a1b..ee619489c 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -183,7 +183,7 @@ func (ts *typeScriptLang) addSourceRules(cfg *JsGazelleConfig, args language.Gen } func (ts *typeScriptLang) addPackageRule(cfg *JsGazelleConfig, args language.GenerateArgs, packageName string, sourceFiles, dataFiles *treeset.Set, srcLabel *label.Label, result *language.GenerateResult) { - npmPackageInfo := newTsProjectInfo() + npmPackageInfo := newTsPackageInfo(srcLabel) packageJsonPath := path.Join(args.Rel, NpmPackageFilename) packageImports, err := node.ParsePackageJsonImportsFile(args.Config.RepoRoot, packageJsonPath) @@ -230,14 +230,6 @@ func (ts *typeScriptLang) addPackageRule(cfg *JsGazelleConfig, args language.Gen } npmPackage := rule.NewRule(packageTargetKind, packageTargetName) - if srcLabel != nil { - if cfg.packageTargetKind == PackageTargetKind_Library { - npmPackage.SetAttr("deps", []label.Label{*srcLabel}) - } else { - npmPackageInfo.sources.Add(srcLabel.String()) - } - } - npmPackage.SetAttr("srcs", npmPackageInfo.sources.Values()) result.Gen = append(result.Gen, npmPackage) diff --git a/gazelle/js/resolve.go b/gazelle/js/resolve.go index a25a34ddb..a40190a34 100644 --- a/gazelle/js/resolve.go +++ b/gazelle/js/resolve.go @@ -206,10 +206,23 @@ func (ts *typeScriptLang) Resolve( BazelLog.Infof("Resolve(%s): //%s:%s", LanguageName, from.Pkg, r.Name()) // TsProject imports are resolved as deps - if r.Kind() == TsProjectKind || r.Kind() == JsLibraryKind || r.Kind() == TsConfigKind || r.Kind() == TsProtoLibraryKind || r.Kind() == NpmPackageKind { + switch r.Kind() { + case TsProjectKind, JsLibraryKind, TsConfigKind, TsProtoLibraryKind: deps := common.NewLabelSet(from) - err := ts.resolveImports(c, ix, deps, importData.(*TsProjectInfo).imports, from) + // Support this target representing a project or a package + var imports *treeset.Set + if packageInfo, isProjectInfo := importData.(*TsPackageInfo); isProjectInfo { + imports = packageInfo.imports + + if packageInfo.source != nil { + deps.Add(packageInfo.source) + } + } else { + imports = importData.(*TsProjectInfo).imports + } + + err := ts.resolveImports(c, ix, deps, imports, from) if err != nil { BazelLog.Fatalf("Resolution Error: %v", err) os.Exit(1) @@ -222,6 +235,27 @@ func (ts *typeScriptLang) Resolve( if !deps.Empty() { r.SetAttr("deps", deps.Labels()) } + case NpmPackageKind: + packageInfo := importData.(*TsPackageInfo) + srcs := packageInfo.sources.Values() + + deps := common.NewLabelSet(from) + err := ts.resolveImports(c, ix, deps, packageInfo.imports, from) + if err != nil { + BazelLog.Fatalf("Resolution Error: %v", err) + os.Exit(1) + } + for _, dep := range deps.Labels() { + srcs = append(srcs, dep.String()) + } + + if packageInfo.source != nil { + srcs = append(srcs, packageInfo.source.String()) + } + + if len(srcs) > 0 { + r.SetAttr("srcs", srcs) + } } BazelLog.Infof("Resolve(%s): //%s:%s DONE in %s", LanguageName, from.Pkg, r.Name(), time.Since(start).String()) diff --git a/gazelle/js/target.go b/gazelle/js/target.go index 7d4faeda9..904063132 100644 --- a/gazelle/js/target.go +++ b/gazelle/js/target.go @@ -1,6 +1,7 @@ package gazelle import ( + "github.com/bazelbuild/bazel-gazelle/label" "github.com/bazelbuild/bazel-gazelle/resolve" "github.com/emirpasic/gods/sets/treeset" godsutils "github.com/emirpasic/gods/utils" @@ -29,6 +30,22 @@ func newLinkAllPackagesImports() *LinkAllPackagesImports { return &LinkAllPackagesImports{} } +type TsPackageInfo struct { + TsProjectInfo + + source *label.Label +} + +func newTsPackageInfo(source *label.Label) *TsPackageInfo { + return &TsPackageInfo{ + TsProjectInfo: TsProjectInfo{ + imports: treeset.NewWith(importStatementComparator), + sources: treeset.NewWithStringComparator(), + }, + source: source, + } +} + // TsProject rule import data type TsProjectInfo struct { // `ImportStatement`s in ths project diff --git a/gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out index c060c8867..5bffc1109 100644 --- a/gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out @@ -12,6 +12,8 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pkg", - srcs = ["package.json"], - deps = [":start.js"], + srcs = [ + "package.json", + ":start.js", + ], ) diff --git a/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out index c122205e0..417933db2 100644 --- a/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out @@ -1,8 +1,21 @@ load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@npm//:defs.bzl", "npm_link_all_packages") # gazelle:js_ignore_imports **/does-not-exist.js +npm_link_all_packages(name = "node_modules") + js_library( name = "tsc", srcs = ["lib1.js"], ) + +npm_package( + name = "pkg", + srcs = [ + "lib1.js", + "package.json", + ":tsc", + ], +) diff --git a/gazelle/js/tests/npm_package_deps/exports-js/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-js/BUILD.out index cc3d964e1..38c25f05a 100644 --- a/gazelle/js/tests/npm_package_deps/exports-js/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-js/BUILD.out @@ -5,8 +5,8 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pkg", - srcs = ["package.json"], - deps = [ + srcs = [ + "package.json", "//exports-js/bin:tsc", "//exports-js/lib:tsc", "//exports-js/lib2:tsc", diff --git a/gazelle/js/tests/npm_package_deps/exports-single/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-single/BUILD.out index e69de29bb..41b8d7a47 100644 --- a/gazelle/js/tests/npm_package_deps/exports-single/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-single/BUILD.out @@ -0,0 +1,12 @@ +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +npm_package( + name = "pkg", + srcs = [ + "package.json", + "//exports-single/bin:tsc", + ], +) diff --git a/gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out index 5a9c475f0..4888b4b62 100644 --- a/gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out @@ -5,6 +5,8 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pkg", - srcs = ["package.json"], - deps = ["//exports-ts/src:tsc"], + srcs = [ + "package.json", + "//exports-ts/src:tsc", + ], ) diff --git a/gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out b/gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out index 7db4cf23b..5236e8cc3 100644 --- a/gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out @@ -13,6 +13,8 @@ ts_project( npm_package( name = "pkg", - srcs = ["package.json"], - deps = [":m"], + srcs = [ + "package.json", + ":m", + ], ) diff --git a/gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out b/gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out index c060c8867..5bffc1109 100644 --- a/gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out @@ -12,6 +12,8 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pkg", - srcs = ["package.json"], - deps = [":start.js"], + srcs = [ + "package.json", + ":start.js", + ], ) diff --git a/gazelle/js/tests/npm_package_deps/main-ts/BUILD.out b/gazelle/js/tests/npm_package_deps/main-ts/BUILD.out index 85b4e2277..ff60625b7 100644 --- a/gazelle/js/tests/npm_package_deps/main-ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/main-ts/BUILD.out @@ -15,5 +15,4 @@ npm_package( "package.json", ":tsc", ], - deps = [":tsc"], ) diff --git a/gazelle/js/tests/npm_package_deps/pnpm-lock.yaml b/gazelle/js/tests/npm_package_deps/pnpm-lock.yaml index 108eb49b3..520b8a6f2 100644 --- a/gazelle/js/tests/npm_package_deps/pnpm-lock.yaml +++ b/gazelle/js/tests/npm_package_deps/pnpm-lock.yaml @@ -10,8 +10,12 @@ importers: exports-gen: {} + exports-ignore: {} + exports-js: {} + exports-single: {} + exports-ts: {} main-custom_ts: {} diff --git a/gazelle/js/tests/npm_package_deps_lib/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/BUILD.in new file mode 100644 index 000000000..93f2b02d8 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/BUILD.in @@ -0,0 +1,5 @@ +# aspect:js_files **/*.{js,ts} +# gazelle:js_npm_package_target_name pkg +# gazelle:js_package_rule_kind js_library +# gazelle:js_project_naming_convention tsc +# gazelle:js_npm_package enabled diff --git a/gazelle/js/tests/npm_package_deps_lib/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/BUILD.out new file mode 100644 index 000000000..7ca58d465 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/BUILD.out @@ -0,0 +1,15 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@npm//:defs.bzl", "npm_link_all_packages") + +# aspect:js_files **/*.{js,ts} +# gazelle:js_npm_package_target_name pkg +# gazelle:js_package_rule_kind js_library +# gazelle:js_project_naming_convention tsc +# gazelle:js_npm_package enabled + +npm_link_all_packages(name = "node_modules") + +js_library( + name = "pkg", + srcs = ["package.json"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/WORKSPACE b/gazelle/js/tests/npm_package_deps_lib/WORKSPACE new file mode 100644 index 000000000..d65a249ed --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/WORKSPACE @@ -0,0 +1 @@ +workspace(name = "npm_package_deps_lib") diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.in new file mode 100644 index 000000000..5ba89e62e --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.in @@ -0,0 +1,6 @@ +genrule( + name = "foo", + srcs = [], + outs = ["start.js"], + cmd = "echo \"console.log(42)\" > \"$@\"", +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out new file mode 100644 index 000000000..5b0d57a56 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out @@ -0,0 +1,17 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@npm//:defs.bzl", "npm_link_all_packages") + +genrule( + name = "foo", + srcs = [], + outs = ["start.js"], + cmd = "echo \"console.log(42)\" > \"$@\"", +) + +npm_link_all_packages(name = "node_modules") + +js_library( + name = "pkg", + srcs = ["package.json"], + deps = [":start.js"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-gen/package.json b/gazelle/js/tests/npm_package_deps_lib/exports-gen/package.json new file mode 100644 index 000000000..5f2b0eeeb --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-gen/package.json @@ -0,0 +1,7 @@ +{ + "name": "pkg-export-generated", + "private": true, + "exports": { + ".": "./start.js" + } +} diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.in new file mode 100644 index 000000000..e854f92d2 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.in @@ -0,0 +1 @@ +# gazelle:js_ignore_imports **/does-not-exist.js diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out new file mode 100644 index 000000000..e87eb62e6 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out @@ -0,0 +1,20 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@npm//:defs.bzl", "npm_link_all_packages") + +# gazelle:js_ignore_imports **/does-not-exist.js + +npm_link_all_packages(name = "node_modules") + +js_library( + name = "tsc", + srcs = ["lib1.js"], +) + +js_library( + name = "pkg", + srcs = [ + "lib1.js", + "package.json", + ], + deps = [":tsc"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/lib1.js b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/lib1.js new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/package.json b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/package.json new file mode 100644 index 000000000..acdcfbc78 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/package.json @@ -0,0 +1,12 @@ +{ + "name": "exports-ignore", + "private": true, + "exports": { + ".": { + "node": "./lib/does-not-exist.js" + }, + "./bin": "./bin/does-not-exist.js", + "./dne": "./does-not-exist.js", + "./lib": "./lib1.js" + } +} diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out new file mode 100644 index 000000000..414a9822f --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out @@ -0,0 +1,14 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +js_library( + name = "pkg", + srcs = ["package.json"], + deps = [ + "//exports-js/bin:tsc", + "//exports-js/lib:tsc", + "//exports-js/lib2:tsc", + ], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/bin/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-js/bin/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/bin/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-js/bin/BUILD.out new file mode 100644 index 000000000..3475d69ee --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-js/bin/BUILD.out @@ -0,0 +1,6 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") + +js_library( + name = "tsc", + srcs = ["main.js"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/bin/main.js b/gazelle/js/tests/npm_package_deps_lib/exports-js/bin/main.js new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/lib/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-js/lib/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/lib/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-js/lib/BUILD.out new file mode 100644 index 000000000..daa346eda --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-js/lib/BUILD.out @@ -0,0 +1,6 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") + +js_library( + name = "tsc", + srcs = ["lib.js"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/lib/lib.js b/gazelle/js/tests/npm_package_deps_lib/exports-js/lib/lib.js new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/BUILD.out new file mode 100644 index 000000000..5e2cfc136 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/BUILD.out @@ -0,0 +1,6 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") + +js_library( + name = "tsc", + srcs = ["lib2.js"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/lib2.js b/gazelle/js/tests/npm_package_deps_lib/exports-js/lib2/lib2.js new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/package.json b/gazelle/js/tests/npm_package_deps_lib/exports-js/package.json new file mode 100644 index 000000000..3d19511c7 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-js/package.json @@ -0,0 +1,12 @@ +{ + "name": "pkg-with-exports", + "private": true, + "exports": { + ".": { + "node": "./lib/lib.js", + "default": "./lib2/lib2.js" + }, + "./bin": "./bin/main.js", + "./stars/*": "./other/*.js" + } +} diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out new file mode 100644 index 000000000..f4b4c2209 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out @@ -0,0 +1,10 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +js_library( + name = "pkg", + srcs = ["package.json"], + deps = ["//exports-single/bin:tsc"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-single/bin/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-single/bin/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-single/bin/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-single/bin/BUILD.out new file mode 100644 index 000000000..3475d69ee --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-single/bin/BUILD.out @@ -0,0 +1,6 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") + +js_library( + name = "tsc", + srcs = ["main.js"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-single/bin/main.js b/gazelle/js/tests/npm_package_deps_lib/exports-single/bin/main.js new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-single/package.json b/gazelle/js/tests/npm_package_deps_lib/exports-single/package.json new file mode 100644 index 000000000..179011e3e --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-single/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-with-exports-string", + "private": true, + "exports": "./bin/main.js" +} diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out new file mode 100644 index 000000000..477351027 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out @@ -0,0 +1,10 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +js_library( + name = "pkg", + srcs = ["package.json"], + deps = ["//exports-ts/src:tsc"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ts/package.json b/gazelle/js/tests/npm_package_deps_lib/exports-ts/package.json new file mode 100644 index 000000000..f1816d0c5 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ts/package.json @@ -0,0 +1,8 @@ +{ + "name": "pkg-with-exports", + "private": true, + "exports": { + ".": "./src/main.js", + "./stars/*": "./other/*.js" + } +} diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ts/src/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/exports-ts/src/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ts/src/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-ts/src/BUILD.out new file mode 100644 index 000000000..fd4935093 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ts/src/BUILD.out @@ -0,0 +1,6 @@ +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") + +ts_project( + name = "tsc", + srcs = ["main.ts"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ts/src/main.ts b/gazelle/js/tests/npm_package_deps_lib/exports-ts/src/main.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.in new file mode 100644 index 000000000..68617f8af --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.in @@ -0,0 +1 @@ +# gazelle:js_files m start.ts diff --git a/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out new file mode 100644 index 000000000..53ea3dc7d --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out @@ -0,0 +1,18 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") +load("@npm//:defs.bzl", "npm_link_all_packages") + +# gazelle:js_files m start.ts + +npm_link_all_packages(name = "node_modules") + +ts_project( + name = "m", + srcs = ["start.ts"], +) + +js_library( + name = "pkg", + srcs = ["package.json"], + deps = [":m"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/package.json b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/package.json new file mode 100644 index 000000000..509c6767b --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-with-main", + "private": true, + "main": "start.js" +} diff --git a/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/start.ts b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/start.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.in new file mode 100644 index 000000000..5ba89e62e --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.in @@ -0,0 +1,6 @@ +genrule( + name = "foo", + srcs = [], + outs = ["start.js"], + cmd = "echo \"console.log(42)\" > \"$@\"", +) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out new file mode 100644 index 000000000..5b0d57a56 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out @@ -0,0 +1,17 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@npm//:defs.bzl", "npm_link_all_packages") + +genrule( + name = "foo", + srcs = [], + outs = ["start.js"], + cmd = "echo \"console.log(42)\" > \"$@\"", +) + +npm_link_all_packages(name = "node_modules") + +js_library( + name = "pkg", + srcs = ["package.json"], + deps = [":start.js"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js-gen/package.json b/gazelle/js/tests/npm_package_deps_lib/main-js-gen/package.json new file mode 100644 index 000000000..e6e3090df --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-js-gen/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-with-gen-main", + "private": true, + "main": "start.js" +} diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out new file mode 100644 index 000000000..f48b74a4b --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out @@ -0,0 +1,18 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +js_library( + name = "tsc", + srcs = ["start.js"], +) + +js_library( + name = "pkg", + srcs = [ + "package.json", + "start.js", + ], + deps = [":tsc"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js/package.json b/gazelle/js/tests/npm_package_deps_lib/main-js/package.json new file mode 100644 index 000000000..509c6767b --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-js/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-with-main", + "private": true, + "main": "start.js" +} diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js/start.js b/gazelle/js/tests/npm_package_deps_lib/main-js/start.js new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out new file mode 100644 index 000000000..227007f48 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out @@ -0,0 +1,16 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +ts_project( + name = "tsc", + srcs = ["start.ts"], +) + +js_library( + name = "pkg", + srcs = ["package.json"], + deps = [":tsc"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-ts/package.json b/gazelle/js/tests/npm_package_deps_lib/main-ts/package.json new file mode 100644 index 000000000..509c6767b --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/main-ts/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg-with-main", + "private": true, + "main": "start.js" +} diff --git a/gazelle/js/tests/npm_package_deps_lib/main-ts/start.ts b/gazelle/js/tests/npm_package_deps_lib/main-ts/start.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_lib/package.json b/gazelle/js/tests/npm_package_deps_lib/package.json new file mode 100644 index 000000000..352055cdf --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/package.json @@ -0,0 +1,3 @@ +{ + "private": true +} diff --git a/gazelle/js/tests/npm_package_deps_lib/pnpm-lock.yaml b/gazelle/js/tests/npm_package_deps_lib/pnpm-lock.yaml new file mode 100644 index 000000000..520b8a6f2 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/pnpm-lock.yaml @@ -0,0 +1,27 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: {} + + exports-gen: {} + + exports-ignore: {} + + exports-js: {} + + exports-single: {} + + exports-ts: {} + + main-custom_ts: {} + + main-js: {} + + main-js-gen: {} + + main-ts: {} diff --git a/gazelle/js/tests/npm_package_deps_lib/pnpm-workspace.yaml b/gazelle/js/tests/npm_package_deps_lib/pnpm-workspace.yaml new file mode 100644 index 000000000..1065f5306 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +packages: + - '.' + - '*' diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out index 1e6bf3afc..a91c61417 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out @@ -18,7 +18,6 @@ npm_package( "package.json", ":tsc", ], - deps = [":tsc"], ) ts_config( diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out index d5b8059ff..6749380c0 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out @@ -14,8 +14,10 @@ ts_project( npm_package( name = "pkg", - srcs = ["package.json"], - deps = [":m"], + srcs = [ + "package.json", + ":m", + ], ) ts_config( diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out index c03ac3973..49ce28faf 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out @@ -17,5 +17,4 @@ npm_package( "package.json", ":tsc", ], - deps = [":tsc"], ) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out index fae96df82..3d59ac164 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out @@ -17,7 +17,6 @@ npm_package( "package.json", ":tsc", ], - deps = [":tsc"], ) ts_config( From 2b3c6ed761bb1d118288b45693fb800e1097972d Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 2 Oct 2024 09:31:27 -0700 Subject: [PATCH 06/23] refactor(cli): cleanup file type checks (#6966) Replacing the mix of constants with names and `is*` method names with only the methods. The one test change is essentially aligning with the default tsconfig value where tsx extensions are *not* preserved. --- ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases GitOrigin-RevId: 2fef14a6047d026f63abfa44c9612a1b040407ea --- gazelle/js/config.go | 21 ++----- gazelle/js/generate.go | 55 ++++++++++++------- .../tests/simple_file_exts/opt-ins/BUILD.out | 5 +- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/gazelle/js/config.go b/gazelle/js/config.go index 73384cabd..67c3e4966 100644 --- a/gazelle/js/config.go +++ b/gazelle/js/config.go @@ -11,7 +11,6 @@ import ( "github.com/bazelbuild/bazel-gazelle/label" "github.com/bmatcuk/doublestar/v4" "github.com/emirpasic/gods/maps/linkedhashmap" - "github.com/emirpasic/gods/sets/treeset" ) // Directives. Keep in sync with documentation in /docs/cli/help/directives.md @@ -113,32 +112,20 @@ var DefaultSourceGlobs = []*TargetGroup{ &TargetGroup{ name: DefaultLibraryName, customSources: []string{}, - defaultSources: []string{fmt.Sprintf("**/*.{%s}", strings.Join(typescriptFileExtensionsArray, ","))}, + defaultSources: []string{fmt.Sprintf("**/*.{%s}", strings.Join(defaultTypescriptFileExtensionsArray, ","))}, testonly: false, }, &TargetGroup{ name: DefaultTestsName, customSources: []string{}, - defaultSources: []string{fmt.Sprintf("**/*.{spec,test}.{%s}", strings.Join(typescriptFileExtensionsArray, ","))}, + defaultSources: []string{fmt.Sprintf("**/*.{spec,test}.{%s}", strings.Join(defaultTypescriptFileExtensionsArray, ","))}, testonly: true, }, } var ( - // Set of supported source file extensions. - typescriptFileExtensions = treeset.NewWithStringComparator("ts", "tsx", "mts", "cts") - - // Array of typescriptFileExtensions. - typescriptFileExtensionsArray = []string{"ts", "tsx", "mts", "cts"} - - // Importable declaration files that are not compiled - declarationFileExtensionsArray = []string{"d.ts", "d.mts", "d.cts"} - - // Supported javascript file extensions that can be sources along with dts files. - javascriptFileExtensions = treeset.NewWithStringComparator("js", "jsx", "cjs", "mjs") - - // Supported data file extensions that typescript can reference. - dataFileExtensions = treeset.NewWithStringComparator("json") + // Array of default typescript source file extensions + defaultTypescriptFileExtensionsArray = []string{"ts", "tsx", "mts", "cts"} // The default TypeScript config file name defaultTsconfigName = "tsconfig.json" diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index ee619489c..3be427c7a 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -742,8 +742,8 @@ func toImportPaths(p string) []string { if path.Base(stripDeclarationExtensions(p)) == IndexFileName { paths = append(paths, path.Dir(p)) } - } else if isSourceFileType(p) { - // The import with the file extension + } else if isTranspiledSourceFileType(p) { + // The import with the transpiled file extension paths = append(paths, swapSourceExtension(p)) // Without the extension if it is implicit @@ -751,6 +751,19 @@ func toImportPaths(p string) []string { paths = append(paths, stripSourceFileExtension(p)) } + // Directory without the filename + if path.Base(stripSourceFileExtension(p)) == IndexFileName { + paths = append(paths, path.Dir(p)) + } + } else if isSourceFileType(p) { + // The import of the raw file + paths = append(paths, p) + + // Without the extension if it is implicit + if isImplicitSourceFileType(p) { + paths = append(paths, stripSourceFileExtension(p)) + } + // Directory without the filename if path.Base(stripSourceFileExtension(p)) == IndexFileName { paths = append(paths, path.Dir(p)) @@ -826,44 +839,48 @@ func addLinkAllPackagesRule(cfg *JsGazelleConfig, args language.GenerateArgs, re // If the file is ts-compatible transpiled source code that may contain imports func isTranspiledSourceFileType(f string) bool { - ext := path.Ext(f) - return len(ext) > 0 && typescriptFileExtensions.Contains(ext[1:]) && !isDeclarationFileType(f) + switch path.Ext(f) { + case ".ts", ".cts", ".mts", ".tsx", ".jsx": + return !isDeclarationFileType(f) + default: + return false + } } // If the file is ts-compatible source code that may contain imports func isSourceFileType(f string) bool { - if isTranspiledSourceFileType(f) || isDeclarationFileType(f) { + switch path.Ext(f) { + case ".ts", ".cts", ".mts", ".tsx", ".jsx", ".js", ".cjs", ".mjs": return true + default: + return false } - - ext := path.Ext(f) - return len(ext) > 0 && javascriptFileExtensions.Contains(ext[1:]) } // A source file that does not explicitly declare itself as cjs or mjs so // it can be imported as if it is either. Node will decide how to interpret // it at runtime based on other factors. func isImplicitSourceFileType(f string) bool { - return path.Ext(f) == ".ts" || path.Ext(f) == ".tsx" || path.Ext(f) == ".js" || path.Ext(f) == ".jsx" + switch path.Ext(f) { + case ".ts", ".tsx", ".js", ".jsx": + return true + default: + return false + } } func isTsxFileType(f string) bool { - return path.Ext(f) == ".tsx" + return strings.HasSuffix(f, ".tsx") || strings.HasSuffix(f, ".jsx") } +// Importable declaration files that are not compiled func isDeclarationFileType(f string) bool { - for _, ex := range declarationFileExtensionsArray { - if strings.HasSuffix(f, "."+ex) { - return true - } - } - - return false + return strings.HasSuffix(f, ".d.ts") || strings.HasSuffix(f, ".d.mts") || strings.HasSuffix(f, ".d.cts") } +// Supported data file extensions that typescript can reference. func isDataFileType(f string) bool { - ext := path.Ext(f) - return len(ext) > 0 && dataFileExtensions.Contains(ext[1:]) + return strings.HasSuffix(f, ".json") } // Strip extensions off of a path, assuming it isSourceFileType() diff --git a/gazelle/js/tests/simple_file_exts/opt-ins/BUILD.out b/gazelle/js/tests/simple_file_exts/opt-ins/BUILD.out index ca42edb2d..c7fbabb31 100644 --- a/gazelle/js/tests/simple_file_exts/opt-ins/BUILD.out +++ b/gazelle/js/tests/simple_file_exts/opt-ins/BUILD.out @@ -1,4 +1,5 @@ load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") # gazelle:js_files **/*.{js,cjs,mjs,jsx} # gazelle:js_files m **/*.mjs @@ -7,7 +8,7 @@ load("@aspect_rules_js//js:defs.bzl", "js_library") # gazelle:js_test_files mtest **/*.spec.mjs # gazelle:js_test_files ctest **/*.spec.cjs -js_library( +ts_project( name = "opt-ins", srcs = [ "non-typed.js", @@ -16,7 +17,7 @@ js_library( ], ) -js_library( +ts_project( name = "opt-ins_tests", testonly = True, srcs = [ From ee4ee1a387c4a44194c3db85fe37650ec499d5f0 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 2 Oct 2024 16:40:56 -0700 Subject: [PATCH 07/23] fix(cli): tsconfig rootdir filtering of source files (#6978) tsconfig `rootDir` filtering is now essentially opt-in via a `${rootDir}` template in the source globs, with the default globs opting in to keep the default behaviour. This means we no longer have this confusion about sources being filtered due to `rootDir` even though we might not be setting `ts_project(tsconfig, root_dir)` or might even be using `js_library` when there is nothing to transpile. This also avoids `filepath.Rel` for every single file, avoids looping over the files multiple times (collect + filter + group), fetching the tsconfig for each file etc. --- ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases - New test cases added GitOrigin-RevId: b8e64fc0b5ba7d71fa7cba83d3d4c97510a5fc7c --- gazelle/js/config.go | 11 ++- gazelle/js/generate.go | 88 +++++++++---------- .../npm_package_deps/exports-ignore/BUILD.out | 1 - .../tests/npm_package_deps/main-js/BUILD.out | 1 - .../exports-ignore/BUILD.out | 5 +- .../npm_package_deps_lib/main-js/BUILD.out | 5 +- .../with_tsconfig/tsconfig.json | 3 +- gazelle/js/typescript/config.go | 17 ---- 8 files changed, 51 insertions(+), 80 deletions(-) diff --git a/gazelle/js/config.go b/gazelle/js/config.go index 67c3e4966..74bc7af56 100644 --- a/gazelle/js/config.go +++ b/gazelle/js/config.go @@ -112,18 +112,20 @@ var DefaultSourceGlobs = []*TargetGroup{ &TargetGroup{ name: DefaultLibraryName, customSources: []string{}, - defaultSources: []string{fmt.Sprintf("**/*.{%s}", strings.Join(defaultTypescriptFileExtensionsArray, ","))}, + defaultSources: []string{fmt.Sprintf("%s/**/*.{%s}", rootDirVar, strings.Join(defaultTypescriptFileExtensionsArray, ","))}, testonly: false, }, &TargetGroup{ name: DefaultTestsName, customSources: []string{}, - defaultSources: []string{fmt.Sprintf("**/*.{spec,test}.{%s}", strings.Join(defaultTypescriptFileExtensionsArray, ","))}, + defaultSources: []string{fmt.Sprintf("%s/**/*.{spec,test}.{%s}", rootDirVar, strings.Join(defaultTypescriptFileExtensionsArray, ","))}, testonly: true, }, } var ( + rootDirVar = "${rootDir}" + // Array of default typescript source file extensions defaultTypescriptFileExtensionsArray = []string{"ts", "tsx", "mts", "cts"} @@ -451,7 +453,7 @@ func (c *JsGazelleConfig) RenderSourceTargetName(groupName, packageName string, } // Determine if and which target the passed file belongs in. -func (c *JsGazelleConfig) GetFileSourceTarget(filePath string) *TargetGroup { +func (c *JsGazelleConfig) GetFileSourceTarget(filePath, rootDir string) *TargetGroup { // Rules are evaluated in reverse order, so we want to for i := len(c.targets) - 1; i >= 0; i-- { target := c.targets[i] @@ -462,7 +464,8 @@ func (c *JsGazelleConfig) GetFileSourceTarget(filePath string) *TargetGroup { sources = target.defaultSources } - for _, glob := range sources { + for _, globTmpl := range sources { + glob := path.Clean(strings.Replace(globTmpl, rootDirVar, rootDir, 1)) m, e := doublestar.Match(glob, filePath) if e != nil { log.Fatalf("Target (%s) glob error: %v", target.name, e) diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index 3be427c7a..e8ce5566c 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -5,7 +5,6 @@ import ( "math" "os" "path" - "path/filepath" "strings" "sync" @@ -82,32 +81,51 @@ func (ts *typeScriptLang) GenerateRules(args language.GenerateArgs) language.Gen } func (ts *typeScriptLang) addSourceRules(cfg *JsGazelleConfig, args language.GenerateArgs, result *language.GenerateResult) { - // Collect all source files. - sourceFiles, dataFiles, collectErr := ts.collectSourceFiles(cfg, args) - if collectErr != nil { - BazelLog.Errorf("Source collection error: %v\n", collectErr) - return - } + tsconfigRel, tsconfig := ts.tsconfig.FindConfig(args.Rel) // Create a set of source files per target. sourceFileGroups := treemap.NewWithStringComparator() for _, group := range cfg.GetSourceTargets() { sourceFileGroups.Put(group.name, treeset.NewWithStringComparator()) } + dataFiles := treeset.NewWithStringComparator() - // A src files into target groups (lib, test, ...custom). - for _, f := range sourceFiles.Values() { - // TODO: exclude files which are included in custom targets via #keep - - file := f.(string) - if target := cfg.GetFileSourceTarget(file); target != nil { - BazelLog.Tracef("add '%s' src '%s/%s'", target.name, args.Rel, file) + // Calculate the tsconfig rootDir relative to the current directory being walked + tsconfigRootDir := "." + if tsconfig != nil { + tsconfigRootDir = path.Join(tsconfigRel, tsconfig.RootDir) + + // Ignore rootDirs not within args.Rel + if args.Rel != "" && !strings.HasPrefix(tsconfigRootDir, args.Rel+"/") { + tsconfigRootDir = "." + } else if args.Rel != "" { + // Make the rootDir relative to the current directory being walked + tsconfigRootDir = tsconfigRootDir[len(args.Rel)+1:] + } + } - groupFiles, _ := sourceFileGroups.Get(target.name) - groupFiles.(*treeset.Set).Add(file) - } else { + // Collect all source files. + collectErr := gazelle.GazelleWalkDir(args, func(file string) error { + if isSourceFileType(file) { + if target := cfg.GetFileSourceTarget(file, tsconfigRootDir); target != nil { + BazelLog.Tracef("add '%s' src '%s/%s'", target.name, args.Rel, file) + + groupFiles, _ := sourceFileGroups.Get(target.name) + groupFiles.(*treeset.Set).Add(file) + return nil + } BazelLog.Tracef("Skip src '%s'", file) } + + // Not collect by any target group, but still collect as a data file. + if isDataFileType(file) { + dataFiles.Add(file) + } + return nil + }) + if collectErr != nil { + BazelLog.Errorf("Source collection error: %v\n", collectErr) + return } // Determine if this is a pnpm project and if a package target should be generated. @@ -149,6 +167,8 @@ func (ts *typeScriptLang) addSourceRules(cfg *JsGazelleConfig, args language.Gen // Add or edit/merge a rule for this source group. srcRule, srcGenErr := ts.addProjectRule( cfg, + tsconfigRel, + tsconfig, args, group, ruleName, @@ -178,11 +198,11 @@ func (ts *typeScriptLang) addSourceRules(cfg *JsGazelleConfig, args language.Gen } } - ts.addPackageRule(cfg, args, packageName, sourceFiles, dataFiles, srcLabel, result) + ts.addPackageRule(cfg, args, packageName, dataFiles, srcLabel, result) } } -func (ts *typeScriptLang) addPackageRule(cfg *JsGazelleConfig, args language.GenerateArgs, packageName string, sourceFiles, dataFiles *treeset.Set, srcLabel *label.Label, result *language.GenerateResult) { +func (ts *typeScriptLang) addPackageRule(cfg *JsGazelleConfig, args language.GenerateArgs, packageName string, dataFiles *treeset.Set, srcLabel *label.Label, result *language.GenerateResult) { npmPackageInfo := newTsPackageInfo(srcLabel) packageJsonPath := path.Join(args.Rel, NpmPackageFilename) @@ -196,7 +216,7 @@ func (ts *typeScriptLang) addPackageRule(cfg *JsGazelleConfig, args language.Gen continue } - if sourceFiles.Contains(impt) || dataFiles.Contains(impt) { + if dataFiles.Contains(impt) { npmPackageInfo.sources.Add(impt) } else { if strings.Contains(impt, "*") { @@ -362,7 +382,7 @@ func hasTranspiledSources(sourceFiles *treeset.Set) bool { return false } -func (ts *typeScriptLang) addProjectRule(cfg *JsGazelleConfig, args language.GenerateArgs, group *TargetGroup, targetName string, sourceFiles, dataFiles *treeset.Set, result *language.GenerateResult) (*rule.Rule, error) { +func (ts *typeScriptLang) addProjectRule(cfg *JsGazelleConfig, tsconfigRel string, tsconfig *typescript.TsConfig, args language.GenerateArgs, group *TargetGroup, targetName string, sourceFiles, dataFiles *treeset.Set, result *language.GenerateResult) (*rule.Rule, error) { // Check for name-collisions with the rule being generated. colError := gazelle.CheckCollisionErrors(targetName, TsProjectKind, sourceRuleKinds, args) if colError != nil { @@ -404,8 +424,6 @@ func (ts *typeScriptLang) addProjectRule(cfg *JsGazelleConfig, args language.Gen } } - tsconfigRel, tsconfig := ts.tsconfig.FindConfig(args.Rel) - // tsconfig 'jsx' options implying a dependency on react if tsconfig != nil && tsconfig.Jsx.IsReact() && info.HasTsx() { info.AddImport(ImportStatement{ @@ -673,30 +691,6 @@ func parseSourceFile(rootDir, filePath string) (parser.ParseResult, []error) { return parser.ParseSource(filePath, string(content)) } -func (ts *typeScriptLang) collectSourceFiles(cfg *JsGazelleConfig, args language.GenerateArgs) (*treeset.Set, *treeset.Set, error) { - sourceFiles := treeset.NewWithStringComparator() - dataFiles := treeset.NewWithStringComparator() - - err := gazelle.GazelleWalkDir(args, func(f string) error { - // Excluded due to being outside the ts root - if !ts.tsconfig.IsWithinTsRoot(f) { - BazelLog.Debugf("Skip %q outside rootDir\n", f) - return filepath.SkipDir - } - - // Otherwise the file is either source or potentially importable. - if isSourceFileType(f) { - sourceFiles.Add(f) - } else if isDataFileType(f) { - dataFiles.Add(f) - } - - return nil - }) - - return sourceFiles, dataFiles, err -} - func (ts *typeScriptLang) addFileLabel(importPath string, label *label.Label) { existing := ts.fileLabels[importPath] diff --git a/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out index 417933db2..1b24280c2 100644 --- a/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out @@ -14,7 +14,6 @@ js_library( npm_package( name = "pkg", srcs = [ - "lib1.js", "package.json", ":tsc", ], diff --git a/gazelle/js/tests/npm_package_deps/main-js/BUILD.out b/gazelle/js/tests/npm_package_deps/main-js/BUILD.out index b688769e5..3e1c38e6a 100644 --- a/gazelle/js/tests/npm_package_deps/main-js/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/main-js/BUILD.out @@ -13,7 +13,6 @@ npm_package( name = "pkg", srcs = [ "package.json", - "start.js", ":tsc", ], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out index e87eb62e6..2dcc51d13 100644 --- a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out @@ -12,9 +12,6 @@ js_library( js_library( name = "pkg", - srcs = [ - "lib1.js", - "package.json", - ], + srcs = ["package.json"], deps = [":tsc"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out index f48b74a4b..449c2132d 100644 --- a/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out @@ -10,9 +10,6 @@ js_library( js_library( name = "pkg", - srcs = [ - "package.json", - "start.js", - ], + srcs = ["package.json"], deps = [":tsc"], ) diff --git a/gazelle/js/tests/simple_dts_only/with_tsconfig/tsconfig.json b/gazelle/js/tests/simple_dts_only/with_tsconfig/tsconfig.json index 5ced9530f..c6f942195 100644 --- a/gazelle/js/tests/simple_dts_only/with_tsconfig/tsconfig.json +++ b/gazelle/js/tests/simple_dts_only/with_tsconfig/tsconfig.json @@ -4,7 +4,6 @@ "declarationMap": true, "sourceMap": true, "outDir": "dist", - "resolveJsonModule": true, - "rootDir": "src" + "resolveJsonModule": true } } diff --git a/gazelle/js/typescript/config.go b/gazelle/js/typescript/config.go index d23449731..8ec392b55 100644 --- a/gazelle/js/typescript/config.go +++ b/gazelle/js/typescript/config.go @@ -3,8 +3,6 @@ package typescript import ( "fmt" "path" - "path/filepath" - "strings" "sync" node "aspect.build/cli/gazelle/js/node" @@ -121,21 +119,6 @@ func (tc *TsWorkspace) FindConfig(dir string) (string, *TsConfig) { return "", nil } -func (tc *TsWorkspace) IsWithinTsRoot(f string) bool { - dir, c := tc.FindConfig(path.Dir(f)) - if c == nil { - return true - } - - if c.RootDir == "" { - return true - } - - rootRelative, relErr := filepath.Rel(path.Join(dir, c.RootDir), f) - - return relErr == nil && !strings.Contains(rootRelative, "..") -} - func (tc *TsWorkspace) ExpandPaths(from, f string) []string { _, c := tc.FindConfig(path.Dir(from)) if c == nil { From 7b5604095661da96591a36383d37d2cd24e788b7 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 2 Oct 2024 16:41:43 -0700 Subject: [PATCH 08/23] fix(cli): set npm_package(srcs) as mergeable gazelle attribute (#6984) I have not been able to reproduce this in a standalone test but this fixes an issue in a client repo. I think the fix makes sense, the `npm_package(srcs)` attribute may be set at generation time for source files, but package targets also have dependencies that must be resolved+merged at resolution time. Essentially doing `SetAttr("srcs")` at generation and resolution time. Normally the `srcs` and `deps` are separate attributes, but for `npm_package` they are the same which is why this is a bit unique. --- ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases - Manual testing; please provide instructions so we can reproduce: run on client repo GitOrigin-RevId: f316224b82d83d69f8858a74017f3e25f77f76bd --- gazelle/js/kinds.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gazelle/js/kinds.go b/gazelle/js/kinds.go index f78f9e94f..b53b00b1d 100644 --- a/gazelle/js/kinds.go +++ b/gazelle/js/kinds.go @@ -84,6 +84,9 @@ var tsKinds = map[string]rule.KindInfo{ MergeableAttrs: map[string]bool{ "srcs": true, }, + ResolveAttrs: map[string]bool{ + "srcs": true, + }, }, } From 536b648b5afbc2d4036fe094d4babef9235be089 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 2 Oct 2024 16:48:35 -0700 Subject: [PATCH 09/23] fix(cli): support direct import of outputted dts files (#6977) Things like package.json might import both the .d.ts and .js version of a file. Those can come from source .d.ts or .ts. --- ### Changes are visible to end-users: no ### Test plan - New test cases added GitOrigin-RevId: 500e11903f791b324a15c05ad2fca9a0a843a058 --- gazelle/js/generate.go | 31 ++++++++++++----- gazelle/js/generate_test.go | 30 ++++++++--------- .../npm_package_deps_tsconfig/pnpm-lock.yaml | 2 ++ .../scenario1/BUILD.in | 1 + .../scenario1/BUILD.out | 33 +++++++++++++++++++ .../scenario1/package.json | 9 +++++ .../scenario1/src/index.ts | 0 .../scenario1/src/types/index.ts | 0 .../scenario1/tsconfig.json | 12 +++++++ 9 files changed, 95 insertions(+), 23 deletions(-) create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/scenario1/package.json create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/scenario1/src/index.ts create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/scenario1/src/types/index.ts create mode 100644 gazelle/js/tests/npm_package_deps_tsconfig/scenario1/tsconfig.json diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index e8ce5566c..bb1d6e862 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -724,8 +724,12 @@ func toImportPaths(p string) []string { paths := make([]string, 0, 1) if isDeclarationFileType(p) { - // With the js extension - paths = append(paths, swapDeclarationExtension(p)) + // The import of the raw dts file + paths = append(paths, p) + + // Assume the js extension also exists + // TODO: don't do that + paths = append(paths, stripDeclarationExtensions(p)+toJsExt(p)) // Without the js extension if isImplicitSourceFileType(p) { @@ -737,8 +741,9 @@ func toImportPaths(p string) []string { paths = append(paths, path.Dir(p)) } } else if isTranspiledSourceFileType(p) { - // The import with the transpiled file extension + // The transpiled files extensions paths = append(paths, swapSourceExtension(p)) + paths = append(paths, stripSourceFileExtension(p)+toDtsExt(p)) // Without the extension if it is implicit if isImplicitSourceFileType(p) { @@ -892,11 +897,6 @@ func stripDeclarationExtensions(f string) string { return stripSourceFileExtension(stripSourceFileExtension(f)) } -// Swap compile to runtime extensions of of a path, assuming it isDeclarationFileType() -func swapDeclarationExtension(f string) string { - return stripDeclarationExtensions(f) + toJsExt(f) -} - func toJsExt(f string) string { e := path.Ext(f) switch e { @@ -916,6 +916,21 @@ func toJsExt(f string) string { } } +func toDtsExt(f string) string { + e := path.Ext(f) + switch e { + case ".ts", ".tsx": + return ".d.ts" + case ".cts": + return ".d.cts" + case ".mts": + return ".d.mts" + default: + BazelLog.Errorf("Unknown extension %q", e) + return ".d.ts" + } +} + // Normalize the given import statement from a relative path // to a path relative to the workspace. func toImportSpecPath(importFrom, importPath string) string { diff --git a/gazelle/js/generate_test.go b/gazelle/js/generate_test.go index 99ed919f3..a92577bd6 100644 --- a/gazelle/js/generate_test.go +++ b/gazelle/js/generate_test.go @@ -134,25 +134,25 @@ func TestGenerate(t *testing.T) { t.Run("toImportPaths", func(t *testing.T) { // Traditional [.d].ts[x] don't require an extension - assertImports(t, "bar.ts", []string{"bar", "bar.js"}) - assertImports(t, "bar.tsx", []string{"bar", "bar.js"}) - assertImports(t, "bar.d.ts", []string{"bar", "bar.js"}) - assertImports(t, "foo/bar.ts", []string{"foo/bar", "foo/bar.js"}) - assertImports(t, "foo/bar.tsx", []string{"foo/bar", "foo/bar.js"}) - assertImports(t, "foo/bar.d.ts", []string{"foo/bar", "foo/bar.js"}) + assertImports(t, "bar.ts", []string{"bar", "bar.d.ts", "bar.js"}) + assertImports(t, "bar.tsx", []string{"bar", "bar.d.ts", "bar.js"}) + assertImports(t, "bar.d.ts", []string{"bar", "bar.d.ts", "bar.js"}) + assertImports(t, "foo/bar.ts", []string{"foo/bar", "foo/bar.d.ts", "foo/bar.js"}) + assertImports(t, "foo/bar.tsx", []string{"foo/bar", "foo/bar.d.ts", "foo/bar.js"}) + assertImports(t, "foo/bar.d.ts", []string{"foo/bar", "foo/bar.d.ts", "foo/bar.js"}) // Traditional [.d].ts[x] index files - assertImports(t, "bar/index.ts", []string{"bar/index", "bar/index.js", "bar"}) - assertImports(t, "bar/index.d.ts", []string{"bar/index", "bar/index.js", "bar"}) - assertImports(t, "bar/index.tsx", []string{"bar/index", "bar/index.js", "bar"}) + assertImports(t, "bar/index.ts", []string{"bar/index", "bar/index.d.ts", "bar/index.js", "bar"}) + assertImports(t, "bar/index.d.ts", []string{"bar/index", "bar/index.d.ts", "bar/index.js", "bar"}) + assertImports(t, "bar/index.tsx", []string{"bar/index", "bar/index.d.ts", "bar/index.js", "bar"}) // .mjs and .cjs files require an extension - assertImports(t, "bar.mts", []string{"bar.mjs"}) - assertImports(t, "bar/index.mts", []string{"bar/index.mjs", "bar"}) - assertImports(t, "bar.d.mts", []string{"bar.mjs"}) - assertImports(t, "bar.cts", []string{"bar.cjs"}) - assertImports(t, "bar/index.cts", []string{"bar/index.cjs", "bar"}) - assertImports(t, "bar.d.cts", []string{"bar.cjs"}) + assertImports(t, "bar.mts", []string{"bar.mjs", "bar.d.mts"}) + assertImports(t, "bar/index.mts", []string{"bar/index.mjs", "bar/index.d.mts", "bar"}) + assertImports(t, "bar.d.mts", []string{"bar.d.mts", "bar.mjs"}) + assertImports(t, "bar.cts", []string{"bar.cjs", "bar.d.cts"}) + assertImports(t, "bar/index.cts", []string{"bar/index.cjs", "bar/index.d.cts", "bar"}) + assertImports(t, "bar.d.cts", []string{"bar.d.cts", "bar.cjs"}) }) } diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-lock.yaml b/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-lock.yaml index af01040db..b9f03b972 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-lock.yaml +++ b/gazelle/js/tests/npm_package_deps_tsconfig/pnpm-lock.yaml @@ -15,3 +15,5 @@ importers: main-custom_ts: {} main-inherit-tsconfig: {} + + scenario1: {} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.in b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.in new file mode 100644 index 000000000..21fe6afa7 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.in @@ -0,0 +1 @@ +# gazelle:js_package_rule_kind npm_package diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out new file mode 100644 index 000000000..bb4dff97f --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out @@ -0,0 +1,33 @@ +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project") +load("@npm//:defs.bzl", "npm_link_all_packages") + +# gazelle:js_package_rule_kind npm_package + +npm_link_all_packages(name = "node_modules") + +ts_project( + name = "tsc", + srcs = [ + "src/index.ts", + "src/types/index.ts", + ], + declaration = True, + declaration_map = True, + out_dir = "dist", + root_dir = "src", + tsconfig = ":tsconfig", +) + +npm_package( + name = "pkg", + srcs = [ + "package.json", + ":tsc", + ], +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", +) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/package.json b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/package.json new file mode 100644 index 000000000..3e4541329 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/package.json @@ -0,0 +1,9 @@ +{ + "name": "scenario1", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": "./dist/index.js", + "./types": "./dist/types/index.d.ts" + } +} diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/src/index.ts b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/src/index.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/src/types/index.ts b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/src/types/index.ts new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/tsconfig.json b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/tsconfig.json new file mode 100644 index 000000000..52db782bf --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "experimentalDecorators": true, + "rootDir": "src", + "outDir": "dist", + "isolatedModules": false, + "declaration": true, + "declarationMap": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules"] +} From 44c61691549e8029c45a795113b9d9947ee59dce Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Mon, 7 Oct 2024 06:41:07 -0700 Subject: [PATCH 10/23] feat: added --fixes flag to Aspect CLI lint command (#7015) Feature request from Figma where they have a custom eslint.bzl and requesting the patches results in two actions on CI. Also fixes flag registration so they are "no-able" to match expected behaviour of other flags: `--nofixes`, `--noreport`, etc... --- - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: yes New `--fixes` flag added to lint command in the the Aspect CLI which defaults to true. Users can now set `--nofixes` to turn off requesting the lint patch output group (`rules_lint_patch`). Requesting the report outputs groups (`rules_lint_human` and `rules_lint_machine`) is still controlled by the `--report` and `--machine` flags. - Covered by existing test cases - New test cases added GitOrigin-RevId: 8351b619b16979d089dd600db9065d8cd48f699d --- docs/aspect_lint.md | 7 ++-- integration_tests/aspect/lint_test.bats | 56 +++++++++++++++++++++++++ pkg/aspect/lint/lint.go | 22 +++++----- 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/docs/aspect_lint.md b/docs/aspect_lint.md index 1838c287c..257831a4f 100755 --- a/docs/aspect_lint.md +++ b/docs/aspect_lint.md @@ -22,10 +22,11 @@ aspect lint [flags] ``` --diff Show unified diff instead of diff stats for fixes - --fix Apply all patch fixes for lint violations + --fix Auto-apply all fixes + --fixes Request fixes from linters (where supported) (default true) -h, --help help for lint - --machine Request the machine readable output from linters - --report Output lint reports (default true) + --machine Request machine readable lint reports from linters (where supported) + --report Request lint reports from linters (default true) ``` ### Options inherited from parent commands diff --git a/integration_tests/aspect/lint_test.bats b/integration_tests/aspect/lint_test.bats index 6e437ccf2..0126fe569 100644 --- a/integration_tests/aspect/lint_test.bats +++ b/integration_tests/aspect/lint_test.bats @@ -40,8 +40,64 @@ EOF run aspect lint //:all assert_failure assert_output --partial "SC2068" + assert_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out" + assert_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out.exit_code" + assert_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.patch" run aspect lint //:all --@aspect_rules_lint//lint:fail_on_violation assert_failure assert_output --partial "SC2068" + # if bazel exits non-zero then outputs are not reported + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out.exit_code" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.patch" +} + +@test 'aspect lint should not output patch files if --nofixes flag is set' { + run aspect lint //:all --nofixes + assert_failure + assert_output --partial "SC2068" + assert_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out" + assert_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out.exit_code" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.patch" + + run aspect lint //:all --nofixes --@aspect_rules_lint//lint:fail_on_violation + assert_failure + assert_output --partial "SC2068" + # if bazel exits non-zero then outputs are not reported + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out.exit_code" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.patch" +} + +@test 'aspect lint should not output report files if --noreport flag is set' { + run aspect lint //:all --noreport + assert_success + refute_output --partial "SC2068" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out.exit_code" + assert_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.patch" + + run aspect lint //:all --noreport --@aspect_rules_lint//lint:fail_on_violation + assert_success + refute_output --partial "SC2068" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out.exit_code" + assert_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.patch" +} + +@test 'aspect lint should always pass if --nofixes and --noreport flags are both set' { + run aspect lint //:all --nofixes --noreport + assert_success + refute_output --partial "SC2068" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out.exit_code" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.patch" + + run aspect lint //:all --nofixes --noreport --@aspect_rules_lint//lint:fail_on_violation + assert_success + refute_output --partial "SC2068" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.out.exit_code" + refute_output --partial "bazel-bin/shell.AspectRulesLintShellCheck.patch" } diff --git a/pkg/aspect/lint/lint.go b/pkg/aspect/lint/lint.go index 705e6f9fe..0af8e5416 100644 --- a/pkg/aspect/lint/lint.go +++ b/pkg/aspect/lint/lint.go @@ -82,11 +82,12 @@ func New( } } -func AddFlags(flags *pflag.FlagSet) { - flags.Bool("fix", false, "Apply all patch fixes for lint violations") - flags.Bool("diff", false, "Show unified diff instead of diff stats for fixes") - flags.Bool("report", true, "Output lint reports") - flags.Bool("machine", false, "Request the machine readable output from linters") +func AddFlags(flagSet *pflag.FlagSet) { + flags.RegisterNoableBoolP(flagSet, "fix", "", false, "Auto-apply all fixes") + flags.RegisterNoableBoolP(flagSet, "diff", "", false, "Show unified diff instead of diff stats for fixes") + flags.RegisterNoableBoolP(flagSet, "fixes", "", true, "Request fixes from linters (where supported)") + flags.RegisterNoableBoolP(flagSet, "report", "", true, "Request lint reports from linters") + flags.RegisterNoableBoolP(flagSet, "machine", "", false, "Request machine readable lint reports from linters (where supported)") } // TODO: hoist this to a flags package so it can be used by other commands that require this functionality @@ -159,8 +160,9 @@ lint: // Get values of lint command specific flags applyAll, _ := cmd.Flags().GetBool("fix") showDiff, _ := cmd.Flags().GetBool("diff") - printReport, _ := cmd.Flags().GetBool("report") - machine, _ := cmd.Flags().GetBool("machine") + requestFixes, _ := cmd.Flags().GetBool("fixes") + requestReports, _ := cmd.Flags().GetBool("report") + machineReports, _ := cmd.Flags().GetBool("machine") // Separate out the lint command specific flags from the list of args to // pass to `bazel build` @@ -181,12 +183,12 @@ lint: // Don't request report and patch files in a mode where we don't need them outputGroups := []string{} - if printReport || applyAll || isInteractiveMode { + if requestFixes || applyAll { bazelCmd = append(bazelCmd, "--@aspect_rules_lint//lint:fix") outputGroups = append(outputGroups, LINT_PATCH_GROUP) } - if printReport { - if machine { + if requestReports { + if machineReports { outputGroups = append(outputGroups, LINT_REPORT_GROUP_MACHINE) } else { outputGroups = append(outputGroups, LINT_REPORT_GROUP_HUMAN) From 334da8f3831e937b2c06dd1795e72cb29664c0a8 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Mon, 7 Oct 2024 16:04:04 -0700 Subject: [PATCH 11/23] refactor(cli): upgrade tree-sitter grammars (#7028) Close https://github.com/aspect-build/aspect-cli/issues/530 ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases GitOrigin-RevId: 91c1f483e9b74b668ac7690d52e543bb039f09ac --- .../common/treesitter/grammars/grammars.bzl | 28 +++++++++---------- gazelle/kotlin/parser/parser.go | 7 +++-- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gazelle/common/treesitter/grammars/grammars.bzl b/gazelle/common/treesitter/grammars/grammars.bzl index 9ed433267..4fb771586 100644 --- a/gazelle/common/treesitter/grammars/grammars.bzl +++ b/gazelle/common/treesitter/grammars/grammars.bzl @@ -7,9 +7,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def fetch_grammars(): http_archive( name = "tree-sitter-json", - sha256 = "83d89d297c475dceb1865a9eacd8da1008e1aecffb6137161361107665cbdf79", - strip_prefix = "tree-sitter-json-0.21.0", - urls = ["https://github.com/tree-sitter/tree-sitter-json/archive/v0.21.0.tar.gz"], + sha256 = "ecde752640fb6eedd25b63647f016f92b3b63096d08f60742cbf19395c5c6036", + strip_prefix = "tree-sitter-json-0.23.0", + urls = ["https://github.com/tree-sitter/tree-sitter-json/archive/v0.23.0.tar.gz"], build_file_content = """ filegroup( name = "srcs", @@ -21,9 +21,9 @@ filegroup( http_archive( name = "tree-sitter-kotlin", - sha256 = "f8d6f766ff2da1bd411e6d55f4394abbeab808163d5ea6df9daa75ad48eb0834", - strip_prefix = "tree-sitter-kotlin-0.3.5", - urls = ["https://github.com/fwcd/tree-sitter-kotlin/archive/0.3.5.tar.gz"], + sha256 = "7dd60975786bf9cb4be6a5176f5ccb5fed505f9929a012da30762505b1015669", + strip_prefix = "tree-sitter-kotlin-0.3.8", + urls = ["https://github.com/fwcd/tree-sitter-kotlin/archive/0.3.8.tar.gz"], build_file_content = """ filegroup( name = "srcs", @@ -35,9 +35,9 @@ filegroup( http_archive( name = "tree-sitter-starlark", - integrity = "sha256-obJ54UOlqTfd1EInZNkV8ju0CFNh3gmULTvVdJ7uPKU=", - strip_prefix = "tree-sitter-starlark-1.0.0", - urls = ["https://github.com/tree-sitter-grammars/tree-sitter-starlark/archive/v1.0.0.tar.gz"], + integrity = "sha256-STb+4buXAstpVLGTDqwTPCzxzEDz3n1EpqPXdtI7IWw=", + strip_prefix = "tree-sitter-starlark-1.2.0", + urls = ["https://github.com/tree-sitter-grammars/tree-sitter-starlark/archive/v1.2.0.tar.gz"], build_file_content = """ filegroup( name = "srcs", @@ -49,18 +49,18 @@ filegroup( http_archive( name = "tree-sitter-typescript", - sha256 = "fb95a7a78268b3c0aeca86cc376681f1f4f9a1ae97b9bd8167c633bfd41398c6", - strip_prefix = "tree-sitter-typescript-0.20.6", - urls = ["https://github.com/tree-sitter/tree-sitter-typescript/archive/v0.20.6.tar.gz"], + sha256 = "af500e16060b0221db8fb0743a37ca677340f8024127b54f6b6fc1ebfde496f4", + strip_prefix = "tree-sitter-typescript-0.23.0", + urls = ["https://github.com/tree-sitter/tree-sitter-typescript/archive/v0.23.0.tar.gz"], build_file_content = """ filegroup( name = "typescript-srcs", - srcs = glob(["**/*.c", "**/*.h"], exclude=["tsx/**"]), + srcs = glob(["common/**/*.h", "typescript/src/**/*.h", "typescript/src/**/*.c"]), visibility = ["//visibility:public"], ) filegroup( name = "tsx-srcs", - srcs = glob(["**/*.c", "**/*.h"], exclude=["typescript/**"]), + srcs = glob(["common/**/*.h", "tsx/src/**/*.h", "tsx/src/**/*.c"]), visibility = ["//visibility:public"], ) """, diff --git a/gazelle/kotlin/parser/parser.go b/gazelle/kotlin/parser/parser.go index a5b09ca70..98721158a 100644 --- a/gazelle/kotlin/parser/parser.go +++ b/gazelle/kotlin/parser/parser.go @@ -61,14 +61,17 @@ func (p *treeSitterParser) Parse(filePath, source string) (*ParseResult, []error nodeK := nodeJ.Child(k) if nodeK.Type() == "identifier" { isStar := false - for l := k + 1; l < int(nodeJ.ChildCount()); l++ { - if nodeJ.Child(l).Type() == ".*" { + for l := int(nodeJ.ChildCount()) - 1; l > k; l-- { + if nodeJ.Child(l).Type() == "wildcard_import" { isStar = true break } } result.Imports = append(result.Imports, readIdentifier(nodeK, sourceCode, !isStar)) + + // Any remaining nodes within nodeJ are comments or wildcards + break } } } From 6ea2ae75209b066b5cdcb7b230b630a63fbe9de7 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Tue, 8 Oct 2024 16:30:11 -0700 Subject: [PATCH 12/23] fix(cli): treat package.json imports as optional dependencies (#7044) There are too many edge cases that are causing issues atm. This should have been optional or opt-in from the start. This makes these imports "optional", so the feature is still enabled by default and users upgrading the cli will get this new feature, but it should no longer ever cause errors. We can maybe change it to error when opted-in in the future and maybe change the default if we are more certain it handles most of the edge cases. --- ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): yes - Suggested release notes appear below: yes Dependencies from package.json `main/types/exports` fields no longer cause errors when `aspect configure` can not resolve the referenced files. ### Test plan - New test cases added GitOrigin-RevId: 3199133ffd87902ab1906811d5383bb0de56b299 --- gazelle/js/generate.go | 5 ++++- gazelle/js/resolve.go | 4 +++- gazelle/js/target.go | 3 +++ .../npm_package_deps_lib/exports-ignore/package.json | 1 + .../js/tests/npm_package_deps_lib/not-found/BUILD.in | 1 + .../js/tests/npm_package_deps_lib/not-found/BUILD.out | 8 ++++++++ .../tests/npm_package_deps_lib/not-found/package.json | 10 ++++++++++ .../tests/npm_package_deps_lib/not-found/src/main.ts | 0 8 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 gazelle/js/tests/npm_package_deps_lib/not-found/BUILD.in create mode 100644 gazelle/js/tests/npm_package_deps_lib/not-found/BUILD.out create mode 100644 gazelle/js/tests/npm_package_deps_lib/not-found/package.json create mode 100644 gazelle/js/tests/npm_package_deps_lib/not-found/src/main.ts diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index bb1d6e862..93598d165 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -220,7 +220,7 @@ func (ts *typeScriptLang) addPackageRule(cfg *JsGazelleConfig, args language.Gen npmPackageInfo.sources.Add(impt) } else { if strings.Contains(impt, "*") { - BazelLog.Warnf("Wildcard import %q in %q not supported", impt, packageJsonPath) + BazelLog.Debugf("Wildcard import %q in %q not supported", impt, packageJsonPath) continue } @@ -231,6 +231,9 @@ func (ts *typeScriptLang) addPackageRule(cfg *JsGazelleConfig, args language.Gen }, ImportPath: impt, SourcePath: packageJsonPath, + + // Set as optional while package.json imports are experimental + Optional: true, }) } } diff --git a/gazelle/js/resolve.go b/gazelle/js/resolve.go index a40190a34..645fc0804 100644 --- a/gazelle/js/resolve.go +++ b/gazelle/js/resolve.go @@ -305,7 +305,9 @@ func (ts *typeScriptLang) resolveImports( // Neither the import or a type definition was found. if resolutionType == Resolution_NotFound && len(types) == 0 { - if cfg.ValidateImportStatements() != ValidationOff { + if imp.Optional { + BazelLog.Infof("Optional import %q for target %q not found", imp.ImportPath, from.String()) + } else if cfg.ValidateImportStatements() != ValidationOff { BazelLog.Debugf("import %q for target %q not found", imp.ImportPath, from.String()) notFound := fmt.Errorf( diff --git a/gazelle/js/target.go b/gazelle/js/target.go index 904063132..cf768c542 100644 --- a/gazelle/js/target.go +++ b/gazelle/js/target.go @@ -21,6 +21,9 @@ type ImportStatement struct { // The path as written in the import statement ImportPath string + + // If the import is optional and failure to resolve should not be an error + Optional bool } // Npm link-all rule import data diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/package.json b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/package.json index acdcfbc78..4d074a203 100644 --- a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/package.json +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/package.json @@ -7,6 +7,7 @@ }, "./bin": "./bin/does-not-exist.js", "./dne": "./does-not-exist.js", + "./not-ignored-dne": "./not-ignored.js", "./lib": "./lib1.js" } } diff --git a/gazelle/js/tests/npm_package_deps_lib/not-found/BUILD.in b/gazelle/js/tests/npm_package_deps_lib/not-found/BUILD.in new file mode 100644 index 000000000..066d7e736 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/not-found/BUILD.in @@ -0,0 +1 @@ +# gazelle:generation_mode update diff --git a/gazelle/js/tests/npm_package_deps_lib/not-found/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/not-found/BUILD.out new file mode 100644 index 000000000..c245e1e88 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/not-found/BUILD.out @@ -0,0 +1,8 @@ +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") + +# gazelle:generation_mode update + +ts_project( + name = "tsc", + srcs = ["src/main.ts"], +) diff --git a/gazelle/js/tests/npm_package_deps_lib/not-found/package.json b/gazelle/js/tests/npm_package_deps_lib/not-found/package.json new file mode 100644 index 000000000..a7c940ec9 --- /dev/null +++ b/gazelle/js/tests/npm_package_deps_lib/not-found/package.json @@ -0,0 +1,10 @@ +{ + "name": "pkg-with-exports", + "private": true, + "main": "./not-found.js", + "types": "./not-found.d.ts", + "exports": { + ".": "./dist/main.js", + "./foo": "./not-found.js" + } +} diff --git a/gazelle/js/tests/npm_package_deps_lib/not-found/src/main.ts b/gazelle/js/tests/npm_package_deps_lib/not-found/src/main.ts new file mode 100644 index 000000000..e69de29bb From b598099ead7133449a60c512c51c6ea8058c8a4e Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 9 Oct 2024 14:18:55 -0700 Subject: [PATCH 13/23] refactor(cli): remove unnecessary log statement (#6983) This no longer provides any useful information now that gazelle is patched to walk subdirectories instead of us doing it manually here. --- ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases GitOrigin-RevId: 8cdd9e60d027f509099508b0e0b0a085afc0772d --- gazelle/common/walk.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gazelle/common/walk.go b/gazelle/common/walk.go index c1555dcaf..ae1d83305 100644 --- a/gazelle/common/walk.go +++ b/gazelle/common/walk.go @@ -1,8 +1,6 @@ package gazelle import ( - "path/filepath" - BazelLog "aspect.build/cli/pkg/logger" "github.com/bazelbuild/bazel-gazelle/language" ) @@ -24,10 +22,7 @@ func GazelleWalkDir(args language.GenerateArgs, walkFunc GazelleWalkFunc) error continue } - BazelLog.Tracef("GazelleWalkDir RegularFile: %s", f) - - walkErr := walkFunc(f) - if walkErr != nil && walkErr != filepath.SkipDir { + if walkErr := walkFunc(f); walkErr != nil { return walkErr } } From ac8855ae4a0eb85f320a417349dac0929460a503 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 9 Oct 2024 14:28:04 -0700 Subject: [PATCH 14/23] test(cli): gazelle triple slash test cases (#7057) Various test cases trying to reproduce a customer issue. --- ### Changes are visible to end-users: no ### Test plan - New test cases added GitOrigin-RevId: 0e04447116b665e83d89a0e91b9931631f5e44f4 --- gazelle/js/parser/parser.go | 4 ++-- .../tests/npm_types_package/only_types/BUILD.out | 7 +++---- .../js/tests/npm_types_package/only_types/only.ts | 1 - .../tests/npm_types_package/only_types/types.d.ts | 1 + .../tests/npm_types_package/transpiled/BUILD.out | 6 ++++++ .../tests/npm_types_package/transpiled/types.ts | 1 + .../npm_types_package/triple_slash/BUILD.out | 6 +++++- .../npm_types_package/triple_slash/defs.d.ts | 1 + .../tests/npm_types_package/triple_slash/ref.ts | 14 +++++++++++++- .../triple_slash_syntaxes/BUILD.in | 0 .../triple_slash_syntaxes/BUILD.out | 11 +++++++++++ .../triple_slash_syntaxes/ref.ts | 15 +++++++++++++++ 12 files changed, 58 insertions(+), 9 deletions(-) delete mode 100644 gazelle/js/tests/npm_types_package/only_types/only.ts create mode 100644 gazelle/js/tests/npm_types_package/only_types/types.d.ts create mode 100644 gazelle/js/tests/npm_types_package/transpiled/BUILD.out create mode 100644 gazelle/js/tests/npm_types_package/transpiled/types.ts create mode 100644 gazelle/js/tests/npm_types_package/triple_slash/defs.d.ts create mode 100644 gazelle/js/tests/npm_types_package/triple_slash_syntaxes/BUILD.in create mode 100644 gazelle/js/tests/npm_types_package/triple_slash_syntaxes/BUILD.out create mode 100644 gazelle/js/tests/npm_types_package/triple_slash_syntaxes/ref.ts diff --git a/gazelle/js/parser/parser.go b/gazelle/js/parser/parser.go index 91f7f2446..5874c363c 100644 --- a/gazelle/js/parser/parser.go +++ b/gazelle/js/parser/parser.go @@ -156,12 +156,12 @@ func isTripleSlashDirective(node *sitter.Node, sourceCode []byte) bool { comment := node.Content(sourceCode) - return strings.HasPrefix(comment, "/// from a comment node // Note: could also potentially use a treesitter query such as: -// / `(program (comment) @result (#match? @c "^///\\s* /// -/// +// Transpiled .ts files, referenced both with and without the .d.ts extension. +// IDEs flag this as an error that should be a regular `import` but this is still valid. +/// +/// + +// ... same with .d.ts source files. +/// +/// + +// ... same with source files with the same BUILD. +/// +/// diff --git a/gazelle/js/tests/npm_types_package/triple_slash_syntaxes/BUILD.in b/gazelle/js/tests/npm_types_package/triple_slash_syntaxes/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/npm_types_package/triple_slash_syntaxes/BUILD.out b/gazelle/js/tests/npm_types_package/triple_slash_syntaxes/BUILD.out new file mode 100644 index 000000000..dd40583e5 --- /dev/null +++ b/gazelle/js/tests/npm_types_package/triple_slash_syntaxes/BUILD.out @@ -0,0 +1,11 @@ +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") + +ts_project( + name = "triple_slash_syntaxes", + srcs = ["ref.ts"], + deps = [ + "//:node_modules/@types/jquery", + "//:node_modules/@types/testing-library__jest-dom", + "//:node_modules/jquery", + ], +) diff --git a/gazelle/js/tests/npm_types_package/triple_slash_syntaxes/ref.ts b/gazelle/js/tests/npm_types_package/triple_slash_syntaxes/ref.ts new file mode 100644 index 000000000..4aadb8ba0 --- /dev/null +++ b/gazelle/js/tests/npm_types_package/triple_slash_syntaxes/ref.ts @@ -0,0 +1,15 @@ +// triple-slash references with various odd syntaxes/spacing + +// No space +/// + +// Random extra spaces +/// + + +// Random similar but invalid syntax +/// +///foo +/// +/// +/// From bc22bf57c7514284bc67594314d575aac7d21b6e Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 9 Oct 2024 14:28:31 -0700 Subject: [PATCH 15/23] test(cli): data files in non-generated BUILD files (#7058) Various test cases trying to reproduce a customer issue. --- ### Changes are visible to end-users: no ### Test plan - New test cases added GitOrigin-RevId: 382be45c9eaaac2578d8a85cc7df89a4f564a3f1 --- .../js/tests/simple_import_disabled/BUILD.out | 5 ++++- .../simple_import_disabled/disabled/BUILD.in | 19 +++++++++++++++++++ .../simple_import_disabled/disabled/BUILD.out | 19 +++++++++++++++++++ .../disabled/data/a.yaml | 0 .../disabled/data/b.yaml | 0 .../disabled/data/c.json | 0 .../js/tests/simple_import_disabled/main.ts | 3 ++- 7 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 gazelle/js/tests/simple_import_disabled/disabled/data/a.yaml create mode 100644 gazelle/js/tests/simple_import_disabled/disabled/data/b.yaml create mode 100644 gazelle/js/tests/simple_import_disabled/disabled/data/c.json diff --git a/gazelle/js/tests/simple_import_disabled/BUILD.out b/gazelle/js/tests/simple_import_disabled/BUILD.out index 4cb55bee9..bd74c7f17 100644 --- a/gazelle/js/tests/simple_import_disabled/BUILD.out +++ b/gazelle/js/tests/simple_import_disabled/BUILD.out @@ -3,5 +3,8 @@ load("@aspect_rules_ts//ts:defs.bzl", "ts_project") ts_project( name = "simple_import_disabled", srcs = ["main.ts"], - deps = ["//disabled:lib"], + deps = [ + "//disabled:data", + "//disabled:lib", + ], ) diff --git a/gazelle/js/tests/simple_import_disabled/disabled/BUILD.in b/gazelle/js/tests/simple_import_disabled/disabled/BUILD.in index 0fee80395..c755df0f2 100644 --- a/gazelle/js/tests/simple_import_disabled/disabled/BUILD.in +++ b/gazelle/js/tests/simple_import_disabled/disabled/BUILD.in @@ -1,8 +1,27 @@ #gazelle:js disabled +load("@aspect_rules_js//js:defs.bzl", "js_library") load("@aspect_rules_ts//ts:defs.bzl", "ts_project") ts_project( name = "lib", srcs = glob(["**/*.ts"]), ) + +js_library( + name = "unknown-data-types", + srcs = glob(["**/*.yaml"]), +) + +js_library( + name = "empty-glob", + srcs = glob( + ["**/*.does-not-exist"], + allow_empty = True, + ), +) + +js_library( + name = "data", + srcs = glob(["data/*.json"]), +) diff --git a/gazelle/js/tests/simple_import_disabled/disabled/BUILD.out b/gazelle/js/tests/simple_import_disabled/disabled/BUILD.out index 0fee80395..c755df0f2 100644 --- a/gazelle/js/tests/simple_import_disabled/disabled/BUILD.out +++ b/gazelle/js/tests/simple_import_disabled/disabled/BUILD.out @@ -1,8 +1,27 @@ #gazelle:js disabled +load("@aspect_rules_js//js:defs.bzl", "js_library") load("@aspect_rules_ts//ts:defs.bzl", "ts_project") ts_project( name = "lib", srcs = glob(["**/*.ts"]), ) + +js_library( + name = "unknown-data-types", + srcs = glob(["**/*.yaml"]), +) + +js_library( + name = "empty-glob", + srcs = glob( + ["**/*.does-not-exist"], + allow_empty = True, + ), +) + +js_library( + name = "data", + srcs = glob(["data/*.json"]), +) diff --git a/gazelle/js/tests/simple_import_disabled/disabled/data/a.yaml b/gazelle/js/tests/simple_import_disabled/disabled/data/a.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/simple_import_disabled/disabled/data/b.yaml b/gazelle/js/tests/simple_import_disabled/disabled/data/b.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/simple_import_disabled/disabled/data/c.json b/gazelle/js/tests/simple_import_disabled/disabled/data/c.json new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/js/tests/simple_import_disabled/main.ts b/gazelle/js/tests/simple_import_disabled/main.ts index 0284f20b3..01fdc84e8 100644 --- a/gazelle/js/tests/simple_import_disabled/main.ts +++ b/gazelle/js/tests/simple_import_disabled/main.ts @@ -1,4 +1,5 @@ import * as a from './disabled/a'; import * as b from './disabled/sub1/b'; +import c from './disabled/data/c.json' -console.log(a, b); +console.log(a, b, c); From 7731bb1cd8f4c43700600e8dc10557fd2ce741aa Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 9 Oct 2024 14:29:58 -0700 Subject: [PATCH 16/23] fix(cli): show correct paths in orion error stack traces (#7034) ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases GitOrigin-RevId: 8f231d868477f4970ec9261edac355f3c157b0b5 --- gazelle/common/starlark/utils/err.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gazelle/common/starlark/utils/err.go b/gazelle/common/starlark/utils/err.go index 5f57f04cf..ac44aeb3a 100644 --- a/gazelle/common/starlark/utils/err.go +++ b/gazelle/common/starlark/utils/err.go @@ -42,7 +42,9 @@ func evalCallbackString(stack starlark.CallStack) string { fmt.Fprintf(out, "Traceback (most recent call last):\n") } for _, fr := range stack { - fmt.Fprintf(out, " %s: in %s\n", strings.TrimLeft(fr.Pos.String(), strip), fr.Name) + p := strings.TrimPrefix(fr.Pos.String(), strip) + p = strings.Trim(p, " \n\r\t/\\") + fmt.Fprintf(out, " %s: in %s\n", p, fr.Name) } return out.String() } From 97eba351d68131d212474e03e14eda5b71105c4d Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 9 Oct 2024 17:43:52 -0700 Subject: [PATCH 17/23] fix(cli): reduce tsconfig paths precedence below pnpm workspace project deps (#7060) An issue found at a client when upgrading from an ancient cli version to more recent. This changes the order of how dependencies can be resolved, reducing the precedence of tsconfig paths to be one of the lowest priorities instead of being on-par with relative file imports. The client use case and the test case added is when a tsconfig file has `paths` essentially just for the IDE dev experience or maybe for legacy non-bazel (or non-pnpm-workspace) reasons. Imports of local workspace projects should use `:node_modules/@wksp/project-a` via package.json instead of `//projects/a` vis tsconfig.json. --- ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: yes Pnpm workspace project dependencies resolved with `aspect configure` are now higher priority then resolving dependencies via tsconfig paths. ### Test plan - Covered by existing test cases - New test cases added GitOrigin-RevId: 7cf0f95489f5600001351d36a7f13500bc465b62 --- gazelle/js/generate.go | 36 +++---- gazelle/js/resolve.go | 94 ++++++++++++------- gazelle/js/target.go | 3 - gazelle/js/tests/pnpm_workspace/tsconfig.json | 10 ++ 4 files changed, 84 insertions(+), 59 deletions(-) create mode 100644 gazelle/js/tests/pnpm_workspace/tsconfig.json diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index 93598d165..f557a954e 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -589,7 +589,6 @@ func (ts *typeScriptLang) collectProtoImports(cfg *JsGazelleConfig, args languag Lang: LanguageName, Imp: dts, }, - Alt: []string{}, ImportPath: imp, SourcePath: sourceFile, }) @@ -653,30 +652,25 @@ func (ts *typeScriptLang) collectImports(cfg *JsGazelleConfig, rootDir, sourcePa } for _, importPath := range parseResults.Imports { + if cfg.IsImportIgnored(importPath) { + BazelLog.Tracef("Import ignored: %q", importPath) + continue + } + // The path from the root workspacePath := toImportSpecPath(sourcePath, importPath) - if !cfg.IsImportIgnored(importPath) { - alternates := make([]string, 0) - for _, alt := range ts.tsconfig.ExpandPaths(sourcePath, importPath) { - alternates = append(alternates, toImportSpecPath(sourcePath, alt)) - } - - // Record all imports. Maybe local, maybe data, maybe in other BUILD etc. - result.Imports = append(result.Imports, ImportStatement{ - ImportSpec: resolve.ImportSpec{ - Lang: LanguageName, - Imp: workspacePath, - }, - Alt: alternates, - ImportPath: importPath, - SourcePath: sourcePath, - }) + // Record all imports. Maybe local, maybe data, maybe in other BUILD etc. + result.Imports = append(result.Imports, ImportStatement{ + ImportSpec: resolve.ImportSpec{ + Lang: LanguageName, + Imp: workspacePath, + }, + ImportPath: importPath, + SourcePath: sourcePath, + }) - BazelLog.Tracef("Import: %q -> %q (alt: %v)", workspacePath, importPath, alternates) - } else { - BazelLog.Tracef("Import ignored: %q -> %q", workspacePath, importPath) - } + BazelLog.Tracef("Import: %q -> %q (via %q)", sourcePath, workspacePath, importPath) } return result diff --git a/gazelle/js/resolve.go b/gazelle/js/resolve.go index 645fc0804..047c89f43 100644 --- a/gazelle/js/resolve.go +++ b/gazelle/js/resolve.go @@ -366,41 +366,9 @@ func (ts *typeScriptLang) resolveImport( return Resolution_Override, res, nil } - possible := make([]resolve.ImportSpec, 0, 1) - possible = append(possible, impStm.ImportSpec) - for _, expandedImp := range impStm.Alt { - possible = append(possible, resolve.ImportSpec{Lang: impStm.Lang, Imp: expandedImp}) - } - - // Gazelle rule index. Try each potential expanded path - for _, eImp := range possible { - if matches := ix.FindRulesByImportWithConfig(c, eImp, LanguageName); len(matches) > 0 { - filteredMatches := make([]label.Label, 0, len(matches)) - for _, match := range matches { - // Prevent from adding itself as a dependency. - if !match.IsSelfImport(from) { - filteredMatches = append(filteredMatches, match.Label) - } - } - - // Too many results, don't know which is correct - if len(filteredMatches) > 1 { - return Resolution_Error, nil, fmt.Errorf( - "Import %q from %q resolved to multiple targets (%s) - this must be fixed using the \"gazelle:resolve\" directive", - impStm.ImportPath, impStm.SourcePath, targetListFromResults(matches)) - } - - // The matches were self imports, no dependency is needed - if len(filteredMatches) == 0 { - return Resolution_None, nil, nil - } - - match := filteredMatches[0] - - BazelLog.Tracef("resolve %q import %q as %q", from, impStm.Imp, match) - - return Resolution_Override, &match, nil - } + // Gazelle rule index + if resolution, match, err := ts.resolveImportFromIndex(c, ix, from, impStm); resolution != Resolution_NotFound { + return resolution, match, err } // References to a label such as a file or file-generating rule @@ -413,6 +381,24 @@ func (ts *typeScriptLang) resolveImport( return Resolution_Package, pkg, nil } + // References via tsconfig mappings (paths, baseUrl, rootDirs etc.) + if tsconfigPaths := ts.tsconfig.ExpandPaths(impStm.SourcePath, impStm.ImportPath); len(tsconfigPaths) > 0 { + for _, p := range tsconfigPaths { + pImp := ImportStatement{ + ImportSpec: resolve.ImportSpec{ + Lang: impStm.ImportSpec.Lang, + Imp: toImportSpecPath(impStm.SourcePath, p), + }, + SourcePath: impStm.SourcePath, + ImportPath: impStm.ImportPath, + Optional: impStm.Optional, + } + if resolution, match, err := ts.resolveImportFromIndex(c, ix, from, pImp); resolution != Resolution_NotFound { + return resolution, match, err + } + } + } + // Native node imports if node.IsNodeImport(imp.Imp) { return Resolution_NativeNode, nil, nil @@ -421,6 +407,44 @@ func (ts *typeScriptLang) resolveImport( return Resolution_NotFound, nil, nil } +func (ts *typeScriptLang) resolveImportFromIndex( + c *config.Config, + ix *resolve.RuleIndex, + from label.Label, + impStm ImportStatement) (ResolutionType, *label.Label, error) { + + matches := ix.FindRulesByImportWithConfig(c, impStm.ImportSpec, LanguageName) + if len(matches) == 0 { + return Resolution_NotFound, nil, nil + } + + filteredMatches := make([]label.Label, 0, len(matches)) + for _, match := range matches { + // Prevent from adding itself as a dependency. + if !match.IsSelfImport(from) { + filteredMatches = append(filteredMatches, match.Label) + } + } + + // Too many results, don't know which is correct + if len(filteredMatches) > 1 { + return Resolution_Error, nil, fmt.Errorf( + "Import %q from %q resolved to multiple targets (%s) - this must be fixed using the \"gazelle:resolve\" directive", + impStm.ImportPath, impStm.SourcePath, targetListFromResults(matches)) + } + + // The matches were self imports, no dependency is needed + if len(filteredMatches) == 0 { + return Resolution_None, nil, nil + } + + match := filteredMatches[0] + + BazelLog.Tracef("resolve %q import %q as %q", from, impStm.Imp, match) + + return Resolution_Override, &match, nil +} + func (ts *typeScriptLang) resolvePackageImport(from label.Label, imp string) *label.Label { impPkg, _ := node.ParseImportPath(imp) diff --git a/gazelle/js/target.go b/gazelle/js/target.go index cf768c542..119b8ccf7 100644 --- a/gazelle/js/target.go +++ b/gazelle/js/target.go @@ -13,9 +13,6 @@ import ( type ImportStatement struct { resolve.ImportSpec - // Alternative paths this statement may resolve to - Alt []string - // The path of the file containing the import SourcePath string diff --git a/gazelle/js/tests/pnpm_workspace/tsconfig.json b/gazelle/js/tests/pnpm_workspace/tsconfig.json new file mode 100644 index 000000000..22c9424e8 --- /dev/null +++ b/gazelle/js/tests/pnpm_workspace/tsconfig.json @@ -0,0 +1,10 @@ +// This tsconfig also maps paths but is only for IDEs! +{ + "compilerOptions": { + "paths": { + // The BUILD dependencies should prioritize the `workspace:*` packages + // instead of mapping to the `ts_project` targets that this tsconfig maps to. + "@lib/*": ["lib/*"] + } + } +} From cc1d2b982ac7c6be8d984ffe5935a4537f635eca Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Wed, 9 Oct 2024 20:11:58 -0700 Subject: [PATCH 18/23] refactor(cli): move gazelle gitignore and walk logic to common (#7016) Gitignore and generation-mode are both generic gazelle config and should require no code in plugins. Note that both of these are currently patched into gazelle while waiting for PRs which will allow the removal of all aspect code: https://github.com/bazelbuild/bazel-gazelle/pull/1921 https://github.com/bazelbuild/bazel-gazelle/pull/1908 --- ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases GitOrigin-RevId: cdfe6690ff0ab2584e429419612cc32e94c6b379 --- gazelle/common/git/BUILD.bazel | 2 + gazelle/common/git/gitignore.go | 39 +++++++++-- gazelle/common/walk.go | 31 ++++++++- gazelle/js/config.go | 15 ---- gazelle/js/configure.go | 69 +++---------------- gazelle/js/generate.go | 7 -- .../gazelle_generation_mode_legacy/BUILD.in | 1 + .../gazelle_generation_mode_legacy/BUILD.out | 7 +- .../default/src/BUILD.out | 6 -- .../default/src/lib1.ts | 1 - .../directory/BUILD.in | 4 -- .../directory/BUILD.out | 16 ----- .../directory/a/BUILD.out | 10 --- .../directory/a/a1/BUILD.out | 6 -- .../directory/a/a1/lib-a1.ts | 1 - .../directory/a/a2/BUILD.out | 7 -- .../directory/a/a2/lib-a2.ts | 3 - .../directory/a/lib-a.ts | 3 - .../directory/b/BUILD.in | 1 - .../directory/b/BUILD.out | 12 ---- .../directory/b/b1/lib-b1.ts | 1 - .../directory/b/lib-b.ts | 3 - .../directory/lib.ts | 3 - .../directory/now-empty-sub/BUILD.in | 9 --- .../directory/now-empty-sub/src/BUILD.out | 7 -- .../directory/now-empty-sub/src/a.ts | 1 - .../directory/now-empty/BUILD.in | 11 --- .../directory/now-empty/BUILD.out | 1 - .../expectedExitCode.txt | 1 + .../expectedStderr.txt | 1 + .../expectedStdout.txt | 5 -- .../none/BUILD.in | 1 - .../none/BUILD.out | 13 ---- .../none/a/a1/BUILD.in | 1 - .../none/a/a1/BUILD.out | 8 --- .../none/a/a1/lib-a1.ts | 1 - .../none/a/a2/lib-a2.ts | 3 - .../none/a/lib-a.ts | 3 - .../none/b/BUILD.in | 2 - .../none/b/BUILD.out | 12 ---- .../none/b/b1/BUILD.out | 6 -- .../none/b/b1/lib-b1.ts | 1 - .../none/b/lib-b.ts | 3 - .../none/lib1.ts | 1 - gazelle/kotlin/configure.go | 6 +- 45 files changed, 79 insertions(+), 266 deletions(-) delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/default/src/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/default/src/lib1.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/BUILD.in delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a1/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a1/lib-a1.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a2/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a2/lib-a2.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/lib-a.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/BUILD.in delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/b1/lib-b1.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/lib-b.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/lib.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/BUILD.in delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/src/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/src/a.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty/BUILD.in delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty/BUILD.out create mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/expectedExitCode.txt create mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/expectedStderr.txt delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/expectedStdout.txt delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/BUILD.in delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/BUILD.in delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/lib-a1.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a2/lib-a2.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/a/lib-a.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/b/BUILD.in delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/b/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/b/b1/BUILD.out delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/b/b1/lib-b1.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/b/lib-b.ts delete mode 100644 gazelle/js/tests/gazelle_generation_mode_legacy/none/lib1.ts diff --git a/gazelle/common/git/BUILD.bazel b/gazelle/common/git/BUILD.bazel index cee94d70b..857d15c6a 100644 --- a/gazelle/common/git/BUILD.bazel +++ b/gazelle/common/git/BUILD.bazel @@ -6,8 +6,10 @@ go_library( importpath = "aspect.build/cli/gazelle/common/git", visibility = ["//visibility:public"], deps = [ + "//gazelle/common", "//pkg/logger", "@bazel_gazelle//config:go_default_library", + "@bazel_gazelle//rule:go_default_library", "@com_github_go_git_go_git_v5//plumbing/format/gitignore", ], ) diff --git a/gazelle/common/git/gitignore.go b/gazelle/common/git/gitignore.go index ed2e4e34d..eec2f1ddb 100644 --- a/gazelle/common/git/gitignore.go +++ b/gazelle/common/git/gitignore.go @@ -7,11 +7,15 @@ import ( "path" "strings" + common "aspect.build/cli/gazelle/common" BazelLog "aspect.build/cli/pkg/logger" "github.com/bazelbuild/bazel-gazelle/config" + "github.com/bazelbuild/bazel-gazelle/rule" gitignore "github.com/go-git/go-git/v5/plumbing/format/gitignore" ) +// TODO: remove and align with gazelle after https://github.com/aspect-build/aspect-cli/issues/755 + // Must align with patched bazel-gazelle const ASPECT_GITIGNORE = "__aspect:gitignore" @@ -25,7 +29,7 @@ const enabledExt = Directive_GitIgnore const lastConfiguredExt = "gitignore:dir" const ignorePatternsExt = "gitignore:patterns" -func CollectIgnoreFiles(c *config.Config, rel string) { +func collectIgnoreFiles(c *config.Config, rel string) { // Only parse once per directory. if lastCollected, hasCollected := c.Exts[lastConfiguredExt]; hasCollected && lastCollected == rel { return @@ -44,12 +48,33 @@ func CollectIgnoreFiles(c *config.Config, rel string) { } } -func EnableGitignore(c *config.Config, enabled bool) { - c.Exts[enabledExt] = enabled - if enabled { - c.Exts[ASPECT_GITIGNORE] = createMatcherFunc(c) - } else { - c.Exts[ASPECT_GITIGNORE] = nil +func ReadGitConfig(c *config.Config, rel string, f *rule.File) { + // Enable .gitignore support by default in Aspect gazelle languages. + // TODO: default to false and encourage use of .bazelignore instead + if rel == "" { + _, exists := c.Exts[enabledExt] + if !exists { + c.Exts[enabledExt] = true + } + } + + // Collect ignore files within this config directory. + collectIgnoreFiles(c, rel) + + // Collect config from directives within this BUILD. + if f != nil { + for _, d := range f.Directives { + switch d.Key { + case Directive_GitIgnore: + enabled := common.ReadEnabled(d) + c.Exts[enabledExt] = enabled + if enabled { + c.Exts[ASPECT_GITIGNORE] = createMatcherFunc(c) + } else { + c.Exts[ASPECT_GITIGNORE] = nil + } + } + } } } diff --git a/gazelle/common/walk.go b/gazelle/common/walk.go index ae1d83305..98205633e 100644 --- a/gazelle/common/walk.go +++ b/gazelle/common/walk.go @@ -1,8 +1,13 @@ package gazelle import ( + "log" + "strings" + BazelLog "aspect.build/cli/pkg/logger" + "github.com/bazelbuild/bazel-gazelle/config" "github.com/bazelbuild/bazel-gazelle/language" + "github.com/bazelbuild/bazel-gazelle/rule" ) type GazelleWalkFunc func(path string) error @@ -10,8 +15,30 @@ type GazelleWalkFunc func(path string) error // Must align with patched bazel-gazelle const ASPECT_WALKSUBDIR = "__aspect:walksubdir" -// Walk the directory of the language.GenerateArgs, optionally recursing into -// subdirectories unlike the files provided in GenerateArgs.RegularFiles. +// Read any configuration regarding walk options. +func ReadWalkConfig(c *config.Config, rel string, f *rule.File) bool { + if f == nil { + v, ok := c.Exts[ASPECT_WALKSUBDIR] + return !ok || !v.(bool) + } + + for _, d := range f.Directives { + switch d.Key { + case Directive_GenerationMode: + switch GenerationModeType(strings.TrimSpace(d.Value)) { + case GenerationModeCreate: + c.Exts[ASPECT_WALKSUBDIR] = false + case GenerationModeUpdate: + c.Exts[ASPECT_WALKSUBDIR] = true + default: + log.Fatalf("invalid value for directive %q: %s", Directive_GenerationMode, d.Value) + } + } + } + return true +} + +// Walk the directory being generated, respecting any walk generation config. func GazelleWalkDir(args language.GenerateArgs, walkFunc GazelleWalkFunc) error { BazelLog.Tracef("GazelleWalkDir: %s", args.Rel) diff --git a/gazelle/js/config.go b/gazelle/js/config.go index 74bc7af56..2d557f9d2 100644 --- a/gazelle/js/config.go +++ b/gazelle/js/config.go @@ -7,7 +7,6 @@ import ( "path" "strings" - common "aspect.build/cli/gazelle/common" "github.com/bazelbuild/bazel-gazelle/label" "github.com/bmatcuk/doublestar/v4" "github.com/emirpasic/gods/maps/linkedhashmap" @@ -158,7 +157,6 @@ type JsGazelleConfig struct { parent *JsGazelleConfig generationEnabled bool - generationMode common.GenerationModeType packageTargetKind PackageTargetKind @@ -191,7 +189,6 @@ func newRootConfig() *JsGazelleConfig { protoGenerationEnabled: true, tsconfigGenerationEnabled: false, packageGenerationEnabled: NpmPackageReferencedMode, - generationMode: common.GenerationModeCreate, packageTargetKind: PackageTargetKind_Package, pnpmLockPath: "pnpm-lock.yaml", ignoreDependencies: make([]string, 0), @@ -384,18 +381,6 @@ func (c *JsGazelleConfig) ValidateImportStatements() ValidationMode { return c.validateImportStatements } -// SetGenerationMode sets whether coarse-grained targets should be -// generated or not. -func (c *JsGazelleConfig) SetGenerationMode(generationMode common.GenerationModeType) { - c.generationMode = generationMode -} - -// GenerationMode returns whether coarse-grained targets should be -// generated or not. -func (c *JsGazelleConfig) GenerationMode() common.GenerationModeType { - return c.generationMode -} - // SetLibraryNamingConvention sets the ts_project target naming convention. func (c *JsGazelleConfig) SetLibraryNamingConvention(libraryNamingConvention string) { c.targetNamingOverrides[DefaultLibraryName] = libraryNamingConvention diff --git a/gazelle/js/configure.go b/gazelle/js/configure.go index ec29e3a77..30adda66c 100644 --- a/gazelle/js/configure.go +++ b/gazelle/js/configure.go @@ -25,9 +25,6 @@ var _ config.Configurer = (*typeScriptLang)(nil) // starts. RegisterFlags may set an initial values in Config.Exts. When flags // are set, they should modify these values. func (ts *typeScriptLang) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) { - // Enable .gitignore support by default - // TODO: change to false and encourage .bazelignore - git.EnableGitignore(c, true) } // CheckFlags validates the configuration after command line flags are parsed. @@ -59,15 +56,13 @@ func (ts *typeScriptLang) KnownDirectives() []string { Directive_LibraryFiles, Directive_TestFiles, - // Common directives supported by this language - common.Directive_GenerationMode, - // TODO(deprecated): remove Directive_CustomTargetFiles, Directive_CustomTargetTestFiles, // TODO: move to common git.Directive_GitIgnore, + common.Directive_GenerationMode, } } @@ -99,11 +94,9 @@ func (ts *typeScriptLang) Configure(c *config.Config, rel string, f *rule.File) ts.readConfigurations(c, rel) } - // TODO: move to common global config.Configurer - // Enable the WALKSUBDIR gazelle patch, setting the flag depending on js the GenerationMode. - c.Exts[common.ASPECT_WALKSUBDIR] = c.Exts[LanguageName].(*JsGazelleConfig).generationMode == common.GenerationModeUpdate + common.ReadWalkConfig(c, rel, f) - git.CollectIgnoreFiles(c, rel) + git.ReadGitConfig(c, rel, f) } func (ts *typeScriptLang) readConfigurations(c *config.Config, rel string) { @@ -230,57 +223,17 @@ func (ts *typeScriptLang) readDirectives(c *config.Config, rel string, f *rule.F } config.addTargetGlob(group, groupGlob, true) - case Directive_CustomTargetFiles: - groupGlob := strings.Split(value, " ") - if len(groupGlob) != 2 { - err := fmt.Errorf("invalid value for directive %q: %s: value must be group + glob", - Directive_CustomTargetFiles, d.Value) - log.Fatal(err) - } - - fmt.Printf("DEPRECATED: %s is deprecated, use %s %s instead\n", Directive_CustomTargetFiles, Directive_LibraryFiles, groupGlob[0]) - config.addTargetGlob(groupGlob[0], groupGlob[1], false) + // TODO: remove, deprecated + case Directive_CustomTargetFiles: + fmt.Fprintf(os.Stderr, "DEPRECATED: %s is deprecated, use %s\n", Directive_CustomTargetFiles, Directive_LibraryFiles) + os.Exit(1) case Directive_CustomTargetTestFiles: - groupGlob := strings.Split(value, " ") - if len(groupGlob) != 2 { - err := fmt.Errorf("invalid value for directive %q: %s: value must be group + glob", - Directive_CustomTargetTestFiles, d.Value) - log.Fatal(err) - } - - fmt.Printf("DEPRECATED: %s is deprecated, use %s %s instead\n", Directive_CustomTargetTestFiles, Directive_TestFiles, groupGlob[0]) - - config.addTargetGlob(groupGlob[0], groupGlob[1], true) - + fmt.Fprintf(os.Stderr, "DEPRECATED: %s is deprecated, use %s\n", Directive_CustomTargetTestFiles, Directive_TestFiles) + os.Exit(1) case Directive_GenerationMode: - mode := strings.TrimSpace(d.Value) - switch mode { - case "directory": - config.SetGenerationMode(common.GenerationModeCreate) - case "none": - config.SetGenerationMode(common.GenerationModeUpdate) - default: - log.Fatalf("invalid value for directive %q: %s", Directive_GenerationMode, d.Value) - } - - fmt.Printf("DEPRECATED: %s is deprecated, use %s %s|%s\n", Directive_GenerationMode, common.Directive_GenerationMode, common.GenerationModeUpdate, common.GenerationModeCreate) - - // Inherited aspect-cli common+pro values - // TODO: move to common location - case common.Directive_GenerationMode: - mode := common.GenerationModeType(strings.TrimSpace(d.Value)) - switch mode { - case common.GenerationModeCreate: - config.SetGenerationMode(common.GenerationModeCreate) - case common.GenerationModeUpdate: - config.SetGenerationMode(common.GenerationModeUpdate) - default: - log.Fatalf("invalid value for directive %q: %s", common.Directive_GenerationMode, d.Value) - } - // TODO: move to common - case git.Directive_GitIgnore: - git.EnableGitignore(c, common.ReadEnabled(d)) + fmt.Fprintf(os.Stderr, "DEPRECATED: %s is deprecated, use %s %s|%s\n", Directive_GenerationMode, common.Directive_GenerationMode, common.GenerationModeUpdate, common.GenerationModeCreate) + os.Exit(1) } } } diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index f557a954e..ea0cddd1d 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -55,13 +55,6 @@ func (ts *typeScriptLang) GenerateRules(args language.GenerateArgs) language.Gen return language.GenerateResult{} } - // If this directory has not been declared as a bazel package only continue - // if generating new BUILD files is enabled. - if cfg.GenerationMode() == gazelle.GenerationModeUpdate && args.File == nil { - BazelLog.Tracef("GenerateRules(%s) BUILD creation disabled: %s", LanguageName, args.Rel) - return language.GenerateResult{} - } - BazelLog.Tracef("GenerateRules(%s): %s", LanguageName, args.Rel) var result language.GenerateResult diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/BUILD.in b/gazelle/js/tests/gazelle_generation_mode_legacy/BUILD.in index e69de29bb..8958b11d9 100644 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/BUILD.in +++ b/gazelle/js/tests/gazelle_generation_mode_legacy/BUILD.in @@ -0,0 +1 @@ +# gazelle:js_generation_mode directory diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/BUILD.out index e0a0128e9..8958b11d9 100644 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/BUILD.out +++ b/gazelle/js/tests/gazelle_generation_mode_legacy/BUILD.out @@ -1,6 +1 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "gazelle_generation_mode", - srcs = ["main.ts"], -) +# gazelle:js_generation_mode directory diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/default/src/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/default/src/BUILD.out deleted file mode 100644 index b2ff0fb2d..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/default/src/BUILD.out +++ /dev/null @@ -1,6 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "src", - srcs = ["lib1.ts"], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/default/src/lib1.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/default/src/lib1.ts deleted file mode 100644 index 5243ca04f..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/default/src/lib1.ts +++ /dev/null @@ -1 +0,0 @@ -// Directory containing only .ts diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/BUILD.in b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/BUILD.in deleted file mode 100644 index 52072608f..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/BUILD.in +++ /dev/null @@ -1,4 +0,0 @@ -# Directory enabling 'directory' mode and containing a .ts -# Same files/layout as sibling directories. - -# gazelle:js_generation_mode directory diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/BUILD.out deleted file mode 100644 index 3b6003374..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/BUILD.out +++ /dev/null @@ -1,16 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -# Directory enabling 'directory' mode and containing a .ts -# Same files/layout as sibling directories. - -# gazelle:js_generation_mode directory - -ts_project( - name = "directory", - srcs = ["lib.ts"], - deps = [ - "//directory/a", - "//directory/a/a1", - "//directory/b", - ], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/BUILD.out deleted file mode 100644 index ca7742269..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/BUILD.out +++ /dev/null @@ -1,10 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "a", - srcs = ["lib-a.ts"], - deps = [ - "//directory/a/a1", - "//directory/a/a2", - ], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a1/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a1/BUILD.out deleted file mode 100644 index e56bf36e0..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a1/BUILD.out +++ /dev/null @@ -1,6 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "a1", - srcs = ["lib-a1.ts"], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a1/lib-a1.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a1/lib-a1.ts deleted file mode 100644 index e6021a54a..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a1/lib-a1.ts +++ /dev/null @@ -1 +0,0 @@ -export const a_a1_lib = '123'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a2/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a2/BUILD.out deleted file mode 100644 index 764459c04..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a2/BUILD.out +++ /dev/null @@ -1,7 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "a2", - srcs = ["lib-a2.ts"], - deps = ["//directory/a/a1"], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a2/lib-a2.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a2/lib-a2.ts deleted file mode 100644 index 67b3f6d0a..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/a2/lib-a2.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { a_a1_lib } from '../a1/lib-a1'; - -export const a_a2_lib = a_a1_lib + 'v2'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/lib-a.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/lib-a.ts deleted file mode 100644 index c66c1e217..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/a/lib-a.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './a1/lib-a1'; -export * from './a2/lib-a2'; -export const a_lib = '123'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/BUILD.in b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/BUILD.in deleted file mode 100644 index 39ba8985e..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:js_generation_mode none diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/BUILD.out deleted file mode 100644 index ddecd51bf..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -# gazelle:js_generation_mode none - -ts_project( - name = "b", - srcs = [ - "b1/lib-b1.ts", - "lib-b.ts", - ], - deps = ["//directory/a"], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/b1/lib-b1.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/b1/lib-b1.ts deleted file mode 100644 index bb7ea6e14..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/b1/lib-b1.ts +++ /dev/null @@ -1 +0,0 @@ -export const value = 'directory/b/b1/lib'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/lib-b.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/lib-b.ts deleted file mode 100644 index 749daceec..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/b/lib-b.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '../a/lib-a'; -export * from './b1/lib-b1'; -export const b_lib = '456'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/lib.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/lib.ts deleted file mode 100644 index 97e3ace16..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/lib.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './a/lib-a'; -export * from './a/a1/lib-a1'; -export * from './b/lib-b'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/BUILD.in b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/BUILD.in deleted file mode 100644 index f230fbdae..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/BUILD.in +++ /dev/null @@ -1,9 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "now-empty-sub", - srcs = ["src/a.ts"], - deps = [ - "//directory/a", - ], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/src/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/src/BUILD.out deleted file mode 100644 index 76259964f..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/src/BUILD.out +++ /dev/null @@ -1,7 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "src", - srcs = ["a.ts"], - deps = ["//directory/a"], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/src/a.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/src/a.ts deleted file mode 100644 index 16f9668dd..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty-sub/src/a.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../../a/lib-a'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty/BUILD.in b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty/BUILD.in deleted file mode 100644 index 73ad5df9b..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty/BUILD.in +++ /dev/null @@ -1,11 +0,0 @@ -# TEST - -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "now-empty", - srcs = ["old.ts"], - deps = [ - "//directory/a", - ], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty/BUILD.out deleted file mode 100644 index 839c30c63..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/directory/now-empty/BUILD.out +++ /dev/null @@ -1 +0,0 @@ -# TEST diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/expectedExitCode.txt b/gazelle/js/tests/gazelle_generation_mode_legacy/expectedExitCode.txt new file mode 100644 index 000000000..56a6051ca --- /dev/null +++ b/gazelle/js/tests/gazelle_generation_mode_legacy/expectedExitCode.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/expectedStderr.txt b/gazelle/js/tests/gazelle_generation_mode_legacy/expectedStderr.txt new file mode 100644 index 000000000..9f8737789 --- /dev/null +++ b/gazelle/js/tests/gazelle_generation_mode_legacy/expectedStderr.txt @@ -0,0 +1 @@ +DEPRECATED: js_generation_mode is deprecated, use generation_mode update|create diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/expectedStdout.txt b/gazelle/js/tests/gazelle_generation_mode_legacy/expectedStdout.txt deleted file mode 100644 index caa01b6d4..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/expectedStdout.txt +++ /dev/null @@ -1,5 +0,0 @@ -DEPRECATED: js_generation_mode is deprecated, use generation_mode update|create -DEPRECATED: js_generation_mode is deprecated, use generation_mode update|create -DEPRECATED: js_generation_mode is deprecated, use generation_mode update|create -DEPRECATED: js_generation_mode is deprecated, use generation_mode update|create -DEPRECATED: js_generation_mode is deprecated, use generation_mode update|create diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/BUILD.in b/gazelle/js/tests/gazelle_generation_mode_legacy/none/BUILD.in deleted file mode 100644 index 39ba8985e..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:js_generation_mode none diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/none/BUILD.out deleted file mode 100644 index 1c4ee431c..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/BUILD.out +++ /dev/null @@ -1,13 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -# gazelle:js_generation_mode none - -ts_project( - name = "none", - srcs = [ - "a/a2/lib-a2.ts", - "a/lib-a.ts", - "lib1.ts", - ], - deps = ["//none/a/a1"], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/BUILD.in b/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/BUILD.in deleted file mode 100644 index 8958b11d9..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:js_generation_mode directory diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/BUILD.out deleted file mode 100644 index 98eafe828..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -# gazelle:js_generation_mode directory - -ts_project( - name = "a1", - srcs = ["lib-a1.ts"], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/lib-a1.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/lib-a1.ts deleted file mode 100644 index e6021a54a..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a1/lib-a1.ts +++ /dev/null @@ -1 +0,0 @@ -export const a_a1_lib = '123'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a2/lib-a2.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a2/lib-a2.ts deleted file mode 100644 index 67b3f6d0a..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/a2/lib-a2.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { a_a1_lib } from '../a1/lib-a1'; - -export const a_a2_lib = a_a1_lib + 'v2'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/lib-a.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/lib-a.ts deleted file mode 100644 index c66c1e217..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/a/lib-a.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './a1/lib-a1'; -export * from './a2/lib-a2'; -export const a_lib = '123'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/BUILD.in b/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/BUILD.in deleted file mode 100644 index d2413b723..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/BUILD.in +++ /dev/null @@ -1,2 +0,0 @@ -# gazelle:js_generation_mode directory - diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/BUILD.out deleted file mode 100644 index efe3eb935..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -# gazelle:js_generation_mode directory - -ts_project( - name = "b", - srcs = ["lib-b.ts"], - deps = [ - "//none", - "//none/b/b1", - ], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/b1/BUILD.out b/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/b1/BUILD.out deleted file mode 100644 index 37f482ee2..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/b1/BUILD.out +++ /dev/null @@ -1,6 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") - -ts_project( - name = "b1", - srcs = ["lib-b1.ts"], -) diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/b1/lib-b1.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/b1/lib-b1.ts deleted file mode 100644 index bb7ea6e14..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/b1/lib-b1.ts +++ /dev/null @@ -1 +0,0 @@ -export const value = 'directory/b/b1/lib'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/lib-b.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/lib-b.ts deleted file mode 100644 index 749daceec..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/b/lib-b.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '../a/lib-a'; -export * from './b1/lib-b1'; -export const b_lib = '456'; diff --git a/gazelle/js/tests/gazelle_generation_mode_legacy/none/lib1.ts b/gazelle/js/tests/gazelle_generation_mode_legacy/none/lib1.ts deleted file mode 100644 index 5243ca04f..000000000 --- a/gazelle/js/tests/gazelle_generation_mode_legacy/none/lib1.ts +++ /dev/null @@ -1 +0,0 @@ -// Directory containing only .ts diff --git a/gazelle/kotlin/configure.go b/gazelle/kotlin/configure.go index 0dffbc700..78b84cfbb 100644 --- a/gazelle/kotlin/configure.go +++ b/gazelle/kotlin/configure.go @@ -48,7 +48,7 @@ func (kt *kotlinLang) Configure(c *config.Config, rel string, f *rule.File) { } // Collect the ignore files for this package - git.CollectIgnoreFiles(c, rel) + git.ReadGitConfig(c, rel, f) if f != nil { for _, d := range f.Directives { @@ -62,10 +62,6 @@ func (kt *kotlinLang) Configure(c *config.Config, rel string, f *rule.File) { case jvm_javaconfig.JavaMavenInstallFile: cfg.SetMavenInstallFile(d.Value) - - // TODO: move to common - case git.Directive_GitIgnore: - git.EnableGitignore(c, common.ReadEnabled(d)) } } } From 0304de28f8be8766f73d4a0280aaa5fe601441cf Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Sun, 13 Oct 2024 21:43:40 -0700 Subject: [PATCH 19/23] feat(cli): set generated BUILD npm package target visibility to public (#7095) Package targets must be visible when linked by rules_js so public visibility is a good default. Close https://github.com/aspect-build/aspect-cli/issues/758 --- ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: yes `configure` generated package targets (`npm_package` or `js_library`) visibility is now set to public by default. ### Test plan - Covered by existing test cases GitOrigin-RevId: 0e6112b2af952a98de0dd6e80339e31bb98089e9 --- gazelle/js/generate.go | 1 + gazelle/js/tests/npm_package_deps/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/exports-js/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/exports-single/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/main-js/BUILD.out | 1 + gazelle/js/tests/npm_package_deps/main-ts/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out | 1 + .../js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out | 1 + .../npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out | 1 + gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out | 1 + gazelle/js/tests/npm_package_lib_target_name/lib/b/BUILD.out | 1 + gazelle/js/tests/npm_package_lib_target_name/lib/c/BUILD.out | 1 + gazelle/js/tests/npm_package_target_enabled/BUILD.out | 1 + gazelle/js/tests/npm_package_target_enabled/lib/a/BUILD.out | 1 + gazelle/js/tests/npm_package_target_enabled/lib/b/BUILD.out | 1 + gazelle/js/tests/npm_package_target_enabled/lib/c/BUILD.out | 1 + gazelle/js/tests/npm_package_target_name/lib/b/BUILD.out | 1 + gazelle/js/tests/npm_package_target_name/lib/c/BUILD.out | 1 + gazelle/js/tests/npm_package_target_referenced/lib/b/BUILD.out | 1 + gazelle/js/tests/npm_package_target_referenced/lib/c/BUILD.out | 1 + gazelle/js/tests/pnpm_project_refs_lock5/BUILD.out | 1 + gazelle/js/tests/pnpm_project_refs_lock5/lib/BUILD.out | 1 + gazelle/js/tests/pnpm_project_refs_lock6/BUILD.out | 1 + gazelle/js/tests/pnpm_project_refs_lock6/lib/BUILD.out | 1 + gazelle/js/tests/pnpm_project_refs_lock9/BUILD.out | 1 + gazelle/js/tests/pnpm_project_refs_lock9/lib/BUILD.out | 1 + gazelle/js/tests/pnpm_workspace/lib/a/BUILD.out | 1 + gazelle/js/tests/pnpm_workspace/lib/b/BUILD.out | 1 + gazelle/js/tests/pnpm_workspace/lib/c/BUILD.out | 1 + gazelle/js/tests/pnpm_workspace_rerooted/lib/a/BUILD.out | 1 + gazelle/js/tests/pnpm_workspace_rerooted/lib/b/BUILD.out | 1 + gazelle/js/tests/pnpm_workspace_rerooted/lib/c/BUILD.out | 1 + gazelle/js/tests/tsconfig_pnpm_ref/tools/BUILD.out | 1 + gazelle/js/tests/tsconfig_pnpm_ref_rerooted/tools/BUILD.out | 1 + 51 files changed, 51 insertions(+) diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index ea0cddd1d..6adbcb16f 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -247,6 +247,7 @@ func (ts *typeScriptLang) addPackageRule(cfg *JsGazelleConfig, args language.Gen npmPackage := rule.NewRule(packageTargetKind, packageTargetName) npmPackage.SetAttr("srcs", npmPackageInfo.sources.Values()) + npmPackage.SetAttr("visibility", []string{rule.CheckInternalVisibility(cfg.rel, "//visibility:public")}) result.Gen = append(result.Gen, npmPackage) result.Imports = append(result.Imports, npmPackageInfo) diff --git a/gazelle/js/tests/npm_package_deps/BUILD.out b/gazelle/js/tests/npm_package_deps/BUILD.out index 40f80f4c6..b30816b09 100644 --- a/gazelle/js/tests/npm_package_deps/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/BUILD.out @@ -11,4 +11,5 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out index 5bffc1109..59abc2d01 100644 --- a/gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-gen/BUILD.out @@ -16,4 +16,5 @@ npm_package( "package.json", ":start.js", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out index 1b24280c2..469b486b6 100644 --- a/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-ignore/BUILD.out @@ -17,4 +17,5 @@ npm_package( "package.json", ":tsc", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/exports-js/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-js/BUILD.out index 38c25f05a..60307c5b9 100644 --- a/gazelle/js/tests/npm_package_deps/exports-js/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-js/BUILD.out @@ -11,4 +11,5 @@ npm_package( "//exports-js/lib:tsc", "//exports-js/lib2:tsc", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/exports-single/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-single/BUILD.out index 41b8d7a47..cb2983237 100644 --- a/gazelle/js/tests/npm_package_deps/exports-single/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-single/BUILD.out @@ -9,4 +9,5 @@ npm_package( "package.json", "//exports-single/bin:tsc", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out b/gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out index 4888b4b62..d5b43a420 100644 --- a/gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/exports-ts/BUILD.out @@ -9,4 +9,5 @@ npm_package( "package.json", "//exports-ts/src:tsc", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out b/gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out index 5236e8cc3..0b52e3070 100644 --- a/gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/main-custom_ts/BUILD.out @@ -17,4 +17,5 @@ npm_package( "package.json", ":m", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out b/gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out index 5bffc1109..59abc2d01 100644 --- a/gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/main-js-gen/BUILD.out @@ -16,4 +16,5 @@ npm_package( "package.json", ":start.js", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/main-js/BUILD.out b/gazelle/js/tests/npm_package_deps/main-js/BUILD.out index 3e1c38e6a..c7aaec36c 100644 --- a/gazelle/js/tests/npm_package_deps/main-js/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/main-js/BUILD.out @@ -15,4 +15,5 @@ npm_package( "package.json", ":tsc", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps/main-ts/BUILD.out b/gazelle/js/tests/npm_package_deps/main-ts/BUILD.out index ff60625b7..0da016d56 100644 --- a/gazelle/js/tests/npm_package_deps/main-ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps/main-ts/BUILD.out @@ -15,4 +15,5 @@ npm_package( "package.json", ":tsc", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/BUILD.out index 7ca58d465..b0ac612f4 100644 --- a/gazelle/js/tests/npm_package_deps_lib/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/BUILD.out @@ -12,4 +12,5 @@ npm_link_all_packages(name = "node_modules") js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out index 5b0d57a56..231299412 100644 --- a/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/exports-gen/BUILD.out @@ -13,5 +13,6 @@ npm_link_all_packages(name = "node_modules") js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = [":start.js"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out index 2dcc51d13..79c29aa41 100644 --- a/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ignore/BUILD.out @@ -13,5 +13,6 @@ js_library( js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = [":tsc"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out index 414a9822f..f84af195e 100644 --- a/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/exports-js/BUILD.out @@ -6,6 +6,7 @@ npm_link_all_packages(name = "node_modules") js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = [ "//exports-js/bin:tsc", "//exports-js/lib:tsc", diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out index f4b4c2209..3fe179c9f 100644 --- a/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/exports-single/BUILD.out @@ -6,5 +6,6 @@ npm_link_all_packages(name = "node_modules") js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = ["//exports-single/bin:tsc"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out index 477351027..a87a41bcd 100644 --- a/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/exports-ts/BUILD.out @@ -6,5 +6,6 @@ npm_link_all_packages(name = "node_modules") js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = ["//exports-ts/src:tsc"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out index 53ea3dc7d..079c0cfc6 100644 --- a/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/main-custom_ts/BUILD.out @@ -14,5 +14,6 @@ ts_project( js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = [":m"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out index 5b0d57a56..231299412 100644 --- a/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/main-js-gen/BUILD.out @@ -13,5 +13,6 @@ npm_link_all_packages(name = "node_modules") js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = [":start.js"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out index 449c2132d..75d767695 100644 --- a/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/main-js/BUILD.out @@ -11,5 +11,6 @@ js_library( js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = [":tsc"], ) diff --git a/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out b/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out index 227007f48..566d77642 100644 --- a/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_lib/main-ts/BUILD.out @@ -12,5 +12,6 @@ ts_project( js_library( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], deps = [":tsc"], ) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out index 7229163d9..571be4798 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/BUILD.out @@ -13,6 +13,7 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], ) ts_config( diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out index a91c61417..ac392b75c 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/exports/BUILD.out @@ -18,6 +18,7 @@ npm_package( "package.json", ":tsc", ], + visibility = ["//visibility:public"], ) ts_config( diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out index 6749380c0..fdcb7be33 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-custom_ts/BUILD.out @@ -18,6 +18,7 @@ npm_package( "package.json", ":m", ], + visibility = ["//visibility:public"], ) ts_config( diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out index 49ce28faf..24f3392d2 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main-inherit-tsconfig/BUILD.out @@ -17,4 +17,5 @@ npm_package( "package.json", ":tsc", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out index 3d59ac164..503c102d6 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/main/BUILD.out @@ -17,6 +17,7 @@ npm_package( "package.json", ":tsc", ], + visibility = ["//visibility:public"], ) ts_config( diff --git a/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out index bb4dff97f..578c33a53 100644 --- a/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out +++ b/gazelle/js/tests/npm_package_deps_tsconfig/scenario1/BUILD.out @@ -25,6 +25,7 @@ npm_package( "package.json", ":tsc", ], + visibility = ["//visibility:public"], ) ts_config( diff --git a/gazelle/js/tests/npm_package_lib_target_name/lib/b/BUILD.out b/gazelle/js/tests/npm_package_lib_target_name/lib/b/BUILD.out index 81304ab0b..7c131e867 100644 --- a/gazelle/js/tests/npm_package_lib_target_name/lib/b/BUILD.out +++ b/gazelle/js/tests/npm_package_lib_target_name/lib/b/BUILD.out @@ -16,4 +16,5 @@ ts_project( npm_package( name = "pkg", srcs = [":tsc"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_lib_target_name/lib/c/BUILD.out b/gazelle/js/tests/npm_package_lib_target_name/lib/c/BUILD.out index bdaf4004c..299f20b21 100644 --- a/gazelle/js/tests/npm_package_lib_target_name/lib/c/BUILD.out +++ b/gazelle/js/tests/npm_package_lib_target_name/lib/c/BUILD.out @@ -15,4 +15,5 @@ ts_project( npm_package( name = "pkg", srcs = [":tsc"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_target_enabled/BUILD.out b/gazelle/js/tests/npm_package_target_enabled/BUILD.out index 7590e4032..0f679cefa 100644 --- a/gazelle/js/tests/npm_package_target_enabled/BUILD.out +++ b/gazelle/js/tests/npm_package_target_enabled/BUILD.out @@ -10,4 +10,5 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "npm_package_target_enabled_pkg", srcs = ["package.json"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_target_enabled/lib/a/BUILD.out b/gazelle/js/tests/npm_package_target_enabled/lib/a/BUILD.out index ccf6eb4a4..51163dd20 100644 --- a/gazelle/js/tests/npm_package_target_enabled/lib/a/BUILD.out +++ b/gazelle/js/tests/npm_package_target_enabled/lib/a/BUILD.out @@ -16,4 +16,5 @@ ts_project( npm_package( name = "a_pkg", srcs = [":a"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_target_enabled/lib/b/BUILD.out b/gazelle/js/tests/npm_package_target_enabled/lib/b/BUILD.out index 18333ad07..b22270c05 100644 --- a/gazelle/js/tests/npm_package_target_enabled/lib/b/BUILD.out +++ b/gazelle/js/tests/npm_package_target_enabled/lib/b/BUILD.out @@ -18,5 +18,6 @@ ts_project( js_library( name = "b_pkg", srcs = [], + visibility = ["//visibility:public"], deps = [":b"], ) diff --git a/gazelle/js/tests/npm_package_target_enabled/lib/c/BUILD.out b/gazelle/js/tests/npm_package_target_enabled/lib/c/BUILD.out index 5be3d2696..d0e98d879 100644 --- a/gazelle/js/tests/npm_package_target_enabled/lib/c/BUILD.out +++ b/gazelle/js/tests/npm_package_target_enabled/lib/c/BUILD.out @@ -15,4 +15,5 @@ ts_project( npm_package( name = "c_pkg", srcs = [":c"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_target_name/lib/b/BUILD.out b/gazelle/js/tests/npm_package_target_name/lib/b/BUILD.out index 18333ad07..b22270c05 100644 --- a/gazelle/js/tests/npm_package_target_name/lib/b/BUILD.out +++ b/gazelle/js/tests/npm_package_target_name/lib/b/BUILD.out @@ -18,5 +18,6 @@ ts_project( js_library( name = "b_pkg", srcs = [], + visibility = ["//visibility:public"], deps = [":b"], ) diff --git a/gazelle/js/tests/npm_package_target_name/lib/c/BUILD.out b/gazelle/js/tests/npm_package_target_name/lib/c/BUILD.out index 5be3d2696..d0e98d879 100644 --- a/gazelle/js/tests/npm_package_target_name/lib/c/BUILD.out +++ b/gazelle/js/tests/npm_package_target_name/lib/c/BUILD.out @@ -15,4 +15,5 @@ ts_project( npm_package( name = "c_pkg", srcs = [":c"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/npm_package_target_referenced/lib/b/BUILD.out b/gazelle/js/tests/npm_package_target_referenced/lib/b/BUILD.out index 18333ad07..b22270c05 100644 --- a/gazelle/js/tests/npm_package_target_referenced/lib/b/BUILD.out +++ b/gazelle/js/tests/npm_package_target_referenced/lib/b/BUILD.out @@ -18,5 +18,6 @@ ts_project( js_library( name = "b_pkg", srcs = [], + visibility = ["//visibility:public"], deps = [":b"], ) diff --git a/gazelle/js/tests/npm_package_target_referenced/lib/c/BUILD.out b/gazelle/js/tests/npm_package_target_referenced/lib/c/BUILD.out index 5be3d2696..d0e98d879 100644 --- a/gazelle/js/tests/npm_package_target_referenced/lib/c/BUILD.out +++ b/gazelle/js/tests/npm_package_target_referenced/lib/c/BUILD.out @@ -15,4 +15,5 @@ ts_project( npm_package( name = "c_pkg", srcs = [":c"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_project_refs_lock5/BUILD.out b/gazelle/js/tests/pnpm_project_refs_lock5/BUILD.out index 48f71eff1..cfbeff64e 100644 --- a/gazelle/js/tests/pnpm_project_refs_lock5/BUILD.out +++ b/gazelle/js/tests/pnpm_project_refs_lock5/BUILD.out @@ -6,4 +6,5 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pnpm_project_refs", srcs = ["package.json"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_project_refs_lock5/lib/BUILD.out b/gazelle/js/tests/pnpm_project_refs_lock5/lib/BUILD.out index f82937811..e17fb5686 100644 --- a/gazelle/js/tests/pnpm_project_refs_lock5/lib/BUILD.out +++ b/gazelle/js/tests/pnpm_project_refs_lock5/lib/BUILD.out @@ -18,4 +18,5 @@ npm_package( "package.json", ":lib_lib", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_project_refs_lock6/BUILD.out b/gazelle/js/tests/pnpm_project_refs_lock6/BUILD.out index 48f71eff1..cfbeff64e 100644 --- a/gazelle/js/tests/pnpm_project_refs_lock6/BUILD.out +++ b/gazelle/js/tests/pnpm_project_refs_lock6/BUILD.out @@ -6,4 +6,5 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pnpm_project_refs", srcs = ["package.json"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_project_refs_lock6/lib/BUILD.out b/gazelle/js/tests/pnpm_project_refs_lock6/lib/BUILD.out index f82937811..e17fb5686 100644 --- a/gazelle/js/tests/pnpm_project_refs_lock6/lib/BUILD.out +++ b/gazelle/js/tests/pnpm_project_refs_lock6/lib/BUILD.out @@ -18,4 +18,5 @@ npm_package( "package.json", ":lib_lib", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_project_refs_lock9/BUILD.out b/gazelle/js/tests/pnpm_project_refs_lock9/BUILD.out index 48f71eff1..cfbeff64e 100644 --- a/gazelle/js/tests/pnpm_project_refs_lock9/BUILD.out +++ b/gazelle/js/tests/pnpm_project_refs_lock9/BUILD.out @@ -6,4 +6,5 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "pnpm_project_refs", srcs = ["package.json"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_project_refs_lock9/lib/BUILD.out b/gazelle/js/tests/pnpm_project_refs_lock9/lib/BUILD.out index f82937811..e17fb5686 100644 --- a/gazelle/js/tests/pnpm_project_refs_lock9/lib/BUILD.out +++ b/gazelle/js/tests/pnpm_project_refs_lock9/lib/BUILD.out @@ -18,4 +18,5 @@ npm_package( "package.json", ":lib_lib", ], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_workspace/lib/a/BUILD.out b/gazelle/js/tests/pnpm_workspace/lib/a/BUILD.out index 393acbecc..1a71f0f6b 100644 --- a/gazelle/js/tests/pnpm_workspace/lib/a/BUILD.out +++ b/gazelle/js/tests/pnpm_workspace/lib/a/BUILD.out @@ -19,4 +19,5 @@ ts_project( npm_package( name = "a", srcs = [":a_lib"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_workspace/lib/b/BUILD.out b/gazelle/js/tests/pnpm_workspace/lib/b/BUILD.out index e56783ed8..ac06049b0 100644 --- a/gazelle/js/tests/pnpm_workspace/lib/b/BUILD.out +++ b/gazelle/js/tests/pnpm_workspace/lib/b/BUILD.out @@ -16,4 +16,5 @@ ts_project( npm_package( name = "b", srcs = [":b_lib"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_workspace/lib/c/BUILD.out b/gazelle/js/tests/pnpm_workspace/lib/c/BUILD.out index 8b29dacd7..7f9767991 100644 --- a/gazelle/js/tests/pnpm_workspace/lib/c/BUILD.out +++ b/gazelle/js/tests/pnpm_workspace/lib/c/BUILD.out @@ -18,5 +18,6 @@ ts_project( js_library( name = "c", srcs = [], + visibility = ["//visibility:public"], deps = [":c_lib"], ) diff --git a/gazelle/js/tests/pnpm_workspace_rerooted/lib/a/BUILD.out b/gazelle/js/tests/pnpm_workspace_rerooted/lib/a/BUILD.out index 393acbecc..1a71f0f6b 100644 --- a/gazelle/js/tests/pnpm_workspace_rerooted/lib/a/BUILD.out +++ b/gazelle/js/tests/pnpm_workspace_rerooted/lib/a/BUILD.out @@ -19,4 +19,5 @@ ts_project( npm_package( name = "a", srcs = [":a_lib"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_workspace_rerooted/lib/b/BUILD.out b/gazelle/js/tests/pnpm_workspace_rerooted/lib/b/BUILD.out index e56783ed8..ac06049b0 100644 --- a/gazelle/js/tests/pnpm_workspace_rerooted/lib/b/BUILD.out +++ b/gazelle/js/tests/pnpm_workspace_rerooted/lib/b/BUILD.out @@ -16,4 +16,5 @@ ts_project( npm_package( name = "b", srcs = [":b_lib"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/pnpm_workspace_rerooted/lib/c/BUILD.out b/gazelle/js/tests/pnpm_workspace_rerooted/lib/c/BUILD.out index b39c86e2d..6bae97758 100644 --- a/gazelle/js/tests/pnpm_workspace_rerooted/lib/c/BUILD.out +++ b/gazelle/js/tests/pnpm_workspace_rerooted/lib/c/BUILD.out @@ -16,4 +16,5 @@ ts_project( npm_package( name = "c", srcs = [":c_lib"], + visibility = ["//visibility:public"], ) diff --git a/gazelle/js/tests/tsconfig_pnpm_ref/tools/BUILD.out b/gazelle/js/tests/tsconfig_pnpm_ref/tools/BUILD.out index 3fc4afdb7..2bb5ccd4b 100644 --- a/gazelle/js/tests/tsconfig_pnpm_ref/tools/BUILD.out +++ b/gazelle/js/tests/tsconfig_pnpm_ref/tools/BUILD.out @@ -7,6 +7,7 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "tools", srcs = ["package.json"], + visibility = ["//visibility:public"], ) ts_config( diff --git a/gazelle/js/tests/tsconfig_pnpm_ref_rerooted/tools/BUILD.out b/gazelle/js/tests/tsconfig_pnpm_ref_rerooted/tools/BUILD.out index 3fc4afdb7..2bb5ccd4b 100644 --- a/gazelle/js/tests/tsconfig_pnpm_ref_rerooted/tools/BUILD.out +++ b/gazelle/js/tests/tsconfig_pnpm_ref_rerooted/tools/BUILD.out @@ -7,6 +7,7 @@ npm_link_all_packages(name = "node_modules") npm_package( name = "tools", srcs = ["package.json"], + visibility = ["//visibility:public"], ) ts_config( From b6c9b5ff3edb2fea5989265c339073dc2fa6d13b Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Thu, 17 Oct 2024 10:01:12 -0700 Subject: [PATCH 20/23] docs(gazelle): correct deprecated js_generation_mode docs (#7098) This is a note about the deprecated one (with `js_` prefix) referring to the new one (no `js_` prefix). ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases GitOrigin-RevId: b5a4c1fd7a51cd9b046b7b02978c2f2a709e132b --- docs/help/topics/directives.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/help/topics/directives.md b/docs/help/topics/directives.md index 49fd82654..7b500fa89 100644 --- a/docs/help/topics/directives.md +++ b/docs/help/topics/directives.md @@ -83,7 +83,7 @@ enable other projects to declare dependencies on the package. | Equivalent to `js_files` but for the test `ts_project` rule. | | `# gazelle:js_npm_package_target_name _name_` | `{dirname}` | | The format used to generate the name of the `npm_package` rule. | -| `# gazelle:generation_mode update\|create` | `create` | +| `# gazelle:js_generation_mode update\|create` | `create` | | DEPRECATED: see `generation_mode` directive. | | `# gazelle:js_custom_files _name_ _glob_` | | | DEPRECATED:Generate additional custom `ts_project` targets | From 044876038be1bfbc4efc63466011099dac55a322 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Fri, 18 Oct 2024 12:34:12 -0700 Subject: [PATCH 21/23] fix(cli): make isFlagInFlagSet more robust incase it is called with '--' (#7029) ### Changes are visible to end-users: no ### Test plan CI Co-authored-by: Greg Magolan GitOrigin-RevId: 72ca500133f72b926bee8df1f476c928ea3ff0cd --- pkg/aspect/root/flags/interceptor.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/aspect/root/flags/interceptor.go b/pkg/aspect/root/flags/interceptor.go index 9939dce4a..6c2beeea1 100644 --- a/pkg/aspect/root/flags/interceptor.go +++ b/pkg/aspect/root/flags/interceptor.go @@ -36,6 +36,9 @@ func isFlagInFlagSet(flags *pflag.FlagSet, arg string) bool { var flag *pflag.Flag if arg[0] == '-' { if arg[1] == '-' { + if len(arg) <= 2 { + return false + } flag = flags.Lookup(strings.SplitN(arg[2:], "=", 2)[0]) } else { for _, s := range arg[1:] { From ac777f6d764b4f9bf64bfc1b0e7e2655a5b18026 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Sun, 20 Oct 2024 21:26:07 -0700 Subject: [PATCH 22/23] chore: resolve dependabot alerts from test case pnpm-lock files (#7128) Resolves high alerts: - https://github.com/aspect-build/silo/security/dependabot/99 - https://github.com/aspect-build/silo/security/dependabot/109 - https://github.com/aspect-build/silo/security/dependabot/113 --- ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases CI GitOrigin-RevId: 42aea24fd80f10e671935af220d64e2246323788 --- .../tests/declare_module_types/pnpm-lock.yaml | 19 - gazelle/js/tests/node_native/pnpm-lock.yaml | 6 - .../js/tests/npm_changed_deps/pnpm-lock.yaml | 10 - .../npm_link_all_packages/pnpm-lock.yaml | 8 - .../js/tests/npm_simple_deps/pnpm-lock.yaml | 39 - .../tests/npm_simple_deps_cjs/pnpm-lock.yaml | 39 - .../js/tests/npm_types_package/pnpm-lock.yaml | 18 - .../js/tests/pnpm_workspace/pnpm-lock.yaml | 64 -- .../root/pnpm-lock.yaml | 64 -- gazelle/js/tests/resolve_order/pnpm-lock.yaml | 11 - gazelle/js/tests/tsconfig_deps/pnpm-lock.yaml | 724 ------------------ gazelle/js/tests/tsconfig_jsx/pnpm-lock.yaml | 25 - 12 files changed, 1027 deletions(-) diff --git a/gazelle/js/tests/declare_module_types/pnpm-lock.yaml b/gazelle/js/tests/declare_module_types/pnpm-lock.yaml index 205b5cfba..76f568ee8 100644 --- a/gazelle/js/tests/declare_module_types/pnpm-lock.yaml +++ b/gazelle/js/tests/declare_module_types/pnpm-lock.yaml @@ -13,22 +13,3 @@ dependencies: devDependencies: '@types/jquery': 3.5.14 '@types/testing-library__jest-dom': 5.14.5 - -packages: - /@types/jquery/3.5.14: - resolution: {integrity: sha512-X1gtMRMbziVQkErhTQmSe2jFwwENA/Zr+PprCkF63vFq+Yt5PZ4AlKqgmeNlwgn7dhsXEK888eIW2520EpC+xg==} - dependencies: - '@types/sizzle': 2.3.3 - dev: true - - /@types/testing-library__jest-dom/5.14.5: - resolution: {integrity: sha512-fake-jest-dom-resolution} - dev: true - - /jquery/3.6.1: - resolution: {integrity: sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==} - dev: false - - /lodash/1.2.3: - resolution: {integrity: sha512-fake-lodash-resolution} - dev: false diff --git a/gazelle/js/tests/node_native/pnpm-lock.yaml b/gazelle/js/tests/node_native/pnpm-lock.yaml index 6f0bdd4e4..5ae191b30 100644 --- a/gazelle/js/tests/node_native/pnpm-lock.yaml +++ b/gazelle/js/tests/node_native/pnpm-lock.yaml @@ -5,9 +5,3 @@ specifiers: dependencies: '@types/node': 18.11.11 - -packages: - - /@types/node/18.11.11: - resolution: {integrity: sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g==} - dev: false \ No newline at end of file diff --git a/gazelle/js/tests/npm_changed_deps/pnpm-lock.yaml b/gazelle/js/tests/npm_changed_deps/pnpm-lock.yaml index 79303ea18..3ead8b472 100644 --- a/gazelle/js/tests/npm_changed_deps/pnpm-lock.yaml +++ b/gazelle/js/tests/npm_changed_deps/pnpm-lock.yaml @@ -7,13 +7,3 @@ specifiers: dependencies: jquery: 3.6.1 lodash: 4.17.21 - -packages: - - /jquery/3.6.1: - resolution: {integrity: sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==} - dev: false - - /lodash/4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: false diff --git a/gazelle/js/tests/npm_link_all_packages/pnpm-lock.yaml b/gazelle/js/tests/npm_link_all_packages/pnpm-lock.yaml index 48f7f5d7e..6b109e356 100644 --- a/gazelle/js/tests/npm_link_all_packages/pnpm-lock.yaml +++ b/gazelle/js/tests/npm_link_all_packages/pnpm-lock.yaml @@ -5,11 +5,3 @@ specifiers: dependencies: '@aspect-test/c': 2.0.2 - -packages: - - /@aspect-test/c/2.0.2: - resolution: {integrity: sha512-rMJmd3YBvY7y0jh+2m72TiAhe6dVKjMMNFFVOXFCbM233m7lsG4cq970H1C8rUsc3AcA5E/cEHlxSVffHlHD2Q==} - hasBin: true - requiresBuild: true - dev: false diff --git a/gazelle/js/tests/npm_simple_deps/pnpm-lock.yaml b/gazelle/js/tests/npm_simple_deps/pnpm-lock.yaml index 2b7289168..bcd994778 100644 --- a/gazelle/js/tests/npm_simple_deps/pnpm-lock.yaml +++ b/gazelle/js/tests/npm_simple_deps/pnpm-lock.yaml @@ -13,42 +13,3 @@ peerDependencies: devDependencies: jquery: 3.6.1 - -packages: - - /@aspect-test/a/5.0.2: - resolution: {integrity: sha512-bURS+F0+tS2XPxUPbrqsTZxIre1U5ZglwzDqcOCrU7MbxuRrkO24hesgTMGJldCglwL/tiEGRlvdMndlPgRdNw==} - hasBin: true - dependencies: - '@aspect-test/b': 5.0.2 - '@aspect-test/c': 2.0.2 - '@aspect-test/d': 2.0.0_@aspect-test+c@2.0.2 - dev: false - - /@aspect-test/b/5.0.2: - resolution: {integrity: sha512-I8wnJV5J0h8ui1O3K6XPq1qGHKopTl/OnvkSfor7uJ9yRCm2Qv6Tf2LsTgR2xzkgiwhA4iBwdYFwecwinF244w==} - hasBin: true - dependencies: - '@aspect-test/a': 5.0.2 - '@aspect-test/c': 2.0.2 - '@aspect-test/d': 2.0.0_@aspect-test+c@2.0.2 - dev: false - - /@aspect-test/c/2.0.2: - resolution: {integrity: sha512-rMJmd3YBvY7y0jh+2m72TiAhe6dVKjMMNFFVOXFCbM233m7lsG4cq970H1C8rUsc3AcA5E/cEHlxSVffHlHD2Q==} - hasBin: true - requiresBuild: true - dev: false - - /@aspect-test/d/2.0.0_@aspect-test+c@2.0.2: - resolution: {integrity: sha512-jndwr8pLUfn795uApTcXG/yZ5hV2At1aS/wo5BVLxqlVVgLoOETF/Dp4QOjMHE/SXkXFowz6Hao+WpmzVvAO0A==} - hasBin: true - peerDependencies: - '@aspect-test/c': x.x.x - dependencies: - '@aspect-test/c': 2.0.2 - dev: false - - /jquery/3.6.1: - resolution: {integrity: sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==} - dev: true diff --git a/gazelle/js/tests/npm_simple_deps_cjs/pnpm-lock.yaml b/gazelle/js/tests/npm_simple_deps_cjs/pnpm-lock.yaml index 2b7289168..bcd994778 100644 --- a/gazelle/js/tests/npm_simple_deps_cjs/pnpm-lock.yaml +++ b/gazelle/js/tests/npm_simple_deps_cjs/pnpm-lock.yaml @@ -13,42 +13,3 @@ peerDependencies: devDependencies: jquery: 3.6.1 - -packages: - - /@aspect-test/a/5.0.2: - resolution: {integrity: sha512-bURS+F0+tS2XPxUPbrqsTZxIre1U5ZglwzDqcOCrU7MbxuRrkO24hesgTMGJldCglwL/tiEGRlvdMndlPgRdNw==} - hasBin: true - dependencies: - '@aspect-test/b': 5.0.2 - '@aspect-test/c': 2.0.2 - '@aspect-test/d': 2.0.0_@aspect-test+c@2.0.2 - dev: false - - /@aspect-test/b/5.0.2: - resolution: {integrity: sha512-I8wnJV5J0h8ui1O3K6XPq1qGHKopTl/OnvkSfor7uJ9yRCm2Qv6Tf2LsTgR2xzkgiwhA4iBwdYFwecwinF244w==} - hasBin: true - dependencies: - '@aspect-test/a': 5.0.2 - '@aspect-test/c': 2.0.2 - '@aspect-test/d': 2.0.0_@aspect-test+c@2.0.2 - dev: false - - /@aspect-test/c/2.0.2: - resolution: {integrity: sha512-rMJmd3YBvY7y0jh+2m72TiAhe6dVKjMMNFFVOXFCbM233m7lsG4cq970H1C8rUsc3AcA5E/cEHlxSVffHlHD2Q==} - hasBin: true - requiresBuild: true - dev: false - - /@aspect-test/d/2.0.0_@aspect-test+c@2.0.2: - resolution: {integrity: sha512-jndwr8pLUfn795uApTcXG/yZ5hV2At1aS/wo5BVLxqlVVgLoOETF/Dp4QOjMHE/SXkXFowz6Hao+WpmzVvAO0A==} - hasBin: true - peerDependencies: - '@aspect-test/c': x.x.x - dependencies: - '@aspect-test/c': 2.0.2 - dev: false - - /jquery/3.6.1: - resolution: {integrity: sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==} - dev: true diff --git a/gazelle/js/tests/npm_types_package/pnpm-lock.yaml b/gazelle/js/tests/npm_types_package/pnpm-lock.yaml index 93a5ca5d8..1ac7beed5 100644 --- a/gazelle/js/tests/npm_types_package/pnpm-lock.yaml +++ b/gazelle/js/tests/npm_types_package/pnpm-lock.yaml @@ -9,21 +9,3 @@ dependencies: '@types/jquery': 3.5.14 '@types/testing-library__jest-dom': 5.14.5 jquery: 3.6.1 - -packages: - /@types/jest/29.2.5: - resolution: {integrity: sha512-H2cSxkKgVmqNHXP7TC2L/WUorrZu8ZigyRywfVzv6EyBlxj39n4C00hjXYQWsbwqgElaj/CiAeSRmk5GoaKTgw==} - dependencies: - expect: 29.3.1 - pretty-format: 29.3.1 - dev: false - - /@types/testing-library__jest-dom/5.14.5: - resolution: {integrity: sha512-SBwbxYoyPIvxHbeHxTZX2Pe/74F/tX2/D3mMvzabdeJ25bBojfW0TyB8BHrbq/9zaaKICJZjLP+8r6AeZMFCuQ==} - dependencies: - '@types/jest': 29.2.5 - dev: false - - /jquery/3.6.1: - resolution: {integrity: sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==} - dev: false diff --git a/gazelle/js/tests/pnpm_workspace/pnpm-lock.yaml b/gazelle/js/tests/pnpm_workspace/pnpm-lock.yaml index aedd02db5..90ea545e1 100644 --- a/gazelle/js/tests/pnpm_workspace/pnpm-lock.yaml +++ b/gazelle/js/tests/pnpm_workspace/pnpm-lock.yaml @@ -73,67 +73,3 @@ importers: dependencies: '@lib/b': link:../b typescript: 4.9.5 - -packages: - - /@aspect-test/a/5.0.2: - resolution: {integrity: sha512-bURS+F0+tS2XPxUPbrqsTZxIre1U5ZglwzDqcOCrU7MbxuRrkO24hesgTMGJldCglwL/tiEGRlvdMndlPgRdNw==} - hasBin: true - dependencies: - '@aspect-test/b': 5.0.2 - '@aspect-test/c': 2.0.2 - '@aspect-test/d': 2.0.0_@aspect-test+c@2.0.2 - - /@aspect-test/b/5.0.2: - resolution: {integrity: sha512-I8wnJV5J0h8ui1O3K6XPq1qGHKopTl/OnvkSfor7uJ9yRCm2Qv6Tf2LsTgR2xzkgiwhA4iBwdYFwecwinF244w==} - hasBin: true - dependencies: - '@aspect-test/a': 5.0.2 - '@aspect-test/c': 2.0.2 - '@aspect-test/d': 2.0.0_@aspect-test+c@2.0.2 - - /@aspect-test/c/2.0.2: - resolution: {integrity: sha512-rMJmd3YBvY7y0jh+2m72TiAhe6dVKjMMNFFVOXFCbM233m7lsG4cq970H1C8rUsc3AcA5E/cEHlxSVffHlHD2Q==} - hasBin: true - requiresBuild: true - - /@aspect-test/d/2.0.0_@aspect-test+c@2.0.2: - resolution: {integrity: sha512-jndwr8pLUfn795uApTcXG/yZ5hV2At1aS/wo5BVLxqlVVgLoOETF/Dp4QOjMHE/SXkXFowz6Hao+WpmzVvAO0A==} - hasBin: true - peerDependencies: - '@aspect-test/c': x.x.x - dependencies: - '@aspect-test/c': 2.0.2 - - /@aspect-test/e/1.0.0: - resolution: {integrity: sha512-GyAxHYKN650db+xnimHnL2LPz65ilmQsVhCasWA7drDNQn/rfmPiEVMzjRiS7m46scXIERaBmiJMzYDf0bIUbA==} - hasBin: true - dev: false - - /@aspect-test/f/1.0.0: - resolution: {integrity: sha512-VjuHu/TXdK0dfMeArZoOFaBY0Z/wAjWuCNtEWDTVJftbDcBtcH3IrhLrOy0NdJu+/CjE0qLCEb78eDGniKNUFA==} - hasBin: true - dev: false - - /@aspect-test/g/1.0.0: - resolution: {integrity: sha512-nYxZCTIw+sHZfuKsqBBL7CW3KOliEoQh0D/ynWyUoB2Vi+DT2+nuvghXqL70/eNegjQ/8hUNTRBDBN2CPgoY8A==} - hasBin: true - dev: false - - /@aspect-test/h/1.0.0: - resolution: {integrity: sha512-U1LStvh2QPmdQN7rlR0PTZZ1btTTcjiHxVmq5SvTxIRgIaJMCIsxcS5ghrd71H/JIwnJOmhI7BEQN3n6Hq9WSw==} - hasBin: true - dev: false - - /typescript/4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} - hasBin: true - dev: false - - file:lib/c: - resolution: {directory: lib/c, type: directory} - name: '@lib/c' - dependencies: - '@aspect-test/f': 1.0.0 - dev: false diff --git a/gazelle/js/tests/pnpm_workspace_rerooted/root/pnpm-lock.yaml b/gazelle/js/tests/pnpm_workspace_rerooted/root/pnpm-lock.yaml index 46273a5ff..9f1748963 100644 --- a/gazelle/js/tests/pnpm_workspace_rerooted/root/pnpm-lock.yaml +++ b/gazelle/js/tests/pnpm_workspace_rerooted/root/pnpm-lock.yaml @@ -76,67 +76,3 @@ importers: dependencies: '@lib/b': link:../b typescript: 4.9.3 - -packages: - - /@aspect-test/a/5.0.2: - resolution: {integrity: sha512-bURS+F0+tS2XPxUPbrqsTZxIre1U5ZglwzDqcOCrU7MbxuRrkO24hesgTMGJldCglwL/tiEGRlvdMndlPgRdNw==} - hasBin: true - dependencies: - '@aspect-test/b': 5.0.2 - '@aspect-test/c': 2.0.2 - '@aspect-test/d': 2.0.0_@aspect-test+c@2.0.2 - - /@aspect-test/b/5.0.2: - resolution: {integrity: sha512-I8wnJV5J0h8ui1O3K6XPq1qGHKopTl/OnvkSfor7uJ9yRCm2Qv6Tf2LsTgR2xzkgiwhA4iBwdYFwecwinF244w==} - hasBin: true - dependencies: - '@aspect-test/a': 5.0.2 - '@aspect-test/c': 2.0.2 - '@aspect-test/d': 2.0.0_@aspect-test+c@2.0.2 - - /@aspect-test/c/2.0.2: - resolution: {integrity: sha512-rMJmd3YBvY7y0jh+2m72TiAhe6dVKjMMNFFVOXFCbM233m7lsG4cq970H1C8rUsc3AcA5E/cEHlxSVffHlHD2Q==} - hasBin: true - requiresBuild: true - - /@aspect-test/d/2.0.0_@aspect-test+c@2.0.2: - resolution: {integrity: sha512-jndwr8pLUfn795uApTcXG/yZ5hV2At1aS/wo5BVLxqlVVgLoOETF/Dp4QOjMHE/SXkXFowz6Hao+WpmzVvAO0A==} - hasBin: true - peerDependencies: - '@aspect-test/c': x.x.x - dependencies: - '@aspect-test/c': 2.0.2 - - /@aspect-test/e/1.0.0: - resolution: {integrity: sha512-GyAxHYKN650db+xnimHnL2LPz65ilmQsVhCasWA7drDNQn/rfmPiEVMzjRiS7m46scXIERaBmiJMzYDf0bIUbA==} - hasBin: true - dev: false - - /@aspect-test/f/1.0.0: - resolution: {integrity: sha512-VjuHu/TXdK0dfMeArZoOFaBY0Z/wAjWuCNtEWDTVJftbDcBtcH3IrhLrOy0NdJu+/CjE0qLCEb78eDGniKNUFA==} - hasBin: true - dev: false - - /@aspect-test/g/1.0.0: - resolution: {integrity: sha512-nYxZCTIw+sHZfuKsqBBL7CW3KOliEoQh0D/ynWyUoB2Vi+DT2+nuvghXqL70/eNegjQ/8hUNTRBDBN2CPgoY8A==} - hasBin: true - dev: false - - /@aspect-test/h/1.0.0: - resolution: {integrity: sha512-U1LStvh2QPmdQN7rlR0PTZZ1btTTcjiHxVmq5SvTxIRgIaJMCIsxcS5ghrd71H/JIwnJOmhI7BEQN3n6Hq9WSw==} - hasBin: true - dev: false - - /typescript/4.9.3: - resolution: {integrity: sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==} - engines: {node: '>=4.2.0'} - hasBin: true - dev: false - - file:../lib/c: - resolution: {directory: ../lib/c, type: directory} - name: '@lib/c' - dependencies: - '@aspect-test/f': 1.0.0 - dev: false diff --git a/gazelle/js/tests/resolve_order/pnpm-lock.yaml b/gazelle/js/tests/resolve_order/pnpm-lock.yaml index 573fbe884..425049a48 100644 --- a/gazelle/js/tests/resolve_order/pnpm-lock.yaml +++ b/gazelle/js/tests/resolve_order/pnpm-lock.yaml @@ -9,14 +9,3 @@ dependencies: '@types/node': 18.11.11 '@types/the-import': 1.0.0 'the-import': 1.0.0 - -packages: - - /@types/node/18.11.11: - resolution: {integrity: fake} - - /@types/the-import/1.0.0: - resolution: {integrity: fake} - - /the-import/1.0.0:: - resolution: {integrity: fake} \ No newline at end of file diff --git a/gazelle/js/tests/tsconfig_deps/pnpm-lock.yaml b/gazelle/js/tests/tsconfig_deps/pnpm-lock.yaml index c8a9a0052..7cb0f5a20 100644 --- a/gazelle/js/tests/tsconfig_deps/pnpm-lock.yaml +++ b/gazelle/js/tests/tsconfig_deps/pnpm-lock.yaml @@ -11,727 +11,3 @@ dependencies: '@types/jquery': 3.5.14 '@types/testing-library__jest-dom': 5.14.5 jquery: 3.6.1 - -packages: - - /@babel/code-frame/7.18.6: - resolution: {integrity: sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.18.6 - dev: false - - /@babel/helper-validator-identifier/7.19.1: - resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} - engines: {node: '>=6.9.0'} - dev: false - - /@babel/highlight/7.18.6: - resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-validator-identifier': 7.19.1 - chalk: 2.4.2 - js-tokens: 4.0.0 - dev: false - - /@babel/runtime/7.20.7: - resolution: {integrity: sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ==} - engines: {node: '>=6.9.0'} - dependencies: - regenerator-runtime: 0.13.11 - dev: false - - /@jest/expect-utils/29.3.1: - resolution: {integrity: sha512-wlrznINZI5sMjwvUoLVk617ll/UYfGIZNxmbU+Pa7wmkL4vYzhV9R2pwVqUh4NWWuLQWkI8+8mOkxs//prKQ3g==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - jest-get-type: 29.2.0 - dev: false - - /@jest/schemas/29.0.0: - resolution: {integrity: sha512-3Ab5HgYIIAnS0HjqJHQYZS+zXc4tUmTmBH3z83ajI6afXp8X3ZtdLX+nXx+I7LNkJD7uN9LAVhgnjDgZa2z0kA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - '@sinclair/typebox': 0.24.51 - dev: false - - /@jest/types/29.3.1: - resolution: {integrity: sha512-d0S0jmmTpjnhCmNpApgX3jrUZgZ22ivKJRvL2lli5hpCRoNnp1f85r2/wpKfXuYu8E7Jjh1hGfhPyup1NM5AmA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - '@jest/schemas': 29.0.0 - '@types/istanbul-lib-coverage': 2.0.4 - '@types/istanbul-reports': 3.0.1 - '@types/node': 18.11.18 - '@types/yargs': 17.0.19 - chalk: 4.1.2 - dev: false - - /@sinclair/typebox/0.24.51: - resolution: {integrity: sha512-1P1OROm/rdubP5aFDSZQILU0vrLCJ4fvHt6EoqHEM+2D/G5MK3bIaymUKLit8Js9gbns5UyJnkP/TZROLw4tUA==} - dev: false - - /@testing-library/jest-dom/5.16.5: - resolution: {integrity: sha512-N5ixQ2qKpi5OLYfwQmUb/5mSV9LneAcaUfp32pn4yCnpb8r/Yz0pXFPck21dIicKmi+ta5WRAknkZCfA8refMA==} - engines: {node: '>=8', npm: '>=6', yarn: '>=1'} - dependencies: - '@babel/runtime': 7.20.7 - '@types/testing-library__jest-dom': 5.14.5 - aria-query: 5.1.3 - chalk: 3.0.0 - css.escape: 1.5.1 - dom-accessibility-api: 0.5.15 - lodash: 4.17.21 - redent: 3.0.0 - dev: false - - /@types/istanbul-lib-coverage/2.0.4: - resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==} - dev: false - - /@types/istanbul-lib-report/3.0.0: - resolution: {integrity: sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==} - dependencies: - '@types/istanbul-lib-coverage': 2.0.4 - dev: false - - /@types/istanbul-reports/3.0.1: - resolution: {integrity: sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==} - dependencies: - '@types/istanbul-lib-report': 3.0.0 - dev: false - - /@types/jest/29.2.5: - resolution: {integrity: sha512-H2cSxkKgVmqNHXP7TC2L/WUorrZu8ZigyRywfVzv6EyBlxj39n4C00hjXYQWsbwqgElaj/CiAeSRmk5GoaKTgw==} - dependencies: - expect: 29.3.1 - pretty-format: 29.3.1 - dev: false - - /@types/jquery/3.5.14: - resolution: {integrity: sha512-X1gtMRMbziVQkErhTQmSe2jFwwENA/Zr+PprCkF63vFq+Yt5PZ4AlKqgmeNlwgn7dhsXEK888eIW2520EpC+xg==} - dependencies: - '@types/sizzle': 2.3.3 - dev: false - - /@types/node/18.11.18: - resolution: {integrity: sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==} - dev: false - - /@types/sizzle/2.3.3: - resolution: {integrity: sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==} - dev: false - - /@types/stack-utils/2.0.1: - resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==} - dev: false - - /@types/testing-library__jest-dom/5.14.5: - resolution: {integrity: sha512-SBwbxYoyPIvxHbeHxTZX2Pe/74F/tX2/D3mMvzabdeJ25bBojfW0TyB8BHrbq/9zaaKICJZjLP+8r6AeZMFCuQ==} - dependencies: - '@types/jest': 29.2.5 - dev: false - - /@types/yargs-parser/21.0.0: - resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==} - dev: false - - /@types/yargs/17.0.19: - resolution: {integrity: sha512-cAx3qamwaYX9R0fzOIZAlFpo4A+1uBVCxqpKz9D26uTF4srRXaGTTsikQmaotCtNdbhzyUH7ft6p9ktz9s6UNQ==} - dependencies: - '@types/yargs-parser': 21.0.0 - dev: false - - /ansi-styles/3.2.1: - resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} - engines: {node: '>=4'} - dependencies: - color-convert: 1.9.3 - dev: false - - /ansi-styles/4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} - dependencies: - color-convert: 2.0.1 - dev: false - - /ansi-styles/5.2.0: - resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} - engines: {node: '>=10'} - dev: false - - /aria-query/5.1.3: - resolution: {integrity: sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==} - dependencies: - deep-equal: 2.2.0 - dev: false - - /available-typed-arrays/1.0.5: - resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} - engines: {node: '>= 0.4'} - dev: false - - /braces/3.0.2: - resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} - engines: {node: '>=8'} - dependencies: - fill-range: 7.0.1 - dev: false - - /call-bind/1.0.2: - resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} - dependencies: - function-bind: 1.1.1 - get-intrinsic: 1.1.3 - dev: false - - /chalk/2.4.2: - resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} - engines: {node: '>=4'} - dependencies: - ansi-styles: 3.2.1 - escape-string-regexp: 1.0.5 - supports-color: 5.5.0 - dev: false - - /chalk/3.0.0: - resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==} - engines: {node: '>=8'} - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - dev: false - - /chalk/4.1.2: - resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - dev: false - - /ci-info/3.7.1: - resolution: {integrity: sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w==} - engines: {node: '>=8'} - dev: false - - /color-convert/1.9.3: - resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} - dependencies: - color-name: 1.1.3 - dev: false - - /color-convert/2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} - dependencies: - color-name: 1.1.4 - dev: false - - /color-name/1.1.3: - resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} - dev: false - - /color-name/1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: false - - /css.escape/1.5.1: - resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==} - dev: false - - /deep-equal/2.2.0: - resolution: {integrity: sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw==} - dependencies: - call-bind: 1.0.2 - es-get-iterator: 1.1.2 - get-intrinsic: 1.1.3 - is-arguments: 1.1.1 - is-array-buffer: 3.0.1 - is-date-object: 1.0.5 - is-regex: 1.1.4 - is-shared-array-buffer: 1.0.2 - isarray: 2.0.5 - object-is: 1.1.5 - object-keys: 1.1.1 - object.assign: 4.1.4 - regexp.prototype.flags: 1.4.3 - side-channel: 1.0.4 - which-boxed-primitive: 1.0.2 - which-collection: 1.0.1 - which-typed-array: 1.1.9 - dev: false - - /define-properties/1.1.4: - resolution: {integrity: sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==} - engines: {node: '>= 0.4'} - dependencies: - has-property-descriptors: 1.0.0 - object-keys: 1.1.1 - dev: false - - /diff-sequences/29.3.1: - resolution: {integrity: sha512-hlM3QR272NXCi4pq+N4Kok4kOp6EsgOM3ZSpJI7Da3UAs+Ttsi8MRmB6trM/lhyzUxGfOgnpkHtgqm5Q/CTcfQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dev: false - - /dom-accessibility-api/0.5.15: - resolution: {integrity: sha512-8o+oVqLQZoruQPYy3uAAQtc6YbtSiRq5aPJBhJ82YTJRHvI6ofhYAkC81WmjFTnfUbqg6T3aCglIpU9p/5e7Cw==} - dev: false - - /es-get-iterator/1.1.2: - resolution: {integrity: sha512-+DTO8GYwbMCwbywjimwZMHp8AuYXOS2JZFWoi2AlPOS3ebnII9w/NLpNZtA7A0YLaVDw+O7KFCeoIV7OPvM7hQ==} - dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.1.3 - has-symbols: 1.0.3 - is-arguments: 1.1.1 - is-map: 2.0.2 - is-set: 2.0.2 - is-string: 1.0.7 - isarray: 2.0.5 - dev: false - - /escape-string-regexp/1.0.5: - resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} - engines: {node: '>=0.8.0'} - dev: false - - /escape-string-regexp/2.0.0: - resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} - engines: {node: '>=8'} - dev: false - - /expect/29.3.1: - resolution: {integrity: sha512-gGb1yTgU30Q0O/tQq+z30KBWv24ApkMgFUpvKBkyLUBL68Wv8dHdJxTBZFl/iT8K/bqDHvUYRH6IIN3rToopPA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - '@jest/expect-utils': 29.3.1 - jest-get-type: 29.2.0 - jest-matcher-utils: 29.3.1 - jest-message-util: 29.3.1 - jest-util: 29.3.1 - dev: false - - /fill-range/7.0.1: - resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} - engines: {node: '>=8'} - dependencies: - to-regex-range: 5.0.1 - dev: false - - /for-each/0.3.3: - resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} - dependencies: - is-callable: 1.2.7 - dev: false - - /function-bind/1.1.1: - resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} - dev: false - - /functions-have-names/1.2.3: - resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} - dev: false - - /get-intrinsic/1.1.3: - resolution: {integrity: sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==} - dependencies: - function-bind: 1.1.1 - has: 1.0.3 - has-symbols: 1.0.3 - dev: false - - /gopd/1.0.1: - resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} - dependencies: - get-intrinsic: 1.1.3 - dev: false - - /graceful-fs/4.2.10: - resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} - dev: false - - /has-bigints/1.0.2: - resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} - dev: false - - /has-flag/3.0.0: - resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} - engines: {node: '>=4'} - dev: false - - /has-flag/4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - dev: false - - /has-property-descriptors/1.0.0: - resolution: {integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==} - dependencies: - get-intrinsic: 1.1.3 - dev: false - - /has-symbols/1.0.3: - resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} - engines: {node: '>= 0.4'} - dev: false - - /has-tostringtag/1.0.0: - resolution: {integrity: sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==} - engines: {node: '>= 0.4'} - dependencies: - has-symbols: 1.0.3 - dev: false - - /has/1.0.3: - resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} - engines: {node: '>= 0.4.0'} - dependencies: - function-bind: 1.1.1 - dev: false - - /indent-string/4.0.0: - resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} - engines: {node: '>=8'} - dev: false - - /is-arguments/1.1.1: - resolution: {integrity: sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - has-tostringtag: 1.0.0 - dev: false - - /is-array-buffer/3.0.1: - resolution: {integrity: sha512-ASfLknmY8Xa2XtB4wmbz13Wu202baeA18cJBCeCy0wXUHZF0IPyVEXqKEcd+t2fNSLLL1vC6k7lxZEojNbISXQ==} - dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.1.3 - is-typed-array: 1.1.10 - dev: false - - /is-bigint/1.0.4: - resolution: {integrity: sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==} - dependencies: - has-bigints: 1.0.2 - dev: false - - /is-boolean-object/1.1.2: - resolution: {integrity: sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - has-tostringtag: 1.0.0 - dev: false - - /is-callable/1.2.7: - resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} - engines: {node: '>= 0.4'} - dev: false - - /is-date-object/1.0.5: - resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==} - engines: {node: '>= 0.4'} - dependencies: - has-tostringtag: 1.0.0 - dev: false - - /is-map/2.0.2: - resolution: {integrity: sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==} - dev: false - - /is-number-object/1.0.7: - resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==} - engines: {node: '>= 0.4'} - dependencies: - has-tostringtag: 1.0.0 - dev: false - - /is-number/7.0.0: - resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} - engines: {node: '>=0.12.0'} - dev: false - - /is-regex/1.1.4: - resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - has-tostringtag: 1.0.0 - dev: false - - /is-set/2.0.2: - resolution: {integrity: sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==} - dev: false - - /is-shared-array-buffer/1.0.2: - resolution: {integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==} - dependencies: - call-bind: 1.0.2 - dev: false - - /is-string/1.0.7: - resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} - engines: {node: '>= 0.4'} - dependencies: - has-tostringtag: 1.0.0 - dev: false - - /is-symbol/1.0.4: - resolution: {integrity: sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==} - engines: {node: '>= 0.4'} - dependencies: - has-symbols: 1.0.3 - dev: false - - /is-typed-array/1.1.10: - resolution: {integrity: sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==} - engines: {node: '>= 0.4'} - dependencies: - available-typed-arrays: 1.0.5 - call-bind: 1.0.2 - for-each: 0.3.3 - gopd: 1.0.1 - has-tostringtag: 1.0.0 - dev: false - - /is-weakmap/2.0.1: - resolution: {integrity: sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==} - dev: false - - /is-weakset/2.0.2: - resolution: {integrity: sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==} - dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.1.3 - dev: false - - /isarray/2.0.5: - resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} - dev: false - - /jest-diff/29.3.1: - resolution: {integrity: sha512-vU8vyiO7568tmin2lA3r2DP8oRvzhvRcD4DjpXc6uGveQodyk7CKLhQlCSiwgx3g0pFaE88/KLZ0yaTWMc4Uiw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - chalk: 4.1.2 - diff-sequences: 29.3.1 - jest-get-type: 29.2.0 - pretty-format: 29.3.1 - dev: false - - /jest-get-type/29.2.0: - resolution: {integrity: sha512-uXNJlg8hKFEnDgFsrCjznB+sTxdkuqiCL6zMgA75qEbAJjJYTs9XPrvDctrEig2GDow22T/LvHgO57iJhXB/UA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dev: false - - /jest-matcher-utils/29.3.1: - resolution: {integrity: sha512-fkRMZUAScup3txIKfMe3AIZZmPEjWEdsPJFK3AIy5qRohWqQFg1qrmKfYXR9qEkNc7OdAu2N4KPHibEmy4HPeQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - chalk: 4.1.2 - jest-diff: 29.3.1 - jest-get-type: 29.2.0 - pretty-format: 29.3.1 - dev: false - - /jest-message-util/29.3.1: - resolution: {integrity: sha512-lMJTbgNcDm5z+6KDxWtqOFWlGQxD6XaYwBqHR8kmpkP+WWWG90I35kdtQHY67Ay5CSuydkTBbJG+tH9JShFCyA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - '@babel/code-frame': 7.18.6 - '@jest/types': 29.3.1 - '@types/stack-utils': 2.0.1 - chalk: 4.1.2 - graceful-fs: 4.2.10 - micromatch: 4.0.5 - pretty-format: 29.3.1 - slash: 3.0.0 - stack-utils: 2.0.6 - dev: false - - /jest-util/29.3.1: - resolution: {integrity: sha512-7YOVZaiX7RJLv76ZfHt4nbNEzzTRiMW/IiOG7ZOKmTXmoGBxUDefgMAxQubu6WPVqP5zSzAdZG0FfLcC7HOIFQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - '@jest/types': 29.3.1 - '@types/node': 18.11.18 - chalk: 4.1.2 - ci-info: 3.7.1 - graceful-fs: 4.2.10 - picomatch: 2.3.1 - dev: false - - /jquery/3.6.1: - resolution: {integrity: sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==} - dev: false - - /js-tokens/4.0.0: - resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - dev: false - - /lodash/4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: false - - /micromatch/4.0.5: - resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} - engines: {node: '>=8.6'} - dependencies: - braces: 3.0.2 - picomatch: 2.3.1 - dev: false - - /min-indent/1.0.1: - resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} - engines: {node: '>=4'} - dev: false - - /object-inspect/1.12.2: - resolution: {integrity: sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==} - dev: false - - /object-is/1.1.5: - resolution: {integrity: sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.4 - dev: false - - /object-keys/1.1.1: - resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} - engines: {node: '>= 0.4'} - dev: false - - /object.assign/4.1.4: - resolution: {integrity: sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.4 - has-symbols: 1.0.3 - object-keys: 1.1.1 - dev: false - - /picomatch/2.3.1: - resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} - engines: {node: '>=8.6'} - dev: false - - /pretty-format/29.3.1: - resolution: {integrity: sha512-FyLnmb1cYJV8biEIiRyzRFvs2lry7PPIvOqKVe1GCUEYg4YGmlx1qG9EJNMxArYm7piII4qb8UV1Pncq5dxmcg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dependencies: - '@jest/schemas': 29.0.0 - ansi-styles: 5.2.0 - react-is: 18.2.0 - dev: false - - /react-is/18.2.0: - resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} - dev: false - - /redent/3.0.0: - resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} - engines: {node: '>=8'} - dependencies: - indent-string: 4.0.0 - strip-indent: 3.0.0 - dev: false - - /regenerator-runtime/0.13.11: - resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} - dev: false - - /regexp.prototype.flags/1.4.3: - resolution: {integrity: sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.4 - functions-have-names: 1.2.3 - dev: false - - /side-channel/1.0.4: - resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} - dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.1.3 - object-inspect: 1.12.2 - dev: false - - /slash/3.0.0: - resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} - engines: {node: '>=8'} - dev: false - - /stack-utils/2.0.6: - resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} - engines: {node: '>=10'} - dependencies: - escape-string-regexp: 2.0.0 - dev: false - - /strip-indent/3.0.0: - resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} - engines: {node: '>=8'} - dependencies: - min-indent: 1.0.1 - dev: false - - /supports-color/5.5.0: - resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} - engines: {node: '>=4'} - dependencies: - has-flag: 3.0.0 - dev: false - - /supports-color/7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} - dependencies: - has-flag: 4.0.0 - dev: false - - /to-regex-range/5.0.1: - resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} - engines: {node: '>=8.0'} - dependencies: - is-number: 7.0.0 - dev: false - - /which-boxed-primitive/1.0.2: - resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} - dependencies: - is-bigint: 1.0.4 - is-boolean-object: 1.1.2 - is-number-object: 1.0.7 - is-string: 1.0.7 - is-symbol: 1.0.4 - dev: false - - /which-collection/1.0.1: - resolution: {integrity: sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==} - dependencies: - is-map: 2.0.2 - is-set: 2.0.2 - is-weakmap: 2.0.1 - is-weakset: 2.0.2 - dev: false - - /which-typed-array/1.1.9: - resolution: {integrity: sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==} - engines: {node: '>= 0.4'} - dependencies: - available-typed-arrays: 1.0.5 - call-bind: 1.0.2 - for-each: 0.3.3 - gopd: 1.0.1 - has-tostringtag: 1.0.0 - is-typed-array: 1.1.10 - dev: false diff --git a/gazelle/js/tests/tsconfig_jsx/pnpm-lock.yaml b/gazelle/js/tests/tsconfig_jsx/pnpm-lock.yaml index 2e7901fab..9c7e54646 100644 --- a/gazelle/js/tests/tsconfig_jsx/pnpm-lock.yaml +++ b/gazelle/js/tests/tsconfig_jsx/pnpm-lock.yaml @@ -11,28 +11,3 @@ importers: react: specifier: ^18.3.1 version: 18.3.1 - -packages: - - js-tokens@4.0.0: - resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - - loose-envify@1.4.0: - resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} - hasBin: true - - react@18.3.1: - resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==} - engines: {node: '>=0.10.0'} - -snapshots: - - js-tokens@4.0.0: {} - - loose-envify@1.4.0: - dependencies: - js-tokens: 4.0.0 - - react@18.3.1: - dependencies: - loose-envify: 1.4.0 From 8376606def6407b98b48b566cbec86f7a03c0a3b Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Tue, 22 Oct 2024 16:07:48 -0700 Subject: [PATCH 23/23] perf(cli): pre-validate aspect-configure glob patterns (#7135) See https://github.com/bmatcuk/doublestar/issues/92 - each time a glob is executed it gets validated if it does not successfully match a path. This now validates it once up front and then avoids re-validating on every (non-matched) glob invocation. --- ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: yes `aspect configure` glob patterns are now validated once up front instead of per evaluation. ### Test plan - Covered by existing test cases GitOrigin-RevId: 82135c3f6342ea0893d5701b6bb4cfc451e6fe0b --- gazelle/js/config.go | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/gazelle/js/config.go b/gazelle/js/config.go index 2d557f9d2..bef33babc 100644 --- a/gazelle/js/config.go +++ b/gazelle/js/config.go @@ -315,6 +315,11 @@ func (c *JsGazelleConfig) PnpmLockfile() string { // a given package. Adding an ignored dependency to a package also makes it // ignored on a subpackage. func (c *JsGazelleConfig) AddIgnoredImport(impGlob string) { + if !doublestar.ValidatePattern(impGlob) { + fmt.Println("Invalid js ignore import glob: ", impGlob) + return + } + c.ignoreDependencies = append(c.ignoreDependencies, impGlob) } @@ -324,14 +329,7 @@ func (c *JsGazelleConfig) IsImportIgnored(impt string) bool { config := c for config != nil { for _, glob := range config.ignoreDependencies { - m, e := doublestar.Match(glob, impt) - - if e != nil { - fmt.Println("Ignore import glob error: ", e) - return false - } - - if m { + if doublestar.MatchUnvalidated(glob, impt) { return true } } @@ -343,6 +341,11 @@ func (c *JsGazelleConfig) IsImportIgnored(impt string) bool { } func (c *JsGazelleConfig) AddResolve(imprt string, label *label.Label) { + if !doublestar.ValidatePattern(imprt) { + fmt.Println("Invalid js resolve glob: ", imprt) + return + } + c.resolves.Put(imprt, label) } @@ -350,13 +353,7 @@ func (c *JsGazelleConfig) GetResolution(imprt string) *label.Label { config := c for config != nil { for _, glob := range config.resolves.Keys() { - m, e := doublestar.Match(glob.(string), imprt) - if e != nil { - fmt.Println("Resolve import glob error: ", e) - return nil - } - - if m { + if doublestar.MatchUnvalidated(glob.(string), imprt) { resolveLabel, _ := config.resolves.Get(glob) return resolveLabel.(*label.Label) } @@ -451,13 +448,8 @@ func (c *JsGazelleConfig) GetFileSourceTarget(filePath, rootDir string) *TargetG for _, globTmpl := range sources { glob := path.Clean(strings.Replace(globTmpl, rootDirVar, rootDir, 1)) - m, e := doublestar.Match(glob, filePath) - if e != nil { - log.Fatalf("Target (%s) glob error: %v", target.name, e) - os.Exit(1) - } - if m { + if doublestar.MatchUnvalidated(glob, filePath) { return target } } @@ -497,6 +489,13 @@ func (c *JsGazelleConfig) addTargetGlob(targetName, glob string, isTestOnly bool log.Fatalf("Custom %s target %s:%s can not override %s target", targetWord, c.rel, targetName, overrideWord) os.Exit(1) } + + if !doublestar.ValidatePattern(glob) { + log.Fatalf("Invalid target (%s) glob: %v", target.name, glob) + os.Exit(1) + return + } + target.customSources = append(target.customSources, glob) return }